diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c5ba407cb221ca6938afb4306e591378ad8db33 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.Cubature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.DensitySynthesis +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerApproximation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerInitialBox +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerRegisters +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerTrajectory +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowActualBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowActualFirstBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowCompactExtension +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowDeterminant +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowFirstBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowGlobalExistence +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowGlobalRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowHigherComposition +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowImplicit +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowIntervalUniqueness +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowJacobianVariation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowJetCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowJetGronwall +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowJetVariation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLiouville +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLocal +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLocalBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLocalDomain +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLocalEquation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowLocalModel +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowMixedDerivative +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowPathEquation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowPathFamily +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowPathJets +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowSliceBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowSpatialRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowUniform +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.FlowVariational +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussEightNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussLocal +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussLocalPositionCell +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussPhysicalCell +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussPositionCell +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussTensorError +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserChargeBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserCoordinateDifferences +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserDifferenceBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserEndpoint +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserFlow +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserFlowRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserFlux +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserGridPotential +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserIntegrability +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserIntegralBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserInverse +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserJacobian +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserNumericalBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserTransport +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserUniformDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserUniformInverse +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserUniformVelocity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserVelocityNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCoordinateOutput +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCross +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCutoff +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridPotential +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearMeshBalance +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearMultiplier +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearNearEstimate +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPacking +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPerturbedComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPromise +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearQuadratureScale +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearRounding +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearTensorCompression +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.RoundedEuler +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.RoundingPolynomialBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabBoxResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabBoxSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabConfinement +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabHighAspectRatio +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabInterior +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabKernelEstimates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabLineFlatness +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabLineIntegral +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabMonotonicity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOriginQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOriginSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOriginValue +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabPlanarIntegral +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabPlanarTail +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabPolynomialResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabProfile +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularization +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabResidualScale +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabSections +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabVerticalCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedCoulombDerivative +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedFarQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedHybrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNearForm +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNearGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNodes diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabResidualScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabResidualScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6475bf2f262c072df87115623ce941295f78a4b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabResidualScale.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOrbitalResidual + +namespace OAI + +/-! A polynomial choice of slab dimensions makes the actual orbital +residual small. The twenty-fourth moment absorbs the total slab mass. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem slabDomain_volume {H S : ℝ} (hH : 0 ≤ H) (hS : 0 ≤ S) : + volume.real (slabDomain H S) = 8*H^2*S := by + have h := (slabProduct_measurePreserving H S).measureReal_preimage + (s := Set.univ) MeasurableSet.univ.nullMeasurableSet + rw [Set.preimage_univ, measureReal_restrict_apply_univ] at h + rw [← h, Measure.real, slabProductMeasure, Measure.pi_univ, Fin.prod_univ_three, + ENNReal.toReal_mul, ENNReal.toReal_mul] + simp only [slabAxisMeasure, Measure.restrict_apply_univ, Real.volume_Icc] + norm_num [slabSide, ENNReal.toReal_ofReal, hH, hS] + ring + +def slabGrowthConstant (rho : ℝ) : ℝ := + rho*(|NeutralAtom.kernelBallMass 1|+8) + +theorem slabUniformBound_polynomial {rho T : ℝ} (hrho : 0 ≤ rho) (hT : 1 ≤ T) : + slabUniformBound rho (T^4) T ≤ slabGrowthConstant rho*T^9 := by + rw [slabUniformBound, slabDomain_volume (by positivity) (by linarith)] + have hp : 1 ≤ T^9 := one_le_pow₀ hT + have h1 : rho*NeutralAtom.kernelBallMass 1 ≤ rho*|NeutralAtom.kernelBallMass 1| *T^9 := by + calc + _ ≤ rho*|NeutralAtom.kernelBallMass 1| := mul_le_mul_of_nonneg_left (le_abs_self _) hrho + _ ≤ _ := le_mul_of_one_le_right (mul_nonneg hrho (abs_nonneg _)) hp + dsimp [slabGrowthConstant] + nlinarith only [h1] + +def slabResidualPolynomialBound (rho freq : ℝ) (u : PlanarPosition) : ℝ := + 72*Real.pi^2*rho^2+8192*rho^2*localizedDensityMoment freq u 4+ + 8*(slabGrowthConstant rho)^2*localizedDensityMoment freq u 24+ + 8*Real.pi^2*rho^2*localizedDensityMoment freq u 24 + +private theorem div_pow_le_div_sq {T C : ℝ} (hT : 1 ≤ T) (hC : 0 ≤ C) + {k : ℕ} (hk : 2 ≤ k) : C/T^k ≤ C/T^2 := + div_le_div_of_nonneg_left hC (by positivity) (pow_le_pow_right₀ hT hk) + +theorem slabOrbitalResidual_polynomial_bound {rho T freq : ℝ} + (hrho : 0 ≤ rho) (hT : 2 ≤ T) (hfreq : 0 < freq) (u : PlanarPosition) : + (∫ x, slabOrbitalResidual rho (T^4) T freq u x^2) ≤ + slabResidualPolynomialBound rho freq u/T^2 := by + have hTpos : 0 < T := by linarith + have hT1 : 1 ≤ T := by linarith + have hT4 : T ≤ T^4/2 := by + have h2 : 2*T ≤ T^2 := by nlinarith [mul_nonneg hTpos.le (sub_nonneg.mpr hT)] + have h4 : T^2 ≤ T^4 := by + exact pow_le_pow_right₀ hT1 (by decide : 2 ≤ 4) + linarith + have h := slabOrbitalResidual_square_bound hrho (pow_pos hTpos 4) hTpos.le hfreq + hTpos hT4 le_rfl u + have hB0 : 0 ≤ slabUniformBound rho (T^4) T := by + have h0 := slabPotential_abs_bound hrho (pow_nonneg hTpos.le 4) hTpos.le (0 : Position) + exact (abs_nonneg _).trans h0 + have hB := (sq_le_sq₀ hB0 (by dsimp [slabGrowthConstant]; positivity)).mpr + (slabUniformBound_polynomial hrho hT1) + have hBterm : 2*(2*slabUniformBound rho (T^4) T)^2* + (localizedDensityMoment freq u 24/T^24) ≤ + 8*(slabGrowthConstant rho)^2*localizedDensityMoment freq u 24/T^6 := by + have hb := mul_le_mul_of_nonneg_right hB + (show 0 ≤ 8*(localizedDensityMoment freq u 24/T^24) by + exact mul_nonneg (by norm_num) (div_nonneg (localizedDensityMoment_nonnegative _ _ _) + (pow_nonneg hTpos.le _))) + convert hb using 1 + all_goals field_simp [ne_of_gt hTpos] + all_goals ring + have he1 : 2*(6*Real.pi*rho*T^3/T^4)^2 = 72*Real.pi^2*rho^2/T^2 := by + field_simp [ne_of_gt hTpos] + ring + have he2 : 2*(64*rho*T/T^4)^2*localizedDensityMoment freq u 4 = + 8192*rho^2*localizedDensityMoment freq u 4/T^6 := by + field_simp [ne_of_gt hTpos] + ring + have he4 : 2*(2*Real.pi*rho)^2*(localizedDensityMoment freq u 24/T^20) = + 8*Real.pi^2*rho^2*localizedDensityMoment freq u 24/T^20 := by ring + rw [he1,he2,he4] at h + have h2 := div_pow_le_div_sq hT1 + (mul_nonneg (mul_nonneg (by norm_num : (0:ℝ)≤8192) (sq_nonneg rho)) + (localizedDensityMoment_nonnegative freq u 4)) (by decide : 2 ≤ 6) + have h3 := div_pow_le_div_sq hT1 + (mul_nonneg (mul_nonneg (by norm_num : (0:ℝ)≤8) (sq_nonneg (slabGrowthConstant rho))) + (localizedDensityMoment_nonnegative freq u 24)) (by decide : 2 ≤ 6) + have h4 := div_pow_le_div_sq hT1 + (mul_nonneg (by positivity : 0 ≤ 8*Real.pi^2*rho^2) + (localizedDensityMoment_nonnegative freq u 24)) (by decide : 2 ≤ 20) + have hs := h.trans (add_le_add (add_le_add (add_le_add le_rfl h2) (hBterm.trans h3)) h4) + simpa only [slabResidualPolynomialBound, add_div] using hs + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabSections.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabSections.lean new file mode 100644 index 0000000000000000000000000000000000000000..833cd4ebb160c43f559edd5b594fc58851924148 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabSections.lean @@ -0,0 +1,200 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularization + +namespace OAI + +/-! Finite product sections of the actual rectangular slab measure. -/ + +noncomputable section +open MeasureTheory Filter +open scoped BigOperators Topology +namespace ContinuumCoulomb + +def slabSide (H S : ℝ) (i : Fin 3) : ℝ := if i = 2 then S else H + +def slabAxisMeasure (H S : ℝ) (i : Fin 3) : Measure ℝ := + volume.restrict (Set.Icc (-slabSide H S i) (slabSide H S i)) + +def slabProductMeasure (H S : ℝ) : Measure (Fin 3 → ℝ) := + Measure.pi (slabAxisMeasure H S) + +def slabProductDomain (H S : ℝ) : Set (Fin 3 → ℝ) := + Set.univ.pi (fun i => Set.Icc (-slabSide H S i) (slabSide H S i)) + +theorem slabProductDomain_preimage (H S : ℝ) : + (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).symm ⁻¹' slabProductDomain H S = slabDomain H S := by + ext x + change (∀ i : Fin 3, i ∈ Set.univ → -slabSide H S i ≤ x i ∧ x i ≤ slabSide H S i) ↔ + |x 0| ≤ H ∧ |x 1| ≤ H ∧ |x 2| ≤ S + simp only [Set.mem_univ, true_implies, abs_le] + constructor + · intro h + exact ⟨by simpa [slabSide] using h 0, + by simpa [slabSide] using h 1, by simpa [slabSide] using h 2⟩ + · rintro ⟨h0, h1, h2⟩ i + fin_cases i + · simpa [slabSide] using h0 + · simpa [slabSide] using h1 + · simpa [slabSide] using h2 + +theorem slabProductMeasure_eq (H S : ℝ) : + slabProductMeasure H S = (volume : Measure (Fin 3 → ℝ)).restrict (slabProductDomain H S) := by + exact (Measure.restrict_pi_pi (fun _ : Fin 3 => (volume : Measure ℝ)) + (fun i => Set.Icc (-slabSide H S i) (slabSide H S i))).symm + +theorem slabProduct_measurePreserving (H S : ℝ) : + MeasurePreserving (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)) + (slabProductMeasure H S) (volume.restrict (slabDomain H S)) := by + have hm := (EuclideanSpace.volume_preserving_symm_measurableEquiv_toLp (Fin 3)).restrict_preimage + (s := slabProductDomain H S) + (MeasurableSet.univ_pi (fun i => measurableSet_Icc)) + rw [slabProductDomain_preimage, ← slabProductMeasure_eq] at hm + exact MeasurePreserving.symm (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).symm hm + +theorem slabProduct_integral (H S : ℝ) (f : Position → ℝ) : + (∫ x, f (WithLp.toLp 2 x) ∂slabProductMeasure H S) = + ∫ y in slabDomain H S, f y := by + exact (slabProduct_measurePreserving H S).integral_comp' f + +theorem slabProduct_integrable (H S : ℝ) (f : Position → ℝ) : + Integrable (fun x => f (WithLp.toLp 2 x)) (slabProductMeasure H S) ↔ + IntegrableOn f (slabDomain H S) := + (slabProduct_measurePreserving H S).integrable_comp_emb + (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).measurableEmbedding + +theorem regularizedKernel_eq_sqrt (epsilon : ℝ) (x : Position) : + NeutralAtom.regularizedKernel epsilon x = (Real.sqrt (‖x‖^2+epsilon^2))⁻¹ := by + rw [NeutralAtom.regularizedKernel, Real.sqrt_eq_rpow] + convert Real.rpow_neg (add_nonneg (sq_nonneg ‖x‖) (sq_nonneg epsilon)) (1/2:ℝ) using 1 + norm_num + +theorem regularizedKernel_section (epsilon : ℝ) (y : Position) (i : Fin 3) + (t : ℝ) (v : Fin 2 → ℝ) : + NeutralAtom.regularizedKernel epsilon (y-WithLp.toLp 2 (i.insertNth t v)) = + coulombLineKernel + (epsilon^2+∑ j : Fin 2, (y (i.succAbove j)-v j)^2) (y i-t) := by + rw [regularizedKernel_eq_sqrt] + unfold coulombLineKernel + congr 2 + rw [EuclideanSpace.real_norm_sq_eq, Fin.sum_univ_succAbove _ i] + simp only [PiLp.sub_apply, Fin.insertNth_apply_same, + Fin.insertNth_apply_succAbove] + ring + +instance slabAxisMeasure_finite (H S : ℝ) (i : Fin 3) : + IsFiniteMeasure (slabAxisMeasure H S i) := by + unfold slabAxisMeasure + infer_instance + +def zeroPositionCoordinate (i : Fin 3) (y : Position) : Position := + WithLp.toLp 2 (Function.update (WithLp.ofLp y) i 0) + +theorem zeroPositionCoordinate_same (i : Fin 3) (y : Position) : + zeroPositionCoordinate i y i = 0 := by simp [zeroPositionCoordinate] + +theorem zeroPositionCoordinate_other (i : Fin 3) (y : Position) (j : Fin 2) : + zeroPositionCoordinate i y (i.succAbove j) = y (i.succAbove j) := by + simp [zeroPositionCoordinate, Fin.succAbove_ne] + +private theorem regularizedProduct_integrable {epsilon H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) : + Integrable (fun x : Fin 3 → ℝ => NeutralAtom.regularizedKernel epsilon + (y-WithLp.toLp 2 x)) (slabProductMeasure H S) := + (slabProduct_integrable H S _).mpr (regularizedSlab_integrableOn hepsilon hH hS y) + +private theorem regularizedSection_integrable {epsilon H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) (i : Fin 3) : + Integrable (fun p : ℝ × (Fin 2 → ℝ) => NeutralAtom.regularizedKernel epsilon + (y-WithLp.toLp 2 (i.insertNth p.1 p.2))) + ((slabAxisMeasure H S i).prod + (Measure.pi (fun j : Fin 2 => slabAxisMeasure H S (i.succAbove j)))) := by + have hp := (measurePreserving_piFinSuccAbove (slabAxisMeasure H S) i).symm + have h := (hp.integrable_comp_emb + (MeasurableEquiv.piFinSuccAbove (fun _ : Fin 3 => ℝ) i).symm.measurableEmbedding).mpr + (regularizedProduct_integrable hepsilon hH hS y) + exact h + +theorem regularizedSlab_sectionIntegral {epsilon H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) (i : Fin 3) : + (∫ x in slabDomain H S, NeutralAtom.regularizedKernel epsilon (y-x)) = + ∫ v : Fin 2 → ℝ, ∫ t : ℝ, + NeutralAtom.regularizedKernel epsilon (y-WithLp.toLp 2 (i.insertNth t v)) + ∂slabAxisMeasure H S i + ∂Measure.pi (fun j : Fin 2 => slabAxisMeasure H S (i.succAbove j)) := by + rw [← slabProduct_integral H S (fun x => NeutralAtom.regularizedKernel epsilon (y-x))] + change (∫ x : Fin 3 → ℝ, NeutralAtom.regularizedKernel epsilon (y-WithLp.toLp 2 x) + ∂Measure.pi (slabAxisMeasure H S)) = _ + rw [← ((measurePreserving_piFinSuccAbove (slabAxisMeasure H S) i).symm).integral_comp'] + simp only [MeasurableEquiv.piFinSuccAbove_symm_apply, Fin.insertNthEquiv] + exact integral_prod_symm _ (regularizedSection_integrable hepsilon hH hS y i) + +private theorem coulombLine_setIntegral_le_center {A H : ℝ} (hA : 0 < A) (hH : 0 ≤ H) + (x : ℝ) : + (∫ t in Set.Icc (-H) H, coulombLineKernel A (x-t)) ≤ + ∫ t in Set.Icc (-H) H, coulombLineKernel A (0-t) := by + have h := coulombLineIntegral_le_center hA hH x + simp only [centeredLineIntegral_translate, + intervalIntegral.integral_of_le (show -H ≤ H by linarith), + ← integral_Icc_eq_integral_Ioc] at h + exact h + +/-- Centering one coordinate increases the attractive Coulomb integral. +The statement holds for the actual finite slab, before taking the singular limit. -/ +theorem regularizedSlab_coordinate_max {epsilon H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) (i : Fin 3) : + (∫ x in slabDomain H S, NeutralAtom.regularizedKernel epsilon (y-x)) ≤ + ∫ x in slabDomain H S, NeutralAtom.regularizedKernel epsilon + (zeroPositionCoordinate i y-x) := by + rw [regularizedSlab_sectionIntegral hepsilon hH hS y i, + regularizedSlab_sectionIntegral hepsilon hH hS (zeroPositionCoordinate i y) i] + apply integral_mono + (regularizedSection_integrable hepsilon hH hS y i).integral_prod_right + (regularizedSection_integrable hepsilon hH hS (zeroPositionCoordinate i y) i).integral_prod_right + intro v + simp_rw [regularizedKernel_section, zeroPositionCoordinate_same, zeroPositionCoordinate_other] + have hA : 0 < epsilon^2+∑ j : Fin 2, (y (i.succAbove j)-v j)^2 := + add_pos_of_pos_of_nonneg (sq_pos_of_ne_zero hepsilon) + (Finset.sum_nonneg (fun _ _ => sq_nonneg _)) + have hside : 0 ≤ slabSide H S i := by unfold slabSide; split <;> assumption + exact coulombLine_setIntegral_le_center hA hside (y i) + +/-- The actual singular finite-slab potential is minimized in each centered +coordinate. The regularized comparison passes through a dominated limit. -/ +theorem slabPotential_coordinate_min {rho H S : ℝ} (hrho : 0 ≤ rho) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) (i : Fin 3) : + slabPotential rho H S (zeroPositionCoordinate i y) ≤ slabPotential rho H S y := by + let epsilon : ℕ → ℝ := fun n => ((n:ℝ)+1)⁻¹ + have hep (n : ℕ) : 0 < epsilon n := by dsimp [epsilon]; positivity + have heps : Tendsto epsilon atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp + (tendsto_atTop_add_const_right _ 1 tendsto_natCast_atTop_atTop) + apply le_of_tendsto_of_tendsto + (regularizedSlabPotential_tendsto hep heps rho hH hS (zeroPositionCoordinate i y)) + (regularizedSlabPotential_tendsto hep heps rho hH hS y) + exact Filter.Eventually.of_forall (fun n => + mul_le_mul_of_nonpos_left (regularizedSlab_coordinate_max (hep n).ne' hH hS y i) + (neg_nonpos.mpr hrho)) + +theorem slabPotential_minimum {rho H S : ℝ} (hrho : 0 ≤ rho) + (hH : 0 ≤ H) (hS : 0 ≤ S) (y : Position) : + slabPotential rho H S 0 ≤ slabPotential rho H S y := by + have h0 := slabPotential_coordinate_min hrho hH hS y 0 + have h1 := slabPotential_coordinate_min hrho hH hS (zeroPositionCoordinate 0 y) 1 + have h2 := slabPotential_coordinate_min hrho hH hS + (zeroPositionCoordinate 1 (zeroPositionCoordinate 0 y)) 2 + have he : zeroPositionCoordinate 2 (zeroPositionCoordinate 1 (zeroPositionCoordinate 0 y)) = 0 := by + ext j + fin_cases j <;> simp [zeroPositionCoordinate] + rw [he] at h2 + exact h2.trans (h1.trans h0) + +theorem slabPotential_nonpositive {rho : ℝ} (hrho : 0 ≤ rho) (H S : ℝ) (y : Position) : + slabPotential rho H S y ≤ 0 := by + rw [slabPotential_eq_setIntegral] + exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hrho) + (integral_nonneg (fun x => inv_nonneg.mpr (norm_nonneg (y-x)))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabVerticalCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabVerticalCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bdfcbe062beb84987974e07cb17fbdf26cca38b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/SlabVerticalCoordinates.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabPlanarTail +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabSections + +namespace OAI + +/-! Vertical-first coordinates for the actual three-dimensional slab. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def slabVerticalEquiv : Position ≃ᵐ ℝ × PlanarPosition := + (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).symm.trans + ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin 3 => ℝ) 2).trans + ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin 2 → ℝ)))) + +theorem slabVerticalEquiv_symm_apply (p : ℝ × PlanarPosition) : + slabVerticalEquiv.symm p = WithLp.toLp 2 ![p.2 0, p.2 1, p.1] := by + ext i + fin_cases i <;> rfl + +theorem slabVerticalEquiv_apply (x : Position) : + slabVerticalEquiv x = (x 2, WithLp.toLp 2 ![x 0, x 1]) := by + apply Prod.ext + · rfl + · ext i + fin_cases i <;> rfl + +theorem slabVerticalEquiv_measurePreserving : MeasurePreserving slabVerticalEquiv := + ((MeasurePreserving.id volume).prod (PiLp.volume_preserving_toLp (Fin 2))).comp + ((volume_preserving_piFinSuccAbove (fun _ : Fin 3 => ℝ) 2).comp + (PiLp.volume_preserving_ofLp (Fin 3))) + +theorem slabVerticalEquiv_preimage (H S : ℝ) : + slabVerticalEquiv ⁻¹' (Set.Icc (-S) S ×ˢ slabPlanarBox H) = slabDomain H S := by + ext x + simp only [Set.mem_preimage, Set.mem_prod, Set.mem_Icc, slabVerticalEquiv_apply, + slabPlanarBox, Set.mem_ofPred_eq, Matrix.cons_val_zero, + Matrix.cons_val_one, Matrix.cons_val_fin_one, slabDomain, abs_le] + tauto + +theorem slabVertical_setIntegral (H S : ℝ) (f : Position → ℝ) : + (∫ x in slabDomain H S, f x) = + ∫ p in Set.Icc (-S) S ×ˢ slabPlanarBox H, f (slabVerticalEquiv.symm p) := by + have h := slabVerticalEquiv_measurePreserving.restrict_preimage + (s := Set.Icc (-S) S ×ˢ slabPlanarBox H) + (measurableSet_Icc.prod (slabPlanarBox_measurable H)) + rw [slabVerticalEquiv_preimage] at h + simpa only [Function.comp_apply, MeasurableEquiv.symm_apply_apply] using + h.integral_comp' (f ∘ slabVerticalEquiv.symm) + +def slabAxisPoint (z : ℝ) : Position := WithLp.toLp 2 ![0,0,z] + +theorem regularizedSlab_vertical_kernel (epsilon z : ℝ) (p : ℝ × PlanarPosition) : + NeutralAtom.regularizedKernel epsilon (slabAxisPoint z-slabVerticalEquiv.symm p) = + coulombLineKernel (epsilon^2+(z-p.1)^2) ‖p.2‖ := by + rw [regularizedKernel_eq_sqrt, slabVerticalEquiv_symm_apply] + unfold coulombLineKernel + congr 2 + rw [EuclideanSpace.real_norm_sq_eq, EuclideanSpace.real_norm_sq_eq] + simp only [slabAxisPoint, PiLp.sub_apply, Fin.sum_univ_succ, + Fin.sum_univ_zero, Matrix.cons_val_zero, Matrix.cons_val_succ, Matrix.cons_val_fin_one, + zero_sub, neg_sq] + rw [Fin.succ_zero_eq_one] + ring + +theorem regularizedSlab_vertical_integrable {epsilon H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (z : ℝ) : + IntegrableOn (fun p : ℝ × PlanarPosition => + coulombLineKernel (epsilon^2+(z-p.1)^2) ‖p.2‖) + (Set.Icc (-S) S ×ˢ slabPlanarBox H) := by + have h := slabVerticalEquiv_measurePreserving.restrict_preimage + (s := Set.Icc (-S) S ×ˢ slabPlanarBox H) + (measurableSet_Icc.prod (slabPlanarBox_measurable H)) + rw [slabVerticalEquiv_preimage] at h + have hs := (MeasurePreserving.symm slabVerticalEquiv h).integrable_comp_emb + (g := fun x : Position => NeutralAtom.regularizedKernel epsilon (slabAxisPoint z-x)) + slabVerticalEquiv.symm.measurableEmbedding + exact (hs.mpr (regularizedSlab_integrableOn hepsilon hH hS (slabAxisPoint z))).congr + (Filter.Eventually.of_forall (regularizedSlab_vertical_kernel epsilon z)) + +theorem regularizedSlab_vertical (epsilon rho : ℝ) {H S : ℝ} (hepsilon : epsilon ≠ 0) + (hH : 0 ≤ H) (hS : 0 ≤ S) (z : ℝ) : + regularizedSlabPotential epsilon rho H S (slabAxisPoint z) = + -rho * ∫ w in Set.Icc (-S) S, ∫ p in slabPlanarBox H, + coulombLineKernel (epsilon^2+(z-w)^2) ‖p‖ := by + unfold regularizedSlabPotential + rw [slabVertical_setIntegral] + simp_rw [regularizedSlab_vertical_kernel] + rw [Measure.volume_eq_prod, setIntegral_prod _ + (regularizedSlab_vertical_integrable hepsilon hH hS z)] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedCoulombDerivative.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedCoulombDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..65ffc9cc999f327e623c8da65712383011451619 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedCoulombDerivative.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombFarCell +import Mathlib.Analysis.Calculus.ContDiff.Bounds + +namespace OAI + +/-! Fourth derivatives of the Coulomb integrand after the Moser map. The +estimate is local at a point and needs no regularity across the pole. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem fourth_composite_norm_bound (f : Position → ℝ) (G : Position → Position) (x : Position) + (hf : ContDiffAt ℝ 4 f (G x)) (hG : ContDiff ℝ 4 G) {C D : ℝ} + (hC : ∀ k : ℕ, k ≤ 4 → ‖iteratedFDeriv ℝ k f (G x)‖ ≤ C) + (hD : ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) : + ‖iteratedFDeriv ℝ 4 (f ∘ G) x‖ ≤ 24*C*D^4 := by + obtain ⟨U,hU,hx,hfU⟩ := hf.contDiffOn' le_rfl (by norm_num) + have hfU : ContDiffOn ℝ 4 f U := by simpa using hfU + have hS : IsOpen (G ⁻¹' U) := hU.preimage hG.continuous + have hc := norm_iteratedFDerivWithin_comp_le hfU hG.contDiffOn (n := 4) le_rfl + hU.uniqueDiffOn hS.uniqueDiffOn (fun _ hy => hy) hx + (fun k hk => by + rw [iteratedFDerivWithin_eq_iteratedFDeriv hU.uniqueDiffOn (hf.of_le (by exact_mod_cast hk)) hx] + exact hC k hk) + (fun k hk hk' => by + rw [iteratedFDerivWithin_eq_iteratedFDeriv (f := G) (x := x) (s := G ⁻¹' U) hS.uniqueDiffOn + (hG.of_le (by exact_mod_cast hk')).contDiffAt hx] + exact hD k hk hk') + rw [iteratedFDerivWithin_eq_iteratedFDeriv (f := f ∘ G) (x := x) (s := G ⁻¹' U) hS.uniqueDiffOn (hf.comp x hG.contDiffAt) hx] at hc + norm_num only [Nat.factorial] at hc + exact hc + +theorem coulomb_kernel_jets_near_bound : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (z : Position) (r : ℝ), 0 < r → r ≤ 1 → r ≤ ‖z‖ → + ∀ k : ℕ, k ≤ 4 → ‖iteratedFDeriv ℝ k Coulomb.coulombKernel z‖ ≤ C/r^5 := by + obtain ⟨C,hC,hbound⟩ := coulombKernel_derivative_decay + refine ⟨C,hC,fun z r hr hr1 hz k hk => ?_⟩ + have hzne : z ≠ 0 := norm_pos_iff.mp (hr.trans_le hz) + have hb := hbound ⟨k,by omega⟩ z hzne + apply (le_div_iff₀ (pow_pos hr 5)).mpr + have hp : r^5 ≤ ‖z‖^(k+1) := by + calc + _ ≤ r^(k+1) := pow_le_pow_of_le_one hr.le hr1 (by omega) + _ ≤ _ := pow_le_pow_left₀ hr.le hz _ + exact (mul_le_mul_of_nonneg_left hp (norm_nonneg _)).trans hb + +theorem transportedCoulomb_fourth_bound : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (y x : Position) (r D : ℝ), 0 < r → r ≤ 1 → r ≤ ‖y-G x‖ → + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ‖iteratedFDeriv ℝ 4 (fun b => Coulomb.coulombKernel (y-G b)) x‖ ≤ 24*C*D^4/r^5 := by + obtain ⟨C,hC,hbound⟩ := coulomb_kernel_jets_near_bound + refine ⟨C,hC,fun G hG y x r D hr hr1 hdist hD => ?_⟩ + have hne : y-G x ≠ 0 := norm_pos_iff.mp (hr.trans_le hdist) + have hf : ContDiffAt ℝ 4 (fun z => Coulomb.coulombKernel (y-z)) (G x) := + ((coulombKernel_contDiffAt hne).of_le + (ENat.natCast_le_of_coe_top_le_withTop le_rfl 4)).comp (G x) (contDiffAt_const.sub contDiffAt_id) + have hb := fourth_composite_norm_bound (fun z => Coulomb.coulombKernel (y-z)) G x hf hG + (fun k hk => by rw [translatedCoulomb_derivative_norm]; exact hbound _ r hr hr1 hdist k hk) hD + apply hb.trans_eq + ring + +theorem transportedCoulomb_cell_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (y b : Position) (h r D : ℝ), 0 ≤ h → 0 < r → r ≤ 1 → + (∀ x ∈ Set.Icc (-1:ℝ) 1, ∀ v ∈ Set.Icc (-1:ℝ) 1, + ∀ z ∈ Set.Icc (-1:ℝ) 1, r ≤ ‖y-G (cubePoint b (h/2) x v z)‖) → + (∀ x ∈ Set.Icc (-1:ℝ) 1, ∀ v ∈ Set.Icc (-1:ℝ) 1, + ∀ z ∈ Set.Icc (-1:ℝ) 1, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → + ‖iteratedFDeriv ℝ k G (cubePoint b (h/2) x v z)‖ ≤ D^k) → + |positionCellGauss b h (fun a => Coulomb.coulombKernel (y-G a))- + positionCellIntegral b h (fun a => Coulomb.coulombKernel (y-G a))| ≤ + 24*C*D^4*h^7/r^5 := by + obtain ⟨C,hC,hbound⟩ := transportedCoulomb_fourth_bound + refine ⟨C,hC,fun G hG y b h r D hh hr hr1 hdist hD => ?_⟩ + have hf (x : ℝ) (hx : x ∈ Set.Icc (-1:ℝ) 1) (v : ℝ) (hv : v ∈ Set.Icc (-1:ℝ) 1) + (z : ℝ) (hz : z ∈ Set.Icc (-1:ℝ) 1) : + ContDiffAt ℝ 4 (fun a => Coulomb.coulombKernel (y-G a)) (cubePoint b (h/2) x v z) := by + have hn : y-G (cubePoint b (h/2) x v z) ≠ 0 := + norm_pos_iff.mp (hr.trans_le (hdist x hx v hv z hz)) + have hi : ContDiffAt ℝ 4 (fun a => y-G a) (cubePoint b (h/2) x v z) := + contDiffAt_const.sub hG.contDiffAt + exact ContDiffAt.comp (g := Coulomb.coulombKernel) (f := fun a : Position => y-G a) + (cubePoint b (h/2) x v z) ((coulombKernel_contDiffAt hn).of_le + (ENat.natCast_le_of_coe_top_le_withTop le_rfl 4)) hi + have hC0 : 0 ≤ C := le_trans (by norm_num) hC + have he := positionCellGauss_error_local (fun a => Coulomb.coulombKernel (y-G a)) b hh + (by positivity : 0 ≤ 24*C*D^4/r^5) hf + (fun x hx v hv z hz => hbound G hG y _ r D hr hr1 (hdist x hx v hv z hz) (hD x hx v hv z hz)) + apply he.trans_eq + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedFarQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedFarQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..226ae240dbc46c4180622b839233263814914c27 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedFarQuadrature.lean @@ -0,0 +1,132 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedHybrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ExceptionalCellVolume + +namespace OAI + +/-! Local fourth-order error with the nondecaying transport correction +charged only to cells meeting the compact well support. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb + +def cellHits (E : Set Position) (b : Position) (h : ℝ) : ℝ := + if ∃ z ∈ positionCube b h, z ∈ E then 1 else 0 + +theorem cellHits_nonneg (E : Set Position) (b : Position) (h : ℝ) : 0 ≤ cellHits E b h := by + unfold cellHits + split_ifs <;> norm_num + +theorem cellHits_indicator_le (E : Set Position) (b : Position) (h : ℝ) + {x : Position} (hx : x ∈ positionCube b h) : + (if x ∈ E then (1:ℝ) else 0) ≤ cellHits E b h := by + by_cases hE : x ∈ E + · simp [hE,cellHits,show ∃ z ∈ positionCube b h, z ∈ E from ⟨x,hx,hE⟩] + · simpa only [ite_eq_right hE] using cellHits_nonneg E b h + +theorem manufactured_cellHits_volume_bound {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h S : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (hS : 1 ≤ S) + (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) : + (∑ i, cellHits (tsupport (manufacturedWellField freq scale S u)) + (gaussCellCenter h (index i)) h*h^3) ≤ 216*m*S := by + let s := Finset.univ.filter (fun i => ∃ z ∈ positionCube (gaussCellCenter h (index i)) h, + z ∈ tsupport (manufacturedWellField freq scale S u)) + have hi : Function.Injective (fun i : {i // i ∈ s} => index i.val) := by + intro i j hij + exact Subtype.ext (hindex hij) + have he := exceptional_cell_volume_bound (fun i : {i // i ∈ s} => index i.val) hi + hh hh1 hS freq scale u (fun i => (Finset.mem_filter.mp i.property).2) + simpa only [Fintype.card_coe,s,cellHits,ite_mul,one_mul,zero_mul,← Finset.sum_filter, + Finset.sum_const,nsmul_eq_mul] using he + +theorem transportedCoulomb_far_cell_hybrid_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (E : Set Position), IsClosed E → (∀ x, x ∉ E → G x = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ (L : ℝ≥0), 0 < L → LipschitzWith L G → + ∀ (y b : Position) (h : ℝ), 0 < h → 4*(L:ℝ)*h ≤ ‖y-G b‖ → + |positionCellGauss b h (fun x => Coulomb.coulombKernel (y-G x))- + positionCellIntegral b h (fun x => Coulomb.coulombKernel (y-G x))| ≤ + (24*C*D^4)*(32/‖y-G b‖^5+cellHits E b h)*h^7 := by + obtain ⟨C,hC,hbound⟩ := transportedCoulomb_hybrid_fourth_bound + refine ⟨C,hC,fun G hG E hE hfix D hD hGD L hL hLip y b h hh hfar => ?_⟩ + have hC0 : 0 ≤ C := (by norm_num : (0:ℝ) ≤ 1).trans hC + have hd : 0 < ‖y-G b‖ := lt_of_lt_of_le (by positivity) hfar + have hf (x : ℝ) (hx : x ∈ Set.Icc (-1:ℝ) 1) (v : ℝ) (hv : v ∈ Set.Icc (-1:ℝ) 1) + (z : ℝ) (hz : z ∈ Set.Icc (-1:ℝ) 1) : + ContDiffAt ℝ 4 (fun a => Coulomb.coulombKernel (y-G a)) (cubePoint b (h/2) x v z) := by + have hc := cubePoint_mem_positionCube b hh.le hx hv hz + have hn := (transported_far_cube_distances hh G hL hLip hfar hc).1 + have hne : y-G (cubePoint b (h/2) x v z) ≠ 0 := + norm_pos_iff.mp (lt_of_lt_of_le (by positivity : (0:ℝ) < (L:ℝ)*h) hn.le) + exact ContDiffAt.comp (g := Coulomb.coulombKernel) (f := fun a : Position => y-G a) + _ ((coulombKernel_contDiffAt hne).of_le + (ENat.natCast_le_of_coe_top_le_withTop le_rfl 4)) (contDiffAt_const.sub hG.contDiffAt) + apply positionCellGauss_error_local _ b hh.le + (mul_nonneg (by positivity) (add_nonneg (by positivity) (cellHits_nonneg E b h))) hf + intro x hx v hv z hz + let a := cubePoint b (h/2) x v z + have hc : a ∈ positionCube b h := cubePoint_mem_positionCube b hh.le hx hv hz + have ha := transported_far_cube_distances hh G hL hLip hfar hc + have hapos : 0 < ‖y-G a‖ := lt_of_lt_of_le (by positivity : (0:ℝ) < (L:ℝ)*h) ha.1.le + have hp : 1/‖y-G a‖^5 ≤ 32/‖y-G b‖^5 := by + have he := one_div_le_one_div_of_le (pow_pos (by positivity : 0 < ‖y-G b‖/2) 5) + (pow_le_pow_left₀ (by positivity : 0 ≤ ‖y-G b‖/2) ha.2.1 5) + apply he.trans_eq + field_simp + norm_num + apply (hbound G hG E hE hfix D hD hGD y a (norm_pos_iff.mp hapos)).trans + exact mul_le_mul_of_nonneg_left (add_le_add hp (cellHits_indicator_le E b h hc)) (by positivity) + +theorem transportedCoulomb_far_grid_hybrid_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (E : Set Position), IsClosed E → (∀ x, x ∉ E → G x = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ (L : ℝ≥0), 0 < L → LipschitzWith L G → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ) + (y : Position) (h : ℝ), 0 < h → + (∀ i, 4*(L:ℝ)*h ≤ ‖y-G (gaussCellCenter h (index i))‖) → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x)))| ≤ + 24*C*D^4*h^4*(32*(∑ i, h^3/‖y-G (gaussCellCenter h (index i))‖^5)+ + ∑ i, cellHits E (gaussCellCenter h (index i)) h*h^3) := by + obtain ⟨C,hC,hbound⟩ := transportedCoulomb_far_cell_hybrid_error + refine ⟨C,hC,?_⟩ + intro G hG E hE hfix D hD hGD L hL hLip ι _ index y h hh hfar + have he := weighted_cubature_error h 1 + (fun i => positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x))) + (fun i => positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x))) + (fun i => 24*C*D^4*(32/‖y-G (gaussCellCenter h (index i))‖^5+ + cellHits E (gaussCellCenter h (index i)) h)) + zero_le_one (fun i => hbound G hG E hE hfix D hD hGD L hL hLip y _ h hh (hfar i)) + simp only [one_mul] at he + apply he.trans_eq + have hs : (∑ i, (24*C*D^4*(32/‖y-G (gaussCellCenter h (index i))‖^5+ + cellHits E (gaussCellCenter h (index i)) h))*h^3) = + (24*C*D^4)*(32*(∑ i, h^3/‖y-G (gaussCellCenter h (index i))‖^5)+ + ∑ i, cellHits E (gaussCellCenter h (index i)) h*h^3) := by + calc + _ = ∑ i, (24*C*D^4)*(32*(h^3/‖y-G (gaussCellCenter h (index i))‖^5)+ + cellHits E (gaussCellCenter h (index i)) h*h^3) := by + apply Finset.sum_congr rfl + intro i _ + ring + _ = _ := by rw [← Finset.mul_sum,Finset.sum_add_distrib,← Finset.mul_sum] + rw [hs] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b9615ef48476f54f0188529910e74c053ba1e87 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedGrid.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserIntegralBound + +namespace OAI + +/-! The far-cell inverse-fifth sum after the actual density transport. +Its constant does not depend on the slab's horizontal extent. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem transported_far_cube_distances {h : ℝ} (hh : 0 < h) + (G : Position → Position) {L : ℝ≥0} (hL : 0 < L) (hG : LipschitzWith L G) + {y b x : Position} (hfar : 4*(L:ℝ)*h ≤ ‖y-G b‖) (hx : x ∈ positionCube b h) : + (L:ℝ)*h < ‖y-G x‖ ∧ ‖y-G b‖/2 ≤ ‖y-G x‖ ∧ ‖y-G x‖ ≤ 2*‖y-G b‖ := by + have hhL : 0 < (L:ℝ)*h := mul_pos (by exact_mod_cast hL) hh + have hn : ‖G x-G b‖ ≤ (L:ℝ)*h := + (hG.norm_sub_le x b).trans (mul_le_mul_of_nonneg_left + (positionCube_norm_sub_le hh.le hx) L.coe_nonneg) + have ha := norm_sub_le_norm_sub_add_norm_sub y (G x) (G b) + have hb := norm_sub_le_norm_sub_add_norm_sub y (G b) (G x) + rw [norm_sub_rev (G b) (G x)] at hb + constructor + · nlinarith + constructor <;> nlinarith + +theorem transported_inverseFifth_far_cube_bound {h : ℝ} (hh : 0 < h) + (G : Position → Position) {L : ℝ≥0} (hL : 0 < L) (hG : LipschitzWith L G) + (y b : Position) (hfar : 4*(L:ℝ)*h ≤ ‖y-G b‖) : + h^3/‖y-G b‖^5 ≤ + 32*(∫ x in positionCube b h, inverseFifthTail ((L:ℝ)*h) (y-G x)) := by + have hr : 0 < (L:ℝ)*h := mul_pos (by exact_mod_cast hL) hh + have hd : 0 < ‖y-G b‖ := lt_of_lt_of_le (by positivity) hfar + have hi : IntegrableOn (fun x => inverseFifthTail ((L:ℝ)*h) (y-G x)) (positionCube b h) := by + apply IntegrableOn.of_bound (positionCube_isCompact b hh.le).measure_lt_top + (((inverseFifthTail_measurable _).comp (continuous_const.sub hG.continuous).measurable).aestronglyMeasurable.restrict) + (1/((L:ℝ)*h)^5) + exact Filter.Eventually.of_forall (fun x => by + change ‖inverseFifthTail ((L:ℝ)*h) (y-G x)‖ ≤ 1/((L:ℝ)*h)^5 + rw [Real.norm_of_nonneg (inverseFifthTail_nonneg _ _)] + exact inverseFifthTail_le hr _) + have hp (x : Position) (hx : x ∈ positionCube b h) : + 1/‖y-G b‖^5 ≤ 32*inverseFifthTail ((L:ℝ)*h) (y-G x) := by + obtain ⟨hxgt,_hxl,hxu⟩ := transported_far_cube_distances hh G hL hG hfar hx + have hdx := hr.trans hxgt + rw [inverseFifthTail_eq_inv_pow _ hxgt,mul_one_div] + apply (div_le_div_iff₀ (pow_pos hd 5) (pow_pos hdx 5)).mpr + have hb := pow_le_pow_left₀ (norm_nonneg (y-G x)) hxu 5 + nlinarith [show (2*‖y-G b‖)^5 = 32*‖y-G b‖^5 by ring] + have he := setIntegral_mono_on + (integrableOn_const (C := 1/‖y-G b‖^5) + ((positionCube_isCompact b hh.le).measure_lt_top (μ := volume)).ne) + (hi.const_mul 32) (positionCube_isClosed b h).measurableSet hp + have hv : (volume.restrict (positionCube b h)).real Set.univ = h^3 := by + simpa only [Measure.real,Measure.restrict_apply_univ] using positionCube_volume b hh.le + simpa only [integral_const,smul_eq_mul,hv,integral_const_mul,div_eq_mul_inv,mul_one,one_mul] using he + +theorem moser_inverseFifth_grid_sum_bound (hpublished : PublishedC4FlowInput) + {rho H S : ℝ} (hrho : 0 < rho) (hH : 0 ≤ H) (hS : 0 ≤ S) + (V : Position → ℝ) (hV : ContDiff ℝ 6 V) + (hbound : ∀ x, |manufacturedCharge V x| ≤ rho/2) + (hsupport : tsupport V ⊆ slabDomain H S) + (G : Position → ℝ → Position) (hG : IsUnitTimeFlow (moserVelocity rho V) G) + (hbij : Function.Bijective (fun x => G x 1)) + (hfix : ∀ x, x ∉ tsupport V → G x 1 = x) + {L : ℝ≥0} (hL : 0 < L) (hLip : LipschitzWith L (fun x => G x 1)) + {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) + (hsub : ∀ i, positionCube (gaussCellCenter h (index i)) h ⊆ slabDomain H S) + (y : Position) (hfar : ∀ i, 4*(L:ℝ)*h ≤ ‖y-G (gaussCellCenter h (index i)) 1‖) : + (∑ i, h^3/‖y-G (gaussCellCenter h (index i)) 1‖^5) ≤ 96*Real.pi/((L:ℝ)*h)^2 := by + have hr : 0 < (L:ℝ)*h := mul_pos (by exact_mod_cast hL) hh + calc + _ ≤ ∑ i, 32*(∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail ((L:ℝ)*h) (y-G x 1)) := + Finset.sum_le_sum (fun i _ => transported_inverseFifth_far_cube_bound hh + (fun x => G x 1) hL hLip y _ (hfar i)) + _ = 32*(∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail ((L:ℝ)*h) (y-G x 1)) := (Finset.mul_sum _ _ _).symm + _ ≤ 32*(∫ x in slabDomain H S, inverseFifthTail ((L:ℝ)*h) (y-G x 1)) := + mul_le_mul_of_nonneg_left (grid_cell_integral_sum_le_on index hindex hh hsub _ + (transportedInverseFifth_integrableOn hH hS hr _ hLip.continuous y) + (fun x => inverseFifthTail_nonneg _ _)) (by norm_num) + _ ≤ 32*(3*Real.pi/((L:ℝ)*h)^2) := mul_le_mul_of_nonneg_left + (moser_inverseFifth_tail_bound hpublished hrho V hV hbound hsupport G hG hbij hfix y hr) + (by norm_num) + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedHybrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedHybrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e1a04e36f89aaf3881a3ab1f4214e646b293bb2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedHybrid.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedCoulombDerivative + +namespace OAI + +/-! The transport correction is confined to the support of the field. Outside +that set only the integrable inverse-fifth Coulomb derivative remains. -/ + +noncomputable section +open Filter +open scoped Topology Classical +namespace ContinuumCoulomb + +theorem coulomb_kernel_jets_hybrid_bound : + ∃ C : ℝ, 1 ≤ C ∧ + (∀ (z : Position), z ≠ 0 → ∀ k : ℕ, k ≤ 4 → + ‖iteratedFDeriv ℝ k Coulomb.coulombKernel z‖ ≤ C*(1+1/‖z‖^5)) ∧ + (∀ (z : Position), z ≠ 0 → + ‖iteratedFDeriv ℝ 4 Coulomb.coulombKernel z‖ ≤ C/‖z‖^5) := by + obtain ⟨C,hC,hbound⟩ := coulombKernel_derivative_decay + have hC0 : 0 ≤ C := (by norm_num : (0:ℝ) ≤ 1).trans hC + refine ⟨C,hC,?_,?_⟩ + · intro z hz k hk + have hd : 0 < ‖z‖ := norm_pos_iff.mpr hz + have hb := hbound ⟨k,by omega⟩ z hz + by_cases hd1 : ‖z‖ ≤ 1 + · have hp : ‖z‖^5 ≤ ‖z‖^(k+1) := + pow_le_pow_of_le_one hd.le hd1 (by omega) + have he : ‖iteratedFDeriv ℝ k Coulomb.coulombKernel z‖ ≤ C/‖z‖^5 := by + apply (le_div_iff₀ (pow_pos hd 5)).mpr + exact (mul_le_mul_of_nonneg_left hp (norm_nonneg _)).trans hb + rw [mul_add,mul_one,mul_one_div] + linarith + · have hp : 1 ≤ ‖z‖^(k+1) := one_le_pow₀ (le_of_not_ge hd1) + have hm : ‖iteratedFDeriv ℝ k Coulomb.coulombKernel z‖ ≤ + ‖iteratedFDeriv ℝ k Coulomb.coulombKernel z‖*‖z‖^(k+1) := by + simpa only [mul_one] using + mul_le_mul_of_nonneg_left hp (norm_nonneg (iteratedFDeriv ℝ k Coulomb.coulombKernel z)) + have he := hm.trans hb + rw [mul_add,mul_one,mul_one_div] + linarith [div_nonneg hC0 (pow_nonneg hd.le 5)] + · intro z hz + apply (le_div_iff₀ (pow_pos (norm_pos_iff.mpr hz) 5)).mpr + exact hbound (4:Fin 5) z hz + +theorem transportedCoulomb_hybrid_fourth_bound : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (E : Set Position), IsClosed E → (∀ x, x ∉ E → G x = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ (y x : Position), y-G x ≠ 0 → + ‖iteratedFDeriv ℝ 4 (fun b => Coulomb.coulombKernel (y-G b)) x‖ ≤ + 24*C*D^4*(1/‖y-G x‖^5 + if x ∈ E then 1 else 0) := by + classical + obtain ⟨C,hC,hbound,hpure⟩ := coulomb_kernel_jets_hybrid_bound + refine ⟨C,hC,fun G hG E hE hfix D hD hGD y x hne => ?_⟩ + have hC0 : 0 ≤ C := (by norm_num : (0:ℝ) ≤ 1).trans hC + have hf : ContDiffAt ℝ 4 (fun z => Coulomb.coulombKernel (y-z)) (G x) := + ((coulombKernel_contDiffAt hne).of_le + (ENat.natCast_le_of_coe_top_le_withTop le_rfl 4)).comp (G x) + (contDiffAt_const.sub contDiffAt_id) + by_cases hx : x ∈ E + · have he := fourth_composite_norm_bound (fun z => Coulomb.coulombKernel (y-z)) G x hf hG + (fun k hk => by rw [translatedCoulomb_derivative_norm]; exact hbound _ hne k hk) + (hGD x) + simp only [ite_eq_left hx] + apply he.trans_eq + ring + · have hlocal : G =ᶠ[𝓝 x] id := by + filter_upwards [hE.isOpen_compl.mem_nhds hx] with z hz + exact hfix z hz + have heq : (fun b => Coulomb.coulombKernel (y-G b)) =ᶠ[𝓝 x] + (fun b => Coulomb.coulombKernel (y-b)) := by + filter_upwards [hlocal] with b hb + rw [hb] + rfl + rw [(heq.iteratedFDeriv ℝ 4).eq_of_nhds,translatedCoulomb_derivative_norm] + have he := hpure (y-x) (by simpa only [hfix x hx] using hne) + have hfac : C ≤ 24*C*D^4 := by nlinarith [one_le_pow₀ hD (n := 4)] + simp only [ite_eq_right hx,add_zero,hfix x hx] + exact he.trans (by simpa only [div_eq_mul_inv,mul_one,one_mul] using + mul_le_mul_of_nonneg_right hfac (inv_nonneg.mpr (pow_nonneg (norm_nonneg (y-x)) 5))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..69f741468f0c4ae391f6d2ba0aee57ea77d8d276 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearForm.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScaledNuclearNear +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNodes + +namespace OAI + +/-! The actual transported Gauss nuclei satisfy the separation hypothesis +in the full weak-H1 near-field bound, uniformly over the chosen finite grid. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem transportedGauss_separation {m : ℕ} {h : ℝ} (hh : 0 < h) + (index : Fin m → GaussLatticeIndex) (hindex : Function.Injective index) + (G : Position → Position) {K : ℝ≥0} (hK : 0 < K) (hG : AntilipschitzWith K G) + (a b : Fin m) (hab : a ≠ b) : + h/(3*(K:ℝ)) ≤ ‖G (gaussLatticePoint h (index a))-G (gaussLatticePoint h (index b))‖ := by + have hb := gaussLatticePoint_separation hh (index a) (index b) (fun he => hab (hindex he)) + have ht := hG.le_mul_dist (gaussLatticePoint h (index a)) (gaussLatticePoint h (index b)) + simp only [dist_eq_norm] at ht + apply (div_le_iff₀ (show 0 < 3*(K:ℝ) by positivity)).mpr + nlinarith + +theorem transportedGauss_near_form {κ : ℝ} (hκ : 0 < κ) + (K : ℝ≥0) (hK : 0 < K) : + ∃ A : ℝ, 1 ≤ A ∧ ∀ (m n : ℕ) (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (h ρ : ℝ), + 0 < h → h ≤ 1 → 0 ≤ ρ → + ∀ (index : Fin m → GaussLatticeIndex), Function.Injective index → + ∀ (G : Position → Position), AntilipschitzWith K G → + (ρ*h^3/8)*(∑ a, ∫ x in electronBall i (G (gaussLatticePoint h (index a))) (κ*h), + Coulomb.coulombKernel (Coulomb.position x i-G (gaussLatticePoint h (index a)))* + ‖u.value s x‖^2) ≤ + ρ*A*h^2*((∫ x, ‖u.value s x‖^2)+ + ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) := by + have hσ : 0 < 1/(3*(K:ℝ)) := by positivity + obtain ⟨A,hA,hbound⟩ := scaled_nuclear_near_bound hκ hσ + refine ⟨A,hA,fun m n u s i h ρ hh hh1 hρ index hindex G hG => ?_⟩ + apply hbound m n u s i (fun a => G (gaussLatticePoint h (index a))) h ρ hh hh1 hρ + intro a b hab + have he := transportedGauss_separation hh index hindex G hK hG a b hab + convert he using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..2156966cda61d9386e244369be3df1055c17e1d1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNearGrid.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserIntegrability +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeIntegral +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedGrid + +namespace OAI + +/-! Near cells have uniformly bounded continuous Coulomb mass after the +actual Moser transport. The bound is independent of the enclosing box. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem transported_near_cube_distance {h : ℝ} (hh : 0 < h) + (G : Position → Position) {L : ℝ≥0} (hL : 0 < L) (hG : LipschitzWith L G) + {y b x : Position} (hnear : ‖y-G b‖ ≤ 4*(L:ℝ)*h) (hx : x ∈ positionCube b h) : + ‖y-G x‖ < 6*(L:ℝ)*h := by + have hn : ‖G x-G b‖ ≤ (L:ℝ)*h := + (hG.norm_sub_le x b).trans (mul_le_mul_of_nonneg_left + (positionCube_norm_sub_le hh.le hx) L.coe_nonneg) + have ht := norm_sub_le_norm_sub_add_norm_sub y (G b) (G x) + rw [norm_sub_rev (G b) (G x)] at ht + have hp : 0 < (L:ℝ)*h := mul_pos (by exact_mod_cast hL) hh + linarith + +theorem transported_near_kernel_eq {h : ℝ} (hh : 0 < h) + (G : Position → Position) {L : ℝ≥0} (hL : 0 < L) (hG : LipschitzWith L G) + {y b x : Position} (hnear : ‖y-G b‖ ≤ 4*(L:ℝ)*h) (hx : x ∈ positionCube b h) : + Coulomb.coulombKernel (y-G x) = Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G x) := by + have hm : y-G x ∈ Metric.ball (0:Position) (6*(L:ℝ)*h) := by + simpa only [Metric.mem_ball,dist_zero_right] using + transported_near_cube_distance hh G hL hG hnear hx + exact (Set.indicator_of_mem hm _).symm + +theorem moser_near_grid_integral_bound (hpublished : PublishedC4FlowInput) + {rho H S : ℝ} (hrho : 0 < rho) (hH : 0 ≤ H) (hS : 0 ≤ S) + (V : Position → ℝ) (hV : ContDiff ℝ 6 V) + (hbound : ∀ x, |manufacturedCharge V x| ≤ rho/2) + (hsupport : tsupport V ⊆ slabDomain H S) + (G : Position → ℝ → Position) (hG : IsUnitTimeFlow (moserVelocity rho V) G) + (hbij : Function.Bijective (fun x => G x 1)) + (hfix : ∀ x, x ∉ tsupport V → G x 1 = x) + {L : ℝ≥0} (hL : 0 < L) (hLip : LipschitzWith L (fun x => G x 1)) + {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) + (hsub : ∀ i, positionCube (gaussCellCenter h (index i)) h ⊆ slabDomain H S) + (y : Position) (hnear : ∀ i, ‖y-G (gaussCellCenter h (index i)) 1‖ ≤ 4*(L:ℝ)*h) : + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1))) ≤ 108*Real.pi*(L:ℝ)^2*h^2 := by + have hi := moser_coulomb_integrableOn hpublished hrho hH hS V hV hbound hsupport G hG hbij hfix y + have ht := moser_truncatedCoulomb_integrable hpublished hrho V hV hbound hsupport + G hG hbij hfix y (6*(L:ℝ)*h) + calc + _ = ∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, + Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G x 1) := by + apply Finset.sum_congr rfl + intro i _ + rw [positionCellIntegral_eq_setIntegral _ hh.le _ (hi.mono_set (hsub i))] + apply setIntegral_congr_fun (positionCube_isClosed _ _).measurableSet + intro x hx + exact transported_near_kernel_eq hh (fun x => G x 1) hL hLip (hnear i) hx + _ ≤ ∫ x in slabDomain H S, Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G x 1) := + grid_cell_integral_sum_le_on index hindex hh hsub _ ht + (fun x => Coulomb.truncatedCoulomb_nonneg _ _) + _ ≤ 3*Real.pi*(6*(L:ℝ)*h)^2 := + moser_truncatedCoulomb_bound hpublished hrho V hV hbound hsupport G hG hbij hfix y (by positivity) + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNodes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..350908c7bb90dbaaf8fe94eaf14fa3f5277cb165 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Nuclei/TransportedNodes.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserInverse +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.Cubature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCoordinates + +namespace OAI + +/-! The actual tensor Gauss nodes on a cubic lattice are separated before +transport, after transport, and after rational rounding. The enclosing finite +set of cells will determine the nucleus count in the final construction. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb + +abbrev GaussLatticeIndex := (Fin 3 → ℤ) × (Fin 3 → Fin 2) + +def gaussLatticePoint (h : ℝ) (i : GaussLatticeIndex) : Position := + WithLp.toLp 2 (fun a => h * ((i.1 a : ℝ) + gaussNode (i.2 a) / 2)) + +theorem gaussAbscissa_bounds : (1 / 2 : ℝ) < gaussAbscissa ∧ gaussAbscissa < 2 / 3 := by + have hp := gaussAbscissa_pos + have hs := gaussAbscissa_sq + constructor <;> nlinarith + +theorem gaussNode_bounds (b : Fin 2) : + -gaussAbscissa ≤ gaussNode b ∧ gaussNode b ≤ gaussAbscissa := by + fin_cases b <;> norm_num [gaussNode, gaussAbscissa_pos.le] + +theorem gauss_lattice_coordinate_separation {h : ℝ} (hh : 0 < h) + (k l : ℤ) (b c : Fin 2) (hne : k ≠ l ∨ b ≠ c) : + h / 3 ≤ |h * ((k : ℝ) + gaussNode b / 2) - + h * ((l : ℝ) + gaussNode c / 2)| := by + have hb := gaussNode_bounds b + have hc := gaussNode_bounds c + have ha := gaussAbscissa_bounds + rcases lt_trichotomy k l with hkl | hkl | hkl + · have hi : (k : ℝ) + 1 ≤ l := by exact_mod_cast (show k + 1 ≤ l by omega) + have hprod := mul_nonneg hh.le (show 0 ≤ gaussNode c - gaussNode b + 2 * gaussAbscissa by linarith) + have hscale := mul_pos hh (show 0 < (2 / 3 : ℝ) - gaussAbscissa by linarith) + have hInt := mul_nonneg hh.le (show 0 ≤ (l : ℝ) - k - 1 by linarith) + nlinarith [neg_le_abs (h * ((k : ℝ) + gaussNode b / 2) - + h * ((l : ℝ) + gaussNode c / 2))] + · subst l + have hbc : b ≠ c := hne.resolve_left (not_not.mpr rfl) + have hplus := le_abs_self (h * ((k : ℝ) + gaussNode b / 2) - + h * ((k : ℝ) + gaussNode c / 2)) + have hminus := neg_le_abs (h * ((k : ℝ) + gaussNode b / 2) - + h * ((k : ℝ) + gaussNode c / 2)) + have hscale := mul_pos hh (show 0 < gaussAbscissa - (1 / 3 : ℝ) by linarith) + fin_cases b <;> fin_cases c <;> norm_num [gaussNode] at * <;> nlinarith + · have hi : (l : ℝ) + 1 ≤ k := by exact_mod_cast (show l + 1 ≤ k by omega) + have hprod := mul_nonneg hh.le (show 0 ≤ gaussNode b - gaussNode c + 2 * gaussAbscissa by linarith) + have hscale := mul_pos hh (show 0 < (2 / 3 : ℝ) - gaussAbscissa by linarith) + have hInt := mul_nonneg hh.le (show 0 ≤ (k : ℝ) - l - 1 by linarith) + nlinarith [le_abs_self (h * ((k : ℝ) + gaussNode b / 2) - + h * ((l : ℝ) + gaussNode c / 2))] + +theorem gaussLatticePoint_separation {h : ℝ} (hh : 0 < h) + (i j : GaussLatticeIndex) (hne : i ≠ j) : + h / 3 ≤ ‖gaussLatticePoint h i - gaussLatticePoint h j‖ := by + have hex : ∃ a, i.1 a ≠ j.1 a ∨ i.2 a ≠ j.2 a := by + by_contra hn + push Not at hn + exact hne (Prod.ext (funext (fun a => (hn a).1)) (funext (fun a => (hn a).2))) + obtain ⟨a, ha⟩ := hex + have hcoord := gauss_lattice_coordinate_separation hh (i.1 a) (j.1 a) (i.2 a) (j.2 a) ha + have hb := PiLp.norm_apply_le (gaussLatticePoint h i - gaussLatticePoint h j) a + change |h * ((i.1 a : ℝ) + gaussNode (i.2 a) / 2) - + h * ((j.1 a : ℝ) + gaussNode (j.2 a) / 2)| ≤ _ at hb + exact hcoord.trans hb + +/-- The inverse Lipschitz estimate gives a quantitative separation suitable +for rational nuclear placement, for any finite selection of cells. -/ +theorem transportedGauss_rounding_injective {m denominator : ℕ} + (hdenom : 0 < denominator) {h : ℝ} (hh : 0 < h) + (index : Fin m → GaussLatticeIndex) (hindex : Function.Injective index) + (G : Position → Position) {C : ℝ≥0} (hC : 0 < C) + (hG : AntilipschitzWith C G) + (hprecision : 6 / (denominator : ℝ) < h / (3 * (C : ℝ))) : + Function.Injective (fun i => roundPosition denominator (G (gaussLatticePoint h (index i)))) := by + apply roundPosition_injective hdenom + intro i j hij + have hbase := gaussLatticePoint_separation hh (index i) (index j) (fun h => hij (hindex h)) + have htrans := hG.le_mul_dist (gaussLatticePoint h (index i)) (gaussLatticePoint h (index j)) + simp only [dist_eq_norm] at htrans + have hdiv : h / (3 * (C : ℝ)) ≤ + ‖G (gaussLatticePoint h (index i)) - G (gaussLatticePoint h (index j))‖ := by + apply (div_le_iff₀ (show 0 < 3 * (C : ℝ) by positivity)).mpr + nlinarith + exact hprecision.trans_le hdiv + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle.lean new file mode 100644 index 0000000000000000000000000000000000000000..d30985eaa5574df23894f77e5153206de75076f5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle.lean @@ -0,0 +1,432 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AbsoluteNuclearForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AffinePhysicalOutput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AffinePhysicalThreshold +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ApproximateBisection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AtomicOutputs +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedFormCross +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedPotentialOperator +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionLocation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionMachine +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedContactCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationComponents +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedGraphError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedHoppingBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedLipschitzBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedMatrixError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationCoefficientError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationCoulombBrackets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationEndpointSigns +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationGraphBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationMesh +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationRationalBracket +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationSquareError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombKernel +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombMass +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombTruncation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedRawModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedWells +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGaussEquiv +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGaussLabels +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredPhysicalThreshold +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalResidualPairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlater +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlaterKinetic +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlaterSynthesis +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalTensor +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactCoulombJets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactCoulombSmooth +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactNuclearPairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalNuclearError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSobolevCore +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSourceGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSourcePairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSourceTransport +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ComplexFormSplit +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ComplexMollification +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactAdjustment +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactBaseSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibratedGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibrationScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCanonicalEdge +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactClosedCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactDisplacement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactEdgeNumber +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactExtent +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGadgetStability +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGadgets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGeometryBlockSemantics +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGlobal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGlobalSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightBisection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediator +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediatorGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediatorLinks +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactPathBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactPolynomialGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactPositionArray +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactQuotientBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGadget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGlobal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalLocal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRealization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactSourceGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactSourceInputCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactStrips +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactTemplates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoordinateLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoreOrbitalCongruence +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoreOrbitalProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoreTensorFiber +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedCrossBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedCrossForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedDiagonalBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedManufacturedResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedNuclearError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedOneElectronProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedRemainderGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedResidualPairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedStateCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCubeCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCubeModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombEvaluationError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombEvaluationParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombFarCell +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGramApprox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombInverseFifth +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombKernelHomogeneity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombKernelSmooth +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombNormalizationError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPacketCoercivity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPacketTests +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPackets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPairEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPairSum +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPoisson +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombQuadratureBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombRawEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombSourceCubature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetRange +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTruncationSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CountertermEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeIntegral +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeMeasure +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.DiagonalPenalty +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.DirectionalFourthDerivative +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ExceptionalCellVolume +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ExplicitVerticalCutoff +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.FullSpinTensorCoefficients +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.FullTensorComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianFrequency +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianJetBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianLine +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianMollification +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianPacket +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianPoincare +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianScalar +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GraphCoefficientStability +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridGroundUpper +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridNodePrecision +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridNuclei +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GroundRoundingInterval +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1BoundedForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1FiniteProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1GraphCore +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1PairingBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatDensityModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatKernelModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatSampleError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingBox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HydrogenInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.InverseFifthCutoffGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.InverseFifthGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.IsolatedForms +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.IsolatedPerturbation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.IsolatedSpectrum +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCorrectedMatrixError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCorrectedOneBody +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulomb +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombBox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombRadial +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombSymmetry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombTranslation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCountertermMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCounterterms +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDensityMoment +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDualMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFockStates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFourIndex +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGradientMoments +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGramConstants +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGramSpacing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGroundUpper +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHigherMoments +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbard +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardEntries +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardTensor +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLeakage +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLinearCoulomb +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLinearOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedMatrixDecayBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModeDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedMomentTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedMultiwellResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedNuclearHardy +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOneBody +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOneBodyMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOrbitalGram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOverlapSpacing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedRawDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedSpinOperator +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTensorResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTransition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedWellResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedCoercivity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedCompactQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedComplementBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedEuler +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFarGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFrequency +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGapScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridGroundComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridWitness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGrowingGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedHubbardComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedManyElectron +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedNuclearComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedNuclearForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedNuclearTensorLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOneElectronGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalNuclearError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedPolynomialComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedPreciseResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedProjectedLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualMajorant +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualPairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedScalarParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedScaleThreshold +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedSlabLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorCoercivity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTransport +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedUniformComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedUniformFlow +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedUniformGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedVelocityEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWeakResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.MixedSlater +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.MovingWells +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationArithmetic +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NumericalGridRounding +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NumericalSquare +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneBodyScaleBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronClosure +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronComplexLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronFormDecomposition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronProjectedLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronTrial +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalBasisExtension +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCellVolume +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalComplementCount +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCutoff +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCutoffTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalDerivative +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalGraphBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalJetBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalNuclearTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalTensor +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCompactnessEstimates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCutoffTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarDistributionAxes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarExponentialEnvelope +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarFieldBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcingModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarFrameBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGapFromUniqueness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGradientMoments +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundIdentity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundTransform +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundUniqueness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatDifferential +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatEvolution +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatKernel +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatLimit +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatTimeModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatTruncation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHopping +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHoppingBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarIMS +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarIMSBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLaplaceIBP +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLocalization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLowerTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDecay +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeEnergy +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeH1 +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeJets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeProperties +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNearGroundCompactness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalizationBox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalizationTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalized +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarOverlap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarPartition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarPolynomialScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarProjectionGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarRadial +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolvent +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventEquation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventTails +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarScaleChoice +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSharpDecay +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSiteCutoffs +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSliceProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolevDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSpectralInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarTestCauchy +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarTranslatedGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarUniformCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWeakConstant +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellBottom +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellLocalization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellOverlap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorSourceCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorSourceContactCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorSpacing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalBoxRound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalClamp +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalContactBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalContactMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalExponential +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalFieldDifferences +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalGaussNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatBox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatPlaneError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatSample +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalLogScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalResolventError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSixQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSmoothTransition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalTaylorRegisters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalTripleQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RayleighGround +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealMollification +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealOneElectronState +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealSpinOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RectangleQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ResolventNumericalBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ResolventSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScalarMollification +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScalarScaleBudgets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScaledNuclearNear +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SeparatedNuclearNear +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SharpBlockPerturbation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ShiftedHubbardBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ShiftedPhysicalForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SingleSpinSource +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SlowLogarithmicExtent +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SmoothCutoffApproximation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SobolevDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SobolevDensityInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFormIdentity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFormIntegrals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFrameBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitIntegratedBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitProjectionBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitProjectionPairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitPullback +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitSpectralBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitTestFunctions +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TM2Composition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ThirdOrderBottom +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ThirdOrderPerturbation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ThirdOrderScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGauss +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussList +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TruncatedNuclearForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.UnitBinaryInclusion +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.UnitProgramGroundInterval +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCutoffTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalEnergy +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalFactorization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalMode +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalOscillatorGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalSliceProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalSpectralInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakComplexLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Laplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Pairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCapDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCapRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCover +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellFieldOrbitalResidual diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AbsoluteNuclearForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AbsoluteNuclearForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..708aa3b7b605030609952f8eb53d480c293c2f71 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AbsoluteNuclearForm.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridPotential +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.WeightedPotentialBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularity + +namespace OAI + +/-! Absolute-value form bound for unit-nucleus replacement. It holds +for every spin component of every many-electron weak-H1 state. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem manufactured_grid_absolute_form_error (hpublished : PublishedC4FlowInput) + (L K : ℝ≥0) (hL : 0 < L) (hK : 0 < K) : + ∃ C A : ℝ, 1 ≤ C ∧ 1 ≤ A ∧ + ∀ (rho H S freq scale : ℝ) (m : ℕ) (u : Fin m → PlanarPosition), + 0 < rho → 0 ≤ H → 1 ≤ S → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ rho/2) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ (G : Position → ℝ → Position), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + Function.Bijective (fun x => G x 1) → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ D^k) → + LipschitzWith L (fun x => G x 1) → AntilipschitzWith K (fun x => G x 1) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ 1 → + (⋃ i, positionCube (gaussCellCenter h (index i)) h) = slabDomain H S → + ∀ (n : ℕ) (w : Coulomb.H1Vector n) (s : SpinConfiguration n) (i : Fin n), + Integrable (fun x => |gridNuclearPotential index (fun x => G x 1) rho h (Coulomb.position x i)- + (slabPotential rho H S (Coulomb.position x i)+ + manufacturedWellField freq scale S u (Coulomb.position x i))| * ‖w.value s x‖^2) ∧ + (∫ x, |gridNuclearPotential index (fun x => G x 1) rho h (Coulomb.position x i)- + (slabPotential rho H S (Coulomb.position x i)+ + manufacturedWellField freq scale S u (Coulomb.position x i))| *‖w.value s x‖^2) ≤ + rho*(24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4)+108*Real.pi*(L:ℝ)^2*h^2)* + (∫ x, ‖w.value s x‖^2)+ + rho*A*h^2*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (i,k) x‖^2) := by + obtain ⟨C,hC,hpoint⟩ := manufactured_grid_potential_error hpublished + have hκ : 0 < 6*(L:ℝ) := by positivity + obtain ⟨A,hA,hnear⟩ := transportedGauss_truncated_form hκ K hK + refine ⟨C,A,hC,hA,?_⟩ + intro rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix D hD hGD hLip hAnti + ι _ index hindex h hh hh1 hcover n w s i + let F : Position → ℝ := fun y => gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y) + let B := rho*(24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4)+108*Real.pi*(L:ℝ)^2*h^2) + let R : ι × (Fin 3 → Fin 2) → Position := fun a => G (gaussLatticePoint h (gridGaussIndex index a)) 1 + have hF : Measurable F := (gridNuclearPotential_measurable index (fun x => G x 1) rho h).sub + (((slabPotential_continuous hrho.le hH (by linarith)).add + (manufacturedWellField_C7 freq scale S u).continuous).measurable) + have he := weighted_potential_absolute_bound w s i F hF R (6*(L:ℝ)*h) B (rho*h^3/8) + (hpoint rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix + D hD hGD L hL hLip index hindex h hh hh1 hcover) + have hn := hnear n w s i h rho hh hh1 hrho.le (gridGaussIndex index) + (gridGaussIndex_injective index hindex) (fun x => G x 1) hAnti + exact ⟨he.1, he.2.trans (add_le_add le_rfl hn)⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalOutput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..65a17e2e2c9a745d5f88db77858c42a33623a5c8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalOutput.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AffinePhysicalThresholdProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.UnitCoulombProgram + +namespace OAI + +/-! A canonical unit-charge instance with the complete physical scalar offset. +The coordinate and threshold metadata remain explicit until the source program +supplies the same fixed polynomial scales to both components. -/ + +namespace ContinuumCoulomb.AffinePhysicalOutput +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := PhysicalNuclearProgram.Input × AffinePhysicalThreshold.Input + +def inputCode : Input → List Bool := + prodCode PhysicalNuclearProgram.inputCode AffinePhysicalThreshold.inputCode + +noncomputable def argument (rho : ℕ) (x : Input) : UnitCoulombProgram.Input := + (x.1,(x.2.1.2.1,AffinePhysicalThreshold.value rho x.2)) + +noncomputable def value (rho U C K : ℕ) (x : Input) : UnitCoulomb := + UnitCoulombProgram.value rho U C K (argument rho x) + +noncomputable opaque argumentProgram (rho : ℕ) : + Procedure inputCode UnitCoulombProgram.inputCode (argument rho) := by + let geom := Procedure.first PhysicalNuclearProgram.inputCode AffinePhysicalThreshold.inputCode + let numbers := Procedure.second PhysicalNuclearProgram.inputCode AffinePhysicalThreshold.inputCode + let count := AffinePhysicalThreshold.electronsProgram.comp numbers + let endpoints := (AffinePhysicalThreshold.program rho).comp numbers + exact geom.pair (count.pair endpoints) + +noncomputable opaque program (rho U C K : ℕ) : + Procedure inputCode unitCoulombCodec.encode (value rho U C K) := + (UnitCoulombProgram.program rho U C K).comp (argumentProgram rho) + +noncomputable def certificate (rho U C K : ℕ) : + Turing.TM2ComputableInPolyTime inputCode unitCoulombCodec.encode (value rho U C K) := + (program rho U C K).toTM2 + +theorem nuclei (rho U C K : ℕ) (x : Input) : + (value rho U C K x).nuclei = PhysicalNuclearProgram.nuclei rho U C K x.1 := rfl + +theorem electrons (rho U C K : ℕ) (x : Input) : + (value rho U C K x).electrons = x.2.1.2.1 := rfl + +theorem lower (rho U C K : ℕ) (x : Input) : + (value rho U C K x).lower.value = (AffinePhysicalThreshold.value rho x.2).1 := + NuclearCoordinateOutput.rational_value _ + +theorem upper (rho U C K : ℕ) (x : Input) : + (value rho U C K x).upper.value = (AffinePhysicalThreshold.value rho x.2).2 := + NuclearCoordinateOutput.rational_value _ + +theorem actual_error (rho U C K : ℕ) (hrho : 0 < rho) (x : Input) + (hmesh : 0 < x.2.1.1.1) {m : ℕ} + (u : Fin m → CoulombPairSum.Point) (hu : Function.Injective u) + (hsites : x.2.2.2.1 = List.ofFn u) : + let v := CoulombPairSum.exactTotal (GaussianFrequency.frequency rho) u + |((value rho U C K x).lower.value:ℝ)- + (AffinePhysicalThreshold.exactValue rho x.2 v).1| ≤ 1/(x.2.1.2.2.1+1:ℝ) ∧ + |((value rho U C K x).upper.value:ℝ)- + (AffinePhysicalThreshold.exactValue rho x.2 v).2| ≤ 1/(x.2.1.2.2.1+1:ℝ) := by + dsimp only + rw [lower,upper] + exact AffinePhysicalThreshold.actual_error rho hrho x.2 hmesh u hu hsites + +theorem valid (rho U C K : ℕ) (x : Input) (hne : 0 < x.2.1.2.1) + (hpositions : ((PhysicalNuclearProgram.nuclei rho U C K x.1).map BinaryPosition.value).Nodup) + (hgap : (1:ℚ) ≤ CenteredPhysicalThreshold.amplification rho x.2.1.1.1*x.2.2.1^2* + (x.2.1.2.2.2.2-x.2.1.2.2.2.1)) : (value rho U C K x).Valid := by + apply UnitCoulombProgram.valid rho U C K (x.1,(x.2.1.2.1,AffinePhysicalThreshold.value rho x.2)) + hne hpositions + rw [AffinePhysicalThreshold.gap] + exact hgap + +end ContinuumCoulomb.AffinePhysicalOutput + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalThreshold.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cb5a2b3281cd7f5efe73454db0c5b081fe182ce --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AffinePhysicalThreshold.lean @@ -0,0 +1,127 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredPhysicalThresholdProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombPairSumProgram + +namespace OAI + +/-! The complete scalar shift in the unit-charge construction. Input endpoints +already contain the exact mediator offset. The remaining finite shift is the +sum of edge weights and the off-site Coulomb energy; only the latter and the +one-particle reference require numerical approximation. -/ + +noncomputable section +namespace ContinuumCoulomb.AffinePhysicalThreshold + +abbrev Input := CenteredPhysicalThreshold.Input × (ℚ × (List CoulombPairSum.Point × List ℚ)) + +def pairPrecision (x : Input) : ℕ := + (8*x.1.1.1^3+1)*(2*(x.1.2.2.1+1)) + +def pairValue (rho : ℕ) (x : Input) : ℚ := + CoulombPairSum.value rho (pairPrecision x,x.2.2.1) + +def finiteValue (rho : ℕ) (x : Input) : ℚ×ℚ := + (x.2.1^2*(x.1.2.2.2.1-x.2.2.2.sum)-pairValue rho x, + x.2.1^2*(x.1.2.2.2.2-x.2.2.2.sum)-pairValue rho x) + +def argument (rho : ℕ) (x : Input) : CenteredPhysicalThreshold.Input := + (x.1.1,(x.1.2.1,(2*(x.1.2.2.1+1),finiteValue rho x))) + +def value (rho : ℕ) (x : Input) : ℚ×ℚ := + CenteredPhysicalThreshold.value rho (argument rho x) + +def exactFinite (x : Input) (v : ℝ) : ℝ×ℝ := + ((x.2.1:ℝ)^2*((x.1.2.2.2.1:ℝ)-(x.2.2.2.sum:ℝ))-v, + (x.2.1:ℝ)^2*((x.1.2.2.2.2:ℝ)-(x.2.2.2.sum:ℝ))-v) + +def exactValue (rho : ℕ) (x : Input) (v : ℝ) : ℝ×ℝ := + (CenteredPhysicalThreshold.actualOffset rho x.1+ + (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)*(exactFinite x v).1, + CenteredPhysicalThreshold.actualOffset rho x.1+ + (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)*(exactFinite x v).2) + +theorem pair_budget (rho : ℕ) (hrho : 0 < rho) (x : Input) : + (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)/(pairPrecision x+1:ℝ) ≤ + 1/(2*((x.1.2.2.1:ℝ)+1)) := by + have ha := CenteredPhysicalThreshold.amplification_bound rho x.1.1.1 hrho + have hp : 0 < 2*((x.1.2.2.1:ℝ)+1) := by positivity + have hd : 0 < (pairPrecision x:ℝ)+1 := by positivity + apply (div_le_div_iff₀ hd hp).mpr + have hm := mul_le_mul_of_nonneg_right ha.2 hp.le + simp only [pairPrecision,Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_pow, + Nat.cast_ofNat] + nlinarith + +theorem reference_budget (x : Input) : + 1/((2*(x.1.2.2.1+1):ℕ)+1:ℝ) ≤ 1/(2*((x.1.2.2.1:ℝ)+1)) := by + apply one_div_le_one_div_of_le (by positivity) + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_one] + linarith + +theorem value_error (rho : ℕ) (hrho : 0 < rho) (x : Input) + (hmesh : 0 < x.1.1.1) (v : ℝ) + (hv : |(pairValue rho x:ℝ)-v| ≤ 1/(pairPrecision x+1:ℝ)) : + |((value rho x).1:ℝ)-(exactValue rho x v).1| ≤ 1/(x.1.2.2.1+1:ℝ) ∧ + |((value rho x).2:ℝ)-(exactValue rho x v).2| ≤ 1/(x.1.2.2.1+1:ℝ) := by + have ha := CenteredPhysicalThreshold.amplification_bound rho x.1.1.1 hrho + have hp : 0 < (x.1.2.2.1:ℝ)+1 := by positivity + have hoff := (CenteredPhysicalThreshold.offset_error rho hrho (argument rho x) hmesh).trans + (reference_budget x) + have hpair : (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)* + |(pairValue rho x:ℝ)-v| ≤ 1/(2*((x.1.2.2.1:ℝ)+1)) := by + apply (mul_le_mul_of_nonneg_left hv ha.1).trans + simpa only [mul_one_div] using pair_budget rho hrho x + have hsum : 1/(2*((x.1.2.2.1:ℝ)+1))+1/(2*((x.1.2.2.1:ℝ)+1)) = + 1/((x.1.2.2.1:ℝ)+1) := by + field_simp [hp.ne'] + ring + have hid1 : ((value rho x).1:ℝ)-(exactValue rho x v).1 = + ((CenteredPhysicalThreshold.offset rho (argument rho x):ℝ)-CenteredPhysicalThreshold.actualOffset rho x.1)- + (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)*((pairValue rho x:ℝ)-v) := by + simp only [value,CenteredPhysicalThreshold.value,exactValue,exactFinite,argument,finiteValue, + Rat.cast_add,Rat.cast_sub,Rat.cast_mul,Rat.cast_pow] + ring + have hid2 : ((value rho x).2:ℝ)-(exactValue rho x v).2 = + ((CenteredPhysicalThreshold.offset rho (argument rho x):ℝ)-CenteredPhysicalThreshold.actualOffset rho x.1)- + (CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)*((pairValue rho x:ℝ)-v) := by + simp only [value,CenteredPhysicalThreshold.value,exactValue,exactFinite,argument,finiteValue, + Rat.cast_add,Rat.cast_sub,Rat.cast_mul,Rat.cast_pow] + ring + have hoff' : |(CenteredPhysicalThreshold.offset rho (argument rho x):ℝ)- + CenteredPhysicalThreshold.actualOffset rho x.1| ≤ 1/(2*((x.1.2.2.1:ℝ)+1)) := hoff + have htri := abs_sub_le ((CenteredPhysicalThreshold.offset rho (argument rho x):ℝ)- + CenteredPhysicalThreshold.actualOffset rho x.1) 0 + ((CenteredPhysicalThreshold.amplification rho x.1.1.1:ℝ)*((pairValue rho x:ℝ)-v)) + simp only [sub_zero,zero_sub,abs_neg] at htri + have hbound := htri.trans + (add_le_add hoff' (by simpa only [abs_mul,abs_of_nonneg ha.1] using hpair)) + rw [hsum] at hbound + constructor + · rw [hid1] + exact hbound + · rw [hid2] + exact hbound + +theorem actual_error (rho : ℕ) (hrho : 0 < rho) (x : Input) + (hmesh : 0 < x.1.1.1) {m : ℕ} + (u : Fin m → CoulombPairSum.Point) (hu : Function.Injective u) + (hsites : x.2.2.1 = List.ofFn u) : + let v := CoulombPairSum.exactTotal (GaussianFrequency.frequency rho) u + |((value rho x).1:ℝ)-(exactValue rho x v).1| ≤ 1/(x.1.2.2.1+1:ℝ) ∧ + |((value rho x).2:ℝ)-(exactValue rho x v).2| ≤ 1/(x.1.2.2.1+1:ℝ) := by + apply value_error rho hrho x hmesh + simpa only [pairValue,hsites] using + CoulombPairSum.error rho (pairPrecision x) hrho u hu + +theorem gap (rho : ℕ) (x : Input) : + (value rho x).2-(value rho x).1 = + CenteredPhysicalThreshold.amplification rho x.1.1.1*x.2.1^2* + (x.1.2.2.2.2-x.1.2.2.2.1) := by + rw [value,CenteredPhysicalThreshold.gap] + simp only [argument,finiteValue] + ring + +end ContinuumCoulomb.AffinePhysicalThreshold + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ApproximateBisection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ApproximateBisection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c7bc99cb391f2871808834791387336f5efb440 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ApproximateBisection.lean @@ -0,0 +1,220 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Data.Rat.Cast.Order +import Mathlib.Tactic + +namespace OAI + +/-! Approximate rational bisection for a Lipschitz residual. A numerically +ambiguous sign terminates with a certified residual bound; otherwise the +true endpoint signs are preserved. No monotonicity or derivative lower +bound is required. -/ + +namespace ContinuumCoulomb.ApproximateBisection + +structure Interval where + lo : ℚ + hi : ℚ + settled : Bool + deriving DecidableEq + +def midpoint (s : Interval) : ℚ := (s.lo + s.hi) / 2 + +def width (s : Interval) : ℝ := (s.hi : ℝ) - s.lo + +def step (δ : ℚ) (evaluate : ℚ → ℚ) (s : Interval) : Interval := + if s.settled then s + else if δ < evaluate (midpoint s) then ⟨midpoint s, s.hi, false⟩ + else if evaluate (midpoint s) < -δ then ⟨s.lo, midpoint s, false⟩ + else ⟨midpoint s, midpoint s, true⟩ + +def initial (a b : ℚ) : Interval := ⟨a, b, false⟩ + +def run (δ : ℚ) (evaluate : ℚ → ℚ) (a b : ℚ) (n : ℕ) : Interval := + (step δ evaluate)^[n] (initial a b) + +@[simp] theorem midpoint_cast (s : Interval) : + (midpoint s : ℝ) = ((s.lo : ℝ) + s.hi) / 2 := by + simp [midpoint] + +theorem midpoint_mem (s : Interval) (h : s.lo ≤ s.hi) : + s.lo ≤ midpoint s ∧ midpoint s ≤ s.hi := by + dsimp [midpoint] + constructor <;> linarith + +/-- The invariant concerns actual residual values, not numerical signs. -/ +structure Invariant (a b : ℚ) (f : ℝ → ℝ) (δ : ℚ) (s : Interval) : Prop where + lower : a ≤ s.lo + upper : s.hi ≤ b + ordered : s.lo ≤ s.hi + certified : s.settled = true → s.lo = s.hi ∧ |f s.lo| ≤ 2 * (δ : ℝ) + signs : s.settled = false → 0 ≤ f s.lo ∧ f s.hi ≤ 0 + +theorem initial_invariant {a b δ : ℚ} {f : ℝ → ℝ} + (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) : + Invariant a b f δ (initial a b) := by + refine ⟨le_rfl, le_rfl, hab, ?_, ?_⟩ + · simp [initial] + · intro _ + exact ⟨ha, hb⟩ + +theorem step_invariant {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} + (_hδ : 0 ≤ δ) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) + {s : Interval} (hs : Invariant a b f δ s) : + Invariant a b f δ (step δ evaluate s) := by + have hm := midpoint_mem s hs.ordered + have he := abs_le.mp (heval (midpoint s) ⟨hs.lower.trans hm.1, hm.2.trans hs.upper⟩) + unfold step + split_ifs with hd hp hn + · exact hs + · have hp' : (δ : ℝ) < evaluate (midpoint s) := by exact_mod_cast hp + refine ⟨hs.lower.trans hm.1, hs.upper, hm.2, ?_, ?_⟩ + · simp + · intro _ + exact ⟨by linarith [he.2], (hs.signs (by simpa using hd)).2⟩ + · have hn' : (evaluate (midpoint s) : ℝ) < -(δ : ℝ) := by exact_mod_cast hn + refine ⟨hs.lower, hm.2.trans hs.upper, hm.1, ?_, ?_⟩ + · simp + · intro _ + exact ⟨(hs.signs (by simpa using hd)).1, by linarith [he.1]⟩ + · have hp' : (evaluate (midpoint s) : ℝ) ≤ δ := by exact_mod_cast le_of_not_gt hp + have hn' : -(δ : ℝ) ≤ evaluate (midpoint s) := by exact_mod_cast le_of_not_gt hn + refine ⟨hs.lower.trans hm.1, hm.2.trans hs.upper, le_rfl, ?_, ?_⟩ + · intro _ + refine ⟨rfl, abs_le.mpr ?_⟩ + constructor <;> linarith [he.1, he.2] + · simp + +theorem step_width {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} + {s : Interval} (hs : Invariant a b f δ s) : + width (step δ evaluate s) ≤ width s / 2 := by + have ho : (s.lo : ℝ) ≤ s.hi := by exact_mod_cast hs.ordered + unfold step + split_ifs with hd hp hn + · have heq := (hs.certified hd).1 + simp only [width, heq, sub_self, zero_div, le_refl] + · simp only [width, midpoint_cast] + linarith + · simp only [width, midpoint_cast] + linarith + · simp only [width, sub_self] + linarith + +theorem run_invariant {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) (n : ℕ) : + Invariant a b f δ (run δ evaluate a b n) := by + induction n with + | zero => exact initial_invariant hab ha hb + | succ n ih => + change Invariant a b f δ ((step δ evaluate)^[n + 1] (initial a b)) + rw [Function.iterate_succ_apply'] + exact step_invariant hδ heval ih + +theorem run_width {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) (n : ℕ) : + width (run δ evaluate a b n) ≤ ((b : ℝ) - a) / 2 ^ n := by + induction n with + | zero => simp [run, initial, width] + | succ n ih => + have hw := step_width (evaluate := evaluate) (run_invariant hδ hab ha hb heval n) + have hrun : run δ evaluate a b (n + 1) = step δ evaluate (run δ evaluate a b n) := + Function.iterate_succ_apply' _ _ _ + rw [hrun] + calc + width (step δ evaluate (run δ evaluate a b n)) ≤ + width (run δ evaluate a b n) / 2 := hw + _ ≤ (((b : ℝ) - a) / 2 ^ n) / 2 := div_le_div_of_nonneg_right ih (by norm_num) + _ = ((b : ℝ) - a) / 2 ^ (n + 1) := by rw [pow_succ, div_div] + +theorem invariant_residual {a b δ : ℚ} {f : ℝ → ℝ} {L : ℝ} + (hδ : 0 ≤ δ) (hL : 0 ≤ L) + (hLip : ∀ x ∈ Set.Icc (a : ℝ) b, ∀ y ∈ Set.Icc (a : ℝ) b, + |f x - f y| ≤ L * |x - y|) + {s : Interval} (hs : Invariant a b f δ s) : + |f (midpoint s)| ≤ 2 * (δ : ℝ) + L * width s := by + have hl : (a : ℝ) ≤ s.lo := by exact_mod_cast hs.lower + have hu : (s.hi : ℝ) ≤ b := by exact_mod_cast hs.upper + have ho : (s.lo : ℝ) ≤ s.hi := by exact_mod_cast hs.ordered + have hm := midpoint_mem s hs.ordered + have hmlo : (s.lo : ℝ) ≤ midpoint s := by exact_mod_cast hm.1 + have hmhi : (midpoint s : ℝ) ≤ s.hi := by exact_mod_cast hm.2 + have hw : 0 ≤ width s := sub_nonneg.mpr ho + by_cases hd : s.settled = true + · obtain ⟨heq, herr⟩ := hs.certified hd + have he : midpoint s = s.lo := by simp [midpoint, heq] + rw [he] + exact herr.trans (le_add_of_nonneg_right (mul_nonneg hL hw)) + · have hsign := hs.signs (by simpa using hd) + have hmemb : (midpoint s : ℝ) ∈ Set.Icc (a : ℝ) b := ⟨hl.trans hmlo, hmhi.trans hu⟩ + have hleft := hLip (midpoint s) hmemb s.lo ⟨hl, ho.trans hu⟩ + have hright := hLip (midpoint s) hmemb s.hi ⟨hl.trans ho, hu⟩ + rw [abs_of_nonneg (sub_nonneg.mpr hmlo)] at hleft + rw [abs_of_nonpos (sub_nonpos.mpr hmhi)] at hright + have hlw : L * ((midpoint s : ℝ) - s.lo) ≤ L * width s := + mul_le_mul_of_nonneg_left (by dsimp [width]; linarith) hL + have hrw : L * -((midpoint s : ℝ) - s.hi) ≤ L * width s := + mul_le_mul_of_nonneg_left (by dsimp [width]; linarith) hL + have hδ' : 0 ≤ (δ : ℝ) := by exact_mod_cast hδ + apply abs_le.mpr + constructor + · have h := (neg_le_abs (f (midpoint s) - f s.lo)).trans hleft + linarith [hsign.1] + · have h := (le_abs_self (f (midpoint s) - f s.hi)).trans hright + linarith [hsign.2] + +/-- After `n` steps the returned rational has residual at most numerical +ambiguity plus the Lipschitz constant times the halved interval width. -/ +theorem run_residual {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} {L : ℝ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) (hL : 0 ≤ L) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) + (hLip : ∀ x ∈ Set.Icc (a : ℝ) b, ∀ y ∈ Set.Icc (a : ℝ) b, + |f x - f y| ≤ L * |x - y|) (n : ℕ) : + |f (midpoint (run δ evaluate a b n))| ≤ + 2 * (δ : ℝ) + L * (((b : ℝ) - a) / 2 ^ n) := by + exact (invariant_residual hδ hL hLip (run_invariant hδ hab ha hb heval n)).trans + (add_le_add_right (mul_le_mul_of_nonneg_left (run_width hδ hab ha hb heval n) hL) _) + +theorem run_mem {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) (n : ℕ) : + midpoint (run δ evaluate a b n) ∈ Set.Icc a b := by + have hi := run_invariant hδ hab ha hb heval n + have hm := midpoint_mem _ hi.ordered + exact ⟨hi.lower.trans hm.1, hm.2.trans hi.upper⟩ + +/-- Binary magnitude bounds give a number of bisection steps linear in +the requested precision and the magnitude exponent. -/ +theorem run_binary_precision {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} {L : ℝ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) (hL : 0 ≤ L) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) + (hLip : ∀ x ∈ Set.Icc (a : ℝ) b, ∀ y ∈ Set.Icc (a : ℝ) b, + |f x - f y| ≤ L * |x - y|) (B p : ℕ) + (hδp : (δ : ℝ) ≤ (2 ^ (p + 2))⁻¹) + (hLB : L ≤ 2 ^ B) (hwidth : (b : ℝ) - a ≤ 2 ^ B) : + |f (midpoint (run δ evaluate a b (2 * B + p + 1)))| ≤ (2 ^ p : ℝ)⁻¹ := by + have hw : 0 ≤ (b : ℝ) - a := sub_nonneg.mpr (by exact_mod_cast hab) + have hprod : L * ((b : ℝ) - a) ≤ (2 ^ B : ℝ) * 2 ^ B := + mul_le_mul hLB hwidth hw (by positivity) + have hden : 0 ≤ (2 ^ (2 * B + p + 1) : ℝ)⁻¹ := by positivity + have herror := run_residual hδ hab ha hb hL heval hLip (2 * B + p + 1) + have hnum := mul_le_mul_of_nonneg_right hprod hden + have hexact : 2 * (2 ^ (p + 2) : ℝ)⁻¹ + + (2 ^ B * 2 ^ B) * (2 ^ (2 * B + p + 1) : ℝ)⁻¹ = (2 ^ p : ℝ)⁻¹ := by + rw [show 2 * B + p + 1 = B + B + (p + 1) by omega] + simp only [pow_add, pow_succ] + field_simp + ring + calc + |f (midpoint (run δ evaluate a b (2 * B + p + 1)))| ≤ + 2 * (δ : ℝ) + (L * ((b : ℝ) - a)) * (2 ^ (2 * B + p + 1) : ℝ)⁻¹ := by + simpa only [div_eq_mul_inv, mul_assoc] using herror + _ ≤ 2 * (2 ^ (p + 2) : ℝ)⁻¹ + + (2 ^ B * 2 ^ B) * (2 ^ (2 * B + p + 1) : ℝ)⁻¹ := by + linarith + _ = (2 ^ p : ℝ)⁻¹ := hexact + +end ContinuumCoulomb.ApproximateBisection + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AtomicOutputs.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AtomicOutputs.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3c626bbd9a3fdee6a368df791f4546b373934ee --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/AtomicOutputs.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HydrogenInput +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPromise + +namespace OAI + +/-! Fixed one-electron outputs for the decidable one-spin source branch. +The only spectral input is the precisely stated published hydrogen bottom. -/ + +noncomputable section +namespace ContinuumCoulomb +open MeasureTheory + +theorem oneElectron_antisymmetric (w : Coulomb.H1Vector 1) : Coulomb.Antisymmetric w := by + intro p s + have hp : p=1 := Subsingleton.elim _ _ + subst p + filter_upwards [] with x + have hx : Coulomb.permute (1 : Equiv.Perm (Fin 1)) x=x := by ext i; rfl + simp [hx] + +def atomicData : UnitNuclearData where + nuclei := 1 + nuclei_pos := by decide + position := fun _ => 0 + distinct := fun _ _ _ => Subsingleton.elim _ _ + electrons := 1 + electrons_pos := by decide + +theorem atomic_form (w : FormState 1) : unitCoulombForm atomicData w = hydrogenForm 0 w.val := by + have ha (y : Position) : Coulomb.attraction atomicData.toNuclearData.toNuclei y = + Coulomb.coulombKernel y := by + unfold Coulomb.attraction + erw [Fin.sum_univ_one] + have hr : realPosition (0 : Fin 3 → ℚ)=0 := by ext i; simp [realPosition] + simp only [atomicData,UnitNuclearData.toNuclearData,NuclearData.toNuclei, + Nat.cast_one,hr,sub_zero,one_mul] + have hp : Coulomb.pairEnergy w.val=0 := by simp [Coulomb.pairEnergy] + change Coulomb.kinetic w.val-Coulomb.nuclearEnergy atomicData.toNuclearData.toNuclei w.val+ + Coulomb.pairEnergy w.val = hydrogenForm 0 w.val + simp only [hp,add_zero,Coulomb.nuclearEnergy,ha,Fin.sum_univ_one, + hydrogenForm,singlePoleEnergy,sub_zero] + +theorem atomic_ground : unitGroundEnergy atomicData = hydrogenEnergy 0 := by + unfold unitGroundEnergy hydrogenEnergy oneElectronEnergy + congr 1 + ext e + constructor + · rintro ⟨w,hw,rfl⟩ + exact ⟨w.val,hw,congrArg (fun t : ℝ => (t:EReal)) (atomic_form w)⟩ + · rintro ⟨w,hw,rfl⟩ + exact ⟨⟨w,oneElectron_antisymmetric w⟩,hw, + congrArg (fun t : ℝ => (t:EReal)) (atomic_form ⟨w,oneElectron_antisymmetric w⟩).symm⟩ + +def atomicOutput (yes : Bool) : UnitCoulomb where + nuclei := [⟨BinaryRational.ofRat 0,BinaryRational.ofRat 0,BinaryRational.ofRat 0⟩] + electrons := 1 + lower := BinaryRational.ofRat (if yes then 0 else -2) + upper := BinaryRational.ofRat (if yes then 1 else -1) + +theorem atomicOutput_valid (yes : Bool) : (atomicOutput yes).Valid := by + refine ⟨by change 0<1; decide,by change 0<1; decide,?_,?_,?_,?_,?_⟩ + · intro i + change Fin 1 at i + fin_cases i + change (0:ℕ)<1 ∧ (0:ℕ)<1 ∧ (0:ℕ)<1 + decide + · intro i j _ + apply Fin.ext + have hi : i.val<1 := i.isLt + have hj : j.val<1 := j.isLt + omega + · cases yes <;> decide + · cases yes <;> decide + · cases yes <;> norm_num [atomicOutput] + +theorem atomicOutput_data (yes : Bool) (h : (atomicOutput yes).Valid) : + (atomicOutput yes).toData h = atomicData := by + cases yes <;> unfold UnitCoulomb.toData atomicOutput atomicData <;> + congr 1 <;> funext i <;> fin_cases i <;> + ext j <;> fin_cases j <;> norm_num [atomicOutput,UnitCoulomb.toData,atomicData,BinaryPosition.value] + +theorem atomicOutput_yes (hh : PublishedHydrogenBottom) : atomicOutput true ∈ unitCoulombPromise.yes := by + refine ⟨atomicOutput_valid true,?_⟩ + rw [atomicOutput_data,atomic_ground,hh] + simp only [atomicOutput,BinaryRational.value_ofRat,ite_true,Rat.cast_zero] + change ((-1/2:ℝ):EReal) ≤ ((0:ℝ):EReal) + exact EReal.coe_le_coe (by norm_num) + +theorem atomicOutput_no (hh : PublishedHydrogenBottom) : atomicOutput false ∈ unitCoulombPromise.no := by + refine ⟨atomicOutput_valid false,?_⟩ + rw [atomicOutput_data,atomic_ground,hh] + simp only [atomicOutput,BinaryRational.value_ofRat,Bool.false_eq_true,ite_false,Rat.cast_neg,Rat.cast_one] + change ((-1:ℝ):EReal) ≤ ((-1/2:ℝ):EReal) + exact EReal.coe_le_coe (by norm_num) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedFormCross.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedFormCross.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e0e1306d1df9612623ac86fd3d4260c657fa0b4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedFormCross.lean @@ -0,0 +1,101 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedPotentialOperator + +namespace OAI + +/-! Polarization of the actual bounded-potential quadratic form on the +full weak-H1 graph. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem h1Coordinates_add {n : ℕ} (u v : Coulomb.H1Vector n) : + h1Coordinates (u.add v) = h1Coordinates u+h1Coordinates v := by + funext a + apply Lp.ext + filter_upwards [(h1Coordinate_memLp (u.add v) a).coeFn_toLp, + (h1Coordinate_memLp u a).coeFn_toLp, (h1Coordinate_memLp v a).coeFn_toLp, + Lp.coeFn_add (h1Coordinates u a) (h1Coordinates v a)] with x huv hu hv ha + change h1Coordinates (u.add v) a x = _ at huv + change h1Coordinates u a x = _ at hu + change h1Coordinates v a x = _ at hv + change h1Coordinates (u.add v) a x = (h1Coordinates u a+h1Coordinates v a) x + rw [ha] + simp only [Pi.add_apply] + rw [hu,hv,huv] + cases a <;> rfl + +def graphBoundedCross {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) (f g : H1Coordinates n) : ℝ := + (1/2:ℝ)*(∑ s, ∑ a, inner ℝ (f (Sum.inr (s,a))) (g (Sum.inr (s,a))))+ + ∑ s, inner ℝ (f (Sum.inl s)) (A (g (Sum.inl s))) + +theorem graphBoundedForm_add {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) + (hA : ∀ x y, inner ℝ x (A y) = inner ℝ y (A x)) (f g : H1Coordinates n) : + graphBoundedForm A (f+g) = graphBoundedForm A f+graphBoundedForm A g+2*graphBoundedCross A f g := by + have hx (s : SpinConfiguration n) : + inner ℝ (g (Sum.inl s)) (A (f (Sum.inl s))) = + inner ℝ (f (Sum.inl s)) (A (g (Sum.inl s))) := hA _ _ + simp only [graphBoundedForm,graphKinetic,graphBoundedCross,Pi.add_apply, + norm_add_sq_real,map_add,inner_add_left,inner_add_right,hx, + Finset.sum_add_distrib,← Finset.mul_sum] + ring + +theorem boundedPotential_operator_symmetric {n : ℕ} (V : Configuration n → ℝ) + (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) + (f g : Lp ℂ 2 (volume : Measure (Configuration n))) : + inner ℝ f (BoundedPotential.operator V hV B hB g) = + inner ℝ g (BoundedPotential.operator V hV B hB f) := by + rw [L2.inner_def,L2.inner_def] + apply integral_congr_ae + filter_upwards [BoundedPotential.operator_ae V hV B hB f, + BoundedPotential.operator_ae V hV B hB g] with x hf hg + rw [hf,hg,← Complex.real_smul,← Complex.real_smul, + real_inner_smul_right,real_inner_smul_right,real_inner_comm] + +theorem boundedPotentialForm_add {n : ℕ} (V : Configuration n → ℝ) + (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) (u v : Coulomb.H1Vector n) : + boundedPotentialForm V (u.add v) = boundedPotentialForm V u+boundedPotentialForm V v+ + 2*graphBoundedCross (BoundedPotential.operator V hV B hB) (h1Coordinates u) (h1Coordinates v) := by + simp only [boundedPotentialForm_eq_graph V hV B hB,h1Coordinates_add] + exact graphBoundedForm_add _ (boundedPotential_operator_symmetric V hV B hB) _ _ + + +theorem Lp_real_inner_eq_re {n : ℕ} + (f g : Lp ℂ 2 (volume : Measure (Configuration n))) : + inner ℝ f g = (inner ℂ f g).re := by + rw [L2.inner_def,L2.inner_def] + have hr := integral_re (L2.integrable_inner (𝕜 := ℂ) f g) + change (∫ x, (inner ℂ (f x) (g x)).re) = (∫ x, inner ℂ (f x) (g x)).re at hr + rw [← hr] + apply integral_congr_ae + filter_upwards [] with x + exact real_inner_eq_re_inner ℂ (f x) (g x) + +def graphComplexCross {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) (f g : H1Coordinates n) : ℂ := + (1/2:ℂ)*(∑ s, ∑ a, inner ℂ (f (Sum.inr (s,a))) (g (Sum.inr (s,a))))+ + ∑ s, inner ℂ (f (Sum.inl s)) (A (g (Sum.inl s))) + +private theorem re_finite_sum {ι : Type*} [Fintype ι] (z : ι → ℂ) : + (∑ i, z i).re = ∑ i, (z i).re := + map_sum Complex.reLm z Finset.univ + +theorem graphBoundedCross_eq_re {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) (f g : H1Coordinates n) : + graphBoundedCross A f g = (graphComplexCross A f g).re := by + simp only [graphBoundedCross,graphComplexCross,Lp_real_inner_eq_re,Complex.add_re, + Complex.mul_re,re_finite_sum] + norm_num + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedPotentialOperator.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedPotentialOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9c87821e7b9f9bf966b2e8deade36f8de85cc03 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/BoundedPotentialOperator.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1BoundedForm + +namespace OAI + +/-! Actual bounded real multiplication potentials on the weak-H1 graph. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb +namespace BoundedPotential + +variable {n : ℕ} (V : Configuration n → ℝ) (hV : Continuous V) + (B : ℝ) (hB : ∀ x, |V x| ≤ B) + +include hV hB in +theorem product_memLp (u : Lp ℂ 2 (volume : Measure (Configuration n))) : + MemLp (fun x => (V x : ℂ) * u x) 2 := by + apply (Lp.memLp u).of_le_mul (c := B) + ((Complex.continuous_ofReal.comp hV).aestronglyMeasurable.mul (Lp.aestronglyMeasurable u)) + filter_upwards [] with x + change ‖(V x : ℂ) * u x‖ ≤ B * ‖u x‖ + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hB x) (norm_nonneg _) + +def value (u : Lp ℂ 2 (volume : Measure (Configuration n))) : + Lp ℂ 2 (volume : Measure (Configuration n)) := + (product_memLp V hV B hB u).toLp (fun x => (V x : ℂ)*u x) + +theorem value_ae (u : Lp ℂ 2 (volume : Measure (Configuration n))) : + value V hV B hB u =ᵐ[volume] fun x => (V x : ℂ)*u x := + (product_memLp V hV B hB u).coeFn_toLp + +private def linear : Lp ℂ 2 (volume : Measure (Configuration n)) →ₗ[ℂ] + Lp ℂ 2 (volume : Measure (Configuration n)) where + toFun := value V hV B hB + map_add' u v := by + apply Lp.ext + filter_upwards [value_ae V hV B hB (u+v), value_ae V hV B hB u, + value_ae V hV B hB v, Lp.coeFn_add u v, + Lp.coeFn_add (value V hV B hB u) (value V hV B hB v)] with x he hu hv hs ht + simp only [he, hs, ht, hu, hv, Pi.add_apply] + ring + map_smul' c u := by + change value V hV B hB (c • u) = c • value V hV B hB u + apply Lp.ext + filter_upwards [value_ae V hV B hB (c • u), value_ae V hV B hB u, + Lp.coeFn_smul c u, Lp.coeFn_smul c (value V hV B hB u)] with x he hu hs ht + simp only [he, hs, ht, hu, Pi.smul_apply, smul_eq_mul] + ring + +def operator : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n)) := + ((linear V hV B hB).mkContinuous B (fun u => + Lp.norm_le_mul_norm_of_ae_le_mul (by + filter_upwards [value_ae V hV B hB u] with x hx + change ‖value V hV B hB u x‖ ≤ B * ‖u x‖ + rw [hx, norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hB x) (norm_nonneg _)))).restrictScalars ℝ + +theorem operator_ae (u : Lp ℂ 2 (volume : Measure (Configuration n))) : + operator V hV B hB u =ᵐ[volume] fun x => (V x : ℂ)*u x := value_ae V hV B hB u + +theorem operator_pairing (u : Lp ℂ 2 (volume : Measure (Configuration n))) : + inner ℝ u (operator V hV B hB u) = ∫ x, V x * ‖u x‖^2 := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [operator_ae V hV B hB u] with x hx + rw [hx, ← Complex.real_smul, real_inner_smul_right, real_inner_self_eq_norm_sq] + +end BoundedPotential +def boundedPotentialForm {n : ℕ} (V : Configuration n → ℝ) (u : Coulomb.H1Vector n) : ℝ := + Coulomb.kinetic u + ∑ s, ∫ x, V x * ‖u.value s x‖^2 + +theorem boundedPotentialForm_eq_graph {n : ℕ} (V : Configuration n → ℝ) + (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) (u : Coulomb.H1Vector n) : + boundedPotentialForm V u = + graphBoundedForm (BoundedPotential.operator V hV B hB) (h1Coordinates u) := by + unfold boundedPotentialForm graphBoundedForm + rw [kinetic_eq_graphKinetic] + congr 1 + apply Finset.sum_congr rfl + intro s _ + rw [BoundedPotential.operator_pairing] + apply integral_congr_ae + filter_upwards [(h1Coordinate_memLp u (Sum.inl s)).coeFn_toLp] with x hx + change h1Coordinates u (Sum.inl s) x = u.value s x at hx + rw [hx] + +theorem boundedPotential_lower_of_compact (hpublished : PublishedSobolevSmoothDensity) + {n : ℕ} (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) + (hB : ∀ x, |V x| ≤ B) (E : ℝ) + (hcompact : ∀ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) → + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) → + E*Coulomb.mass v ≤ boundedPotentialForm V v) + (u : Coulomb.H1Vector n) : E*Coulomb.mass u ≤ boundedPotentialForm V u := by + rw [boundedPotentialForm_eq_graph V hV B hB] + apply boundedForm_lower_of_compact hpublished _ E + intro v hv hd + rw [← boundedPotentialForm_eq_graph V hV B hB] + exact hcompact v hv hd + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisection.lean new file mode 100644 index 0000000000000000000000000000000000000000..80e28ba611aef373312a19264cfd2d5492729d81 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisection.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationComponents +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram + +namespace OAI + +/-! Deterministic bisection with the concrete hopping/Coulomb evaluator. +The premises are endpoint signs and the already proved separated-site gap; +there is no numeric evaluator assumption. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation +open ExactQuantumFactoring.BitStackProgram + +abbrev BisectionInput := ℕ × (Environment × (ℚ × ℚ)) + +def bisectionInputCode : BisectionInput → List Bool := + prodCode unaryCode (prodCode environmentCode (prodCode ratCode ratCode)) + +def tolerance (e : Environment) : ℚ := 1 / ((e.1.2 : ℚ) + 1) + +def bisectionArgument (x : BisectionInput) : BisectionProgram.Input Environment := + (x.1, (x.2.1, (tolerance x.2.1, x.2.2))) + +def bisect (rho : ℕ) (x : BisectionInput) : ℚ := + BisectionProgram.approximate (value rho) (bisectionArgument x) + +noncomputable opaque bisectionArgumentProgram : Procedure bisectionInputCode + (BisectionProgram.inputCode environmentCode) bisectionArgument := by + let n := Procedure.first unaryCode (prodCode environmentCode (prodCode ratCode ratCode)) + let tail := Procedure.second unaryCode (prodCode environmentCode (prodCode ratCode ratCode)) + let env := (Procedure.first environmentCode (prodCode ratCode ratCode)).comp tail + let ends := (Procedure.second environmentCode (prodCode ratCode ratCode)).comp tail + let np := (Procedure.first (prodCode unaryCode unaryCode) + (prodCode unaryCode (prodCode ratCode ratCode))).comp env + let p := (Procedure.second unaryCode unaryCode).comp np + let p1 := Procedure.natToRat.comp (Procedure.unaryToBits.comp + (Procedure.unarySuccessor.comp p)) + let delta := Procedure.ratInv.comp p1 + exact (n.pair (env.pair (delta.pair ends))).congrFun (by + intro x + simp only [Function.comp_apply, id_eq, Nat.succ_eq_add_one, bisectionArgument, + tolerance, one_div, Nat.cast_add, Nat.cast_one] + ) + +def residual (rho : ℕ) (e : Environment) (d : ℝ) : ℝ := + (e.2.1 : ℝ) * planarHopping d - + coulombHoppingTarget (GaussianFrequency.frequency rho) e.2.2.1 e.2.2.2 d + +def residualLipschitz (rho : ℕ) (e : Environment) : ℝ := + (e.2.1 : ℝ) * planarHoppingLipschitzConstant + + coulombTargetLipschitzConstant (GaussianFrequency.frequency rho) e.2.2.1 e.2.2.2 + +theorem bisect_residual (rho : ℕ) (hrho : 0 < rho) (e : Environment) (a b : ℚ) + (hK : 0 ≤ e.2.2.2) (hKN : (e.2.2.2 : ℝ) ≤ e.1.1) + (hτ : 0 ≤ e.2.2.1) (hτ1 : e.2.2.1 ≤ 1) (hab : a ≤ b) + (haN : -(e.1.1 : ℝ) ≤ a) (hbN : (b : ℝ) ≤ e.1.1) + (ha : 0 ≤ residual rho e a) (hb : residual rho e b ≤ 0) + (hgap : ∀ r ∈ Set.Icc (a : ℝ) b, + localizedGramConstant (GaussianFrequency.frequency rho) ≤ + localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) r) (n : ℕ) : + |residual rho e (bisect rho (n, (e, (a, b))))| ≤ + 2 * ((e.1.2 : ℝ) + 1)⁻¹ + + residualLipschitz rho e * (((b : ℝ) - a) / 2 ^ n) := by + have hf : 0 < GaussianFrequency.frequency rho := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have hKr : (0 : ℝ) ≤ e.2.2.2 := by exact_mod_cast hK + have hτr : (0 : ℝ) ≤ e.2.2.1 := by exact_mod_cast hτ + have hLip0 : 0 ≤ residualLipschitz rho e := add_nonneg + (mul_nonneg (Nat.cast_nonneg _) (by positivity)) + (coulombTargetLipschitzConstant_nonnegative _ _ hτr) + have heval (q : ℚ) (hq : q ∈ Set.Icc a b) : + |(value rho e q : ℝ) - residual rho e q| ≤ (tolerance e : ℝ) := by + have hqa : (a : ℝ) ≤ q := by exact_mod_cast hq.1 + have hqb : (q : ℝ) ≤ b := by exact_mod_cast hq.2 + have hqN : |(q : ℝ)| ≤ e.1.1 := abs_le.mpr ⟨haN.trans hqa, hqb.trans hbN⟩ + have hg := (localizedGramConstant_positive hf).le.trans (hgap q ⟨hqa, hqb⟩) + have he := approximation_error rho hrho e q hK hKN hτ hτ1 hqN hg + simpa only [residual, coulombHoppingTarget, tolerance, Rat.cast_div, + Rat.cast_one, Rat.cast_add, Rat.cast_natCast, one_div, Rat.cast_inv] using he + have hLip (r : ℝ) (hr : r ∈ Set.Icc (a : ℝ) b) + (s : ℝ) (hs : s ∈ Set.Icc (a : ℝ) b) : + |residual rho e r - residual rho e s| ≤ residualLipschitz rho e * |r - s| := + calibratedResidual_abs_sub hf hτr hKr (Nat.cast_nonneg _) r s (hgap r hr) (hgap s hs) + have ht : 0 ≤ tolerance e := by unfold tolerance; positivity + have h := BisectionProgram.residual (value rho) e ht hab ha hb hLip0 heval hLip n + simpa only [bisect, bisectionArgument, tolerance, Rat.cast_div, Rat.cast_one, + Rat.cast_add, Rat.cast_natCast, one_div, Rat.cast_inv] using h + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionLocation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionLocation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1e6fb87919d5f65a21e782ab3764167a3a87096 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionLocation.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionSchedule + +namespace OAI + +/-! Every returned rational remains in its original search interval. This +geometric invariant does not need an accuracy or residual-sign hypothesis. -/ + +namespace ContinuumCoulomb + +private theorem bisection_step_nested (δ : ℚ) (evaluate : ℚ → ℚ) + {a b : ℚ} (s : ApproximateBisection.Interval) + (hs : a ≤ s.lo ∧ s.lo ≤ s.hi ∧ s.hi ≤ b) : + a ≤ (ApproximateBisection.step δ evaluate s).lo ∧ + (ApproximateBisection.step δ evaluate s).lo ≤ (ApproximateBisection.step δ evaluate s).hi ∧ + (ApproximateBisection.step δ evaluate s).hi ≤ b := by + have hm := ApproximateBisection.midpoint_mem s hs.2.1 + unfold ApproximateBisection.step + split_ifs + · exact hs + · exact ⟨hs.1.trans hm.1, hm.2, hs.2.2⟩ + · exact ⟨hs.1, hm.1, hm.2.trans hs.2.2⟩ + · exact ⟨hs.1.trans hm.1, le_rfl, hm.2.trans hs.2.2⟩ + +theorem bisection_run_nested (δ : ℚ) (evaluate : ℚ → ℚ) (a b : ℚ) + (hab : a ≤ b) (n : ℕ) : + a ≤ (ApproximateBisection.run δ evaluate a b n).lo ∧ + (ApproximateBisection.run δ evaluate a b n).lo ≤ + (ApproximateBisection.run δ evaluate a b n).hi ∧ + (ApproximateBisection.run δ evaluate a b n).hi ≤ b := by + induction n with + | zero => exact ⟨le_rfl, hab, le_rfl⟩ + | succ n ih => + simpa only [ApproximateBisection.run, Function.iterate_succ_apply'] using + bisection_step_nested δ evaluate (ApproximateBisection.run δ evaluate a b n) ih + +theorem bisection_value_mem {E : Type} (evaluate : E → ℚ → ℚ) (e : E) + (δ a b : ℚ) (hab : a ≤ b) (n : ℕ) : + BisectionProgram.approximate evaluate (n, (e, (δ, (a, b)))) ∈ Set.Icc a b := by + obtain ⟨hp, hi⟩ := BisectionRegisters.iterate_interval δ (evaluate e) + (BisectionRegisters.initial a b) (BisectionRegisters.initial_den_pos a b) n + unfold BisectionProgram.approximate + rw [BisectionRegisters.middle_eq _ hp, hi, BisectionRegisters.initial_interval] + have hs := bisection_run_nested δ (evaluate e) a b hab n + have hm := ApproximateBisection.midpoint_mem (ApproximateBisection.run δ (evaluate e) a b n) hs.2.1 + exact ⟨hs.1.trans hm.1, hm.2.trans hs.2.2⟩ + +namespace CalibratedEvaluation + +theorem bisect_mem (rho : ℕ) (e : Environment) (a b : ℚ) (hab : a ≤ b) (n : ℕ) : + bisect rho (n, (e, (a, b))) ∈ Set.Icc a b := + bisection_value_mem (value rho) e (tolerance e) a b hab n + +theorem scheduledValue_mem (rho : ℕ) (e : Environment) (a b : ℚ) (hab : a ≤ b) : + scheduledValue rho e a b ∈ Set.Icc a b := + bisect_mem rho (refinedEnvironment e) a b hab (iterations rho e) + +end CalibratedEvaluation +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionMachine.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..a14ca5731b7d2c4405c88be39445bb0c173b70f6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionMachine.lean @@ -0,0 +1,25 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisection +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedEvaluationProgram + +namespace OAI + +/-! Literal bisection with the certified calibrated-residual machine. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque bisectionProgram (rho : ℕ) : Procedure bisectionInputCode ratCode (bisect rho) := + ((BisectionProgram.program (program rho)).comp bisectionArgumentProgram).congrFun + (by intro x; rfl) + +noncomputable def bisectionCertificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime bisectionInputCode ratCode (bisect rho) := + (bisectionProgram rho).toTM2 + + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e5cf0fd8b1c7e93c991da09d3a31544e7607014 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedBisectionSchedule.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedLipschitzBound + +namespace OAI + +/-! Polynomial unary iteration and evaluation-precision choices for the +actual calibrated bisection. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation + +def refinedEnvironment (e : Environment) : Environment := + ((e.1.1, 8 * (e.1.2 + 1)), e.2) + +def iterations (rho : ℕ) (e : Environment) : ℕ := + 16 * lipschitzGuard rho * (e.2.1 + e.1.1 + 1) * (e.1.1 + 1) * (e.1.2 + 1) + +def scheduledValue (rho : ℕ) (e : Environment) (a b : ℚ) : ℚ := + bisect rho (iterations rho e, (refinedEnvironment e, (a, b))) + +theorem bisection_scalar_budget {C A N S : ℝ} {n : ℕ} + (hC : 0 < C) (hA : 0 < A) (hN : 0 ≤ N) (hS : 0 < S) + (hn : (n : ℝ) = 16 * C * A * (N + 1) * S) : + 2 * (8 * S + 1)⁻¹ + C * A * (2 * N) / 2 ^ n ≤ S⁻¹ := by + have hn0 : (0 : ℝ) < n := by rw [hn]; positivity + have hfirst : 2 * (8 * S + 1)⁻¹ ≤ (4 * S)⁻¹ := by + apply (mul_inv_le_iff₀ (by positivity)).mpr + apply (le_inv_mul_iff₀ (by positivity : (0 : ℝ) < 4 * S)).mpr + linarith + have hsecond : C * A * (2 * N) / 2 ^ n ≤ (8 * S)⁻¹ := by + calc + _ = C * A * (2 * N) * (2 : ℝ)⁻¹ ^ n := by rw [div_eq_mul_inv, inv_pow] + _ ≤ C * A * (2 * N) * ((n : ℝ) + 1)⁻¹ := + mul_le_mul_of_nonneg_left (CoulombQuadratureSchedule.dyadic_le_inverse n) (by positivity) + _ ≤ C * A * (2 * (N + 1)) * (n : ℝ)⁻¹ := by + apply mul_le_mul + · gcongr + linarith + · exact inv_anti₀ hn0 (by linarith) + · positivity + · positivity + _ = (8 * S)⁻¹ := by + rw [hn] + field_simp [hC.ne', hA.ne', hS.ne', ne_of_gt (show 0 < N + 1 by linarith)] + ring + have hs := add_le_add hfirst hsecond + apply hs.trans + simp only [mul_inv_rev] + norm_num + nlinarith [inv_pos.mpr hS] + +theorem scheduled_residual (rho : ℕ) (hrho : 0 < rho) (e : Environment) (a b : ℚ) + (hK : (0 : ℚ) ≤ e.2.2.2) (hKN : (e.2.2.2 : ℝ) ≤ e.1.1) + (hτ : (0 : ℚ) ≤ e.2.2.1) (hτ1 : e.2.2.1 ≤ 1) (hab : a ≤ b) + (haN : -(e.1.1 : ℝ) ≤ a) (hbN : (b : ℝ) ≤ e.1.1) + (ha : 0 ≤ residual rho e a) (hb : residual rho e b ≤ 0) + (hgap : ∀ r ∈ Set.Icc (a : ℝ) b, + localizedGramConstant (GaussianFrequency.frequency rho) ≤ + localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) r) : + |residual rho e (scheduledValue rho e a b)| ≤ ((e.1.2 : ℝ) + 1)⁻¹ := by + have hK' : (0 : ℝ) ≤ e.2.2.2 := by exact_mod_cast hK + have hτ1' : (e.2.2.1 : ℝ) ≤ 1 := by exact_mod_cast hτ1 + have he := bisect_residual rho hrho (refinedEnvironment e) a b + hK hKN hτ hτ1 hab haN hbN ha hb hgap (iterations rho e) + have hL := residualLipschitz_bound rho e hK' hKN hτ1' + have hwidth : (0 : ℝ) ≤ b - a := by exact_mod_cast sub_nonneg.mpr hab + have hwidth' : (b : ℝ) - a ≤ 2 * (e.1.1 : ℝ) := by linarith + have hcount : (iterations rho e : ℝ) = + 16 * (lipschitzGuard rho : ℝ) * ((e.2.1 : ℝ) + e.1.1 + 1) * + ((e.1.1 : ℝ) + 1) * ((e.1.2 : ℝ) + 1) := by + simp only [iterations, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + have hC : (0 : ℝ) < lipschitzGuard rho := by exact_mod_cast lipschitzGuard_positive rho + have hA : (0 : ℝ) < (e.2.1 : ℝ) + e.1.1 + 1 := by positivity + have hbnd := bisection_scalar_budget hC hA (Nat.cast_nonneg e.1.1) + (show (0 : ℝ) < e.1.2 + 1 by positivity) hcount + have hterm : residualLipschitz rho e * (((b : ℝ) - a) / 2 ^ iterations rho e) ≤ + (lipschitzGuard rho : ℝ) * ((e.2.1 : ℝ) + e.1.1 + 1) * (2 * (e.1.1 : ℝ)) / + 2 ^ iterations rho e := by + calc + _ ≤ ((lipschitzGuard rho : ℝ) * ((e.2.1 : ℝ) + e.1.1 + 1)) * + (((b : ℝ) - a) / 2 ^ iterations rho e) := + mul_le_mul_of_nonneg_right hL (div_nonneg hwidth (by positivity)) + _ ≤ _ := by rw [mul_div_assoc]; gcongr + have he' : |residual rho e (scheduledValue rho e a b)| ≤ + 2 * (8 * ((e.1.2 : ℝ) + 1) + 1)⁻¹ + + residualLipschitz rho e * (((b : ℝ) - a) / 2 ^ iterations rho e) := by + simpa only [refinedEnvironment, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, + Nat.cast_one, scheduledValue, residual, residualLipschitz] using he + exact (he'.trans (add_le_add (le_refl _) hterm)).trans hbnd + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedContactCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedContactCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..6562ad4369b5869b108009c60b3fd02403142c15 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedContactCorrectness.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedContactProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactPositionArray +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibratedGeometry + +namespace OAI + +/-! The composed numerical program outputs the actual rational geometric +realization of the final mediator graph, in its original vertex order. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedContactProgram +open ContactMediator + +def graphInput (d : SquareLatticeHeisenberg) (N P H : ℕ) + (K : GlobalEdge d → ℚ) : Input := + (H, ((N, P), (List.ofFn d.coordinate, (d.bonds.toList, List.ofFn K)))) + +def graphLengths (rho : ℕ) (ε c : ℚ) (k A B N P : ℕ) + (d : SquareLatticeHeisenberg) (K : GlobalEdge d → ℚ) : GlobalEdge d → ℚ := + fun a => AutomaticCalibration.normalizedValue rho ε c k A B (N, (P, K a)) + +theorem raw_graphInput (rho : ℕ) (ε c : ℚ) (k A B N P H : ℕ) + (d : SquareLatticeHeisenberg) (K : GlobalEdge d → ℚ) : + rawInput rho ε c k A B (graphInput d N P H K) = + ContactSourceInputProgram.literalInput d H (graphLengths rho ε c k A B N P d K) := by + simp only [rawInput, graphInput, AutomaticCalibrationList.value, List.map_ofFn, + ContactSourceInputProgram.literalInput, Function.comp_def] + rfl + +theorem value_graphInput (rho : ℕ) (ε c : ℚ) (k A B N P H : ℕ) + (d : SquareLatticeHeisenberg) (K : GlobalEdge d → ℚ) : + value rho ε c k A B (graphInput d N P H K) = + List.ofFn (fun x => ContactCalibratedGeometry.position d H + (AutomaticCalibration.spacing c k N) (graphLengths rho ε c k A B N P d K) x) := by + unfold value + rw [raw_graphInput] + exact ContactSourceInputProgram.scaled_literal_array d H + (AutomaticCalibration.spacing c k N) (graphLengths rho ε c k A B N P d K) + +theorem graphLengths_scale (rho : ℕ) (ε : ℚ) {c : ℚ} (hc : 0 < c) + (k A B N P : ℕ) (hN : 0 < N) (d : SquareLatticeHeisenberg) + (K : GlobalEdge d → ℚ) (a : GlobalEdge d) : + (AutomaticCalibration.spacing c k N : ℝ) * graphLengths rho ε c k A B N P d K a = + (AutomaticCalibration.value rho ε c k A B (N, (P, K a)) : ℝ) := by + have hq := AutomaticCalibration.spacing_positive hc k N hN + have heq : AutomaticCalibration.spacing c k N * + graphLengths rho ε c k A B N P d K a = + AutomaticCalibration.value rho ε c k A B (N, (P, K a)) := by + unfold graphLengths AutomaticCalibration.normalizedValue + field_simp [hq.ne'] + exact_mod_cast heq + +theorem graphLengths_near_one (rho : ℕ) {ε c : ℚ} (hε : 0 ≤ ε) (hc : 0 < c) + (hεtol : (ε : ℝ) / 2 ≤ contactLengthTolerance) (k A B N P : ℕ) + (hN : 0 < N) (d : SquareLatticeHeisenberg) (K : GlobalEdge d → ℚ) (a : GlobalEdge d) : + (graphLengths rho ε c k A B N P d K a : ℝ) ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + obtain ⟨hl, hu⟩ := AutomaticCalibration.normalizedValue_mem rho hε hc k A B + (N, (P, K a)) hN + have hl' : (1 : ℝ) - (ε : ℝ) / 2 ≤ graphLengths rho ε c k A B N P d K a := by + exact_mod_cast hl + have hu' : (graphLengths rho ε c k A B N P d K a : ℝ) ≤ 1 + (ε : ℝ) / 2 := by + exact_mod_cast hu + constructor <;> linarith + +theorem graph_separation (rho : ℕ) {ε c : ℚ} (hε : 0 ≤ ε) (hc : 0 < c) + (hεtol : (ε : ℝ) / 2 ≤ contactLengthTolerance) (k A B N P H W G : ℕ) + (hN : 0 < N) (hH : 7200 ≤ H) (d : SquareLatticeHeisenberg) (K : GlobalEdge d → ℚ) + (x y : GlobalSite d) (hxy : x ≠ y) : + (9 / 10 : ℝ) * AutomaticCalibration.spacing c k N ≤ + dist (ContactCalibratedGeometry.point d H (AutomaticCalibration.spacing c k N) + (graphLengths rho ε c k A B N P d K) x) + (ContactCalibratedGeometry.point d H (AutomaticCalibration.spacing c k N) + (graphLengths rho ε c k A B N P d K) y) := + ContactCalibratedGeometry.separation d W G H (AutomaticCalibration.spacing_positive hc k N hN) + _ hH (graphLengths_near_one rho hε hc hεtol k A B N P hN d K) x y hxy + +end ContinuumCoulomb.CalibratedContactProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3354e23b6d25ff85dc0b0000c198a3b552b481e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationBudget.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationParameters + +namespace OAI + +/-! A fixed polynomial accuracy schedule for the calibrated hopping +residual. The square-root input uses quadratic precision in the requested +inverse error, rather than assuming a spectral gap for numerical samples. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation + +theorem hopping_budget (scale P : ℕ) : + (scale : ℝ) * ((hoppingPrecision scale P : ℝ) + 1)⁻¹ ≤ + (4 * ((P : ℝ) + 1))⁻¹ := by + have hP : 0 < (P : ℝ) + 1 := by positivity + have hprec : (hoppingPrecision scale P : ℝ) = + 4 * ((scale : ℝ) + 1) * ((P : ℝ) + 1) := by + simp only [hoppingPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + rw [hprec] + apply (mul_inv_le_iff₀ (by positivity)).mpr + apply (le_inv_mul_iff₀ (by positivity : (0 : ℝ) < 4 * (P + 1))).mpr + nlinarith + +theorem root_budget (P : ℕ) : + (2 : ℝ)⁻¹ ^ rootPrecision P ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + apply (CoulombQuadratureSchedule.dyadic_le_inverse _).trans + apply inv_anti₀ (by positivity) + simp only [rootPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _] + +theorem coulomb_root_budget (N P : ℕ) {K : ℝ} (hKN : K ≤ N) : + Real.sqrt (2 * K * ((coulombPrecision N P : ℝ) + 1)⁻¹) ≤ + (4 * ((P : ℝ) + 1))⁻¹ := by + let S := (P : ℝ) + 1 + have hS : 0 < S := by dsimp only [S]; positivity + have hN : (0 : ℝ) ≤ N := Nat.cast_nonneg _ + have hprec : (coulombPrecision N P : ℝ) = 64 * ((N : ℝ) + 1) * S ^ 2 := by + simp only [coulombPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one, + Nat.cast_pow, S] + have hsmall : 2 * K * ((coulombPrecision N P : ℝ) + 1)⁻¹ ≤ ((4 * S)⁻¹) ^ 2 := by + rw [hprec] + apply (mul_inv_le_iff₀ (by positivity)).mpr + have he : ((4 * S)⁻¹) ^ 2 * (64 * ((N : ℝ) + 1) * S ^ 2 + 1) = + 4 * ((N : ℝ) + 1) + ((4 * S)⁻¹) ^ 2 := by + field_simp [hS.ne'] + ring + rw [he] + nlinarith [sq_nonneg ((4 * S)⁻¹)] + exact (Real.sqrt_le_sqrt hsmall).trans_eq (by + rw [Real.sqrt_sq_eq_abs, abs_of_pos (inv_pos.mpr (mul_pos (by norm_num) hS))]) + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationComponents.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationComponents.lean new file mode 100644 index 0000000000000000000000000000000000000000..98a04ea04cb1d7522ff73fc26f6186a0acaa088e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationComponents.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationError + +namespace OAI + +/-! An actual polynomial TM2 evaluator for the Coulomb-calibrated residual. +This is the numeric callback used by deterministic bisection. -/ + +namespace ContinuumCoulomb.CalibratedEvaluation +open ExactQuantumFactoring.BitStackProgram + +attribute [local irreducible] CoulombEvaluation.approximate + +def environmentCode : Environment → List Bool := + prodCode (prodCode unaryCode unaryCode) (prodCode unaryCode (prodCode ratCode ratCode)) + +def inputCode : (Environment × ℚ) → List Bool := prodCode environmentCode ratCode + +noncomputable opaque coulombPrecisionProgram : + Procedure (prodCode unaryCode unaryCode) unaryCode (fun x => coulombPrecision x.1 x.2) := by + let n := Procedure.unarySuccessor.comp (Procedure.first unaryCode unaryCode) + let p := ResolventSchedule.squareProgram.comp + (Procedure.unarySuccessor.comp (Procedure.second unaryCode unaryCode)) + let prod := ResolventSchedule.mulProgram.comp (n.pair p) + exact ((CoulombEvaluation.scaleProgram 64).comp prod).congrFun (by + intro x + simp only [Function.comp_apply, Nat.succ_eq_add_one, coulombPrecision] + ring) + +noncomputable opaque hoppingPrecisionProgram : + Procedure (prodCode unaryCode unaryCode) unaryCode (fun x => hoppingPrecision x.1 x.2) := by + let s := Procedure.unarySuccessor.comp (Procedure.first unaryCode unaryCode) + let p := Procedure.unarySuccessor.comp (Procedure.second unaryCode unaryCode) + let prod := ResolventSchedule.mulProgram.comp (s.pair p) + exact ((CoulombEvaluation.scaleProgram 4).comp prod).congrFun (by + intro x + simp only [Function.comp_apply, Nat.succ_eq_add_one, hoppingPrecision] + ring) + +noncomputable opaque rootPrecisionProgram : Procedure unaryCode unaryCode rootPrecision := + ((CoulombEvaluation.scaleProgram 8).comp Procedure.unarySuccessor).congrFun (by intro x; rfl) + +noncomputable opaque environmentProgram : Procedure inputCode environmentCode Prod.fst := + Procedure.first environmentCode ratCode +noncomputable opaque distanceProgram : Procedure inputCode ratCode Prod.snd := + Procedure.second environmentCode ratCode +noncomputable opaque metadataProgram : Procedure inputCode (prodCode unaryCode unaryCode) + (fun x => x.1.1) := + (Procedure.first (prodCode unaryCode unaryCode) + (prodCode unaryCode (prodCode ratCode ratCode))).comp environmentProgram +noncomputable opaque boundProgram : Procedure inputCode unaryCode (fun x => x.1.1.1) := + (Procedure.first unaryCode unaryCode).comp metadataProgram +noncomputable opaque precisionProgram : Procedure inputCode unaryCode (fun x => x.1.1.2) := + (Procedure.second unaryCode unaryCode).comp metadataProgram +noncomputable opaque parametersProgram : Procedure inputCode + (prodCode unaryCode (prodCode ratCode ratCode)) (fun x => x.1.2) := + (Procedure.second (prodCode unaryCode unaryCode) + (prodCode unaryCode (prodCode ratCode ratCode))).comp environmentProgram +noncomputable opaque scaleProgram : Procedure inputCode unaryCode (fun x => x.1.2.1) := + (Procedure.first unaryCode (prodCode ratCode ratCode)).comp parametersProgram +noncomputable opaque scalarParametersProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.1.2.2) := + (Procedure.second unaryCode (prodCode ratCode ratCode)).comp parametersProgram +noncomputable opaque tauProgram : Procedure inputCode ratCode (fun x => x.1.2.2.1) := + (Procedure.first ratCode ratCode).comp scalarParametersProgram +noncomputable opaque weightProgram : Procedure inputCode ratCode (fun x => x.1.2.2.2) := + (Procedure.second ratCode ratCode).comp scalarParametersProgram +noncomputable opaque coulombAccuracyProgram : Procedure inputCode unaryCode + (fun x => coulombPrecision x.1.1.1 x.1.1.2) := + coulombPrecisionProgram.comp metadataProgram +noncomputable def onsiteArgument (x : Environment × ℚ) : CoulombEvaluation.Input := + (coulombPrecision x.1.1.1 x.1.1.2, 0) +noncomputable def separatedArgument (x : Environment × ℚ) : CoulombEvaluation.Input := + (coulombPrecision x.1.1.1 x.1.1.2, x.2) + +noncomputable opaque onsiteArgumentProgram : + Procedure inputCode CoulombEvaluation.inputCode onsiteArgument := + coulombAccuracyProgram.pair (Procedure.constant inputCode ratCode 0) +noncomputable opaque separatedArgumentProgram : + Procedure inputCode CoulombEvaluation.inputCode separatedArgument := + coulombAccuracyProgram.pair distanceProgram + +noncomputable opaque onsiteRawProgram (rho : ℕ) : Procedure inputCode ratCode + ((fun q : CoulombEvaluation.Input => CoulombEvaluation.approximate rho q.1 q.2) ∘ onsiteArgument) := + (CoulombEvaluation.program rho).comp onsiteArgumentProgram +noncomputable opaque separatedRawProgram (rho : ℕ) : Procedure inputCode ratCode + ((fun q : CoulombEvaluation.Input => CoulombEvaluation.approximate rho q.1 q.2) ∘ separatedArgument) := + (CoulombEvaluation.program rho).comp separatedArgumentProgram + +noncomputable opaque onsiteProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => CoulombEvaluation.approximate rho (coulombPrecision x.1.1.1 x.1.1.2) 0) := + (onsiteRawProgram rho).congrFun (by intro x; simp only [Function.comp_apply, onsiteArgument]) +noncomputable opaque separatedProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => CoulombEvaluation.approximate rho (coulombPrecision x.1.1.1 x.1.1.2) x.2) := + (separatedRawProgram rho).congrFun (by intro x; simp only [Function.comp_apply, separatedArgument]) + +noncomputable opaque gapProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => gap rho x.1.1.1 x.1.1.2 x.2) := + (CappedKernelProgram.maximumProgram.comp ((Procedure.constant inputCode ratCode 0).pair + (Procedure.ratSub.comp ((onsiteProgram rho).pair (separatedProgram rho))))).congrFun + (by intro x; rfl) +noncomputable opaque radicandProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => x.1.2.2.2 * gap rho x.1.1.1 x.1.1.2 x.2) := + Procedure.ratMul.comp (weightProgram.pair (gapProgram rho)) +noncomputable opaque rootProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2) := + (RationalSquareRoot.program.comp + ((rootPrecisionProgram.comp precisionProgram).pair (radicandProgram rho))).congrFun + (by intro x; rfl) +noncomputable opaque hoppingAccuracyProgram : Procedure inputCode unaryCode + (fun x => hoppingPrecision x.1.2.1 x.1.1.2) := + hoppingPrecisionProgram.comp (scaleProgram.pair precisionProgram) +noncomputable opaque hoppingProgram : Procedure inputCode ratCode + (fun x => ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2)) := + ComputableHopping.program.comp ((boundProgram.pair hoppingAccuracyProgram).pair distanceProgram) +noncomputable opaque scaledHoppingProgram : Procedure inputCode ratCode + (fun x => (x.1.2.1 : ℚ) * + ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2)) := + Procedure.ratMul.comp ((Procedure.natToRat.comp + (Procedure.unaryToBits.comp scaleProgram)).pair hoppingProgram) +noncomputable opaque targetProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => x.1.2.2.1 * root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2) := + Procedure.ratMul.comp (tauProgram.pair (rootProgram rho)) + +end ContinuumCoulomb.CalibratedEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationError.lean new file mode 100644 index 0000000000000000000000000000000000000000..47506325df644aff329d586e8a5318fed7a0cb1d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationError.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationBudget + +namespace OAI + +/-! Certified evaluation of the actual calibrated hopping residual, +uniformly on rational points in a bounded interval. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation + +theorem approximation_error (rho : ℕ) (hrho : 0 < rho) (e : Environment) (d : ℚ) + (hK : (0 : ℚ) ≤ e.2.2.2) (hKN : (e.2.2.2 : ℝ) ≤ e.1.1) + (hτ : (0 : ℚ) ≤ e.2.2.1) (hτ1 : e.2.2.1 ≤ 1) + (hd : |(d : ℝ)| ≤ (e.1.1 : ℝ)) + (hgap : 0 ≤ localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ)) : + |(value rho e d : ℝ) - + ((e.2.1 : ℝ) * planarHopping (d : ℝ) - (e.2.2.1 : ℝ) * + Real.sqrt ((e.2.2.2 : ℝ) * + (localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ))))| ≤ + ((e.1.2 : ℝ) + 1)⁻¹ := by + have hKr : (0 : ℝ) ≤ e.2.2.2 := by exact_mod_cast hK + have hτr : (0 : ℝ) ≤ e.2.2.1 := by exact_mod_cast hτ + have hτ1r : (e.2.2.1 : ℝ) ≤ 1 := by exact_mod_cast hτ1 + have hu := CoulombEvaluation.approximation_error rho (coulombPrecision e.1.1 e.1.2) hrho 0 + have hv := CoulombEvaluation.approximation_error rho (coulombPrecision e.1.1 e.1.2) hrho d + simp only [Rat.cast_zero] at hu + have ht := ComputableHopping.approximation_error + ((e.1.1, hoppingPrecision e.2.1 e.1.2), d) hd + have hq : (0 : ℚ) ≤ e.2.2.2 * gap rho e.1.1 e.1.2 d := + mul_nonneg hK (le_max_left _ _) + have hr := RationalSquareRoot.value_error (rootPrecision e.1.2) hq + have hr' : |(root rho e.1.1 e.1.2 e.2.2.2 d : ℝ) - + Real.sqrt ((e.2.2.2 : ℝ) * max 0 + ((CoulombEvaluation.approximate rho (coulombPrecision e.1.1 e.1.2) 0 : ℝ) - + CoulombEvaluation.approximate rho (coulombPrecision e.1.1 e.1.2) d))| ≤ + (2 : ℝ)⁻¹ ^ rootPrecision e.1.2 := by + simpa only [root, gap, Rat.cast_mul, Rat.cast_max, Rat.cast_zero, Rat.cast_sub] using hr + have he := calibrated_residual_error (Nat.cast_nonneg e.2.1) hτr hKr hgap ht hu hv hr' + have hhop := hopping_budget e.2.1 e.1.2 + have hroot := root_budget e.1.2 + have hcoulomb := coulomb_root_budget e.1.1 e.1.2 hKN + have hnonneg : 0 ≤ (2 : ℝ)⁻¹ ^ rootPrecision e.1.2 + + Real.sqrt (2 * (e.2.2.2 : ℝ) * ((coulombPrecision e.1.1 e.1.2 : ℝ) + 1)⁻¹) := by + positivity + have htarget := mul_le_mul_of_nonneg_right hτ1r hnonneg + have hfinal := he.trans (add_le_add hhop + (htarget.trans (by simpa only [one_mul] using add_le_add hroot hcoulomb))) + have hsum : (4 * ((e.1.2 : ℝ) + 1))⁻¹ + + ((4 * ((e.1.2 : ℝ) + 1))⁻¹ + (4 * ((e.1.2 : ℝ) + 1))⁻¹) = + 3 * (4 * ((e.1.2 : ℝ) + 1))⁻¹ := by ring + have hout : |(value rho e d : ℝ) - + ((e.2.1 : ℝ) * planarHopping (d : ℝ) - (e.2.2.1 : ℝ) * + Real.sqrt ((e.2.2.2 : ℝ) * + (localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ))))| ≤ + 3 * (4 * ((e.1.2 : ℝ) + 1))⁻¹ := by + simpa only [value, Rat.cast_sub, Rat.cast_mul, Rat.cast_natCast, hsum] using hfinal + apply hout.trans + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr (show (0 : ℝ) < e.1.2 + 1 by positivity)] + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationParameters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc99521c7235649a5bc7f30ea4b5804be8a8d4ed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedEvaluationParameters.lean @@ -0,0 +1,33 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombEvaluationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableHopping +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationSquareError + +namespace OAI + +/-! The literal scalar function supplied to calibrated-distance bisection. +The displacement/weight bound, amplification and requested accuracy are unary; +the positive target parameters and the queried distance are rational. -/ + +namespace ContinuumCoulomb.CalibratedEvaluation + +abbrev Environment := (ℕ × ℕ) × (ℕ × (ℚ × ℚ)) + +noncomputable def coulombPrecision (N P : ℕ) : ℕ := 64 * (N + 1) * (P + 1) ^ 2 +noncomputable def hoppingPrecision (scale P : ℕ) : ℕ := 4 * (scale + 1) * (P + 1) +noncomputable def rootPrecision (P : ℕ) : ℕ := 8 * (P + 1) + +noncomputable def gap (rho N P : ℕ) (d : ℚ) : ℚ := + max 0 (CoulombEvaluation.approximate rho (coulombPrecision N P) 0 - + CoulombEvaluation.approximate rho (coulombPrecision N P) d) + +noncomputable def root (rho N P : ℕ) (K d : ℚ) : ℚ := + RationalSquareRoot.value (rootPrecision P, K * gap rho N P d) + +noncomputable def value (rho : ℕ) (e : Environment) (d : ℚ) : ℚ := + (e.2.1 : ℚ) * ComputableHopping.approximate + ((e.1.1, hoppingPrecision e.2.1 e.1.2), d) - + e.2.2.1 * root rho e.1.1 e.1.2 e.2.2.2 d + +end ContinuumCoulomb.CalibratedEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedGraphError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedGraphError.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5d4a58cc66b84b38b7f63a56dec5cdbaeb082c1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedGraphError.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationGraphBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionLocation + +namespace OAI + +/-! The actual scheduled rational distances produce a finite Hubbard +superexchange graph whose ground energy is close to the requested spin graph. +Only the analytic endpoint signs and separated-site gap are hypotheses. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation +open scoped BigOperators + +def edgeEnvironment (N P scale : ℕ) (τ K : ℚ) : Environment := ((N, P), (scale, (τ, K))) + +def scheduledDistance (rho N P scale : ℕ) (τ K a b : ℚ) : ℚ := + scheduledValue rho (edgeEnvironment N P scale τ K) a b + +def scheduledCoefficient (rho N P scale : ℕ) (τ K a b : ℚ) : ℝ := + ((scale : ℝ) * planarHopping (scheduledDistance rho N P scale τ K a b)) ^ 2 / + (localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) + (scheduledDistance rho N P scale τ K a b)) + +theorem scheduled_graphSourceBottom_error {Edge : Type*} [Fintype Edge] + (rho : ℕ) (hrho : 0 < rho) (m : ℕ) (left right : Edge → Fin (m + 1)) + (N P scale : ℕ) (τ : ℚ) (K a b : Edge → ℚ) + (hK : ∀ e, 0 ≤ K e) (hKN : ∀ e, (K e : ℝ) ≤ N) + (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) (hab : ∀ e, a e ≤ b e) + (haN : ∀ e, -(N : ℝ) ≤ a e) (hbN : ∀ e, (b e : ℝ) ≤ N) + (ha : ∀ e, 0 ≤ residual rho (edgeEnvironment N P scale τ (K e)) (a e)) + (hb : ∀ e, residual rho (edgeEnvironment N P scale τ (K e)) (b e) ≤ 0) + (hgap : ∀ e r, r ∈ Set.Icc (a e : ℝ) (b e) → + localizedGramConstant (GaussianFrequency.frequency rho) ≤ + localizedCoulombProfile (GaussianFrequency.frequency rho) 0 - + localizedCoulombProfile (GaussianFrequency.frequency rho) r) : + |HubbardGlobal.graphSourceBottom m left right + (fun e => scheduledCoefficient rho N P scale τ (K e) (a e) (b e)) - + HubbardGlobal.graphSourceBottom m left right (fun e => (τ : ℝ) ^ 2 * K e)| ≤ + 4 * Fintype.card Edge * + (((P : ℝ) + 1)⁻¹ * + (2 * Real.sqrt ((N : ℝ) * localizedCoulombProfile (GaussianFrequency.frequency rho) 0) + + ((P : ℝ) + 1)⁻¹) / localizedGramConstant (GaussianFrequency.frequency rho)) := by + let freq := GaussianFrequency.frequency rho + let d : Edge → ℚ := fun e => scheduledDistance rho N P scale τ (K e) (a e) (b e) + let t : Edge → ℝ := fun e => (scale : ℝ) * planarHopping (d e) + let gap : Edge → ℝ := fun e => localizedCoulombProfile freq 0 - localizedCoulombProfile freq (d e) + have hfreq : 0 < freq := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have hmem (e : Edge) : (d e : ℝ) ∈ Set.Icc (a e : ℝ) (b e) := by + have hm := scheduledValue_mem rho (edgeEnvironment N P scale τ (K e)) (a e) (b e) (hab e) + exact ⟨by exact_mod_cast hm.1, by exact_mod_cast hm.2⟩ + have hgap' (e : Edge) : localizedGramConstant freq ≤ gap e := hgap e (d e) (hmem e) + have hU (e : Edge) : gap e ≤ localizedCoulombProfile freq 0 := by + have hp : 0 ≤ localizedCoulombProfile freq (d e) := by + unfold localizedCoulombProfile + rw [localizedCoulombProfileAt_eq] + exact localizedCoulombCoeff_nonnegative _ _ _ + dsimp only [gap] + linarith + have hres (e : Edge) : + |t e - (τ : ℝ) * Real.sqrt ((K e : ℝ) * gap e)| ≤ ((P : ℝ) + 1)⁻¹ := by + have hs := scheduled_residual rho hrho (edgeEnvironment N P scale τ (K e)) + (a e) (b e) (hK e) (hKN e) hτ hτ1 (hab e) (haN e) (hbN e) (ha e) (hb e) (hgap e) + simpa only [residual, coulombHoppingTarget, edgeEnvironment, d, t, gap, freq, + scheduledDistance] using hs + have hKr (e : Edge) : (0 : ℝ) ≤ K e := by exact_mod_cast hK e + have hτr : (0 : ℝ) ≤ τ := by exact_mod_cast hτ + have hτr1 : (τ : ℝ) ≤ 1 := by exact_mod_cast hτ1 + have h := HubbardGlobal.calibrated_graphSourceBottom_uniform_error m left right + t (fun e => (K e : ℝ)) gap hKr hKN (localizedGramConstant_positive hfreq) + hgap' hU hτr hτr1 hres + simpa only [scheduledCoefficient, scheduledDistance, t, gap, d, freq] using h + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedHoppingBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedHoppingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..637883cfa37b5323358481481dfdd2d10f8032ef --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedHoppingBound.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbard + +namespace OAI + +/-! Explicit total hopping bounds for actual Coulomb-calibrated contacts. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem calibrated_hopping_sum_bound {Edge : Type*} [Fintype Edge] + (freq scale τ B : ℝ) (hτ : 0 ≤ τ) (distance K : Edge → ℝ) + (hK : ∀ e, 0 ≤ K e) (hB : ∀ e, K e ≤ B) + (hcal : ∀ e, scale * planarHopping (distance e) = coulombHoppingTarget freq τ (K e) (distance e)) : + 4 * ∑ e, |scale * planarHopping (distance e)| ≤ + 4 * (Fintype.card Edge : ℝ) * (τ * Real.sqrt (B * localizedCoulombProfile freq 0)) := by + have hpoint (e : Edge) : |scale * planarHopping (distance e)| ≤ + τ * Real.sqrt (B * localizedCoulombProfile freq 0) := by + rw [hcal e, coulombHoppingTarget, abs_of_nonneg (mul_nonneg hτ (Real.sqrt_nonneg _))] + apply mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt ?_) hτ + calc + _ ≤ K e * localizedCoulombProfile freq 0 := mul_le_mul_of_nonneg_left + (sub_le_self _ (localizedCoulombProfile_nonnegative freq (distance e))) (hK e) + _ ≤ _ := mul_le_mul_of_nonneg_right (hB e) (localizedCoulombProfile_nonnegative freq 0) + have h := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum (s := Finset.univ) (fun e _ => hpoint e)) (by norm_num : (0 : ℝ) ≤ 4) + simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_assoc] using h + +def calibratedTau (freq ε B : ℝ) (r : ℕ) : ℝ := + ε * localizedGramConstant freq / + (4 * ((r : ℝ) + 1) * (Real.sqrt (B * localizedCoulombProfile freq 0) + 1)) + +theorem calibratedTau_nonnegative {freq ε B : ℝ} (hfreq : 0 < freq) (hε : 0 ≤ ε) (r : ℕ) : + 0 ≤ calibratedTau freq ε B r := by + unfold calibratedTau + exact div_nonneg (mul_nonneg hε (localizedGramConstant_positive hfreq).le) (by positivity) + +theorem calibratedTau_budget {freq ε B : ℝ} (hfreq : 0 < freq) (hε : 0 ≤ ε) (r : ℕ) : + 4 * (r : ℝ) * (calibratedTau freq ε B r * Real.sqrt (B * localizedCoulombProfile freq 0)) ≤ + ε * localizedGramConstant freq := by + let q := Real.sqrt (B * localizedCoulombProfile freq 0) + have hq : 0 ≤ q := Real.sqrt_nonneg _ + have hd : 0 < 4 * ((r : ℝ) + 1) * (q + 1) := by positivity + have hεc : 0 ≤ ε * localizedGramConstant freq := + mul_nonneg hε (localizedGramConstant_positive hfreq).le + have hratio : 4 * (r : ℝ) * q ≤ 4 * ((r : ℝ) + 1) * (q + 1) := by + nlinarith [Nat.cast_nonneg (α := ℝ) r] + unfold calibratedTau + change 4 * (r : ℝ) * (ε * localizedGramConstant freq / (4 * ((r : ℝ) + 1) * (q + 1)) * q) ≤ _ + rw [show 4 * (r : ℝ) * (ε * localizedGramConstant freq / (4 * ((r : ℝ) + 1) * (q + 1)) * q) = + (ε * localizedGramConstant freq) * (4 * (r : ℝ) * q) / (4 * ((r : ℝ) + 1) * (q + 1)) by ring] + exact (div_le_iff₀ hd).mpr (mul_le_mul_of_nonneg_left hratio hεc) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedLipschitzBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedLipschitzBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9341d37905e5cc1772981ec1050458d014cb6ac5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedLipschitzBound.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisection + +namespace OAI + +/-! A fixed unary guard bounds the actual residual modulus by a polynomial +in the displacement/weight bound and the amplification. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedEvaluation + +def targetModulusBase (rho : ℕ) : ℝ := + localizedCoulombLipschitzConstant (GaussianFrequency.frequency rho) / + (2 * Real.sqrt (localizedGramConstant (GaussianFrequency.frequency rho))) + +def lipschitzGuard (rho : ℕ) : ℕ := + ⌈(planarHoppingLipschitzConstant : ℝ) + targetModulusBase rho⌉₊ + 1 + +theorem targetModulusBase_nonnegative (rho : ℕ) : 0 ≤ targetModulusBase rho := + div_nonneg (localizedCoulombLipschitzConstant_nonnegative _) + (mul_nonneg (by norm_num) (Real.sqrt_nonneg _)) + +theorem lipschitzGuard_bound (rho : ℕ) : + (planarHoppingLipschitzConstant : ℝ) + targetModulusBase rho ≤ lipschitzGuard rho := by + have h := Nat.le_ceil ((planarHoppingLipschitzConstant : ℝ) + targetModulusBase rho) + simp only [lipschitzGuard, Nat.cast_add, Nat.cast_one] + linarith + +theorem lipschitzGuard_positive (rho : ℕ) : 0 < lipschitzGuard rho := by + unfold lipschitzGuard + omega + +theorem residualLipschitz_bound (rho : ℕ) (e : Environment) + (hK : (0 : ℝ) ≤ e.2.2.2) (hKN : (e.2.2.2 : ℝ) ≤ e.1.1) + (hτ1 : (e.2.2.1 : ℝ) ≤ 1) : + residualLipschitz rho e ≤ + (lipschitzGuard rho : ℝ) * ((e.2.1 : ℝ) + e.1.1 + 1) := by + have hH : 0 ≤ (planarHoppingLipschitzConstant : ℝ) := NNReal.coe_nonneg _ + have hA := targetModulusBase_nonnegative rho + have hN : (0 : ℝ) ≤ e.1.1 := Nat.cast_nonneg _ + have hS : (0 : ℝ) ≤ e.2.1 := Nat.cast_nonneg _ + have hroot : Real.sqrt (e.2.2.2 : ℝ) ≤ (e.1.1 : ℝ) + 1 := by + have hs := Real.sqrt_nonneg (e.2.2.2 : ℝ) + have he := Real.sq_sqrt hK + nlinarith [sq_nonneg (Real.sqrt (e.2.2.2 : ℝ) - 1)] + have hprod : (e.2.2.1 : ℝ) * Real.sqrt (e.2.2.2 : ℝ) ≤ (e.1.1 : ℝ) + 1 := + (mul_le_mul_of_nonneg_right hτ1 (Real.sqrt_nonneg _)).trans + (by simpa only [one_mul] using hroot) + have htarget : coulombTargetLipschitzConstant (GaussianFrequency.frequency rho) + e.2.2.1 e.2.2.2 = + ((e.2.2.1 : ℝ) * Real.sqrt (e.2.2.2 : ℝ)) * targetModulusBase rho := by + unfold coulombTargetLipschitzConstant targetModulusBase + ring + have htargetBound := mul_le_mul_of_nonneg_right hprod hA + have hguard := mul_le_mul_of_nonneg_right (lipschitzGuard_bound rho) + (show (0 : ℝ) ≤ (e.2.1 : ℝ) + e.1.1 + 1 by positivity) + unfold residualLipschitz + rw [htarget] + have hcross : 0 ≤ (planarHoppingLipschitzConstant : ℝ) * ((e.1.1 : ℝ) + 1) + + targetModulusBase rho * (e.2.1 : ℝ) := by positivity + nlinarith + +end ContinuumCoulomb.CalibratedEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedMatrixError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedMatrixError.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c30e1e138e013c990c8854aafa5167f817494e7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibratedMatrixError.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockGraphEntries +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibratedGeometry + +namespace OAI + +/-! The approximate edge calibrations control the entire hopping matrix. +Simplicity prevents an edge error from acquiring a graph-size factor. -/ + +noncomputable section +namespace ContinuumCoulomb.HubbardGlobal +variable {Edge : Type*} [Fintype Edge] + +theorem graphHoppingMatrix_stability (m : ℕ) (left right : Edge → Fin (m+1)) + (hloop : ∀ e, left e ≠ right e) + (hsimple : ∀ e f, e ≠ f → + ¬(left e=left f ∧ right e=right f) ∧ ¬(left e=right f ∧ right e=left f)) + (t s : Edge → ℂ) {ε : ℝ} (hε : 0 ≤ ε) + (hedge : ∀ e, ‖t e-s e‖ ≤ ε) (i j : Fin (m+1)) : + ‖graphHoppingMatrix m left right t i j-graphHoppingMatrix m left right s i j‖ ≤ ε := by + classical + by_cases hij : i=j + · subst j + rw [graphHoppingMatrix_diagonal m left right t hloop, + graphHoppingMatrix_diagonal m left right s hloop,sub_self,norm_zero] + exact hε + by_cases he : ∃ e, (i=left e ∧ j=right e) ∨ (i=right e ∧ j=left e) + · obtain ⟨e,he|he⟩ := he + · rcases he with ⟨rfl,rfl⟩ + simpa only [graphHoppingMatrix_edge m left right _ hloop hsimple] using hedge e + · rcases he with ⟨rfl,rfl⟩ + rw [graphHoppingMatrix_symmetric m left right t, + graphHoppingMatrix_symmetric m left right s] + simpa only [graphHoppingMatrix_edge m left right _ hloop hsimple] using hedge e + · have hn : ∀ e, ¬(i=left e ∧ j=right e) ∧ ¬(i=right e ∧ j=left e) := by + intro e + exact ⟨fun h => he ⟨e,Or.inl h⟩,fun h => he ⟨e,Or.inr h⟩⟩ + rw [graphHoppingMatrix_nonedge m left right t i j hn, + graphHoppingMatrix_nonedge m left right s i j hn,sub_self,norm_zero] + exact hε + +theorem planarHoppingMatrix_calibrated_error (m : ℕ) + (left right : Edge → Fin (m+1)) (u : Fin (m+1) → PlanarPosition) + (hloop : ∀ e, left e ≠ right e) + (hsimple : ∀ e f, e ≠ f → + ¬(left e=left f ∧ right e=right f) ∧ ¬(left e=right f ∧ right e=left f)) + {scale D L ε : ℝ} (hscale : 0 ≤ scale) (hD : 2 ≤ D) (hε : 0 ≤ ε) + (hL : ∀ i j, ‖u i-u j‖ ≤ L) + (hsep : ∀ i j, i ≠ j → + (∀ e, ¬(i=left e ∧ j=right e) ∧ ¬(i=right e ∧ j=left e)) → D ≤ ‖u i-u j‖) + (target : Edge → ℝ) + (hres : ∀ e, |scale*planarHopping ‖u (left e)-u (right e)‖-target e| ≤ ε) + (i j : Fin (m+1)) : + ‖((scale*planarHoppingMatrix u i j:ℝ):ℂ)- + graphHoppingMatrix m left right (fun e => (-(target e):ℝ)) i j‖ ≤ + scale*planarHoppingUpperConstant*(L+1)*Real.exp (-D)+ε := by + let actual : Edge → ℂ := fun e => (-(scale*planarHopping ‖u (left e)-u (right e)‖):ℝ) + have hc := graphHoppingMatrix_stability m left right hloop hsimple actual + (fun e => (-(target e):ℝ)) hε (fun e => ?_) i j + · exact (norm_sub_le_norm_sub_add_norm_sub _ (graphHoppingMatrix m left right actual i j) _).trans + (add_le_add (planarHoppingMatrix_graph_error m left right u hloop hsimple + hscale hD hL hsep i j) hc) + · simpa only [actual,← Complex.ofReal_sub,Complex.norm_real,Real.norm_eq_abs, + neg_sub_neg,abs_sub_comm] using hres e + +end ContinuumCoulomb.HubbardGlobal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoefficientError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoefficientError.lean new file mode 100644 index 0000000000000000000000000000000000000000..78570d61f3526c651963533a0f3fcd4ed7ab4b84 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoefficientError.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationSquareError + +namespace OAI + +/-! A numerical calibration residual controls the actual superexchange +coefficient directly. No inverse-function or derivative lower bound is used. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem calibrated_coefficient_error {a K gap τ ε : ℝ} + (hK : 0 ≤ K) (hgap : 0 < gap) (hτ : 0 ≤ τ) + (hres : |a - τ * Real.sqrt (K * gap)| ≤ ε) : + |a ^ 2 / gap - τ ^ 2 * K| ≤ + ε * (2 * τ * Real.sqrt (K * gap) + ε) / gap := by + let b := τ * Real.sqrt (K * gap) + have hb : 0 ≤ b := mul_nonneg hτ (Real.sqrt_nonneg _) + have he : 0 ≤ ε := (abs_nonneg _).trans hres + have hb2 : b ^ 2 = τ ^ 2 * K * gap := by + dsimp only [b] + rw [mul_pow, Real.sq_sqrt (mul_nonneg hK hgap.le)] + ring + have ha : |a| ≤ b + ε := by + calc + _ = |(a - b) + b| := by congr 1; ring + _ ≤ |a - b| + |b| := abs_add_le _ _ + _ ≤ ε + b := add_le_add hres (le_of_eq (abs_of_nonneg hb)) + _ = _ := by ring + have hsum : |a + b| ≤ 2 * b + ε := + (abs_add_le _ _).trans (by rw [abs_of_nonneg hb]; linarith) + have hsq : |a ^ 2 - b ^ 2| ≤ ε * (2 * b + ε) := by + rw [show a ^ 2 - b ^ 2 = (a - b) * (a + b) by ring, abs_mul] + exact mul_le_mul hres hsum (abs_nonneg _) he + have hid : a ^ 2 / gap - τ ^ 2 * K = (a ^ 2 - b ^ 2) / gap := by + rw [hb2] + field_simp [hgap.ne'] + rw [hid, abs_div, abs_of_pos hgap] + simpa only [b, mul_assoc] using div_le_div_of_nonneg_right hsq hgap.le + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoulombBrackets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoulombBrackets.lean new file mode 100644 index 0000000000000000000000000000000000000000..d274a2e62314583a3bd7a06a7444db73a9d036ae --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationCoulombBrackets.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationEndpointSigns +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetRange + +namespace OAI + +/-! Explicit rational search intervals for the actual Coulomb-calibrated +hopping target. The fixed exponent simultaneously enforces the separated +two-site denominator and both endpoint signs. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibrationRationalBracket + +theorem exists_coulomb_brackets {freq : ℝ} (hfreq : 0 < freq) + (ε : ℚ) (hε : 0 < ε) (hε1 : ε < 1) (A B : ℕ) (kmin : ℝ) : + ∃ (c : ℚ) (k : ℕ), 0 < c ∧ 0 < k ∧ kmin ≤ (k : ℝ) ∧ + ∀ N : ℕ, 2 ≤ N → + let D := (k : ℝ) * Real.log (N : ℝ) + let p := endpoints ε (RationalLogScale.value c k N) + (1 - (ε : ℝ)) * D ≤ p.1 ∧ p.2 ≤ (1 + (ε : ℝ)) * D ∧ + 5 ≤ (1 - (ε : ℝ)) * D ∧ + (∀ r : ℝ, (p.1 : ℝ) ≤ r → localizedGramConstant freq ≤ + localizedCoulombProfile freq 0 - localizedCoulombProfile freq r) ∧ + (∀ K : ℚ, ((N : ℝ) ^ A)⁻¹ ≤ K → (K : ℝ) ≤ (N : ℝ) ^ A → + 0 ≤ (N : ℝ) ^ k * planarHopping p.1 - + coulombHoppingTarget freq ((N : ℝ) ^ B)⁻¹ K p.1 ∧ + (N : ℝ) ^ k * planarHopping p.2 - + coulombHoppingTarget freq ((N : ℝ) ^ B)⁻¹ K p.2 ≤ 0) := by + have hεR : (0 : ℝ) < ε := by exact_mod_cast hε + have hεR1 : (ε : ℝ) < 1 := by exact_mod_cast hε1 + obtain ⟨L, _, hrange⟩ := exists_coulomb_target_polynomial_bounds hfreq A B + obtain ⟨k₀, _, hspacing⟩ := exists_localizedGram_spacing hfreq 1 + obtain ⟨c, k, hc, hk, hkmin, hbracket⟩ := exists_rational_hopping_brackets + ε hε hε1 (B + A + L) (max kmin ((k₀ : ℝ) / (1 - (ε : ℝ)))) + have hkmin' : kmin ≤ (k : ℝ) := (le_max_left _ _).trans hkmin + have hkspacing : (k₀ : ℝ) / (1 - (ε : ℝ)) ≤ k := (le_max_right _ _).trans hkmin + refine ⟨c, k, hc, hk, hkmin', fun N hN => ?_⟩ + have hNR : (2 : ℝ) ≤ N := by exact_mod_cast hN + have hNp : (0 : ℝ) < N := by linarith + have hlogN : 0 ≤ Real.log (N : ℝ) := Real.log_nonneg (by linarith) + let D : ℝ := (k : ℝ) * Real.log (N : ℝ) + let p := endpoints ε (RationalLogScale.value c k N) + obtain ⟨ha0, ha1, hb0, hb1, haHop, hbHop⟩ := hbracket N hN + have hlength : (k₀ : ℝ) * Real.log (N : ℝ) ≤ (1 - (ε : ℝ)) * D := by + have hm := mul_le_mul_of_nonneg_right + ((div_le_iff₀ (sub_pos.mpr hεR1)).mp hkspacing) hlogN + nlinarith only [hm] + obtain ⟨hfive, hleak⟩ := hspacing N hNR + have hleak₂ : 2 * localLeakageBound freq ((k₀ : ℝ) * Real.log (N : ℝ)) ≤ + localDualMass freq / 2 := by + have hm := mul_le_mul_of_nonneg_right hNR + (localLeakageBound_nonnegative freq ((k₀ : ℝ) * Real.log (N : ℝ))) + exact hm.trans (by simpa only [pow_one] using hleak) + have hsepA : (k₀ : ℝ) * Real.log (N : ℝ) ≤ (p.1 : ℝ) := hlength.trans ha0 + have hD0 : 0 ≤ D := mul_nonneg (Nat.cast_nonneg _) hlogN + have hab : (p.1 : ℝ) ≤ p.2 := by + have horder : (1 - (ε : ℝ) / 4) * D ≤ (1 + (ε : ℝ) / 4) * D := by + nlinarith [mul_nonneg hεR.le hD0] + exact ha1.trans (horder.trans hb0) + change (1 - (ε : ℝ)) * D ≤ (p.1 : ℝ) ∧ _ + refine ⟨ha0, hb1, hfive.trans hlength, ?_, ?_⟩ + · intro r hr + exact localizedCoulombProfile_gap hfreq hfive hleak₂ (hsepA.trans hr) + · intro K hKlo hKhi + have hK : (0 : ℝ) ≤ K := (inv_nonneg.mpr (pow_nonneg hNp.le A)).trans hKlo + have hτ : 0 ≤ ((N : ℝ) ^ B)⁻¹ := inv_nonneg.mpr (pow_nonneg hNp.le B) + obtain ⟨htlo, hthi⟩ := hrange N hNR K hKlo hKhi + have htargetA := coulombHoppingTarget_bounds hfreq hfive hleak₂ hsepA hτ hK + have htargetB := coulombHoppingTarget_bounds hfreq hfive hleak₂ (hsepA.trans hab) hτ hK + exact ⟨sub_nonneg.mpr ((htargetA.2.trans hthi).trans haHop), + sub_nonpos.mpr (hbHop.trans (htlo.trans htargetB.1))⟩ + +end ContinuumCoulomb.CalibrationRationalBracket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationEndpointSigns.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationEndpointSigns.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ca12f81ce2ced8205211bf339080daf91371a12 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationEndpointSigns.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationRationalBracket +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarScaleChoice + +namespace OAI + +/-! The rational endpoints retain the analytic polynomial hopping brackets. +This uses the proved exponential envelopes and does not require monotonicity +of the hopping function. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibrationRationalBracket + +theorem brackets_of_larger_tolerance {A k : ℕ} {ε η N : ℝ} + (hε : 0 ≤ ε) (hεη : ε ≤ η) (hη1 : η ≤ 1) (hN : 2 ≤ N) + (hd : 2 ≤ (1 - η) * ((k : ℝ) * Real.log N)) + (hγ : 0 ≤ (k : ℝ) * ε - ((A : ℝ) + 1)) + (hlo : (k : ℝ) + 3 ≤ planarHoppingLowerConstant * + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1))) + (hhi : planarHoppingUpperConstant * (2 * (k : ℝ) + 1) ≤ + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1))) : + N ^ A ≤ N ^ k * planarHopping ((1 - η) * ((k : ℝ) * Real.log N)) ∧ + N ^ k * planarHopping ((1 + η) * ((k : ℝ) * Real.log N)) ≤ (N ^ A)⁻¹ := by + have he : (k : ℝ) * ε - ((A : ℝ) + 1) ≤ (k : ℝ) * η - ((A : ℝ) + 1) := + sub_le_sub_right (mul_le_mul_of_nonneg_left hεη (Nat.cast_nonneg _)) _ + have hp := Real.rpow_le_rpow_of_exponent_le (by norm_num : (1 : ℝ) ≤ 2) he + have h := planar_polynomial_brackets (hε.trans hεη) hη1 hN hd (hγ.trans he) + (hlo.trans (mul_le_mul_of_nonneg_left hp planarHoppingLowerConstant_positive.le)) + (hhi.trans hp) + have heq : Real.exp ((k : ℝ) * Real.log N) = N ^ k := by + rw [Real.exp_nat_mul, Real.exp_log (by linarith)] + simpa only [heq] using h + +theorem exists_rational_hopping_brackets (ε : ℚ) (hε : 0 < ε) (hε1 : ε < 1) + (A : ℕ) (kmin : ℝ) : + ∃ (c : ℚ) (k : ℕ), 0 < c ∧ 0 < k ∧ kmin ≤ (k : ℝ) ∧ + ∀ N : ℕ, 2 ≤ N → + let D := (k : ℝ) * Real.log (N : ℝ) + let p := endpoints ε (RationalLogScale.value c k N) + (1 - (ε : ℝ)) * D ≤ p.1 ∧ p.1 ≤ (1 - (ε : ℝ) / 4) * D ∧ + (1 + (ε : ℝ) / 4) * D ≤ p.2 ∧ p.2 ≤ (1 + (ε : ℝ)) * D ∧ + (N : ℝ) ^ A ≤ (N : ℝ) ^ k * planarHopping p.1 ∧ + (N : ℝ) ^ k * planarHopping p.2 ≤ ((N : ℝ) ^ A)⁻¹ := by + have hεR : (0 : ℝ) < ε := by exact_mod_cast hε + have hεR1 : (ε : ℝ) < 1 := by exact_mod_cast hε1 + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨c, hcpos, hc⟩ := RationalLogScale.exists_logTwo_approximation + (show (0 : ℝ) < (ε : ℝ) / 16 by positivity) + (show (ε : ℝ) / 16 ≤ 1 by linarith) + have hc' : |(c : ℝ) - Real.log 2| ≤ (ε : ℝ) / 64 * Real.log 2 := by + convert hc using 1; ring + let B : ℝ := max kmin (max (128 / (ε : ℝ)) (2 / ((1 - (ε : ℝ)) * Real.log 2))) + obtain ⟨k, hkpos, hkB, hγ, _hd, hlo, hhi⟩ := exists_planar_scale_conditions_above + B A (show (0 : ℝ) < (ε : ℝ) / 4 by positivity) + (show (ε : ℝ) / 4 < 1 by linarith) + have hkmin : kmin ≤ (k : ℝ) := (le_max_left _ _).trans hkB + have hkcount : 128 ≤ (ε : ℝ) * (k : ℝ) := by + have hb : 128 / (ε : ℝ) ≤ (k : ℝ) := + (le_max_left _ _).trans ((le_max_right _ _).trans hkB) + nlinarith [(div_le_iff₀ hεR).mp hb] + have hkfloor : 2 ≤ (1 - (ε : ℝ)) * ((k : ℝ) * Real.log 2) := by + have hb : 2 / ((1 - (ε : ℝ)) * Real.log 2) ≤ (k : ℝ) := + (le_max_right _ _).trans ((le_max_right _ _).trans hkB) + have hm := (div_le_iff₀ (mul_pos (sub_pos.mpr hεR1) hlog)).mp hb + nlinarith + refine ⟨c, k, hcpos, hkpos, hkmin, fun N hN => ?_⟩ + have hNR : (2 : ℝ) ≤ N := by exact_mod_cast hN + have hlogN : Real.log 2 ≤ Real.log (N : ℝ) := Real.log_le_log (by norm_num) hNR + let D : ℝ := (k : ℝ) * Real.log (N : ℝ) + let p := endpoints ε (RationalLogScale.value c k N) + have hD : 0 < D := mul_pos (by exact_mod_cast hkpos) (hlog.trans_le hlogN) + have hfloor : 2 ≤ (1 - (ε : ℝ)) * D := by + have hm := mul_le_mul_of_nonneg_left hlogN (Nat.cast_nonneg k : (0 : ℝ) ≤ k) + exact hkfloor.trans (mul_le_mul_of_nonneg_left hm (sub_pos.mpr hεR1).le) + obtain ⟨ha0, ha1, hb0, hb1⟩ := rational_endpoint_bounds ε c hε hε1.le hc' k N hN hkcount + have har0 : 1 - (ε : ℝ) ≤ (p.1 : ℝ) / D := (le_div_iff₀ hD).mpr ha0 + have har1 : (p.1 : ℝ) / D ≤ 1 - (ε : ℝ) / 4 := (div_le_iff₀ hD).mpr ha1 + have hbr0 : 1 + (ε : ℝ) / 4 ≤ (p.2 : ℝ) / D := (le_div_iff₀ hD).mpr hb0 + have hbr1 : (p.2 : ℝ) / D ≤ 1 + (ε : ℝ) := (div_le_iff₀ hD).mpr hb1 + let ηa : ℝ := 1 - (p.1 : ℝ) / D + let ηb : ℝ := (p.2 : ℝ) / D - 1 + have hηa : (ε : ℝ) / 4 ≤ ηa ∧ ηa ≤ (ε : ℝ) := by dsimp only [ηa]; constructor <;> linarith + have hηb : (ε : ℝ) / 4 ≤ ηb ∧ ηb ≤ (ε : ℝ) := by dsimp only [ηb]; constructor <;> linarith + have haeq : (1 - ηa) * D = (p.1 : ℝ) := by + dsimp only [ηa] + field_simp [hD.ne']; ring + have hbeq : (1 + ηb) * D = (p.2 : ℝ) := by + dsimp only [ηb] + field_simp [hD.ne']; ring + have hshort := brackets_of_larger_tolerance (show (0 : ℝ) ≤ (ε : ℝ) / 4 by positivity) + hηa.1 (hηa.2.trans hεR1.le) hNR + (hfloor.trans (mul_le_mul_of_nonneg_right (by linarith : 1 - (ε : ℝ) ≤ 1 - ηa) hD.le)) + hγ hlo hhi + have hlong := brackets_of_larger_tolerance (show (0 : ℝ) ≤ (ε : ℝ) / 4 by positivity) + hηb.1 (hηb.2.trans hεR1.le) hNR + (hfloor.trans (mul_le_mul_of_nonneg_right (by linarith : 1 - (ε : ℝ) ≤ 1 - ηb) hD.le)) + hγ hlo hhi + change (1 - (ε : ℝ)) * D ≤ (p.1 : ℝ) ∧ _ + refine ⟨ha0, ha1, hb0, hb1, ?_, ?_⟩ + · have hs : (N : ℝ) ^ A ≤ (N : ℝ) ^ k * planarHopping ((1 - ηa) * D) := hshort.1 + rwa [haeq] at hs + · have hl : (N : ℝ) ^ k * planarHopping ((1 + ηb) * D) ≤ ((N : ℝ) ^ A)⁻¹ := hlong.2 + rwa [hbeq] at hl + +end ContinuumCoulomb.CalibrationRationalBracket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationGraphBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationGraphBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..faa5eb1b70343804a08777a54985adfaf9946337 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationGraphBudget.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GraphCoefficientStability + +namespace OAI + +/-! A uniform coefficient budget for the actual calibrated Hubbard graph. +The residual is measured against the analytic hopping target, while the +conclusion concerns the finite-spin variational bottom. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem calibrated_coefficient_uniform_error {a K gap τ ε g N U : ℝ} + (hK : 0 ≤ K) (hKN : K ≤ N) (hg : 0 < g) (hgap : g ≤ gap) (hU : gap ≤ U) + (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) + (hres : |a - τ * Real.sqrt (K * gap)| ≤ ε) : + |a ^ 2 / gap - τ ^ 2 * K| ≤ ε * (2 * Real.sqrt (N * U) + ε) / g := by + have hgapp : 0 < gap := hg.trans_le hgap + have hε : 0 ≤ ε := (abs_nonneg _).trans hres + have hN : 0 ≤ N := hK.trans hKN + have hroot : Real.sqrt (K * gap) ≤ Real.sqrt (N * U) := + Real.sqrt_le_sqrt (mul_le_mul hKN hU hgapp.le hN) + have htarget : τ * Real.sqrt (K * gap) ≤ Real.sqrt (N * U) := + (mul_le_mul_of_nonneg_right hτ1 (Real.sqrt_nonneg _)).trans (by simpa using hroot) + have hnum : ε * (2 * τ * Real.sqrt (K * gap) + ε) ≤ + ε * (2 * Real.sqrt (N * U) + ε) := by + apply mul_le_mul_of_nonneg_left _ hε + linarith + exact (calibrated_coefficient_error hK hgapp hτ hres).trans + ((div_le_div_of_nonneg_right hnum hgapp.le).trans + (div_le_div_of_nonneg_left (by positivity) hg hgap)) + +namespace HubbardGlobal +variable {Edge : Type*} [Fintype Edge] + +theorem calibrated_graphSourceBottom_uniform_error + (m : ℕ) (left right : Edge → Fin (m + 1)) + (t K gap : Edge → ℝ) {τ ε g N U : ℝ} + (hK : ∀ e, 0 ≤ K e) (hKN : ∀ e, K e ≤ N) + (hg : 0 < g) (hgap : ∀ e, g ≤ gap e) (hU : ∀ e, gap e ≤ U) + (hτ : 0 ≤ τ) (hτ1 : τ ≤ 1) + (hres : ∀ e, |t e - τ * Real.sqrt (K e * gap e)| ≤ ε) : + |graphSourceBottom m left right (fun e => t e ^ 2 / gap e) - + graphSourceBottom m left right (fun e => τ ^ 2 * K e)| ≤ + 4 * Fintype.card Edge * (ε * (2 * Real.sqrt (N * U) + ε) / g) := by + apply (graphSourceBottom_stability m left right _ _).trans + calc + 4 * ∑ e, |t e ^ 2 / gap e - τ ^ 2 * K e| ≤ + 4 * ∑ _e : Edge, ε * (2 * Real.sqrt (N * U) + ε) / g := by + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact Finset.sum_le_sum (fun e _ => calibrated_coefficient_uniform_error + (hK e) (hKN e) hg (hgap e) (hU e) hτ hτ1 (hres e)) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring + +end HubbardGlobal +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationMesh.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..066c39a63cc18f6b8986d74ec1c4cd1c3ca82bbc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationMesh.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PhysicalNuclearProgram + +namespace OAI + +/-! Exact compatibility between polynomial hopping amplification and the +equal masses of the unit-nucleus Gauss mesh. -/ + +namespace ContinuumCoulomb.CalibrationMesh + +def base (n : ℕ) : ℕ := n^30 +def radius (n k : ℕ) : ℕ := n^k +def mesh (n k : ℕ) : ℕ := n^(10*k) +def width (n k : ℕ) : ℕ := n^(5*k) +def horizontal (n k : ℕ) : ℕ := width n k ^ 10 +def prefactor (rho : ℕ) : ℚ := 8/(rho:ℚ) +def amplification (rho n k : ℕ) : ℚ := prefactor rho * (base n:ℚ)^k + +theorem prefactor_positive {rho : ℕ} (hrho : 0 < rho) : 0 < prefactor rho := by + unfold prefactor + positivity + +theorem base_ge_two {n : ℕ} (hn : 2 ≤ n) : 2 ≤ base n := by + exact (by norm_num : 2 ≤ 2^30).trans (Nat.pow_le_pow_left hn 30) + +theorem mesh_positive {n : ℕ} (hn : 0 < n) (k : ℕ) : 0 < mesh n k := pow_pos hn _ + +theorem base_power_eq_mesh_cube (n k : ℕ) : base n ^ k = mesh n k ^ 3 := by + simp only [base,mesh,← pow_mul] + congr 1 + omega + +theorem amplification_eq_mesh (rho n k : ℕ) : + amplification rho n k = 8*(mesh n k:ℚ)^3/(rho:ℚ) := by + have he : (base n:ℚ)^k = (mesh n k:ℚ)^3 := by + exact_mod_cast base_power_eq_mesh_cube n k + rw [amplification,he,prefactor] + ring + +theorem physical_factor_eq (rho n k : ℕ) : + PhysicalNuclearProgram.factor rho (mesh n k) = (amplification rho n k)⁻¹ := by + rw [amplification_eq_mesh,PhysicalNuclearProgram.factor] + exact (inv_div _ _).symm + +theorem amplification_positive {rho n : ℕ} (hrho : 0 < rho) (hn : 0 < n) (k : ℕ) : + 0 < amplification rho n k := by + rw [amplification_eq_mesh] + have hm := mesh_positive hn k + positivity + +theorem mesh_eq_radius (n k : ℕ) : mesh n k = radius n k ^ 10 := by + simp only [mesh,radius,← pow_mul] + congr 1 + omega + +theorem width_eq_radius (n k : ℕ) : width n k = radius n k ^ 5 := by + simp only [width,radius,← pow_mul] + congr 1 + omega + +end ContinuumCoulomb.CalibrationMesh + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationRationalBracket.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationRationalBracket.lean new file mode 100644 index 0000000000000000000000000000000000000000..c167ea50bc8a18926aa4b39bbe41c500b7ecd5bd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationRationalBracket.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalLogScale + +namespace OAI + +/-! Rational endpoints lie inside the permitted contact interval and outside +the smaller interval used for the analytic sign estimates. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibrationRationalBracket + +def endpoints (ε q : ℚ) : ℚ × ℚ := ((1 - ε / 2) * q, (1 + ε / 2) * q) + +theorem endpoint_bounds {ε D q : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) (hD : 0 ≤ D) + (hqlo : (1 - ε / 16) * D ≤ q) (hqhi : q ≤ (1 + ε / 16) * D) : + (1 - ε) * D ≤ (1 - ε / 2) * q ∧ + (1 - ε / 2) * q ≤ (1 - ε / 4) * D ∧ + (1 + ε / 4) * D ≤ (1 + ε / 2) * q ∧ + (1 + ε / 2) * q ≤ (1 + ε) * D := by + have hc0 : 0 ≤ 1 - ε / 2 := by linarith + have hc1 : 0 ≤ 1 + ε / 2 := by linarith + have hsq : ε ^ 2 ≤ ε := by nlinarith + have ha0 : 1 - ε ≤ (1 - ε / 2) * (1 - ε / 16) := by nlinarith [sq_nonneg ε] + have ha1 : (1 - ε / 2) * (1 + ε / 16) ≤ 1 - ε / 4 := by nlinarith [sq_nonneg ε] + have hb0 : 1 + ε / 4 ≤ (1 + ε / 2) * (1 - ε / 16) := by nlinarith + have hb1 : (1 + ε / 2) * (1 + ε / 16) ≤ 1 + ε := by nlinarith + refine ⟨?_, ?_, ?_, ?_⟩ + · exact (mul_le_mul_of_nonneg_right ha0 hD).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hqlo hc0) + · exact (mul_le_mul_of_nonneg_left hqhi hc0).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_right ha1 hD) + · exact (mul_le_mul_of_nonneg_right hb0 hD).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hqlo hc1) + · exact (mul_le_mul_of_nonneg_left hqhi hc1).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hb1 hD) + +theorem rational_endpoint_bounds (ε c : ℚ) (hε : 0 < ε) (hε1 : ε ≤ 1) + (hc : |(c : ℝ) - Real.log 2| ≤ (ε : ℝ) / 64 * Real.log 2) + (k N : ℕ) (hN : 2 ≤ N) (hk : 128 ≤ (ε : ℝ) * (k : ℝ)) : + let D := (k : ℝ) * Real.log (N : ℝ) + let p := endpoints ε (RationalLogScale.value c k N) + (1 - (ε : ℝ)) * D ≤ p.1 ∧ p.1 ≤ (1 - (ε : ℝ) / 4) * D ∧ + (1 + (ε : ℝ) / 4) * D ≤ p.2 ∧ p.2 ≤ (1 + (ε : ℝ)) * D := by + have hεR : (0 : ℝ) < ε := by exact_mod_cast hε + have hεR1 : (ε : ℝ) ≤ 1 := by exact_mod_cast hε1 + have hc' : |(c : ℝ) - Real.log 2| ≤ ((ε : ℝ) / 16) / 4 * Real.log 2 := by + convert hc using 1; ring + have hk' : 8 ≤ ((ε : ℝ) / 16) * (k : ℝ) := by nlinarith + obtain ⟨hlo, hhi⟩ := RationalLogScale.relative_bounds c + (show 0 < (ε : ℝ) / 16 by positivity) (show (ε : ℝ) / 16 ≤ 1 by linarith) + hc' k N hN hk' + have hD : 0 ≤ (k : ℝ) * Real.log (N : ℝ) := + mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by exact_mod_cast (show 1 ≤ N by omega))) + simpa only [endpoints, Rat.cast_mul, Rat.cast_sub, Rat.cast_add, Rat.cast_div, + Rat.cast_one, Rat.cast_ofNat] using endpoint_bounds hεR hεR1 hD hlo hhi + +end ContinuumCoulomb.CalibrationRationalBracket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationSquareError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationSquareError.lean new file mode 100644 index 0000000000000000000000000000000000000000..35c8d1b2f703e3b029e2fc2eafa384be69d1b315 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CalibrationSquareError.lean @@ -0,0 +1,54 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot + +namespace OAI + +/-! Scalar error propagation for the square root appearing in the +calibrated hopping target. Negative numerical gaps are clipped at zero. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem clipped_difference_error {u v u' v' ε : ℝ} (hgap : 0 ≤ u - v) + (hu : |u' - u| ≤ ε) (hv : |v' - v| ≤ ε) : + |max 0 (u' - v') - (u - v)| ≤ 2 * ε := by + have hm := abs_max_sub_max_le_abs (u' - v') (u - v) (0 : ℝ) + rw [max_eq_left hgap] at hm + rw [max_comm 0 (u' - v')] + apply hm.trans + have he : (u' - v') - (u - v) = (u' - u) - (v' - v) := by ring + rw [he] + exact (abs_sub _ _).trans ((add_le_add hu hv).trans_eq (by ring)) + +theorem clipped_sqrt_difference_error {u v u' v' K ε : ℝ} + (hK : 0 ≤ K) (hgap : 0 ≤ u - v) + (hu : |u' - u| ≤ ε) (hv : |v' - v| ≤ ε) : + |Real.sqrt (K * max 0 (u' - v')) - Real.sqrt (K * (u - v))| ≤ + Real.sqrt (2 * K * ε) := by + have hs := RationalSquareRoot.sqrt_perturbation + (mul_nonneg hK (le_max_left 0 (u' - v'))) (mul_nonneg hK hgap) + have he : |K * max 0 (u' - v') - K * (u - v)| ≤ 2 * K * ε := by + rw [← mul_sub, abs_mul, abs_of_nonneg hK] + exact (mul_le_mul_of_nonneg_left (clipped_difference_error hgap hu hv) hK).trans_eq (by ring) + exact hs.trans (Real.sqrt_le_sqrt he) + +theorem calibrated_residual_error {scale τ K T T' u v u' v' r' εT εC εR : ℝ} + (hscale : 0 ≤ scale) (hτ : 0 ≤ τ) (hK : 0 ≤ K) (hgap : 0 ≤ u - v) + (hT : |T' - T| ≤ εT) (hu : |u' - u| ≤ εC) (hv : |v' - v| ≤ εC) + (hr : |r' - Real.sqrt (K * max 0 (u' - v'))| ≤ εR) : + |(scale * T' - τ * r') - (scale * T - τ * Real.sqrt (K * (u - v)))| ≤ + scale * εT + τ * (εR + Real.sqrt (2 * K * εC)) := by + have hs := clipped_sqrt_difference_error hK hgap hu hv + have ht := (abs_sub_le r' (Real.sqrt (K * max 0 (u' - v'))) + (Real.sqrt (K * (u - v)))).trans (add_le_add hr hs) + have he : (scale * T' - τ * r') - (scale * T - τ * Real.sqrt (K * (u - v))) = + scale * (T' - T) - τ * (r' - Real.sqrt (K * (u - v))) := by ring + rw [he] + apply (abs_sub _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg hscale, abs_of_nonneg hτ] + exact add_le_add (mul_le_mul_of_nonneg_left hT hscale) (mul_le_mul_of_nonneg_left ht hτ) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombKernel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dff2602b785db84aa58dc61ad38c9112d837253 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombKernel.lean @@ -0,0 +1,160 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulomb + +namespace OAI + +/-! A bounded Lipschitz kernel for literal Coulomb quadrature. The original +singular potential differs only inside the cap radius; the next theorem +controls that error by the actual Coulomb mass of the small ball. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def cappedCoulombKernel (ε : ℝ) (x : Position) : ℝ := (max ε ‖x‖)⁻¹ + +theorem cappedCoulombKernel_nonnegative {ε : ℝ} (hε : 0 < ε) (x : Position) : + 0 ≤ cappedCoulombKernel ε x := by + unfold cappedCoulombKernel + exact inv_nonneg.mpr (hε.le.trans (le_max_left _ _)) + +theorem cappedCoulombKernel_le {ε : ℝ} (hε : 0 < ε) (x : Position) : + cappedCoulombKernel ε x ≤ ε⁻¹ := + inv_anti₀ hε (le_max_left _ _) + +theorem cappedCoulombKernel_continuous {ε : ℝ} (hε : 0 < ε) : + Continuous (cappedCoulombKernel ε) := by + apply (continuous_const.max continuous_norm).inv₀ + intro x + exact (hε.trans_le (le_max_left _ _)).ne' + +theorem cappedCoulombKernel_norm_sub {ε : ℝ} (hε : 0 < ε) (x y : Position) : + |cappedCoulombKernel ε x - cappedCoulombKernel ε y| ≤ ε⁻¹ ^ 2 * ‖x - y‖ := by + let a := max ε ‖x‖ + let b := max ε ‖y‖ + have ha : 0 < a := hε.trans_le (le_max_left _ _) + have hb : 0 < b := hε.trans_le (le_max_left _ _) + have hia : a⁻¹ ≤ ε⁻¹ := inv_anti₀ hε (le_max_left _ _) + have hib : b⁻¹ ≤ ε⁻¹ := inv_anti₀ hε (le_max_left _ _) + have hdiff : |a - b| ≤ ‖x - y‖ := by + have hm := abs_max_sub_max_le_abs ‖x‖ ‖y‖ ε + rw [max_comm ‖x‖ ε, max_comm ‖y‖ ε] at hm + exact hm.trans (abs_norm_sub_norm_le x y) + have he : cappedCoulombKernel ε x - cappedCoulombKernel ε y = + (b - a) * a⁻¹ * b⁻¹ := by + change a⁻¹ - b⁻¹ = _ + field_simp [ha.ne', hb.ne'] + rw [he, abs_mul, abs_mul, abs_of_pos (inv_pos.mpr ha), + abs_of_pos (inv_pos.mpr hb), abs_sub_comm b a] + calc + _ ≤ ‖x - y‖ * ε⁻¹ * ε⁻¹ := by gcongr + _ = _ := by ring + +theorem cappedCoulombKernel_difference {ε : ℝ} (hε : 0 < ε) + (x : Position) (hx : x ≠ 0) : + |NeutralAtom.coulombKernel x - cappedCoulombKernel ε x| ≤ + (Metric.ball (0 : Position) ε).indicator NeutralAtom.coulombKernel x := by + have hn : 0 < ‖x‖ := norm_pos_iff.mpr hx + by_cases he : ‖x‖ < ε + · rw [Set.indicator_of_mem (by simpa only [Metric.mem_ball, dist_zero_right] using he)] + have hc : cappedCoulombKernel ε x = ε⁻¹ := by + unfold cappedCoulombKernel + rw [max_eq_left he.le] + rw [NeutralAtom.coulombKernel, hc, abs_of_nonneg (sub_nonneg.mpr (inv_anti₀ hn he.le))] + have hi := inv_nonneg.mpr hε.le + linarith + · rw [Set.indicator_of_notMem (by simpa only [Metric.mem_ball, dist_zero_right] using he)] + simp only [NeutralAtom.coulombKernel, cappedCoulombKernel, max_eq_right (le_of_not_gt he), + sub_self, abs_zero, le_refl] + +def cappedCoulombPotential (ε : ℝ) (ρ : Position → ℝ) (x : Position) : ℝ := + ∫ y, cappedCoulombKernel ε (x - y) * ρ y + +theorem cappedCoulombPotential_integrable {ε : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (x : Position) : + Integrable (fun y => cappedCoulombKernel ε (x - y) * ρ y) := by + apply hρ.bdd_mul (c := ε⁻¹) + ((cappedCoulombKernel_continuous hε).comp (continuous_const.sub continuous_id)).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun y => by + change ‖cappedCoulombKernel ε (x - y)‖ ≤ ε⁻¹ + rw [Real.norm_of_nonneg (cappedCoulombKernel_nonnegative hε _)] + exact cappedCoulombKernel_le hε _) + +theorem cappedCoulombPotential_nonnegative {ε : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hpos : ∀ x, 0 ≤ ρ x) (x : Position) : + 0 ≤ cappedCoulombPotential ε ρ x := + integral_nonneg (fun y => mul_nonneg (cappedCoulombKernel_nonnegative hε _) (hpos y)) + +theorem cappedCoulombPotential_le {ε : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (hpos : ∀ x, 0 ≤ ρ x) (x : Position) : + cappedCoulombPotential ε ρ x ≤ ε⁻¹ * ∫ y, ρ y := by + have h := integral_mono (cappedCoulombPotential_integrable hε hρ x) + (hρ.const_mul ε⁻¹) (fun y => + mul_le_mul_of_nonneg_right (cappedCoulombKernel_le hε _) (hpos y)) + simpa only [cappedCoulombPotential, integral_const_mul] using h + +theorem cappedCoulombPotential_norm_sub {ε : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (hpos : ∀ x, 0 ≤ ρ x) (x x' : Position) : + ‖cappedCoulombPotential ε ρ x - cappedCoulombPotential ε ρ x'‖ ≤ + (ε⁻¹ ^ 2 * ∫ y, ρ y) * ‖x - x'‖ := by + unfold cappedCoulombPotential + rw [← integral_sub (cappedCoulombPotential_integrable hε hρ x) + (cappedCoulombPotential_integrable hε hρ x')] + have h := norm_integral_le_of_norm_le + (f := fun y => cappedCoulombKernel ε (x - y) * ρ y - + cappedCoulombKernel ε (x' - y) * ρ y) + (hρ.const_mul (ε⁻¹ ^ 2 * ‖x - x'‖)) + (Filter.Eventually.of_forall (fun y => by + rw [← sub_mul, norm_mul, Real.norm_of_nonneg (hpos y), Real.norm_eq_abs] + apply mul_le_mul_of_nonneg_right _ (hpos y) + simpa only [sub_sub_sub_cancel_right] using + cappedCoulombKernel_norm_sub hε (x - y) (x' - y))) + rw [integral_const_mul] at h + convert h using 1 + ring + +theorem cappedCoulombPotential_continuous {ε : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (hpos : ∀ x, 0 ≤ ρ x) : + Continuous (cappedCoulombPotential ε ρ) := by + have hc : 0 ≤ ε⁻¹ ^ 2 * ∫ y, ρ y := + mul_nonneg (sq_nonneg _) (integral_nonneg hpos) + exact (show LipschitzWith ⟨ε⁻¹ ^ 2 * ∫ y, ρ y, hc⟩ (cappedCoulombPotential ε ρ) from + lipschitzWith_iff_norm_sub_le.mpr (cappedCoulombPotential_norm_sub hε hρ hpos)).continuous + +theorem cappedCoulombPotential_error {ε B : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (hpos : ∀ x, 0 ≤ ρ x) + (hbound : ∀ x, ρ x ≤ B) (x : Position) : + |NeutralAtom.potentialOf ρ x - cappedCoulombPotential ε ρ x| ≤ + B * NeutralAtom.kernelBallMass ε := by + have hi := (NeutralAtom.bounded_density_convolution NeutralAtom.measurable_coulombKernel + NeutralAtom.coulombKernel_nonneg (NeutralAtom.coulombKernel_integrableOn_ball 1) + (fun _ => NeutralAtom.coulombKernel_le_one) hρ hpos hbound x).1 + rw [NeutralAtom.potentialOf, cappedCoulombPotential, + ← integral_sub hi (cappedCoulombPotential_integrable hε hρ x)] + have hd := norm_integral_le_of_norm_le + (f := fun y => NeutralAtom.coulombKernel (x - y) * ρ y - + cappedCoulombKernel ε (x - y) * ρ y) + ((NeutralAtom.translated_kernel_indicator_integrable x ε).const_mul B) + (by + filter_upwards [volume.ae_ne x] with y hy + rw [← sub_mul, norm_mul, Real.norm_of_nonneg (hpos y), Real.norm_eq_abs] + have hc := cappedCoulombKernel_difference hε (x - y) (sub_ne_zero.mpr hy.symm) + have hs : (Metric.ball (0 : Position) ε).indicator NeutralAtom.coulombKernel (x - y) = + (Metric.ball x ε).indicator (fun z => NeutralAtom.coulombKernel (x - z)) y := by + rw [NeutralAtom.translated_kernel_indicator_eq] + rw [hs] at hc + have hp : 0 ≤ (Metric.ball x ε).indicator + (fun z => NeutralAtom.coulombKernel (x - z)) y := + Set.indicator_nonneg (fun z _ => NeutralAtom.coulombKernel_nonneg (x - z)) y + calc + _ ≤ (Metric.ball x ε).indicator + (fun z => NeutralAtom.coulombKernel (x - z)) y * B := + mul_le_mul hc (hbound y) (hpos y) hp + _ = _ := mul_comm _ _) + simpa only [Real.norm_eq_abs, integral_const_mul, + NeutralAtom.translated_kernel_indicator_integral] using hd + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombMass.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..37da5d9f971d52471dae83a5bec3b14eaed85d76 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombMass.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombKernel + +namespace OAI + +/-! The exact three-dimensional near-pole mass makes the cap error +quadratic in its rational radius. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem coulomb_kernelBallMass {ε : ℝ} (hε : 0 ≤ ε) : + NeutralAtom.kernelBallMass ε = 2 * Real.pi * ε ^ 2 := by + unfold NeutralAtom.kernelBallMass + rw [← integral_indicator measurableSet_ball] + have he : (Metric.ball (0 : Position) ε).indicator NeutralAtom.coulombKernel = + (fun x : Position => (Set.Iio ε).indicator (fun r : ℝ => r⁻¹) ‖x‖) := by + funext x + by_cases hx : ‖x‖ < ε + · simp [NeutralAtom.coulombKernel, Metric.mem_ball, dist_zero_right, hx] + · simp [Metric.mem_ball, dist_zero_right, hx] + rw [he, integral_fun_norm_addHaar volume] + have hi : (∫ r in Set.Ioi (0 : ℝ), r ^ (Module.finrank ℝ Position - 1) • + (Set.Iio ε).indicator (fun t : ℝ => t⁻¹) r) = ε ^ 2 / 2 := by + simp only [finrank_euclideanSpace_fin, smul_eq_mul] + norm_num + have hm : (fun r : ℝ => r ^ 2 * (Set.Iio ε).indicator (fun t : ℝ => t⁻¹) r) = + (Set.Iio ε).indicator (fun r : ℝ => r) := by + funext r + by_cases hr : r < ε + · simp only [Set.indicator_apply, Set.mem_Iio, hr, ite_true] + by_cases hzero : r = 0 + · simp [hzero] + · field_simp [hzero] + · simp [hr] + rw [hm, setIntegral_indicator measurableSet_Iio] + have hinter : Set.Ioi (0 : ℝ) ∩ Set.Iio ε = Set.Ioo 0 ε := by ext r; rfl + rw [hinter, ← integral_Ioc_eq_integral_Ioo, + ← intervalIntegral.integral_of_le hε, integral_id] + ring + rw [hi] + simp only [Measure.real, EuclideanSpace.volume_ball_fin_three, ENNReal.ofReal_one, one_pow, + one_mul, ENNReal.toReal_ofReal (by positivity : 0 ≤ Real.pi * 4 / 3), smul_eq_mul, + nsmul_eq_mul] + norm_num [Position, finrank_euclideanSpace_fin] + ring + +theorem cappedCoulombPotential_error_explicit {ε B : ℝ} (hε : 0 < ε) + {ρ : Position → ℝ} (hρ : Integrable ρ) (hpos : ∀ x, 0 ≤ ρ x) + (hbound : ∀ x, ρ x ≤ B) (x : Position) : + |NeutralAtom.potentialOf ρ x - cappedCoulombPotential ε ρ x| ≤ + 2 * Real.pi * B * ε ^ 2 := by + have h := cappedCoulombPotential_error hε hρ hpos hbound x + rw [coulomb_kernelBallMass hε.le] at h + convert h using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombTruncation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0209d4660229c23a76ba309b9dd4fb1c7e20df9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedCoulombTruncation.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombKernel + +namespace OAI + +/-! Finite-box truncation of the bounded Coulomb integral. The bound is +uniform in the displacement and uses only the discarded density masses. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def cappedPairIntegrand (ε : ℝ) (shift : Position) (f g : Position → ℝ) + (p : Position × Position) : ℝ := + f p.1 * g p.2 * cappedCoulombKernel ε (p.1 - p.2 - shift) + +theorem cappedPairIntegrand_integrable {ε : ℝ} (hε : 0 < ε) (shift : Position) + {f g : Position → ℝ} (hf : Integrable f) (hg : Integrable g) : + Integrable (cappedPairIntegrand ε shift f g) := by + have hp : Integrable (fun p : Position × Position => f p.1 * g p.2) := by + simpa only [Measure.volume_eq_prod] using hf.mul_prod hg + unfold cappedPairIntegrand + apply hp.mul_bdd (c := ε⁻¹) + (((cappedCoulombKernel_continuous hε).comp + ((continuous_fst.sub continuous_snd).sub continuous_const)).aestronglyMeasurable) + exact Filter.Eventually.of_forall (fun p => by + change ‖cappedCoulombKernel ε (p.1 - p.2 - shift)‖ ≤ ε⁻¹ + rw [Real.norm_of_nonneg (cappedCoulombKernel_nonnegative hε _)] + exact cappedCoulombKernel_le hε _) + +theorem cappedPair_truncation_error {ε : ℝ} (hε : 0 < ε) (shift : Position) + {f g : Position → ℝ} (hf : Integrable f) (hg : Integrable g) + (hf0 : ∀ x, 0 ≤ f x) (hg0 : ∀ y, 0 ≤ g y) + {S T : Set Position} (hS : MeasurableSet S) (hT : MeasurableSet T) : + |(∫ p, cappedPairIntegrand ε shift f g p) - + ∫ p in S ×ˢ T, cappedPairIntegrand ε shift f g p| ≤ + ε⁻¹ * ((∫ x in Sᶜ, f x) * (∫ y, g y) + + (∫ x, f x) * (∫ y in Tᶜ, g y)) := by + let F := cappedPairIntegrand ε shift f g + let M : Position × Position → ℝ := fun p => ε⁻¹ * + (Sᶜ.indicator f p.1 * g p.2 + f p.1 * Tᶜ.indicator g p.2) + have hFi : Integrable F := cappedPairIntegrand_integrable hε shift hf hg + have hSi := hf.indicator hS.compl + have hTi := hg.indicator hT.compl + have hfirst : Integrable (fun p : Position × Position => Sᶜ.indicator f p.1 * g p.2) := by + simpa only [Measure.volume_eq_prod] using hSi.mul_prod hg + have hsecond : Integrable (fun p : Position × Position => f p.1 * Tᶜ.indicator g p.2) := by + simpa only [Measure.volume_eq_prod] using hf.mul_prod hTi + have hMi : Integrable M := by + simpa only [M, Pi.add_apply] using (hfirst.add hsecond).const_mul ε⁻¹ + have hpt (p : Position × Position) : + ‖F p - (S ×ˢ T).indicator F p‖ ≤ M p := by + have hF0 : 0 ≤ F p := mul_nonneg (mul_nonneg (hf0 _) (hg0 _)) + (cappedCoulombKernel_nonnegative hε _) + have hFbound : F p ≤ ε⁻¹ * (f p.1 * g p.2) := by + unfold F cappedPairIntegrand + calc + _ ≤ f p.1 * g p.2 * ε⁻¹ := mul_le_mul_of_nonneg_left + (cappedCoulombKernel_le hε _) (mul_nonneg (hf0 _) (hg0 _)) + _ = _ := by ring + have hM0 : 0 ≤ M p := mul_nonneg (inv_nonneg.mpr hε.le) + (add_nonneg + (mul_nonneg (Set.indicator_nonneg (fun x _ => hf0 x) _) (hg0 _)) + (mul_nonneg (hf0 _) (Set.indicator_nonneg (fun y _ => hg0 y) _))) + by_cases hs : p.1 ∈ S <;> by_cases ht : p.2 ∈ T + · rw [Set.indicator_of_mem (show p ∈ S ×ˢ T from ⟨hs, ht⟩), sub_self, norm_zero] + exact hM0 + · have hp : p ∉ S ×ˢ T := by simp [ht] + rw [Set.indicator_of_notMem hp, sub_zero, Real.norm_of_nonneg hF0] + simpa only [M, Set.indicator_of_notMem (show p.1 ∉ Sᶜ by simpa using hs), + Set.indicator_of_mem (show p.2 ∈ Tᶜ from ht), zero_mul, zero_add] using hFbound + · have hp : p ∉ S ×ˢ T := by simp [hs] + rw [Set.indicator_of_notMem hp, sub_zero, Real.norm_of_nonneg hF0] + simpa only [M, Set.indicator_of_mem (show p.1 ∈ Sᶜ from hs), + Set.indicator_of_notMem (show p.2 ∉ Tᶜ by simpa using ht), mul_zero, add_zero] using hFbound + · have hp : p ∉ S ×ˢ T := by simp [hs] + rw [Set.indicator_of_notMem hp, sub_zero, Real.norm_of_nonneg hF0] + dsimp only [M] + rw [Set.indicator_of_mem (show p.1 ∈ Sᶜ from hs), + Set.indicator_of_mem (show p.2 ∈ Tᶜ from ht)] + have hz := mul_nonneg (inv_nonneg.mpr hε.le) (mul_nonneg (hf0 p.1) (hg0 p.2)) + linarith + rw [← integral_indicator (hS.prod hT), ← integral_sub hFi (hFi.indicator (hS.prod hT))] + have h := norm_integral_le_of_norm_le + (f := fun p => F p - (S ×ˢ T).indicator F p) hMi (Filter.Eventually.of_forall hpt) + rw [Real.norm_eq_abs] at h + apply h.trans_eq + simp only [M, integral_const_mul] + rw [integral_add hfirst hsecond, Measure.volume_eq_prod, integral_prod_mul, integral_prod_mul, + integral_indicator hS.compl, integral_indicator hT.compl] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedRawModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedRawModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..823b56b6feac3938ba87dc19c05610cc20ac02bd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedRawModulus.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensityModulus + +namespace OAI + +/-! A polynomial modulus for the actual six-coordinate capped density +integrand. Relative displacement has no effect on this modulus. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem bounded_product_sub {a b c d : ℝ} + (ha0 : 0 ≤ a) (ha1 : a ≤ 1) (hd0 : 0 ≤ d) (hd1 : d ≤ 1) : + |a * b - c * d| ≤ |a - c| + |b - d| := by + have he : a * b - c * d = a * (b - d) + (a - c) * d := by ring + rw [he] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg ha0, abs_of_nonneg hd0] + have h1 := mul_le_of_le_one_left (abs_nonneg (b - d)) ha1 + have h2 := mul_le_of_le_one_right (abs_nonneg (a - c)) hd1 + linarith + +theorem cappedRawPair_modulus {freq ε L : ℝ} (hf : 0 ≤ freq) (hε : 0 < ε) + (shift : Position) (x y x' y' : Position) + (hx : |(positionSplitCoordinates x).2| ≤ L) + (hy : |(positionSplitCoordinates y).2| ≤ L) + (hx' : |(positionSplitCoordinates x').2| ≤ L) + (hy' : |(positionSplitCoordinates y').2| ≤ L) : + |cappedPairIntegrand ε shift (localizedRawDensity freq) (localizedRawDensity freq) (x, y) - + cappedPairIntegrand ε shift (localizedRawDensity freq) (localizedRawDensity freq) (x', y')| ≤ + ((64 + 2 * freq * L) * ε⁻¹ + ε⁻¹ ^ 2) * (‖x - x'‖ + ‖y - y'‖) := by + let a := localizedRawDensity freq x * localizedRawDensity freq y + let b := localizedRawDensity freq x' * localizedRawDensity freq y' + let k := cappedCoulombKernel ε (x - y - shift) + let k' := cappedCoulombKernel ε (x' - y' - shift) + have hb0 : 0 ≤ b := mul_nonneg (localizedRawDensity_nonnegative _ _) (localizedRawDensity_nonnegative _ _) + have hb1 : b ≤ 1 := (mul_le_mul (localizedRawDensity_le_one hf _) + (localizedRawDensity_le_one hf _) (localizedRawDensity_nonnegative _ _) zero_le_one).trans_eq (one_mul 1) + have hk0 : 0 ≤ k := cappedCoulombKernel_nonnegative hε _ + have hk1 : k ≤ ε⁻¹ := cappedCoulombKernel_le hε _ + have hab : |a - b| ≤ (64 + 2 * freq * L) * (‖x - x'‖ + ‖y - y'‖) := by + have h := bounded_product_sub (a := localizedRawDensity freq x) + (b := localizedRawDensity freq y) (c := localizedRawDensity freq x') + (d := localizedRawDensity freq y') (localizedRawDensity_nonnegative freq x) + (localizedRawDensity_le_one hf x) (localizedRawDensity_nonnegative freq y') + (localizedRawDensity_le_one hf y') + apply h.trans + have h1 := localizedRawDensity_box_modulus hf x x' hx hx' + have h2 := localizedRawDensity_box_modulus hf y y' hy hy' + linarith + have hkk : |k - k'| ≤ ε⁻¹ ^ 2 * (‖x - x'‖ + ‖y - y'‖) := by + have h := cappedCoulombKernel_norm_sub hε (x - y - shift) (x' - y' - shift) + have hn : ‖x - y - shift - (x' - y' - shift)‖ ≤ ‖x - x'‖ + ‖y - y'‖ := by + rw [show x - y - shift - (x' - y' - shift) = (x - x') - (y - y') by abel] + exact norm_sub_le _ _ + exact h.trans (mul_le_mul_of_nonneg_left hn (sq_nonneg _)) + have he : cappedPairIntegrand ε shift (localizedRawDensity freq) (localizedRawDensity freq) (x, y) - + cappedPairIntegrand ε shift (localizedRawDensity freq) (localizedRawDensity freq) (x', y') = + (a - b) * k + b * (k - k') := by + dsimp only [cappedPairIntegrand, a, b, k, k'] + ring + rw [he] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg hk0, abs_of_nonneg hb0] + have h1 := mul_le_mul hab hk1 hk0 (by + have hL : 0 ≤ L := (abs_nonneg _).trans hx + positivity) + have h2 := (mul_le_of_le_one_left (abs_nonneg (k - k')) hb1).trans hkk + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedWells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedWells.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b8d95b75714ca29cb68d47d2c40f9cdec2799e9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CappedWells.lean @@ -0,0 +1,159 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model + +namespace OAI + +/-! +# The explicit cap in the isolated-well construction + +The quintic transition is the normalized integral of a positive multiple +of `s²(1-s)²`. Capping removes a whole neighbourhood of both nuclear poles. +The resulting pointwise bound is uniform in the secondary displacements, +as required before any energy tuning is carried out. +-/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def wellTransition (s : ℝ) : ℝ := 6 * s ^ 5 - 15 * s ^ 4 + 10 * s ^ 3 + +theorem wellTransition_bounds {s : ℝ} (hs0 : 0 ≤ s) (hs1 : s ≤ 1) : + 0 ≤ wellTransition s ∧ wellTransition s ≤ 1 := by + have hleft : wellTransition s = + s ^ 3 * (1 + 3 * (1 - s) + 6 * (1 - s) ^ 2) := by + unfold wellTransition + ring + have hright : 1 - wellTransition s = (1 - s) ^ 3 * (1 + 3 * s + 6 * s ^ 2) := by + unfold wellTransition + ring + have h0 : 0 ≤ wellTransition s := by rw [hleft]; positivity + have h1 : 0 ≤ 1 - wellTransition s := by rw [hright]; positivity + exact ⟨h0, by linarith⟩ + +def wellCap (t : ℝ) : ℝ := + if t ≤ 1 / 16 then 0 else if 1 / 8 ≤ t then 1 else wellTransition (16 * t - 1) + +theorem wellCap_eq_zero {t : ℝ} (ht : t ≤ 1 / 16) : wellCap t = 0 := by + simp only [wellCap, ite_eq_left ht] + +theorem wellCap_eq_one {t : ℝ} (ht : 1 / 8 ≤ t) : wellCap t = 1 := by + have hn : ¬ t ≤ 1 / 16 := by linarith + simp only [wellCap, ite_eq_right hn, ite_eq_left ht] + +theorem wellCap_bounds (t : ℝ) : 0 ≤ wellCap t ∧ wellCap t ≤ 1 := by + unfold wellCap + split_ifs with h0 h1 + · norm_num + · norm_num + · exact wellTransition_bounds (by linarith) (by linarith) + +theorem wellCap_nonzero_radius {D r : ℝ} (hD : 0 < D) + (hcap : wellCap (r / D) ≠ 0) : D / 16 < r := by + have h : ¬ r / D ≤ 1 / 16 := fun hr => hcap (wellCap_eq_zero hr) + have hr := (lt_div_iff₀ hD).mp (lt_of_not_ge h) + linarith + +def sitePotential (q q' : ℝ) (center displacement x : Position) : ℝ := + q * Coulomb.coulombKernel (x - center) + + q' * Coulomb.coulombKernel (x - center - displacement) + +def cappedSitePotential (D q q' : ℝ) (center displacement x : Position) : ℝ := + wellCap (‖x - center‖ / D) * sitePotential q q' center displacement x + +theorem sitePotential_nonneg {q q' : ℝ} (hq : 0 ≤ q) (hq' : 0 ≤ q') + (center displacement x : Position) : 0 ≤ sitePotential q q' center displacement x := by + unfold sitePotential Coulomb.coulombKernel + positivity + +theorem cappedSitePotential_nonneg {D q q' : ℝ} (hq : 0 ≤ q) (hq' : 0 ≤ q') + (center displacement x : Position) : + 0 ≤ cappedSitePotential D q q' center displacement x := + mul_nonneg (wellCap_bounds _).1 (sitePotential_nonneg hq hq' _ _ _) + +theorem cappedSitePotential_zero_near_primary {D q q' : ℝ} (hD : 0 < D) + (center displacement x : Position) (hx : ‖x - center‖ ≤ D / 16) : + cappedSitePotential D q q' center displacement x = 0 := by + unfold cappedSitePotential + rw [wellCap_eq_zero ((div_le_iff₀ hD).mpr (by linarith)), zero_mul] + +/-- The cap removes the secondary pole together with an explicit surrounding +ball; the cancellation is not merely a convention for the value at the pole. -/ +theorem cappedSitePotential_zero_near_secondary {D q q' : ℝ} + (hD : 128 ≤ D) (center displacement x : Position) + (hdisp : ‖displacement‖ ≤ 4) + (hx : ‖x - center - displacement‖ ≤ D / 32) : + cappedSitePotential D q q' center displacement x = 0 := by + have hD0 : 0 < D := by linarith + have hnorm : ‖x - center‖ ≤ D / 16 := by + calc + ‖x - center‖ = ‖(x - center - displacement) + displacement‖ := by congr 1; abel + _ ≤ ‖x - center - displacement‖ + ‖displacement‖ := norm_add_le _ _ + _ ≤ D / 16 := by linarith + unfold cappedSitePotential + rw [wellCap_eq_zero ((div_le_iff₀ hD0).mpr (by linarith)), zero_mul] + +theorem cappedSitePotential_bound {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq' : 0 ≤ q') (center displacement x : Position) + (hdisp : ‖displacement‖ ≤ 4) : + cappedSitePotential D q q' center displacement x ≤ (16 * q + 32 * q') / D := by + have hD0 : 0 < D := by linarith + by_cases hc : wellCap (‖x - center‖ / D) = 0 + · simp only [cappedSitePotential, hc, zero_mul] + positivity + · have hr := wellCap_nonzero_radius hD0 hc + have hs : D / 32 ≤ ‖x - center - displacement‖ := by + have ht : ‖x - center‖ ≤ ‖x - center - displacement‖ + ‖displacement‖ := by + calc + _ = ‖(x - center - displacement) + displacement‖ := by congr 1; abel + _ ≤ _ := norm_add_le _ _ + linarith + have hprimary : Coulomb.coulombKernel (x - center) ≤ 16 / D := by + unfold Coulomb.coulombKernel + calc + _ ≤ (D / 16)⁻¹ := inv_anti₀ (by positivity) hr.le + _ = _ := by ring + have hsecondary : Coulomb.coulombKernel (x - center - displacement) ≤ 32 / D := by + unfold Coulomb.coulombKernel + calc + _ ≤ (D / 32)⁻¹ := inv_anti₀ (by positivity) hs + _ = _ := by ring + calc + cappedSitePotential D q q' center displacement x ≤ sitePotential q q' center displacement x := + mul_le_of_le_one_left (sitePotential_nonneg hq hq' _ _ _) (wellCap_bounds _).2 + _ ≤ q * (16 / D) + q' * (32 / D) := + add_le_add (mul_le_mul_of_nonneg_left hprimary hq) + (mul_le_mul_of_nonneg_left hsecondary hq') + _ = _ := by ring + +def backgroundPotential {m : ℕ} (D q q' : ℝ) (center displacement : Fin m → Position) + (site : Fin m) (x : Position) : ℝ := + ∑ j, if j = site then 0 else cappedSitePotential D q q' (center j) (displacement j) x + +theorem backgroundPotential_bounds {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (x : Position) : + 0 ≤ backgroundPotential D q q' center displacement site x ∧ + backgroundPotential D q q' center displacement site x ≤ 48 * m / D := by + have hD0 : 0 < D := by linarith + constructor + · exact Finset.sum_nonneg fun j _ => by + split_ifs + · exact le_rfl + · exact cappedSitePotential_nonneg hq hq' _ _ _ + · calc + _ ≤ ∑ _j : Fin m, (48 / D : ℝ) := by + apply Finset.sum_le_sum + intro j _ + split_ifs + · positivity + · apply (cappedSitePotential_bound hD hq hq' _ _ _ (hdisp j)).trans + apply (div_le_div_iff_of_pos_right hD0).mpr + linarith + _ = _ := by simp; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussEquiv.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..0415fa33ae26e4a3d0ef9c97642fac4067d1f2aa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussEquiv.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredGaussProgram + +namespace OAI + +/-! The emitted centered label list is exactly the finite cell-by-eight-node +grid used by the Coulomb quadrature theorems. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.CenteredGaussLabels + +def decode (i : GaussLatticeIndex) : TransformedGauss.Label := + ((i.1 0,(i.1 1,i.1 2)),(decide (i.2 0=1),(decide (i.2 1=1),decide (i.2 2=1)))) + +private theorem bit_value (v : Fin 2) : (if decide (v=1) then (1:Fin 2) else 0) = v := by + fin_cases v <;> decide + +@[simp] theorem index_decode (i : GaussLatticeIndex) : + RationalGaussNodes.index (decode i).1 (decode i).2 = i := by + apply Prod.ext + · funext a + fin_cases a <;> rfl + · funext a + fin_cases a <;> exact bit_value _ + +@[simp] theorem decode_index (l : TransformedGauss.Label) : + decode (RationalGaussNodes.index l.1 l.2) = l := by + apply TransformedGauss.index_injective + exact index_decode _ + +def indexEquiv : TransformedGauss.Label ≃ GaussLatticeIndex where + toFun l := RationalGaussNodes.index l.1 l.2 + invFun := decode + left_inv := decode_index + right_inv := index_decode + +abbrev Grid (r : Radii) := + {k // k ∈ centeredGridIndices (radiiVector r)} × (Fin 3 → Fin 2) + +def restrictedEquiv (r : Radii) : {l // l ∈ labels r} ≃ Grid r where + toFun l := (⟨(indexEquiv l.val).1,(mem_labels r l.val).mp l.property⟩,(indexEquiv l.val).2) + invFun kv := ⟨decode (kv.1.val,kv.2),(mem_labels r _).mpr (by + rw [index_decode] + exact kv.1.property)⟩ + left_inv l := Subtype.ext (decode_index l.val) + right_inv kv := by + have he := index_decode (kv.1.val,kv.2) + have h1 : (indexEquiv (decode (kv.1.val,kv.2))).1 = kv.1.val := + congrArg (fun p : GaussLatticeIndex => p.1) he + have h2 : (indexEquiv (decode (kv.1.val,kv.2))).2 = kv.2 := + congrArg (fun p : GaussLatticeIndex => p.2) he + exact Prod.ext (Subtype.ext h1) h2 + +def enumerationEquiv (r : Radii) : Fin (labels r).length ≃ Grid r := + (List.Nodup.getEquiv (labels r) (labels_nodup r)).trans (restrictedEquiv r) + +@[simp] theorem enumeration_first (r : Radii) (a : Fin (labels r).length) : + (enumerationEquiv r a).1.val = (RationalGaussNodes.index ((labels r).get a).1 ((labels r).get a).2).1 := rfl + +@[simp] theorem enumeration_second (r : Radii) (a : Fin (labels r).length) : + (enumerationEquiv r a).2 = (RationalGaussNodes.index ((labels r).get a).1 ((labels r).get a).2).2 := rfl + +theorem sum_enumeration {A : Type*} [AddCommMonoid A] (r : Radii) (f : GaussLatticeIndex → A) : + (∑ a : Fin (labels r).length, + f (RationalGaussNodes.index ((labels r).get a).1 ((labels r).get a).2)) = + ∑ k : {k // k ∈ centeredGridIndices (radiiVector r)}, ∑ v : Fin 3 → Fin 2, f (k.val,v) := by + have he := (enumerationEquiv r).sum_comp (fun kv : Grid r => f (kv.1.val,kv.2)) + simpa only [Fintype.sum_prod_type,enumeration_first,enumeration_second] using he + +end ContinuumCoulomb.CenteredGaussLabels + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussLabels.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..892c1bb9bf166f22eba96d4f3e23260b608d26f7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGaussLabels.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGrid + +namespace OAI + +/-! A concrete duplicate-free list of all eight Gauss labels in each cell +of the centered rectangular grid, with the exact polynomial count. -/ + +namespace ContinuumCoulomb.CenteredGaussLabels +open EulerRegisters (Registers) +open RationalGaussNodes (Signs) + +abbrev Radii := ℕ×(ℕ×ℕ) + +def integers (R : ℕ) : List ℤ := + (List.range (2*R+1)).map (fun j : ℕ => (j:ℤ)-(R:ℤ)) +def signs : List Signs := + [false,true] ×ˢ ([false,true] ×ˢ [false,true]) +def cells (r : Radii) : List Registers := + integers r.1 ×ˢ (integers r.2.1 ×ˢ integers r.2.2) +def labels (r : Radii) : List (Registers×Signs) := cells r ×ˢ signs +def radiiVector (r : Radii) : Fin 3 → ℕ := ![r.1,r.2.1,r.2.2] + +theorem mem_integers (R : ℕ) (j : ℤ) : j ∈ integers R ↔ -(R:ℤ) ≤ j ∧ j ≤ R := by + constructor + · intro h + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp h + have hi' := List.mem_range.mp hi + omega + · rintro ⟨hl,hu⟩ + refine List.mem_map.mpr ⟨(j+(R:ℤ)).toNat,List.mem_range.mpr ?_,?_⟩ <;> omega + +theorem integers_nodup (R : ℕ) : (integers R).Nodup := + (List.nodup_range).map (by + intro a b h + have he : (a:ℤ)-(R:ℤ) = (b:ℤ)-(R:ℤ) := h + omega) + +theorem signs_mem (s : Signs) : s ∈ signs := by + rcases s with ⟨a,b,c⟩ + cases a <;> cases b <;> cases c <;> simp [signs] + +theorem labels_nodup (r : Radii) : (labels r).Nodup := by + apply List.Nodup.product + · exact (integers_nodup r.1).product ((integers_nodup r.2.1).product (integers_nodup r.2.2)) + · decide + +theorem labels_length (r : Radii) : + (labels r).length = 8*((2*r.1+1)*(2*r.2.1+1)*(2*r.2.2+1)) := by + simp only [labels,cells,signs,integers,List.length_product,List.length_map,List.length_range] + simp only [List.length_cons,List.length_nil] + ring + +theorem mem_labels (r : Radii) (l : Registers×Signs) : + l ∈ labels r ↔ (RationalGaussNodes.index l.1 l.2).1 ∈ centeredGridIndices (radiiVector r) := by + rcases l with ⟨⟨a,b,c⟩,s⟩ + rw [labels,List.mem_product] + simp only [signs_mem,and_true,cells,List.mem_product,mem_integers] + rw [mem_centeredGridIndices] + constructor + · rintro ⟨h0,h1,h2⟩ i + fin_cases i + · simpa [RationalGaussNodes.index,radiiVector] using h0 + · simpa [RationalGaussNodes.index,radiiVector] using h1 + · simpa [RationalGaussNodes.index,radiiVector] using h2 + · intro h + exact ⟨by simpa [RationalGaussNodes.index,radiiVector] using h 0, + by simpa [RationalGaussNodes.index,radiiVector] using h 1, + by simpa [RationalGaussNodes.index,radiiVector] using h 2⟩ + +end ContinuumCoulomb.CenteredGaussLabels + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..9423687a4fc334d53406b21f7819bf3a3f75c7b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredGrid.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeIntegral + +namespace OAI + +/-! A concrete finite family of lattice cubes tiles the enclosing rectangular +slab, including its boundary. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +def centeredGridIndices (r : Fin 3 → ℕ) : Finset (Fin 3 → ℤ) := + Fintype.piFinset (fun i => Finset.Icc (-(r i : ℤ)) (r i : ℤ)) + +theorem mem_centeredGridIndices (r : Fin 3 → ℕ) (k : Fin 3 → ℤ) : + k ∈ centeredGridIndices r ↔ ∀ i, -(r i : ℤ) ≤ k i ∧ k i ≤ (r i : ℤ) := by + simp only [centeredGridIndices,Fintype.mem_piFinset,Finset.mem_Icc] + +theorem exists_centered_grid_integer (N : ℕ) {h x : ℝ} (hh : 0 < h) + (hx : |x| ≤ ((N:ℝ)+1/2)*h) : + ∃ k : ℤ, -(N:ℤ) ≤ k ∧ k ≤ (N:ℤ) ∧ |x-h*(k:ℝ)| ≤ h/2 := by + let j : ℤ := ⌊x/h+1/2⌋ + have hx' := abs_le.mp hx + have he : (x/h)*h = x := div_mul_cancel₀ _ hh.ne' + have hjl : (j:ℝ) ≤ x/h+1/2 := Int.floor_le _ + have hju : x/h+1/2 < (j:ℝ)+1 := Int.lt_floor_add_one _ + have hjlow : -(N:ℤ) ≤ j := by + apply Int.le_floor.mpr + push_cast + nlinarith + by_cases hj : j ≤ (N:ℤ) + · refine ⟨j,hjlow,hj,abs_le.mpr ⟨?_,?_⟩⟩ + · nlinarith [mul_le_mul_of_nonneg_right hjl hh.le] + · nlinarith [mul_lt_mul_of_pos_right hju hh] + · refine ⟨(N:ℤ),by omega,le_rfl,abs_le.mpr ⟨?_,?_⟩⟩ + · have hjn : (N:ℝ)+1 ≤ (j:ℝ) := by exact_mod_cast (show (N:ℤ)+1 ≤ j by omega) + norm_num only [Int.cast_natCast] + nlinarith [mul_le_mul_of_nonneg_right hjn hh.le,mul_le_mul_of_nonneg_right hjl hh.le] + · exact_mod_cast (show x-h*(N:ℝ) ≤ h/2 by nlinarith [hx'.2]) + +theorem centeredGrid_covers (r : Fin 3 → ℕ) {h : ℝ} (hh : 0 < h) : + (⋃ k : {k // k ∈ centeredGridIndices r}, positionCube (gaussCellCenter h k.val) h) = + {x : Position | ∀ i, |x i| ≤ ((r i:ℝ)+1/2)*h} := by + ext x + constructor + · intro hx + obtain ⟨k,hk⟩ := Set.mem_iUnion.mp hx + have hki := (mem_centeredGridIndices r k.val).mp k.property + intro i + have hc := abs_le.mp (mem_positionCube.mp hk i) + have hb1 : -(r i:ℝ) ≤ (k.val i:ℝ) := by exact_mod_cast (hki i).1 + have hb2 : (k.val i:ℝ) ≤ (r i:ℝ) := by exact_mod_cast (hki i).2 + apply abs_le.mpr + change -(h/2) ≤ x i-h*(k.val i:ℝ) ∧ x i-h*(k.val i:ℝ) ≤ h/2 at hc + rcases hc with ⟨hcl,hcu⟩ + constructor <;> nlinarith [mul_le_mul_of_nonneg_left hb1 hh.le, + mul_le_mul_of_nonneg_left hb2 hh.le] + · intro hx + choose k hk1 hk2 hk3 using fun i => exists_centered_grid_integer (r i) hh (hx i) + refine Set.mem_iUnion.mpr ⟨⟨k,(mem_centeredGridIndices r k).mpr (fun i => ⟨hk1 i,hk2 i⟩)⟩,?_⟩ + rw [mem_positionCube] + exact hk3 + +theorem grid_cell_integral_sum_eq {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) {B : Set Position} + (hcover : (⋃ i, positionCube (gaussCellCenter h (index i)) h) = B) + (f : Position → ℝ) (hf : IntegrableOn f B) : + (∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, f x) = ∫ x in B, f x := by + have he (i : ι) := positionOpenCube_ae_eq (gaussCellCenter h (index i)) h + have hsets : (⋃ i, positionOpenCube (gaussCellCenter h (index i)) h) =ᵐ[volume] + (⋃ i, positionCube (gaussCellCenter h (index i)) h) := by + filter_upwards [ae_all_iff.mpr he] with x hx + simp only [Set.mem_iUnion] + simp_rw [hx] + have hi (i : ι) : IntegrableOn f (positionOpenCube (gaussCellCenter h (index i)) h) := by + apply hf.mono_set + intro x hx + rw [← hcover] + exact Set.mem_iUnion.mpr ⟨i,positionOpenCube_subset _ _ hx⟩ + calc + _ = ∑ i, ∫ x in positionOpenCube (gaussCellCenter h (index i)) h, f x := by + apply Finset.sum_congr rfl + intro i _ + exact (setIntegral_congr_set (he i)).symm + _ = ∫ x in ⋃ i, positionOpenCube (gaussCellCenter h (index i)) h, f x := + (integral_iUnion_fintype (fun i => positionOpenCube_measurable _ _) + (fun i j hij => grid_openCubes_disjoint hh (fun he => hij (hindex he))) hi).symm + _ = ∫ x in ⋃ i, positionCube (gaussCellCenter h (index i)) h, f x := + setIntegral_congr_set hsets + _ = _ := by rw [hcover] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredPhysicalThreshold.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredPhysicalThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc55a9a518a5056e2c68eb3b79dadd54ae23a782 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CenteredPhysicalThreshold.lean @@ -0,0 +1,121 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SlabBoxProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.PhysicalThreshold +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianFrequencyProgram + +namespace OAI + +/-! Physical threshold reference for the exact half-cell boundary of the +centered grid. The finite threshold is scaled by lambda and the true rational +slab reference by lambda squared times the electron count. -/ + +noncomputable section +namespace ContinuumCoulomb.CenteredPhysicalThreshold + +abbrev Geometry := ℕ × (ℕ × ℕ) +abbrev Input := Geometry × (ℕ × (ℕ × (ℚ × ℚ))) + +def amplification (rho mesh : ℕ) : ℚ := 8*(mesh:ℚ)^3/rho + +def precision (x : Input) : ℕ := + 8*(8*x.1.1^3+1)^2*(x.2.1+1)*(x.2.2.1+1) + +def reference (rho : ℕ) (x : Input) : ℚ := + SlabBoxSchedule.value rho (SlabBoxSchedule.centered (precision x) x.1.1 x.1.2.1 x.1.2.2)+ + (GaussianFrequency.approximate rho (precision x)-1)/2 + +def offset (rho : ℕ) (x : Input) : ℚ := + amplification rho x.1.1^2*x.2.1*reference rho x + +def value (rho : ℕ) (x : Input) : ℚ×ℚ := + (offset rho x+amplification rho x.1.1*x.2.2.2.1, + offset rho x+amplification rho x.1.1*x.2.2.2.2) + +def actualReference (rho : ℕ) (g : Geometry) : ℝ := + slabPotential (rho:ℝ) (SlabBoxSchedule.centeredWidth g.2.1 g.1:ℝ) + (SlabBoxSchedule.centeredWidth g.2.2 g.1:ℝ) 0+(GaussianFrequency.frequency rho-1)/2 + +def actualOffset (rho : ℕ) (x : Input) : ℝ := + (amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ)*actualReference rho x.1 + +theorem reference_error (rho : ℕ) (x : Input) (hmesh : 0 < x.1.1) : + |(reference rho x:ℝ)-actualReference rho x.1| ≤ + 2/(precision x+1:ℝ) := by + have hs := SlabBoxSchedule.centered_error rho (precision x) x.1.1 x.1.2.1 x.1.2.2 hmesh + rw [← SlabBoxSchedule.centeredWidth_real,← SlabBoxSchedule.centeredWidth_real] at hs + have hf := GaussianFrequency.approximation_error rho (precision x) + have he : (reference rho x:ℝ)-actualReference rho x.1 = + ((SlabBoxSchedule.value rho (SlabBoxSchedule.centered (precision x) x.1.1 x.1.2.1 x.1.2.2):ℝ)- + slabPotential (rho:ℝ) (SlabBoxSchedule.centeredWidth x.1.2.1 x.1.1:ℝ) + (SlabBoxSchedule.centeredWidth x.1.2.2 x.1.1:ℝ) 0)+ + ((GaussianFrequency.approximate rho (precision x):ℝ)-GaussianFrequency.frequency rho)/2 := by + simp only [reference,actualReference,Rat.cast_add,Rat.cast_sub,Rat.cast_div,Rat.cast_one, + Rat.cast_ofNat] + ring + rw [he] + apply (abs_add_le _ _).trans + rw [abs_div,abs_of_pos (by norm_num : (0:ℝ) < 2)] + have hn : 0 ≤ ((precision x:ℝ)+1)⁻¹ := by positivity + simp only [div_eq_mul_inv] at hs ⊢ + nlinarith + +theorem amplification_bound (rho mesh : ℕ) (hrho : 0 < rho) : + 0 ≤ (amplification rho mesh:ℝ) ∧ (amplification rho mesh:ℝ) ≤ 8*(mesh:ℝ)^3 := by + have hp : 0 < (rho:ℝ) := by exact_mod_cast hrho + have h1 : 1 ≤ (rho:ℝ) := by exact_mod_cast (Nat.succ_le_iff.mpr hrho) + simp only [amplification,Rat.cast_div,Rat.cast_mul,Rat.cast_ofNat,Rat.cast_pow,Rat.cast_natCast] + constructor + · positivity + · exact div_le_self (by positivity) h1 + +theorem offset_error (rho : ℕ) (hrho : 0 < rho) (x : Input) (hmesh : 0 < x.1.1) : + |(offset rho x:ℝ)-actualOffset rho x| ≤ 1/(x.2.2.1+1:ℝ) := by + have he := reference_error rho x hmesh + have ha := amplification_bound rho x.1.1 hrho + have hsq : (amplification rho x.1.1:ℝ)^2 ≤ (8*(x.1.1:ℝ)^3+1)^2 := by + nlinarith + have hcoef : (amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ)*2 ≤ + 8*(8*(x.1.1:ℝ)^3+1)^2*((x.2.1:ℝ)+1) := by + have ht := mul_le_mul_of_nonneg_right hsq (Nat.cast_nonneg x.2.1) + nlinarith [sq_nonneg (8*(x.1.1:ℝ)^3+1)] + have hprec : (precision x:ℝ) = + 8*(8*(x.1.1:ℝ)^3+1)^2*((x.2.1:ℝ)+1)*((x.2.2.1:ℝ)+1) := by + simp [precision] + have hden : 0 < (precision x:ℝ)+1 := by positivity + have hp : 0 < (x.2.2.1:ℝ)+1 := by positivity + have hprod : (amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ)*2*((x.2.2.1:ℝ)+1) ≤ + (precision x:ℝ)+1 := by + rw [hprec] + nlinarith [mul_le_mul_of_nonneg_right hcoef hp.le] + have hid : (offset rho x:ℝ)-actualOffset rho x = + (amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ)* + ((reference rho x:ℝ)-actualReference rho x.1) := by + simp only [offset,actualOffset,Rat.cast_mul,Rat.cast_pow,Rat.cast_natCast] + ring + rw [hid,abs_mul,abs_of_nonneg (by positivity : 0 ≤ (amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ))] + apply (mul_le_mul_of_nonneg_left he (by positivity)).trans + apply (le_div_iff₀ hp).mpr + calc + _ = ((amplification rho x.1.1:ℝ)^2*(x.2.1:ℝ)*2* + ((x.2.2.1:ℝ)+1))/((precision x:ℝ)+1) := by ring + _ ≤ 1 := (div_le_one hden).mpr hprod + +theorem lower_error (rho : ℕ) (hrho : 0 < rho) (x : Input) (hmesh : 0 < x.1.1) : + |((value rho x).1:ℝ)-(actualOffset rho x+ + (amplification rho x.1.1:ℝ)*(x.2.2.2.1:ℝ))| ≤ 1/(x.2.2.1+1:ℝ) := by + simpa only [value,Rat.cast_add,Rat.cast_mul,add_sub_add_right_eq_sub] using offset_error rho hrho x hmesh + +theorem upper_error (rho : ℕ) (hrho : 0 < rho) (x : Input) (hmesh : 0 < x.1.1) : + |((value rho x).2:ℝ)-(actualOffset rho x+ + (amplification rho x.1.1:ℝ)*(x.2.2.2.2:ℝ))| ≤ 1/(x.2.2.1+1:ℝ) := by + simpa only [value,Rat.cast_add,Rat.cast_mul,add_sub_add_right_eq_sub] using offset_error rho hrho x hmesh + +theorem gap (rho : ℕ) (x : Input) : + (value rho x).2-(value rho x).1 = amplification rho x.1.1*(x.2.2.2.2-x.2.2.2.1) := by + unfold value + ring + +end ContinuumCoulomb.CenteredPhysicalThreshold + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalH1.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalH1.lean new file mode 100644 index 0000000000000000000000000000000000000000..98548134a088a23cc499c1ef8e93ac1690cfbe3a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalH1.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts + +namespace OAI + +/-! C1 functions with square-integrable classical partials belong to the +actual weak H1 domain. Only the test function needs compact support; this +allows the decaying manufactured orbitals and their finite Slater sums. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem complex_C1_test_ibp {n : ℕ} (f : Configuration n → ℂ) (hf : ContDiff ℝ 1 f) + (φ : Configuration n → ℝ) (hφ : ContDiff ℝ 1 φ) (hc : HasCompactSupport φ) (v : Configuration n) : + (∫ x, f x * (fderiv ℝ φ x v : ℂ)) = -(∫ x, fderiv ℝ f x v * (φ x : ℂ)) := by + let g : Configuration n → ℂ := fun x => (φ x : ℂ) + have hg : ContDiff ℝ 1 g := Complex.ofRealCLM.contDiff.comp hφ + have hgc : HasCompactSupport g := hc.comp_left Complex.ofReal_zero + have hd (x : Configuration n) : fderiv ℝ g x v = (fderiv ℝ φ x v : ℂ) := + congrArg (fun L : Configuration n →L[ℝ] ℂ => L v) + ((Complex.ofRealCLM.hasFDerivAt.comp x (hφ.differentiable (by norm_num) x).hasFDerivAt).fderiv) + have hf' : Continuous (fun x => fderiv ℝ f x v) := + (hf.continuous_fderiv (by norm_num)).clm_apply continuous_const + have hg' : Continuous (fun x => fderiv ℝ g x v) := + (hg.continuous_fderiv (by norm_num)).clm_apply continuous_const + have hi1 : Integrable (fun x => fderiv ℝ f x v * g x) := + (hf'.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left + have hi2 : Integrable (fun x => f x * fderiv ℝ g x v) := + (hf.continuous.mul hg').integrable_of_hasCompactSupport (hgc.fderiv_apply ℝ v).mul_left + have hi3 : Integrable (fun x => f x * g x) := + (hf.continuous.mul hg.continuous).integrable_of_hasCompactSupport hgc.mul_left + have h := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hi1 hi2 hi3 + (fun x _ => hf.differentiable (by norm_num) x) (fun x _ => hg.differentiable (by norm_num) x) + simpa only [hd] using h + +def classicalH1State {n : ℕ} (f : SpinConfiguration n → Configuration n → ℂ) + (hf : ∀ s, ContDiff ℝ 1 (f s)) (hL2 : ∀ s, MemLp (f s) 2) + (hpartial : ∀ s a, MemLp (fun x => fderiv ℝ (f s) x (EuclideanSpace.single a 1)) 2) : + Coulomb.H1Vector n where + value := f + gradient s a x := fderiv ℝ (f s) x (EuclideanSpace.single a 1) + value_L2 := hL2 + partial_L2 := hpartial + weak_partial s a φ hφ hc := complex_C1_test_ibp (f s) (hf s) φ (hφ.of_le (by simp)) hc _ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalResidualPairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalResidualPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0f0a4ad806ff2af4bac3873f0e1a9e48fa9bc3d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalResidualPairing.lean @@ -0,0 +1,135 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakComplexLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedFormCross +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorTotalReplacement + +namespace OAI + +/-! An actual differential residual controls the mixed bounded-potential +form against every weak-H1 state, without restricting its smoothness. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem h1Coordinates_complex_inner {n : ℕ} (u v : Coulomb.H1Vector n) (a : H1Index n) : + inner ℂ (h1Coordinates u a) (h1Coordinates v a) = + ∫ x, star (h1CoordinateFunction u a x)*h1CoordinateFunction v a x := + h1_inner_complex_coordinate v a _ (h1Coordinate_memLp u a) + +theorem h1Coordinates_complex_mass_inner {n : ℕ} (u v : Coulomb.H1Vector n) : + (∑ s, inner ℂ (h1Coordinates u (Sum.inl s)) (h1Coordinates v (Sum.inl s))) = + inner ℂ u.toHilbert v.toHilbert := by + rw [PiLp.inner_apply] + rfl + +theorem boundedPotential_complex_pairing {n : ℕ} (u v : Coulomb.H1Vector n) + (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) + (s : SpinConfiguration n) : + inner ℂ (h1Coordinates u (Sum.inl s)) + (BoundedPotential.operator V hV B hB (h1Coordinates v (Sum.inl s))) = + ∫ x, star (u.value s x)*((V x:ℂ)*v.value s x) := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [(h1Coordinate_memLp u (Sum.inl s)).coeFn_toLp, + (h1Coordinate_memLp v (Sum.inl s)).coeFn_toLp, + BoundedPotential.operator_ae V hV B hB (h1Coordinates v (Sum.inl s))] with x hu hv hA + change h1Coordinates u (Sum.inl s) x = u.value s x at hu + change h1Coordinates v (Sum.inl s) x = v.value s x at hv + rw [hA,hu,hv,RCLike.inner_apply] + exact mul_comm _ _ + +theorem classical_residual_pairing (hdensity : PublishedSobolevSmoothDensity) + {n : ℕ} (u v : Coulomb.H1Vector n) + (V : Configuration n → ℝ) (hV : Continuous V) (B E : ℝ) (hB : ∀ x, |V x| ≤ B) + (R : SpinConfiguration n → Configuration n → ℂ) + (hR : ∀ s, MemLp (R s) 2) + (hu : ∀ s, ContDiff ℝ 2 (u.value s)) + (hdu : ∀ s a x, u.gradient s a x = configurationComplexPartial (u.value s) a x) + (heq : ∀ s x, R s x = (-1/2:ℂ)*configurationComplexLaplacian (u.value s) x+ + (V x:ℂ)*u.value s x-(E:ℂ)*u.value s x) : + graphComplexCross (BoundedPotential.operator V hV B hB) (h1Coordinates u) (h1Coordinates v)- + (E:ℂ)*inner ℂ u.toHilbert v.toHilbert = + ∑ s, ∫ x, star (R s x)*v.value s x := by + have hm (s : SpinConfiguration n) : MemLp (fun x => (V x:ℂ)*u.value s x) 2 := by + apply (u.value_L2 s).of_le_mul (c := B) + ((Complex.continuous_ofReal.comp hV).aestronglyMeasurable.mul (u.value_L2 s).aestronglyMeasurable) + filter_upwards [] with x + change ‖(V x:ℂ)*u.value s x‖ ≤ B*‖u.value s x‖ + simp only [norm_mul,Complex.norm_real,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hB x) (norm_nonneg _) + have hLap (s : SpinConfiguration n) : MemLp (configurationComplexLaplacian (u.value s)) 2 := by + have hfun : configurationComplexLaplacian (u.value s) = + (fun x => (2:ℂ)*((V x:ℂ)*u.value s x-(E:ℂ)*u.value s x-R s x)) := by + funext x + linear_combination 2*(heq s x) + rw [hfun] + exact ((hm s).sub ((u.value_L2 s).const_mul (E:ℂ)) |>.sub (hR s)).const_mul 2 + have hp (s : SpinConfiguration n) (a : Fin n × Fin 3) : + MemLp (configurationComplexPartial (u.value s) a) 2 := + (memLp_congr_ae (Filter.Eventually.of_forall (hdu s a))).mp (u.partial_L2 s a) + have hkin (s : SpinConfiguration n) := weakH1_complex_laplacian_pairing hdensity + (u.value s) (hu s) (hp s) (hLap s) v s + have hpoint (s : SpinConfiguration n) : + (1/2:ℂ)*(∑ a, ∫ x, star (u.gradient s a x)*v.gradient s a x)+ + (∫ x, star (u.value s x)*((V x:ℂ)*v.value s x))- + (E:ℂ)*(∫ x, star (u.value s x)*v.value s x) = + ∫ x, star (R s x)*v.value s x := by + have hLI := (hLap s).star.integrable_mul (v.value_L2 s) + have hVI := (hm s).star.integrable_mul (v.value_L2 s) + have hUI := (u.value_L2 s).star.integrable_mul (v.value_L2 s) + have hhalf : star (-1/2:ℂ) = (-1/2:ℂ) := by + change (starRingEnd ℂ) (-1/2) = (-1/2:ℂ) + simp only [map_div₀,map_neg,map_one,map_ofNat] + have hE : star (E:ℂ) = (E:ℂ) := Complex.conj_ofReal E + have hprod (x : Configuration n) : star (R s x)*v.value s x = + (-1/2:ℂ)*(star (configurationComplexLaplacian (u.value s) x)*v.value s x)+ + star ((V x:ℂ)*u.value s x)*v.value s x- + (E:ℂ)*(star (u.value s x)*v.value s x) := by + rw [heq] + simp only [star_sub,star_add,star_mul,hhalf,hE] + ring + simp_rw [hprod] + have hsub := integral_sub ((hLI.const_mul (-1/2:ℂ)).add hVI) (hUI.const_mul (E:ℂ)) + have hadd := integral_add (hLI.const_mul (-1/2:ℂ)) hVI + simp only [Pi.add_apply,Pi.mul_apply,Pi.star_apply] at hsub hadd + rw [hsub,hadd,integral_const_mul,integral_const_mul] + simp_rw [← hdu] at hkin + rw [hkin] + have hvprod : (∫ x, star ((V x:ℂ)*u.value s x)*v.value s x) = + ∫ x, star (u.value s x)*((V x:ℂ)*v.value s x) := by + congr 1 + funext x + simp only [star_mul,Complex.star_def,Complex.conj_ofReal] + ring + rw [hvprod] + ring + rw [← h1Coordinates_complex_mass_inner] + simp only [graphComplexCross,h1Coordinates_complex_inner,boundedPotential_complex_pairing, + h1CoordinateFunction] + simp only [Finset.mul_sum,← Finset.sum_add_distrib,← Finset.sum_sub_distrib] + exact Finset.sum_congr rfl (fun s _ => by simpa only [Finset.mul_sum] using hpoint s) + +theorem residual_integral_square_bound {n : ℕ} (v : Coulomb.H1Vector n) + (R : SpinConfiguration n → Configuration n → ℂ) (hR : ∀ s, MemLp (R s) 2) : + ‖∑ s, ∫ x, star (R s x)*v.value s x‖^2 ≤ + (∑ s, ∫ x, ‖R s x‖^2)*Coulomb.mass v := by + let r (s : SpinConfiguration n) : Lp ℂ 2 (volume : Measure (Configuration n)) := + (hR s).toLp (R s) + have he (s : SpinConfiguration n) : (∫ x, star (R s x)*v.value s x) = + inner ℂ (r s) (h1Coordinates v (Sum.inl s)) := + (h1_inner_complex_coordinate v (Sum.inl s) _ (hR s)).symm + simp only [he] + have ht : ‖∑ s, inner ℂ (r s) (h1Coordinates v (Sum.inl s))‖ ≤ + ∑ s, ‖r s‖*‖h1Coordinates v (Sum.inl s)‖ := + (norm_sum_le _ _).trans (Finset.sum_le_sum (fun s _ => norm_inner_le_norm _ _)) + have hb := (pow_le_pow_left₀ (norm_nonneg _) ht 2).trans + (Finset.sum_mul_sq_le_sq_mul_sq Finset.univ _ _) + simpa only [r,Coulomb.norm_toLp_sq_complex,h1Coordinates_norm_sq,h1CoordinateFunction, + Coulomb.mass] using hb + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlater.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlater.lean new file mode 100644 index 0000000000000000000000000000000000000000..eae13fa801130d4fcc8695da06656b4727243ccd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlater.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalTensor + +namespace OAI + +/-! Finite Slater determinants of C1 decaying orbitals are actual spinful +antisymmetric weak-H1 states. Orthonormal orbitals give unit mass on the +full continuum configuration space. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem slaterConfiguration_C1 {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) (s : SpinConfiguration n) : + ContDiff ℝ 1 (Coulomb.slaterConfiguration v s) := by + rw [Coulomb.slaterConfiguration_expansion] + apply contDiff_const.mul + exact ContDiff.sum (fun p _ => contDiff_const.mul (tensorOrbital_C1 v hv p s)) + +theorem slaterConfiguration_memLp {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) (s : SpinConfiguration n) : + MemLp (Coulomb.slaterConfiguration v s) 2 := by + have ht (p : Equiv.Perm (Fin n)) : MemLp + (fun x => (((p.sign : ℤ) : ℂ)) * Coulomb.tensorOrbital v p s x) 2 volume := + (Coulomb.tensorOrbital_memLp v hL2 p s).const_mul _ + have hs : MemLp (fun x => ∑ p : Equiv.Perm (Fin n), + (((p.sign : ℤ) : ℂ)) * Coulomb.tensorOrbital v p s x) 2 volume := + memLp_finsetSum Finset.univ (fun p _ => ht p) + have hc : MemLp (fun x => (↑(Real.sqrt (n.factorial : ℝ))⁻¹ : ℂ) * + ∑ p : Equiv.Perm (Fin n), (((p.sign : ℤ) : ℂ)) * Coulomb.tensorOrbital v p s x) 2 volume := + hs.const_mul _ + simpa only [Coulomb.slaterConfiguration_expansion] using hc + +theorem slaterConfiguration_partial_memLp {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) + (s : SpinConfiguration n) (i : Fin n) (b : Fin 3) : + MemLp (fun x => fderiv ℝ (Coulomb.slaterConfiguration v s) x (EuclideanSpace.single (i,b) 1)) 2 := by + have ht (p : Equiv.Perm (Fin n)) (x : Configuration n) : + DifferentiableAt ℝ (Coulomb.tensorOrbital v p s) x := (tensorOrbital_C1 v hv p s).differentiable (by norm_num) x + have he (x : Configuration n) : + fderiv ℝ (Coulomb.slaterConfiguration v s) x (EuclideanSpace.single (i,b) 1) = + (↑(Real.sqrt (n.factorial : ℝ))⁻¹ : ℂ) * + ∑ p : Equiv.Perm (Fin n), (((p.sign : ℤ) : ℂ)) * + fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1) := by + rw [Coulomb.slaterConfiguration_expansion, fderiv_const_mul + (DifferentiableAt.fun_sum (fun p _ => (ht p x).const_mul _)), + fderiv_fun_sum (fun p _ => (ht p x).const_mul _)] + simp only [smul_apply, smul_eq_mul, sum_apply, fderiv_const_mul (ht _ x)] + have htL (p : Equiv.Perm (Fin n)) : MemLp (fun x => (((p.sign : ℤ) : ℂ)) * + fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1)) 2 volume := + (tensorOrbital_partial_memLp v hv hL2 hpartial p s i b).const_mul _ + have hs : MemLp (fun x => ∑ p : Equiv.Perm (Fin n), (((p.sign : ℤ) : ℂ)) * + fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1)) 2 volume := + memLp_finsetSum Finset.univ (fun p _ => htL p) + have hc : MemLp (fun x => (↑(Real.sqrt (n.factorial : ℝ))⁻¹ : ℂ) * + ∑ p : Equiv.Perm (Fin n), (((p.sign : ℤ) : ℂ)) * + fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1)) 2 volume := + hs.const_mul _ + simpa only [he] using hc + +def classicalSlaterState {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) : + Coulomb.H1Vector n := + classicalH1State (Coulomb.slaterConfiguration v) (slaterConfiguration_C1 v hv) + (slaterConfiguration_memLp v hL2) (fun s a => slaterConfiguration_partial_memLp v hv hL2 hpartial s a.1 a.2) + +theorem classicalSlaterState_antisymmetric {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) : + Coulomb.Antisymmetric (classicalSlaterState v hv hL2 hpartial) := by + intro p s + filter_upwards [] with x + change Coulomb.slaterConfiguration v (s ∘ p) (Coulomb.permute p x) = _ * Coulomb.slaterConfiguration v s x + have he : (fun i => ((s ∘ p) i, Coulomb.position (Coulomb.permute p x) i)) = + (fun i => (s i, Coulomb.position x i)) ∘ p := by + funext i + simp only [Function.comp_apply, Coulomb.position_permute] + simp only [Coulomb.slaterConfiguration, Coulomb.slaterWave, he, Coulomb.determinantWave_permute] + ring + +theorem classicalSlaterState_normalized {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) + (ho : ∀ i j, (∑ s : Fin 2, ∫ x : Position, star (v i x s) * v j x s) = + if i = j then (1 : ℂ) else 0) : Coulomb.mass (classicalSlaterState v hv hL2 hpartial) = 1 := by + rw [← Coulomb.cubeState_full_mass] + change (∫ x, ‖Coulomb.slaterWave (fun i => Coulomb.flatSpinOrbital (v i)) x‖ ^ 2 + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure)) = 1 + apply Coulomb.slaterWave_normalized (fun i => Coulomb.flatSpinOrbital (v i)) + (fun i => Coulomb.flatSpinOrbital_memLp (v i) (hL2 i)) + intro i j + rw [Coulomb.flatSpinOrbital_inner (v i) (v j) (hL2 i) (hL2 j)] + exact ho i j + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterKinetic.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterKinetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..d665aa9dfe21c8bf32b3440009fac2b5c339f857 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterKinetic.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlater + +namespace OAI + +/-! Exact kinetic energy of the actual C1 decaying Slater state. The +finite determinant calculation needs L2 classical partials, without a +compact-support restriction on the occupied orbitals. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem slaterConfiguration_C1_fderiv {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (s : SpinConfiguration n) (x : Configuration n) (i : Fin n) (b : Fin 3) : + fderiv ℝ (Coulomb.slaterConfiguration v s) x (EuclideanSpace.single (i,b) 1) = + (↑(Real.sqrt (n.factorial : ℝ))⁻¹ : ℂ) * + Coulomb.slotDeterminant (fun a (sx : Fin 2 × Position) => v a sx.2 sx.1) + (fun a sx => fderiv ℝ (fun y => v a y sx.1) sx.2 (EuclideanSpace.single b 1)) i + (fun j => (s j, Coulomb.position x j)) := by + have ht (p : Equiv.Perm (Fin n)) : DifferentiableAt ℝ (Coulomb.tensorOrbital v p s) x := + (tensorOrbital_C1 v hv p s).differentiable (by norm_num) x + rw [Coulomb.slaterConfiguration_expansion, fderiv_const_mul (DifferentiableAt.fun_sum (fun p _ => + (ht p).const_mul _)), fderiv_fun_sum (fun p _ => (ht p).const_mul _)] + simp only [smul_apply, smul_eq_mul, sum_apply, + fderiv_const_mul (ht _), tensorOrbital_C1_fderiv v hv] + unfold Coulomb.slotDeterminant + congr 1 + apply Finset.sum_congr rfl + intro p _ + rw [Coulomb.slotTensor_factor] + +theorem classicalSlaterState_cubeGradient {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) + (i : Fin n) (b : Fin 3) (z : Fin n → Fin 2 × (Fin 3 → ℝ)) : + Coulomb.cubeGradient (classicalSlaterState v hv hL2 hpartial) (i,b) z = + (↑(Real.sqrt (n.factorial : ℝ))⁻¹ : ℂ) * + Coulomb.slotDeterminant (fun a => Coulomb.flatSpinOrbital (v a)) + (fun a => Coulomb.flatSpinOrbital (fun x s => + fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1))) i z := by + change fderiv ℝ (Coulomb.slaterConfiguration v _) _ (EuclideanSpace.single (i,b) 1) = _ + rw [slaterConfiguration_C1_fderiv v hv] + rfl + +theorem classicalSlaterState_kinetic {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) + (ho : ∀ i j, (∑ s : Fin 2, ∫ x : Position, star (v i x s) * v j x s) = + if i = j then (1:ℂ) else 0) : + Coulomb.kinetic (classicalSlaterState v hv hL2 hpartial) = (1/2:ℝ) * ∑ i, ∑ s, ∑ b : Fin 3, + ∫ x : Position, ‖fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)‖^2 := by + have hV (i : Fin n) (s : Fin 2) : MemLp (fun x => v i x s) 2 volume := hL2 i s + have hD (i : Fin n) (s : Fin 2) (b : Fin 3) : + MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2 volume := hpartial i s b + have hO (i j : Fin n) : (∫ a, star (Coulomb.flatSpinOrbital (v i) a) * Coulomb.flatSpinOrbital (v j) a + ∂Coulomb.spinSpaceMeasure) = if i = j then (1:ℂ) else 0 := by + rw [Coulomb.flatSpinOrbital_inner (v i) (v j) (hV i) (hV j)] + exact ho i j + have hb (b : Fin 3) : (∑ i, ∑ s, ∫ x, ‖(classicalSlaterState v hv hL2 hpartial).gradient s (i,b) x‖^2) = + ∑ i, ∑ s, ∫ x : Position, + ‖fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)‖^2 := by + simp_rw [← Coulomb.cubeGradient_full_norm, classicalSlaterState_cubeGradient] + have hn : (0:ℝ) < n.factorial := Nat.cast_pos.mpr (Nat.factorial_pos n) + simp only [norm_mul, mul_pow, norm_inv, Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Real.sqrt_nonneg _), inv_pow, Real.sq_sqrt hn.le, integral_const_mul] + rw [← Finset.mul_sum, Coulomb.slotDeterminant_total_norm_sq _ _ + (fun i => Coulomb.flatSpinOrbital_memLp (v i) (hV i)) + (fun i => Coulomb.flatSpinOrbital_memLp _ (fun s => hD i s b)) hO, + ← mul_assoc, inv_mul_cancel₀ hn.ne', one_mul] + apply Finset.sum_congr rfl + intro i _ + have h := Coulomb.flatSpinOrbital_inner + (fun x s => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) + (fun x s => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) + (fun s => hD i s b) (fun s => hD i s b) + have hz (z : ℂ) : star z * z = (↑(‖z‖^2) : ℂ) := by + rw [mul_comm, Complex.ofReal_pow] + exact inner_self_eq_norm_sq_to_K (𝕜 := ℂ) z + simp_rw [hz, integral_complex_ofReal] at h + exact Complex.ofReal_injective (by simpa only [Complex.ofReal_sum] using h) + unfold Coulomb.kinetic + congr 1 + simp only [Fintype.sum_prod_type] + calc + _ = ∑ b : Fin 3, ∑ i, ∑ s, ∫ x, ‖(classicalSlaterState v hv hL2 hpartial).gradient s (i,b) x‖^2 := by + rw [Finset.sum_comm] + calc + _ = ∑ i, ∑ b : Fin 3, ∑ s, ∫ x, ‖(classicalSlaterState v hv hL2 hpartial).gradient s (i,b) x‖^2 := by + apply Finset.sum_congr rfl + intro i _ + exact Finset.sum_comm + _ = _ := Finset.sum_comm + _ = _ := by + simp_rw [hb] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + exact Finset.sum_comm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterSynthesis.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterSynthesis.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea68cfa843ba7b8f8188f85dae2162b469c3e7d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalSlaterSynthesis.lean @@ -0,0 +1,141 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlater +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.SlaterOccupation +import OAI.Analysis.CoulombRadii.FieldAnalysis.TsumFixed + +namespace OAI + +/-! Arbitrary complex occupation amplitudes give actual antisymmetric +weak-H1 continuum states. Their continuum mass equals the finite Fock norm, +so this construction treats every state of the fixed-particle mode space. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open SlaterOccupation + +def selectedSpatialSpinOrbitals {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (S : Occupied Q n) : Fin n → Position → Fin 2 → ℂ := + fun i => v (selection S i) + +def slaterSynthesisValue {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (c : EuclideanSpace ℂ (Occupied Q n)) (s : SpinConfiguration n) (x : Configuration n) : ℂ := + ∑ S, c S * Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s x + +theorem slaterSynthesisValue_C1 {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (c : EuclideanSpace ℂ (Occupied Q n)) (s : SpinConfiguration n) : + ContDiff ℝ 1 (slaterSynthesisValue v c s) := + ContDiff.sum (fun S _ => contDiff_const.mul + (slaterConfiguration_C1 (selectedSpatialSpinOrbitals v S) (fun i s => hv (selection S i) s) s)) + +theorem slaterSynthesisValue_memLp {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (c : EuclideanSpace ℂ (Occupied Q n)) (s : SpinConfiguration n) : + MemLp (slaterSynthesisValue v c s) 2 := by + have ht (S : Occupied Q n) : MemLp (fun x => + c S * Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s x) 2 volume := + (slaterConfiguration_memLp (selectedSpatialSpinOrbitals v S) + (fun i s => hL2 (selection S i) s) s).const_mul (c S) + exact memLp_finsetSum Finset.univ (fun S _ => ht S) + +theorem slaterSynthesisValue_fderiv {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (c : EuclideanSpace ℂ (Occupied Q n)) (s : SpinConfiguration n) (x e : Configuration n) : + fderiv ℝ (slaterSynthesisValue v c s) x e = + ∑ S, c S * fderiv ℝ (Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s) x e := by + have hd (S : Occupied Q n) : + DifferentiableAt ℝ (Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s) x := + (slaterConfiguration_C1 _ (fun i s => hv (selection S i) s) s).differentiable (by norm_num) x + unfold slaterSynthesisValue + rw [fderiv_fun_sum (fun S _ => (hd S).const_mul (c S))] + simp only [sum_apply, fderiv_const_mul (hd _), smul_apply, smul_eq_mul] + +theorem slaterSynthesisValue_partial_memLp {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (hpartial : ∀ i s b, MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2) + (c : EuclideanSpace ℂ (Occupied Q n)) (s : SpinConfiguration n) (a : Fin n × Fin 3) : + MemLp (fun x => fderiv ℝ (slaterSynthesisValue v c s) x (EuclideanSpace.single a 1)) 2 := by + have ht (S : Occupied Q n) : MemLp (fun x => c S * + fderiv ℝ (Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s) x + (EuclideanSpace.single a 1)) 2 volume := + (slaterConfiguration_partial_memLp _ (fun i s => hv (selection S i) s) + (fun i s => hL2 (selection S i) s) (fun i s b => hpartial (selection S i) s b) s a.1 a.2).const_mul (c S) + have hs : MemLp (fun x => ∑ S, c S * + fderiv ℝ (Coulomb.slaterConfiguration (selectedSpatialSpinOrbitals v S) s) x + (EuclideanSpace.single a 1)) 2 volume := + memLp_finsetSum Finset.univ (fun S _ => ht S) + simpa only [slaterSynthesisValue_fderiv v hv] using hs + +def classicalSlaterSynthesis {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (hpartial : ∀ i s b, MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2) + (c : EuclideanSpace ℂ (Occupied Q n)) : Coulomb.H1Vector n := + classicalH1State (slaterSynthesisValue v c) (slaterSynthesisValue_C1 v hv c) + (slaterSynthesisValue_memLp v hL2 c) (slaterSynthesisValue_partial_memLp v hv hL2 hpartial c) + +theorem slaterConfiguration_permute {n : ℕ} (v : Fin n → Position → Fin 2 → ℂ) + (p : Equiv.Perm (Fin n)) (s : SpinConfiguration n) (x : Configuration n) : + Coulomb.slaterConfiguration v (s ∘ p) (Coulomb.permute p x) = + (((p.sign : ℤ) : ℂ)) * Coulomb.slaterConfiguration v s x := by + have he : (fun i => ((s ∘ p) i, Coulomb.position (Coulomb.permute p x) i)) = + (fun i => (s i, Coulomb.position x i)) ∘ p := by + funext i + simp only [Function.comp_apply, Coulomb.position_permute] + simp only [Coulomb.slaterConfiguration, Coulomb.slaterWave, he, Coulomb.determinantWave_permute] + ring + +theorem classicalSlaterSynthesis_antisymmetric {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (hpartial : ∀ i s b, MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2) + (c : EuclideanSpace ℂ (Occupied Q n)) : + Coulomb.Antisymmetric (classicalSlaterSynthesis v hv hL2 hpartial c) := by + intro p s + filter_upwards [] with x + change slaterSynthesisValue v c (s ∘ p) (Coulomb.permute p x) = _ * slaterSynthesisValue v c s x + unfold slaterSynthesisValue + simp only [slaterConfiguration_permute, Finset.mul_sum] + apply Finset.sum_congr rfl + intro S _ + ring + +theorem classicalSlaterSynthesis_cubeState {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (hpartial : ∀ i s b, MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2) + (c : EuclideanSpace ℂ (Occupied Q n)) (z : Fin n → Fin 2 × (Fin 3 → ℝ)) : + Coulomb.cubeState (classicalSlaterSynthesis v hv hL2 hpartial c) z = + ∑ S, c S * wave (fun i => Coulomb.flatSpinOrbital (v i)) S z := rfl + +theorem classicalSlaterSynthesis_mass {Q n : ℕ} (v : Fin (Q+1) → Position → Fin 2 → ℂ) + (hv : ∀ i s, ContDiff ℝ 1 (fun x => v i x s)) + (hL2 : ∀ i s, MemLp (fun x => v i x s) 2) + (hpartial : ∀ i s b, MemLp (fun x => fderiv ℝ (fun y => v i y s) x (EuclideanSpace.single b 1)) 2) + (ho : ∀ i j, (∑ s : Fin 2, ∫ x, star (v i x s) * v j x s) = if i=j then (1 : ℂ) else 0) + (c : EuclideanSpace ℂ (Occupied Q n)) : + Coulomb.mass (classicalSlaterSynthesis v hv hL2 hpartial c) = ‖c‖^2 := by + have hV (i : Fin (Q+1)) : MemLp (Coulomb.flatSpinOrbital (v i)) 2 Coulomb.spinSpaceMeasure := + Coulomb.flatSpinOrbital_memLp (v i) (hL2 i) + have hO (i j : Fin (Q+1)) : (∫ a, star (Coulomb.flatSpinOrbital (v i) a) * + Coulomb.flatSpinOrbital (v j) a ∂Coulomb.spinSpaceMeasure) = if i=j then (1 : ℂ) else 0 := by + rw [Coulomb.flatSpinOrbital_inner (v i) (v j) (hL2 i) (hL2 j)] + exact ho i j + rw [← Coulomb.cubeState_full_mass] + simp only [classicalSlaterSynthesis_cubeState] + have h := Coulomb.orbital_sum_sq (fun S : Occupied Q n => wave (fun i => Coulomb.flatSpinOrbital (v i)) S) + (wave_memLp _ hV) (by + intro S T + by_cases h : S=T + · simpa only [h, ite_true] using wave_overlap _ hV hO S T + · simpa only [h, ite_false] using wave_overlap _ hV hO S T) + Finset.univ (fun S => c S) + simpa only [EuclideanSpace.norm_sq_eq] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalTensor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa4d45f83c94b4eb00f62cdea8434283e7f6bcd5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ClassicalTensor.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 +import OAI.Analysis.CoulombRadii.FormDomain.CubeGradient + +namespace OAI + +/-! C1 tensor products and their actual weak-H1 partials. Fubini supplies +L2 membership for decaying orbitals; compact support is unnecessary. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem tensorOrbital_C1 {n : ℕ} {α : Type*} (v : α → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) (p : Fin n → α) (s : SpinConfiguration n) : + ContDiff ℝ 1 (Coulomb.tensorOrbital v p s) := by + unfold Coulomb.tensorOrbital + apply contDiff_prod + intro i _ + exact (hv (p i) (s i)).comp (Coulomb.positionCLM i).contDiff + +theorem tensorOrbital_C1_fderiv {n : ℕ} {α : Type*} (v : α → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) (p : Fin n → α) + (s : SpinConfiguration n) (x : Configuration n) (i : Fin n) (b : Fin 3) : + fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1) = + (fderiv ℝ (fun y => v (p i) y (s i)) (Coulomb.position x i) (EuclideanSpace.single b 1)) * + ∏ j ∈ Finset.univ.erase i, v (p j) (Coulomb.position x j) (s j) := by + have hd (j : Fin n) : DifferentiableAt ℝ (fun y : Configuration n => + v (p j) (Coulomb.position y j) (s j)) x := + by + change DifferentiableAt ℝ ((fun y => v (p j) y (s j)) ∘ Coulomb.positionCLM j) x + exact ((hv (p j) (s j)).differentiable (by norm_num) (Coulomb.positionCLM j x)).comp x + (Coulomb.positionCLM j).differentiableAt + have he (j : Fin n) : fderiv ℝ (fun y : Configuration n => v (p j) (Coulomb.position y j) (s j)) x = + (fderiv ℝ (fun y => v (p j) y (s j)) (Coulomb.position x j)).comp (Coulomb.positionCLM j) := + by + change fderiv ℝ ((fun y => v (p j) y (s j)) ∘ Coulomb.positionCLM j) x = _ + exact (((hv (p j) (s j)).differentiable (by norm_num) (Coulomb.positionCLM j x)).hasFDerivAt.comp x + (Coulomb.positionCLM j).hasFDerivAt).fderiv + unfold Coulomb.tensorOrbital + rw [fderiv_finsetProd (fun j _ => hd j), sum_apply] + simp only [smul_apply, smul_eq_mul, he, ContinuousLinearMap.comp_apply, Coulomb.positionCLM_single] + rw [Finset.sum_eq_single i] + · simp only [ite_true] + ring + · intro j _ hji + simp only [ite_eq_right hji, map_zero, mul_zero] + · simp + +theorem tensorOrbital_partial_memLp {n : ℕ} {α : Type*} (v : α → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x (EuclideanSpace.single b 1)) 2) + (p : Fin n → α) (s : SpinConfiguration n) (i : Fin n) (b : Fin 3) : + MemLp (fun x => fderiv ℝ (Coulomb.tensorOrbital v p s) x (EuclideanSpace.single (i,b) 1)) 2 := by + let f : Fin n → Position → ℂ := fun j y => v (p j) y (s j) + let d : Fin n → Position → ℂ := fun j x => fderiv ℝ (fun y => v (p j) y (s j)) x (EuclideanSpace.single b 1) + have h := (Coulomb.slotTensor_memLp f d (fun j => hL2 (p j) (s j)) + (fun j => hpartial (p j) (s j) b) (Equiv.refl (Fin n)) i).comp_measurePreserving + (Coulomb.configurationMeasurableEquiv_measurePreserving n) + convert h using 1 + funext x + simp only [Function.comp_apply] + rw [tensorOrbital_C1_fderiv v hv, Coulomb.slotTensor_factor] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombJets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombJets.lean new file mode 100644 index 0000000000000000000000000000000000000000..90ae84745caa6ee0a58c0d25b5a40d8382d87180 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombJets.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactCoulombSmooth + +namespace OAI + +/-! Derivatives through order four of a compact source's Coulomb field. +The pole stays in the integrable kernel; all derivatives land on the source. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem compact_derivative_eval {q : Position → ℝ} (hc : HasCompactSupport q) + (k : ℕ) (v : Fin k → Position) : + HasCompactSupport (fun x => iteratedFDeriv ℝ k q x v) := by + exact (hc.iteratedFDeriv (𝕜 := ℝ) k).comp_left + (g := fun T : ContinuousMultilinearMap ℝ (fun _ : Fin k => Position) ℝ => T v) + (by simp) + +theorem compact_coulomb_iteratedFDeriv {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) : + ∀ k : ℕ, k ≤ 4 → ∀ (v : Fin k → Position) (y : Position), + iteratedFDeriv ℝ k (NeutralAtom.potentialOf q) y v = + NeutralAtom.potentialOf (fun x => iteratedFDeriv ℝ k q x v) y := by + intro k + induction k with + | zero => + intro _ v y + simp only [iteratedFDeriv_zero_apply] + | succ k ih => + intro hk v y + have hk4 : k < (4 : WithTop ℕ∞) := by exact_mod_cast (by omega : k < 4) + have hp := (compact_coulomb_C4 hq hc).differentiable_iteratedFDeriv hk4 + have hq' := hq.differentiable_iteratedFDeriv hk4 + have hr : ContDiff ℝ 1 (fun x => iteratedFDeriv ℝ k q x (Fin.tail v)) := + (ContinuousMultilinearMap.apply ℝ (fun _ : Fin k => Position) ℝ (Fin.tail v)).contDiff.comp + (hq.iteratedFDeriv_right (by exact_mod_cast (show 1+k ≤ 4 by omega))) + have hs : HasCompactSupport (fun x => iteratedFDeriv ℝ k q x (Fin.tail v)) := + compact_derivative_eval hc k (Fin.tail v) + rw [(hp y).iteratedFDeriv_succ_apply_left'] + have hid : (fun z => iteratedFDeriv ℝ k (NeutralAtom.potentialOf q) z (Fin.tail v)) = + NeutralAtom.potentialOf (fun x => iteratedFDeriv ℝ k q x (Fin.tail v)) := + funext (ih (by omega) (Fin.tail v)) + rw [hid] + change NeutralAtom.dirPartial _ (v 0) y = _ + rw [compact_coulomb_partial hr hs] + congr 1 + funext x + exact ((hq' x).iteratedFDeriv_succ_apply_left').symm + +theorem compact_coulomb_jet_bound {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) + {k : ℕ} (hk : k ≤ 4) {M : ℝ} + (hM : ∀ x, ‖iteratedFDeriv ℝ k q x‖ ≤ M) (y : Position) : + ‖iteratedFDeriv ℝ k (NeutralAtom.potentialOf q) y‖ ≤ + 2*Real.pi*M+∫ x, ‖iteratedFDeriv ℝ k q x‖ := by + let D := fun x => ‖iteratedFDeriv ℝ k q x‖ + have hd : Continuous D := (hq.continuous_iteratedFDeriv (by exact_mod_cast hk)).norm + have hcD : HasCompactSupport D := (hc.iteratedFDeriv (𝕜 := ℝ) k).norm + have hbound := compact_coulomb_bound hd hcD (fun x => by + simpa only [D,Real.norm_of_nonneg (norm_nonneg _)] using hM x) y + have hpot : 0 ≤ NeutralAtom.potentialOf D y := + integral_nonneg (fun x => mul_nonneg (NeutralAtom.coulombKernel_nonneg _) (norm_nonneg _)) + simp only [Real.norm_of_nonneg hpot] at hbound + have hM0 : 0 ≤ M := (norm_nonneg _).trans (hM 0) + apply ContinuousMultilinearMap.opNorm_le_bound (by positivity) + intro v + rw [compact_coulomb_iteratedFDeriv hq hc k hk] + let P : ℝ := ∏ i, ‖v i‖ + have hP : 0 ≤ P := Finset.prod_nonneg (fun _ _ => norm_nonneg _) + have hi : Integrable (fun x => NeutralAtom.coulombKernel (y-x)*D x) := by + have hh := hcD.convolutionExists_right (ContinuousLinearMap.mul ℝ ℝ) + NeutralAtom.locallyIntegrable_coulombKernel hd y + change Integrable (fun x => NeutralAtom.coulombKernel x*D (y-x)) at hh + simpa only [sub_sub_cancel] using hh.comp_sub_left y + have hb := norm_integral_le_of_norm_le (hi.mul_const P) (Filter.Eventually.of_forall + (fun x => show ‖NeutralAtom.coulombKernel (y-x)*iteratedFDeriv ℝ k q x v‖ ≤ + (NeutralAtom.coulombKernel (y-x)*D x)*P from by + rw [norm_mul,Real.norm_of_nonneg (NeutralAtom.coulombKernel_nonneg _),mul_assoc] + exact mul_le_mul_of_nonneg_left ((iteratedFDeriv ℝ k q x).le_opNorm v) + (NeutralAtom.coulombKernel_nonneg _))) + change ‖∫ x, NeutralAtom.coulombKernel (y-x)*iteratedFDeriv ℝ k q x v‖ ≤ _ + apply hb.trans + rw [integral_mul_const] + apply mul_le_mul_of_nonneg_right _ hP + simpa only [D,norm_norm,NeutralAtom.potentialOf] using hbound + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombSmooth.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bca4f5ae8f7053973f64d3a86e28b243437d9ce --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactCoulombSmooth.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.DensitySynthesis +import Mathlib.Analysis.Calculus.ContDiff.Convolution + +namespace OAI + +/-! Smooth Coulomb fields of compact source pieces. Derivatives are moved +to the density, which avoids differentiating through the Coulomb pole. -/ + +noncomputable section +open MeasureTheory +open scoped Convolution +namespace ContinuumCoulomb + +theorem potentialOf_eq_convolution (q : Position → ℝ) : + NeutralAtom.potentialOf q = + NeutralAtom.coulombKernel ⋆[ContinuousLinearMap.mul ℝ ℝ,volume] q := by + funext y + change (∫ x, NeutralAtom.coulombKernel (y-x)*q x) = + ∫ x, NeutralAtom.coulombKernel x*q (y-x) + rw [← integral_sub_left_eq_self (fun x => NeutralAtom.coulombKernel (y-x)*q x) volume y] + simp only [sub_sub_cancel] + +theorem compact_coulomb_C4 {q : Position → ℝ} (hq : ContDiff ℝ 4 q) + (hc : HasCompactSupport q) : ContDiff ℝ 4 (NeutralAtom.potentialOf q) := by + rw [potentialOf_eq_convolution] + exact hc.contDiff_convolution_right (ContinuousLinearMap.mul ℝ ℝ) + NeutralAtom.locallyIntegrable_coulombKernel hq + +theorem compact_coulomb_partial {q : Position → ℝ} (hq : ContDiff ℝ 1 q) + (hc : HasCompactSupport q) (v y : Position) : + NeutralAtom.dirPartial (NeutralAtom.potentialOf q) v y = + NeutralAtom.potentialOf (NeutralAtom.dirPartial q v) y := by + have hd := hc.hasFDerivAt_convolution_right (ContinuousLinearMap.mul ℝ ℝ) + NeutralAtom.locallyIntegrable_coulombKernel hq y + have hi := (hc.fderiv ℝ).convolutionExists_right + ((ContinuousLinearMap.mul ℝ ℝ).precompR Position) + NeutralAtom.locallyIntegrable_coulombKernel (hq.continuous_fderiv (by norm_num)) y + change fderiv ℝ (NeutralAtom.potentialOf q) y v = _ + rw [potentialOf_eq_convolution,hd.fderiv] + change (∫ x, (ContinuousLinearMap.mul ℝ ℝ).precompR Position + (NeutralAtom.coulombKernel x) (fderiv ℝ q (y-x))) v = _ + rw [ContinuousLinearMap.integral_apply hi v,potentialOf_eq_convolution] + rfl + +theorem compact_coulomb_bound {q : Position → ℝ} (hq : Continuous q) + (hc : HasCompactSupport q) {M : ℝ} (hM : ∀ x, ‖q x‖ ≤ M) (y : Position) : + ‖NeutralAtom.potentialOf q y‖ ≤ 2*Real.pi*M+∫ x, ‖q x‖ := by + have he := Coulomb.coulomb_convolution_bound (hq.integrable_of_hasCompactSupport hc).norm + hq.measurable.norm (fun x => norm_nonneg (q x)) hM (by norm_num : (0:ℝ) < 1) y + have hn := norm_integral_le_integral_norm (μ := volume) + (fun x => NeutralAtom.coulombKernel (y-x)*q x) + simp only [norm_mul,Real.norm_of_nonneg (NeutralAtom.coulombKernel_nonneg _)] at hn + apply hn.trans + simpa only [one_pow,mul_one,inv_one,one_mul,Coulomb.coulombKernel,NeutralAtom.coulombKernel] using he + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactNuclearPairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactNuclearPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0b5b1f929af47122cdab7f8fc8cae90e43b8749 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactNuclearPairing.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSourcePairing +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularity + +namespace OAI + +/-! Identification of the compact-source cubature error with the actual +nuclear matrix element, including the manufactured continuous potential. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem gridNuclearPotential_mul_integrable {q : Position → ℝ} + (hq : Continuous q) (hc : HasCompactSupport q) + {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) + (G : Position → Position) (rho h : ℝ) : + Integrable (fun y => gridNuclearPotential index G rho h y*q y) := by + have hi (a : ι × (Fin 3 → Fin 2)) : Integrable (fun y => + Coulomb.coulombKernel (y-G (gaussLatticePoint h (gridGaussIndex index a)))*q y) := by + convert compact_coulomb_eval_integrable hq hc (G (gaussLatticePoint h (gridGaussIndex index a))) using 1 + funext y + ring + convert (integrable_finsetSum Finset.univ (fun a _ => hi a)).const_mul (-(rho*h^3/8)) using 1 + funext y + simp only [gridNuclearPotential,Finset.sum_mul,mul_assoc] + +theorem manufactured_compact_nuclear_pairing (hpublished : PublishedC4FlowInput) + {rho H S h : ℝ} (hrho : 0 < rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hh : 0 < h) + (V : Position → ℝ) (hV : ContDiff ℝ 6 V) (hcV : HasCompactSupport V) + (hcharge : ∀ x, |manufacturedCharge V x| ≤ rho/2) + (hsupport : tsupport V ⊆ slabDomain H S) + (G : Position → ℝ → Position) (hflow : IsUnitTimeFlow (moserVelocity rho V) G) + (hbij : Function.Bijective (fun x => G x 1)) + (hfix : ∀ x, x ∉ tsupport V → G x 1 = x) (hG : Continuous (fun x => G x 1)) + {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + (hcover : (⋃ i, positionCube (gaussCellCenter h (index i)) h) = slabDomain H S) + {q : Position → ℝ} (hq : ContDiff ℝ 4 q) (hcq : HasCompactSupport q) + (hpos : ∀ y, 0 ≤ q y) : + (∫ y, (gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+V y))*q y) = + -rho*((∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x 1)))- + ∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x 1))) := by + have hsub (i : ι) : positionCube (gaussCellCenter h (index i)) h ⊆ slabDomain H S := by + rw [← hcover] + exact Set.subset_iUnion_of_subset i (fun _ hx => hx) + have hkernel (y : Position) := moser_coulomb_integrableOn hpublished hrho hH hS + V hV hcharge hsupport G hflow hbij hfix y + have hsum (f : Position → ℝ) (hf : IntegrableOn f (slabDomain H S)) : + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h f) = + ∫ x in slabDomain H S, f x := by + simp_rw [positionCellIntegral_eq_setIntegral _ hh.le _ (hf.mono_set (hsub _))] + exact grid_cell_integral_sum_eq index hindex hh hcover f hf + have hpoint (y : Position) : + -rho*(∫ x in slabDomain H S, Coulomb.coulombKernel (y-G x 1)) = slabPotential rho H S y+V y := by + rw [← hsum _ (hkernel y)] + exact moser_grid_potential hpublished hrho hH hS hh V hV hcV hcharge hsupport + G hflow hbij hfix index hindex hcover y + have hiPot : IntegrableOn (fun x => NeutralAtom.potentialOf q (G x 1)) (slabDomain H S) := + ((compact_coulomb_C4 hq hcq).continuous.comp hG).continuousOn.integrableOn_compact + (slabDomain_isCompact hH hS) + have hcontinuous : (∫ y, (slabPotential rho H S y+V y)*q y) = + -rho*(∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x 1))) := by + rw [hsum _ hiPot,compact_source_transport_pairing hq hcq hpos (slabDomain_isCompact hH hS) hG, + ← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with y + rw [← hpoint y] + ring + have hPi : Integrable (fun y => (slabPotential rho H S y+V y)*q y) := + (((slabPotential_continuous hrho.le hH hS).add hV.continuous).mul hq.continuous).integrable_of_hasCompactSupport + hcq.mul_left + simp_rw [sub_mul] + rw [integral_sub (gridNuclearPotential_mul_integrable hq.continuous hcq index (fun x => G x 1) rho h) hPi, + gridNuclearPotential_pairing hq.continuous hcq,hcontinuous] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalDensity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..9edfb14d0095e3e5f322cfda1d3639243a10e58e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalDensity.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCutoff +import Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls + +namespace OAI + +/-! Compact cutoff densities for compressed nuclear matrix elements. The +fourth-order source bounds grow only cubically in the cutoff radius. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def compactOrbitalDensity (freq R : ℝ) (u v : PlanarPosition) (x : Position) : ℝ := + orbitalCutoff R u x*(continuumLocalizedMode freq u x*continuumLocalizedMode freq v x) + +theorem compactOrbitalDensity_nonnegative {freq : ℝ} (hfreq : 0 < freq) + (R : ℝ) (u v : PlanarPosition) (x : Position) : + 0 ≤ compactOrbitalDensity freq R u v x := + mul_nonneg (orbitalCutoff_nonnegative R u x) + (mul_nonneg (continuumLocalizedMode_positive hfreq u x).le + (continuumLocalizedMode_positive hfreq v x).le) + +theorem compactOrbitalDensity_C4 (freq R : ℝ) (u v : PlanarPosition) : + ContDiff ℝ 4 (compactOrbitalDensity freq R u v) := + ((orbitalCutoff_smooth R u).of_le (by simp)).mul + (((continuumLocalizedMode_C7 freq u).of_le (by norm_num)).mul + ((continuumLocalizedMode_C7 freq v).of_le (by norm_num))) + +theorem compactOrbitalDensity_support (freq : ℝ) {R : ℝ} (hR : 0 < R) (u v : PlanarPosition) : + tsupport (compactOrbitalDensity freq R u v) ⊆ Metric.closedBall (planarCenter u) (2*R) := + tsupport_mul_subset_left.trans (orbitalCutoff_support hR u) + +theorem compactOrbitalDensity_hasCompactSupport (freq : ℝ) {R : ℝ} (hR : 0 < R) + (u v : PlanarPosition) : HasCompactSupport (compactOrbitalDensity freq R u v) := + (orbitalCutoff_hasCompactSupport hR u).mul_right + +private theorem ball_supported_jet_integral {F : Type*} [NormedAddCommGroup F] + {q : Position → F} {B R : ℝ} + (hB : 0 ≤ B) (hR : 0 ≤ R) (u : PlanarPosition) + (hs : tsupport q ⊆ Metric.closedBall (planarCenter u) (2*R)) + (hb : ∀ x, ‖q x‖ ≤ B) : (∫ x, ‖q x‖) ≤ 64*B*R^3 := by + let S := Metric.closedBall (planarCenter u) (2*R) + have he : (∫ x in S, ‖q x‖) = ∫ x, ‖q x‖ := + setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by + rw [image_eq_zero_of_notMem_tsupport (fun hsx => hx (hs hsx)),norm_zero]) + have h := norm_setIntegral_le_of_norm_le_const (μ := volume) (f := fun x => ‖q x‖) + (s := S) (isCompact_closedBall _ _).measure_lt_top (fun x _ => by simpa using hb x) + rw [he] at h + have hvol : volume.real S = (2*R)^3*(Real.pi*4/3) := by + simp only [S,Measure.real,EuclideanSpace.volume_closedBall_fin_three, + ENNReal.toReal_mul,ENNReal.toReal_pow,ENNReal.toReal_ofReal (by positivity : 0 ≤ 2*R), + ENNReal.toReal_ofReal (by positivity : 0 ≤ Real.pi*4/3)] + rw [hvol] at h + have hpi : Real.pi*4/3 ≤ 8 := by linarith [Real.pi_lt_four] + calc + _ ≤ ‖∫ x, ‖q x‖‖ := le_abs_self _ + _ ≤ B*((2*R)^3*(Real.pi*4/3)) := h + _ ≤ B*((2*R)^3*8) := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hpi (by positivity)) hB + _ = _ := by ring + +theorem compactOrbitalDensity_jets_bounded {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ R, 1 ≤ R → ∀ u v k, k ≤ 4 → + (∀ x, ‖iteratedFDeriv ℝ k (compactOrbitalDensity freq R u v) x‖ ≤ B) ∧ + (∫ x, ‖iteratedFDeriv ℝ k (compactOrbitalDensity freq R u v) x‖) ≤ 64*B*R^3 := by + obtain ⟨A,hA,ha⟩ := continuumLocalizedMode_jets_bounded hfreq + obtain ⟨C,hC,hc⟩ := orbitalCutoff_jets_bounded + let B := 16*C*(16*A*A)+1 + have hA0 : 0 ≤ A := by linarith + have hC0 : 0 ≤ C := by linarith + have hB : 1 ≤ B := by + dsimp [B] + have hn : 0 ≤ 16*C*(16*A*A) := by positivity + linarith + refine ⟨B,hB,fun R hR u v k hk => ?_⟩ + have hpair (j : ℕ) (hj : j ≤ 4) (x : Position) : + ‖iteratedFDeriv ℝ j (fun y => continuumLocalizedMode freq u y*continuumLocalizedMode freq v y) x‖ ≤ + 16*A*A := + fourJet_mul ((continuumLocalizedMode_C7 freq u).of_le (by norm_num)) + ((continuumLocalizedMode_C7 freq v).of_le (by norm_num)) hA0 hA0 (ha u) (ha v) hj x + have hb (x : Position) : ‖iteratedFDeriv ℝ k (compactOrbitalDensity freq R u v) x‖ ≤ B := by + exact (fourJet_mul ((orbitalCutoff_smooth R u).of_le (by simp)) + (((continuumLocalizedMode_C7 freq u).of_le (by norm_num)).mul + ((continuumLocalizedMode_C7 freq v).of_le (by norm_num))) hC0 (by positivity) + (hc R hR u) hpair hk x).trans (by dsimp [B]; linarith) + refine ⟨hb,?_⟩ + apply ball_supported_jet_integral (by linarith) (by linarith) u _ hb + exact (tsupport_iteratedFDeriv_subset k).trans + (compactOrbitalDensity_support freq (by linarith) u v) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalNuclearError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalNuclearError.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f310bce9d1afbe780f01c2a2647a67a7d7be144 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalNuclearError.lean @@ -0,0 +1,55 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactNuclearPairing + +namespace OAI + +/-! Fourth-order nuclear replacement for the actual cutoff orbital +transition densities, with every analytic source estimate discharged. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem manufactured_compact_orbital_nuclear_error (hpublished : PublishedC4FlowInput) + {freq : ℝ} (hfreq : 0 < freq) : + ∃ B C : ℝ, 1 ≤ B ∧ 1 ≤ C ∧ + ∀ (R : ℝ), 1 ≤ R → ∀ (v w : PlanarPosition), + ∀ (rho H S scale : ℝ), 0 < rho → 0 ≤ H → 1 ≤ S → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ rho/2) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ (G : Position → ℝ → Position), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + Function.Bijective (fun x => G x 1) → + ContDiff ℝ 4 (fun x => G x 1) → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) → + ∀ (D : ℝ), 0 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ D^k) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ 1 → + (⋃ i, positionCube (gaussCellCenter h (index i)) h) = slabDomain H S → + |∫ y, (gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y))* + compactOrbitalDensity freq R v w y| ≤ + rho*(24*((2*Real.pi+1)*(64*B*R^3))*D^4*(216*m*S+13824*R^3)+ + 2048*Real.pi*C*(64*B*R^3))*h^4 := by + obtain ⟨B,C,hB,hC,hq⟩ := manufactured_compact_orbital_quadrature hfreq + refine ⟨B,C,hB,hC,?_⟩ + intro R hR v w rho H S scale hrho hH hS m u hcharge hsupp G hflow hbij hG hfix D hD hGD + ι _ index hindex h hh hh1 hcover + rw [manufactured_compact_nuclear_pairing hpublished hrho hH (by linarith) hh + (manufacturedWellField freq scale S u) ((manufacturedWellField_C7 freq scale S u).of_le (by norm_num)) + (manufacturedWellField_compact freq scale (by linarith) u) hcharge hsupp G hflow hbij hfix hG.continuous + index hindex hcover (compactOrbitalDensity_C4 freq R v w) + (compactOrbitalDensity_hasCompactSupport freq (by linarith) v w) + (compactOrbitalDensity_nonnegative hfreq R v w)] + rw [abs_mul,abs_neg,abs_of_pos hrho] + exact (mul_le_mul_of_nonneg_left + (hq R hR v w scale S hS m u (fun x => G x 1) hG hfix D hD hGD index hindex h hh hh1) + hrho.le).trans_eq (by ring) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..0045c7386a51938f5a082fa7d7e9fcbfdfaaebab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactOrbitalQuadrature.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedCompactQuadrature + +namespace OAI + +/-! The transported fourth-order rule applied to the actual compact +orbital transition density, with all source bounds discharged. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufactured_compact_orbital_quadrature {freq : ℝ} (hfreq : 0 < freq) : + ∃ B C : ℝ, 1 ≤ B ∧ 1 ≤ C ∧ + ∀ (R : ℝ), 1 ≤ R → ∀ (v w : PlanarPosition), + ∀ (scale S : ℝ), 1 ≤ S → ∀ (m : ℕ) (u : Fin m → PlanarPosition), + ∀ (G : Position → Position), ContDiff ℝ 4 G → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x = x) → + ∀ (D : ℝ), 0 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ 1 → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf (compactOrbitalDensity freq R v w) (G x)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf (compactOrbitalDensity freq R v w) (G x)))| ≤ + (24*((2*Real.pi+1)*(64*B*R^3))*D^4*(216*m*S+13824*R^3)+ + 2048*Real.pi*C*(64*B*R^3))*h^4 := by + obtain ⟨B,hB,hb⟩ := compactOrbitalDensity_jets_bounded hfreq + obtain ⟨C,hC,hquad⟩ := manufactured_compact_source_quadrature + refine ⟨B,C,hB,hC,?_⟩ + intro R hR v w scale S hS m u G hG hfix D hD hGD ι _ index hindex h hh hh1 + have hR0 : 0 < R := lt_of_lt_of_le zero_lt_one hR + have hBR : B ≤ 64*B*R^3 := by + have hpow : 1 ≤ R^3 := one_le_pow₀ hR + have hp := mul_le_mul_of_nonneg_left hpow (show 0 ≤ B by linarith) + nlinarith + have he := hquad (compactOrbitalDensity freq R v w) + (compactOrbitalDensity_C4 freq R v w) (compactOrbitalDensity_hasCompactSupport freq hR0 v w) + (64*B*R^3) (by positivity) + (fun k hk x => ((hb R hR v w k hk).1 x).trans hBR) + (fun k hk => (hb R hR v w k hk).2) v (2*R) (by linarith) + (fun x hx => by + simpa only [Metric.mem_closedBall,dist_eq_norm] using + compactOrbitalDensity_support freq hR0 v w (subset_tsupport _ hx)) + freq scale S hS m u G hG hfix D hD hGD index hindex h hh hh1 + convert he using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSobolevCore.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSobolevCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e9297ec018d4ad2d3844b60916ba6fc31bbd57f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSobolevCore.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SmoothCutoffApproximation + +namespace OAI + +/-! Compactly supported C1 approximation on the full declared weak-H1 +configuration domain. Only the explicitly cited smooth-density input is +conditional; the compactification step is proved here. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +private theorem integral_square_error_triangle {n : ℕ} + (f g h : Configuration n → ℂ) (hf : MemLp f 2) (hg : MemLp g 2) (hh : MemLp h 2) : + (∫ x, ‖f x-h x‖^2) ≤ 2*(∫ x, ‖f x-g x‖^2) + 2*(∫ x, ‖g x-h x‖^2) := by + have hi (v w : Configuration n → ℂ) (hv : MemLp v 2) (hw : MemLp w 2) : + Integrable (fun x => ‖v x-w x‖^2) := + (memLp_two_iff_integrable_sq_norm (hv.sub hw).aestronglyMeasurable).mp (hv.sub hw) + calc + _ ≤ ∫ x, 2*‖f x-g x‖^2 + 2*‖g x-h x‖^2 := by + apply integral_mono (hi f h hf hh) ((hi f g hf hg).const_mul 2 |>.add + ((hi g h hg hh).const_mul 2)) + intro x + change ‖f x-h x‖^2 ≤ 2*‖f x-g x‖^2 + 2*‖g x-h x‖^2 + have he : ‖f x-h x‖ ≤ ‖f x-g x‖ + ‖g x-h x‖ := by + calc + _ = ‖(f x-g x)+(g x-h x)‖ := by congr 1; ring + _ ≤ _ := norm_add_le _ _ + have hs := pow_le_pow_left₀ (norm_nonneg _) he 2 + nlinarith [sq_nonneg (‖f x-g x‖ - ‖g x-h x‖)] + _ = _ := by + rw [integral_add ((hi f g hf hg).const_mul 2) ((hi g h hg hh).const_mul 2), + integral_const_mul, integral_const_mul] + +theorem h1GraphError_triangle {n : ℕ} (u v w : Coulomb.H1Vector n) : + h1GraphError u w ≤ 2*h1GraphError u v + 2*h1GraphError v w := by + have hv := Finset.sum_le_sum (fun s (_ : s ∈ Finset.univ) => + integral_square_error_triangle (u.value s) (v.value s) (w.value s) + (u.value_L2 s) (v.value_L2 s) (w.value_L2 s)) + have hg := Finset.sum_le_sum (fun s (_ : s ∈ Finset.univ) => + Finset.sum_le_sum (fun a (_ : a ∈ Finset.univ) => + integral_square_error_triangle (u.gradient s a) (v.gradient s a) (w.gradient s a) + (u.partial_L2 s a) (v.partial_L2 s a) (w.partial_L2 s a))) + have h := add_le_add hv hg + simp only [Finset.sum_add_distrib, ← Finset.mul_sum] at h + unfold h1GraphError + linarith + +/-- The smooth-density theorem plus the proved cutoff step gives a compact +core for the actual full weak-H1 vectors, with no symmetry restriction. -/ +theorem exists_compact_h1_approximation (hpublished : PublishedSobolevSmoothDensity) + {n : ℕ} (u : Coulomb.H1Vector n) {ε : ℝ} (hε : 0 < ε) : + ∃ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) ∧ + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) ∧ + h1GraphError u v < ε := by + obtain ⟨v, hv, hd, hve⟩ := exists_smooth_h1_approximation hpublished u + (by linarith : (0 : ℝ) < ε/4) + obtain ⟨w, hw, hwd, hwe⟩ := exists_compact_approximation_of_smooth v hv hd + (by linarith : (0 : ℝ) < ε/4) + refine ⟨w, hw, hwd, ?_⟩ + have h := h1GraphError_triangle u v w + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..20de31769b7dbc6a7c8bd312e848a38ccce15dc9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceGrid.lean @@ -0,0 +1,117 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSourceTransport +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.InverseFifthCutoffGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombTranslation + +namespace OAI + +/-! The fourth-order cell error for a compact orbital source, split into +cells near that source or the transport support and the remaining far cells. -/ + +noncomputable section +open MeasureTheory +open scoped Classical +namespace ContinuumCoulomb + +def sourceExceptionalCell (E : Set Position) (u : PlanarPosition) (R : ℝ) + (b : Position) (h : ℝ) : Prop := + (∃ x ∈ positionCube b h, x ∈ E) ∨ ‖planarCenter u-b‖ ≤ 4*R + +theorem compact_source_grid_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (q : Position → ℝ), ContDiff ℝ 4 q → HasCompactSupport q → + ∀ (B : ℝ), 0 ≤ B → + (∀ k : ℕ, k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k q x‖ ≤ B) → + (∀ k : ℕ, k ≤ 4 → (∫ x, ‖iteratedFDeriv ℝ k q x‖) ≤ B) → + ∀ (u : PlanarPosition) (R : ℝ), 0 < R → + (∀ x, q x ≠ 0 → ‖x-planarCenter u‖ ≤ R) → + ∀ (G : Position → Position), ContDiff ℝ 4 G → + ∀ (E : Set Position), (∀ x, x ∉ E → G x = x) → + ∀ (D : ℝ), 0 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ R → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)))| ≤ + 24*((2*Real.pi+1)*B)*D^4*h^4* + ((Fintype.card {i // sourceExceptionalCell E u R (gaussCellCenter h (index i)) h}:ℕ):ℝ)*h^3+ + 2048*Real.pi*C*B*h^4/R^2 := by + obtain ⟨C,hC,hfar⟩ := compact_source_unchanged_cell_bound + refine ⟨C,hC,?_⟩ + intro q hq hc B hB hb hi u R hR hsupp G hG E hfix D hD hGD ι _ index hindex h hh hhR + let p : ι → Prop := fun i => sourceExceptionalCell E u R (gaussCellCenter h (index i)) h + let Q : ι → ℝ := fun i => positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)) + let I : ι → ℝ := fun i => positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)) + have hnear : |(∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val)| ≤ + 24*((2*Real.pi+1)*B)*D^4*h^4*(Fintype.card {i // p i}:ℝ)*h^3 := by + calc + _ ≤ ∑ i : {i // p i}, |Q i.val-I i.val| := by + rw [← Finset.sum_sub_distrib] + exact Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : {i // p i}, 24*((2*Real.pi+1)*B)*D^4*h^7 := + Finset.sum_le_sum (fun i _ => compact_source_transported_cell_bound hq hc hB hb hi + G hG hD hGD _ hh.le) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]; ring + have hfi : Function.Injective (fun i : {i // ¬p i} => index i.val) := + fun i j hij => Subtype.ext (hindex hij) + have hdist (i : {i // ¬p i}) : 4*R ≤ ‖planarCenter u-gaussCellCenter h (index i.val)‖ := by + exact (lt_of_not_ge (fun he => i.property (Or.inr he))).le + have hfs (i : {i // ¬p i}) : + |Q i.val-I i.val| ≤ + (32*C*h^7/‖planarCenter u-gaussCellCenter h (index i.val)‖^5)*B := by + let b := gaussCellCenter h (index i.val) + have hd : 0 < ‖planarCenter u-b‖ := lt_of_lt_of_le (by positivity) (hdist i) + have hf := hfar q hq hc G b h (‖planarCenter u-b‖/2) hh.le (by positivity) + (fun x hx => hfix x (fun he => i.property (Or.inl ⟨x,hx,he⟩))) (fun x hx y hy => by + have hs := hsupp x hx + have hn := positionCube_norm_sub_le hh.le hy + have ht := norm_sub_le_norm_sub_add_norm_sub (planarCenter u) x b + have ht' := norm_sub_le_norm_sub_add_norm_sub x y b + rw [norm_sub_rev (planarCenter u) x] at ht + rw [norm_sub_rev x y] at ht' + have := hdist i + change 4*R ≤ ‖planarCenter u-b‖ at this + linarith) + have hm : (∫ x, ‖q x‖) ≤ B := by simpa only [norm_iteratedFDeriv_zero] using hi 0 (by omega) + apply hf.trans + have hfac : 0 ≤ C*h^7/(‖planarCenter u-b‖/2)^5 := by positivity + apply (mul_le_mul_of_nonneg_left hm hfac).trans_eq + change C*h^7/(‖planarCenter u-b‖/2)^5*B = (32*C*h^7/‖planarCenter u-b‖^5)*B + field_simp + ring + have hfarSum : |(∑ i : {i // ¬p i}, Q i.val)-(∑ i : {i // ¬p i}, I i.val)| ≤ + 2048*Real.pi*C*B*h^4/R^2 := by + calc + _ ≤ ∑ i : {i // ¬p i}, |Q i.val-I i.val| := by + rw [← Finset.sum_sub_distrib] + exact Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i : {i // ¬p i}, (32*C*h^7/‖planarCenter u-gaussCellCenter h (index i.val)‖^5)*B := + Finset.sum_le_sum (fun i _ => hfs i) + _ = (32*C*B*h^4)*(∑ i : {i // ¬p i}, h^3/‖planarCenter u-gaussCellCenter h (index i.val)‖^5) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ ≤ (32*C*B*h^4)*(64*Real.pi/R^2) := + mul_le_mul_of_nonneg_left (inverseFifth_cutoff_grid_sum _ hfi hh hR hhR _ hdist) (by positivity) + _ = _ := by ring + have heQ := Fintype.sum_subtype_add_sum_subtype p Q + have heI := Fintype.sum_subtype_add_sum_subtype p I + change |(∑ i, Q i)-(∑ i, I i)| ≤ _ + rw [← heQ,← heI] + have ht := abs_add_le ((∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val)) + ((∑ i : {i // ¬p i}, Q i.val)-(∑ i : {i // ¬p i}, I i.val)) + have he : ((∑ i : {i // p i}, Q i.val)+(∑ i : {i // ¬p i}, Q i.val))- + ((∑ i : {i // p i}, I i.val)+(∑ i : {i // ¬p i}, I i.val)) = + ((∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val))+ + ((∑ i : {i // ¬p i}, Q i.val)-(∑ i : {i // ¬p i}, I i.val)) := by ring + rw [he] + exact ht.trans (add_le_add hnear hfarSum) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourcePairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourcePairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..32b400ff4fbd9fd11f8ed7969d03005772258447 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourcePairing.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombSourceCubature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridPotential + +namespace OAI + +/-! Fubini identities for nonnegative compact source densities and the +actual transported nuclear potential. No separation from a nuclear pole is +required for these identities. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem compact_source_transport_integrable {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) (hpos : ∀ y, 0 ≤ q y) + {S : Set Position} (hS : IsCompact S) {G : Position → Position} (hG : Continuous G) : + Integrable (fun p : Position × Position => q p.2*Coulomb.coulombKernel (p.2-G p.1)) + ((volume.restrict S).prod volume) := by + have hm : Measurable (fun p : Position × Position => q p.2*Coulomb.coulombKernel (p.2-G p.1)) := + (hq.continuous.measurable.comp measurable_snd).mul + (Coulomb.coulombKernel_measurable.comp (measurable_snd.sub (hG.measurable.comp measurable_fst))) + apply (integrable_prod_iff hm.aestronglyMeasurable).mpr + refine ⟨Filter.Eventually.of_forall (fun x => compact_coulomb_eval_integrable hq.continuous hc (G x)),?_⟩ + have hi : IntegrableOn (fun x => NeutralAtom.potentialOf q (G x)) S := + ((compact_coulomb_C4 hq hc).continuous.comp hG).continuousOn.integrableOn_compact hS + have he : (fun x => ∫ y, ‖q y*Coulomb.coulombKernel (y-G x)‖) = + (fun x => NeutralAtom.potentialOf q (G x)) := by + funext x + rw [compact_coulomb_eval_eq] + apply integral_congr_ae + filter_upwards [] with y + exact Real.norm_of_nonneg (mul_nonneg (hpos y) (Coulomb.coulombKernel_nonneg _)) + change Integrable (fun x => ∫ y, ‖q y*Coulomb.coulombKernel (y-G x)‖) (volume.restrict S) + rw [he] + exact hi + +theorem compact_source_transport_pairing {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) (hpos : ∀ y, 0 ≤ q y) + {S : Set Position} (hS : IsCompact S) {G : Position → Position} (hG : Continuous G) : + (∫ x in S, NeutralAtom.potentialOf q (G x)) = + ∫ y, q y*(∫ x in S, Coulomb.coulombKernel (y-G x)) := by + have hi := compact_source_transport_integrable hq hc hpos hS hG + simp_rw [compact_coulomb_eval_eq] + rw [integral_integral_swap hi] + apply integral_congr_ae + filter_upwards [] with y + exact integral_const_mul _ _ + +theorem gridNuclearPotential_pairing {q : Position → ℝ} + (hq : Continuous q) (hc : HasCompactSupport q) + {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) + (G : Position → Position) (rho h : ℝ) : + (∫ y, gridNuclearPotential index G rho h y*q y) = + -rho*∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)) := by + have hi (a : ι × (Fin 3 → Fin 2)) : Integrable (fun y => + Coulomb.coulombKernel (y-G (gaussLatticePoint h (gridGaussIndex index a)))*q y) := by + convert compact_coulomb_eval_integrable hq hc (G (gaussLatticePoint h (gridGaussIndex index a))) using 1 + funext y + ring + calc + _ = -(rho*h^3/8)*∑ a : ι × (Fin 3 → Fin 2), + NeutralAtom.potentialOf q (G (gaussLatticePoint h (gridGaussIndex index a))) := by + simp only [gridNuclearPotential,mul_assoc,Finset.sum_mul] + rw [integral_const_mul,integral_finsetSum Finset.univ (fun a _ => hi a)] + congr 1 + apply Finset.sum_congr rfl + intro a _ + rw [compact_coulomb_eval_eq] + apply integral_congr_ae + filter_upwards [] with y + ring + _ = _ := by + simp only [gaussCell_quadrature_lattice,Fintype.sum_prod_type,gridGaussIndex,← Finset.mul_sum] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceTransport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8e3bced87e54c117f63cdf6862ab5d63540cdca --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CompactSourceTransport.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactCoulombJets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombSourceCubature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedCoulombDerivative + +namespace OAI + +/-! Smooth compact orbital densities give a uniform transported-cell bound. +Cells on which the flow is the identity retain the sharper separated-source +bound, so only the compact exceptional region needs the uniform estimate. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem compact_source_transported_cell_bound {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) + {B : ℝ} (hB : 0 ≤ B) + (hb : ∀ k : ℕ, k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k q x‖ ≤ B) + (hi : ∀ k : ℕ, k ≤ 4 → (∫ x, ‖iteratedFDeriv ℝ k q x‖) ≤ B) + (G : Position → Position) (hG : ContDiff ℝ 4 G) {D : ℝ} (_hD : 0 ≤ D) + (hGD : ∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) + (b : Position) {h : ℝ} (hh : 0 ≤ h) : + |positionCellGauss b h (fun x => NeutralAtom.potentialOf q (G x))- + positionCellIntegral b h (fun x => NeutralAtom.potentialOf q (G x))| ≤ + 24*((2*Real.pi+1)*B)*D^4*h^7 := by + have hqC := compact_coulomb_C4 hq hc + apply positionCellGauss_error _ (hqC.comp hG) b hh (by positivity) + intro x _ y _ z _ + apply fourth_composite_norm_bound (NeutralAtom.potentialOf q) G _ hqC.contDiffAt hG + (C := (2*Real.pi+1)*B) (D := D) ?_ (hGD _) + intro k hk + have ht := compact_coulomb_jet_bound hq hc hk (hb k hk) (G (cubePoint b (h/2) x y z)) + have hL := hi k hk + nlinarith + +private theorem cellGauss_congr_on_cube (b : Position) {h : ℝ} (hh : 0 ≤ h) + (f g : Position → ℝ) (heq : ∀ x ∈ positionCube b h, f x = g x) : + positionCellGauss b h f = positionCellGauss b h g := by + unfold positionCellGauss + congr 1 + apply gaussTensor3_congr_on + intro x hx y hy z hz + exact heq _ (cubePoint_mem_positionCube b hh hx hy hz) + +private theorem cellIntegral_congr_on_cube (b : Position) {h : ℝ} (hh : 0 ≤ h) + (f g : Position → ℝ) (heq : ∀ x ∈ positionCube b h, f x = g x) : + positionCellIntegral b h f = positionCellIntegral b h g := by + unfold positionCellIntegral + congr 1 + apply unitCube_integral_congr + intro x hx y hy z hz + exact heq _ (cubePoint_mem_positionCube b hh hx hy hz) + +theorem compact_source_unchanged_cell_bound : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (q : Position → ℝ), ContDiff ℝ 4 q → HasCompactSupport q → + ∀ (G : Position → Position) (b : Position) (h r : ℝ), 0 ≤ h → 0 < r → + (∀ x ∈ positionCube b h, G x = x) → + (∀ x, q x ≠ 0 → ∀ y ∈ positionCube b h, r ≤ ‖y-x‖) → + |positionCellGauss b h (fun x => NeutralAtom.potentialOf q (G x))- + positionCellIntegral b h (fun x => NeutralAtom.potentialOf q (G x))| ≤ + (C*h^7/r^5)*(∫ x, ‖q x‖) := by + obtain ⟨C,hC,hbound⟩ := compact_coulomb_far_cell_error + refine ⟨C,hC,fun q hq hc G b h r hh hr hfix hsep => ?_⟩ + have heq (x : Position) (hx : x ∈ positionCube b h) : + NeutralAtom.potentialOf q (G x) = NeutralAtom.potentialOf q x := by rw [hfix x hx] + rw [cellGauss_congr_on_cube b hh _ _ heq,cellIntegral_congr_on_cube b hh _ _ heq] + exact hbound q hq hc b h r hh hr hsep + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexFormSplit.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexFormSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..06e63052426972a3ba710816f6279b816a3c2522 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexFormSplit.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitPullback + +namespace OAI + +/-! The physical complex one-electron quadratic form splits exactly into +its real and imaginary parts. Finite real-orbital penalties split as well. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem complex_norm_sq_parts (z : ℂ) : ‖z‖^2 = z.re^2+z.im^2 := by + rw [Complex.sq_norm, Complex.normSq_apply] + ring + +theorem complex_mass_parts {f : Position → ℂ} (hf : MemLp f 2) : + (∫ x, ‖f x‖^2) = (∫ x, (f x).re^2)+(∫ x, (f x).im^2) := by + simp_rw [complex_norm_sq_parts] + exact integral_add hf.re.integrable_sq hf.im.integrable_sq + +theorem complex_real_orbital_parts {f : Position → ℂ} {ψ : Position → ℝ} + (hf : MemLp f 2) (hψ : MemLp ψ 2) : + ‖∫ x, f x*(ψ x : ℂ)‖^2 = + (∫ x, (f x).re*ψ x)^2+(∫ x, (f x).im*ψ x)^2 := by + have hi : Integrable (fun x => f x*(ψ x : ℂ)) := hf.integrable_mul hψ.ofReal + have hr := integral_re hi + have hm := integral_im hi + change (∫ x, (f x*(ψ x : ℂ)).re) = (∫ x, f x*(ψ x : ℂ)).re at hr + change (∫ x, (f x*(ψ x : ℂ)).im) = (∫ x, f x*(ψ x : ℂ)).im at hm + simp only [Complex.mul_re, Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, + mul_zero, sub_zero, zero_add] at hr hm + rw [complex_norm_sq_parts,← hr,← hm] + +theorem realPart_partial {f : Position → ℂ} (hf : ContDiff ℝ 1 f) (x e : Position) : + fderiv ℝ (fun y => (f y).re) x e = (fderiv ℝ f x e).re := by + exact congrArg (fun L : Position →L[ℝ] ℝ => L e) + (Complex.reCLM.hasFDerivAt.comp x (hf.differentiable (by norm_num) x).hasFDerivAt).fderiv + +theorem imagPart_partial {f : Position → ℂ} (hf : ContDiff ℝ 1 f) (x e : Position) : + fderiv ℝ (fun y => (f y).im) x e = (fderiv ℝ f x e).im := by + exact congrArg (fun L : Position →L[ℝ] ℝ => L e) + (Complex.imCLM.hasFDerivAt.comp x (hf.differentiable (by norm_num) x).hasFDerivAt).fderiv + +def positionComplexKinetic (f : Position → ℂ) : ℝ := + (1/2:ℝ)*∑ a : Fin 3, ∫ x, ‖fderiv ℝ f x (EuclideanSpace.single a 1)‖^2 + +def positionComplexForm (V : Position → ℝ) (f : Position → ℂ) : ℝ := + positionComplexKinetic f+∫ x, V x*‖f x‖^2 + +theorem positionComplexForm_parts {f : Position → ℂ} + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) + (V : Position → ℝ) (hV : Continuous V) : + positionComplexForm V f = positionRealForm V (fun x => (f x).re) + + positionRealForm V (fun x => (f x).im) := by + have hr : ContDiff ℝ 1 (fun x => (f x).re) := Complex.reCLM.contDiff.comp hf + have hi : ContDiff ℝ 1 (fun x => (f x).im) := Complex.imCLM.contDiff.comp hf + have hrc : HasCompactSupport (fun x => (f x).re) := hc.comp_left (g := Complex.re) rfl + have hic : HasCompactSupport (fun x => (f x).im) := hc.comp_left (g := Complex.im) rfl + have hkr (a : Fin 3) := compact_directional_square_integrable volume hr hrc (EuclideanSpace.single a 1) + have hki (a : Fin 3) := compact_directional_square_integrable volume hi hic (EuclideanSpace.single a 1) + have hrr : HasCompactSupport (fun x => (f x).re^2) := + hrc.comp_left (g := fun t : ℝ => t^2) (by simp) + have hii : HasCompactSupport (fun x => (f x).im^2) := + hic.comp_left (g := fun t : ℝ => t^2) (by simp) + have hprc : HasCompactSupport (fun x => V x*(f x).re^2) := hrr.mul_left + have hpic : HasCompactSupport (fun x => V x*(f x).im^2) := hii.mul_left + have hpr : Integrable (fun x => V x*(f x).re^2) := + (hV.mul (hr.continuous.pow 2)).integrable_of_hasCompactSupport + hprc + have hpi : Integrable (fun x => V x*(f x).im^2) := + (hV.mul (hi.continuous.pow 2)).integrable_of_hasCompactSupport + hpic + have hk (a : Fin 3) : (∫ x, ‖fderiv ℝ f x (EuclideanSpace.single a 1)‖^2) = + (∫ x, (fderiv ℝ (fun y => (f y).re) x (EuclideanSpace.single a 1))^2)+ + (∫ x, (fderiv ℝ (fun y => (f y).im) x (EuclideanSpace.single a 1))^2) := by + rw [← integral_add (hkr a) (hki a)] + apply integral_congr_ae + filter_upwards [] with x + rw [realPart_partial hf, imagPart_partial hf, complex_norm_sq_parts] + have hp : (∫ x, V x*‖f x‖^2) = (∫ x, V x*(f x).re^2)+(∫ x, V x*(f x).im^2) := by + rw [← integral_add hpr hpi] + apply integral_congr_ae + filter_upwards [] with x + rw [complex_norm_sq_parts,mul_add] + unfold positionComplexForm positionComplexKinetic positionRealForm positionRealKinetic + simp_rw [hk] + rw [Finset.sum_add_distrib,hp] + ring + +/-- Real-valued orbitals give the same finite-rank lower estimate for +arbitrary complex test functions, without a reality restriction on states. -/ +theorem real_form_lower_to_complex {ι : Type*} [Fintype ι] + (V : Position → ℝ) (hV : Continuous V) (ψ : ι → Position → ℝ) + (hψ : ∀ i, MemLp (ψ i) 2) (E κ : ℝ) + (hbound : ∀ g : Position → ℝ, ContDiff ℝ 1 g → HasCompactSupport g → + E*(∫ x, g x^2)-κ*(∑ i, (∫ x, g x*ψ i x)^2) ≤ positionRealForm V g) + (f : Position → ℂ) (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + E*(∫ x, ‖f x‖^2)-κ*(∑ i, ‖∫ x, f x*(ψ i x : ℂ)‖^2) ≤ positionComplexForm V f := by + have hr : ContDiff ℝ 1 (fun x => (f x).re) := Complex.reCLM.contDiff.comp hf + have hi : ContDiff ℝ 1 (fun x => (f x).im) := Complex.imCLM.contDiff.comp hf + have hrc : HasCompactSupport (fun x => (f x).re) := hc.comp_left (g := Complex.re) rfl + have hic : HasCompactSupport (fun x => (f x).im) := hc.comp_left (g := Complex.im) rfl + have hfr := hbound _ hr hrc + have hfi := hbound _ hi hic + have hL2 : MemLp f 2 := hf.continuous.memLp_of_hasCompactSupport hc + rw [complex_mass_parts hL2,positionComplexForm_parts hf hc V hV] + simp_rw [complex_real_orbital_parts hL2 (hψ _)] + rw [Finset.sum_add_distrib] + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexMollification.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexMollification.lean new file mode 100644 index 0000000000000000000000000000000000000000..d59eb26df51324c9560eadd8116aa76d3dd93a68 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ComplexMollification.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealMollification + +namespace OAI + +/-! Componentwise mollification preserves the actual complex weak derivatives. +All estimates here are unconditional. -/ + +noncomputable section +open MeasureTheory Filter ContinuousLinearMap +open scoped Topology Convolution +namespace ContinuumCoulomb + +private theorem re_memLp {n : ℕ} {u : Configuration n → ℂ} (hu : MemLp u 2) : + MemLp (fun x => (u x).re) 2 := Complex.reCLM.comp_memLp' hu + +private theorem im_memLp {n : ℕ} {u : Configuration n → ℂ} (hu : MemLp u 2) : + MemLp (fun x => (u x).im) 2 := Complex.imCLM.comp_memLp' hu + +def complexMollification {n : ℕ} (u : Configuration n → ℂ) (k : ℕ) : + Configuration n → ℂ := fun x => + (realMollification (fun y => (u y).re) k x : ℂ)+ + Complex.I*(realMollification (fun y => (u y).im) k x : ℂ) + +@[simp] theorem complexMollification_re {n : ℕ} (u : Configuration n → ℂ) (k : ℕ) + (x : Configuration n) : + (complexMollification u k x).re = realMollification (fun y => (u y).re) k x := by + simp [complexMollification] + +@[simp] theorem complexMollification_im {n : ℕ} (u : Configuration n → ℂ) (k : ℕ) + (x : Configuration n) : + (complexMollification u k x).im = realMollification (fun y => (u y).im) k x := by + simp [complexMollification] + +theorem complexMollification_smooth {n : ℕ} {u : Configuration n → ℂ} + (hu : MemLp u 2) (k : ℕ) : ContDiff ℝ (⊤ : ℕ∞) (complexMollification u k) := + (Complex.ofRealCLM.contDiff.comp (realMollification_smooth (re_memLp hu) k)).add + (contDiff_const.mul (Complex.ofRealCLM.contDiff.comp (realMollification_smooth (im_memLp hu) k))) + +theorem complexMollification_memLp {n : ℕ} {u : Configuration n → ℂ} + (hu : MemLp u 2) (k : ℕ) : MemLp (complexMollification u k) 2 := by + apply (memLp_two_iff_integrable_sq_norm + (complexMollification_smooth hu k).continuous.aestronglyMeasurable).mpr + simp_rw [Coulomb.complex_norm_sq_components,complexMollification_re,complexMollification_im] + exact ((realMollification_contraction (re_memLp hu) k).1.integrable_sq).add + ((realMollification_contraction (im_memLp hu) k).1.integrable_sq) + +theorem complexMollification_error {n : ℕ} {u : Configuration n → ℂ} + (hu : MemLp u 2) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ k in atTop, (∫ x, ‖u x-complexMollification u k x‖^2) < ε := by + have hr := realMollification_error (re_memLp hu) (half_pos hε) + have hi := realMollification_error (im_memLp hu) (half_pos hε) + filter_upwards [hr,hi] with k hkr hki + have he : (∫ x, ‖u x-complexMollification u k x‖^2) = + (∫ x, (realMollification (fun y => (u y).re) k x-(u x).re)^2)+ + (∫ x, (realMollification (fun y => (u y).im) k x-(u x).im)^2) := by + have hR : Integrable (fun x => + (realMollification (fun y => (u y).re) k x-(u x).re)^2) := by + simpa only [Pi.sub_apply] using + ((realMollification_contraction (re_memLp hu) k).1.sub (re_memLp hu)).integrable_sq + have hI : Integrable (fun x => + (realMollification (fun y => (u y).im) k x-(u x).im)^2) := by + simpa only [Pi.sub_apply] using + ((realMollification_contraction (im_memLp hu) k).1.sub (im_memLp hu)).integrable_sq + rw [← integral_add hR hI] + apply integral_congr_ae + apply Eventually.of_forall + intro x + dsimp only + rw [Coulomb.complex_norm_sq_components] + simp only [Complex.sub_re,Complex.sub_im,complexMollification_re,complexMollification_im] + ring + rw [he] + linarith + +theorem complexMollification_partial {n : ℕ} {u g : Configuration n → ℂ} + (hu : MemLp u 2) (hg : MemLp g 2) (v : Configuration n) + (hw : ∀ (φ : Configuration n → ℝ), ContDiff ℝ (⊤ : ℕ∞) φ → HasCompactSupport φ → + (∫ x, u x*(fderiv ℝ φ x v:ℂ)) = -(∫ x, g x*(φ x:ℂ))) + (k : ℕ) (x : Configuration n) : + fderiv ℝ (complexMollification u k) x v = complexMollification g k x := by + have hd (L : ℂ →L[ℝ] ℝ) : + fderiv ℝ (realMollification (fun y => L (u y)) k) x v = + realMollification (fun y => L (g y)) k x := + Coulomb.weak_convolution_partial _ _ _ v + ((L.comp_memLp' hu).locallyIntegrable (by norm_num)) + (Coulomb.hardyMollifier k).contDiff_normed + (Coulomb.hardyMollifier k).hasCompactSupport_normed + (Coulomb.weak_complex_component u g hu hg v hw L) x + have hc := (complexMollification_smooth hu k).differentiable (by simp) + have hp (L : ℂ →L[ℝ] ℝ) : + fderiv ℝ (fun y => L (complexMollification u k y)) x v = + L (fderiv ℝ (complexMollification u k) x v) := + congrArg (fun A : Configuration n →L[ℝ] ℝ => A v) + (L.hasFDerivAt.comp x (hc x).hasFDerivAt).fderiv + apply Complex.ext + · have h := hp Complex.reCLM + simp only [Complex.reCLM_apply,complexMollification_re] at h + have hderiv := hd Complex.reCLM + simp only [Complex.reCLM_apply] at hderiv + change fderiv ℝ (realMollification (fun y => (u y).re) k) x v = _ at h + rw [hderiv] at h + simpa only [Complex.reCLM_apply,complexMollification_re] using h.symm + · have h := hp Complex.imCLM + simp only [Complex.imCLM_apply,complexMollification_im] at h + have hderiv := hd Complex.imCLM + simp only [Complex.imCLM_apply] at hderiv + change fderiv ℝ (realMollification (fun y => (u y).im) k) x v = _ at h + rw [hderiv] at h + simpa only [Complex.imCLM_apply,complexMollification_im] using h.symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactAdjustment.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactAdjustment.lean new file mode 100644 index 0000000000000000000000000000000000000000..868ba4eb8d0c74598728e59d41c9cfc2087894d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactAdjustment.lean @@ -0,0 +1,191 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactTemplates +import Mathlib.Topology.Order.IntermediateValue + +namespace OAI + +/-! An explicit one-variable continuation for independent contact lengths. +Four sloping links share a transverse height; the other five remain axial. +Thus each nine-link path is adjusted by one scalar intermediate-value solve, +with fixed endpoints and no solve whose dimension grows with the lattice. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +def contactLengthTolerance : ℝ := 1 / 100000000 + +def contactHeightLow (c : ℝ) : ℝ := Real.sqrt (1 - (c + 1 / 1000) ^ 2) +def contactHeightHigh (c : ℝ) : ℝ := Real.sqrt (1 - (c - 1 / 1000) ^ 2) + +def adjustedContactForward (length h : ℝ) : ℝ := Real.sqrt (length ^ 2 - h ^ 2) + +def adjustedContactStepX (lengths : ℕ → ℝ) (h : ℝ) (k : ℕ) : ℝ := + if k = 2 ∨ k = 3 ∨ k = 5 ∨ k = 6 then adjustedContactForward (lengths k) h + else lengths k + +def adjustedContactStepY (h : ℝ) (k : ℕ) : ℝ := + if k = 2 ∨ k = 3 then h else if k = 5 ∨ k = 6 then -h else 0 + +def adjustedContactVertex (lengths : ℕ → ℝ) (h : ℝ) (k : ℕ) : ContactPoint := + contactPoint (∑ j ∈ Finset.range k, adjustedContactStepX lengths h j) + (∑ j ∈ Finset.range k, adjustedContactStepY h j) + +def adjustedContactSpan (lengths : ℕ → ℝ) (h : ℝ) : ℝ := + ∑ j ∈ Finset.range 9, adjustedContactStepX lengths h j + +/-- A quantitative square-root estimate, with fixed rational margins. -/ +theorem adjustedContactForward_bound {length c h : ℝ} + (hl : 1 - contactLengthTolerance ≤ length) (hl' : length ≤ 1 + contactLengthTolerance) + (hc : 7 / 10 ≤ c) (hc' : c ≤ 9 / 10) (hh : h ^ 2 = 1 - c ^ 2) : + c - 1 / 10000 ≤ adjustedContactForward length h ∧ + adjustedContactForward length h ≤ c + 1 / 10000 := by + have hlnonneg : 0 ≤ length := by unfold contactLengthTolerance at hl; linarith + have hlo : (1 - contactLengthTolerance) ^ 2 ≤ length ^ 2 := by + have := mul_nonneg (sub_nonneg.mpr hl) + (show 0 ≤ length + (1 - contactLengthTolerance) by + unfold contactLengthTolerance; linarith) + nlinarith + have hhi : length ^ 2 ≤ (1 + contactLengthTolerance) ^ 2 := by + have := mul_nonneg (sub_nonneg.mpr hl') + (show 0 ≤ (1 + contactLengthTolerance) + length by + unfold contactLengthTolerance; linarith) + nlinarith + have hc2 : (7 / 10 : ℝ) ^ 2 ≤ c ^ 2 := by nlinarith + have hrad : 0 ≤ length ^ 2 - h ^ 2 := by + unfold contactLengthTolerance at hlo + nlinarith + have hs : adjustedContactForward length h ^ 2 = length ^ 2 - h ^ 2 := Real.sq_sqrt hrad + have hsnonneg : 0 ≤ adjustedContactForward length h := Real.sqrt_nonneg _ + unfold contactLengthTolerance at hlo hhi + constructor <;> nlinarith + +theorem contactHeightLow_sq {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) : + contactHeightLow c ^ 2 = 1 - (c + 1 / 1000) ^ 2 := by + apply Real.sq_sqrt + nlinarith + +theorem contactHeightHigh_sq {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) : + contactHeightHigh c ^ 2 = 1 - (c - 1 / 1000) ^ 2 := by + apply Real.sq_sqrt + nlinarith + +theorem contactHeight_order {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) : + contactHeightLow c ≤ contactHeightHigh c := by + have hlow := contactHeightLow_sq hc hc' + have hhigh := contactHeightHigh_sq hc hc' + have hl : 0 ≤ contactHeightLow c := Real.sqrt_nonneg _ + have hh : 0 ≤ contactHeightHigh c := Real.sqrt_nonneg _ + nlinarith + +theorem adjustedContactSpan_continuous (lengths : ℕ → ℝ) : + Continuous (adjustedContactSpan lengths) := by + unfold adjustedContactSpan adjustedContactStepX adjustedContactForward + apply continuous_finsetSum + intro k _ + split_ifs <;> fun_prop + +/-- The low-height endpoint overshoots the desired unperturbed span. -/ +theorem adjustedContactSpan_low {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) : + 5 + 4 * c + contactLengthTolerance ≤ adjustedContactSpan lengths (contactHeightLow c) := by + have hf (k : ℕ) (hk : k < 9) := adjustedContactForward_bound (hl k hk) (hl' k hk) + (show 7 / 10 ≤ c + 1 / 1000 by linarith) + (show c + 1 / 1000 ≤ 9 / 10 by linarith) (contactHeightLow_sq hc hc') + have h2 := (hf 2 (by norm_num)).1 + have h3 := (hf 3 (by norm_num)).1 + have h5 := (hf 5 (by norm_num)).1 + have h6 := (hf 6 (by norm_num)).1 + have h0 := hl 0 (by norm_num) + have h1 := hl 1 (by norm_num) + have h4 := hl 4 (by norm_num) + have h7 := hl 7 (by norm_num) + have h8 := hl 8 (by norm_num) + norm_num [adjustedContactSpan, Finset.sum_range_succ, adjustedContactStepX] + unfold contactLengthTolerance at * + linarith + +/-- The high-height endpoint undershoots the desired unperturbed span. -/ +theorem adjustedContactSpan_high {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) : + adjustedContactSpan lengths (contactHeightHigh c) ≤ 5 + 4 * c - contactLengthTolerance := by + have hf (k : ℕ) (hk : k < 9) := adjustedContactForward_bound (hl k hk) (hl' k hk) + (show 7 / 10 ≤ c - 1 / 1000 by linarith) + (show c - 1 / 1000 ≤ 9 / 10 by linarith) (contactHeightHigh_sq hc hc') + have h2 := (hf 2 (by norm_num)).2 + have h3 := (hf 3 (by norm_num)).2 + have h5 := (hf 5 (by norm_num)).2 + have h6 := (hf 6 (by norm_num)).2 + have h0 := hl' 0 (by norm_num) + have h1 := hl' 1 (by norm_num) + have h4 := hl' 4 (by norm_num) + have h7 := hl' 7 (by norm_num) + have h8 := hl' 8 (by norm_num) + norm_num [adjustedContactSpan, Finset.sum_range_succ, adjustedContactStepX] + unfold contactLengthTolerance at * + linarith + +/-- All nine link lengths can be prescribed independently while both +endpoints remain fixed at any allowed span. -/ +theorem adjustedContactSpan_exists {c span : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) + (hspan : 5 + 4 * c - contactLengthTolerance ≤ span) + (hspan' : span ≤ 5 + 4 * c + contactLengthTolerance) : + ∃ h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c), adjustedContactSpan lengths h = span := by + have hiv := intermediate_value_Icc' (contactHeight_order hc hc') + (adjustedContactSpan_continuous lengths).continuousOn + exact hiv ⟨(adjustedContactSpan_high hc hc' lengths hl hl').trans hspan, + hspan'.trans (adjustedContactSpan_low hc hc' lengths hl hl')⟩ + +theorem adjustedContactVertex_end (lengths : ℕ → ℝ) (h : ℝ) : + adjustedContactVertex lengths h 9 = contactPoint (adjustedContactSpan lengths h) 0 := by + ext i + fin_cases i + · rfl + · norm_num [adjustedContactVertex, contactPoint, Finset.sum_range_succ, adjustedContactStepY] + +/-- The continued path has the prescribed actual Euclidean link lengths. -/ +theorem adjustedContact_link_length {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) {k : ℕ} (hk : k < 9) : + dist (adjustedContactVertex lengths h (k + 1)) (adjustedContactVertex lengths h k) = lengths k := by + have hlength : 0 ≤ lengths k := by + have := hl k hk + unfold contactLengthTolerance at this + linarith + have hlow : 0 ≤ contactHeightLow c := Real.sqrt_nonneg _ + have hhigh := contactHeightHigh_sq hc hc' + have hh0 : 0 ≤ h := hlow.trans hh.1 + have hh2 : h ^ 2 ≤ contactHeightHigh c ^ 2 := by nlinarith [hh.2] + have hmin := hl k hk + have hmin2 : (1 - contactLengthTolerance) ^ 2 ≤ lengths k ^ 2 := by + have := mul_nonneg (sub_nonneg.mpr hmin) + (show 0 ≤ lengths k + (1 - contactLengthTolerance) by + unfold contactLengthTolerance; linarith) + nlinarith + have hc2 : (7 / 10 : ℝ) ^ 2 ≤ (c - 1 / 1000) ^ 2 := by nlinarith + have hrad : 0 ≤ lengths k ^ 2 - h ^ 2 := by + unfold contactLengthTolerance at hmin2 + nlinarith + have hroot : adjustedContactForward (lengths k) h ^ 2 = lengths k ^ 2 - h ^ 2 := Real.sq_sqrt hrad + have hsq : dist (adjustedContactVertex lengths h (k + 1)) (adjustedContactVertex lengths h k) ^ 2 = + lengths k ^ 2 := by + unfold adjustedContactVertex + rw [contactPoint_dist_sq] + simp only [Finset.sum_range_succ, add_sub_cancel_left] + unfold adjustedContactStepX adjustedContactStepY + split_ifs <;> (try omega) <;> nlinarith + nlinarith [show 0 ≤ dist (adjustedContactVertex lengths h (k + 1)) + (adjustedContactVertex lengths h k) from dist_nonneg] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactBaseSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactBaseSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b42d210a037b8ad31c78164875e90f4c7f6f17c8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactBaseSeparation.lean @@ -0,0 +1,203 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGadgets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactPathBounds +import Mathlib.Data.Nat.Dist + +namespace OAI + +/-! The exact nineteen-link base gadget and all of its nonlink separations. -/ + +noncomputable section +namespace ContinuumCoulomb + +def contactBaseGadgetPosition (negative : Bool) : ContactGadgetSite → ContactPoint := + Sum.elim (fun k => contactPathVertex (contactGadgetSlope negative) k.val) + (Sum.elim (fun k => contactPoint (contactGadgetRightOrigin negative 1) 0 + + contactPathVertex (contactGadgetSlope negative) (k.val + 1)) + (fun _ => if negative then contactPoint (17 / 2) 1 else contactPoint 9 0)) + +def contactGadgetLinked (negative : Bool) : ContactGadgetSite → ContactGadgetSite → Prop + | Sum.inl i, Sum.inl j => Nat.dist i.val j.val = 1 + | Sum.inl i, Sum.inr (Sum.inl j) => negative = true ∧ i = 9 ∧ j = 0 + | Sum.inr (Sum.inl j), Sum.inl i => negative = true ∧ i = 9 ∧ j = 0 + | Sum.inl i, Sum.inr (Sum.inr _) => i = 9 + | Sum.inr (Sum.inr _), Sum.inl i => i = 9 + | Sum.inr (Sum.inl i), Sum.inr (Sum.inl j) => Nat.dist i.val j.val = 1 + | Sum.inr (Sum.inl i), Sum.inr (Sum.inr _) => negative = false ∧ i = 0 + | Sum.inr (Sum.inr _), Sum.inr (Sum.inl i) => negative = false ∧ i = 0 + | Sum.inr (Sum.inr _), Sum.inr (Sum.inr _) => False + +theorem contactPath_second_axial_lower {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + {k : ℕ} (hk : 2 ≤ k) : 2 ≤ contactPathVertex c k 0 := by + have h := contactPath_horizontal_lower (by linarith : c ≤ 1) hk + have h2 : contactPathVertex c 2 0 = 2 := by + norm_num [contactPathVertex, contactPoint, Finset.sum_range_succ, contactStepX] + rw [h2] at h + have hn : 0 ≤ c * (k - 2 : ℕ) := mul_nonneg (by linarith) (Nat.cast_nonneg _) + linarith + +theorem contact_axial_separation (p q : ContactPoint) {margin : ℝ} + (h : margin ≤ p 0 - q 0) : margin ≤ dist p q := + h.trans ((le_abs_self _).trans (contactPoint_coordinate_le_dist p q 0)) + +theorem contactBase_left_left_separation (negative : Bool) (i j : Fin 10) + (hne : i ≠ j) (hlink : Nat.dist i.val j.val ≠ 1) : + 7 / 5 ≤ dist (contactPathVertex (contactGadgetSlope negative) i.val) + (contactPathVertex (contactGadgetSlope negative) j.val) := by + have hs := contactGadgetSlope_bounds negative + have hv : i.val ≠ j.val := fun h => hne (Fin.ext h) + rcases lt_or_gt_of_ne hv with h | h + · rw [Nat.dist_eq_sub_of_le (Nat.le_of_lt h)] at hlink + rw [dist_comm] + exact (by norm_num : (7 / 5 : ℝ) ≤ 3 / 2).trans + (contactPath_nonlink_separation hs.1 (by linarith [hs.2]) (by omega)) + · rw [Nat.dist_comm, Nat.dist_eq_sub_of_le (Nat.le_of_lt h)] at hlink + exact (by norm_num : (7 / 5 : ℝ) ≤ 3 / 2).trans + (contactPath_nonlink_separation hs.1 (by linarith [hs.2]) (by omega)) + +theorem contactBase_left_right_separation (negative : Bool) (i : Fin 10) (j : Fin 9) + (hlink : ¬(negative = true ∧ i = 9 ∧ j = 0)) : + 7 / 5 ≤ dist (contactBaseGadgetPosition negative (Sum.inl i)) + (contactBaseGadgetPosition negative (Sum.inr (Sum.inl j))) := by + have hs := contactGadgetSlope_bounds negative + have hr := (leftContactStripSite (contactGadgetSlope negative) hs.1 hs.2 + (j.val + 1) (by omega) (by have := j.isLt; omega)).axial_lower + change 1 ≤ contactPathVertex (contactGadgetSlope negative) (j.val + 1) 0 at hr + have hl := (contactPath_axial_bounds hs.1 hs.2 (show i.val ≤ 9 by have := i.isLt; omega)).2 + rw [dist_comm] + apply contact_axial_separation + change 7 / 5 ≤ contactGadgetRightOrigin negative 1 + + contactPathVertex (contactGadgetSlope negative) (j.val + 1) 0 - + contactPathVertex (contactGadgetSlope negative) i.val 0 + cases negative + · norm_num [contactGadgetRightOrigin, contactGadgetSlope] at * + linarith + · by_cases hi : i = 9 + · have hj : j ≠ 0 := fun hj => hlink ⟨rfl, hi, hj⟩ + have hv : j.val ≠ 0 := fun h => hj (Fin.ext h) + have hsecond := contactPath_second_axial_lower hs.1 hs.2 (show 2 ≤ j.val + 1 by omega) + subst i + change 7 / 5 ≤ 17 / 2 + contactPathVertex (7 / 8) (j.val + 1) 0 - contactPathVertex (7 / 8) 9 0 + rw [contactPathVertex_end, contactPoint_zero] + norm_num [contactGadgetSlope] at hsecond ⊢ + linarith + · have hi8 : i.val ≤ 8 := by + have hv : i.val ≠ 9 := fun h => hi (Fin.ext h) + have := i.isLt + omega + by_cases hi0 : i.val = 0 + · have hx : contactPathVertex (7 / 8) i.val 0 = 0 := by rw [hi0]; simp [contactPathVertex] + norm_num [contactGadgetRightOrigin, contactGadgetSlope] at hr ⊢ + rw [hx] + linarith + · have hlast := (contactPath_internal_axial_bounds hs.1 hs.2 (show 1 ≤ i.val by omega) hi8).2 + norm_num [contactGadgetRightOrigin, contactGadgetSlope] at hr hlast ⊢ + linarith + +theorem contactBase_side_left_separation (negative : Bool) (i : Fin 10) (hi : i ≠ 9) : + 7 / 5 ≤ dist (contactBaseGadgetPosition negative contactGadgetSide) + (contactBaseGadgetPosition negative (Sum.inl i)) := by + have hs := contactGadgetSlope_bounds negative + have hi8 : i.val ≤ 8 := by + have hv : i.val ≠ 9 := fun h => hi (Fin.ext h) + have := i.isLt + omega + cases negative + · apply contact_axial_separation + change 7 / 5 ≤ 9 - contactPathVertex (3 / 4) i.val 0 + by_cases hi0 : i.val = 0 + · rw [hi0] + norm_num [contactPathVertex] + · have hlast := (contactPath_internal_axial_bounds hs.1 hs.2 (show 1 ≤ i.val by omega) hi8).2 + norm_num [contactGadgetSlope] at hlast + linarith + · by_cases hi' : i.val = 8 + · have hx : contactPathVertex (7 / 8) i.val = contactPoint (15 / 2) 0 := by + rw [hi'] + ext k + fin_cases k <;> norm_num [contactPathVertex, contactPoint, Finset.sum_range_succ, + contactStepX, contactStepY] + change 7 / 5 ≤ dist (contactPoint (17 / 2) 1) (contactPathVertex (7 / 8) i.val) + rw [hx] + have hd := contactPoint_dist_sq (17 / 2) 1 (15 / 2) 0 + norm_num at hd + nlinarith [show 0 ≤ dist (contactPoint (17 / 2) 1) (contactPoint (15 / 2) 0) from dist_nonneg] + · have hproj := contactPath_horizontal_lower (c := (7 / 8 : ℝ)) (by norm_num) + (show i.val ≤ 9 by omega) + rw [contactPathVertex_end, contactPoint_zero] at hproj + have hcount : (2 : ℝ) ≤ (9 - i.val : ℕ) := by exact_mod_cast (show 2 ≤ 9 - i.val by omega) + apply contact_axial_separation + change 7 / 5 ≤ 17 / 2 - contactPathVertex (7 / 8) i.val 0 + norm_num at hproj + nlinarith + +theorem contactBase_side_right_separation (negative : Bool) (j : Fin 9) + (hlink : ¬(negative = false ∧ j = 0)) : + 7 / 5 ≤ dist (contactBaseGadgetPosition negative contactGadgetSide) + (contactBaseGadgetPosition negative (Sum.inr (Sum.inl j))) := by + have hs := contactGadgetSlope_bounds negative + cases negative + · have hj : j ≠ 0 := fun h => hlink ⟨rfl, h⟩ + have hv : j.val ≠ 0 := fun h => hj (Fin.ext h) + have hsecond := contactPath_second_axial_lower hs.1 hs.2 (show 2 ≤ j.val + 1 by omega) + rw [dist_comm] + apply contact_axial_separation + change 7 / 5 ≤ (contactGadgetRightOrigin false 1 + contactPathVertex (3 / 4) (j.val + 1) 0) - 9 + norm_num [contactGadgetRightOrigin, contactGadgetSlope] at hsecond ⊢ + linarith + · by_cases hj : j = 0 + · subst j + have hx : contactPoint (17 / 2) 0 + contactPathVertex (7 / 8) 1 = contactPoint (19 / 2) 0 := by + ext k + fin_cases k <;> norm_num [contactPathVertex, contactPoint, Finset.sum_range_succ, + contactStepX, contactStepY, PiLp.add_apply] + change 7 / 5 ≤ dist (contactPoint (17 / 2) 1) + (contactPoint (17 / 2) 0 + contactPathVertex (7 / 8) 1) + rw [hx] + have hd := contactPoint_dist_sq (17 / 2) 1 (19 / 2) 0 + norm_num at hd + nlinarith [show 0 ≤ dist (contactPoint (17 / 2) 1) (contactPoint (19 / 2) 0) from dist_nonneg] + · have hv : j.val ≠ 0 := fun h => hj (Fin.ext h) + have hsecond := contactPath_second_axial_lower hs.1 hs.2 (show 2 ≤ j.val + 1 by omega) + rw [dist_comm] + apply contact_axial_separation + change 7 / 5 ≤ (contactGadgetRightOrigin true 1 + contactPathVertex (7 / 8) (j.val + 1) 0) - 17 / 2 + norm_num [contactGadgetRightOrigin, contactGadgetSlope] at hsecond ⊢ + linarith + +/-- Every distinct nonlinked pair in either actual base gadget is at +least1.4 apart, including the negative-sign side site. -/ +theorem contactBaseGadget_nonlink_separation (negative : Bool) (x y : ContactGadgetSite) + (hne : x ≠ y) (hlink : ¬ contactGadgetLinked negative x y) : + 7 / 5 ≤ dist (contactBaseGadgetPosition negative x) (contactBaseGadgetPosition negative y) := by + rcases x with i | (i | ⟨⟩) <;> rcases y with j | (j | ⟨⟩) + · exact contactBase_left_left_separation negative i j (fun h => hne (congrArg Sum.inl h)) hlink + · exact contactBase_left_right_separation negative i j hlink + · rw [dist_comm] + exact contactBase_side_left_separation negative i hlink + · rw [dist_comm] + exact contactBase_left_right_separation negative j i hlink + · change 7 / 5 ≤ dist (contactPoint (contactGadgetRightOrigin negative 1) 0 + + contactPathVertex (contactGadgetSlope negative) (i.val + 1)) + (contactPoint (contactGadgetRightOrigin negative 1) 0 + + contactPathVertex (contactGadgetSlope negative) (j.val + 1)) + rw [dist_add_left] + have hi10 : i.val + 1 < 10 := by have := i.isLt; omega + have hj10 : j.val + 1 < 10 := by have := j.isLt; omega + apply contactBase_left_left_separation negative ⟨i.val + 1, hi10⟩ ⟨j.val + 1, hj10⟩ + · intro h + have hv := congrArg Fin.val h + have hij : i = j := Fin.ext (by simpa using hv) + exact hne (congrArg (fun k : Fin 9 => (Sum.inr (Sum.inl k) : ContactGadgetSite)) hij) + · change Nat.dist (i.val + 1) (j.val + 1) ≠ 1 + simpa only [Nat.dist_add_add_right, contactGadgetLinked] using hlink + · rw [dist_comm] + exact contactBase_side_right_separation negative i hlink + · exact contactBase_side_left_separation negative j hlink + · exact contactBase_side_right_separation negative j hlink + · exact False.elim (hne rfl) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibratedGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibratedGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..02705de9b222712e7ba83224d48e26e14411ef18 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibratedGeometry.lean @@ -0,0 +1,129 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGlobal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationGraphBudget + +namespace OAI + +/-! Scaled rational contact coordinates retain the actual Coulomb +calibration, with the coordinate and scalar-evaluation errors added +explicitly. The gap follows from the proved separated-density estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactCalibratedGeometry +open ContactMediator MediatorIteration +open scoped BigOperators + +def position (d : SquareLatticeHeisenberg) (P : ℕ) (q : ℚ) + (ℓ : GlobalEdge d → ℚ) (x : GlobalSite d) : ℚ × ℚ := + (q * (ContactRationalGlobal.position d P ℓ x).1, + q * (ContactRationalGlobal.position d P ℓ x).2) + +def point (d : SquareLatticeHeisenberg) (P : ℕ) (q : ℚ) + (ℓ : GlobalEdge d → ℚ) (x : GlobalSite d) : ContactPoint := + (q : ℝ) • ContactRationalGlobal.point d P ℓ x + +theorem position_cast (d : SquareLatticeHeisenberg) (P : ℕ) (q : ℚ) + (ℓ : GlobalEdge d → ℚ) (x : GlobalSite d) : + contactPoint (position d P q ℓ x).1 (position d P q ℓ x).2 = point d P q ℓ x := by + unfold position point + rw [← ContactRationalGlobal.position_cast] + ext i + fin_cases i <;> simp [contactPoint, Rat.cast_mul] + +theorem distance (d : SquareLatticeHeisenberg) (P : ℕ) {q : ℚ} (hq : 0 < q) + (ℓ : GlobalEdge d → ℚ) (x y : GlobalSite d) : + dist (point d P q ℓ x) (point d P q ℓ y) = + (q : ℝ) * dist (ContactRationalGlobal.point d P ℓ x) + (ContactRationalGlobal.point d P ℓ y) := by + have hqr : (0 : ℝ) < q := by exact_mod_cast hq + simp only [point, dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs, abs_of_pos hqr] + +theorem edge_error (d : SquareLatticeHeisenberg) (W G P : ℕ) {q : ℚ} (hq : 0 < q) + (ℓ : GlobalEdge d → ℚ) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (a : GlobalEdge d) : + |dist (point d P q ℓ ((finalGraph d.bonds W G).left a)) + (point d P q ℓ ((finalGraph d.bonds W G).right a)) - (q : ℝ) * ℓ a| ≤ + (q : ℝ) * (72 * ((P : ℝ) + 1)⁻¹) := by + rw [distance d P hq, ← mul_sub, abs_mul, abs_of_pos (show (0 : ℝ) < q by exact_mod_cast hq)] + exact mul_le_mul_of_nonneg_left (ContactRationalGlobal.edge_error d W G P ℓ hℓ a) + (by exact_mod_cast hq.le) + +theorem separation (d : SquareLatticeHeisenberg) (W G P : ℕ) {q : ℚ} (hq : 0 < q) + (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (x y : GlobalSite d) (hne : x ≠ y) : + (9 / 10 : ℝ) * q ≤ dist (point d P q ℓ x) (point d P q ℓ y) := by + rw [distance d P hq] + have h := mul_le_mul_of_nonneg_left + (ContactRationalGlobal.separation d W G P ℓ hP hℓ x y hne) + (show (0 : ℝ) ≤ q by exact_mod_cast hq.le) + simpa only [mul_comm] using h + +theorem nonedge_separation (d : SquareLatticeHeisenberg) (W G P : ℕ) {q : ℚ} + (hq : 0 < q) (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (x y : GlobalSite d) (hne : x ≠ y) (hn : Nonedge d W G x y) : + (6 / 5 : ℝ) * q < dist (point d P q ℓ x) (point d P q ℓ y) := by + rw [distance d P hq] + have h := mul_lt_mul_of_pos_left + (ContactRationalGlobal.nonedge_separation d W G P ℓ hP hℓ x y hne hn) + (show (0 : ℝ) < q by exact_mod_cast hq) + simpa only [mul_comm] using h + +theorem coordinate_bound (d : SquareLatticeHeisenberg) (P : ℕ) {q : ℚ} (hq : 0 < q) + (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + {M : ℝ} (hcoord : ∀ j k, |(contactGridAxis (d.coordinate j) k : ℝ)| ≤ M) + (x : GlobalSite d) (i : Fin 2) : |point d P q ℓ x i| ≤ (q : ℝ) * (17 * M + 17) := by + change |(q : ℝ) * ContactRationalGlobal.point d P ℓ x i| ≤ _ + rw [abs_mul, abs_of_pos (show (0 : ℝ) < q by exact_mod_cast hq)] + exact mul_le_mul_of_nonneg_left + (ContactRationalGlobal.coordinate_bound d P ℓ hP hℓ hcoord x i) + (by exact_mod_cast hq.le) + +theorem calibrated_edge_residual (d : SquareLatticeHeisenberg) (W G P : ℕ) + {q : ℚ} (hq : 0 < q) (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + {freq D scale τ ε : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + (hleak : 2 * localLeakageBound freq D ≤ localDualMass freq / 2) + (hDq : D ≤ (9 / 10 : ℝ) * q) (hscale : 0 ≤ scale) (hτ : 0 ≤ τ) + (K : GlobalEdge d → ℝ) (hK : ∀ a, 0 ≤ K a) + (hres : ∀ a, |scale * planarHopping ((q : ℝ) * ℓ a) - + coulombHoppingTarget freq τ (K a) ((q : ℝ) * ℓ a)| ≤ ε) + (a : GlobalEdge d) + (hne : (finalGraph d.bonds W G).left a ≠ (finalGraph d.bonds W G).right a) : + let r := dist (point d P q ℓ ((finalGraph d.bonds W G).left a)) + (point d P q ℓ ((finalGraph d.bonds W G).right a)) + |scale * planarHopping r - coulombHoppingTarget freq τ (K a) r| ≤ + ε + (scale * (planarHoppingLipschitzConstant : ℝ) + + coulombTargetLipschitzConstant freq τ (K a)) * ((q : ℝ) * (72 * ((P : ℝ) + 1)⁻¹)) := by + intro r + have hr : D ≤ r := hDq.trans (separation d W G P hq ℓ hP hℓ _ _ hne) + have ht : D ≤ (q : ℝ) * ℓ a := by + have hl := (hℓ a).1 + have htol : (9 / 10 : ℝ) ≤ ℓ a := by + unfold contactLengthTolerance at hl + linarith + exact hDq.trans (by nlinarith [show (0 : ℝ) < q by exact_mod_cast hq]) + have hrgap := localizedCoulombProfile_gap hfreq hD hleak hr + have htgap := localizedCoulombProfile_gap hfreq hD hleak ht + have hdiff := calibratedResidual_abs_sub hfreq hτ (hK a) hscale r ((q : ℝ) * ℓ a) + hrgap htgap + have hc : 0 ≤ scale * (planarHoppingLipschitzConstant : ℝ) + + coulombTargetLipschitzConstant freq τ (K a) := + add_nonneg (mul_nonneg hscale (by positivity)) + (coulombTargetLipschitzConstant_nonnegative freq (K a) hτ) + have hd := mul_le_mul_of_nonneg_left (edge_error d W G P hq ℓ hℓ a) hc + have htri := abs_add_le + (scale * planarHopping r - coulombHoppingTarget freq τ (K a) r - + (scale * planarHopping ((q : ℝ) * ℓ a) - coulombHoppingTarget freq τ (K a) ((q : ℝ) * ℓ a))) + (scale * planarHopping ((q : ℝ) * ℓ a) - coulombHoppingTarget freq τ (K a) ((q : ℝ) * ℓ a)) + rw [sub_add_cancel] at htri + linarith [hres a] + +end ContinuumCoulomb.ContactCalibratedGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b6037076428f42fa03cc839e78ee23d6cb9636a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibration.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRealization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibrationScale + +namespace OAI + +/-! Simultaneous calibration of every edge of the actual positive mediator +graph, together with whole-matrix Coulomb coercivity for its realized sites. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.ContactMediator +open MediatorIteration + +theorem exists_calibrated_finalGraph_above {freq : ℝ} (hfreq : 0 < freq) (A B S : ℕ) (kmin : ℝ) : + ∃ k : ℕ, 0 < k ∧ kmin ≤ (k : ℝ) ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (1 - contactLengthTolerance) * ((k : ℝ) * Real.log N) ∧ + ∀ (d : SquareLatticeHeisenberg) (W G : ℕ) (K : GlobalEdge d → ℝ), + (Fintype.card (GlobalSite d) : ℝ) ≤ N ^ S → + (∀ a, (N ^ A)⁻¹ ≤ K a) → (∀ a, K a ≤ N ^ A) → + ∃ u : GlobalSite d → PlanarPosition, + (∀ a, N ^ k * planarHopping ‖u ((finalGraph d.bonds W G).left a) - + u ((finalGraph d.bonds W G).right a)‖ = + coulombHoppingTarget freq (N ^ B)⁻¹ (K a) + ‖u ((finalGraph d.bonds W G).left a) - u ((finalGraph d.bonds W G).right a)‖) ∧ + (∀ x y, x ≠ y → (1 - contactLengthTolerance) * ((k : ℝ) * Real.log N) ≤ + ‖u x - u y‖) ∧ + (∀ x y, x ≠ y → Nonedge d W G x y → + (6 / 5) * ((k : ℝ) * Real.log N) < ‖u x - u y‖) ∧ + (∀ c : GlobalSite d → ℝ, localizedGramConstant freq * ∑ i, c i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * c i * c j) ∧ + Function.Injective u ∧ + (∀ M : ℝ, (∀ j i, |(contactGridAxis (d.coordinate j) i : ℝ)| ≤ M) → + ∀ x i, |u x i| ≤ ((k : ℝ) * Real.log N) * (17 * M + 17)) := by + obtain ⟨L, _, hrange⟩ := exists_coulomb_target_polynomial_bounds hfreq A B + obtain ⟨k, hk, hminimum, hcal⟩ := exists_uniform_coulomb_calibration_above + (ε := contactLengthTolerance) hfreq + (by norm_num [contactLengthTolerance]) (by norm_num [contactLengthTolerance]) (B + A + L) S kmin + refine ⟨k, hk, hminimum, fun N hN => ⟨(hcal N hN).1, ?_⟩⟩ + intro d W G K hcount hlo hhi + have hNpos : 0 < N := by linarith + let D : ℝ := (k : ℝ) * Real.log N + have hD : 0 < D := mul_pos (by exact_mod_cast hk) (Real.log_pos (by linarith)) + have htarget (a : GlobalEdge d) : + ∃ t ∈ Set.Icc ((1 - contactLengthTolerance) * D) ((1 + contactLengthTolerance) * D), + N ^ k * planarHopping t = coulombHoppingTarget freq (N ^ B)⁻¹ (K a) t := by + obtain ⟨hl, hh⟩ := hrange N hN (K a) (hlo a) (hhi a) + exact (hcal N hN).2.2.1 (N ^ B)⁻¹ (K a) (by positivity) + ((inv_nonneg.mpr (pow_nonneg hNpos.le A)).trans (hlo a)) hl hh + choose t ht using htarget + let ℓ : GlobalEdge d → ℝ := fun a => t a / D + have hℓ (a : GlobalEdge d) : ℓ a ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + constructor + · exact (le_div_iff₀ hD).mpr (ht a).1.1 + · exact (div_le_iff₀ hD).mpr (ht a).1.2 + obtain ⟨u, hlen, hnon, hsep, hinj, hext⟩ := exists_scaled_finalGraph_realization d W G D hD ℓ hℓ + have hdist (a : GlobalEdge d) : + ‖u ((finalGraph d.bonds W G).left a) - u ((finalGraph d.bonds W G).right a)‖ = t a := by + rw [← dist_eq_norm, hlen] + dsimp only [ℓ] + field_simp [hD.ne'] + refine ⟨u, ?_, ?_, ?_, ?_, hinj, hext⟩ + · intro a + rw [hdist] + exact (ht a).2 + · intro x y hxy + simpa only [dist_eq_norm, D] using hsep x y hxy + · intro x y hxy hn + simpa only [dist_eq_norm, D] using hnon x y hxy hn + · intro c + apply (hcal N hN).2.2.2 _ (by simpa only [Fintype.card_fin] using hcount) u + intro x y hxy + simpa only [dist_eq_norm, D] using hsep x y hxy + +theorem exists_calibrated_finalGraph {freq : ℝ} (hfreq : 0 < freq) (A B S : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (1 - contactLengthTolerance) * ((k : ℝ) * Real.log N) ∧ + ∀ (d : SquareLatticeHeisenberg) (W G : ℕ) (K : GlobalEdge d → ℝ), + (Fintype.card (GlobalSite d) : ℝ) ≤ N ^ S → + (∀ a, (N ^ A)⁻¹ ≤ K a) → (∀ a, K a ≤ N ^ A) → + ∃ u : GlobalSite d → PlanarPosition, + (∀ a, N ^ k * planarHopping ‖u ((finalGraph d.bonds W G).left a) - + u ((finalGraph d.bonds W G).right a)‖ = + coulombHoppingTarget freq (N ^ B)⁻¹ (K a) + ‖u ((finalGraph d.bonds W G).left a) - u ((finalGraph d.bonds W G).right a)‖) ∧ + (∀ x y, x ≠ y → (1 - contactLengthTolerance) * ((k : ℝ) * Real.log N) ≤ + ‖u x - u y‖) ∧ + (∀ x y, x ≠ y → Nonedge d W G x y → + (6 / 5) * ((k : ℝ) * Real.log N) < ‖u x - u y‖) ∧ + (∀ c : GlobalSite d → ℝ, localizedGramConstant freq * ∑ i, c i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * c i * c j) ∧ + Function.Injective u ∧ + (∀ M : ℝ, (∀ j i, |(contactGridAxis (d.coordinate j) i : ℝ)| ≤ M) → + ∀ x i, |u x i| ≤ ((k : ℝ) * Real.log N) * (17 * M + 17)) := by + obtain ⟨k, hk, _, hcal⟩ := exists_calibrated_finalGraph_above hfreq A B S 0 + exact ⟨k, hk, hcal⟩ + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibrationScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibrationScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..35292753e8f9bbe43a9c534184e0bebbd01efc15 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCalibrationScale.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetRange + +namespace OAI + +/-! The simultaneous Coulomb calibration permits any fixed lower bound on +its exponent, so the same scale can meet later localization estimates. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.ContactMediator + +theorem exists_uniform_coulomb_calibration_above {freq ε : ℝ} (hfreq : 0 < freq) + (hε : 0 < ε) (hε₁ : ε < 1) (A S : ℕ) (kmin : ℝ) : + ∃ k : ℕ, 0 < k ∧ kmin ≤ (k : ℝ) ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ + (∀ d : ℝ, (1 - ε) * ((k : ℝ) * Real.log N) ≤ d → + localizedGramConstant freq ≤ localizedCoulombProfile freq 0 - localizedCoulombProfile freq d) ∧ + (∀ τ K : ℝ, 0 ≤ τ → 0 ≤ K → + (N ^ A)⁻¹ ≤ τ * Real.sqrt (K * localizedGramConstant freq) → + τ * Real.sqrt (K * localizedCoulombProfile freq 0) ≤ N ^ A → + ∃ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), N ^ k * planarHopping d = coulombHoppingTarget freq τ K d) ∧ + (∀ (m : ℕ), (m : ℝ) ≤ N ^ S → ∀ (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → (1 - ε) * ((k : ℝ) * Real.log N) ≤ ‖u i - u j‖) → + ∀ d : Fin m → ℝ, localizedGramConstant freq * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j) := by + obtain ⟨k₀, _, hspacing⟩ := exists_localizedGram_spacing hfreq (S + 1) + obtain ⟨k, hk, hlarge, hcal⟩ := exists_uniform_planar_calibration_above + (max kmin ((k₀ : ℝ) / (1 - ε))) A hε hε₁ + have hminimum : kmin ≤ (k : ℝ) := (le_max_left _ _).trans hlarge + have hgram : (k₀ : ℝ) / (1 - ε) ≤ k := (le_max_right _ _).trans hlarge + refine ⟨k, hk, hminimum, fun N hN => ?_⟩ + have hNp : 0 < N := by linarith + have hN₁ : 1 ≤ N := by linarith + have hlog : 0 ≤ Real.log N := Real.log_nonneg hN₁ + have hlength : (k₀ : ℝ) * Real.log N ≤ (1 - ε) * ((k : ℝ) * Real.log N) := by + have h := mul_le_mul_of_nonneg_right ((div_le_iff₀ (sub_pos.mpr hε₁)).mp hgram) hlog + nlinarith only [h] + obtain ⟨hD, hleak⟩ := hspacing N hN + have hpow : N ^ S ≤ N ^ (S + 1) := pow_le_pow_right₀ hN₁ (Nat.le_succ S) + have htwo : (2 : ℝ) ≤ N ^ (S + 1) := by + exact hN.trans (by simpa only [pow_one] using pow_le_pow_right₀ hN₁ (show 1 ≤ S + 1 by omega)) + have hleak₂ : 2 * localLeakageBound freq ((k₀ : ℝ) * Real.log N) ≤ localDualMass freq / 2 := + (mul_le_mul_of_nonneg_right htwo (localLeakageBound_nonnegative _ _)).trans hleak + refine ⟨hD.trans hlength, ?_, ?_, ?_⟩ + · intro d hd + exact localizedCoulombProfile_gap hfreq hD hleak₂ (hlength.trans hd) + · intro τ K hτ hK hlo hhi + apply (hcal N hN).2 (coulombHoppingTarget freq τ K) + (coulombHoppingTarget_continuous hfreq τ K).continuousOn + intro d hd + have hb := coulombHoppingTarget_bounds hfreq hD hleak₂ (hlength.trans hd.1) hτ hK + exact ⟨hlo.trans hb.1, hb.2.trans hhi⟩ + · intro m hm u hsep d + apply localizedGram_uniform_coercive hfreq hD u + (fun i j hij => hlength.trans (hsep i j hij)) ?_ d + exact (mul_le_mul_of_nonneg_right (hm.trans hpow) (localLeakageBound_nonnegative _ _)).trans hleak + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCanonicalEdge.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCanonicalEdge.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfb1c57a85b85102473c4fdc8da4424befb95638 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactCanonicalEdge.lean @@ -0,0 +1,30 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactSourceGrid + +namespace OAI + +/-! The canonical strip record has an explicit finite computation from its +two lattice endpoints. This identifies the selected record with the record used by rational +coordinate programs. -/ + +namespace ContinuumCoulomb + +def canonicalContactEdge (p q : ℤ × ℤ) : ContactGridEdge := + let vertical := decide (p.1 = q.1) + let forward := if vertical then decide (p.2 < q.2) else decide (p.1 < q.1) + { vertical := vertical, anchor := if forward then p else q, reversed := !forward } + +theorem canonicalContactEdge_endpoints (e : ContactGridEdge) : + canonicalContactEdge e.left e.right = e := by + rcases e with ⟨v, ⟨a, b⟩, r⟩ + cases v <;> cases r <;> + simp [canonicalContactEdge, ContactGridEdge.left, ContactGridEdge.right, + ContactGridEdge.upper] + +theorem SquareLatticeHeisenberg.contactEdge_computation (d : SquareLatticeHeisenberg) + (e : Fin d.edges) : + d.contactEdge e = canonicalContactEdge (d.coordinate (d.left e)) (d.coordinate (d.right e)) := by + rw [← d.contactEdge_left e, ← d.contactEdge_right e, canonicalContactEdge_endpoints] + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactClosedCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactClosedCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3bd1012b2a78fe4092bb564596f2c6a975cdab7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactClosedCoordinates.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactVertexProgram + +namespace OAI + +/-! The rational path keeps both original endpoints exact. Replacing its +last approximate prefix sum by the prescribed span improves its distance +to the exact reference path and does not change the polynomial program. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactHeightEvaluation +open ExactQuantumFactoring.BitStackProgram + +def closedVertex (e : Environment) (k : ℕ) : ℚ × ℚ := + if k = 9 then (e.2.2, 0) else vertex e k + +def closedVertexPoint (e : Environment) (k : ℕ) : ContactPoint := + contactPoint (closedVertex e k).1 (closedVertex e k).2 + +theorem closedVertex_start (e : Environment) : closedVertex e 0 = (0, 0) := by + simp [closedVertex, vertex] + +theorem closedVertex_end (e : Environment) : closedVertex e 9 = (e.2.2, 0) := by + simp [closedVertex] + +theorem closedVertex_error (e : Environment) (h₀ : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (hroot : adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h₀ = (e.2.2 : ℝ)) + {k : ℕ} (hk : k ≤ 9) : + dist (closedVertexPoint e k) (adjustedContactVertex (fun j => (lengthAt e j : ℝ)) h₀ k) ≤ + 36 * ((e.1 : ℝ) + 1)⁻¹ := by + by_cases hk9 : k = 9 + · subst k + rw [adjustedContactVertex_end, hroot] + simp only [closedVertexPoint, closedVertex_end, Rat.cast_zero, dist_self] + positivity + · simpa only [closedVertexPoint, closedVertex, ite_eq_right hk9, vertexPoint] using + vertex_error e h₀ hl hl' hh₀ hroot hk + +noncomputable opaque closedVertexProgram (k : ℕ) : Procedure environmentCode + (prodCode ratCode ratCode) (fun e => closedVertex e k) := by + by_cases hk : k = 9 + · let data := Procedure.second unaryCode (prodCode (listCode ratCode) ratCode) + let target := (Procedure.second (listCode ratCode) ratCode).comp data + exact (target.pair (Procedure.constant environmentCode ratCode 0)).congrFun (by + intro e + simp only [closedVertex, ite_eq_left hk, Function.comp_apply]) + · exact (vertexProgram k).congrFun (by + intro e + simp only [closedVertex, ite_eq_right hk]) + +noncomputable def closedVertexListProgram : (k : ℕ) → Procedure environmentCode + (listCode (prodCode ratCode ratCode)) (fun e => (List.range k).map (closedVertex e)) + | 0 => (Procedure.constant environmentCode (listCode (prodCode ratCode ratCode)) []).congrFun + (by intro e; rfl) + | k + 1 => by + let singleton := (Procedure.listCons (prodCode ratCode ratCode)).comp + ((closedVertexProgram k).pair + (Procedure.constant environmentCode (listCode (prodCode ratCode ratCode)) [])) + exact ((Procedure.listAppend (prodCode ratCode ratCode) (0, 0)).comp + ((closedVertexListProgram k).pair singleton)).congrFun (by + intro e + simp only [Function.comp_apply, List.range_succ, List.map_append, + List.map_cons, List.map_nil]) + +noncomputable def closedVertexListCertificate : Turing.TM2ComputableInPolyTime + environmentCode (listCode (prodCode ratCode ratCode)) + (fun e => (List.range 10).map (closedVertex e)) := (closedVertexListProgram 10).toTM2 + +end ContinuumCoulomb.ContactHeightEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactDisplacement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactDisplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..04884d8f666cc81bd91ac1086d9b60fc345439d8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactDisplacement.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactAdjustment + +namespace OAI + +/-! Uniform displacement bounds for the explicit independent-length paths. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem adjustedContactForward_antitone {length h h' : ℝ} (hh : 0 ≤ h) (hle : h ≤ h') : + adjustedContactForward length h' ≤ adjustedContactForward length h := by + apply Real.sqrt_le_sqrt + nlinarith + +theorem adjustedContactForward_near {c h length : ℝ} + (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (hl : 1 - contactLengthTolerance ≤ length) (hl' : length ≤ 1 + contactLengthTolerance) : + |adjustedContactForward length h - c| ≤ 11 / 10000 := by + have hlow := adjustedContactForward_bound hl hl' + (show 7 / 10 ≤ c + 1 / 1000 by linarith) + (show c + 1 / 1000 ≤ 9 / 10 by linarith) (contactHeightLow_sq hc hc') + have hhigh := adjustedContactForward_bound hl hl' + (show 7 / 10 ≤ c - 1 / 1000 by linarith) + (show c - 1 / 1000 ≤ 9 / 10 by linarith) (contactHeightHigh_sq hc hc') + have hlo : 0 ≤ contactHeightLow c := Real.sqrt_nonneg _ + have hh0 : 0 ≤ h := hlo.trans hh.1 + have ha := adjustedContactForward_antitone (length := length) hlo hh.1 + have hb := adjustedContactForward_antitone (length := length) hh0 hh.2 + apply abs_le.mpr + constructor <;> linarith + +theorem contactHeight_near {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) : + |h - contactSlopeHeight c| ≤ 1 / 250 := by + have hbase := contactSlopeHeight_sq (by linarith : -1 ≤ c) (by linarith : c ≤ 1) + have hlowsq := contactHeightLow_sq hc hc' + have hhighsq := contactHeightHigh_sq hc hc' + have hbase0 : 0 ≤ contactSlopeHeight c := Real.sqrt_nonneg _ + have hlow0 : 0 ≤ contactHeightLow c := Real.sqrt_nonneg _ + have hhigh0 : 0 ≤ contactHeightHigh c := Real.sqrt_nonneg _ + have hbaseMin : 2 / 5 ≤ contactSlopeHeight c := by nlinarith + have hlowMin : 2 / 5 ≤ contactHeightLow c := by nlinarith + have hhighMin : 2 / 5 ≤ contactHeightHigh c := by nlinarith + have hlowNear : contactSlopeHeight c - 1 / 250 ≤ contactHeightLow c := by nlinarith + have hhighNear : contactHeightHigh c ≤ contactSlopeHeight c + 1 / 250 := by nlinarith + exact abs_le.mpr ⟨by linarith [hh.1], by linarith [hh.2]⟩ + +theorem adjustedContactStepX_near {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) {k : ℕ} (hk : k < 9) : + |adjustedContactStepX lengths h k - contactStepX c k| ≤ 11 / 10000 := by + unfold adjustedContactStepX contactStepX + split_ifs + · exact adjustedContactForward_near hc hc' hh (hl k hk) (hl' k hk) + · apply abs_le.mpr + have h1 := hl k hk + have h2 := hl' k hk + unfold contactLengthTolerance at h1 h2 + constructor <;> linarith + +theorem adjustedContactStepY_near {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) (k : ℕ) : + |adjustedContactStepY h k - contactStepY c k| ≤ 1 / 250 := by + have hnear := contactHeight_near hc hc' hh + unfold adjustedContactStepY contactStepY + split_ifs + · exact hnear + · simpa only [neg_sub_neg, abs_sub_comm] using hnear + · norm_num + +theorem contact_sum_error {f g : ℕ → ℝ} {k : ℕ} {eta : ℝ} + (h : ∀ j < k, |f j - g j| ≤ eta) : + |(∑ j ∈ Finset.range k, f j) - ∑ j ∈ Finset.range k, g j| ≤ k * eta := by + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j ∈ Finset.range k, |f j - g j| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j ∈ Finset.range k, eta := Finset.sum_le_sum (fun j hj => h j (Finset.mem_range.mp hj)) + _ = _ := by simp + +/-- A uniform displacement bound with room for moving the path origin. -/ +theorem adjustedContactVertex_displacement {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (lengths : ℕ → ℝ) + (hl : ∀ j < 9, 1 - contactLengthTolerance ≤ lengths j) + (hl' : ∀ j < 9, lengths j ≤ 1 + contactLengthTolerance) {k : ℕ} (hk : k ≤ 9) : + dist (adjustedContactVertex lengths h k) (contactPathVertex c k) < 1 / 25 := by + have hx := contact_sum_error (k := k) + (fun j hj => adjustedContactStepX_near hc hc' hh lengths hl hl' (by omega : j < 9)) + have hy := contact_sum_error (k := k) + (fun j _ => adjustedContactStepY_near hc hc' hh j) + have hkreal : (k : ℝ) ≤ 9 := by exact_mod_cast hk + have hx' : |adjustedContactVertex lengths h k 0 - contactPathVertex c k 0| ≤ 99 / 10000 := by + change |(∑ j ∈ Finset.range k, adjustedContactStepX lengths h j) - + ∑ j ∈ Finset.range k, contactStepX c j| ≤ 99 / 10000 + linarith + have hy' : |adjustedContactVertex lengths h k 1 - contactPathVertex c k 1| ≤ 9 / 250 := by + change |(∑ j ∈ Finset.range k, adjustedContactStepY h j) - + ∑ j ∈ Finset.range k, contactStepY c j| ≤ 9 / 250 + linarith + have hdist := contactPoint_dist_sq + (∑ j ∈ Finset.range k, adjustedContactStepX lengths h j) + (∑ j ∈ Finset.range k, adjustedContactStepY h j) + (∑ j ∈ Finset.range k, contactStepX c j) + (∑ j ∈ Finset.range k, contactStepY c j) + change dist (adjustedContactVertex lengths h k) (contactPathVertex c k) ^ 2 = + (adjustedContactVertex lengths h k 0 - contactPathVertex c k 0) ^ 2 + + (adjustedContactVertex lengths h k 1 - contactPathVertex c k 1) ^ 2 at hdist + have hxSq : (adjustedContactVertex lengths h k 0 - contactPathVertex c k 0) ^ 2 ≤ (99 / 10000 : ℝ) ^ 2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg + (adjustedContactVertex lengths h k 0 - contactPathVertex c k 0)) + (by norm_num : (0 : ℝ) ≤ 99 / 10000)).mpr hx' + have hySq : (adjustedContactVertex lengths h k 1 - contactPathVertex c k 1) ^ 2 ≤ (9 / 250 : ℝ) ^ 2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg + (adjustedContactVertex lengths h k 1 - contactPathVertex c k 1)) + (by norm_num : (0 : ℝ) ≤ 9 / 250)).mpr hy' + nlinarith [show 0 ≤ dist (adjustedContactVertex lengths h k) (contactPathVertex c k) from dist_nonneg] + +theorem adjustedContactVertex_near {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (lengths : ℕ → ℝ) + (hl : ∀ j < 9, 1 - contactLengthTolerance ≤ lengths j) + (hl' : ∀ j < 9, lengths j ≤ 1 + contactLengthTolerance) {k : ℕ} (hk : k ≤ 9) : + dist (adjustedContactVertex lengths h k) (contactPathVertex c k) < 1 / 20 := + (adjustedContactVertex_displacement hc hc' hh lengths hl hl' hk).trans (by norm_num) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactEdgeNumber.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactEdgeNumber.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f79b937baecbe9363a6fc77acb8ba60694346c9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactEdgeNumber.lean @@ -0,0 +1,34 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediator + +namespace OAI + +/-! Natural-number formulas for the exact final-edge permutation. These +are the indices used to fetch calibrated lengths from the emitted list. -/ + +namespace ContinuumCoulomb.ContactMediator + +def pathNumber (r e : ℕ) : LocalPath → ℕ + | Sum.inl s => e * 2 + s.val + | Sum.inr (s, t) => r * 2 + (e * 2 + s.val) * 2 + t.val + +def edgeNumber (r e : ℕ) : LocalEdge → ℕ + | Sum.inl _ => e + | Sum.inr (Sum.inl p) => r + pathNumber r e p + | Sum.inr (Sum.inr (p, t)) => r + (r * 2 + r * 2 * 2) + pathNumber r e p * 2 + t.val + +theorem pathIndex_val (r : ℕ) (e : Fin r) (p : LocalPath) : + (pathIndex r e p).val = pathNumber r e.val p := by + rcases p with s | ⟨s, t⟩ <;> + simp [pathIndex, pathNumber, spokeIndex, finProdFinEquiv] <;> ring + +theorem encodeEdge_val (r : ℕ) (e : Fin r) (a : LocalEdge) : + (encodeEdge r e a).val = edgeNumber r e.val a := by + rcases a with u | (p | ⟨p, t⟩) + · simp [encodeEdge, edgeNumber] + · simp [encodeEdge, edgeNumber, pathIndex_val] + · simp [encodeEdge, edgeNumber, spokeIndex, finProdFinEquiv, pathIndex_val, Nat.add_assoc] + ring + +end ContinuumCoulomb.ContactMediator + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactExtent.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactExtent.lean new file mode 100644 index 0000000000000000000000000000000000000000..6816784e4d516b8a510ca8e149e8d6fe00ccb0c6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactExtent.lean @@ -0,0 +1,129 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGlobal +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +/-! The contact realization preserves polynomial coordinate extent. -/ + +noncomputable section +namespace ContinuumCoulomb + +def contactGridAxis (a : ℤ × ℤ) (i : Fin 2) : ℤ := ![a.1, a.2] i + +@[simp] theorem contactGridPoint_apply (a : ℤ × ℤ) (i : Fin 2) : + contactGridPoint a i = 17 * (contactGridAxis a i : ℝ) := by + fin_cases i <;> rfl + +/-- Every internal strip remains within sixteen coordinate units of its +canonical lower/left lattice endpoint. -/ +theorem ContactGridEdge.strip_coordinate_bound (e : ContactGridEdge) (p : ContactStripSite) + (i : Fin 2) : + |e.place (contactPoint p.axial p.transverse) i - contactGridPoint e.anchor i| ≤ 16 := by + obtain ⟨q, hq⟩ := e.place_strip p + rw [hq] + cases h : e.vertical <;> fin_cases i <;> + simp only [Bool.false_eq_true, ite_false, ite_true, horizontalContact, verticalContact, + contactGridPoint] + all_goals + dsimp [contactPoint] + apply abs_le.mpr + constructor <;> linarith [q.axial_lower, q.axial_upper, q.transverse_lower, q.transverse_upper] + +/-- A source edge's canonical anchor is one of its two actual endpoints. -/ +theorem SquareLatticeHeisenberg.contactEdge_anchor (d : SquareLatticeHeisenberg) + (e : Fin d.edges) : + (d.contactEdge e).anchor = d.coordinate (d.left e) ∨ + (d.contactEdge e).anchor = d.coordinate (d.right e) := by + cases h : (d.contactEdge e).reversed + · left + simpa only [ContactGridEdge.left, h, Bool.false_eq_true, ite_false] using d.contactEdge_left e + · right + simpa only [ContactGridEdge.right, h, ite_true] using d.contactEdge_right e + +namespace ContactMediator + +theorem globalSite_card (d : SquareLatticeHeisenberg) : + Fintype.card (GlobalSite d) = d.vertices + 18 * d.edges := by + simp only [GlobalSite, Fintype.card_fin] + ring + +theorem globalEdge_card (d : SquareLatticeHeisenberg) : + Fintype.card (GlobalEdge d) = 19 * d.edges := by + simp only [GlobalEdge, Fintype.card_fin] + ring + +private theorem abs_le_add_abs_sub (x y : ℝ) : |x| ≤ |x - y| + |y| := by + have h := abs_add_le (x - y) y + simpa only [sub_add_cancel] using h + +/-- Uniform coordinate bounds of the source control the full final graph, +including all eighteen fresh sites per edge. -/ +theorem globalPosition_coordinate_bound (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) {M : ℝ} + (hcoord : ∀ j k, |(contactGridAxis (d.coordinate j) k : ℝ)| ≤ M) + (hP : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20) + (x : GlobalSite d) (i : Fin 2) : + |globalPosition d P x i| ≤ 17 * M + 17 := by + obtain ⟨x, rfl⟩ := (siteEquiv d.vertices d.edges).surjective x + cases x with + | inl j => + rw [globalPosition_old, contactGridPoint_apply, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 17)] + linarith [hcoord j i] + | inr eu => + rcases eu with ⟨e, u⟩ + obtain ⟨p, hp⟩ := globalPosition_internal_near_strip d P hP e u + let z := (d.contactEdge e).place (contactPoint p.axial p.transverse) + have hanchor : |(contactGridAxis (d.contactEdge e).anchor i : ℝ)| ≤ M := by + rcases d.contactEdge_anchor e with h | h + · rw [h] + exact hcoord (d.left e) i + · rw [h] + exact hcoord (d.right e) i + have hb : |contactGridPoint (d.contactEdge e).anchor i| ≤ 17 * M := by + rw [contactGridPoint_apply, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 17)] + exact mul_le_mul_of_nonneg_left hanchor (by norm_num) + have hz : |z i| ≤ 17 * M + 16 := by + have ht := abs_le_add_abs_sub (z i) (contactGridPoint (d.contactEdge e).anchor i) + have hs := (d.contactEdge e).strip_coordinate_bound p i + dsimp only [z] at ht ⊢ + linarith + have hd := contactPoint_coordinate_le_dist z + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u)))) i + have ht := abs_le_add_abs_sub + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u))) i) (z i) + rw [abs_sub_comm] at ht + linarith + +/-- A fixed logarithmic spacing and polynomial source extent give an +explicit polynomial bound for every realized coordinate. -/ +theorem logarithmic_extent_polynomial (k s : ℕ) {N : ℝ} (hN : 2 ≤ N) : + (k : ℝ) * Real.log N * (17 * N ^ s + 17) ≤ N ^ (k + s + 7) := by + have hNp : 0 < N := by linarith + have hN₁ : 1 ≤ N := by linarith + have hk₂ : (k : ℝ) ≤ (2 : ℝ) ^ k := by exact_mod_cast (Nat.lt_two_pow_self (n := k)).le + have hkN : (k : ℝ) ≤ N ^ k := hk₂.trans (pow_le_pow_left₀ (by norm_num) hN k) + have hlog : Real.log N ≤ N := (Real.log_le_sub_one_of_pos hNp).trans (by linarith) + have hlog₀ := Real.log_nonneg hN₁ + have hs : 1 ≤ N ^ s := one_le_pow₀ hN₁ + have hsize : 17 * N ^ s + 17 ≤ 34 * N ^ s := by linarith + have h34 : (34 : ℝ) ≤ N ^ 6 := + (by norm_num : (34 : ℝ) ≤ 2 ^ 6).trans (pow_le_pow_left₀ (by norm_num) hN 6) + calc + (k : ℝ) * Real.log N * (17 * N ^ s + 17) ≤ + (N ^ k * N) * (34 * N ^ s) := + mul_le_mul (mul_le_mul hkN hlog hlog₀ (pow_nonneg hNp.le k)) hsize + (by positivity) (by positivity) + _ = 34 * (N ^ k * N ^ s * N) := by ring + _ ≤ N ^ 6 * (N ^ k * N ^ s * N) := + mul_le_mul_of_nonneg_right h34 (by positivity) + _ = N ^ (k + s + 7) := by + rw [show k + s + 7 = 6 + k + s + 1 by omega, pow_add, pow_add, pow_add, pow_one] + ring + +end ContactMediator +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgetStability.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgetStability.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a6c10b1ce096249119341f3b42b826cefa49d41 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgetStability.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactBaseSeparation + +namespace OAI + +/-! The prescribed nineteen-link gadgets retain the nonlink separation of the +base shapes. All estimates concern the actual coordinate constructions. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem contactPoint_axis_dist (x x' : ℝ) : + dist (contactPoint x 0) (contactPoint x' 0) = |x - x'| := by + have h := contactPoint_dist_sq x 0 x' 0 + nlinarith [sq_abs (x - x'), abs_nonneg (x - x'), + show 0 ≤ dist (contactPoint x 0) (contactPoint x' 0) from dist_nonneg] + +theorem contactPoint_vertical_dist (x y y' : ℝ) : + dist (contactPoint x y) (contactPoint x y') = |y - y'| := by + have h := contactPoint_dist_sq x y x y' + nlinarith [sq_abs (y - y'), abs_nonneg (y - y'), + show 0 ≤ dist (contactPoint x y) (contactPoint x y') from dist_nonneg] + +theorem contactGadgetOrigin_near (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) : + dist (contactPoint (contactGadgetRightOrigin negative central) 0) + (contactPoint (contactGadgetRightOrigin negative 1) 0) ≤ contactLengthTolerance := by + rw [contactPoint_axis_dist] + cases negative + · apply abs_le.mpr + simp only [contactGadgetRightOrigin, Bool.false_eq_true, ite_false] + constructor <;> linarith + · norm_num [contactGadgetRightOrigin, contactLengthTolerance] + +/-- The complete actual gadget, including the central partner, stays inside +the same fixed separation guard as the independently adjusted paths. -/ +theorem contactGadgetPosition_near (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) + (leftLengths rightLengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths k) + (hl' : ∀ k < 9, leftLengths k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths k) + (hr' : ∀ k < 9, rightLengths k ≤ 1 + contactLengthTolerance) + {leftHeight rightHeight : ℝ} + (hleftHeight : leftHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (hrightHeight : rightHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) (x : ContactGadgetSite) : + dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight x) + (contactBaseGadgetPosition negative x) < 1 / 20 := by + have hs := contactGadgetSlope_bounds negative + rcases x with i | (i | ⟨⟩) + · exact adjustedContactVertex_near hs.1 hs.2 hleftHeight leftLengths hl hl' + (show i.val ≤ 9 by have := i.isLt; omega) + · have hpath := adjustedContactVertex_displacement hs.1 hs.2 hrightHeight rightLengths hr hr' + (show i.val + 1 ≤ 9 by have := i.isLt; omega) + have horigin := contactGadgetOrigin_near negative hc hc' + have hdist := dist_add_add_le (contactPoint (contactGadgetRightOrigin negative central) 0) + (adjustedContactVertex rightLengths rightHeight (i.val + 1)) + (contactPoint (contactGadgetRightOrigin negative 1) 0) + (contactPathVertex (contactGadgetSlope negative) (i.val + 1)) + change dist (contactPoint (contactGadgetRightOrigin negative central) 0 + + adjustedContactVertex rightLengths rightHeight (i.val + 1)) + (contactPoint (contactGadgetRightOrigin negative 1) 0 + + contactPathVertex (contactGadgetSlope negative) (i.val + 1)) < 1 / 20 + unfold contactLengthTolerance at horigin + linarith + · cases negative + · change dist (contactPoint ((17 + central) / 2) 0) (contactPoint 9 0) < 1 / 20 + have h := contactGadgetOrigin_near false hc hc' + norm_num [contactGadgetRightOrigin, contactLengthTolerance] at h + linarith + · change dist (contactPoint (17 / 2) central) (contactPoint (17 / 2) 1) < 1 / 20 + rw [contactPoint_vertical_dist] + have habs : |central - 1| ≤ contactLengthTolerance := abs_le.mpr ⟨by linarith, by linarith⟩ + exact habs.trans_lt (by norm_num [contactLengthTolerance]) + +/-- The actual variable-link gadget retains distance greater than1.2 for +every distinct pair which is not one of its nineteen links. -/ +theorem contactGadget_nonlink_separation (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) + (leftLengths rightLengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths k) + (hl' : ∀ k < 9, leftLengths k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths k) + (hr' : ∀ k < 9, rightLengths k ≤ 1 + contactLengthTolerance) + {leftHeight rightHeight : ℝ} + (hleftHeight : leftHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (hrightHeight : rightHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (x y : ContactGadgetSite) (hne : x ≠ y) (hlink : ¬ contactGadgetLinked negative x y) : + 6 / 5 < dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight x) + (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight y) := by + have hnear := contactGadgetPosition_near negative hc hc' leftLengths rightLengths hl hl' hr hr' + hleftHeight hrightHeight + apply contact_separation_stable (contactBaseGadgetPosition negative x) + (contactBaseGadgetPosition negative y) _ _ (contactBaseGadget_nonlink_separation negative x y hne hlink) + · rw [dist_comm] + exact (hnear x).le + · rw [dist_comm] + exact (hnear y).le + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..155566aa0bc70bacfcab5bf401818c51730c8704 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGadgets.lean @@ -0,0 +1,168 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactDisplacement + +namespace OAI + +/-! The two signed-edge contact gadgets. Each has twenty sites, nineteen +links, fixed original endpoints, and independently prescribed link lengths. +A negative input sign places the central partner off the backbone. -/ + +noncomputable section +namespace ContinuumCoulomb + +abbrev ContactGadgetSite := Fin 10 ⊕ (Fin 9 ⊕ Unit) + +def contactGadgetSlope (negative : Bool) : ℝ := if negative then 7 / 8 else 3 / 4 + +def contactGadgetSpan (negative : Bool) (central : ℝ) : ℝ := + if negative then 17 / 2 else (17 - central) / 2 + +def contactGadgetRightOrigin (negative : Bool) (central : ℝ) : ℝ := + if negative then 17 / 2 else (17 + central) / 2 + +def contactGadgetSide : ContactGadgetSite := Sum.inr (Sum.inr ()) + +def contactGadgetRightNode (negative : Bool) (k : Fin 10) : ContactGadgetSite := + if hk : k = 0 then + if negative then Sum.inl 9 else contactGadgetSide + else Sum.inr (Sum.inl ⟨k.val - 1, by have := k.isLt; omega⟩) + +def contactGadgetPosition (negative : Bool) (central : ℝ) + (leftLengths rightLengths : ℕ → ℝ) (leftHeight rightHeight : ℝ) : + ContactGadgetSite → ContactPoint := + Sum.elim (fun k => adjustedContactVertex leftLengths leftHeight k.val) + (Sum.elim (fun k => contactPoint (contactGadgetRightOrigin negative central) 0 + + adjustedContactVertex rightLengths rightHeight (k.val + 1)) + (fun _ => if negative then contactPoint (17 / 2) central + else contactPoint (contactGadgetRightOrigin negative central) 0)) + +theorem contactGadgetSlope_bounds (negative : Bool) : + 3 / 4 ≤ contactGadgetSlope negative ∧ contactGadgetSlope negative ≤ 7 / 8 := by + cases negative <;> norm_num [contactGadgetSlope] + +theorem contactGadgetSpan_bounds (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) : + 5 + 4 * contactGadgetSlope negative - contactLengthTolerance ≤ contactGadgetSpan negative central ∧ + contactGadgetSpan negative central ≤ 5 + 4 * contactGadgetSlope negative + contactLengthTolerance := by + cases negative + · simp only [contactGadgetSlope, contactGadgetSpan, Bool.false_eq_true, ite_false] + constructor <;> linarith + · norm_num [contactGadgetSlope, contactGadgetSpan, contactLengthTolerance] + +theorem contactGadgetRightNode_position (negative : Bool) (central : ℝ) + (leftLengths rightLengths : ℕ → ℝ) (leftHeight rightHeight : ℝ) + (hleft : adjustedContactSpan leftLengths leftHeight = contactGadgetSpan negative central) + (k : Fin 10) : + contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (contactGadgetRightNode negative k) = + contactPoint (contactGadgetRightOrigin negative central) 0 + + adjustedContactVertex rightLengths rightHeight k.val := by + by_cases hk : k = 0 + · subst k + rw [contactGadgetRightNode, dite_eq_left rfl] + cases negative + · simp [contactGadgetPosition, contactGadgetSide, adjustedContactVertex, contactPoint] + · change adjustedContactVertex leftLengths leftHeight 9 = contactPoint (17 / 2) 0 + + adjustedContactVertex rightLengths rightHeight 0 + rw [adjustedContactVertex_end, hleft] + simp [contactGadgetSpan, adjustedContactVertex, contactPoint] + · rw [contactGadgetRightNode, dite_eq_right hk] + change contactPoint (contactGadgetRightOrigin negative central) 0 + + adjustedContactVertex rightLengths rightHeight (k.val - 1 + 1) = _ + congr 2 + have : k.val ≠ 0 := fun h => hk (Fin.ext h) + omega + +/-- Every physical link has its independently prescribed length. -/ +theorem contactGadget_link_lengths (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) + (leftLengths rightLengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths k) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths k) + {leftHeight rightHeight : ℝ} + (hleftHeight : leftHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (hrightHeight : rightHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (hleft : adjustedContactSpan leftLengths leftHeight = contactGadgetSpan negative central) : + (∀ k : Fin 9, + dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (Sum.inl k.succ)) + (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (Sum.inl k.castSucc)) = leftLengths k.val) ∧ + dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + contactGadgetSide) + (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (Sum.inl 9)) = central ∧ + (∀ k : Fin 9, + dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (contactGadgetRightNode negative k.succ)) + (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (contactGadgetRightNode negative k.castSucc)) = rightLengths k.val) := by + have hs := contactGadgetSlope_bounds negative + have hcentral : 0 ≤ central := by unfold contactLengthTolerance at hc; linarith + refine ⟨?_, ?_, ?_⟩ + · intro k + exact adjustedContact_link_length hs.1 hs.2 hleftHeight leftLengths hl k.isLt + · have hA : contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (Sum.inl 9) = contactPoint (contactGadgetSpan negative central) 0 := by + change adjustedContactVertex leftLengths leftHeight 9 = _ + rw [adjustedContactVertex_end, hleft] + rw [hA] + have hsq : dist (contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + contactGadgetSide) (contactPoint (contactGadgetSpan negative central) 0) ^ 2 = central ^ 2 := by + cases negative <;> simp only [contactGadgetSide, contactGadgetPosition, Sum.elim_inr, + contactGadgetRightOrigin, contactGadgetSpan, Bool.false_eq_true, ite_false, + ite_true, contactPoint_dist_sq] <;> ring + nlinarith [show 0 ≤ dist (contactGadgetPosition negative central leftLengths rightLengths + leftHeight rightHeight contactGadgetSide) (contactPoint (contactGadgetSpan negative central) 0) + from dist_nonneg] + · intro k + rw [contactGadgetRightNode_position negative central leftLengths rightLengths leftHeight rightHeight hleft, + contactGadgetRightNode_position negative central leftLengths rightLengths leftHeight rightHeight hleft, + dist_add_left] + exact adjustedContact_link_length hs.1 hs.2 hrightHeight rightLengths hr k.isLt + +/-- Independent implementation of all nineteen links with the two original +vertices fixed. No dimensional parameter of a larger lattice enters. -/ +theorem contactGadget_independent_lengths (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) + (leftLengths rightLengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths k) + (hl' : ∀ k < 9, leftLengths k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths k) + (hr' : ∀ k < 9, rightLengths k ≤ 1 + contactLengthTolerance) : + ∃ leftHeight rightHeight, + leftHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative)) ∧ + rightHeight ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative)) ∧ + adjustedContactSpan leftLengths leftHeight = contactGadgetSpan negative central ∧ + adjustedContactSpan rightLengths rightHeight = contactGadgetSpan negative central ∧ + contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight (Sum.inl 0) = + contactPoint 0 0 ∧ + contactGadgetPosition negative central leftLengths rightLengths leftHeight rightHeight + (contactGadgetRightNode negative 9) = contactPoint 17 0 := by + have hs := contactGadgetSlope_bounds negative + have hspan := contactGadgetSpan_bounds negative hc hc' + obtain ⟨leftHeight, hleftHeight, hleft⟩ := adjustedContactSpan_exists hs.1 hs.2 leftLengths hl hl' hspan.1 hspan.2 + obtain ⟨rightHeight, hrightHeight, hright⟩ := adjustedContactSpan_exists hs.1 hs.2 rightLengths hr hr' hspan.1 hspan.2 + refine ⟨leftHeight, rightHeight, hleftHeight, hrightHeight, hleft, hright, ?_, ?_⟩ + · simp [contactGadgetPosition, adjustedContactVertex] + · rw [contactGadgetRightNode_position negative central leftLengths rightLengths leftHeight rightHeight hleft] + change contactPoint (contactGadgetRightOrigin negative central) 0 + + adjustedContactVertex rightLengths rightHeight 9 = contactPoint 17 0 + rw [adjustedContactVertex_end, hright] + cases negative + · ext i + fin_cases i + · change (17 + central) / 2 + (17 - central) / 2 = 17 + ring + · norm_num [contactPoint, PiLp.add_apply] + · ext i + fin_cases i <;> norm_num [contactGadgetRightOrigin, contactGadgetSpan, contactPoint, PiLp.add_apply] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGeometryBlockSemantics.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGeometryBlockSemantics.lean new file mode 100644 index 0000000000000000000000000000000000000000..37a9f064d83aa57515b829115de0249e1bd19514 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGeometryBlockSemantics.lean @@ -0,0 +1,167 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactGeometryBlockProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalLocal + +namespace OAI + +/-! The serialized blocks are the original iterated graph's vertex array, +through the explicit site permutation. No graph relabeling is assumed. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactGeometryBlockProgram +open ContactMediator + +private theorem lookup_ofFn {α : Type*} {n : ℕ} (f : Fin n → α) (d : α) (i : Fin n) : + ((List.ofFn f).drop i.val).headD d = f i := by + rw [List.drop_eq_getElem_cons (by simpa only [List.length_ofFn] using i.isLt)] + simp only [List.headD_cons, List.getElem_ofFn] + +theorem block_ofFn {n r : ℕ} (f : Fin n → ContactGadgetSite) (g : Fin r → EdgeInput) : + block (List.ofFn f) (List.ofFn g) = + List.ofFn (fun i : Fin (r * n) => ContactPlacedGadgetProgram.position + (g i.divNat) (f i.modNat)) := by + apply List.ext_getElem + · simp only [block, List.length_map, List.length_range, List.length_ofFn, Nat.mul_comm] + · intro i h₁ h₂ + have hi : i < r * n := by simpa only [List.length_ofFn] using h₂ + have hiq : i / n < r := Nat.div_lt_of_lt_mul (by simpa only [Nat.mul_comm] using hi) + have hn : 0 < n := by + by_contra h + have : n = 0 := by omega + simp [this] at hi + have him : i % n < n := Nat.mod_lt _ hn + simp only [block, List.getElem_map, List.getElem_range, List.getElem_ofFn, List.length_ofFn] + rw [lookup_ofFn g defaultEdge ⟨i / n, hiq⟩, List.map_ofFn] + rw [lookup_ofFn (ContactPlacedGadgetProgram.position (g ⟨i / n, hiq⟩) ∘ f) + (0, 0) ⟨i % n, him⟩] + rfl + +def literalEdge (d : SquareLatticeHeisenberg) (P : ℕ) + (ℓ : ContactMediator.GlobalEdge d → ℚ) (e : Fin d.edges) : EdgeInput := + ((d.coordinate (d.left e), d.coordinate (d.right e)), + ContactRationalLocal.input P (ContactMediator.edgeNegative d.bonds e) + (fun a => ℓ (ContactMediator.encodeEdge d.edges e a))) + +def literalInput (d : SquareLatticeHeisenberg) (P : ℕ) + (ℓ : ContactMediator.GlobalEdge d → ℚ) : Input := + (List.ofFn d.coordinate, List.ofFn (literalEdge d P ℓ)) + +theorem literal_position (d : SquareLatticeHeisenberg) (P : ℕ) + (ℓ : ContactMediator.GlobalEdge d → ℚ) (e : Fin d.edges) (u : LocalInternal) : + ContactPlacedGadgetProgram.position (literalEdge d P ℓ e) (localToContact (Sum.inr u)) = + ContactRationalGlobal.position d P ℓ (siteEquiv d.vertices d.edges (Sum.inr (e, u))) := by + simp only [ContactRationalGlobal.position, Equiv.symm_apply_apply] + rw [d.contactEdge_computation] + rfl + +theorem literal_old (d : SquareLatticeHeisenberg) (P : ℕ) + (ℓ : ContactMediator.GlobalEdge d → ℚ) (i : Fin d.vertices) : + oldPoint (d.coordinate i) = + ContactRationalGlobal.position d P ℓ (siteEquiv d.vertices d.edges (Sum.inl i)) := by + simp only [ContactRationalGlobal.position, Equiv.symm_apply_apply, oldPoint] + +theorem literal_length (d : SquareLatticeHeisenberg) (P : ℕ) + (ℓ : ContactMediator.GlobalEdge d → ℚ) : + (positions (literalInput d P ℓ)).length = d.vertices + 18 * d.edges := by + rw [positions_length] + simp only [literalInput, List.length_ofFn] + +def firstIndex (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 2)) : GlobalSite d := + siteEquiv d.vertices d.edges (Sum.inr (i.divNat, Sum.inl i.modNat)) + +def secondIndex (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 4)) : GlobalSite d := + let st : Fin 2 × Fin 2 := finProdFinEquiv.symm i.modNat + siteEquiv d.vertices d.edges (Sum.inr (i.divNat, Sum.inr (Sum.inl st))) + +def thirdFirstIndex (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 4)) : GlobalSite d := + let st : Fin 2 × Fin 2 := finProdFinEquiv.symm i.modNat + siteEquiv d.vertices d.edges (Sum.inr (i.divNat, Sum.inr (Sum.inr (Sum.inl st.1, st.2)))) + +def thirdSecondIndex (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 8)) : GlobalSite d := + let st : Fin 4 × Fin 2 := finProdFinEquiv.symm i.modNat + let su : Fin 2 × Fin 2 := finProdFinEquiv.symm st.1 + siteEquiv d.vertices d.edges (Sum.inr (i.divNat, Sum.inr (Sum.inr (Sum.inr su, st.2)))) + +theorem firstIndex_val (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 2)) : + (firstIndex d i).val = d.vertices + i.val := by + simp [firstIndex, siteEquiv, encodeSite, MediatorGraph.old, MediatorGraph.fresh, + MediatorGraph.vertexEquiv, finProdFinEquiv] + omega + +theorem secondIndex_val (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 4)) : + (secondIndex d i).val = d.vertices + d.edges * 2 + i.val := by + simp [secondIndex, siteEquiv, encodeSite, MediatorGraph.old, MediatorGraph.fresh, + MediatorGraph.vertexEquiv, spokeIndex, finProdFinEquiv] + omega + +theorem thirdFirstIndex_val (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 4)) : + (thirdFirstIndex d i).val = d.vertices + d.edges * 2 + d.edges * 2 * 2 + i.val := by + simp [thirdFirstIndex, siteEquiv, encodeSite, MediatorGraph.fresh, + MediatorGraph.vertexEquiv, pathIndex, spokeIndex, finProdFinEquiv] + omega + +theorem thirdSecondIndex_val (d : SquareLatticeHeisenberg) (i : Fin (d.edges * 8)) : + (thirdSecondIndex d i).val = + d.vertices + d.edges * 2 + d.edges * 2 * 2 + d.edges * 4 + i.val := by + simp [thirdSecondIndex, siteEquiv, encodeSite, MediatorGraph.fresh, + MediatorGraph.vertexEquiv, pathIndex, spokeIndex, finProdFinEquiv] + omega + +theorem first_block (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + block firstSites (List.ofFn (literalEdge d P ℓ)) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (firstIndex d i)) := by + rw [firstSites, block_ofFn] + congr 1 + funext i + exact literal_position d P ℓ i.divNat (Sum.inl i.modNat) + +theorem second_block (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + block secondSites (List.ofFn (literalEdge d P ℓ)) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (secondIndex d i)) := by + rw [secondSites, block_ofFn] + congr 1 + funext i + exact literal_position d P ℓ i.divNat (Sum.inr (Sum.inl (finProdFinEquiv.symm i.modNat))) + +theorem thirdFirst_block (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + block thirdFirstSites (List.ofFn (literalEdge d P ℓ)) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (thirdFirstIndex d i)) := by + rw [thirdFirstSites, block_ofFn] + congr 1 + funext i + let st : Fin 2 × Fin 2 := finProdFinEquiv.symm i.modNat + exact literal_position d P ℓ i.divNat (Sum.inr (Sum.inr (Sum.inl st.1, st.2))) + +theorem thirdSecond_block (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + block thirdSecondSites (List.ofFn (literalEdge d P ℓ)) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (thirdSecondIndex d i)) := by + rw [thirdSecondSites, block_ofFn] + congr 1 + funext i + exact literal_position d P ℓ i.divNat + (Sum.inr (Sum.inr (Sum.inr (finProdFinEquiv.symm + (finProdFinEquiv.symm i.modNat : Fin 4 × Fin 2).1), + (finProdFinEquiv.symm i.modNat : Fin 4 × Fin 2).2))) + +theorem literal_blocks (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + positions (literalInput d P ℓ) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ + (siteEquiv d.vertices d.edges (Sum.inl i))) ++ + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (firstIndex d i)) ++ + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (secondIndex d i)) ++ + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (thirdFirstIndex d i)) ++ + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ (thirdSecondIndex d i)) := by + unfold positions literalInput + rw [List.map_ofFn, first_block, second_block, thirdFirst_block, thirdSecond_block] + have hold : List.ofFn (oldPoint ∘ d.coordinate) = + List.ofFn (fun i => ContactRationalGlobal.position d P ℓ + (siteEquiv d.vertices d.edges (Sum.inl i))) := by + congr 1 + funext i + exact literal_old d P ℓ i + rw [hold] + +end ContinuumCoulomb.ContactGeometryBlockProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobal.lean new file mode 100644 index 0000000000000000000000000000000000000000..43876d10cc15190da86dc6905aa60d7c8a25e19e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobal.lean @@ -0,0 +1,151 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediatorLinks +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactSourceGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceMatrix + +namespace OAI + +/-! Gluing the independently adjusted nineteen-link gadgets along the +actual original lattice vertices. All fresh sites retain their source-edge +label under the explicit final-graph permutation. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactMediator +open MediatorIteration + +abbrev GlobalSite (d : SquareLatticeHeisenberg) := + Fin (d.vertices + d.edges * 2 + d.edges * 2 * 2 + (d.edges * 2 + d.edges * 2 * 2) * 2) + +abbrev GlobalEdge (d : SquareLatticeHeisenberg) := + Fin (d.edges + ((d.edges * 2 + d.edges * 2 * 2) + (d.edges * 2 + d.edges * 2 * 2) * 2)) + +def joinedPosition (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) : + Fin d.vertices ⊕ (Fin d.edges × LocalInternal) → ContactPoint + | Sum.inl i => contactGridPoint (d.coordinate i) + | Sum.inr (e, u) => (d.contactEdge e).place (P e (Sum.inr u)) + +def globalPosition (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) (i : GlobalSite d) : ContactPoint := + joinedPosition d P ((siteEquiv d.vertices d.edges).symm i) + +@[simp] theorem globalPosition_old (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) (i : Fin d.vertices) : + globalPosition d P (siteEquiv d.vertices d.edges (Sum.inl i)) = + contactGridPoint (d.coordinate i) := by + simp [globalPosition, joinedPosition] + +@[simp] theorem globalPosition_internal (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) (e : Fin d.edges) (u : LocalInternal) : + globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u))) = + (d.contactEdge e).place (P e (Sum.inr u)) := by + simp [globalPosition, joinedPosition] + +/-- Anchoring a local gadget at zero and seventeen makes its two old +vertices agree with the unique global positions of the original spins. -/ +theorem globalPosition_local (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) + (h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0) + (h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0) + (e : Fin d.edges) (x : LocalSite) : + globalPosition d P (localVertex (d.left e) (d.right e) e x) = + (d.contactEdge e).place (P e x) := by + cases x with + | inl s => + fin_cases s + · change globalPosition d P (siteEquiv d.vertices d.edges (Sum.inl (d.left e))) = + (d.contactEdge e).place (P e (localOld 0)) + rw [globalPosition_old, h₀ e, ContactGridEdge.place_zero, d.contactEdge_left] + · change globalPosition d P (siteEquiv d.vertices d.edges (Sum.inl (d.right e))) = + (d.contactEdge e).place (P e (localOld 1)) + rw [globalPosition_old, h₁ e, ContactGridEdge.place_end, d.contactEdge_right] + | inr u => simp [localVertex] + +/-- The exact edge lengths of the local gadgets are the lengths of every +edge in the actual final mediator enumeration. -/ +theorem globalPosition_link_lengths (d : SquareLatticeHeisenberg) (W G : ℕ) + (P : Fin d.edges → LocalSite → ContactPoint) + (h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0) + (h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0) + (ℓ : GlobalEdge d → ℝ) + (hℓ : ∀ e a, dist (P e (localLeft (member (d.coefficient e)) a)) + (P e (localRight a)) = ℓ (encodeEdge d.edges e a)) (a : GlobalEdge d) : + dist (globalPosition d P ((finalGraph d.bonds W G).left a)) + (globalPosition d P ((finalGraph d.bonds W G).right a)) = ℓ a := by + obtain ⟨⟨e, a⟩, rfl⟩ := (edgeEquiv d.edges).surjective a + change dist (globalPosition d P ((finalGraph d.bonds W G).left (encodeEdge d.edges e a))) + (globalPosition d P ((finalGraph d.bonds W G).right (encodeEdge d.edges e a))) = _ + rw [finalGraph_left, finalGraph_right] + change dist (globalPosition d P (localVertex (d.left e) (d.right e) e + (localLeft (member (d.coefficient e)) a))) + (globalPosition d P (localVertex (d.left e) (d.right e) e (localRight a))) = _ + rw [globalPosition_local d P h₀ h₁, globalPosition_local d P h₀ h₁, + ContactGridEdge.place_dist] + exact hℓ e a + +/-- The independent local adjustments stay close to points in the exact +canonical strip belonging to their original source edge. -/ +theorem globalPosition_internal_near_strip (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) + (hP : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20) + (e : Fin d.edges) (u : LocalInternal) : + ∃ p : ContactStripSite, dist ((d.contactEdge e).place + (contactPoint p.axial p.transverse)) + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u)))) < 1 / 20 := by + have hleft : localToContact (Sum.inr u) ≠ Sum.inl 0 := by + intro h + have heq := congrArg contactToLocal h + rw [contact_local_inverse] at heq + simp only [contactToLocal, Matrix.cons_val_zero, localOld, reduceCtorEq] at heq + have hright : localToContact (Sum.inr u) ≠ + contactGadgetRightNode (edgeNegative d.bonds e) 9 := by + intro h + have heq := congrArg contactToLocal h + rw [contact_local_inverse] at heq + cases hn : edgeNegative d.bonds e <;> + simp [contactToLocal, contactGadgetRightNode, localOld] at heq + obtain ⟨p, hp⟩ := contactBaseGadget_internal_strip (edgeNegative d.bonds e) + (localToContact (Sum.inr u)) hleft hright + refine ⟨p, ?_⟩ + rw [globalPosition_internal, ContactGridEdge.place_dist, ← hp, dist_comm] + exact hP e (Sum.inr u) + +/-- All fresh sites belonging to distinct original edges have the fixed +nonedge margin, uniformly in the size of the original lattice graph. -/ +theorem globalPosition_distinct_gadgets (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) + (hP : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20) + (e f : Fin d.edges) (hef : e ≠ f) (u v : LocalInternal) : + 6 / 5 < dist (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u)))) + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (f, v)))) := by + obtain ⟨p, hp⟩ := globalPosition_internal_near_strip d P hP e u + obtain ⟨q, hq⟩ := globalPosition_internal_near_strip d P hP f v + exact ContactGridEdge.distinct_perturbed_separation (d.contactEdge e) (d.contactEdge f) + (fun h => hef (d.contactEdge_key_injective h)) p q _ _ hp.le hq.le + +/-- A nonincident original spin is separated from every fresh site of a +gadget, including after its independent contact-length adjustment. -/ +theorem globalPosition_nonincident (d : SquareLatticeHeisenberg) + (P : Fin d.edges → LocalSite → ContactPoint) + (hP : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20) + (i : Fin d.vertices) (e : Fin d.edges) (hi₀ : i ≠ d.left e) (hi₁ : i ≠ d.right e) + (u : LocalInternal) : + 6 / 5 < dist (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u)))) + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inl i))) := by + obtain ⟨p, hp⟩ := globalPosition_internal_near_strip d P hP e u + have hs := ContactGridEdge.external_vertex_separation (d.contactEdge e) (d.coordinate i) + (by simpa using fun h => hi₀ (d.coordinate_injective h)) + (by simpa using fun h => hi₁ (d.coordinate_injective h)) p + rw [globalPosition_old] + have ht := dist_triangle ((d.contactEdge e).place (contactPoint p.axial p.transverse)) + (globalPosition d P (siteEquiv d.vertices d.edges (Sum.inr (e, u)))) + (contactGridPoint (d.coordinate i)) + linarith + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobalSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobalSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ef4b6a351b92404d16a520a6593f7edc4f62f63 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGlobalSeparation.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGlobal + +namespace OAI + +/-! Uniform all-site and nonedge separation for the actual final graph. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactMediator +open MediatorIteration + +@[simp] theorem localVertex_old_zero {n r : ℕ} (a b : Fin n) (e : Fin r) : + localVertex a b e (localOld 0) = siteEquiv n r (Sum.inl a) := by + simp [localVertex, localOld] + +@[simp] theorem localVertex_old_one {n r : ℕ} (a b : Fin n) (e : Fin r) : + localVertex a b e (localOld 1) = siteEquiv n r (Sum.inl b) := by + simp [localVertex, localOld] + +@[simp] theorem localVertex_internal {n r : ℕ} (a b : Fin n) (e : Fin r) (u : LocalInternal) : + localVertex a b e (Sum.inr u) = siteEquiv n r (Sum.inr (e, u)) := rfl + +def Nonedge (d : SquareLatticeHeisenberg) (W G : ℕ) (x y : GlobalSite d) : Prop := + ¬∃ a, samePair ((finalGraph d.bonds W G).left a) ((finalGraph d.bonds W G).right a) x y + +theorem Nonedge.symm {d : SquareLatticeHeisenberg} {W G : ℕ} {x y : GlobalSite d} + (h : Nonedge d W G x y) : Nonedge d W G y x := by + rintro ⟨a, ha⟩ + exact h ⟨a, samePair_swap_target ha⟩ + +theorem globalPosition_local_nonedge (d : SquareLatticeHeisenberg) (W G : ℕ) + (P : Fin d.edges → LocalSite → ContactPoint) + (h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0) + (h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0) + (hsep : ∀ e x y, x ≠ y → Nonedge d W G + (localVertex (d.left e) (d.right e) e x) + (localVertex (d.left e) (d.right e) e y) → 6 / 5 < dist (P e x) (P e y)) + (e : Fin d.edges) (x y : LocalSite) (hne : x ≠ y) + (hn : Nonedge d W G (localVertex (d.left e) (d.right e) e x) + (localVertex (d.left e) (d.right e) e y)) : + 6 / 5 < dist (globalPosition d P (localVertex (d.left e) (d.right e) e x)) + (globalPosition d P (localVertex (d.left e) (d.right e) e y)) := by + rw [globalPosition_local d P h₀ h₁, globalPosition_local d P h₀ h₁, + ContactGridEdge.place_dist] + exact hsep e x y hne hn + +/-- Combining the local nonedge theorem with distinct-strip and external +vertex estimates gives the fixed margin on every nonedge of finalGraph. -/ +theorem globalPosition_nonedge (d : SquareLatticeHeisenberg) (W G : ℕ) + (P : Fin d.edges → LocalSite → ContactPoint) + (h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0) + (h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0) + (hsep : ∀ e x y, x ≠ y → Nonedge d W G + (localVertex (d.left e) (d.right e) e x) + (localVertex (d.left e) (d.right e) e y) → 6 / 5 < dist (P e x) (P e y)) + (hP : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20) + (x y : GlobalSite d) (hne : x ≠ y) (hn : Nonedge d W G x y) : + 6 / 5 < dist (globalPosition d P x) (globalPosition d P y) := by + obtain ⟨x, rfl⟩ := (siteEquiv d.vertices d.edges).surjective x + obtain ⟨y, rfl⟩ := (siteEquiv d.vertices d.edges).surjective y + cases x with + | inl i => + cases y with + | inl j => + have hij : i ≠ j := fun h => hne (by subst j; rfl) + simpa only [globalPosition_old] using + lt_of_lt_of_le (by norm_num : (6 / 5 : ℝ) < 17) + (contactGridPoint_separation (fun h => hij (d.coordinate_injective h))) + | inr eu => + rcases eu with ⟨e, u⟩ + by_cases hi₀ : i = d.left e + · subst i + simpa only [localVertex_old_zero, localVertex_internal] using + globalPosition_local_nonedge d W G P h₀ h₁ hsep e (localOld 0) (Sum.inr u) + (by simp [localOld]) (by simpa only [localVertex_old_zero, localVertex_internal] using hn) + · by_cases hi₁ : i = d.right e + · subst i + simpa only [localVertex_old_one, localVertex_internal] using + globalPosition_local_nonedge d W G P h₀ h₁ hsep e (localOld 1) (Sum.inr u) + (by simp [localOld]) (by simpa only [localVertex_old_one, localVertex_internal] using hn) + · rw [dist_comm] + exact globalPosition_nonincident d P hP i e hi₀ hi₁ u + | inr eu => + rcases eu with ⟨e, u⟩ + cases y with + | inl i => + by_cases hi₀ : i = d.left e + · subst i + simpa only [localVertex_old_zero, localVertex_internal] using + globalPosition_local_nonedge d W G P h₀ h₁ hsep e (Sum.inr u) (localOld 0) + (by simp [localOld]) (by simpa only [localVertex_old_zero, localVertex_internal] using hn) + · by_cases hi₁ : i = d.right e + · subst i + simpa only [localVertex_old_one, localVertex_internal] using + globalPosition_local_nonedge d W G P h₀ h₁ hsep e (Sum.inr u) (localOld 1) + (by simp [localOld]) (by simpa only [localVertex_old_one, localVertex_internal] using hn) + · exact globalPosition_nonincident d P hP i e hi₀ hi₁ u + | inr fv => + rcases fv with ⟨f, v⟩ + by_cases hef : e = f + · subst f + have huv : u ≠ v := fun h => hne (by subst v; rfl) + simpa only [localVertex_internal] using + globalPosition_local_nonedge d W G P h₀ h₁ hsep e (Sum.inr u) (Sum.inr v) + (by simpa using huv) (by simpa only [localVertex_internal] using hn) + · exact globalPosition_distinct_gadgets d P hP e f hef u v + +/-- With the prescribed local lengths, all distinct sites have at least the +smallest permitted edge length, whether or not they are adjacent. -/ +theorem globalPosition_separation (d : SquareLatticeHeisenberg) (W G : ℕ) + (P : Fin d.edges → LocalSite → ContactPoint) + (h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0) + (h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0) + (ℓ : GlobalEdge d → ℝ) + (hlen : ∀ e a, dist (P e (localLeft (member (d.coefficient e)) a)) + (P e (localRight a)) = ℓ (encodeEdge d.edges e a)) + (hℓ : ∀ a, 1 - contactLengthTolerance ≤ ℓ a) + (hsep : ∀ x y, x ≠ y → Nonedge d W G x y → + 6 / 5 < dist (globalPosition d P x) (globalPosition d P y)) + (x y : GlobalSite d) (hne : x ≠ y) : + 1 - contactLengthTolerance ≤ dist (globalPosition d P x) (globalPosition d P y) := by + by_cases hn : Nonedge d W G x y + · have hs := hsep x y hne hn + unfold contactLengthTolerance + linarith + · simp only [Nonedge, not_not] at hn + obtain ⟨a, ha⟩ := hn + have he := globalPosition_link_lengths d W G P h₀ h₁ ℓ hlen a + rcases ha with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · rw [he] + exact hℓ a + · rw [dist_comm, he] + exact hℓ a + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..6120ae13a0b9a90717133f45face98c22cd88c9f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactGrid.lean @@ -0,0 +1,266 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactLattice + +namespace OAI + +/-! Rigid placements of the fixed contact strip on the square lattice. +Reversing an original edge reflects its axial coordinate; this keeps its +internal points in the same canonical strip. -/ + +noncomputable section +namespace ContinuumCoulomb + +/-- The original square-lattice vertices are spaced seventeen units apart. -/ +def contactGridPoint (a : ℤ × ℤ) : ContactPoint := + contactPoint (17 * a.1) (17 * a.2) + +def contactReflect (p : ContactPoint) : ContactPoint := contactPoint (17 - p 0) (p 1) + +def contactHorizontal (a : ℤ × ℤ) (p : ContactPoint) : ContactPoint := + contactPoint (17 * a.1 + p 0) (17 * a.2 + p 1) + +def contactVertical (a : ℤ × ℤ) (p : ContactPoint) : ContactPoint := + contactPoint (17 * a.1 - p 1) (17 * a.2 + p 0) + +private theorem contact_dist_eq_of_sq_eq {p q x y : ContactPoint} + (h : dist p q ^ 2 = dist x y ^ 2) : dist p q = dist x y := by + nlinarith [dist_nonneg (x := p) (y := q), dist_nonneg (x := x) (y := y)] + +theorem contactReflect_dist (p q : ContactPoint) : + dist (contactReflect p) (contactReflect q) = dist p q := by + apply contact_dist_eq_of_sq_eq + rw [contactReflect, contactReflect, contactPoint_dist_sq, ← contactPoint_eta p, + ← contactPoint_eta q, contactPoint_dist_sq] + simp only [contactPoint_zero, contactPoint_one] + ring + +theorem contactHorizontal_dist (a : ℤ × ℤ) (p q : ContactPoint) : + dist (contactHorizontal a p) (contactHorizontal a q) = dist p q := by + apply contact_dist_eq_of_sq_eq + rw [contactHorizontal, contactHorizontal, contactPoint_dist_sq, ← contactPoint_eta p, + ← contactPoint_eta q, contactPoint_dist_sq] + simp only [contactPoint_zero, contactPoint_one] + ring + +theorem contactVertical_dist (a : ℤ × ℤ) (p q : ContactPoint) : + dist (contactVertical a p) (contactVertical a q) = dist p q := by + apply contact_dist_eq_of_sq_eq + rw [contactVertical, contactVertical, contactPoint_dist_sq, ← contactPoint_eta p, + ← contactPoint_eta q, contactPoint_dist_sq] + simp only [contactPoint_zero, contactPoint_one] + ring + +def ContactStripSite.reflect (p : ContactStripSite) : ContactStripSite where + axial := 17 - p.axial + transverse := p.transverse + axial_lower := by linarith [p.axial_upper] + axial_upper := by linarith [p.axial_lower] + transverse_lower := p.transverse_lower + transverse_upper := p.transverse_upper + off_axis_lower := by intro h; linarith [p.off_axis_upper h] + off_axis_upper := by intro h; linarith [p.off_axis_lower h] + +@[simp] theorem contactReflect_strip (p : ContactStripSite) : + contactReflect (contactPoint p.axial p.transverse) = + contactPoint p.reflect.axial p.reflect.transverse := rfl + +/-- The canonical key of a lattice edge consists of its direction and its +lower/left endpoint. The final Boolean records the input orientation. -/ +structure ContactGridEdge where + vertical : Bool + anchor : ℤ × ℤ + reversed : Bool + deriving DecidableEq + +def ContactGridEdge.key (e : ContactGridEdge) : Bool × (ℤ × ℤ) := (e.vertical, e.anchor) + +def ContactGridEdge.upper (e : ContactGridEdge) : ℤ × ℤ := + if e.vertical then (e.anchor.1, e.anchor.2 + 1) else (e.anchor.1 + 1, e.anchor.2) + +def ContactGridEdge.left (e : ContactGridEdge) : ℤ × ℤ := + if e.reversed then e.upper else e.anchor + +def ContactGridEdge.right (e : ContactGridEdge) : ℤ × ℤ := + if e.reversed then e.anchor else e.upper + +def ContactGridEdge.place (e : ContactGridEdge) (p : ContactPoint) : ContactPoint := + let p' := if e.reversed then contactReflect p else p + if e.vertical then contactVertical e.anchor p' else contactHorizontal e.anchor p' + +theorem ContactGridEdge.place_dist (e : ContactGridEdge) (p q : ContactPoint) : + dist (e.place p) (e.place q) = dist p q := by + cases e with + | mk vertical anchor reversed => + cases vertical <;> cases reversed <;> + simp [ContactGridEdge.place, contactHorizontal_dist, contactVertical_dist, contactReflect_dist] + +@[simp] theorem ContactGridEdge.place_zero (e : ContactGridEdge) : + e.place (contactPoint 0 0) = contactGridPoint e.left := by + rcases e with ⟨vertical, ⟨a, b⟩, reversed⟩ + cases vertical <;> cases reversed <;> ext i <;> fin_cases i <;> + simp [ContactGridEdge.place, ContactGridEdge.left, ContactGridEdge.upper, + contactReflect, contactHorizontal, contactVertical, contactGridPoint, contactPoint] <;> ring + +@[simp] theorem ContactGridEdge.place_end (e : ContactGridEdge) : + e.place (contactPoint 17 0) = contactGridPoint e.right := by + rcases e with ⟨vertical, ⟨a, b⟩, reversed⟩ + cases vertical <;> cases reversed <;> ext i <;> fin_cases i <;> + simp [ContactGridEdge.place, ContactGridEdge.right, ContactGridEdge.upper, + contactReflect, contactHorizontal, contactVertical, contactGridPoint, contactPoint] <;> ring + +/-- The orientation flag does not alter the strip containing an internal site. -/ +theorem ContactGridEdge.place_strip (e : ContactGridEdge) (p : ContactStripSite) : + ∃ q : ContactStripSite, e.place (contactPoint p.axial p.transverse) = + if e.vertical then verticalContact e.anchor.1 e.anchor.2 q + else horizontalContact e.anchor.1 e.anchor.2 q := by + refine ⟨if e.reversed then p.reflect else p, ?_⟩ + cases h : e.reversed <;> cases v : e.vertical <;> + simp [ContactGridEdge.place, h, v, contactReflect, contactHorizontal, contactVertical, + horizontalContact, verticalContact, ContactStripSite.reflect] + +/-- Vertical parallel strips have the same separation as horizontal ones. -/ +theorem verticalContact_separation (a b c d : ℤ) + (hne : (a, b) ≠ (c, d)) (p q : ContactStripSite) : + 7 / 5 < dist (verticalContact a b p) (verticalContact c d q) := by + have hk : (b, -a) ≠ (d, -c) := by + intro h + apply hne + have h₁ := congrArg Prod.fst h + have h₂ := congrArg Prod.snd h + exact Prod.ext (by omega) h₁ + have hs := horizontalContact_separation b (-a) d (-c) hk p q + have hd : dist (verticalContact a b p) (verticalContact c d q) = + dist (horizontalContact b (-a) p) (horizontalContact d (-c) q) := by + apply contact_dist_eq_of_sq_eq + simp only [verticalContact, horizontalContact, contactPoint_dist_sq, Int.cast_neg] + ring + rw [hd] + exact hs + +theorem ContactGridEdge.distinct_strip_separation (e f : ContactGridEdge) + (hne : e.key ≠ f.key) (p q : ContactStripSite) : + 7 / 5 < dist (e.place (contactPoint p.axial p.transverse)) + (f.place (contactPoint q.axial q.transverse)) := by + obtain ⟨p', hp⟩ := e.place_strip p + obtain ⟨q', hq⟩ := f.place_strip q + rw [hp, hq] + cases he : e.vertical <;> cases hf : f.vertical <;> simp only [Bool.false_eq_true, ite_false, ite_true] + · apply horizontalContact_separation _ _ _ _ _ p' q' + intro h + exact hne (by simp [ContactGridEdge.key, he, hf, Prod.ext_iff] at h ⊢; exact h) + · exact perpendicularContact_separation _ _ _ _ p' q' + · rw [dist_comm] + exact perpendicularContact_separation _ _ _ _ q' p' + · apply verticalContact_separation _ _ _ _ _ p' q' + intro h + exact hne (by simp [ContactGridEdge.key, he, hf, Prod.ext_iff] at h ⊢; exact h) + +/-- Perturbed internal nodes of distinct original edges remain noncontacts. -/ +theorem ContactGridEdge.distinct_perturbed_separation (e f : ContactGridEdge) + (hne : e.key ≠ f.key) (p q : ContactStripSite) (x y : ContactPoint) + (hx : dist (e.place (contactPoint p.axial p.transverse)) x ≤ 1 / 20) + (hy : dist (f.place (contactPoint q.axial q.transverse)) y ≤ 1 / 20) : + 6 / 5 < dist x y := + contact_separation_stable _ _ _ _ (e.distinct_strip_separation f hne p q).le hx hy + +private theorem int_abs_difference_one {a b : ℤ} (h : a ≠ b) : + (1 : ℝ) ≤ |(a : ℝ) - b| := by + rcases lt_or_gt_of_ne h with h | h + · have h' : (a : ℝ) + 1 ≤ b := by exact_mod_cast (show a + 1 ≤ b by omega) + exact (neg_le_abs _).trans' (by linarith) + · have h' : (b : ℝ) + 1 ≤ a := by exact_mod_cast (show b + 1 ≤ a by omega) + exact (le_abs_self _).trans' (by linarith) + +theorem contactGridPoint_separation {a b : ℤ × ℤ} (hne : a ≠ b) : + 17 ≤ dist (contactGridPoint a) (contactGridPoint b) := by + by_cases h₀ : a.1 = b.1 + · have h₁ : a.2 ≠ b.2 := fun h => hne (Prod.ext h₀ h) + have ha := int_abs_difference_one h₁ + have hd := contactPoint_coordinate_le_dist (contactGridPoint a) (contactGridPoint b) 1 + change |17 * (a.2 : ℝ) - 17 * b.2| ≤ _ at hd + rw [← mul_sub, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 17)] at hd + linarith + · have ha := int_abs_difference_one h₀ + have hd := contactPoint_coordinate_le_dist (contactGridPoint a) (contactGridPoint b) 0 + change |17 * (a.1 : ℝ) - 17 * b.1| ≤ _ at hd + rw [← mul_sub, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 17)] at hd + linarith + +/-- A lattice vertex outside the two endpoints is far from the entire +horizontal internal strip, before any adjustment. -/ +theorem horizontalContact_external_vertex (a c : ℤ × ℤ) (p : ContactStripSite) + (h₀ : c ≠ a) (h₁ : c ≠ (a.1 + 1, a.2)) : + 7 / 5 < dist (horizontalContact a.1 a.2 p) (contactGridPoint c) := by + by_cases hb : c.2 = a.2 + · have hc₀ : c.1 ≠ a.1 := fun h => h₀ (Prod.ext h hb) + have hc₁ : c.1 ≠ a.1 + 1 := fun h => h₁ (Prod.ext h hb) + have hd := contactPoint_coordinate_le_dist + (horizontalContact a.1 a.2 p) (contactGridPoint c) 0 + change |17 * (a.1 : ℝ) + p.axial - 17 * c.1| ≤ _ at hd + have hc : c.1 ≤ a.1 - 1 ∨ a.1 + 2 ≤ c.1 := by omega + rcases hc with hc | hc + · have hc' : (c.1 : ℝ) ≤ a.1 - 1 := by exact_mod_cast hc + have hp := p.axial_lower + have hx := le_abs_self (17 * (a.1 : ℝ) + p.axial - 17 * c.1) + linarith + · have hc' : (a.1 : ℝ) + 2 ≤ c.1 := by exact_mod_cast hc + have hp := p.axial_upper + have hx := neg_le_abs (17 * (a.1 : ℝ) + p.axial - 17 * c.1) + linarith + · have hd := contactPoint_coordinate_le_dist + (horizontalContact a.1 a.2 p) (contactGridPoint c) 1 + change |17 * (a.2 : ℝ) + p.transverse - 17 * c.2| ≤ _ at hd + have hsep := contact_parallel_line_separation a.2 c.2 (Ne.symm hb) + p.transverse_lower p.transverse_upper (show (0 : ℝ) ≤ 0 by norm_num) + (show (0 : ℝ) ≤ 4 / 3 by norm_num) + simp only [add_zero] at hsep + linarith + +theorem verticalContact_external_vertex (a c : ℤ × ℤ) (p : ContactStripSite) + (h₀ : c ≠ a) (h₁ : c ≠ (a.1, a.2 + 1)) : + 7 / 5 < dist (verticalContact a.1 a.2 p) (contactGridPoint c) := by + have hc₀ : (c.2, -c.1) ≠ (a.2, -a.1) := by + intro h + apply h₀ + exact Prod.ext (by have := congrArg Prod.snd h; dsimp at this; omega) + (congrArg Prod.fst h) + have hc₁ : (c.2, -c.1) ≠ (a.2 + 1, -a.1) := by + intro h + apply h₁ + exact Prod.ext (by have := congrArg Prod.snd h; dsimp at this; omega) + (congrArg Prod.fst h) + have hs := horizontalContact_external_vertex (a.2, -a.1) (c.2, -c.1) p hc₀ hc₁ + have hd : dist (verticalContact a.1 a.2 p) (contactGridPoint c) = + dist (horizontalContact a.2 (-a.1) p) (contactGridPoint (c.2, -c.1)) := by + apply contact_dist_eq_of_sq_eq + simp only [verticalContact, horizontalContact, contactGridPoint, contactPoint_dist_sq, + Int.cast_neg] + ring + rw [hd] + exact hs + +theorem ContactGridEdge.external_vertex_separation (e : ContactGridEdge) + (c : ℤ × ℤ) (hc₀ : c ≠ e.left) (hc₁ : c ≠ e.right) (p : ContactStripSite) : + 7 / 5 < dist (e.place (contactPoint p.axial p.transverse)) (contactGridPoint c) := by + have ha : c ≠ e.anchor := by + cases h : e.reversed + · simpa [ContactGridEdge.left, h] using hc₀ + · simpa [ContactGridEdge.right, h] using hc₁ + have hu : c ≠ e.upper := by + cases h : e.reversed + · simpa [ContactGridEdge.right, h] using hc₁ + · simpa [ContactGridEdge.left, h] using hc₀ + obtain ⟨q, hq⟩ := e.place_strip p + rw [hq] + cases h : e.vertical + · simp only [Bool.false_eq_true, ite_false] + exact horizontalContact_external_vertex e.anchor c q ha + (by simpa [ContactGridEdge.upper, h] using hu) + · simp only [ite_true] + exact verticalContact_external_vertex e.anchor c q ha + (by simpa [ContactGridEdge.upper, h] using hu) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBisection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBisection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b880f119712835ddc495ad3b3b001f6f12c8e16 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBisection.lean @@ -0,0 +1,158 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionLocation + +namespace OAI + +/-! The height search uses fixed rational endpoints, its concrete evaluator, +and a linear unary precision schedule. The reference height is supplied by +the already proved contact intermediate-value theorem. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactHeightEvaluation + +def tolerance (e : Environment) : ℚ := 1 / ((e.1 : ℚ) + 1) + +def argument (e : Environment) (n : ℕ) : BisectionProgram.Input Environment := + (n, (e, (tolerance e, ((2 / 5 : ℚ), (3 / 4 : ℚ))))) + +def bisect (e : Environment) (n : ℕ) : ℚ := + BisectionProgram.approximate value (argument e n) + +def refinedEnvironment (e : Environment) : Environment := (16 * (e.1 + 1), e.2) + +def iterations (e : Environment) : ℕ := 64 * (e.1 + 1) + +def scheduledValue (e : Environment) : ℚ := bisect (refinedEnvironment e) (iterations e) + +theorem bisect_mem (e : Environment) (n : ℕ) : + (bisect e n : ℝ) ∈ Set.Icc (2 / 5) (3 / 4) := by + have hm := bisection_value_mem value e (tolerance e) (2 / 5) (3 / 4) + (by norm_num) n + have hm' : bisect e n ∈ Set.Icc (2 / 5 : ℚ) (3 / 4) := hm + constructor + · simpa only [Rat.cast_div, Rat.cast_ofNat] using (Rat.cast_le (K := ℝ)).mpr hm'.1 + · simpa only [Rat.cast_div, Rat.cast_ofNat] using (Rat.cast_le (K := ℝ)).mpr hm'.2 + +theorem endpoint_signs (e : Environment) (h₀ : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (hroot : adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h₀ = (e.2.2 : ℝ)) : + 0 ≤ residual e (2 / 5) ∧ residual e (3 / 4) ≤ 0 := by + have ha := (adjustedContactSpan_broad_slope (by norm_num) hh₀.1 hh₀.2 + (fun k => (lengthAt e k : ℝ)) hl hl').1 + have hb := (adjustedContactSpan_broad_slope hh₀.1 hh₀.2 (by norm_num) + (fun k => (lengthAt e k : ℝ)) hl hl').1 + rw [hroot] at ha hb + constructor <;> unfold residual <;> linarith [hh₀.1, hh₀.2] + +theorem bisect_residual (e : Environment) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (ha : 0 ≤ residual e (2 / 5)) (hb : residual e (3 / 4) ≤ 0) (n : ℕ) : + |residual e (bisect e n)| ≤ 2 * ((e.1 : ℝ) + 1)⁻¹ + + 8 * (((3 / 4 : ℝ) - 2 / 5) / 2 ^ n) := by + have heval (q : ℚ) (hq : q ∈ Set.Icc (2 / 5 : ℚ) (3 / 4)) : + |(value e q : ℝ) - residual e q| ≤ (tolerance e : ℝ) := by + have hq' : (q : ℝ) ∈ Set.Icc (2 / 5) (3 / 4) := by + constructor + · simpa only [Rat.cast_div, Rat.cast_ofNat] using (Rat.cast_le (K := ℝ)).mpr hq.1 + · simpa only [Rat.cast_div, Rat.cast_ofNat] using (Rat.cast_le (K := ℝ)).mpr hq.2 + simpa only [tolerance, Rat.cast_div, Rat.cast_one, Rat.cast_add, + Rat.cast_natCast, one_div, Rat.cast_inv] using approximation_error e q hl hq' + have hLip (r : ℝ) (hr : r ∈ Set.Icc (2 / 5) (3 / 4)) + (s : ℝ) (hs : s ∈ Set.Icc (2 / 5) (3 / 4)) : + |residual e r - residual e s| ≤ 8 * |r - s| := by + simpa only [residual, sub_sub_sub_cancel_right] using + adjustedContactSpan_broad_lipschitz hr hs (fun k => (lengthAt e k : ℝ)) hl hl' + have ha' : 0 ≤ residual e ((2 / 5 : ℚ) : ℝ) := by + simpa only [Rat.cast_div, Rat.cast_ofNat] using ha + have hb' : residual e ((3 / 4 : ℚ) : ℝ) ≤ 0 := by + simpa only [Rat.cast_div, Rat.cast_ofNat] using hb + have hLip' (r : ℝ) (hr : r ∈ Set.Icc ((2 / 5 : ℚ) : ℝ) ((3 / 4 : ℚ) : ℝ)) + (s : ℝ) (hs : s ∈ Set.Icc ((2 / 5 : ℚ) : ℝ) ((3 / 4 : ℚ) : ℝ)) : + |residual e r - residual e s| ≤ 8 * |r - s| := + hLip r (by simpa only [Rat.cast_div, Rat.cast_ofNat] using hr) + s (by simpa only [Rat.cast_div, Rat.cast_ofNat] using hs) + have he := BisectionProgram.residual value e + (show 0 ≤ tolerance e by unfold tolerance; positivity) + (show (2 / 5 : ℚ) ≤ 3 / 4 by norm_num) ha' hb' + (show (0 : ℝ) ≤ 8 by norm_num) heval hLip' n + simpa only [bisect, argument, tolerance, Rat.cast_div, Rat.cast_one, + Rat.cast_add, Rat.cast_natCast, Rat.cast_ofNat, one_div, Rat.cast_inv] using he + +theorem scheduled_residual (e : Environment) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (ha : 0 ≤ residual e (2 / 5)) (hb : residual e (3 / 4) ≤ 0) : + |residual e (scheduledValue e)| ≤ (2 * ((e.1 : ℝ) + 1))⁻¹ := by + have he := bisect_residual (refinedEnvironment e) hl hl' ha hb (iterations e) + have he' : |residual e (scheduledValue e)| ≤ + 2 * (16 * ((e.1 : ℝ) + 1) + 1)⁻¹ + + 8 * (((3 / 4 : ℝ) - 2 / 5) / 2 ^ iterations e) := by + simpa only [scheduledValue, refinedEnvironment, residual, lengthAt, Nat.cast_mul, + Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] using he + have hS : (0 : ℝ) < (e.1 : ℝ) + 1 := by positivity + have hn : (iterations e : ℝ) = 64 * ((e.1 : ℝ) + 1) := by + simp only [iterations, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + have hn0 : (0 : ℝ) < iterations e := by rw [hn]; positivity + have hfirst : 2 * (16 * ((e.1 : ℝ) + 1) + 1)⁻¹ ≤ + (8 * ((e.1 : ℝ) + 1))⁻¹ := by + apply (mul_inv_le_iff₀ (by positivity)).mpr + apply (le_inv_mul_iff₀ (by positivity : (0 : ℝ) < 8 * ((e.1 : ℝ) + 1))).mpr + linarith + have hsecond : 8 * (((3 / 4 : ℝ) - 2 / 5) / 2 ^ iterations e) ≤ + (8 * ((e.1 : ℝ) + 1))⁻¹ := by + calc + _ ≤ 8 * (2 : ℝ)⁻¹ ^ iterations e := by + rw [div_eq_mul_inv, inv_pow] + gcongr + norm_num + _ ≤ 8 * ((iterations e : ℝ) + 1)⁻¹ := + mul_le_mul_of_nonneg_left (CoulombQuadratureSchedule.dyadic_le_inverse _) (by norm_num) + _ ≤ 8 * (iterations e : ℝ)⁻¹ := + mul_le_mul_of_nonneg_left (inv_anti₀ hn0 (by linarith)) (by norm_num) + _ = (8 * ((e.1 : ℝ) + 1))⁻¹ := by + rw [hn] + field_simp [ne_of_gt hS] + ring + apply he'.trans ((add_le_add hfirst hsecond).trans _) + simp only [mul_inv_rev] + norm_num + nlinarith [inv_pos.mpr hS] + +theorem scheduled_height_error (e : Environment) (h₀ : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (hroot : adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h₀ = (e.2.2 : ℝ)) : + |(scheduledValue e : ℝ) - h₀| ≤ ((e.1 : ℝ) + 1)⁻¹ := by + have hs := endpoint_signs e h₀ hl hl' hh₀ hroot + have he := scheduled_residual e hl hl' hs.1 hs.2 + have hi := adjustedContactSpan_broad_inverse_error + (bisect_mem (refinedEnvironment e) (iterations e)) hh₀ + (fun k => (lengthAt e k : ℝ)) hl hl' hroot + have h := hi.trans (mul_le_mul_of_nonneg_left he (by norm_num : (0 : ℝ) ≤ 2)) + calc + _ ≤ 2 * (2 * ((e.1 : ℝ) + 1))⁻¹ := h + _ = _ := by field_simp + +theorem exists_scheduled_height_error (e : Environment) {c : ℝ} + (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hspan : 5 + 4 * c - contactLengthTolerance ≤ (e.2.2 : ℝ)) + (hspan' : (e.2.2 : ℝ) ≤ 5 + 4 * c + contactLengthTolerance) : + ∃ h₀ ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c), + adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h₀ = (e.2.2 : ℝ) ∧ + |(scheduledValue e : ℝ) - h₀| ≤ ((e.1 : ℝ) + 1)⁻¹ := by + obtain ⟨h₀, hh₀, hroot⟩ := adjustedContactSpan_exists hc hc' + (fun k => (lengthAt e k : ℝ)) hl hl' hspan hspan' + exact ⟨h₀, hh₀, hroot, scheduled_height_error e h₀ hl hl' + (contactHeight_interval_bounds hc hc' hh₀) hroot⟩ + +end ContinuumCoulomb.ContactHeightEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3a6d0307c7bb33d023d1bce350578b81ca074e9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightBounds.lean @@ -0,0 +1,140 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactAdjustment + +namespace OAI + +/-! Uniform direct and inverse moduli for the nine-link height solve. The +four sloping links keep this one-dimensional solve quantitatively regular. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem contactHeight_interval_bounds {c h : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) : + 2 / 5 ≤ h ∧ h ≤ 3 / 4 := by + have hl0 : 0 ≤ contactHeightLow c := Real.sqrt_nonneg _ + have hu0 : 0 ≤ contactHeightHigh c := Real.sqrt_nonneg _ + have hl := contactHeightLow_sq hc hc' + have hu := contactHeightHigh_sq hc hc' + constructor + · nlinarith [hh.1] + · nlinarith [hh.2] + +theorem adjustedContactForward_slope {length h₁ h₂ : ℝ} + (hl : 99 / 100 ≤ length) (hl' : length ≤ 101 / 100) + (hh₁ : 2 / 5 ≤ h₁) (hh : h₁ ≤ h₂) (hh₂ : h₂ ≤ 3 / 4) : + (h₂ - h₁) / 5 ≤ adjustedContactForward length h₁ - adjustedContactForward length h₂ ∧ + adjustedContactForward length h₁ - adjustedContactForward length h₂ ≤ 2 * (h₂ - h₁) := by + have h₁0 : 0 ≤ h₁ := by linarith + have h₂0 : 0 ≤ h₂ := by linarith + have h₁U : h₁ ≤ 3 / 4 := hh.trans hh₂ + have h₂L : 2 / 5 ≤ h₂ := hh₁.trans hh + have hl0 : 0 ≤ length := by linarith + have hl2lo : (99 / 100 : ℝ) ^ 2 ≤ length ^ 2 := by nlinarith + have hl2hi : length ^ 2 ≤ (101 / 100 : ℝ) ^ 2 := by nlinarith + have hr₁ : 0 ≤ length ^ 2 - h₁ ^ 2 := by nlinarith + have hr₂ : 0 ≤ length ^ 2 - h₂ ^ 2 := by nlinarith + let x₁ := adjustedContactForward length h₁ + let x₂ := adjustedContactForward length h₂ + have hx₁ : 0 ≤ x₁ := Real.sqrt_nonneg _ + have hx₂ : 0 ≤ x₂ := Real.sqrt_nonneg _ + have hx₁sq : x₁ ^ 2 = length ^ 2 - h₁ ^ 2 := Real.sq_sqrt hr₁ + have hx₂sq : x₂ ^ 2 = length ^ 2 - h₂ ^ 2 := Real.sq_sqrt hr₂ + have hx₁lo : 1 / 2 ≤ x₁ := by nlinarith + have hx₂lo : 1 / 2 ≤ x₂ := by nlinarith + have hx₁hi : x₁ ≤ 2 := by nlinarith + have hx₂hi : x₂ ≤ 2 := by nlinarith + have hxx : x₂ ≤ x₁ := by + nlinarith [mul_nonneg (sub_nonneg.mpr hh) (add_nonneg h₁0 h₂0)] + have hid : (x₁ - x₂) * (x₁ + x₂) = (h₂ - h₁) * (h₁ + h₂) := by nlinarith + change (h₂ - h₁) / 5 ≤ x₁ - x₂ ∧ x₁ - x₂ ≤ 2 * (h₂ - h₁) + constructor + · nlinarith [mul_nonneg (sub_nonneg.mpr hxx) + (show 0 ≤ 4 - (x₁ + x₂) by linarith), + mul_nonneg (sub_nonneg.mpr hh) (show 0 ≤ h₁ + h₂ - 4 / 5 by linarith)] + · nlinarith [mul_nonneg (sub_nonneg.mpr hxx) + (show 0 ≤ x₁ + x₂ - 1 by linarith), + mul_nonneg (sub_nonneg.mpr hh) (show 0 ≤ 2 - (h₁ + h₂) by linarith)] + +theorem adjustedContactSpan_broad_slope {h₁ h₂ : ℝ} + (hh₁ : 2 / 5 ≤ h₁) (hh : h₁ ≤ h₂) (hh₂ : h₂ ≤ 3 / 4) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) : + (h₂ - h₁) / 2 ≤ adjustedContactSpan lengths h₁ - adjustedContactSpan lengths h₂ ∧ + adjustedContactSpan lengths h₁ - adjustedContactSpan lengths h₂ ≤ 8 * (h₂ - h₁) := by + have hf (k : ℕ) (hk : k < 9) := adjustedContactForward_slope + (show 99 / 100 ≤ lengths k by have := hl k hk; norm_num [contactLengthTolerance] at this ⊢; linarith) + (show lengths k ≤ 101 / 100 by have := hl' k hk; norm_num [contactLengthTolerance] at this ⊢; linarith) + hh₁ hh hh₂ + have hf₂ := hf 2 (by norm_num) + have hf₃ := hf 3 (by norm_num) + have hf₅ := hf 5 (by norm_num) + have hf₆ := hf 6 (by norm_num) + norm_num [adjustedContactSpan, Finset.sum_range_succ, adjustedContactStepX] + constructor <;> linarith [hf₂.1, hf₂.2, hf₃.1, hf₃.2, hf₅.1, hf₅.2, hf₆.1, hf₆.2] + +theorem adjustedContactSpan_slope {c h₁ h₂ : ℝ} + (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh₁ : h₁ ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (hh₂ : h₂ ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) (hh : h₁ ≤ h₂) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) : + (h₂ - h₁) / 2 ≤ adjustedContactSpan lengths h₁ - adjustedContactSpan lengths h₂ ∧ + adjustedContactSpan lengths h₁ - adjustedContactSpan lengths h₂ ≤ 8 * (h₂ - h₁) := + adjustedContactSpan_broad_slope (contactHeight_interval_bounds hc hc' hh₁).1 hh + (contactHeight_interval_bounds hc hc' hh₂).2 lengths hl hl' + +theorem adjustedContactSpan_broad_inverse_error {h h₀ span : ℝ} + (hh : h ∈ Set.Icc (2 / 5) (3 / 4)) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) + (hroot : adjustedContactSpan lengths h₀ = span) : + |h - h₀| ≤ 2 * |adjustedContactSpan lengths h - span| := by + rcases le_total h h₀ with hle | hle + · have hs := (adjustedContactSpan_broad_slope hh.1 hle hh₀.2 lengths hl hl').1 + rw [hroot] at hs + have hx : 0 ≤ adjustedContactSpan lengths h - span := by linarith + rw [abs_of_nonpos (sub_nonpos.mpr hle), abs_of_nonneg hx] + linarith + · have hs := (adjustedContactSpan_broad_slope hh₀.1 hle hh.2 lengths hl hl').1 + rw [hroot] at hs + have hx : adjustedContactSpan lengths h - span ≤ 0 := by linarith + rw [abs_of_nonneg (sub_nonneg.mpr hle), abs_of_nonpos hx] + linarith + +theorem adjustedContactSpan_inverse_error {c h h₀ span : ℝ} + (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (hh : h ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (hh₀ : h₀ ∈ Set.Icc (contactHeightLow c) (contactHeightHigh c)) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) + (hroot : adjustedContactSpan lengths h₀ = span) : + |h - h₀| ≤ 2 * |adjustedContactSpan lengths h - span| := + adjustedContactSpan_broad_inverse_error (contactHeight_interval_bounds hc hc' hh) + (contactHeight_interval_bounds hc hc' hh₀) lengths hl hl' hroot + +theorem adjustedContactSpan_broad_lipschitz {h h' : ℝ} + (hh : h ∈ Set.Icc (2 / 5) (3 / 4)) (hh' : h' ∈ Set.Icc (2 / 5) (3 / 4)) + (lengths : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ lengths k) + (hl' : ∀ k < 9, lengths k ≤ 1 + contactLengthTolerance) : + |adjustedContactSpan lengths h - adjustedContactSpan lengths h'| ≤ 8 * |h - h'| := by + rcases le_total h h' with hle | hle + · obtain ⟨hlower, hupper⟩ := adjustedContactSpan_broad_slope hh.1 hle hh'.2 lengths hl hl' + have hs : 0 ≤ adjustedContactSpan lengths h - adjustedContactSpan lengths h' := by linarith + rw [abs_of_nonneg hs, abs_of_nonpos (sub_nonpos.mpr hle)] + linarith + · obtain ⟨hlower, hupper⟩ := adjustedContactSpan_broad_slope hh'.1 hle hh.2 lengths hl hl' + have hs : adjustedContactSpan lengths h - adjustedContactSpan lengths h' ≤ 0 := by linarith + rw [abs_of_nonpos hs, abs_of_nonneg (sub_nonneg.mpr hle)] + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..755ae3d2ec8f87ff791101a776a1b9252a4ade00 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactHeightEvaluation.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationBudget + +namespace OAI + +/-! A concrete rational evaluator for the one-dimensional height residual. +There are exactly four dyadic square-root calls; all other terms are exact. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactHeightEvaluation + +abbrev Environment := ℕ × (List ℚ × ℚ) + +def lengthAt (e : Environment) (k : ℕ) : ℚ := (e.2.1.drop k).headD 1 + +def rootSample (e : Environment) (h : ℚ) (k : ℕ) : ℚ := + RationalSquareRoot.value (CalibratedEvaluation.rootPrecision e.1, (lengthAt e k) ^ 2 - h ^ 2) + +def value (e : Environment) (h : ℚ) : ℚ := + lengthAt e 0 + lengthAt e 1 + lengthAt e 4 + lengthAt e 7 + lengthAt e 8 + + rootSample e h 2 + rootSample e h 3 + rootSample e h 5 + rootSample e h 6 - e.2.2 + +def residual (e : Environment) (h : ℝ) : ℝ := + adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h - (e.2.2 : ℝ) + +theorem rootSample_error (e : Environment) (h : ℚ) (k : ℕ) + (hl : 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hh : (h : ℝ) ∈ Set.Icc (2 / 5) (3 / 4)) : + |(rootSample e h k : ℝ) - adjustedContactForward (lengthAt e k) h| ≤ + (2 : ℝ)⁻¹ ^ CalibratedEvaluation.rootPrecision e.1 := by + have hlow : (99 / 100 : ℝ) ≤ lengthAt e k := by + norm_num [contactLengthTolerance] at hl + linarith + have hrad : (0 : ℝ) ≤ (lengthAt e k : ℝ) ^ 2 - (h : ℝ) ^ 2 := by + have hh0 : (0 : ℝ) ≤ h := by linarith [hh.1] + nlinarith [hh.2] + have hradQ : (0 : ℚ) ≤ (lengthAt e k) ^ 2 - h ^ 2 := by exact_mod_cast hrad + have he := RationalSquareRoot.value_error (CalibratedEvaluation.rootPrecision e.1) hradQ + simpa only [rootSample, adjustedContactForward, Rat.cast_sub, Rat.cast_pow] using he + +private theorem four_errors {a b c d E : ℝ} + (ha : |a| ≤ E) (hb : |b| ≤ E) (hc : |c| ≤ E) (hd : |d| ≤ E) : + |a + b + c + d| ≤ 4 * E := by + have h₁ := (abs_add_le a b).trans (add_le_add ha hb) + have h₂ := (abs_add_le c d).trans (add_le_add hc hd) + have h := (abs_add_le (a + b) (c + d)).trans (add_le_add h₁ h₂) + rw [add_assoc (a + b) c d] + exact h.trans_eq (by ring) + +theorem approximation_error (e : Environment) (h : ℚ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hh : (h : ℝ) ∈ Set.Icc (2 / 5) (3 / 4)) : + |(value e h : ℝ) - residual e h| ≤ ((e.1 : ℝ) + 1)⁻¹ := by + have h₂ := rootSample_error e h 2 (hl 2 (by norm_num)) hh + have h₃ := rootSample_error e h 3 (hl 3 (by norm_num)) hh + have h₅ := rootSample_error e h 5 (hl 5 (by norm_num)) hh + have h₆ := rootSample_error e h 6 (hl 6 (by norm_num)) hh + have heq : (value e h : ℝ) - residual e h = + ((rootSample e h 2 : ℝ) - adjustedContactForward (lengthAt e 2) h) + + ((rootSample e h 3 : ℝ) - adjustedContactForward (lengthAt e 3) h) + + ((rootSample e h 5 : ℝ) - adjustedContactForward (lengthAt e 5) h) + + ((rootSample e h 6 : ℝ) - adjustedContactForward (lengthAt e 6) h) := by + norm_num [value, residual, adjustedContactSpan, adjustedContactStepX, + Finset.sum_range_succ, Rat.cast_add, Rat.cast_sub] + ring + rw [heq] + apply (four_errors h₂ h₃ h₅ h₆).trans + have hb := mul_le_mul_of_nonneg_left (CalibratedEvaluation.root_budget e.1) + (show (0 : ℝ) ≤ 4 by norm_num) + convert hb using 1 + field_simp [show (e.1 : ℝ) + 1 ≠ 0 by positivity] + +end ContinuumCoulomb.ContactHeightEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactLattice.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c21b125adabed2e8b5b16c0af660d22a925d6b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactLattice.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactBaseSeparation + +namespace OAI + +/-! The actual gadget sites fit the common lattice strips. Together with +ContactStrips, this separates distinct edges without a size-dependent loss. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem contactPoint_eta (p : ContactPoint) : contactPoint (p 0) (p 1) = p := by + ext i + fin_cases i <;> rfl + +/-- Every base-gadget site other than the two original vertices belongs to +the uniform internal strip. -/ +theorem contactBaseGadget_internal_strip (negative : Bool) (x : ContactGadgetSite) + (hleft : x ≠ Sum.inl 0) (hright : x ≠ contactGadgetRightNode negative 9) : + ∃ p : ContactStripSite, + contactBaseGadgetPosition negative x = contactPoint p.axial p.transverse := by + have hs := contactGadgetSlope_bounds negative + rcases x with i | (i | ⟨⟩) + · have hi : 1 ≤ i.val := by + have hv : i.val ≠ 0 := fun h => hleft (congrArg Sum.inl (Fin.ext h)) + omega + let p := leftContactStripSite (contactGadgetSlope negative) hs.1 hs.2 i.val hi + (show i.val ≤ 9 by have := i.isLt; omega) + exact ⟨p, (contactPoint_eta (contactPathVertex (contactGadgetSlope negative) i.val)).symm⟩ + · have hi8 : i.val ≠ 8 := by + intro h + have hi : i = 8 := Fin.ext h + subst i + apply hright + norm_num [contactGadgetRightNode] + have hi : i.val + 1 ≤ 8 := by have := i.isLt; omega + have horigin : contactGadgetRightOrigin negative 1 + (5 + 4 * contactGadgetSlope negative) = 17 := by + cases negative <;> norm_num [contactGadgetRightOrigin, contactGadgetSlope] + let p := rightContactStripSite (contactGadgetSlope negative) (contactGadgetRightOrigin negative 1) + hs.1 hs.2 horigin (i.val + 1) (by omega) hi + refine ⟨p, ?_⟩ + change contactPoint (contactGadgetRightOrigin negative 1) 0 + + contactPathVertex (contactGadgetSlope negative) (i.val + 1) = + contactPoint (contactGadgetRightOrigin negative 1 + + contactPathVertex (contactGadgetSlope negative) (i.val + 1) 0) + (contactPathVertex (contactGadgetSlope negative) (i.val + 1) 1) + ext j + fin_cases j <;> simp [contactPoint, PiLp.add_apply] + · cases negative + · let p : ContactStripSite := { + axial := 9 + transverse := 0 + axial_lower := by norm_num + axial_upper := by norm_num + transverse_lower := by norm_num + transverse_upper := by norm_num + off_axis_lower := by intro h; exact False.elim (h rfl) + off_axis_upper := by intro h; exact False.elim (h rfl) } + exact ⟨p, rfl⟩ + · let p : ContactStripSite := { + axial := 17 / 2 + transverse := 1 + axial_lower := by norm_num + axial_upper := by norm_num + transverse_lower := by norm_num + transverse_upper := by norm_num + off_axis_lower := by intro _; norm_num + off_axis_upper := by intro _; norm_num } + exact ⟨p, rfl⟩ + +/-- Perpendicular-edge separation persists for the actual adjusted nodes. -/ +theorem perpendicularContact_perturbed_separation (a b c d : ℤ) (p q : ContactStripSite) + (x y : ContactPoint) (hx : dist (horizontalContact a b p) x ≤ 1 / 20) + (hy : dist (verticalContact c d q) y ≤ 1 / 20) : 6 / 5 < dist x y := + contact_separation_stable _ _ _ _ (perpendicularContact_separation a b c d p q).le hx hy + +/-- Parallel-edge separation persists with the same fixed margin. -/ +theorem horizontalContact_perturbed_separation (a b c d : ℤ) + (hne : (a, b) ≠ (c, d)) (p q : ContactStripSite) + (x y : ContactPoint) (hx : dist (horizontalContact a b p) x ≤ 1 / 20) + (hy : dist (horizontalContact c d q) y ≤ 1 / 20) : 6 / 5 < dist x y := + contact_separation_stable _ _ _ _ (horizontalContact_separation a b c d hne p q).le hx hy + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediator.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediator.lean new file mode 100644 index 0000000000000000000000000000000000000000..da43885c05142d5bc68507cec37d31c53a63ded5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediator.lean @@ -0,0 +1,399 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorIteration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGadgetStability + +namespace OAI + +/-! Explicit labels for the eighteen fresh sites of each three-stage +mediator gadget. These identify the actual iterated graph with the +nineteen-link contact geometry, rather than only matching their counts. -/ + +namespace ContinuumCoulomb.ContactMediator +open MediatorGraph MediatorIteration + +abbrev LocalPath := Fin 2 ⊕ (Fin 2 × Fin 2) +abbrev LocalInternal := Fin 2 ⊕ ((Fin 2 × Fin 2) ⊕ (LocalPath × Fin 2)) +abbrev LocalSite := Fin 2 ⊕ LocalInternal + +def spokeIndex (r : ℕ) (e : Fin r) (s : Fin 2) : Fin (r * 2) := + finProdFinEquiv (e, s) + +def pathIndex (r : ℕ) (e : Fin r) : LocalPath → Fin (r * 2 + r * 2 * 2) + | Sum.inl s => finSumFinEquiv (Sum.inl (spokeIndex r e s)) + | Sum.inr (s, t) => finSumFinEquiv (Sum.inr (spokeIndex (r * 2) (spokeIndex r e s) t)) + +def decodePath (r : ℕ) (a : Fin (r * 2 + r * 2 * 2)) : Fin r × LocalPath := + match finSumFinEquiv.symm a with + | Sum.inl a => + let es := finProdFinEquiv.symm a + (es.1, Sum.inl es.2) + | Sum.inr a => + let st := finProdFinEquiv.symm a + let es := finProdFinEquiv.symm st.1 + (es.1, Sum.inr (es.2, st.2)) + +def pathEquiv (r : ℕ) : Fin r × LocalPath ≃ Fin (r * 2 + r * 2 * 2) where + toFun x := pathIndex r x.1 x.2 + invFun := decodePath r + left_inv := by + rintro ⟨e, s | ⟨s, t⟩⟩ <;> simp [pathIndex, decodePath, spokeIndex] + right_inv := by + intro a + obtain ⟨a, rfl⟩ := finSumFinEquiv.surjective a + cases a with + | inl a => + obtain ⟨⟨e, s⟩, rfl⟩ := finProdFinEquiv.surjective a + simp [pathIndex, decodePath, spokeIndex] + | inr a => + obtain ⟨⟨a, t⟩, rfl⟩ := finProdFinEquiv.surjective a + obtain ⟨⟨e, s⟩, rfl⟩ := finProdFinEquiv.surjective a + simp [pathIndex, decodePath, spokeIndex] + +@[simp] theorem decodePath_pathIndex (r : ℕ) (e : Fin r) (p : LocalPath) : + decodePath r (pathIndex r e p) = (e, p) := + (pathEquiv r).symm_apply_apply (e, p) + +@[simp] theorem finProd_divNat {m n : ℕ} (a : Fin m) (b : Fin n) : + (finProdFinEquiv (a, b)).divNat = a := + congrArg Prod.fst ((finProdFinEquiv : Fin m × Fin n ≃ Fin (m * n)).symm_apply_apply (a, b)) + +@[simp] theorem finProd_modNat {m n : ℕ} (a : Fin m) (b : Fin n) : + (finProdFinEquiv (a, b)).modNat = b := + congrArg Prod.snd ((finProdFinEquiv : Fin m × Fin n ≃ Fin (m * n)).symm_apply_apply (a, b)) + +def encodeSite (n r : ℕ) : Fin n ⊕ (Fin r × LocalInternal) → + Fin (n + r * 2 + r * 2 * 2 + (r * 2 + r * 2 * 2) * 2) + | Sum.inl i => old _ _ (old _ _ (old n r i)) + | Sum.inr (e, Sum.inl s) => old _ _ (old _ _ (fresh n r e s)) + | Sum.inr (e, Sum.inr (Sum.inl (s, t))) => + old _ _ (fresh (n + r * 2) (r * 2) (spokeIndex r e s) t) + | Sum.inr (e, Sum.inr (Sum.inr (p, t))) => + fresh (n + r * 2 + r * 2 * 2) (r * 2 + r * 2 * 2) (pathIndex r e p) t + +def decodeSite (n r : ℕ) + (k : Fin (n + r * 2 + r * 2 * 2 + (r * 2 + r * 2 * 2) * 2)) : + Fin n ⊕ (Fin r × LocalInternal) := + match (vertexEquiv (n + r * 2 + r * 2 * 2) (r * 2 + r * 2 * 2)).symm k with + | Sum.inl k => + match (vertexEquiv (n + r * 2) (r * 2)).symm k with + | Sum.inl k => + match (vertexEquiv n r).symm k with + | Sum.inl i => Sum.inl i + | Sum.inr (e, s) => Sum.inr (e, Sum.inl s) + | Sum.inr (a, t) => + let es := finProdFinEquiv.symm a + Sum.inr (es.1, Sum.inr (Sum.inl (es.2, t))) + | Sum.inr (a, t) => + match finSumFinEquiv.symm a with + | Sum.inl a => + let es := finProdFinEquiv.symm a + Sum.inr (es.1, Sum.inr (Sum.inr (Sum.inl es.2, t))) + | Sum.inr a => + let st := finProdFinEquiv.symm a + let es := finProdFinEquiv.symm st.1 + Sum.inr (es.1, Sum.inr (Sum.inr (Sum.inr (es.2, st.2), t))) + +theorem decode_encode (n r : ℕ) (x : Fin n ⊕ (Fin r × LocalInternal)) : + decodeSite n r (encodeSite n r x) = x := by + rcases x with i | ⟨e, s | (st | ⟨p, t⟩)⟩ + · simp [encodeSite, decodeSite, old] + · simp [encodeSite, decodeSite, old, fresh] + · rcases st with ⟨s, t⟩ + simp [encodeSite, decodeSite, old, fresh, spokeIndex] + · cases p with + | inl s => simp [encodeSite, decodeSite, fresh, pathIndex, spokeIndex] + | inr st => + rcases st with ⟨s, u⟩ + simp [encodeSite, decodeSite, fresh, pathIndex, spokeIndex] + +theorem encode_decode (n r : ℕ) + (k : Fin (n + r * 2 + r * 2 * 2 + (r * 2 + r * 2 * 2) * 2)) : + encodeSite n r (decodeSite n r k) = k := by + obtain ⟨k, rfl⟩ := (vertexEquiv (n + r * 2 + r * 2 * 2) + (r * 2 + r * 2 * 2)).surjective k + rcases k with k | ⟨a, t⟩ + · obtain ⟨k, rfl⟩ := (vertexEquiv (n + r * 2) (r * 2)).surjective k + rcases k with k | ⟨a, t⟩ + · obtain ⟨k, rfl⟩ := (vertexEquiv n r).surjective k + rcases k with i | ⟨e, s⟩ + · simp [encodeSite, decodeSite, old] + · simp [encodeSite, decodeSite, old, fresh] + · obtain ⟨⟨e, s⟩, rfl⟩ := finProdFinEquiv.surjective a + simp [encodeSite, decodeSite, old, fresh, spokeIndex] + · obtain ⟨a, rfl⟩ := finSumFinEquiv.surjective a + cases a with + | inl a => + obtain ⟨⟨e, s⟩, rfl⟩ := finProdFinEquiv.surjective a + simp [encodeSite, decodeSite, fresh, pathIndex, spokeIndex] + | inr a => + obtain ⟨⟨a, u⟩, rfl⟩ := finProdFinEquiv.surjective a + obtain ⟨⟨e, s⟩, rfl⟩ := finProdFinEquiv.surjective a + simp [encodeSite, decodeSite, fresh, pathIndex, spokeIndex] + +def siteEquiv (n r : ℕ) : Fin n ⊕ (Fin r × LocalInternal) ≃ + Fin (n + r * 2 + r * 2 * 2 + (r * 2 + r * 2 * 2) * 2) where + toFun := encodeSite n r + invFun := decodeSite n r + left_inv := decode_encode n r + right_inv := encode_decode n r + +def localToContact : LocalSite → ContactGadgetSite + | Sum.inl s => if s = 0 then Sum.inl 0 else Sum.inr (Sum.inl 8) + | Sum.inr (Sum.inl s) => if s = 0 then Sum.inl 9 else contactGadgetSide + | Sum.inr (Sum.inr (Sum.inl (s, t))) => + if s = 0 then Sum.inl (if t = 0 then 3 else 6) + else Sum.inr (Sum.inl (if t = 0 then 5 else 2)) + | Sum.inr (Sum.inr (Sum.inr (Sum.inl s, t))) => + if s = 0 then Sum.inl (if t = 0 then 4 else 5) + else Sum.inr (Sum.inl (if t = 0 then 4 else 3)) + | Sum.inr (Sum.inr (Sum.inr (Sum.inr (s, u), t))) => + if s = 0 then Sum.inl (if u = 0 then (if t = 0 then 1 else 2) + else (if t = 0 then 8 else 7)) + else Sum.inr (Sum.inl (if u = 0 then (if t = 0 then 7 else 6) + else (if t = 0 then 0 else 1))) + +def localOld (s : Fin 2) : LocalSite := Sum.inl s +def localFirst (s : Fin 2) : LocalSite := Sum.inr (Sum.inl s) +def localSecond (s t : Fin 2) : LocalSite := Sum.inr (Sum.inr (Sum.inl (s, t))) +def localThird (p : LocalPath) (t : Fin 2) : LocalSite := + Sum.inr (Sum.inr (Sum.inr (p, t))) + +def contactToLocal : ContactGadgetSite → LocalSite + | Sum.inl i => ![localOld 0, + localThird (Sum.inr (0, 0)) 0, localThird (Sum.inr (0, 0)) 1, + localSecond 0 0, localThird (Sum.inl 0) 0, localThird (Sum.inl 0) 1, + localSecond 0 1, localThird (Sum.inr (0, 1)) 1, + localThird (Sum.inr (0, 1)) 0, localFirst 0] i + | Sum.inr (Sum.inl i) => ![localThird (Sum.inr (1, 1)) 0, + localThird (Sum.inr (1, 1)) 1, localSecond 1 1, + localThird (Sum.inl 1) 1, localThird (Sum.inl 1) 0, + localSecond 1 0, localThird (Sum.inr (1, 0)) 1, + localThird (Sum.inr (1, 0)) 0, localOld 1] i + | Sum.inr (Sum.inr _) => localFirst 1 + +theorem contact_local_inverse (x : LocalSite) : contactToLocal (localToContact x) = x := by + rcases x with s | (s | (⟨s, t⟩ | ⟨p, t⟩)) + · fin_cases s <;> rfl + · fin_cases s <;> rfl + · fin_cases s <;> fin_cases t <;> rfl + · cases p with + | inl s => fin_cases s <;> fin_cases t <;> rfl + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> fin_cases t <;> rfl + +theorem local_contact_inverse (x : ContactGadgetSite) : localToContact (contactToLocal x) = x := by + rcases x with i | (i | ⟨⟩) + · fin_cases i <;> rfl + · fin_cases i <;> rfl + · rfl + +def localContactEquiv : LocalSite ≃ ContactGadgetSite where + toFun := localToContact + invFun := contactToLocal + left_inv := contact_local_inverse + right_inv := local_contact_inverse + +def localVertex {n r : ℕ} (a b : Fin n) (e : Fin r) : LocalSite → + Fin (n + r * 2 + r * 2 * 2 + (r * 2 + r * 2 * 2) * 2) := + fun x => siteEquiv n r (Sum.elim + (fun s => Sum.inl (if s = 0 then a else b)) (fun u => Sum.inr (e, u)) x) + +theorem localVertex_injective {n r : ℕ} (a b : Fin n) (e : Fin r) (hab : a ≠ b) : + Function.Injective (localVertex a b e) := by + intro x y h + have h' := (siteEquiv n r).injective h + cases x with + | inl s => + cases y with + | inl t => + fin_cases s <;> fin_cases t <;> simp_all [localVertex] + | inr t => simp at h' + | inr s => + cases y with + | inl t => simp at h' + | inr t => + exact congrArg Sum.inr (Prod.mk.inj (Sum.inr.inj h')).2 + +abbrev LocalEdge := Unit ⊕ (LocalPath ⊕ (LocalPath × Fin 2)) + +def encodeEdge (r : ℕ) (e : Fin r) : LocalEdge → + Fin (r + ((r * 2 + r * 2 * 2) + (r * 2 + r * 2 * 2) * 2)) + | Sum.inl _ => finSumFinEquiv (Sum.inl e) + | Sum.inr (Sum.inl p) => + finSumFinEquiv (Sum.inr (finSumFinEquiv (Sum.inl (pathIndex r e p)))) + | Sum.inr (Sum.inr (p, t)) => + finSumFinEquiv (Sum.inr (finSumFinEquiv + (Sum.inr (spokeIndex (r * 2 + r * 2 * 2) (pathIndex r e p) t)))) + +def decodeEdge (r : ℕ) + (a : Fin (r + ((r * 2 + r * 2 * 2) + (r * 2 + r * 2 * 2) * 2))) : + Fin r × LocalEdge := + match finSumFinEquiv.symm a with + | Sum.inl e => (e, Sum.inl ()) + | Sum.inr a => + match finSumFinEquiv.symm a with + | Sum.inl a => + let ep := (pathEquiv r).symm a + (ep.1, Sum.inr (Sum.inl ep.2)) + | Sum.inr a => + let pt := finProdFinEquiv.symm a + let ep := (pathEquiv r).symm pt.1 + (ep.1, Sum.inr (Sum.inr (ep.2, pt.2))) + +def edgeEquiv (r : ℕ) : Fin r × LocalEdge ≃ + Fin (r + ((r * 2 + r * 2 * 2) + (r * 2 + r * 2 * 2) * 2)) where + toFun x := encodeEdge r x.1 x.2 + invFun := decodeEdge r + left_inv := by + rintro ⟨e, ⟨⟩ | (p | ⟨p, t⟩)⟩ + · simp [encodeEdge, decodeEdge] + · change decodeEdge r (finSumFinEquiv (Sum.inr + (finSumFinEquiv (Sum.inl (pathEquiv r (e, p)))))) = _ + simp [decodeEdge] + · change decodeEdge r (finSumFinEquiv (Sum.inr (finSumFinEquiv + (Sum.inr (spokeIndex (r * 2 + r * 2 * 2) (pathEquiv r (e, p)) t))))) = _ + simp [decodeEdge, spokeIndex] + right_inv := by + intro a + obtain ⟨a, rfl⟩ := finSumFinEquiv.surjective a + cases a with + | inl e => simp [encodeEdge, decodeEdge] + | inr a => + obtain ⟨a, rfl⟩ := finSumFinEquiv.surjective a + cases a with + | inl a => + obtain ⟨⟨e, p⟩, rfl⟩ := (pathEquiv r).surjective a + simp [encodeEdge, decodeEdge]; rfl + | inr a => + obtain ⟨⟨a, t⟩, rfl⟩ := finProdFinEquiv.surjective a + obtain ⟨⟨e, p⟩, rfl⟩ := (pathEquiv r).surjective a + simp [encodeEdge, decodeEdge, spokeIndex]; rfl + +def firstAttachment (member : Fin 2) (s : Fin 2) : Fin 2 := + if s = 0 then 0 else member + +def secondEndpoint (member : Fin 2) (p : LocalPath) (t : Fin 2) : LocalSite := + match p with + | Sum.inl s => localSecond s t + | Sum.inr (s, u) => if t = 0 then + (if u = 0 then localOld s else localFirst (firstAttachment member s)) + else localSecond s u + +def localLeft (member : Fin 2) : LocalEdge → LocalSite + | Sum.inl _ => localFirst 0 + | Sum.inr (Sum.inl p) => localThird p 0 + | Sum.inr (Sum.inr (p, t)) => secondEndpoint member p t + +def localRight : LocalEdge → LocalSite + | Sum.inl _ => localFirst 1 + | Sum.inr (Sum.inl p) => localThird p 1 + | Sum.inr (Sum.inr (p, t)) => localThird p t + +theorem localEdge_contactLinked (negative : Bool) (e : LocalEdge) : + contactGadgetLinked negative + (localToContact (localLeft (if negative then 0 else 1) e)) + (localToContact (localRight e)) := by + rcases e with ⟨⟩ | (p | ⟨p, t⟩) + · cases negative <;> norm_num [contactGadgetLinked, localToContact, localLeft, localRight, + secondEndpoint, firstAttachment, localFirst, localSecond, localOld, localThird, + contactGadgetSide, Nat.dist] + · cases p with + | inl s => fin_cases s <;> cases negative <;> norm_num [contactGadgetLinked, localToContact, localLeft, localRight, + secondEndpoint, firstAttachment, localFirst, localSecond, localOld, localThird, + contactGadgetSide, Nat.dist] + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> cases negative <;> norm_num [contactGadgetLinked, localToContact, localLeft, localRight, + secondEndpoint, firstAttachment, localFirst, localSecond, localOld, localThird, + contactGadgetSide, Nat.dist] + · cases p with + | inl s => fin_cases s <;> fin_cases t <;> cases negative <;> norm_num [contactGadgetLinked, localToContact, localLeft, localRight, + secondEndpoint, firstAttachment, localFirst, localSecond, localOld, localThird, + contactGadgetSide, Nat.dist] + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> fin_cases t <;> cases negative <;> norm_num [contactGadgetLinked, localToContact, localLeft, localRight, + secondEndpoint, firstAttachment, localFirst, localSecond, localOld, localThird, + contactGadgetSide, Nat.dist] + +theorem spoke_nonneg (r W G : ℕ) (J : ℚ) : 0 ≤ MediatorParameters.spoke r W G J := by + unfold MediatorParameters.spoke DyadicRootProgram.value + positivity + +theorem member_spoke (r W G : ℕ) (J : ℚ) : + member (MediatorParameters.spoke r W G J) = 1 := by + simp only [member, not_lt.mpr (spoke_nonneg r W G J), ite_false] + +theorem member_nat (N : ℕ) : member (N : ℚ) = 1 := by + simp [member] + +theorem member_secondPath {n r : ℕ} (F : Bonds n r) (W G : ℕ) + (e : Fin r) (p : LocalPath) : + member ((secondPaths F W G).weight (pathIndex r e p)) = 1 := by + cases p with + | inl s => + simp [secondPaths, join, secondCentral, central, pathIndex, member_nat] + | inr st => + rcases st with ⟨s, t⟩ + simp [secondPaths, join, secondSpokes, spokes, pathIndex, spokeIndex, member_spoke] + +/-- Every left endpoint of the actual three-stage graph has the explicit +local gadget label. This identity retains the original edge index. -/ +theorem finalGraph_left {n r : ℕ} (F : Bonds n r) (W G : ℕ) + (e : Fin r) (a : LocalEdge) : + (finalGraph F W G).left (encodeEdge r e a) = + localVertex (F.left e) (F.right e) e (localLeft (member (F.weight e)) a) := by + rcases a with ⟨⟩ | (p | ⟨p, t⟩) + · simp [finalGraph, encodeEdge, join, lift, retainedCentral, firstCentral, central, + localVertex, localLeft, localFirst, siteEquiv, encodeSite] + · simp [finalGraph, encodeEdge, join, thirdCentral, central, + localVertex, localLeft, localThird, siteEquiv, encodeSite] + · cases p with + | inl s => + fin_cases s <;> fin_cases t <;> + simp [finalGraph, encodeEdge, join, thirdSpokes, spokes, secondPaths, secondCentral, + central, pathIndex, spokeIndex, localVertex, localLeft, secondEndpoint, + localSecond, siteEquiv, encodeSite] + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> fin_cases t <;> + simp [finalGraph, encodeEdge, join, thirdSpokes, spokes, secondPaths, secondSpokes, + firstSpokes, pathIndex, spokeIndex, member_spoke, localVertex, localLeft, + secondEndpoint, firstAttachment, localOld, localFirst, localSecond, siteEquiv, + encodeSite] + +/-- The matching right-endpoint identity uses the proved nonnegativity of +the actual rounded spokes, so later subdivisions always use member one. -/ +theorem finalGraph_right {n r : ℕ} (F : Bonds n r) (W G : ℕ) + (e : Fin r) (a : LocalEdge) : + (finalGraph F W G).right (encodeEdge r e a) = + localVertex (F.left e) (F.right e) e (localRight a) := by + rcases a with ⟨⟩ | (p | ⟨p, t⟩) + · simp [finalGraph, encodeEdge, join, lift, retainedCentral, firstCentral, central, + localVertex, localRight, localFirst, siteEquiv, encodeSite] + · simp [finalGraph, encodeEdge, join, thirdCentral, central, + localVertex, localRight, localThird, siteEquiv, encodeSite] + · have hm := member_secondPath F W G e p + fin_cases t <;> + simp [finalGraph, encodeEdge, join, thirdSpokes, spokes, spokeIndex, hm, + localVertex, localRight, localThird, siteEquiv, encodeSite] + +def edgeNegative {n r : ℕ} (F : Bonds n r) (e : Fin r) : Bool := decide (F.weight e < 0) + +theorem member_edgeNegative {n r : ℕ} (F : Bonds n r) (e : Fin r) : + member (F.weight e) = if edgeNegative F e then 0 else 1 := by + simp [member, edgeNegative] + +/-- The entire actual final edge enumeration, not just a graph with the +same cardinality, is carried to the nineteen physical contact links. -/ +theorem finalGraph_contact_links {n r : ℕ} (F : Bonds n r) (_W _G : ℕ) + (e : Fin r) (a : LocalEdge) : + contactGadgetLinked (edgeNegative F e) + (localToContact (localLeft (member (F.weight e)) a)) + (localToContact (localRight a)) := by + rw [member_edgeNegative] + exact localEdge_contactLinked (edgeNegative F e) a + +end ContinuumCoulomb.ContactMediator + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f9daa3c512f6a06c53c62940d9aa3e7337530b3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorGeometry.lean @@ -0,0 +1,157 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediator + +namespace OAI + +/-! Independent prescribed lengths for the exact nineteen local edges +identified with the actual iterated mediator graph. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactMediator + +abbrev ContactEdge := Fin 9 ⊕ (Unit ⊕ Fin 9) + +def leftEdge (k : Fin 9) : LocalEdge := + ![Sum.inr (Sum.inr (Sum.inr (0, 0), 0)), + Sum.inr (Sum.inl (Sum.inr (0, 0))), + Sum.inr (Sum.inr (Sum.inr (0, 0), 1)), + Sum.inr (Sum.inr (Sum.inl 0, 0)), + Sum.inr (Sum.inl (Sum.inl 0)), + Sum.inr (Sum.inr (Sum.inl 0, 1)), + Sum.inr (Sum.inr (Sum.inr (0, 1), 1)), + Sum.inr (Sum.inl (Sum.inr (0, 1))), + Sum.inr (Sum.inr (Sum.inr (0, 1), 0))] k + +def rightEdge (k : Fin 9) : LocalEdge := + ![Sum.inr (Sum.inr (Sum.inr (1, 1), 0)), + Sum.inr (Sum.inl (Sum.inr (1, 1))), + Sum.inr (Sum.inr (Sum.inr (1, 1), 1)), + Sum.inr (Sum.inr (Sum.inl 1, 1)), + Sum.inr (Sum.inl (Sum.inl 1)), + Sum.inr (Sum.inr (Sum.inl 1, 0)), + Sum.inr (Sum.inr (Sum.inr (1, 0), 1)), + Sum.inr (Sum.inl (Sum.inr (1, 0))), + Sum.inr (Sum.inr (Sum.inr (1, 0), 0))] k + +def edgeAt : ContactEdge → LocalEdge := + Sum.elim leftEdge (Sum.elim (fun _ => Sum.inl ()) rightEdge) + +def edgeIndex : LocalEdge → ContactEdge + | Sum.inl _ => Sum.inr (Sum.inl ()) + | Sum.inr (Sum.inl (Sum.inl s)) => + if s = 0 then Sum.inl 4 else Sum.inr (Sum.inr 4) + | Sum.inr (Sum.inl (Sum.inr (s, u))) => + if s = 0 then Sum.inl (if u = 0 then 1 else 7) + else Sum.inr (Sum.inr (if u = 0 then 7 else 1)) + | Sum.inr (Sum.inr (Sum.inl s, t)) => + if s = 0 then Sum.inl (if t = 0 then 3 else 5) + else Sum.inr (Sum.inr (if t = 0 then 5 else 3)) + | Sum.inr (Sum.inr (Sum.inr (s, u), t)) => + if s = 0 then Sum.inl (if u = 0 then (if t = 0 then 0 else 2) + else (if t = 0 then 8 else 6)) + else Sum.inr (Sum.inr (if u = 0 then (if t = 0 then 8 else 6) + else (if t = 0 then 0 else 2))) + +def contactEdgeEquiv : ContactEdge ≃ LocalEdge where + toFun := edgeAt + invFun := edgeIndex + left_inv := by + rintro (k | (⟨⟩ | k)) + · fin_cases k <;> rfl + · rfl + · fin_cases k <;> rfl + right_inv := by + rintro (⟨⟩ | (p | ⟨p, t⟩)) + · rfl + · cases p with + | inl s => fin_cases s <;> rfl + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> rfl + · cases p with + | inl s => fin_cases s <;> fin_cases t <;> rfl + | inr su => + rcases su with ⟨s, u⟩ + fin_cases s <;> fin_cases u <;> fin_cases t <;> rfl + +theorem leftEdge_distance (negative : Bool) (G : ContactGadgetSite → ContactPoint) (k : Fin 9) : + dist (G (localToContact (localLeft (if negative then 0 else 1) (leftEdge k)))) + (G (localToContact (localRight (leftEdge k)))) = + dist (G (Sum.inl k.succ)) (G (Sum.inl k.castSucc)) := by + fin_cases k <;> cases negative <;> + simp [leftEdge, localToContact, localLeft, localRight, secondEndpoint, firstAttachment, + localOld, localFirst, localSecond, localThird, dist_comm] <;> first | rfl | exact dist_comm _ _ + +theorem rightEdge_distance (negative : Bool) (G : ContactGadgetSite → ContactPoint) (k : Fin 9) : + dist (G (localToContact (localLeft (if negative then 0 else 1) (rightEdge k)))) + (G (localToContact (localRight (rightEdge k)))) = + dist (G (contactGadgetRightNode negative k.succ)) + (G (contactGadgetRightNode negative k.castSucc)) := by + fin_cases k <;> cases negative <;> + simp [rightEdge, localToContact, localLeft, localRight, secondEndpoint, firstAttachment, + localOld, localFirst, localSecond, localThird, contactGadgetRightNode, contactGadgetSide, + dist_comm] <;> first | rfl | exact dist_comm _ _ + +def pathLengths (ℓ : LocalEdge → ℝ) (edge : Fin 9 → LocalEdge) (k : ℕ) : ℝ := + if hk : k < 9 then ℓ (edge ⟨k, hk⟩) else 1 + +theorem exists_local_geometry (negative : Bool) (ℓ : LocalEdge → ℝ) + (hℓ : ∀ a, ℓ a ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) : + ∃ P : LocalSite → ContactPoint, + P (localOld 0) = contactPoint 0 0 ∧ + P (localOld 1) = contactPoint 17 0 ∧ + (∀ a, dist (P (localLeft (if negative then 0 else 1) a)) (P (localRight a)) = ℓ a) ∧ + (∀ x y, x ≠ y → ¬contactGadgetLinked negative (localToContact x) (localToContact y) → + 6 / 5 < dist (P x) (P y)) ∧ + (∀ x, dist (P x) (contactBaseGadgetPosition negative (localToContact x)) < 1 / 20) := by + let central := ℓ (Sum.inl ()) + let ll := pathLengths ℓ leftEdge + let rr := pathLengths ℓ rightEdge + have hl (k : ℕ) (hk : k < 9) : ll k ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + simpa only [ll, pathLengths, dite_eq_left hk] using hℓ (leftEdge ⟨k, hk⟩) + have hr (k : ℕ) (hk : k < 9) : rr k ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + simpa only [rr, pathLengths, dite_eq_left hk] using hℓ (rightEdge ⟨k, hk⟩) + obtain ⟨lh, rh, hlh, hrh, hls, _, hstart, hend⟩ := + contactGadget_independent_lengths negative (hℓ (Sum.inl ())).1 (hℓ (Sum.inl ())).2 ll rr + (fun k hk => (hl k hk).1) (fun k hk => (hl k hk).2) + (fun k hk => (hr k hk).1) (fun k hk => (hr k hk).2) + let G := contactGadgetPosition negative central ll rr lh rh + let P : LocalSite → ContactPoint := G ∘ localToContact + have hlinks := contactGadget_link_lengths negative (hℓ (Sum.inl ())).1 ll rr + (fun k hk => (hl k hk).1) (fun k hk => (hr k hk).1) hlh hrh hls + refine ⟨P, ?_, ?_, ?_, ?_, ?_⟩ + · exact hstart + · simpa [P, G, localToContact, localOld, contactGadgetRightNode] using hend + · intro a + obtain ⟨b, rfl⟩ := contactEdgeEquiv.surjective a + rcases b with k | (⟨⟩ | k) + · change dist (G (localToContact (localLeft _ (leftEdge k)))) + (G (localToContact (localRight (leftEdge k)))) = _ + rw [leftEdge_distance] + change dist (G (Sum.inl k.succ)) (G (Sum.inl k.castSucc)) = ℓ (leftEdge k) + simpa only [G, central, ll, pathLengths, dite_eq_left k.isLt] using hlinks.1 k + · change dist (G (Sum.inl 9)) (G contactGadgetSide) = central + rw [dist_comm] + exact hlinks.2.1 + · change dist (G (localToContact (localLeft _ (rightEdge k)))) + (G (localToContact (localRight (rightEdge k)))) = _ + rw [rightEdge_distance] + change dist (G (contactGadgetRightNode negative k.succ)) + (G (contactGadgetRightNode negative k.castSucc)) = ℓ (rightEdge k) + simpa only [G, central, rr, pathLengths, dite_eq_left k.isLt] using hlinks.2.2 k + · intro x y hxy hlink + exact contactGadget_nonlink_separation negative (hℓ (Sum.inl ())).1 + (hℓ (Sum.inl ())).2 ll rr (fun k hk => (hl k hk).1) (fun k hk => (hl k hk).2) + (fun k hk => (hr k hk).1) (fun k hk => (hr k hk).2) hlh hrh + (localToContact x) (localToContact y) + (fun h => hxy (localContactEquiv.injective h)) hlink + · exact fun x => contactGadgetPosition_near negative (hℓ (Sum.inl ())).1 + (hℓ (Sum.inl ())).2 ll rr (fun k hk => (hl k hk).1) (fun k hk => (hl k hk).2) + (fun k hk => (hr k hk).1) (fun k hk => (hr k hk).2) hlh hrh (localToContact x) + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorLinks.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorLinks.lean new file mode 100644 index 0000000000000000000000000000000000000000..561a3bd6a0bd9a9187cb214f118bd74253b4e6a6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactMediatorLinks.lean @@ -0,0 +1,177 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediatorGeometry + +namespace OAI + +/-! The contact adjacency is exactly the edge relation of the actual +nineteen-link gadget, including the signed central attachment. -/ + +namespace ContinuumCoulomb.ContactMediator +open MediatorIteration + +def samePair {α : Type*} (a b c d : α) : Prop := + (a = c ∧ b = d) ∨ (a = d ∧ b = c) + +theorem samePair_swap_target {α : Type*} {a b c d : α} (h : samePair a b c d) : + samePair a b d c := h.symm + +theorem samePair_trans {α : Type*} {a b c d e f : α} + (h : samePair a b c d) (k : samePair c d e f) : samePair a b e f := by + rcases h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · exact k + · rcases k with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> simp [samePair] + +theorem samePair_map {α β : Type*} (f : α → β) {a b c d : α} + (h : samePair a b c d) : samePair (f a) (f b) (f c) (f d) := by + rcases h with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> simp [samePair] + +def contactPair (negative : Bool) (a : LocalEdge) (x y : ContactGadgetSite) : Prop := + samePair (localToContact (localLeft (if negative then 0 else 1) a)) + (localToContact (localRight a)) x y + +theorem leftEdge_pair (negative : Bool) (k : Fin 9) : + contactPair negative (leftEdge k) (Sum.inl k.castSucc) (Sum.inl k.succ) := by + fin_cases k <;> cases negative <;> norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide] + +theorem rightEdge_pair (negative : Bool) (k : Fin 9) : + contactPair negative (rightEdge k) (contactGadgetRightNode negative k.castSucc) + (contactGadgetRightNode negative k.succ) := by + fin_cases k <;> cases negative <;> norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide] + +private theorem adjacent_indices {n : ℕ} (i j : Fin (n + 1)) (h : Nat.dist i.val j.val = 1) : + ∃ k : Fin n, (i = k.castSucc ∧ j = k.succ) ∨ (i = k.succ ∧ j = k.castSucc) := by + have hi := i.isLt + have hj := j.isLt + unfold Nat.dist at h + by_cases hij : i.val ≤ j.val + · refine ⟨⟨i.val, by omega⟩, Or.inl ⟨Fin.ext rfl, Fin.ext (by dsimp; omega)⟩⟩ + · refine ⟨⟨j.val, by omega⟩, Or.inr ⟨Fin.ext (by dsimp; omega), Fin.ext rfl⟩⟩ + +private theorem left_adjacent_exists (negative : Bool) (i j : Fin 10) + (h : Nat.dist i.val j.val = 1) : + ∃ a, contactPair negative a (Sum.inl i) (Sum.inl j) := by + obtain ⟨k, h | h⟩ := adjacent_indices i j h + · rcases h with ⟨rfl, rfl⟩ + exact ⟨leftEdge k, leftEdge_pair negative k⟩ + · rcases h with ⟨rfl, rfl⟩ + exact ⟨leftEdge k, samePair_swap_target (leftEdge_pair negative k)⟩ + +private theorem right_nodes (negative : Bool) (k : Fin 8) : + contactGadgetRightNode negative k.succ.castSucc = Sum.inr (Sum.inl k.castSucc) ∧ + contactGadgetRightNode negative k.succ.succ = Sum.inr (Sum.inl k.succ) := by + fin_cases k <;> cases negative <;> norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide] + +private theorem right_adjacent_exists (negative : Bool) (i j : Fin 9) + (h : Nat.dist i.val j.val = 1) : + ∃ a, contactPair negative a (Sum.inr (Sum.inl i)) (Sum.inr (Sum.inl j)) := by + obtain ⟨k, h | h⟩ := adjacent_indices i j h + · rcases h with ⟨rfl, rfl⟩ + refine ⟨rightEdge k.succ, ?_⟩ + simpa only [contactPair, (right_nodes negative k).1, (right_nodes negative k).2] using + rightEdge_pair negative k.succ + · rcases h with ⟨rfl, rfl⟩ + refine ⟨rightEdge k.succ, ?_⟩ + apply samePair_swap_target + simpa only [contactPair, (right_nodes negative k).1, (right_nodes negative k).2] using + rightEdge_pair negative k.succ + +theorem contactLinked_exists (negative : Bool) (x y : ContactGadgetSite) + (h : contactGadgetLinked negative x y) : ∃ a, contactPair negative a x y := by + rcases x with i | (i | ⟨⟩) <;> rcases y with j | (j | ⟨⟩) + · exact left_adjacent_exists negative i j h + · rcases h with ⟨rfl, rfl, rfl⟩ + exact ⟨rightEdge 0, by norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide]⟩ + · change i = 9 at h + subst i + refine ⟨Sum.inl (), ?_⟩ + cases negative <;> norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide] + · rcases h with ⟨rfl, rfl, rfl⟩ + exact ⟨rightEdge 0, by norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide]⟩ + · exact right_adjacent_exists negative i j h + · rcases h with ⟨rfl, rfl⟩ + exact ⟨rightEdge 0, by norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide]⟩ + · change j = 9 at h + subst j + refine ⟨Sum.inl (), ?_⟩ + cases negative <;> norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide] + · rcases h with ⟨rfl, rfl⟩ + exact ⟨rightEdge 0, by norm_num [contactPair, samePair, localToContact, localLeft, localRight, + leftEdge, rightEdge, secondEndpoint, firstAttachment, localOld, localFirst, + localSecond, localThird, contactGadgetRightNode, contactGadgetSide]⟩ + · exact False.elim h + +theorem contactLinked_symm (negative : Bool) {x y : ContactGadgetSite} + (h : contactGadgetLinked negative x y) : contactGadgetLinked negative y x := by + rcases x with i | (i | ⟨⟩) <;> rcases y with j | (j | ⟨⟩) <;> + first | exact h | simpa only [contactGadgetLinked, Nat.dist_comm] using h + +theorem contactLinked_iff (negative : Bool) (x y : LocalSite) : + contactGadgetLinked negative (localToContact x) (localToContact y) ↔ + ∃ a, samePair (localLeft (if negative then 0 else 1) a) (localRight a) x y := by + constructor + · intro h + obtain ⟨a, ha⟩ := contactLinked_exists negative (localToContact x) (localToContact y) h + refine ⟨a, ?_⟩ + rcases ha with ⟨hx, hy⟩ | ⟨hx, hy⟩ + · exact Or.inl ⟨localContactEquiv.injective hx, localContactEquiv.injective hy⟩ + · exact Or.inr ⟨localContactEquiv.injective hx, localContactEquiv.injective hy⟩ + · rintro ⟨a, ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩⟩ + · exact localEdge_contactLinked negative a + · exact contactLinked_symm negative (localEdge_contactLinked negative a) + +/-- A contact link is an edge of the actual full graph. Consequently a +nonedge of that graph cannot be an unaccounted local contact. -/ +theorem finalGraph_nonedge_contactNonlink {n r : ℕ} (F : Bonds n r) (W G : ℕ) + (e : Fin r) (x y : LocalSite) + (h : ¬∃ a, samePair ((finalGraph F W G).left a) ((finalGraph F W G).right a) + (localVertex (F.left e) (F.right e) e x) (localVertex (F.left e) (F.right e) e y)) : + ¬contactGadgetLinked (edgeNegative F e) (localToContact x) (localToContact y) := by + intro hc + obtain ⟨a, ha⟩ := (contactLinked_iff (edgeNegative F e) x y).mp hc + rw [← member_edgeNegative F e] at ha + apply h + refine ⟨encodeEdge r e a, ?_⟩ + rw [finalGraph_left, finalGraph_right] + exact samePair_map (localVertex (F.left e) (F.right e) e) ha + +theorem exists_finalGraph_gadget_geometry {n r : ℕ} (F : Bonds n r) (W G : ℕ) + (e : Fin r) + (ℓ : Fin (r + ((r * 2 + r * 2 * 2) + (r * 2 + r * 2 * 2) * 2)) → ℝ) + (hℓ : ∀ a, ℓ a ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) : + ∃ P : LocalSite → ContactPoint, + P (localOld 0) = contactPoint 0 0 ∧ + P (localOld 1) = contactPoint 17 0 ∧ + (∀ a, dist (P (localLeft (member (F.weight e)) a)) (P (localRight a)) = ℓ (encodeEdge r e a)) ∧ + (∀ x y, x ≠ y → + (¬∃ a, samePair ((finalGraph F W G).left a) ((finalGraph F W G).right a) + (localVertex (F.left e) (F.right e) e x) (localVertex (F.left e) (F.right e) e y)) → + 6 / 5 < dist (P x) (P y)) ∧ + (∀ x, dist (P x) (contactBaseGadgetPosition (edgeNegative F e) (localToContact x)) < 1 / 20) := by + obtain ⟨P, h0, h1, hlinks, hnonlinks, hnear⟩ := + exists_local_geometry (edgeNegative F e) (fun a => ℓ (encodeEdge r e a)) + (fun a => hℓ (encodeEdge r e a)) + refine ⟨P, h0, h1, ?_, ?_, hnear⟩ + · intro a + rw [member_edgeNegative] + exact hlinks a + · intro x y hxy h + exact hnonlinks x y hxy (finalGraph_nonedge_contactNonlink F W G e x y h) + +end ContinuumCoulomb.ContactMediator + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPathBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPathBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3052c4b4520f47019140c6ec6a633e8d7364699b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPathBounds.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactStrips + +namespace OAI + +/-! Coordinate bounds for the two explicit paths. These imply the fixed strip +conditions used to separate gadgets throughout an arbitrarily large lattice. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem contactSlopeHeight_bounds {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) : + 0 ≤ contactSlopeHeight c ∧ contactSlopeHeight c ≤ 2 / 3 := by + have hs := contactSlopeHeight_sq (by linarith : -1 ≤ c) (by linarith : c ≤ 1) + have hn : 0 ≤ contactSlopeHeight c := Real.sqrt_nonneg _ + exact ⟨hn, by nlinarith⟩ + +theorem contactPath_transverse_bounds {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + {k : ℕ} (hk : k ≤ 9) : + 0 ≤ contactPathVertex c k 1 ∧ contactPathVertex c k 1 ≤ 4 / 3 := by + have hs := contactSlopeHeight_bounds hc hc' + interval_cases k <;> norm_num [contactPathVertex, Finset.sum_range_succ, contactStepY, + contactPoint] <;> (try constructor) <;> linarith + +theorem contactPath_axial_bounds {c : ℝ} (hc : 3 / 4 ≤ c) (_hc' : c ≤ 7 / 8) + {k : ℕ} (hk : k ≤ 9) : + 0 ≤ contactPathVertex c k 0 ∧ contactPathVertex c k 0 ≤ 5 + 4 * c := by + interval_cases k <;> norm_num [contactPathVertex, Finset.sum_range_succ, contactStepX, + contactPoint] <;> (try constructor) <;> linarith + +theorem contactPath_internal_axial_bounds {c : ℝ} (hc : 3 / 4 ≤ c) (_hc' : c ≤ 7 / 8) + {k : ℕ} (hk : 1 ≤ k) (hk' : k ≤ 8) : + 1 ≤ contactPathVertex c k 0 ∧ contactPathVertex c k 0 ≤ 4 + 4 * c := by + interval_cases k <;> norm_num [contactPathVertex, Finset.sum_range_succ, contactStepX, + contactPoint] <;> (try constructor) <;> linarith + +theorem contactPath_off_axis_bounds {c : ℝ} (hc : 3 / 4 ≤ c) (_hc' : c ≤ 7 / 8) + {k : ℕ} (hk : k ≤ 9) (hy : contactPathVertex c k 1 ≠ 0) : + 11 / 4 ≤ contactPathVertex c k 0 ∧ contactPathVertex c k 0 ≤ 9 / 4 + 4 * c := by + interval_cases k <;> norm_num [contactPathVertex, Finset.sum_range_succ, contactStepY, contactPoint] at hy + all_goals norm_num [contactPathVertex, Finset.sum_range_succ, contactStepX, contactPoint] + all_goals constructor <;> linarith + +/-- Left-path internal sites and its central endpoint satisfy the common +length-17 strip bounds. -/ +def leftContactStripSite (c : ℝ) (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (k : ℕ) (hk : 1 ≤ k) (hk' : k ≤ 9) : ContactStripSite where + axial := contactPathVertex c k 0 + transverse := contactPathVertex c k 1 + axial_lower := by + by_cases h : k = 9 + · subst k + rw [contactPathVertex_end, contactPoint_zero] + linarith + · exact (contactPath_internal_axial_bounds hc hc' hk (by omega)).1 + axial_upper := (contactPath_axial_bounds hc hc' hk').2.trans (by linarith) + transverse_lower := (contactPath_transverse_bounds hc hc' hk').1 + transverse_upper := (contactPath_transverse_bounds hc hc' hk').2 + off_axis_lower := fun h => (contactPath_off_axis_bounds hc hc' hk' h).1 + off_axis_upper := fun h => (contactPath_off_axis_bounds hc hc' hk' h).2.trans (by linarith) + +/-- Right-path internal sites use an origin chosen so their far endpoint is17. -/ +def rightContactStripSite (c origin : ℝ) (hc : 3 / 4 ≤ c) (hc' : c ≤ 7 / 8) + (horigin : origin + (5 + 4 * c) = 17) + (k : ℕ) (hk : 1 ≤ k) (hk' : k ≤ 8) : ContactStripSite where + axial := origin + contactPathVertex c k 0 + transverse := contactPathVertex c k 1 + axial_lower := by + have := (contactPath_internal_axial_bounds hc hc' hk hk').1 + linarith + axial_upper := by + have := (contactPath_internal_axial_bounds hc hc' hk hk').2 + linarith + transverse_lower := (contactPath_transverse_bounds hc hc' (by omega : k ≤ 9)).1 + transverse_upper := (contactPath_transverse_bounds hc hc' (by omega : k ≤ 9)).2 + off_axis_lower := by + intro hy + have := (contactPath_off_axis_bounds hc hc' (by omega : k ≤ 9) hy).1 + linarith + off_axis_upper := by + intro hy + have := (contactPath_off_axis_bounds hc hc' (by omega : k ≤ 9) hy).2 + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPolynomialGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPolynomialGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..31e71fa21b229653cdd01b3b213ed20f92359c3e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPolynomialGeometry.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCalibratedGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SlowLogarithmicExtent + +namespace OAI + +/-! The fixed source spacing and rational precision imply precisely the +separation and spatial growth used by the continuum comparison. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactCalibratedGeometry +open ContactMediator + +theorem precision_ge_7200 {N h : ℕ} (hN : 2 ≤ N) (hh : 13 ≤ h) : 7200 ≤ N^h := by + calc + 7200 ≤ 2^13 := by norm_num + _ ≤ N^13 := Nat.pow_le_pow_left hN 13 + _ ≤ N^h := Nat.pow_le_pow_right (by omega) hh + +theorem planar_norm_le_two (x : ContactPoint) {C : ℝ} (hC : 0 ≤ C) + (hx : ∀ i, |x i| ≤ C) : ‖x‖ ≤ 2*C := by + have hnorm : ‖x‖^2=(x 0)^2+(x 1)^2 := by + rw [EuclideanSpace.norm_sq_eq] + simp only [Fin.sum_univ_two,Real.norm_eq_abs,sq_abs] + have h0 := (sq_le_sq₀ (abs_nonneg (x 0)) hC).mpr (hx 0) + have h1 := (sq_le_sq₀ (abs_nonneg (x 1)) hC).mpr (hx 1) + rw [sq_abs] at h0 h1 + nlinarith [norm_nonneg x,sq_nonneg C] + +theorem polynomial_norm (d : SquareLatticeHeisenberg) {N k s P : ℕ} + (hN : 2 ≤ N) (hk : 1100 ≤ k) {q : ℚ} (hq : 0 < q) + (hqhi : (q:ℝ) ≤ 31*(k:ℝ)*Real.log N) (ℓ : GlobalEdge d → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ e, (ℓ e:ℝ) ∈ Set.Icc (1-contactLengthTolerance) (1+contactLengthTolerance)) + (hcoord : ∀ j i, |(contactGridAxis (d.coordinate j) i:ℝ)| ≤ (N:ℝ)^s) + (x : GlobalSite d) : ‖point d P q ℓ x‖ ≤ (N:ℝ)^(k/100+s+13) := by + have hNR : (2:ℝ) ≤ N := by exact_mod_cast hN + have hc : 0 ≤ (q:ℝ)*(17*(N:ℝ)^s+17) := by positivity + calc + _ ≤ 2*((q:ℝ)*(17*(N:ℝ)^s+17)) := + planar_norm_le_two _ hc (coordinate_bound d P hq ℓ hP hℓ hcoord x) + _ ≤ 2*(31*(k:ℝ)*Real.log N)*(17*(N:ℝ)^s+17) := by + have hm := mul_le_mul_of_nonneg_right hqhi (show 0 ≤ 17*(N:ℝ)^s+17 by positivity) + nlinarith only [hm] + _ ≤ _ := slow_logarithmic_extent k s hk hNR + +theorem spacing_polynomial {N k s : ℕ} (hN : 2 ≤ N) (hk : 1100 ≤ k) + {q : ℝ} (hqhi : q ≤ 31*(k:ℝ)*Real.log N) : q ≤ (N:ℝ)^(k/100+s+13) := by + have hNR : (2:ℝ) ≤ N := by exact_mod_cast hN + have hN1 : (1:ℝ) ≤ N := le_trans (by norm_num) hNR + have hx : 0 ≤ 31*(k:ℝ)*Real.log N := + mul_nonneg (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) (Real.log_nonneg hN1) + have hs := one_le_pow₀ hN1 (n := s) + have hm : 31*(k:ℝ)*Real.log N ≤ 2*(31*(k:ℝ)*Real.log N)*(17*(N:ℝ)^s+17) := by + nlinarith [mul_nonneg hx (show 0 ≤ 34*(N:ℝ)^s+33 by positivity)] + exact hqhi.trans (hm.trans (slow_logarithmic_extent k s hk hNR)) + +theorem polynomial_separation (d : SquareLatticeHeisenberg) (W G P N k : ℕ) + (hN : 2 ≤ N) {q : ℚ} (hq : 0 < q) + (hqlo : (59/2:ℝ)*(k:ℝ)*Real.log N ≤ q) (ℓ : GlobalEdge d → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ e, (ℓ e:ℝ) ∈ Set.Icc (1-contactLengthTolerance) (1+contactLengthTolerance)) + (x y : GlobalSite d) (hxy : x ≠ y) : + 25*(k:ℝ)*Real.log N ≤ ‖point d P q ℓ x-point d P q ℓ y‖ := by + have hs := separation d W G P hq ℓ hP hℓ x y hxy + rw [dist_eq_norm] at hs + have hx : 0 ≤ (k:ℝ)*Real.log N := mul_nonneg (Nat.cast_nonneg _) + (Real.log_nonneg (by exact_mod_cast (show 1 ≤ N by omega))) + nlinarith + +theorem polynomial_nonedge_separation (d : SquareLatticeHeisenberg) (W G P N k : ℕ) + (hN : 2 ≤ N) {q : ℚ} (hq : 0 < q) + (hqlo : (59/2:ℝ)*(k:ℝ)*Real.log N ≤ q) (ℓ : GlobalEdge d → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ e, (ℓ e:ℝ) ∈ Set.Icc (1-contactLengthTolerance) (1+contactLengthTolerance)) + (x y : GlobalSite d) (hxy : x ≠ y) (hn : Nonedge d W G x y) : + 35*(k:ℝ)*Real.log N ≤ ‖point d P q ℓ x-point d P q ℓ y‖ := by + have hs := nonedge_separation d W G P hq ℓ hP hℓ x y hxy hn + rw [dist_eq_norm] at hs + have hx : 0 ≤ (k:ℝ)*Real.log N := mul_nonneg (Nat.cast_nonneg _) + (Real.log_nonneg (by exact_mod_cast (show 1 ≤ N by omega))) + nlinarith + +end ContinuumCoulomb.ContactCalibratedGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPositionArray.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPositionArray.lean new file mode 100644 index 0000000000000000000000000000000000000000..47f4db430f358b47986833b5543f70cfde00593f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactPositionArray.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactSourceInputCorrectness + +namespace OAI + +/-! The literal coordinate list has the exact final mediator enumeration, +including the original vertices. This identifies the machine output with +the geometric realization without an unproved permutation. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactGeometryBlockProgram +open ContactMediator + +private theorem siteCount (d : SquareLatticeHeisenberg) : + d.vertices + d.edges * 2 + d.edges * 2 * 2 + (d.edges * 2 + d.edges * 2 * 2) * 2 = + d.vertices + d.edges * 2 + d.edges * 4 + d.edges * 4 + d.edges * 8 := by omega + +theorem literal_array (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + positions (literalInput d P ℓ) = List.ofFn (ContactRationalGlobal.position d P ℓ) := by + rw [literal_blocks] + conv_rhs => + rw [List.ofFn_congr (siteCount d)] + rw [List.ofFn_add, List.ofFn_add, List.ofFn_add, List.ofFn_add] + simp only [List.append_assoc] + refine congrArg₂ List.append ?_ (congrArg₂ List.append ?_ + (congrArg₂ List.append ?_ (congrArg₂ List.append ?_ ?_))) + · apply congrArg List.ofFn + funext i + apply congrArg (ContactRationalGlobal.position d P ℓ) + apply Fin.ext + change (siteEquiv d.vertices d.edges (Sum.inl i)).val = i.val + simp [siteEquiv, encodeSite, MediatorGraph.old, MediatorGraph.vertexEquiv] + · apply congrArg List.ofFn + funext i + apply congrArg (ContactRationalGlobal.position d P ℓ) + apply Fin.ext + change (firstIndex d i).val = d.vertices + i.val + exact firstIndex_val d i + · apply congrArg List.ofFn + funext i + apply congrArg (ContactRationalGlobal.position d P ℓ) + apply Fin.ext + change (secondIndex d i).val = d.vertices + d.edges * 2 + i.val + exact secondIndex_val d i + · apply congrArg List.ofFn + funext i + apply congrArg (ContactRationalGlobal.position d P ℓ) + apply Fin.ext + change (thirdFirstIndex d i).val = d.vertices + d.edges * 2 + d.edges * 4 + i.val + simpa only [Nat.mul_assoc] using thirdFirstIndex_val d i + · apply congrArg List.ofFn + funext i + apply congrArg (ContactRationalGlobal.position d P ℓ) + apply Fin.ext + change (thirdSecondIndex d i).val = + d.vertices + d.edges * 2 + d.edges * 4 + d.edges * 4 + i.val + simpa only [Nat.mul_assoc] using thirdSecondIndex_val d i + +end ContinuumCoulomb.ContactGeometryBlockProgram + +namespace ContinuumCoulomb.ContactSourceInputProgram +open ContactMediator + +theorem literal_array (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + positions (literalInput d P ℓ) = List.ofFn (ContactRationalGlobal.position d P ℓ) := by + rw [literal_positions, ContactGeometryBlockProgram.literal_array] + +theorem scaled_literal_array (d : SquareLatticeHeisenberg) (P : ℕ) (q : ℚ) + (ℓ : GlobalEdge d → ℚ) : + scaledPositions (q, literalInput d P ℓ) = + List.ofFn (fun x => (q * (ContactRationalGlobal.position d P ℓ x).1, + q * (ContactRationalGlobal.position d P ℓ x).2)) := by + simp only [scaledPositions, literal_array, List.map_ofFn, Function.comp_def] + +end ContinuumCoulomb.ContactSourceInputProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactQuotientBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactQuotientBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..555dcc951c33cf23eceaed35565eda49ef9979a6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactQuotientBounds.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingBox + +namespace OAI + +/-! Stability of the actual contact quotient. A fixed natural guard for +the fixed positive normalization integral suffices for all inputs. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarHoppingNumerator_abs_le_four (d : ℝ) : |planarHoppingNumerator d| ≤ 4 := by + rw [planarHoppingNumerator_box] + have hpoint (a b : ℝ) : + ‖planarHoppingIntegrand d (planarPairEquiv.symm (a, b))‖ ≤ 1 := by + rw [Real.norm_eq_abs, abs_of_nonneg (planarHoppingIntegrand_nonnegative d _)] + exact (mul_le_of_le_one_left (planarResolventMode_positive _).le + (planarForcing_le_one _)).trans (planarResolventMode_le_one _) + have hinner (a : ℝ) : + ‖∫ b in (-1 : ℝ)..1, planarHoppingIntegrand d (planarPairEquiv.symm (a, b))‖ ≤ 2 := by + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (f := fun b => planarHoppingIntegrand d (planarPairEquiv.symm (a, b))) + (a := (-1 : ℝ)) (b := 1) (C := 1) (fun b _ => hpoint a b) + norm_num at h ⊢ + exact h + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (f := fun a => ∫ b in (-1 : ℝ)..1, + planarHoppingIntegrand d (planarPairEquiv.symm (a, b))) + (a := (-1 : ℝ)) (b := 1) (C := 2) (fun a _ => hinner a) + norm_num at h ⊢ + exact h + +def contactNormalizationGuard : ℕ := + ⌈2 / (∫ r, planarResolventMode r ^ 2)⌉₊ + 1 + +theorem contactNormalizationGuard_positive : 0 < contactNormalizationGuard := by + unfold contactNormalizationGuard + omega + +theorem contactNormalizationGuard_bound : + 2 ≤ (contactNormalizationGuard : ℝ) * (∫ r, planarResolventMode r ^ 2) := by + have hp := planarResolventMode_square_integral_positive + have hceil := Nat.le_ceil (2 / (∫ r, planarResolventMode r ^ 2)) + have hg : 2 / (∫ r, planarResolventMode r ^ 2) ≤ (contactNormalizationGuard : ℝ) := by + unfold contactNormalizationGuard + push_cast + linarith + exact (div_le_iff₀ hp).mp hg + +theorem contact_quotient_error {C a a' b b' ε : ℝ} + (hC : 1 ≤ C) (ha : 0 < a) (hguard : 2 ≤ C * a) + (hε : 0 ≤ ε) (hsmall : C * ε ≤ 1) + (hb : |b| ≤ 4) (hea : |a' - a| ≤ ε) (heb : |b' - b| ≤ ε) : + |b' / (2 * a') - b / (2 * a)| ≤ 3 * C ^ 2 * ε := by + have hC0 : 0 < C := by linarith + have hlinear := mul_le_mul_of_nonneg_left (abs_le.mp hea).1 hC0.le + have hga' : 1 ≤ C * a' := by nlinarith + have ha' : 0 < a' := by + by_contra hn + have hn' := le_of_not_gt hn + have hh := mul_nonpos_of_nonneg_of_nonpos hC0.le hn' + linarith + have hia : a⁻¹ ≤ C := (inv_le_iff_one_le_mul₀ ha).mpr (by linarith) + have hia' : a'⁻¹ ≤ C := (inv_le_iff_one_le_mul₀ ha').mpr hga' + have heq : b' / (2 * a') - b / (2 * a) = + ((b' - b) * a'⁻¹ + b * (a - a') * a'⁻¹ * a⁻¹) / 2 := by + field_simp [ha.ne', ha'.ne'] + ring + have hfirst : |(b' - b) * a'⁻¹| ≤ ε * C := by + rw [abs_mul, abs_of_pos (inv_pos.mpr ha')] + exact mul_le_mul heb hia' (inv_nonneg.mpr ha'.le) hε + have hsecond : |b * (a - a') * a'⁻¹ * a⁻¹| ≤ 4 * ε * C ^ 2 := by + rw [abs_mul, abs_mul, abs_mul, abs_of_pos (inv_pos.mpr ha), + abs_of_pos (inv_pos.mpr ha'), abs_sub_comm a a'] + calc + _ ≤ 4 * ε * C * C := by gcongr + _ = _ := by ring + rw [heq, abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)] + have htotal := (abs_add_le ((b' - b) * a'⁻¹) (b * (a - a') * a'⁻¹ * a⁻¹)).trans + (add_le_add hfirst hsecond) + have hCC : C ≤ C ^ 2 := by nlinarith + have hmon := mul_le_mul_of_nonneg_left hCC hε + apply (div_le_div_of_nonneg_right htotal (by norm_num)).trans + nlinarith [mul_nonneg (sq_nonneg C) hε] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..48a8396f6cc78a2aba580fa18ff1be9e856a043f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalCoordinates.lean @@ -0,0 +1,145 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightBisection + +namespace OAI + +/-! Rational contact vertices approximate the same exact height witness as +the deterministic height solve. This estimate preserves separation margins +when the requested precision is increased. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.ContactHeightEvaluation + +def stepX (e : Environment) (h : ℚ) (k : ℕ) : ℚ := + if k = 2 ∨ k = 3 ∨ k = 5 ∨ k = 6 then rootSample e h k else lengthAt e k + +def stepY (h : ℚ) (k : ℕ) : ℚ := + if k = 2 ∨ k = 3 then h else if k = 5 ∨ k = 6 then -h else 0 + +def vertex (e : Environment) (k : ℕ) : ℚ × ℚ := + (∑ j ∈ Finset.range k, stepX e (scheduledValue e) j, + ∑ j ∈ Finset.range k, stepY (scheduledValue e) j) + +def vertexPoint (e : Environment) (k : ℕ) : ContactPoint := + contactPoint (vertex e k).1 (vertex e k).2 + +theorem forward_lipschitz {length h h' : ℝ} + (hl : 99 / 100 ≤ length) (hl' : length ≤ 101 / 100) + (hh : h ∈ Set.Icc (2 / 5) (3 / 4)) (hh' : h' ∈ Set.Icc (2 / 5) (3 / 4)) : + |adjustedContactForward length h - adjustedContactForward length h'| ≤ 2 * |h - h'| := by + rcases le_total h h' with hle | hle + · obtain ⟨hlo, hhi⟩ := adjustedContactForward_slope hl hl' hh.1 hle hh'.2 + have hs : 0 ≤ adjustedContactForward length h - adjustedContactForward length h' := by linarith + rw [abs_of_nonneg hs, abs_of_nonpos (sub_nonpos.mpr hle)] + linarith + · obtain ⟨hlo, hhi⟩ := adjustedContactForward_slope hl hl' hh'.1 hle hh.2 + have hs : adjustedContactForward length h - adjustedContactForward length h' ≤ 0 := by linarith + rw [abs_of_nonpos hs, abs_of_nonneg (sub_nonneg.mpr hle)] + linarith + +theorem stepX_error (e : Environment) (h₀ : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (he : |(scheduledValue e : ℝ) - h₀| ≤ ((e.1 : ℝ) + 1)⁻¹) + {k : ℕ} (hk : k < 9) : + |(stepX e (scheduledValue e) k : ℝ) - + adjustedContactStepX (fun j => (lengthAt e j : ℝ)) h₀ k| ≤ + 3 * ((e.1 : ℝ) + 1)⁻¹ := by + by_cases hs : k = 2 ∨ k = 3 ∨ k = 5 ∨ k = 6 + · have hh := bisect_mem (refinedEnvironment e) (iterations e) + have hlower : (99 / 100 : ℝ) ≤ lengthAt e k := by + have := hl k hk + norm_num [contactLengthTolerance] at this ⊢ + linarith + have hupper : (lengthAt e k : ℝ) ≤ 101 / 100 := by + have := hl' k hk + norm_num [contactLengthTolerance] at this ⊢ + linarith + have hsample := rootSample_error e (scheduledValue e) k (hl k hk) hh + have hforward := forward_lipschitz hlower hupper hh hh₀ + have hdyadic : (2 : ℝ)⁻¹ ^ CalibratedEvaluation.rootPrecision e.1 ≤ + ((e.1 : ℝ) + 1)⁻¹ := (CalibratedEvaluation.root_budget e.1).trans (by + apply inv_anti₀ (by positivity) + nlinarith [show (0 : ℝ) ≤ e.1 from Nat.cast_nonneg e.1]) + have h := (abs_sub_le (rootSample e (scheduledValue e) k : ℝ) + (adjustedContactForward (lengthAt e k) (scheduledValue e)) + (adjustedContactForward (lengthAt e k) h₀)).trans + (add_le_add (hsample.trans hdyadic) (hforward.trans (mul_le_mul_of_nonneg_left he (by norm_num)))) + have h' : |(rootSample e (scheduledValue e) k : ℝ) - + adjustedContactForward (lengthAt e k) h₀| ≤ 3 * ((e.1 : ℝ) + 1)⁻¹ := by + calc + _ ≤ ((e.1 : ℝ) + 1)⁻¹ + 2 * ((e.1 : ℝ) + 1)⁻¹ := h + _ = _ := by ring + simpa only [stepX, adjustedContactStepX, ite_eq_left hs] using h' + · simp only [stepX, adjustedContactStepX, ite_eq_right hs, sub_self, abs_zero] + positivity + +theorem stepY_error (e : Environment) (h₀ : ℝ) + (he : |(scheduledValue e : ℝ) - h₀| ≤ ((e.1 : ℝ) + 1)⁻¹) (k : ℕ) : + |(stepY (scheduledValue e) k : ℝ) - adjustedContactStepY h₀ k| ≤ + ((e.1 : ℝ) + 1)⁻¹ := by + by_cases h₁ : k = 2 ∨ k = 3 + · simpa only [stepY, adjustedContactStepY, ite_eq_left h₁] using he + · by_cases h₂ : k = 5 ∨ k = 6 + · simpa only [stepY, adjustedContactStepY, ite_eq_right h₁, ite_eq_left h₂, + Rat.cast_neg, neg_sub_neg, abs_sub_comm] using he + · simp only [stepY, adjustedContactStepY, ite_eq_right h₁, ite_eq_right h₂, Rat.cast_zero, + sub_zero, abs_zero] + positivity + +private theorem contactPoint_dist_le_abs (x y x' y' : ℝ) : + dist (contactPoint x y) (contactPoint x' y') ≤ |x - x'| + |y - y'| := by + have hsq := contactPoint_dist_sq x y x' y' + nlinarith [sq_abs (x - x'), sq_abs (y - y'), + mul_nonneg (abs_nonneg (x - x')) (abs_nonneg (y - y')), + show 0 ≤ dist (contactPoint x y) (contactPoint x' y') from dist_nonneg, + abs_nonneg (x - x'), abs_nonneg (y - y')] + +theorem vertex_error (e : Environment) (h₀ : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ (lengthAt e k : ℝ)) + (hl' : ∀ k < 9, (lengthAt e k : ℝ) ≤ 1 + contactLengthTolerance) + (hh₀ : h₀ ∈ Set.Icc (2 / 5) (3 / 4)) + (hroot : adjustedContactSpan (fun k => (lengthAt e k : ℝ)) h₀ = (e.2.2 : ℝ)) + {k : ℕ} (hk : k ≤ 9) : + dist (vertexPoint e k) (adjustedContactVertex (fun j => (lengthAt e j : ℝ)) h₀ k) ≤ + 36 * ((e.1 : ℝ) + 1)⁻¹ := by + have he := scheduled_height_error e h₀ hl hl' hh₀ hroot + have hx : |(∑ j ∈ Finset.range k, (stepX e (scheduledValue e) j : ℝ)) - + ∑ j ∈ Finset.range k, adjustedContactStepX (fun j => (lengthAt e j : ℝ)) h₀ j| ≤ + (k : ℝ) * (3 * ((e.1 : ℝ) + 1)⁻¹) := by + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _j ∈ Finset.range k, 3 * ((e.1 : ℝ) + 1)⁻¹ := by + apply Finset.sum_le_sum + intro j hj + exact stepX_error e h₀ hl hl' hh₀ he (lt_of_lt_of_le (Finset.mem_range.mp hj) hk) + _ = _ := by simp + have hy : |(∑ j ∈ Finset.range k, (stepY (scheduledValue e) j : ℝ)) - + ∑ j ∈ Finset.range k, adjustedContactStepY h₀ j| ≤ + (k : ℝ) * ((e.1 : ℝ) + 1)⁻¹ := by + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _j ∈ Finset.range k, ((e.1 : ℝ) + 1)⁻¹ := by + exact Finset.sum_le_sum (fun j _ => stepY_error e h₀ he j) + _ = _ := by simp + have hd := contactPoint_dist_le_abs + (∑ j ∈ Finset.range k, (stepX e (scheduledValue e) j : ℝ)) + (∑ j ∈ Finset.range k, (stepY (scheduledValue e) j : ℝ)) + (∑ j ∈ Finset.range k, adjustedContactStepX (fun j => (lengthAt e j : ℝ)) h₀ j) + (∑ j ∈ Finset.range k, adjustedContactStepY h₀ j) + have hk' : (k : ℝ) ≤ 9 := by exact_mod_cast hk + have hb : (k : ℝ) * (3 * ((e.1 : ℝ) + 1)⁻¹) + (k : ℝ) * ((e.1 : ℝ) + 1)⁻¹ ≤ + 36 * ((e.1 : ℝ) + 1)⁻¹ := by + nlinarith [mul_le_mul_of_nonneg_right hk' (inv_nonneg.mpr + (show (0 : ℝ) ≤ e.1 + 1 by positivity))] + simpa only [vertexPoint, vertex, adjustedContactVertex, Rat.cast_sum] using + hd.trans ((add_le_add hx hy).trans hb) + +end ContinuumCoulomb.ContactHeightEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGadget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGadget.lean new file mode 100644 index 0000000000000000000000000000000000000000..f60aa9009ea17dc64956db14b6cc724a5ba8fa4e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGadget.lean @@ -0,0 +1,190 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactClosedCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGadgetStability + +namespace OAI + +/-! A concrete rational twenty-site gadget. The two paths share the same +rational prescribed span; their outer endpoints are exact and their +internal vertices approximate the original independent-length gadget. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactRationalGadget +open ContactHeightEvaluation + +abbrev Input := ℕ × (Bool × (ℚ × (List ℚ × List ℚ))) + +def span (negative : Bool) (central : ℚ) : ℚ := + if negative then 17 / 2 else (17 - central) / 2 + +def origin (negative : Bool) (central : ℚ) : ℚ := + if negative then 17 / 2 else (17 + central) / 2 + +def leftEnvironment (x : Input) : Environment := + (x.1, (x.2.2.2.1, span x.2.1 x.2.2.1)) + +def rightEnvironment (x : Input) : Environment := + (x.1, (x.2.2.2.2, span x.2.1 x.2.2.1)) + +def position (x : Input) : ContactGadgetSite → ℚ × ℚ := + Sum.elim (fun k => closedVertex (leftEnvironment x) k.val) + (Sum.elim (fun k => + (origin x.2.1 x.2.2.1 + (closedVertex (rightEnvironment x) (k.val + 1)).1, + (closedVertex (rightEnvironment x) (k.val + 1)).2)) + (fun _ => if x.2.1 then (17 / 2, x.2.2.1) else (origin x.2.1 x.2.2.1, 0))) + +def point (x : Input) (s : ContactGadgetSite) : ContactPoint := + contactPoint (position x s).1 (position x s).2 + +def leftLengths (x : Input) (k : ℕ) : ℝ := lengthAt (leftEnvironment x) k +def rightLengths (x : Input) (k : ℕ) : ℝ := lengthAt (rightEnvironment x) k + +theorem span_cast (b : Bool) (c : ℚ) : + (span b c : ℝ) = contactGadgetSpan b c := by + cases b <;> simp [span, contactGadgetSpan, Rat.cast_div, Rat.cast_sub] + +theorem origin_cast (b : Bool) (c : ℚ) : + (origin b c : ℝ) = contactGadgetRightOrigin b c := by + cases b <;> simp [origin, contactGadgetRightOrigin, Rat.cast_div, Rat.cast_add] + +theorem point_left (x : Input) (k : Fin 10) : + point x (Sum.inl k) = closedVertexPoint (leftEnvironment x) k.val := rfl + +theorem point_right (x : Input) (k : Fin 9) : + point x (Sum.inr (Sum.inl k)) = + contactPoint (contactGadgetRightOrigin x.2.1 x.2.2.1) 0 + + closedVertexPoint (rightEnvironment x) (k.val + 1) := by + ext i + fin_cases i <;> + simp [point, position, closedVertexPoint, contactPoint, Rat.cast_add, + origin_cast, PiLp.add_apply] + +theorem point_side (x : Input) : + point x contactGadgetSide = + if x.2.1 then contactPoint (17 / 2) x.2.2.1 + else contactPoint (contactGadgetRightOrigin x.2.1 x.2.2.1) 0 := by + cases hb : x.2.1 <;> + simp [point, position, contactGadgetSide, hb, origin_cast, Rat.cast_div] + +theorem point_start (x : Input) : point x (Sum.inl 0) = contactPoint 0 0 := by + rw [point_left] + simp [closedVertexPoint, closedVertex_start] + +theorem point_end (x : Input) : + point x (contactGadgetRightNode x.2.1 9) = contactPoint 17 0 := by + have hnode : contactGadgetRightNode x.2.1 9 = Sum.inr (Sum.inl 8) := by + simp [contactGadgetRightNode] + rw [hnode, point_right] + change contactPoint (contactGadgetRightOrigin x.2.1 x.2.2.1) 0 + + closedVertexPoint (rightEnvironment x) 9 = _ + simp only [closedVertexPoint, closedVertex_end, rightEnvironment, span_cast, Rat.cast_zero] + cases hb : x.2.1 <;> ext i <;> fin_cases i + all_goals simp [contactGadgetRightOrigin, contactGadgetSpan, contactPoint, PiLp.add_apply] + all_goals ring + +theorem point_near_reference (x : Input) (hL hR : ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths x k) + (hl' : ∀ k < 9, leftLengths x k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths x k) + (hr' : ∀ k < 9, rightLengths x k ≤ 1 + contactLengthTolerance) + (hLmem : hL ∈ Set.Icc (contactHeightLow (contactGadgetSlope x.2.1)) + (contactHeightHigh (contactGadgetSlope x.2.1))) + (hRmem : hR ∈ Set.Icc (contactHeightLow (contactGadgetSlope x.2.1)) + (contactHeightHigh (contactGadgetSlope x.2.1))) + (hLroot : adjustedContactSpan (leftLengths x) hL = contactGadgetSpan x.2.1 x.2.2.1) + (hRroot : adjustedContactSpan (rightLengths x) hR = contactGadgetSpan x.2.1 x.2.2.1) + (s : ContactGadgetSite) : + dist (point x s) + (contactGadgetPosition x.2.1 x.2.2.1 (leftLengths x) (rightLengths x) hL hR s) ≤ + 36 * ((x.1 : ℝ) + 1)⁻¹ := by + have hs := contactGadgetSlope_bounds x.2.1 + have hL' := contactHeight_interval_bounds hs.1 hs.2 hLmem + have hR' := contactHeight_interval_bounds hs.1 hs.2 hRmem + have hLroot' : adjustedContactSpan (leftLengths x) hL = + ((leftEnvironment x).2.2 : ℝ) := by simpa only [leftEnvironment, span_cast] using hLroot + have hRroot' : adjustedContactSpan (rightLengths x) hR = + ((rightEnvironment x).2.2 : ℝ) := by simpa only [rightEnvironment, span_cast] using hRroot + rcases s with k | (k | u) + · rw [point_left] + exact closedVertex_error (leftEnvironment x) hL hl hl' hL' hLroot' + (by have := k.isLt; omega) + · rw [point_right] + change dist (_ + _) (_ + _) ≤ _ + rw [dist_add_left] + exact closedVertex_error (rightEnvironment x) hR hr hr' hR' hRroot' + (by have := k.isLt; omega) + · cases u + change dist (point x contactGadgetSide) _ ≤ _ + rw [point_side] + change dist _ (if x.2.1 then _ else _) ≤ _ + rw [dist_self] + positivity + +theorem exists_reference (x : Input) + (hc : 1 - contactLengthTolerance ≤ (x.2.2.1 : ℝ)) + (hc' : (x.2.2.1 : ℝ) ≤ 1 + contactLengthTolerance) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ leftLengths x k) + (hl' : ∀ k < 9, leftLengths x k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rightLengths x k) + (hr' : ∀ k < 9, rightLengths x k ≤ 1 + contactLengthTolerance) : + ∃ hL hR, + hL ∈ Set.Icc (contactHeightLow (contactGadgetSlope x.2.1)) + (contactHeightHigh (contactGadgetSlope x.2.1)) ∧ + hR ∈ Set.Icc (contactHeightLow (contactGadgetSlope x.2.1)) + (contactHeightHigh (contactGadgetSlope x.2.1)) ∧ + adjustedContactSpan (leftLengths x) hL = contactGadgetSpan x.2.1 x.2.2.1 ∧ + adjustedContactSpan (rightLengths x) hR = contactGadgetSpan x.2.1 x.2.2.1 ∧ + ∀ s, dist (point x s) + (contactGadgetPosition x.2.1 x.2.2.1 (leftLengths x) (rightLengths x) hL hR s) ≤ + 36 * ((x.1 : ℝ) + 1)⁻¹ := by + have hs := contactGadgetSlope_bounds x.2.1 + have hspan := contactGadgetSpan_bounds x.2.1 hc hc' + obtain ⟨hL, hLmem, hLroot⟩ := adjustedContactSpan_exists hs.1 hs.2 + (leftLengths x) hl hl' hspan.1 hspan.2 + obtain ⟨hR, hRmem, hRroot⟩ := adjustedContactSpan_exists hs.1 hs.2 + (rightLengths x) hr hr' hspan.1 hspan.2 + exact ⟨hL, hR, hLmem, hRmem, hLroot, hRroot, + point_near_reference x hL hR hl hl' hr hr' hLmem hRmem hLroot hRroot⟩ + +theorem reference_near_base (negative : Bool) {central : ℝ} + (hc : 1 - contactLengthTolerance ≤ central) (hc' : central ≤ 1 + contactLengthTolerance) + (ll rr : ℕ → ℝ) + (hl : ∀ k < 9, 1 - contactLengthTolerance ≤ ll k) + (hl' : ∀ k < 9, ll k ≤ 1 + contactLengthTolerance) + (hr : ∀ k < 9, 1 - contactLengthTolerance ≤ rr k) + (hr' : ∀ k < 9, rr k ≤ 1 + contactLengthTolerance) + {hL hR : ℝ} + (hLmem : hL ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) + (hRmem : hR ∈ Set.Icc (contactHeightLow (contactGadgetSlope negative)) + (contactHeightHigh (contactGadgetSlope negative))) (s : ContactGadgetSite) : + dist (contactGadgetPosition negative central ll rr hL hR s) + (contactBaseGadgetPosition negative s) < 9 / 200 := by + have hs := contactGadgetSlope_bounds negative + rcases s with k | (k | ⟨⟩) + · exact (adjustedContactVertex_displacement hs.1 hs.2 hLmem ll hl hl' + (by have := k.isLt; omega)).trans (by norm_num) + · have hp := adjustedContactVertex_displacement hs.1 hs.2 hRmem rr hr hr' + (show k.val + 1 ≤ 9 by have := k.isLt; omega) + have ho := contactGadgetOrigin_near negative hc hc' + have hd := dist_add_add_le (contactPoint (contactGadgetRightOrigin negative central) 0) + (adjustedContactVertex rr hR (k.val + 1)) + (contactPoint (contactGadgetRightOrigin negative 1) 0) + (contactPathVertex (contactGadgetSlope negative) (k.val + 1)) + change dist (_ + _) (_ + _) < _ + unfold contactLengthTolerance at ho + linarith + · cases negative + · have ho := contactGadgetOrigin_near false hc hc' + norm_num [contactGadgetRightOrigin, contactLengthTolerance] at ho + change dist (contactPoint ((17 + central) / 2) 0) (contactPoint 9 0) < _ + linarith + · change dist (contactPoint (17 / 2) central) (contactPoint (17 / 2) 1) < _ + rw [contactPoint_vertical_dist] + have habs : |central - 1| ≤ contactLengthTolerance := abs_le.mpr ⟨by linarith, by linarith⟩ + exact habs.trans_lt (by norm_num [contactLengthTolerance]) + +end ContinuumCoulomb.ContactRationalGadget + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGlobal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGlobal.lean new file mode 100644 index 0000000000000000000000000000000000000000..b65468176889f344f750f0fe5541fab3ecd45ee9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalGlobal.lean @@ -0,0 +1,142 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalLocal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRealization + +namespace OAI + +/-! The rational local gadgets are glued through the exact final-graph +permutation. All old lattice sites remain fixed; all nineteen edges per +source edge retain a controlled error and all nonedges retain the margin. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactRationalGlobal +open ContactMediator MediatorIteration + +def localPoints (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (e : Fin d.edges) : LocalSite → ContactPoint := + ContactRationalLocal.point P (edgeNegative d.bonds e) (fun a => ℓ (encodeEdge d.edges e a)) + +def point (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + GlobalSite d → ContactPoint := globalPosition d (localPoints d P ℓ) + +theorem local_start (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (e : Fin d.edges) : localPoints d P ℓ e (localOld 0) = contactPoint 0 0 := + (ContactRationalLocal.exists_link_approximation P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) (fun _ => hℓ _)).1 + +theorem local_end (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (e : Fin d.edges) : localPoints d P ℓ e (localOld 1) = contactPoint 17 0 := + (ContactRationalLocal.exists_link_approximation P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) (fun _ => hℓ _)).2.1 + +theorem edge_error (d : SquareLatticeHeisenberg) (W G P : ℕ) (ℓ : GlobalEdge d → ℚ) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (a : GlobalEdge d) : + |dist (point d P ℓ ((finalGraph d.bonds W G).left a)) + (point d P ℓ ((finalGraph d.bonds W G).right a)) - (ℓ a : ℝ)| ≤ + 72 * ((P : ℝ) + 1)⁻¹ := by + obtain ⟨⟨e, a⟩, rfl⟩ := (edgeEquiv d.edges).surjective a + change |dist (globalPosition d (localPoints d P ℓ) + ((finalGraph d.bonds W G).left (encodeEdge d.edges e a))) + (globalPosition d (localPoints d P ℓ) + ((finalGraph d.bonds W G).right (encodeEdge d.edges e a))) - + (ℓ (encodeEdge d.edges e a) : ℝ)| ≤ _ + rw [finalGraph_left, finalGraph_right] + change |dist (globalPosition d (localPoints d P ℓ) + (localVertex (d.left e) (d.right e) e (localLeft (member (d.coefficient e)) a))) + (globalPosition d (localPoints d P ℓ) + (localVertex (d.left e) (d.right e) e (localRight a))) - + (ℓ (encodeEdge d.edges e a) : ℝ)| ≤ _ + rw [globalPosition_local d _ (local_start d P ℓ hℓ) (local_end d P ℓ hℓ), + globalPosition_local d _ (local_start d P ℓ hℓ) (local_end d P ℓ hℓ), + ContactGridEdge.place_dist] + have hm : member (d.coefficient e) = if edgeNegative d.bonds e then 0 else 1 := + member_edgeNegative d.bonds e + rw [hm] + exact (ContactRationalLocal.exists_link_approximation P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) (fun a => hℓ _)).2.2.1 a + +theorem nonedge_separation (d : SquareLatticeHeisenberg) (W G P : ℕ) + (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (x y : GlobalSite d) (hne : x ≠ y) (hn : Nonedge d W G x y) : + 6 / 5 < dist (point d P ℓ x) (point d P ℓ y) := by + apply globalPosition_nonedge d W G (localPoints d P ℓ) + (local_start d P ℓ hℓ) (local_end d P ℓ hℓ) _ _ x y hne hn + · intro e s t hst hnon + exact ContactRationalLocal.nonedge_separation P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) (by omega) (fun a => hℓ _) s t hst + (finalGraph_nonedge_contactNonlink d.bonds W G e s t hnon) + · intro e s + exact ContactRationalLocal.near_base P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) hP (fun a => hℓ _) s + +theorem separation (d : SquareLatticeHeisenberg) (W G P : ℕ) (ℓ : GlobalEdge d → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (x y : GlobalSite d) (hne : x ≠ y) : + 9 / 10 ≤ dist (point d P ℓ x) (point d P ℓ y) := by + by_cases hn : Nonedge d W G x y + · exact (by norm_num : (9 / 10 : ℝ) ≤ 6 / 5).trans + (nonedge_separation d W G P ℓ hP hℓ x y hne hn).le + · simp only [Nonedge, not_not] at hn + obtain ⟨a, ha⟩ := hn + have he := (abs_le.mp (edge_error d W G P ℓ hℓ a)).1 + have hsmall : 72 * ((P : ℝ) + 1)⁻¹ ≤ 1 / 50 := by + apply (mul_inv_le_iff₀ (by positivity)).mpr + have hPR : (7200 : ℝ) ≤ P := by exact_mod_cast hP + linarith + have hl := (hℓ a).1 + unfold contactLengthTolerance at hl + rcases ha with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ + · linarith + · rw [dist_comm] + linarith + +theorem coordinate_bound (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + {M : ℝ} (hcoord : ∀ j k, |(contactGridAxis (d.coordinate j) k : ℝ)| ≤ M) + (x : GlobalSite d) (i : Fin 2) : |point d P ℓ x i| ≤ 17 * M + 17 := + globalPosition_coordinate_bound d (localPoints d P ℓ) hcoord + (fun e s => ContactRationalLocal.near_base P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) hP (fun _ => hℓ _) s) x i + +def rationalPlace (e : ContactGridEdge) (p : ℚ × ℚ) : ℚ × ℚ := + let q := if e.reversed then (17 - p.1, p.2) else p + if e.vertical then (17 * e.anchor.1 - q.2, 17 * e.anchor.2 + q.1) + else (17 * e.anchor.1 + q.1, 17 * e.anchor.2 + q.2) + +theorem rationalPlace_cast (e : ContactGridEdge) (p : ℚ × ℚ) : + contactPoint (rationalPlace e p).1 (rationalPlace e p).2 = + e.place (contactPoint p.1 p.2) := by + cases hv : e.vertical <;> cases hr : e.reversed <;> ext i <;> fin_cases i <;> + simp [rationalPlace, ContactGridEdge.place, hv, hr, contactReflect, + contactVertical, contactHorizontal, contactPoint, Rat.cast_sub, Rat.cast_add, Rat.cast_mul] + +def position (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (x : GlobalSite d) : ℚ × ℚ := + match (siteEquiv d.vertices d.edges).symm x with + | Sum.inl i => (17 * (d.coordinate i).1, 17 * (d.coordinate i).2) + | Sum.inr (e, u) => rationalPlace (d.contactEdge e) + (ContactRationalLocal.position P (edgeNegative d.bonds e) + (fun a => ℓ (encodeEdge d.edges e a)) (Sum.inr u)) + +theorem position_cast (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (x : GlobalSite d) : contactPoint (position d P ℓ x).1 (position d P ℓ x).2 = point d P ℓ x := by + obtain ⟨x, rfl⟩ := (siteEquiv d.vertices d.edges).surjective x + cases x with + | inl i => + simp [position, point, contactGridPoint, Rat.cast_mul] + | inr eu => + rcases eu with ⟨e, u⟩ + simp only [position, Equiv.symm_apply_apply, rationalPlace_cast, point, + globalPosition_internal] + rfl + +end ContinuumCoulomb.ContactRationalGlobal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalLocal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..0857b9a60b96bcff7b70fe40e982124227dab727 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRationalLocal.lean @@ -0,0 +1,148 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGadget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediatorGeometry + +namespace OAI + +/-! Rational contact coordinates indexed by the actual nineteen local +mediator edges. Every link has a quantitative error and the nonedge margin +survives with a fixed minimum requested precision. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactRationalLocal +open ContactMediator ContactRationalGadget + +def input (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) : ContactRationalGadget.Input := + (P, (negative, (ℓ (Sum.inl ()), + (List.ofFn (fun k : Fin 9 => ℓ (leftEdge k)), + List.ofFn (fun k : Fin 9 => ℓ (rightEdge k)))))) + +def position (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) (s : LocalSite) : ℚ × ℚ := + ContactRationalGadget.position (input P negative ℓ) (localToContact s) + +def point (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) (s : LocalSite) : ContactPoint := + ContactRationalGadget.point (input P negative ℓ) (localToContact s) + +private theorem length_ofFn (f : Fin 9 → ℚ) (k : ℕ) (hk : k < 9) : + ((List.ofFn f).drop k).headD 1 = f ⟨k, hk⟩ := by + rw [List.drop_eq_getElem_cons (by simpa only [List.length_ofFn] using hk)] + simp only [List.headD_cons, List.getElem_ofFn] + +theorem left_length (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) + (k : ℕ) (hk : k < 9) : + leftLengths (input P negative ℓ) k = (ℓ (leftEdge ⟨k, hk⟩) : ℝ) := by + simp only [leftLengths, ContactHeightEvaluation.lengthAt, leftEnvironment, input] + rw [length_ofFn _ k hk] + +theorem right_length (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) + (k : ℕ) (hk : k < 9) : + rightLengths (input P negative ℓ) k = (ℓ (rightEdge ⟨k, hk⟩) : ℝ) := by + simp only [rightLengths, ContactHeightEvaluation.lengthAt, rightEnvironment, input] + rw [length_ofFn _ k hk] + +private theorem distance_error {x y x' y' : ContactPoint} {E : ℝ} + (hx : dist x x' ≤ E) (hy : dist y y' ≤ E) : + |dist x y - dist x' y'| ≤ 2 * E := by + have h := dist_dist_dist_le x y x' y' + rw [Real.dist_eq] at h + exact h.trans (by linarith) + +theorem exists_link_approximation (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) : + point P negative ℓ (localOld 0) = contactPoint 0 0 ∧ + point P negative ℓ (localOld 1) = contactPoint 17 0 ∧ + (∀ a, |dist (point P negative ℓ (localLeft (if negative then 0 else 1) a)) + (point P negative ℓ (localRight a)) - (ℓ a : ℝ)| ≤ 72 * ((P : ℝ) + 1)⁻¹) ∧ + (∀ s, dist (point P negative ℓ s) + (contactBaseGadgetPosition negative (localToContact s)) < + 36 * ((P : ℝ) + 1)⁻¹ + 9 / 200) := by + let x := input P negative ℓ + have hl (k : ℕ) (hk : k < 9) : leftLengths x k ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + rw [show leftLengths x k = _ from left_length P negative ℓ k hk] + exact hℓ _ + have hr (k : ℕ) (hk : k < 9) : rightLengths x k ∈ + Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance) := by + rw [show rightLengths x k = _ from right_length P negative ℓ k hk] + exact hℓ _ + obtain ⟨hL, hR, hLmem, hRmem, hLroot, hRroot, hnear⟩ := ContactRationalGadget.exists_reference x + (hℓ (Sum.inl ())).1 (hℓ (Sum.inl ())).2 + (fun k hk => (hl k hk).1) (fun k hk => (hl k hk).2) + (fun k hk => (hr k hk).1) (fun k hk => (hr k hk).2) + let G := contactGadgetPosition negative (ℓ (Sum.inl ())) (leftLengths x) (rightLengths x) hL hR + have hlinks := contactGadget_link_lengths negative (hℓ (Sum.inl ())).1 + (leftLengths x) (rightLengths x) (fun k hk => (hl k hk).1) (fun k hk => (hr k hk).1) + hLmem hRmem hLroot + refine ⟨?_, ?_, ?_, ?_⟩ + · exact ContactRationalGadget.point_start x + · simpa [point, localToContact, localOld, x, input, contactGadgetRightNode] using + ContactRationalGadget.point_end x + · intro a + have he := distance_error (hnear (localToContact (localLeft (if negative then 0 else 1) a))) + (hnear (localToContact (localRight a))) + have hexact : dist (G (localToContact (localLeft (if negative then 0 else 1) a))) + (G (localToContact (localRight a))) = (ℓ a : ℝ) := by + obtain ⟨b, rfl⟩ := contactEdgeEquiv.surjective a + rcases b with k | (⟨⟩ | k) + · change dist (G (localToContact (localLeft (if negative then 0 else 1) (leftEdge k)))) + (G (localToContact (localRight (leftEdge k)))) = (ℓ (leftEdge k) : ℝ) + rw [leftEdge_distance] + exact (hlinks.1 k).trans (left_length P negative ℓ k.val k.isLt) + · change dist (G (Sum.inl 9)) (G contactGadgetSide) = _ + rw [dist_comm] + exact hlinks.2.1 + · change dist (G (localToContact (localLeft (if negative then 0 else 1) (rightEdge k)))) + (G (localToContact (localRight (rightEdge k)))) = (ℓ (rightEdge k) : ℝ) + rw [rightEdge_distance] + exact (hlinks.2.2 k).trans (right_length P negative ℓ k.val k.isLt) + change |dist (ContactRationalGadget.point x _) + (ContactRationalGadget.point x _) - + dist (G (localToContact (localLeft (if negative then 0 else 1) a))) + (G (localToContact (localRight a)))| ≤ 2 * (36 * ((P : ℝ) + 1)⁻¹) at he + change |dist (ContactRationalGadget.point x _) (ContactRationalGadget.point x _) - _| ≤ _ + rw [hexact] at he + exact he.trans_eq (by ring) + · intro s + have hb := ContactRationalGadget.reference_near_base negative (hℓ (Sum.inl ())).1 (hℓ (Sum.inl ())).2 + (leftLengths x) (rightLengths x) (fun k hk => (hl k hk).1) (fun k hk => (hl k hk).2) + (fun k hk => (hr k hk).1) (fun k hk => (hr k hk).2) hLmem hRmem (localToContact s) + exact (dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt (hnear _) hb) + +theorem nonedge_separation (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) + (hP : 1440 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (s t : LocalSite) (hne : s ≠ t) + (hnon : ¬contactGadgetLinked negative (localToContact s) (localToContact t)) : + 6 / 5 < dist (point P negative ℓ s) (point P negative ℓ t) := by + have hnear := (exists_link_approximation P negative ℓ hℓ).2.2.2 + have hsmall : 36 * ((P : ℝ) + 1)⁻¹ ≤ 1 / 40 := by + apply (mul_inv_le_iff₀ (by positivity)).mpr + have hPR : (1440 : ℝ) ≤ P := by exact_mod_cast hP + linarith + have hs := hnear s + have ht := hnear t + have hbase := contactBaseGadget_nonlink_separation negative (localToContact s) (localToContact t) + (fun h => hne (localContactEquiv.injective h)) hnon + have h₁ := dist_triangle (contactBaseGadgetPosition negative (localToContact s)) + (point P negative ℓ s) (contactBaseGadgetPosition negative (localToContact t)) + have h₂ := dist_triangle (point P negative ℓ s) (point P negative ℓ t) + (contactBaseGadgetPosition negative (localToContact t)) + rw [dist_comm] at hs + linarith + +theorem near_base (P : ℕ) (negative : Bool) (ℓ : LocalEdge → ℚ) + (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) + (s : LocalSite) : + dist (point P negative ℓ s) (contactBaseGadgetPosition negative (localToContact s)) < 1 / 20 := by + have h := (exists_link_approximation P negative ℓ hℓ).2.2.2 s + have hsmall : 36 * ((P : ℝ) + 1)⁻¹ ≤ 1 / 200 := by + apply (mul_inv_le_iff₀ (by positivity)).mpr + have hPR : (7200 : ℝ) ≤ P := by exact_mod_cast hP + linarith + linarith + +end ContinuumCoulomb.ContactRationalLocal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ff736adc67c339cfb2a60c757ab83e20ab96c30 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactRealization.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGlobalSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactExtent + +namespace OAI + +/-! A geometric realization of the exact final mediator graph, with +independently prescribed near-unit edge lengths and uniform nonedge gaps. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactMediator +open MediatorIteration + +/-- No graph isomorphism or extra geometric premise is assumed: the output +is indexed by the actual finalGraph vertices and edges. -/ +theorem exists_finalGraph_realization (d : SquareLatticeHeisenberg) (W G : ℕ) + (ℓ : GlobalEdge d → ℝ) + (hℓ : ∀ a, ℓ a ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) : + ∃ Q : GlobalSite d → ContactPoint, + (∀ i, Q (siteEquiv d.vertices d.edges (Sum.inl i)) = contactGridPoint (d.coordinate i)) ∧ + (∀ a, dist (Q ((finalGraph d.bonds W G).left a)) + (Q ((finalGraph d.bonds W G).right a)) = ℓ a) ∧ + (∀ x y, x ≠ y → Nonedge d W G x y → 6 / 5 < dist (Q x) (Q y)) ∧ + (∀ x y, x ≠ y → 1 - contactLengthTolerance ≤ dist (Q x) (Q y)) ∧ + (∀ M : ℝ, (∀ j i, |(contactGridAxis (d.coordinate j) i : ℝ)| ≤ M) → + ∀ x i, |Q x i| ≤ 17 * M + 17) := by + choose P hP using fun e => exists_finalGraph_gadget_geometry d.bonds W G e ℓ hℓ + have h₀ : ∀ e, P e (localOld 0) = contactPoint 0 0 := fun e => (hP e).1 + have h₁ : ∀ e, P e (localOld 1) = contactPoint 17 0 := fun e => (hP e).2.1 + have hlen : ∀ e a, dist (P e (localLeft (member (d.coefficient e)) a)) + (P e (localRight a)) = ℓ (encodeEdge d.edges e a) := fun e => (hP e).2.2.1 + have hsep : ∀ e x y, x ≠ y → Nonedge d W G + (localVertex (d.left e) (d.right e) e x) + (localVertex (d.left e) (d.right e) e y) → 6 / 5 < dist (P e x) (P e y) := + fun e => (hP e).2.2.2.1 + have hnear : ∀ e x, dist (P e x) + (contactBaseGadgetPosition (edgeNegative d.bonds e) (localToContact x)) < 1 / 20 := + fun e => (hP e).2.2.2.2 + have hn := globalPosition_nonedge d W G P h₀ h₁ hsep hnear + exact ⟨globalPosition d P, globalPosition_old d P, + globalPosition_link_lengths d W G P h₀ h₁ ℓ hlen, hn, + globalPosition_separation d W G P h₀ h₁ ℓ hlen (fun a => (hℓ a).1) hn, + fun _ hc x i => globalPosition_coordinate_bound d P hc hnear x i⟩ + +private theorem dist_real_smul (D : ℝ) (hD : 0 < D) (x y : ContactPoint) : + dist (D • x) (D • y) = D * dist x y := by + simp only [dist_eq_norm, ← smul_sub, norm_smul, Real.norm_eq_abs, abs_of_pos hD] + +/-- Multiplication by the chosen physical spacing preserves every exact +edge length and gives the required strict nonedge separation. -/ +theorem exists_scaled_finalGraph_realization (d : SquareLatticeHeisenberg) (W G : ℕ) + (D : ℝ) (hD : 0 < D) (ℓ : GlobalEdge d → ℝ) + (hℓ : ∀ a, ℓ a ∈ Set.Icc (1 - contactLengthTolerance) (1 + contactLengthTolerance)) : + ∃ Q : GlobalSite d → ContactPoint, + (∀ a, dist (Q ((finalGraph d.bonds W G).left a)) + (Q ((finalGraph d.bonds W G).right a)) = D * ℓ a) ∧ + (∀ x y, x ≠ y → Nonedge d W G x y → (6 / 5) * D < dist (Q x) (Q y)) ∧ + (∀ x y, x ≠ y → (1 - contactLengthTolerance) * D ≤ dist (Q x) (Q y)) ∧ + Function.Injective Q ∧ + (∀ M : ℝ, (∀ j i, |(contactGridAxis (d.coordinate j) i : ℝ)| ≤ M) → + ∀ x i, |Q x i| ≤ D * (17 * M + 17)) := by + obtain ⟨Q, _, hlen, hnon, hsep, hext⟩ := exists_finalGraph_realization d W G ℓ hℓ + refine ⟨fun x => D • Q x, ?_, ?_, ?_, ?_, ?_⟩ + · intro a + rw [dist_real_smul D hD, hlen] + · intro x y hxy hn + rw [dist_real_smul D hD] + nlinarith [hnon x y hxy hn] + · intro x y hxy + rw [dist_real_smul D hD] + nlinarith [hsep x y hxy] + · intro x y hxy + by_contra hne + have hpos : 0 < (1 - contactLengthTolerance) * D := + mul_pos (by norm_num [contactLengthTolerance]) hD + have hs := hsep x y hne + have hz : dist (D • Q x) (D • Q y) = 0 := dist_eq_zero.mpr hxy + rw [dist_real_smul D hD] at hz + nlinarith + · intro M hc x i + change |D * Q x i| ≤ _ + rw [abs_mul, abs_of_pos hD] + exact mul_le_mul_of_nonneg_left (hext M hc x i) hD.le + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..414b3cd54856029c56231133d4389adbbb535b1b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceGrid.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceHamiltonian + +namespace OAI + +/-! Every edge of the actual signed square-lattice source has a canonical +geometric strip, and the source's simple-edge promise makes these strips +pairwise distinct. -/ + +noncomputable section +namespace ContinuumCoulomb + +private theorem natAbs_one_cases {a : ℤ} (h : a.natAbs = 1) : a = 1 ∨ a = -1 := by + exact Int.natAbs_eq_natAbs_iff.mp (by simpa using h) + +theorem exists_contactGridEdge (p q : ℤ × ℤ) + (h : (p.1 - q.1).natAbs + (p.2 - q.2).natAbs = 1) : + ∃ e : ContactGridEdge, e.left = p ∧ e.right = q := by + have hx : (p.1 - q.1).natAbs = 0 ∨ (p.1 - q.1).natAbs = 1 := by omega + rcases hx with hx | hx + · have hxeq : p.1 = q.1 := sub_eq_zero.mp (Int.natAbs_eq_zero.mp hx) + have hy : (p.2 - q.2).natAbs = 1 := by omega + rcases natAbs_one_cases hy with hy | hy + · refine ⟨⟨true, q, true⟩, ?_, ?_⟩ + · apply Prod.ext <;> simp [ContactGridEdge.left, ContactGridEdge.upper] <;> omega + · simp [ContactGridEdge.right] + · refine ⟨⟨true, p, false⟩, ?_, ?_⟩ + · simp [ContactGridEdge.left] + · apply Prod.ext <;> simp [ContactGridEdge.right, ContactGridEdge.upper] <;> omega + · have hy : (p.2 - q.2).natAbs = 0 := by omega + have hyeq : p.2 = q.2 := sub_eq_zero.mp (Int.natAbs_eq_zero.mp hy) + rcases natAbs_one_cases hx with hx | hx + · refine ⟨⟨false, q, true⟩, ?_, ?_⟩ + · apply Prod.ext <;> simp [ContactGridEdge.left, ContactGridEdge.upper] <;> omega + · simp [ContactGridEdge.right] + · refine ⟨⟨false, p, false⟩, ?_, ?_⟩ + · simp [ContactGridEdge.left] + · apply Prod.ext <;> simp [ContactGridEdge.right, ContactGridEdge.upper] <;> omega + +theorem ContactGridEdge.same_key_endpoints {e f : ContactGridEdge} (h : e.key = f.key) : + (e.left = f.left ∧ e.right = f.right) ∨ + (e.left = f.right ∧ e.right = f.left) := by + have hv : e.vertical = f.vertical := congrArg Prod.fst h + have ha : e.anchor = f.anchor := congrArg Prod.snd h + have hu : e.upper = f.upper := by simp only [ContactGridEdge.upper, hv, ha] + cases he : e.reversed <;> cases hf : f.reversed <;> + simp [ContactGridEdge.left, ContactGridEdge.right, he, hf, ha, hu] + +def SquareLatticeHeisenberg.contactEdge (F : SquareLatticeHeisenberg) (e : Fin F.edges) : + ContactGridEdge := + (exists_contactGridEdge (F.coordinate (F.left e)) (F.coordinate (F.right e)) (F.adjacent e)).choose + +@[simp] theorem SquareLatticeHeisenberg.contactEdge_left (F : SquareLatticeHeisenberg) + (e : Fin F.edges) : (F.contactEdge e).left = F.coordinate (F.left e) := + (exists_contactGridEdge _ _ (F.adjacent e)).choose_spec.1 + +@[simp] theorem SquareLatticeHeisenberg.contactEdge_right (F : SquareLatticeHeisenberg) + (e : Fin F.edges) : (F.contactEdge e).right = F.coordinate (F.right e) := + (exists_contactGridEdge _ _ (F.adjacent e)).choose_spec.2 + +/-- Distinct source edges cannot share a canonical strip, even when their +listed orientations are opposite. -/ +theorem SquareLatticeHeisenberg.contactEdge_key_injective (F : SquareLatticeHeisenberg) : + Function.Injective (fun e => (F.contactEdge e).key) := by + intro e f h + by_contra hne + have hs := F.edge_simple e f hne + rcases ContactGridEdge.same_key_endpoints h with ⟨hl, hr⟩ | ⟨hl, hr⟩ + · apply hs.1 + exact ⟨F.coordinate_injective (by simpa using hl), + F.coordinate_injective (by simpa using hr)⟩ + · apply hs.2 + exact ⟨F.coordinate_injective (by simpa using hl), + F.coordinate_injective (by simpa using hr)⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceInputCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceInputCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..41005cd231f86472a85d5a2490ebd3893865edf3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactSourceInputCorrectness.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactSourceInputProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactGeometryBlockSemantics +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceBondLists +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorListCorrectness + +namespace OAI + +/-! The raw-list program uses exactly the original source endpoints and +exactly the calibrated lengths of the final mediator edges. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactSourceInputProgram +open ContactMediator + +private theorem lookup_ofFn {α : Type*} {n : ℕ} (f : Fin n → α) (d : α) (i : Fin n) : + ((List.ofFn f).drop i.val).headD d = f i := by + rw [List.drop_eq_getElem_cons (by simpa only [List.length_ofFn] using i.isLt)] + simp only [List.headD_cons, List.getElem_ofFn] + +def literalInput (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : Input := + (P, (List.ofFn d.coordinate, (d.bonds.toList, List.ofFn ℓ))) + +theorem local_lookup (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (e : Fin d.edges) (negative : Bool) (a : LocalEdge) : + ContactLocalInputProgram.lookup + (P, (d.edges, (e.val, (negative, List.ofFn ℓ)))) a = ℓ (encodeEdge d.edges e a) := by + unfold ContactLocalInputProgram.lookup + rw [← encodeEdge_val] + exact lookup_ofFn ℓ 1 (encodeEdge d.edges e a) + +theorem local_record (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (e : Fin d.edges) (negative : Bool) : + ContactLocalInputProgram.record (P, (d.edges, (e.val, (negative, List.ofFn ℓ)))) = + ContactRationalLocal.input P negative (fun a => ℓ (encodeEdge d.edges e a)) := by + simp only [ContactLocalInputProgram.record, ContactRationalLocal.input, local_lookup] + +theorem literal_bond (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (e : Fin d.edges) : + bond (e.val, literalInput d P ℓ) = ((d.left e).val, ((d.right e).val, d.coefficient e)) := by + change ((List.ofFn (fun e : Fin d.edges => + ((d.left e).val, ((d.right e).val, d.coefficient e)))).drop e.val).headD _ = _ + exact lookup_ofFn _ _ e + +theorem literal_edge (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) + (e : Fin d.edges) : + edge (e.val, literalInput d P ℓ) = ContactGeometryBlockProgram.literalEdge d P ℓ e := by + unfold edge + rw [literal_bond] + change Prod.mk + (Prod.mk (((List.ofFn d.coordinate).drop (d.left e).val).headD (0, 0)) + (((List.ofFn d.coordinate).drop (d.right e).val).headD (0, 0))) + (ContactLocalInputProgram.record (P, ((d.bonds.toList).length, + (e.val, (decide (d.coefficient e < 0), List.ofFn ℓ))))) = _ + rw [lookup_ofFn, lookup_ofFn] + have hlen : d.bonds.toList.length = d.edges := by simp [MediatorIteration.Bonds.toList] + rw [hlen, local_record] + rfl + +theorem literal_edges (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + edges (literalInput d P ℓ) = + List.ofFn (ContactGeometryBlockProgram.literalEdge d P ℓ) := by + apply List.ext_getElem + · simp [edges, literalInput, MediatorIteration.Bonds.toList] + · intro i h₁ h₂ + have hi : i < d.edges := by simpa only [List.length_ofFn] using h₂ + simp only [edges, List.getElem_map, List.getElem_range, List.getElem_ofFn] + exact literal_edge d P ℓ ⟨i, hi⟩ + +theorem literal_positions (d : SquareLatticeHeisenberg) (P : ℕ) (ℓ : GlobalEdge d → ℚ) : + positions (literalInput d P ℓ) = + ContactGeometryBlockProgram.positions (ContactGeometryBlockProgram.literalInput d P ℓ) := by + unfold positions + rw [literal_edges] + rfl + +end ContinuumCoulomb.ContactSourceInputProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactStrips.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactStrips.lean new file mode 100644 index 0000000000000000000000000000000000000000..524e97e33e4b4a160c738ed11b3b66f786e4743f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactStrips.lean @@ -0,0 +1,157 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactTemplates + +namespace OAI + +/-! Uniform separation of contacts from different lattice edges. The estimates +use only fixed strip bounds, so the lattice size never enters their constants. -/ + +noncomputable section +namespace ContinuumCoulomb + +/-- Coordinates of an internal site in an oriented length-17 lattice edge. +Off-axis sites stay farther from both original endpoints. -/ +structure ContactStripSite where + axial : ℝ + transverse : ℝ + axial_lower : 1 ≤ axial + axial_upper : axial ≤ 16 + transverse_lower : 0 ≤ transverse + transverse_upper : transverse ≤ 4 / 3 + off_axis_lower : transverse ≠ 0 → 11 / 4 ≤ axial + off_axis_upper : transverse ≠ 0 → axial ≤ 57 / 4 + +def horizontalContact (a b : ℤ) (p : ContactStripSite) : ContactPoint := + contactPoint (17 * a + p.axial) (17 * b + p.transverse) + +def verticalContact (a b : ℤ) (p : ContactStripSite) : ContactPoint := + contactPoint (17 * a - p.transverse) (17 * b + p.axial) + +theorem contact_interval_lattice_distance {x margin : ℝ} + (hx : margin ≤ x) (hx' : x ≤ 17 - margin) (k : ℤ) : + margin ≤ |x - 17 * k| := by + by_cases hk : k ≤ 0 + · have hk' : (k : ℝ) ≤ 0 := by exact_mod_cast hk + exact (le_abs_self _).trans' (by linarith) + · have hk' : (1 : ℝ) ≤ k := by exact_mod_cast (show (1 : ℤ) ≤ k by omega) + exact (neg_le_abs _).trans' (by linarith) + +theorem contactPoint_coordinate_le_dist (p q : ContactPoint) (i : Fin 2) : + |p i - q i| ≤ dist p q := by + have hdist := EuclideanSpace.dist_sq_eq p q + simp only [Fin.sum_univ_two, Real.dist_eq, sq_abs] at hdist + fin_cases i + · change |p 0 - q 0| ≤ dist p q + nlinarith [sq_nonneg (p 1 - q 1), abs_nonneg (p 0 - q 0), + sq_abs (p 0 - q 0), show 0 ≤ dist p q from dist_nonneg] + · change |p 1 - q 1| ≤ dist p q + nlinarith [sq_nonneg (p 0 - q 0), abs_nonneg (p 1 - q 1), + sq_abs (p 1 - q 1), show 0 ≤ dist p q from dist_nonneg] + +/-- Perpendicular gadgets retain the paper's 1.4 nonlink margin. -/ +theorem perpendicularContact_separation (a b c d : ℤ) (p q : ContactStripSite) : + 7 / 5 < dist (horizontalContact a b p) (verticalContact c d q) := by + by_cases hp : p.transverse = 0 + · by_cases hq : q.transverse = 0 + · have hx := contact_interval_lattice_distance p.axial_lower + (show p.axial ≤ 17 - (1 : ℝ) by linarith [p.axial_upper]) (c - a) + have hy := contact_interval_lattice_distance q.axial_lower + (show q.axial ≤ 17 - (1 : ℝ) by linarith [q.axial_upper]) (b - d) + have hdist := contactPoint_dist_sq + (17 * a + p.axial) (17 * b + p.transverse) + (17 * c - q.transverse) (17 * d + q.axial) + have hx' : 1 ≤ |17 * (a : ℝ) + p.axial - (17 * c - q.transverse)| := by + push_cast at hx + rw [hq, sub_zero] + convert hx using 1 + congr 1 + ring + have hy' : 1 ≤ |17 * (b : ℝ) + p.transverse - (17 * d + q.axial)| := by + push_cast at hy + rw [hp] + have hneg : 17 * (b : ℝ) + 0 - (17 * d + q.axial) = + -(q.axial - 17 * ((b : ℝ) - d)) := by ring + rw [hneg, abs_neg] + exact hy + have hx2 : 1 ≤ (17 * (a : ℝ) + p.axial - (17 * c - q.transverse)) ^ 2 := by + nlinarith [sq_abs (17 * (a : ℝ) + p.axial - (17 * c - q.transverse))] + have hy2 : 1 ≤ (17 * (b : ℝ) + p.transverse - (17 * d + q.axial)) ^ 2 := by + nlinarith [sq_abs (17 * (b : ℝ) + p.transverse - (17 * d + q.axial))] + change dist (horizontalContact a b p) (verticalContact c d q) ^ 2 = _ at hdist + nlinarith [show 0 ≤ dist (horizontalContact a b p) (verticalContact c d q) from dist_nonneg] + · have hy := contact_interval_lattice_distance (q.off_axis_lower hq) + (show q.axial ≤ 17 - (11 / 4 : ℝ) by linarith [q.off_axis_upper hq]) (b - d) + push_cast at hy + have htriangle := abs_add_le (q.axial - 17 * ((b : ℝ) - d) - p.transverse) p.transverse + have htrans : |p.transverse| ≤ 4 / 3 := by + rw [abs_of_nonneg p.transverse_lower] + exact p.transverse_upper + have hcoordinate := contactPoint_coordinate_le_dist + (horizontalContact a b p) (verticalContact c d q) 1 + change |17 * (b : ℝ) + p.transverse - (17 * d + q.axial)| ≤ _ at hcoordinate + have hneg : q.axial - 17 * ((b : ℝ) - d) - p.transverse = + -(17 * (b : ℝ) + p.transverse - (17 * d + q.axial)) := by ring + rw [hneg, abs_neg] at htriangle + have hsum : -(17 * (b : ℝ) + p.transverse - (17 * d + q.axial)) + p.transverse = + q.axial - 17 * ((b : ℝ) - d) := by ring + rw [hsum] at htriangle + linarith + · have hx := contact_interval_lattice_distance (p.off_axis_lower hp) + (show p.axial ≤ 17 - (11 / 4 : ℝ) by linarith [p.off_axis_upper hp]) (c - a) + push_cast at hx + have htriangle := abs_sub_le (p.axial - 17 * ((c : ℝ) - a) + q.transverse) (0 : ℝ) q.transverse + simp only [sub_zero, zero_sub, abs_neg] at htriangle + have htrans : |q.transverse| ≤ 4 / 3 := by + rw [abs_of_nonneg q.transverse_lower] + exact q.transverse_upper + have hcoordinate := contactPoint_coordinate_le_dist + (horizontalContact a b p) (verticalContact c d q) 0 + change |17 * (a : ℝ) + p.axial - (17 * c - q.transverse)| ≤ _ at hcoordinate + have hdiff : p.axial - 17 * ((c : ℝ) - a) + q.transverse - q.transverse = + p.axial - 17 * ((c : ℝ) - a) := by ring + rw [hdiff] at htriangle + have hsum : p.axial - 17 * ((c : ℝ) - a) + q.transverse = + 17 * (a : ℝ) + p.axial - (17 * c - q.transverse) := by ring + rw [hsum] at htriangle + linarith + +/-- Internal points from distinct collinear length-17 intervals are at least +2 apart in their axial projection. -/ +theorem contact_interval_separation (a c : ℤ) (hne : a ≠ c) {x y : ℝ} + (hx : 1 ≤ x) (hx' : x ≤ 16) (hy : 1 ≤ y) (hy' : y ≤ 16) : + 2 ≤ |17 * (a : ℝ) + x - (17 * c + y)| := by + rcases lt_or_gt_of_ne hne with h | h + · have h' : (a : ℝ) + 1 ≤ c := by exact_mod_cast (show a + 1 ≤ c by omega) + exact (neg_le_abs _).trans' (by linarith) + · have h' : (c : ℝ) + 1 ≤ a := by exact_mod_cast (show c + 1 ≤ a by omega) + exact (le_abs_self _).trans' (by linarith) + +theorem contact_parallel_line_separation (b d : ℤ) (hne : b ≠ d) {x y : ℝ} + (hx : 0 ≤ x) (hx' : x ≤ 4 / 3) (hy : 0 ≤ y) (hy' : y ≤ 4 / 3) : + 47 / 3 ≤ |17 * (b : ℝ) + x - (17 * d + y)| := by + rcases lt_or_gt_of_ne hne with h | h + · have h' : (b : ℝ) + 1 ≤ d := by exact_mod_cast (show b + 1 ≤ d by omega) + exact (neg_le_abs _).trans' (by linarith) + · have h' : (d : ℝ) + 1 ≤ b := by exact_mod_cast (show d + 1 ≤ b by omega) + exact (le_abs_self _).trans' (by linarith) + +/-- Parallel gadgets from distinct oriented lattice edges do not interfere. -/ +theorem horizontalContact_separation (a b c d : ℤ) + (hne : (a, b) ≠ (c, d)) (p q : ContactStripSite) : + 7 / 5 < dist (horizontalContact a b p) (horizontalContact c d q) := by + by_cases hb : b = d + · have ha : a ≠ c := by intro ha; exact hne (Prod.ext ha hb) + have h := contact_interval_separation a c ha p.axial_lower p.axial_upper q.axial_lower q.axial_upper + have hdist := contactPoint_coordinate_le_dist (horizontalContact a b p) (horizontalContact c d q) 0 + change |17 * (a : ℝ) + p.axial - (17 * c + q.axial)| ≤ _ at hdist + linarith + · have h := contact_parallel_line_separation b d hb p.transverse_lower p.transverse_upper + q.transverse_lower q.transverse_upper + have hdist := contactPoint_coordinate_le_dist (horizontalContact a b p) (horizontalContact c d q) 1 + change |17 * (b : ℝ) + p.transverse - (17 * d + q.transverse)| ≤ _ at hdist + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactTemplates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactTemplates.lean new file mode 100644 index 0000000000000000000000000000000000000000..90730d959144a1a48cfc81df215fa3846617f232 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ContactTemplates.lean @@ -0,0 +1,122 @@ +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic + +namespace OAI + +/-! The two fixed nine-link contact templates used after spin subdivision. +Coordinates use the Euclidean plane. The link lengths and separation +bounds are stable under small movements of the sites. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +abbrev ContactPoint := EuclideanSpace ℝ (Fin 2) + +def contactPoint (x y : ℝ) : ContactPoint := WithLp.toLp 2 ![x, y] + +@[simp] theorem contactPoint_zero (x y : ℝ) : contactPoint x y 0 = x := rfl +@[simp] theorem contactPoint_one (x y : ℝ) : contactPoint x y 1 = y := rfl + +theorem contactPoint_dist_sq (x y x' y' : ℝ) : + dist (contactPoint x y) (contactPoint x' y') ^ 2 = + (x - x') ^ 2 + (y - y') ^ 2 := by + rw [EuclideanSpace.dist_sq_eq] + simp only [Fin.sum_univ_two, contactPoint_zero, contactPoint_one, Real.dist_eq, sq_abs] + +def contactSlopeHeight (c : ℝ) : ℝ := Real.sqrt (1 - c ^ 2) + +def contactStepX (c : ℝ) (k : ℕ) : ℝ := + if k = 2 ∨ k = 3 ∨ k = 5 ∨ k = 6 then c else 1 + +def contactStepY (c : ℝ) (k : ℕ) : ℝ := + if k = 2 ∨ k = 3 then contactSlopeHeight c + else if k = 5 ∨ k = 6 then -contactSlopeHeight c else 0 + +def contactPathVertex (c : ℝ) (k : ℕ) : ContactPoint := + contactPoint (∑ j ∈ Finset.range k, contactStepX c j) + (∑ j ∈ Finset.range k, contactStepY c j) + +theorem contactSlopeHeight_sq {c : ℝ} (hc : -1 ≤ c) (hc' : c ≤ 1) : + contactSlopeHeight c ^ 2 = 1 - c ^ 2 := by + apply Real.sq_sqrt + nlinarith + +theorem contactPathVertex_start (c : ℝ) : contactPathVertex c 0 = contactPoint 0 0 := by + simp [contactPathVertex] + +theorem contactPathVertex_end (c : ℝ) : + contactPathVertex c 9 = contactPoint (5 + 4 * c) 0 := by + ext i + fin_cases i + · norm_num [contactPathVertex, contactPoint, Finset.sum_range_succ, contactStepX] + ring + · norm_num [contactPathVertex, contactPoint, Finset.sum_range_succ, contactStepY] + +/-- Every specified link of either template has length exactly one. -/ +theorem contactPath_link_length {c : ℝ} (hc : -1 ≤ c) (hc' : c ≤ 1) (k : ℕ) : + dist (contactPathVertex c (k + 1)) (contactPathVertex c k) = 1 := by + have hs := contactSlopeHeight_sq hc hc' + have hsq : dist (contactPathVertex c (k + 1)) (contactPathVertex c k) ^ 2 = 1 := by + unfold contactPathVertex + rw [contactPoint_dist_sq] + simp only [Finset.sum_range_succ, add_sub_cancel_left] + unfold contactStepX contactStepY + split_ifs <;> (try omega) <;> nlinarith + nlinarith [show 0 ≤ dist (contactPathVertex c (k + 1)) (contactPathVertex c k) from dist_nonneg] + +theorem contactStepX_lower {c : ℝ} (hc : c ≤ 1) (k : ℕ) : c ≤ contactStepX c k := by + unfold contactStepX + split_ifs <;> linarith + +/-- Horizontal projection accumulates a uniform positive amount per step. -/ +theorem contactPath_horizontal_lower {c : ℝ} (hc : c ≤ 1) {i j : ℕ} (hij : i ≤ j) : + c * (j - i : ℕ) ≤ contactPathVertex c j 0 - contactPathVertex c i 0 := by + change c * (j - i : ℕ) ≤ (∑ k ∈ Finset.range j, contactStepX c k) - + ∑ k ∈ Finset.range i, contactStepX c k + rw [← Finset.sum_Ico_eq_sub _ hij] + calc + c * (j - i : ℕ) = ∑ _k ∈ Finset.Ico i j, c := by simp [mul_comm] + _ ≤ _ := Finset.sum_le_sum (fun k _ => contactStepX_lower hc k) + +/-- Nonconsecutive vertices on a backbone are separated by at least 1.5. -/ +theorem contactPath_nonlink_separation {c : ℝ} (hc : 3 / 4 ≤ c) (hc' : c ≤ 1) + {i j : ℕ} (hij : i + 2 ≤ j) : + 3 / 2 ≤ dist (contactPathVertex c j) (contactPathVertex c i) := by + have h := contactPath_horizontal_lower hc' (show i ≤ j by omega) + have hcount : (2 : ℝ) ≤ (j - i : ℕ) := by exact_mod_cast (show 2 ≤ j - i by omega) + have hx : 3 / 2 ≤ contactPathVertex c j 0 - contactPathVertex c i 0 := by + nlinarith + have hdist := contactPoint_dist_sq + (∑ k ∈ Finset.range j, contactStepX c k) (∑ k ∈ Finset.range j, contactStepY c k) + (∑ k ∈ Finset.range i, contactStepX c k) (∑ k ∈ Finset.range i, contactStepY c k) + change dist (contactPathVertex c j) (contactPathVertex c i) ^ 2 = + (contactPathVertex c j 0 - contactPathVertex c i 0) ^ 2 + + (contactPathVertex c j 1 - contactPathVertex c i 1) ^ 2 at hdist + nlinarith [sq_nonneg (contactPathVertex c j 1 - contactPathVertex c i 1), + show 0 ≤ dist (contactPathVertex c j) (contactPathVertex c i) from dist_nonneg] + +theorem contactTemplate_span_eight : contactPathVertex (3 / 4) 9 = contactPoint 8 0 := by + rw [contactPathVertex_end] + norm_num + +theorem contactTemplate_span_eight_half : + contactPathVertex (7 / 8) 9 = contactPoint (17 / 2) 0 := by + rw [contactPathVertex_end] + norm_num + +/-- The paper's nonlink margin survives independent small movements. -/ +theorem contact_separation_stable (x y x' y' : ContactPoint) + (hsep : 7 / 5 ≤ dist x y) (hx : dist x x' ≤ 1 / 20) (hy : dist y y' ≤ 1 / 20) : + 6 / 5 < dist x' y' := by + have h := dist_triangle x x' y + have h' := dist_triangle x' y' y + rw [dist_comm y' y] at h' + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoordinateLaplacian.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoordinateLaplacian.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91cb437d3fa835b54ab5a7caa5d337b83494a67 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoordinateLaplacian.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Laplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitPullback + +namespace OAI + +/-! Coordinate identities for the actual three-dimensional Laplacian. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +private def directionalSecond {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (f : E → ℝ) (e x : E) : ℝ := fderiv ℝ (fun y => fderiv ℝ f y e) x e + +private theorem directionalSecond_affine {E F : Type*} + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] + (f : F → ℝ) (hf : ContDiff ℝ 2 f) (L : E →L[ℝ] F) (c : F) (e x : E) : + directionalSecond (fun y => f (L y+c)) e x = directionalSecond f (L e) (L x+c) := by + have hfirst (y : E) : fderiv ℝ (fun z => f (L z+c)) y e = + fderiv ℝ f (L y+c) (L e) := by + exact congrArg (fun M : E →L[ℝ] ℝ => M e) + (((hf.differentiable (by norm_num) _).hasFDerivAt).comp y + (L.hasFDerivAt.add_const c)).fderiv + have hd : ContDiff ℝ 1 (fun y => fderiv ℝ f y (L e)) := + (hf.fderiv_right (show (1 : WithTop ℕ∞)+1 ≤ 2 by norm_num)).clm_apply contDiff_const + unfold directionalSecond + simp_rw [hfirst] + exact congrArg (fun M : E →L[ℝ] ℝ => M e) + (((hd.differentiable (by norm_num) _).hasFDerivAt).comp x + (L.hasFDerivAt.add_const c)).fderiv + +private theorem split_planar_second (f : SplitPosition → ℝ) (hf : ContDiff ℝ 2 f) + (a : Fin 2) (p : SplitPosition) : + planarPartial (planarPartial (fun r => f (r,p.2)) (planarAxis a)) (planarAxis a) p.1 = + directionalSecond f (planarAxis a,0) p := by + change directionalSecond (fun r => f (r,p.2)) (planarAxis a) p.1 = _ + have h := directionalSecond_affine f hf + (ContinuousLinearMap.inl ℝ PlanarPosition ℝ) (0,p.2) (planarAxis a) p.1 + simpa only [ContinuousLinearMap.inl_apply, + Prod.mk_add_mk, add_zero, zero_add] using h + +private theorem split_vertical_second (f : SplitPosition → ℝ) (hf : ContDiff ℝ 2 f) + (p : SplitPosition) : + deriv (deriv (fun z => f (p.1,z))) p.2 = directionalSecond f (0,1) p := by + have h := directionalSecond_affine f hf + (ContinuousLinearMap.inr ℝ PlanarPosition ℝ) (p.1,0) 1 p.2 + simpa only [directionalSecond, fderiv_apply_one_eq_deriv, ContinuousLinearMap.inr_apply, + Prod.mk_add_mk, add_zero, zero_add] using h + +theorem oneElectron_split_laplacian (f : SplitPosition → ℝ) (hf : ContDiff ℝ 2 f) + (x : Configuration 1) : + configurationRealLaplacian (fun y => f (positionSplitCoordinates (oneElectronCoordinates y))) x = + splitLaplacian f (positionSplitCoordinates (oneElectronCoordinates x)) := by + let L : Configuration 1 →L[ℝ] SplitPosition := + positionSplitCoordinates.toContinuousLinearMap.comp oneElectronCoordinates.toContinuousLinearEquiv.toContinuousLinearMap + have hs (a : Fin 3) : + directionalSecond (fun y => f (positionSplitCoordinates (oneElectronCoordinates y))) + (EuclideanSpace.single (0,a) 1) x = + directionalSecond f (positionSplitCoordinates (EuclideanSpace.single a 1)) + (positionSplitCoordinates (oneElectronCoordinates x)) := by + simpa only [ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, + LinearIsometryEquiv.coe_toContinuousLinearEquiv, oneElectronCoordinates_single, add_zero, L] using + directionalSecond_affine f hf L 0 (EuclideanSpace.single (0,a) 1) x + have hp (a : Fin 2) : positionSplitCoordinates (EuclideanSpace.single (Fin.castSucc a) 1) = + (planarAxis a,0) := by + rw [← splitCoordinate_planar_axis, ContinuousLinearEquiv.apply_symm_apply] + have hz : positionSplitCoordinates (EuclideanSpace.single (2:Fin 3) 1) = (0,1) := by + rw [← splitCoordinate_vertical_axis, ContinuousLinearEquiv.apply_symm_apply] + unfold configurationRealLaplacian configurationRealPartial + change (∑ a : Fin 1 × Fin 3, directionalSecond _ (EuclideanSpace.single a 1) x) = _ + rw [Fintype.sum_prod_type, Fin.sum_univ_one] + simp_rw [hs] + change positionSplitCoordinates (EuclideanSpace.single (Fin.last 2) 1) = (0,1) at hz + rw [Fin.sum_univ_castSucc (n := 2),hz] + simp_rw [hp] + unfold splitLaplacian planarLaplacian + simp_rw [split_planar_second f hf, split_vertical_second f hf] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalCongruence.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..77faa6727fea886454d4d5e64a57ee3137f64c84 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalCongruence.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ElectronSlotBound + +namespace OAI + +/-! The core occupation depends only on the L2 state. A global phase and +fermionic coordinate permutations preserve it. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem coreOrbitalCoefficient_phase_ae {n : ℕ} (u v : Coulomb.H1Vector (n+1)) + (c : ℂ) (h : ∀ s, u.value s =ᵐ[volume] fun x => c*v.value s x) + (φ : Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) (t : SpinConfiguration 1) : + coreOrbitalCoefficient u φ s t =ᵐ[volume] + fun x => c*coreOrbitalCoefficient v φ s t x := by + have hp := (Coulomb.joinConfiguration_measurePreserving n 1).quasiMeasurePreserving.ae + (h (Fin.append s t)) + filter_upwards [Measure.ae_ae_of_ae_prod hp] with x hx + unfold coreOrbitalCoefficient + calc + _ = ∫ y, c*(star (φ y)*v.value (Fin.append s t) (Coulomb.joinConfiguration n 1 (x,y))) := by + apply integral_congr_ae + filter_upwards [hx] with y hy + change u.value (Fin.append s t) (Coulomb.joinConfiguration n 1 (x,y)) = + c*v.value (Fin.append s t) (Coulomb.joinConfiguration n 1 (x,y)) at hy + rw [hy] + ring + _ = _ := integral_const_mul _ _ + +theorem coreOrbitalMass_phase {n : ℕ} {ι : Type*} [Fintype ι] + (u v : Coulomb.H1Vector (n+1)) (c : ℂ) (hc : ‖c‖=1) + (h : ∀ s, u.value s =ᵐ[volume] fun x => c*v.value s x) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) : + coreOrbitalMass u φ = coreOrbitalMass v φ := by + rw [coreOrbitalMass_eq_coefficients,coreOrbitalMass_eq_coefficients] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro t _ + apply Finset.sum_congr rfl + intro i _ + apply integral_congr_ae + filter_upwards [coreOrbitalCoefficient_phase_ae u v c h (φ i) s t] with x hx + rw [hx,norm_mul,hc,one_mul] + +theorem coreOrbitalMass_permutation {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) (hu : Coulomb.Antisymmetric u) + (p : Equiv.Perm (Fin (n+1))) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) : + coreOrbitalMass (u.permutation p) φ = coreOrbitalMass u φ := by + apply coreOrbitalMass_phase _ _ ((p.sign : ℤ):ℂ) (Coulomb.sign_complex_norm p) + intro s + filter_upwards [hu p s] with x hx + rw [Coulomb.permutation_value,hx] + +theorem totalOrbitalMass_antisymmetric {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) (hu : Coulomb.Antisymmetric u) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) : + totalOrbitalMass u φ = (n+1:ℕ)*coreOrbitalMass u φ := by + unfold totalOrbitalMass electronSlotOrbitalMass + simp_rw [coreOrbitalMass_permutation u hu] + simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d005a15af8c5a27d430fdf4c49b8431d7d99d6a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreOrbitalProjection.lean @@ -0,0 +1,123 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1FiniteProjection +import OAI.Analysis.CoulombRadii.FormDomain.CoreKinetic + +namespace OAI + +/-! Integrating the one-particle projection estimate over the other electron +coordinates. Slices belong to the full weak-H1 domain almost everywhere. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem h1_inner_orbital {n : ℕ} (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (φ : Lp ℂ 2 (volume : Measure (Configuration n))) : + inner ℂ φ (h1Coordinates u (Sum.inl s)) = + ∫ x, star (φ x)*u.value s x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [(h1Coordinate_memLp u (Sum.inl s)).coeFn_toLp] with x hx + change h1Coordinates u (Sum.inl s) x = u.value s x at hx + rw [hx,RCLike.inner_apply] + exact mul_comm _ _ + +def coreOrbitalCoefficient {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (φ : Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) (t : SpinConfiguration 1) (x : Configuration n) : ℂ := + ∫ y, star (φ y)*u.value (Fin.append s t) (Coulomb.joinConfiguration n 1 (x,y)) + +theorem coreOrbitalCoefficient_memLp {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (φ : Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) (t : SpinConfiguration 1) : + MemLp (coreOrbitalCoefficient u φ s t) 2 := + Coulomb.fiberContract_memLp (Lp.memLp φ) + ((u.value_L2 (Fin.append s t)).comp_measurePreserving + (Coulomb.joinConfiguration_measurePreserving n 1)) + +theorem core_graphOrbitalMass_ae {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) : + (fun x => graphOrbitalMass φ (h1Coordinates (u.coreSlice s x))) =ᵐ[volume] + fun x => ∑ t, ∑ i, ‖coreOrbitalCoefficient u (φ i) s t x‖^2 := by + filter_upwards [u.coreSliceRegular_ae s] with x hx + simp only [graphOrbitalMass,h1_inner_orbital,u.coreSlice_value s hx, + coreOrbitalCoefficient] + +theorem core_graphOrbitalMass_integrable {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) : + Integrable (fun x => graphOrbitalMass φ (h1Coordinates (u.coreSlice s x))) := by + apply Integrable.congr _ (core_graphOrbitalMass_ae u φ s).symm + exact integrable_finsetSum _ (fun t _ => integrable_finsetSum _ + (fun i _ => (coreOrbitalCoefficient_memLp u (φ i) s t).norm.integrable_sq)) + +def coreOrbitalMass {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) : ℝ := + ∑ s, ∫ x, graphOrbitalMass φ (h1Coordinates (u.coreSlice s x)) + +theorem coreOrbitalMass_eq_coefficients {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) : + coreOrbitalMass u φ = ∑ s, ∑ t, ∑ i, ∫ x, ‖coreOrbitalCoefficient u (φ i) s t x‖^2 := by + unfold coreOrbitalMass + apply Finset.sum_congr rfl + intro s _ + rw [integral_congr_ae (core_graphOrbitalMass_ae u φ s), + integral_finsetSum _ (fun t _ => integrable_finsetSum _ + (fun i _ => (coreOrbitalCoefficient_memLp u (φ i) s t).norm.integrable_sq))] + apply Finset.sum_congr rfl + intro t _ + exact integral_finsetSum _ + (fun i _ => (coreOrbitalCoefficient_memLp u (φ i) s t).norm.integrable_sq) + +theorem bounded_state_potential_integrable {n : ℕ} (u : Coulomb.H1Vector n) + (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) + (hB : ∀ x, |V x| ≤ B) (s : SpinConfiguration n) : + Integrable (fun x => V x*‖u.value s x‖^2) := by + apply ((u.value_L2 s).norm.integrable_sq.const_mul B).mono' + (hV.aestronglyMeasurable.mul ((u.value_L2 s).aestronglyMeasurable.norm.pow 2)) + filter_upwards [] with x + change ‖V x*‖u.value s x‖^2‖ ≤ B*‖u.value s x‖^2 + rw [Real.norm_eq_abs,abs_mul,abs_of_nonneg (sq_nonneg ‖u.value s x‖)] + exact mul_le_mul_of_nonneg_right (hB x) (sq_nonneg _) + +theorem coreOneBody_projection_lower {n : ℕ} {ι : Type*} [Fintype ι] + (V : Configuration 1 → ℝ) (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) + (φ : ι → Lp ℂ 2 (volume : Measure (Configuration 1))) (E κ : ℝ) + (hbound : ∀ v : Coulomb.H1Vector 1, + E*Coulomb.mass v-κ*graphOrbitalMass φ (h1Coordinates v) ≤ boundedPotentialForm V v) + (u : Coulomb.H1Vector (n+1)) : + E*Coulomb.mass u-κ*coreOrbitalMass u φ ≤ Coulomb.coreKinetic u+ + Coulomb.potentialForm (fun z => V ((Coulomb.joinConfiguration n 1).symm z).2) u := by + have hip (st : SpinConfiguration (n+1)) : Integrable + (fun z => V ((Coulomb.joinConfiguration n 1).symm z).2*‖u.value st z‖^2) := + bounded_state_potential_integrable u _ + (hV.comp ((Coulomb.joinConfiguration n 1).symm.continuous.snd)) B (fun z => hB _) st + have hp (s : SpinConfiguration n) := + Coulomb.potentialForm_coreSlice_parameter_integrable u s (fun _ y => V y) + (fun t => hip (Fin.append s t)) + have hs (s : SpinConfiguration n) := integral_mono + (((Coulomb.mass_coreSlice_integrable u s).const_mul E).sub + ((core_graphOrbitalMass_integrable u φ s).const_mul κ)) + ((Coulomb.kinetic_coreSlice_integrable u s).add (hp s)) + (fun x => hbound (u.coreSlice s x)) + have hh := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hs s) + simp only [Pi.sub_apply,Pi.add_apply] at hh + simp_rw [integral_sub ((Coulomb.mass_coreSlice_integrable u _).const_mul E) + ((core_graphOrbitalMass_integrable u φ _).const_mul κ),integral_const_mul, + integral_add (Coulomb.kinetic_coreSlice_integrable u _) (hp _)] at hh + have hpot := Coulomb.integral_potentialForm_coreSlice_parameter u (fun _ y => V y) hip + simp only [Coulomb.potentialForm] at hpot + simpa only [Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum, + Coulomb.integral_mass_coreSlice,Coulomb.integral_kinetic_coreSlice, + coreOrbitalMass,Coulomb.coreKinetic,Coulomb.potentialForm,hpot] using hh + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreTensorFiber.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreTensorFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa2d646824a19f0f2aaf92ff995570d7eb959eb8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoreTensorFiber.lean @@ -0,0 +1,192 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.LastTensorFiber +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.FullSpinTensorCoefficients +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoreOrbitalProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealSpinOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronClosure +import OAI.Analysis.CoulombRadii.FieldAnalysis.SpinConfigurationIntegral + +namespace OAI + +/-! The last-coordinate contraction in full spin space is exactly the +core-slice orbital coefficient used by the many-electron energy bound. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +def spinConfigurationPoint {n : ℕ} (s : SpinConfiguration n) (x : Configuration n) : + Fin n → Fin 2 × (Fin 3 → ℝ) := fun i => (s i,fun a => x (i,a)) + +theorem spinConfigurationPoint_coordinates {n : ℕ} + (z : Fin n → Fin 2 × (Fin 3 → ℝ)) : + spinConfigurationPoint ((Coulomb.spinCubeEquiv n) z).1 + (WithLp.toLp 2 ((Coulomb.spinCubeEquiv n) z).2) = z := by + rfl + +theorem cubeState_snoc {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (s : SpinConfiguration n) (x : Configuration n) (t : Fin 2) (y : Configuration 1) : + Coulomb.cubeState u (Fin.snoc (spinConfigurationPoint s x) + (t,fun a => y (0,a))) = + u.value (Fin.append s (fun _ => t)) (Coulomb.joinConfiguration n 1 (x,y)) := by + unfold Coulomb.cubeState + congr 1 + · funext i + refine Fin.lastCases ?_ (fun j => ?_) i + · simp [Fin.append_right_eq_snoc] + · simp [Fin.append_right_eq_snoc,spinConfigurationPoint] + · apply PiLp.ext + intro a + obtain ⟨i,b⟩ := a + refine Fin.lastCases ?_ (fun j => ?_) i + · simp only [Fin.snoc_last] + change y (0,b) = Coulomb.joinConfiguration n 1 (x,y) (Fin.last n,b) + simpa only [show Fin.natAdd n (0:Fin 1) = Fin.last n from Fin.ext rfl] using + (Coulomb.joinConfiguration_right n 1 x y (0:Fin 1) b).symm + · simp only [Fin.snoc_castSucc] + change x (j,b) = Coulomb.joinConfiguration n 1 (x,y) (j.castSucc,b) + simpa only [show Fin.castAdd 1 j = j.castSucc from Fin.ext rfl] using + (Coulomb.joinConfiguration_left n 1 x y j b).symm + +theorem lastTensorFiber_coreSlice {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (s : SpinConfiguration n) (x : Configuration n) (hx : u.CoreSliceRegular s x) + (z : Fin 2 × (Fin 3 → ℝ)) : + lastTensorFiber (Coulomb.cubeState u) (spinConfigurationPoint s x,z) = + Coulomb.flatSpinOrbital (fun y t => (u.coreSlice s x).value (fun _ => t) + (oneElectronCoordinates.symm y)) z := by + change Coulomb.cubeState u (Fin.snoc (spinConfigurationPoint s x) z) = + (u.coreSlice s x).value (fun _ => z.1) (oneElectronCoordinates.symm (WithLp.toLp 2 z.2)) + rw [u.coreSlice_value s hx] + have hz : (z.1,fun a => oneElectronCoordinates.symm (WithLp.toLp 2 z.2) (0,a)) = z := by + exact Prod.ext rfl rfl + simpa only [hz] using cubeState_snoc u s x z.1 + (oneElectronCoordinates.symm (WithLp.toLp 2 z.2)) + +theorem coreOrbitalCoefficient_slice {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (φ : Lp ℂ 2 (volume : Measure (Configuration 1))) + (s : SpinConfiguration n) (x : Configuration n) (hx : u.CoreSliceRegular s x) + (t : SpinConfiguration 1) : + coreOrbitalCoefficient u φ s t x = + inner ℂ φ (h1Coordinates (u.coreSlice s x) (Sum.inl t)) := by + rw [h1_inner_orbital] + simp only [u.coreSlice_value s hx,coreOrbitalCoefficient] + +theorem lastTensorFiber_realOrbital_core {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (f : Position → ℝ) (hf : MemLp f 2) (σ : Fin 2) + (s : SpinConfiguration n) (x : Configuration n) (hx : u.CoreSliceRegular s x) : + Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital f σ)) (lastTensorFiber (Coulomb.cubeState u)) + (spinConfigurationPoint s x) = + coreOrbitalCoefficient u (oneElectronOrbitalLp f hf) s (fun _ => σ) x := by + let w (y : Position) (t : Fin 2) := + (u.coreSlice s x).value (fun _ => t) (oneElectronCoordinates.symm y) + have hw (t : Fin 2) : MemLp (fun y => w y t) 2 := + ((u.coreSlice s x).value_L2 (fun _ => t)).comp_measurePreserving + oneElectronCoordinates.symm.measurePreserving + have he : Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital f σ)) (lastTensorFiber (Coulomb.cubeState u)) + (spinConfigurationPoint s x) = + ∫ z, star (Coulomb.flatSpinOrbital (realSpinOrbital f σ) z)*Coulomb.flatSpinOrbital w z + ∂Coulomb.spinSpaceMeasure := by + unfold Coulomb.fiberContract + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun z => congrArg (fun c => + star (Coulomb.flatSpinOrbital (realSpinOrbital f σ) z)*c) + (lastTensorFiber_coreSlice u s x hx z)) + rw [he,Coulomb.flatSpinOrbital_inner _ w (realSpinOrbital_memLp f hf σ) hw] + have hsum : (∑ t : Fin 2, ∫ y, star (realSpinOrbital f σ y t)*w y t) = + ∫ y, (f y:ℂ)*w y σ := by + have hpoint (t : Fin 2) : (∫ y, star (realSpinOrbital f σ y t)*w y t) = + if t=σ then (∫ y, (f y:ℂ)*w y σ) else 0 := by + by_cases ht : t=σ + · subst t + simp only [realSpinOrbital,ite_true,Complex.star_def,Complex.conj_ofReal] + · simp only [realSpinOrbital,ht,ite_false,star_zero,zero_mul,integral_zero] + simp only [hpoint] + simp + rw [hsum,coreOrbitalCoefficient_slice u _ s x hx,oneElectron_inner_real_orbital] + rw [← oneElectronCoordinates_integral_complex (fun y => (f y:ℂ)*w y σ)] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun y => by + dsimp [w] + rw [LinearIsometryEquiv.symm_apply_apply] + ring) + +theorem lastTensorFiber_realOrbital_integral {n : ℕ} (u : Coulomb.H1Vector (n+1)) + (f : Position → ℝ) (hf : MemLp f 2) (σ : Fin 2) : + (∫ y, ‖Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital f σ)) (lastTensorFiber (Coulomb.cubeState u)) y‖^2 + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure)) = + ∑ s, ∫ x, ‖coreOrbitalCoefficient u (oneElectronOrbitalLp f hf) s (fun _ => σ) x‖^2 := by + have hs (s : SpinConfiguration n) := + (PiLp.volume_preserving_toLp (Fin n × Fin 3)).quasiMeasurePreserving.ae + (u.coreSliceRegular_ae s) + have hp := (Measure.quasiMeasurePreserving_snd + (μ := (Measure.count : Measure (SpinConfiguration n)))).ae (ae_all_iff.mpr hs) + have ht := (Coulomb.spinCubeEquiv_full_measurePreserving n).quasiMeasurePreserving.ae hp + have he : (fun y => ‖Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital f σ)) (lastTensorFiber (Coulomb.cubeState u)) y‖^2) =ᵐ[ + Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure] + fun y => ‖coreOrbitalCoefficient u (oneElectronOrbitalLp f hf) + ((Coulomb.spinCubeEquiv n) y).1 (fun _ => σ) + (WithLp.toLp 2 ((Coulomb.spinCubeEquiv n) y).2)‖^2 := by + filter_upwards [ht] with y hy + have h := lastTensorFiber_realOrbital_core u f hf σ + ((Coulomb.spinCubeEquiv n) y).1 (WithLp.toLp 2 ((Coulomb.spinCubeEquiv n) y).2) + (hy ((Coulomb.spinCubeEquiv n) y).1) + rw [spinConfigurationPoint_coordinates] at h + exact congrArg (fun z : ℂ => ‖z‖^2) h + rw [integral_congr_ae he] + exact Coulomb.spinConfiguration_integral _ (fun s => + (coreOrbitalCoefficient_memLp u (oneElectronOrbitalLp f hf) s (fun _ => σ)).norm.integrable_sq) + +theorem coreOrbitalMass_last_occupation {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) (f : ι → Position → ℝ) (hf : ∀ i, MemLp (f i) 2) : + coreOrbitalMass u (fun i => oneElectronOrbitalLp (f i) (hf i)) = + ∑ i, ∑ σ : Fin 2, ∫ y, ‖Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital (f i) σ)) (lastTensorFiber (Coulomb.cubeState u)) y‖^2 + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure) := by + rw [coreOrbitalMass_eq_coefficients] + have he (i : ι) (σ : Fin 2) := lastTensorFiber_realOrbital_integral u (f i) (hf i) σ + simp_rw [he] + symm + calc + _ = ∑ i, ∑ s, ∑ σ : Fin 2, ∫ x, + ‖coreOrbitalCoefficient u (oneElectronOrbitalLp (f i) (hf i)) s (fun _ => σ) x‖^2 := by + apply Finset.sum_congr rfl + intro i _ + exact Finset.sum_comm + _ = ∑ s, ∑ i, ∑ σ : Fin 2, ∫ x, + ‖coreOrbitalCoefficient u (oneElectronOrbitalLp (f i) (hf i)) s (fun _ => σ) x‖^2 := + Finset.sum_comm + _ = ∑ s, ∑ σ : Fin 2, ∑ i, ∫ x, + ‖coreOrbitalCoefficient u (oneElectronOrbitalLp (f i) (hf i)) s (fun _ => σ) x‖^2 := by + apply Finset.sum_congr rfl + intro s _ + exact Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl + intro s _ + exact (Equiv.funUnique (Fin 1) (Fin 2)).symm.sum_comp + (fun t : SpinConfiguration 1 => ∑ i, ∫ x, + ‖coreOrbitalCoefficient u (oneElectronOrbitalLp (f i) (hf i)) s t x‖^2) + +theorem coreOrbitalMass_first_occupation {n : ℕ} {ι : Type*} [Fintype ι] + (u : Coulomb.H1Vector (n+1)) (hu : Coulomb.Antisymmetric u) + (f : ι → Position → ℝ) (hf : ∀ i, MemLp (f i) 2) : + coreOrbitalMass u (fun i => oneElectronOrbitalLp (f i) (hf i)) = + ∑ i, ∑ σ : Fin 2, ∫ y, ‖Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (realSpinOrbital (f i) σ)) (Coulomb.firstFiber (Coulomb.cubeState u)) y‖^2 + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure) := by + rw [coreOrbitalMass_last_occupation u f hf] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro σ _ + exact last_first_fiber_norm_integral _ (fullSpin_antisymmetric u hu) _ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedComplement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..15d6519694e25d48112e2db6e33694db4c2a87c9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedComplement.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.OrthonormalLocalizedModes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronClosure + +namespace OAI + +/-! Symmetric Gram correction preserves the actual orbital span and hence its +orthogonal complement. The inverse coefficients are obtained from the proved +Gram identity, without adding a spectral hypothesis. -/ + +noncomputable section +open MeasureTheory Matrix +open scoped BigOperators +namespace ContinuumCoulomb + +theorem correctedLocalizedCoefficients_leftInverse {D : ℝ} {m : ℕ} + (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) : + (localizedModeGram u*correctedLocalizedCoefficients u)* + correctedLocalizedCoefficients u = 1 := by + have h := correctedLocalizedCoefficients_gram u hsep hs + have ht : (correctedLocalizedCoefficients u)ᵀ = correctedLocalizedCoefficients u := + GramCorrection.correction_transpose (localizedModeGram_isHermitian u) + rw [ht, Matrix.mul_assoc] at h + exact mul_eq_one_comm.mp h + +theorem continuumLocalizedMode_expand_corrected {D : ℝ} {m : ℕ} (freq : ℝ) + (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (i : Fin m) (x : Position) : + continuumLocalizedMode freq (u i) x = + ∑ j, (localizedModeGram u*correctedLocalizedCoefficients u) i j * + correctedLocalizedMode freq u j x := by + symm + unfold correctedLocalizedMode localizedLinearOrbital + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [← mul_assoc, ← Finset.sum_mul, ← Matrix.mul_apply] + rw [correctedLocalizedCoefficients_leftInverse u hsep hs] + simp only [Matrix.one_apply, ite_mul, one_mul, zero_mul, + Finset.sum_ite_eq, Finset.mem_univ, ite_true] + +theorem corrected_orthogonal_implies_raw {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) + (f : Position → ℂ) (hf : MemLp f 2) + (ho : ∀ j, (∫ x, f x*(correctedLocalizedMode freq u j x : ℂ)) = 0) + (i : Fin m) : (∫ x, f x*(continuumLocalizedMode freq (u i) x : ℂ)) = 0 := by + have hi (j : Fin m) : Integrable (fun x => + ((localizedModeGram u*correctedLocalizedCoefficients u) i j : ℂ)* + (f x*(correctedLocalizedMode freq u j x : ℂ))) := + (hf.integrable_mul (correctedLocalizedMode_memLp hfreq u j).ofReal).const_mul _ + have he (x : Position) : f x*(continuumLocalizedMode freq (u i) x : ℂ) = + ∑ j, ((localizedModeGram u*correctedLocalizedCoefficients u) i j : ℂ)* + (f x*(correctedLocalizedMode freq u j x : ℂ)) := by + rw [continuumLocalizedMode_expand_corrected freq u hsep hs] + simp only [Complex.ofReal_sum,Complex.ofReal_mul,Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun j _ => hi j)] + simp only [integral_const_mul,ho,mul_zero,Finset.sum_const_zero] + +theorem corrected_graph_orthogonal_implies_raw {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (v : Coulomb.H1Vector 1) + (ho : ∀ s i, inner ℂ + (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = 0) : + graphOrbitalMass (fun i => oneElectronOrbitalLp (continuumLocalizedMode freq (u i)) + (continuumLocalizedMode_memLp hfreq (u i))) (h1Coordinates v) = 0 := by + apply graphOrbitalMass_eq_zero + intro s i + rw [oneElectron_inner_real_orbital] + have hf : MemLp (oneElectronPullback (v.value s)) 2 := + (v.value_L2 s).comp_measurePreserving oneElectronCoordinates.symm.measurePreserving + have hh (j : Fin m) : + (∫ x, oneElectronPullback (v.value s) x*(correctedLocalizedMode freq u j x : ℂ)) = 0 := by + have h := ho s j + rw [oneElectron_inner_real_orbital] at h + have he := oneElectronPullback_integral_complex + (fun x => v.value s x*(correctedLocalizedMode freq u j (oneElectronCoordinates x) : ℂ)) + simpa only [oneElectronPullback,LinearIsometryEquiv.apply_symm_apply] using he.trans h + have h := corrected_orthogonal_implies_raw hfreq u hsep hs _ hf hh i + have he := oneElectronPullback_integral_complex + (fun x => v.value s x*(continuumLocalizedMode freq (u i) (oneElectronCoordinates x) : ℂ)) + have he' : (∫ x, oneElectronPullback (v.value s) x*(continuumLocalizedMode freq (u i) x : ℂ)) = + ∫ x, v.value s x*(continuumLocalizedMode freq (u i) (oneElectronCoordinates x) : ℂ) := by + simpa only [oneElectronPullback,LinearIsometryEquiv.apply_symm_apply] using he + exact he'.symm.trans h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f20045b70903156d219c6e61f5c045b6989a7b8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossBound.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedCrossForm +import Mathlib.Algebra.Order.Chebyshev + +namespace OAI + +/-! The off-diagonal form bound sums over spatial modes and spin components, +without a sum over exponentially many many-electron occupations. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem complex_conj_sum_square_le {ι : Type*} [Fintype ι] (c z : ι → ℂ) : + ‖∑ i, (starRingEnd ℂ) (c i)*z i‖^2 ≤ (∑ i, ‖c i‖^2)*(∑ i, ‖z i‖^2) := by + have h : ‖∑ i, (starRingEnd ℂ) (c i)*z i‖ ≤ ∑ i, ‖c i‖*‖z i‖ := by + simpa only [norm_mul,Complex.norm_conj] using + norm_sum_le Finset.univ (fun i => (starRingEnd ℂ) (c i)*z i) + exact (pow_le_pow_left₀ (norm_nonneg _) h 2).trans + (Finset.sum_mul_sq_le_sq_mul_sq Finset.univ (fun i => ‖c i‖) (fun i => ‖z i‖)) + +theorem corrected_cross_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) + (c : SpinConfiguration 1 → Fin m → ℂ) (v : Coulomb.H1Vector 1) + (ho : ∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = 0) + (B : ℝ) (hB : ∀ x : Configuration 1, + |manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)| ≤ B) : + (graphBoundedCross (BoundedPotential.operator + (fun x => manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)) + ((manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + oneElectronCoordinates.continuous) B hB) + (h1Coordinates (correctedOneElectronState hfreq u c)) (h1Coordinates v))^2 ≤ + (4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j))* + Coulomb.mass (correctedOneElectronState hfreq u c)*Coulomb.mass v := by + let V : Configuration 1 → ℝ := fun x => + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x) + let E : ℝ := (-1/2:ℝ)+freq/2 + let z (s : SpinConfiguration 1) (i : Fin m) := + realOrbitalPairing V E (oneElectronCorrectedMode freq u i) v s + let err : ℝ := 4*(m:ℝ)*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) + have hz (s : SpinConfiguration 1) (i : Fin m) : + ‖z s i‖^2 ≤ err*(∫ x, ‖v.value s x‖^2) := + correctedModePairing_square_bound hdensity hrho hH hS hfreq hrelation hR hRH hRS + scale u hsep hs hδ hcoeff i v s + have hsum : (∑ s, ∑ i, ‖z s i‖^2) ≤ (m:ℝ)*err*Coulomb.mass v := by + calc + _ ≤ ∑ s : SpinConfiguration 1, ∑ _i : Fin m, err*(∫ x, ‖v.value s x‖^2) := + Finset.sum_le_sum (fun s _ => Finset.sum_le_sum (fun i _ => hz s i)) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + ← Finset.mul_sum,Coulomb.mass] + ring + have hcs := complex_conj_sum_square_le + (fun p : SpinConfiguration 1 × Fin m => c p.1 p.2) (fun p => z p.1 p.2) + simp only [Fintype.sum_prod_type] at hcs + rw [← correctedOneElectronState_mass hfreq u hsep hs c] at hcs + have hcomplex : ‖∑ s, ∑ i, (starRingEnd ℂ) (c s i)*z s i‖^2 ≤ + Coulomb.mass (correctedOneElectronState hfreq u c)*((m:ℝ)*err*Coulomb.mass v) := + hcs.trans (mul_le_mul_of_nonneg_left hsum (Coulomb.mass_nonneg _)) + rw [graphBoundedCross_eq_re,corrected_complex_cross_orthogonal hfreq u c V _ B E hB v ho] + have hre : ((∑ s, ∑ i, (starRingEnd ℂ) (c s i)*z s i).re)^2 ≤ + ‖∑ s, ∑ i, (starRingEnd ℂ) (c s i)*z s i‖^2 := by + rw [complex_norm_sq_parts] + nlinarith only [sq_nonneg ((∑ s, ∑ i, (starRingEnd ℂ) (c s i)*z s i).im)] + apply hre.trans + convert hcomplex using 1 + dsimp [err] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..21d5d3d4b491d2398929a01a7f58d9cd448df47c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedCrossForm.lean @@ -0,0 +1,101 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedFormCross +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedStateCoordinates + +namespace OAI + +/-! The mixed form of an actual corrected-orbital state is the finite sum +of its orbital residual pairings against the complementary state. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem corrected_potential_pairing {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (V : Configuration 1 → ℝ) + (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) + (BoundedPotential.operator V hV B hB (h1Coordinates v (Sum.inl s))) = + ∫ x, v.value s x*(V x*oneElectronCorrectedMode freq u i x : ℝ) := by + have hm : MemLp (fun x : Configuration 1 => (oneElectronCorrectedMode freq u i x : ℂ)) 2 := + (oneElectronCorrectedMode_memLp hfreq u i).ofReal + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hm.coeFn_toLp, + BoundedPotential.operator_ae V hV B hB (h1Coordinates v (Sum.inl s)), + (h1Coordinate_memLp v (Sum.inl s)).coeFn_toLp] with x hp hA hv + change oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i) x = (oneElectronCorrectedMode freq u i x : ℂ) at hp + change h1Coordinates v (Sum.inl s) x = v.value s x at hv + rw [hA,hp,hv,RCLike.inner_apply] + simp only [Complex.conj_ofReal,Complex.ofReal_mul] + ring + +theorem corrected_complex_cross_expansion {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (V : Configuration 1 → ℝ) (hV : Continuous V) (B E : ℝ) (hB : ∀ x, |V x| ≤ B) + (v : Coulomb.H1Vector 1) : + graphComplexCross (BoundedPotential.operator V hV B hB) + (h1Coordinates (correctedOneElectronState hfreq u c)) (h1Coordinates v) = + ∑ s, ∑ i, (starRingEnd ℂ) (c s i)* + (realOrbitalPairing V E (oneElectronCorrectedMode freq u i) v s+ + (E:ℂ)*inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s))) := by + have hd (s : SpinConfiguration 1) (i : Fin m) (a : Fin 1 × Fin 3) : + inner ℂ (correctedPartialLp hfreq u i a) (h1Coordinates v (Sum.inr (s,a))) = + ∫ x, v.gradient s a x*(configurationRealPartial (oneElectronCorrectedMode freq u i) a x : ℂ) := + h1_inner_real_coordinate v (Sum.inr (s,a)) _ (oneElectronCorrectedMode_partial_memLp hfreq u i a) + have hv (s : SpinConfiguration 1) (i : Fin m) : + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = + ∫ x, v.value s x*(oneElectronCorrectedMode freq u i x : ℂ) := + oneElectron_inner_real_orbital v s _ (correctedLocalizedMode_memLp hfreq u i) + have hp (s : SpinConfiguration 1) (i : Fin m) : + realOrbitalPairing V E (oneElectronCorrectedMode freq u i) v s+ + (E:ℂ)*inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = + (1/2:ℂ)*(∑ a, inner ℂ (correctedPartialLp hfreq u i a) (h1Coordinates v (Sum.inr (s,a))))+ + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) + (BoundedPotential.operator V hV B hB (h1Coordinates v (Sum.inl s))) := by + simp only [realOrbitalPairing,hd,hv,corrected_potential_pairing hfreq u i V hV B hB] + ring + simp_rw [hp] + unfold graphComplexCross + simp_rw [correctedOneElectronState_gradient_coordinate,correctedOneElectronState_coordinate, + sum_inner,inner_smul_left] + have hk (s : SpinConfiguration 1) : + (∑ a : Fin 1 × Fin 3, ∑ i, (starRingEnd ℂ) (c s i)* + inner ℂ (correctedPartialLp hfreq u i a) (h1Coordinates v (Sum.inr (s,a)))) = + ∑ i, (starRingEnd ℂ) (c s i)* + ∑ a, inner ℂ (correctedPartialLp hfreq u i a) (h1Coordinates v (Sum.inr (s,a))) := by + rw [Finset.sum_comm] + simp only [Finset.mul_sum] + simp_rw [hk] + rw [Finset.mul_sum,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro s _ + rw [Finset.mul_sum,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + ring + +theorem corrected_complex_cross_orthogonal {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (V : Configuration 1 → ℝ) (hV : Continuous V) (B E : ℝ) (hB : ∀ x, |V x| ≤ B) + (v : Coulomb.H1Vector 1) + (ho : ∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = 0) : + graphComplexCross (BoundedPotential.operator V hV B hB) + (h1Coordinates (correctedOneElectronState hfreq u c)) (h1Coordinates v) = + ∑ s, ∑ i, (starRingEnd ℂ) (c s i)*realOrbitalPairing V E (oneElectronCorrectedMode freq u i) v s := by + rw [corrected_complex_cross_expansion hfreq u c V hV B E hB v] + simp only [ho,mul_zero,add_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedDiagonalBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedDiagonalBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..557a255a6c2fb595fbf23596ed722753a0a07aaf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedDiagonalBound.lean @@ -0,0 +1,137 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronProjectedLower + +namespace OAI + +/-! The same residual controls the actual compressed diagonal form, with no +entrywise sum over occupation configurations. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem corrected_residual_sum_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) + (c : SpinConfiguration 1 → Fin m → ℂ) (v : Coulomb.H1Vector 1) : + ‖∑ s, ∑ i, (starRingEnd ℂ) (c s i)* + realOrbitalPairing (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) ((-1/2:ℝ)+freq/2) (oneElectronCorrectedMode freq u i) v s‖^2 ≤ + (4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j))* + Coulomb.mass (correctedOneElectronState hfreq u c)*Coulomb.mass v := by + let z (s : SpinConfiguration 1) (i : Fin m) := + realOrbitalPairing (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) ((-1/2:ℝ)+freq/2) (oneElectronCorrectedMode freq u i) v s + let err := 4*(m:ℝ)*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) + have hz (s : SpinConfiguration 1) (i : Fin m) : + ‖z s i‖^2 ≤ err*(∫ x, ‖v.value s x‖^2) := + correctedModePairing_square_bound hdensity hrho hH hS hfreq hrelation hR hRH hRS + scale u hsep hs hδ hcoeff i v s + have hsum : (∑ s, ∑ i, ‖z s i‖^2) ≤ (m:ℝ)*err*Coulomb.mass v := by + calc + _ ≤ ∑ s : SpinConfiguration 1, ∑ _i : Fin m, err*(∫ x, ‖v.value s x‖^2) := + Finset.sum_le_sum (fun s _ => Finset.sum_le_sum (fun i _ => hz s i)) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + ← Finset.mul_sum,Coulomb.mass] + ring + have hcs := complex_conj_sum_square_le + (fun p : SpinConfiguration 1 × Fin m => c p.1 p.2) (fun p => z p.1 p.2) + simp only [Fintype.sum_prod_type] at hcs + rw [← correctedOneElectronState_mass hfreq u hsep hs c] at hcs + have h := hcs.trans (mul_le_mul_of_nonneg_left hsum (Coulomb.mass_nonneg _)) + convert h using 1 + dsimp [err] + ring + +theorem corrected_diagonal_residual_identity {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (c : SpinConfiguration 1 → Fin m → ℂ) + (V : Configuration 1 → ℝ) (hV : Continuous V) (B E : ℝ) (hB : ∀ x, |V x| ≤ B) : + boundedPotentialForm V (correctedOneElectronState hfreq u c)- + E*Coulomb.mass (correctedOneElectronState hfreq u c) = + (∑ s, ∑ i, (starRingEnd ℂ) (c s i)* + realOrbitalPairing V E (oneElectronCorrectedMode freq u i) + (correctedOneElectronState hfreq u c) s).re := by + have ho := correctedOneElectronOrbital_orthonormal hfreq u hsep hs + have hi (s : SpinConfiguration 1) (i : Fin m) : + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) + (h1Coordinates (correctedOneElectronState hfreq u c) (Sum.inl s)) = c s i := by + rw [correctedOneElectronState_coordinate] + exact ho.inner_right_sum (c s) (Finset.mem_univ i) + have he := corrected_complex_cross_expansion hfreq u c V hV B E hB + (correctedOneElectronState hfreq u c) + simp only [hi,mul_add,Finset.sum_add_distrib] at he + have hnorm (z : ℂ) : (starRingEnd ℂ) z*z = (‖z‖^2 : ℝ) := by + rw [← Complex.normSq_eq_conj_mul_self,Complex.normSq_eq_norm_sq] + have hm : (∑ s, ∑ i, (starRingEnd ℂ) (c s i)*((E:ℂ)*c s i)) = + (E*Coulomb.mass (correctedOneElectronState hfreq u c) : ℝ) := by + rw [correctedOneElectronState_mass hfreq u hsep hs c] + push_cast + simp_rw [show ∀ z : ℂ, (starRingEnd ℂ) z*((E:ℂ)*z) = (E:ℂ)*((starRingEnd ℂ) z*z) by + intro z; ring,hnorm] + simp only [← Finset.mul_sum] + push_cast + rfl + rw [hm] at he + have hre := congrArg Complex.re he + have hself : graphBoundedCross (BoundedPotential.operator V hV B hB) + (h1Coordinates (correctedOneElectronState hfreq u c)) + (h1Coordinates (correctedOneElectronState hfreq u c)) = + boundedPotentialForm V (correctedOneElectronState hfreq u c) := by + rw [boundedPotentialForm_eq_graph V hV B hB] + simp only [graphBoundedCross,graphBoundedForm,graphKinetic,real_inner_self_eq_norm_sq] + rw [← graphBoundedCross_eq_re,hself] at hre + simp only [Complex.add_re,Complex.ofReal_re] at hre + linarith + +theorem corrected_diagonal_lower + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R ε : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) + (hε : 0 ≤ ε) (herr : 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) ≤ ε^2) + (c : SpinConfiguration 1 → Fin m → ℂ) : + (((-1/2:ℝ)+freq/2)-ε)*Coulomb.mass (correctedOneElectronState hfreq u c) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) (correctedOneElectronState hfreq u c) := by + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hV := (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + oneElectronCoordinates.continuous + have hi := corrected_diagonal_residual_identity hfreq u hsep hs c _ hV B + ((-1/2:ℝ)+freq/2) (fun x => hB (oneElectronCoordinates x)) + simp only [Function.comp_def] at hi + have hb := corrected_residual_sum_square_bound hdensity hrho hH hS hfreq hrelation + hR hRH hRS scale u hsep hs hδ hcoeff c (correctedOneElectronState hfreq u c) + have hb' := hb.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right herr (Coulomb.mass_nonneg _)) (Coulomb.mass_nonneg _)) + have hreal : (boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) (correctedOneElectronState hfreq u c)- + ((-1/2:ℝ)+freq/2)*Coulomb.mass (correctedOneElectronState hfreq u c))^2 ≤ + ε^2*Coulomb.mass (correctedOneElectronState hfreq u c)* + Coulomb.mass (correctedOneElectronState hfreq u c) := by + rw [hi] + apply le_trans _ hb' + rw [complex_norm_sq_parts] + nlinarith only [sq_nonneg ((∑ s, ∑ i, (starRingEnd ℂ) (c s i)* + realOrbitalPairing (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) ((-1/2:ℝ)+freq/2) (oneElectronCorrectedMode freq u i) + (correctedOneElectronState hfreq u c) s).im)] + have hn : 0 ≤ ε*Coulomb.mass (correctedOneElectronState hfreq u c) := + mul_nonneg hε (Coulomb.mass_nonneg _) + nlinarith only [hreal,hn] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedManufacturedResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedManufacturedResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..a363285812df5da8dc43a401c66775d2543ae606 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedManufacturedResidual.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.OrthonormalLocalizedModes + +namespace OAI + +/-! Gram correction preserves a polynomial residual bound: it sums over +spatial modes, independently of the many-electron occupation basis. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def correctedManufacturedResidual (rho H S freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (x : Position) : ℝ := + ∑ j, correctedLocalizedCoefficients u i j*manufacturedOrbitalResidual rho H S freq scale u j x + +theorem correctedManufacturedResidual_memLp {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) (i : Fin m) : + MemLp (correctedManufacturedResidual rho H S freq scale u i) 2 := + memLp_finsetSum Finset.univ (fun j _ => + (manufacturedOrbitalResidual_memLp hrho hH hS hfreq scale u hδ hcoeff j).const_mul _) + +theorem correctedManufacturedResidual_square_bound {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (hδ : 0 ≤ δ) + (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) (i : Fin m) : + (∫ x, correctedManufacturedResidual rho H S freq scale u i x^2) ≤ + 4*(m : ℝ)*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) := by + have hraw (j : Fin m) := + manufacturedOrbitalResidual_square_integrable hrho hH.le hS.le hfreq scale u hδ hcoeff j + have hc (j : Fin m) : correctedLocalizedCoefficients u i j^2 ≤ 4 := by + have h := (correctedLocalizedCoefficients_entries u hsep hs i j).2 + calc + _ = |correctedLocalizedCoefficients u i j|^2 := (sq_abs _).symm + _ ≤ (2:ℝ)^2 := pow_le_pow_left₀ (abs_nonneg _) h 2 + _ = 4 := by norm_num + have hpoint (x : Position) : correctedManufacturedResidual rho H S freq scale u i x^2 ≤ + 4*(m : ℝ)*(∑ j, manufacturedOrbitalResidual rho H S freq scale u j x^2) := by + have h := sq_sum_le_card_mul_sum_sq (s := Finset.univ) + (f := fun j => correctedLocalizedCoefficients u i j*manufacturedOrbitalResidual rho H S freq scale u j x) + simp only [Finset.card_univ,Fintype.card_fin] at h + change correctedManufacturedResidual rho H S freq scale u i x^2 ≤ _ at h + apply h.trans + have hh := Finset.sum_le_sum (s := Finset.univ) (fun j _ => + mul_le_mul_of_nonneg_right (hc j) (sq_nonneg (manufacturedOrbitalResidual rho H S freq scale u j x))) + simp only [mul_pow] at * + have hmul := mul_le_mul_of_nonneg_left hh (Nat.cast_nonneg m : (0:ℝ) ≤ m) + calc + _ ≤ (m:ℝ)*(∑ j, 4*manufacturedOrbitalResidual rho H S freq scale u j x^2) := hmul + _ = _ := by rw [← Finset.mul_sum]; ring + have hi := integral_mono + (correctedManufacturedResidual_memLp hrho hH.le hS.le hfreq scale u hδ hcoeff i).integrable_sq + ((integrable_finsetSum Finset.univ (fun j _ => hraw j)).const_mul (4*(m:ℝ))) hpoint + rw [integral_const_mul,integral_finsetSum Finset.univ (fun j _ => hraw j)] at hi + exact hi.trans (mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun j _ => + manufacturedOrbitalResidual_square_bound hrho hH hS hfreq hR hRH hRS scale u hsep hδ hcoeff j)) + (by positivity)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedNuclearError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedNuclearError.lean new file mode 100644 index 0000000000000000000000000000000000000000..50d611e17a62cc754186c9728b58a840e0aa7b06 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedNuclearError.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.OrthonormalLocalizedModes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalNuclearError + +namespace OAI + +/-! Finite basis correction of the actual nuclear error form. Only +polynomially many orbital matrix entries are summed. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem localizedLinearOrbital_weighted_integrable (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*continuumLocalizedMode freq (u i) x* + continuumLocalizedMode freq (u j) x)) (a b : Fin m → ℝ) : + Integrable (fun x => F x*localizedLinearOrbital freq u a x*localizedLinearOrbital freq u b x) := by + have hi (i j : Fin m) : Integrable (fun x => (a i*b j)* + (F x*continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x)) := + (hI i j).const_mul _ + have he (x : Position) : F x*localizedLinearOrbital freq u a x*localizedLinearOrbital freq u b x = + ∑ i, ∑ j, (a i*b j)*(F x*continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x) := by + simp only [localizedLinearOrbital,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + simp_rw [he] + exact integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j _ => hi i j)) + +theorem localizedLinearOrbital_weighted_pairing (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*continuumLocalizedMode freq (u i) x* + continuumLocalizedMode freq (u j) x)) (a b : Fin m → ℝ) : + (∫ x, F x*localizedLinearOrbital freq u a x*localizedLinearOrbital freq u b x) = + ∑ i, ∑ j, (a i*b j)*(∫ x, F x*continuumLocalizedMode freq (u i) x* + continuumLocalizedMode freq (u j) x) := by + have hi (i j : Fin m) : Integrable (fun x => (a i*b j)* + (F x*continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x)) := + (hI i j).const_mul _ + have he (x : Position) : F x*localizedLinearOrbital freq u a x*localizedLinearOrbital freq u b x = + ∑ i, ∑ j, (a i*b j)*(F x*continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x) := by + simp only [localizedLinearOrbital,Finset.mul_sum,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j _ => hi i j))] + apply Finset.sum_congr rfl + intro i _ + rw [integral_finsetSum _ (fun j _ => hi i j)] + simp only [integral_const_mul] + +theorem correctedLocalizedMode_nuclear_error {freq D ε : ℝ} {m : ℕ} + (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*continuumLocalizedMode freq (u i) x* + continuumLocalizedMode freq (u j) x)) + (herror : ∀ i j, |∫ x, F x*continuumLocalizedMode freq (u i) x* + continuumLocalizedMode freq (u j) x| ≤ ε) (i j : Fin m) : + Integrable (fun x => F x*correctedLocalizedMode freq u i x*correctedLocalizedMode freq u j x) ∧ + |∫ x, F x*correctedLocalizedMode freq u i x*correctedLocalizedMode freq u j x| ≤ + 4*(m:ℝ)^2*ε := by + refine ⟨localizedLinearOrbital_weighted_integrable freq u F hI _ _,?_⟩ + rw [correctedLocalizedMode,correctedLocalizedMode,localizedLinearOrbital_weighted_pairing freq u F hI] + have hb (p q : Fin m) : |(correctedLocalizedCoefficients u i p*correctedLocalizedCoefficients u j q)* + (∫ x, F x*continuumLocalizedMode freq (u p) x*continuumLocalizedMode freq (u q) x)| ≤ 4*ε := by + rw [abs_mul,abs_mul] + have hc := mul_le_mul (correctedLocalizedCoefficients_entries u hsep hs i p).2 + (correctedLocalizedCoefficients_entries u hsep hs j q).2 (abs_nonneg _) (by norm_num) + have he := mul_le_mul hc (herror p q) (abs_nonneg _) (by norm_num : (0:ℝ) ≤ 2*2) + simpa only [show (2:ℝ)*2=4 by norm_num] using he + calc + _ ≤ ∑ p : Fin m, ∑ q : Fin m, |(correctedLocalizedCoefficients u i p*correctedLocalizedCoefficients u j q)* + (∫ x, F x*continuumLocalizedMode freq (u p) x*continuumLocalizedMode freq (u q) x)| := by + exact (Finset.abs_sum_le_sum_abs _ _).trans + (Finset.sum_le_sum (fun p _ => Finset.abs_sum_le_sum_abs _ _)) + _ ≤ ∑ _p : Fin m, ∑ _q : Fin m, 4*ε := + Finset.sum_le_sum (fun p _ => Finset.sum_le_sum (fun q _ => hb p q)) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedOneElectronProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedOneElectronProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ce2bb014c3cf548611213f5d746aa49f8a1f3f0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedOneElectronProjection.lean @@ -0,0 +1,258 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 + +namespace OAI + +/-! The corrected orbital span lies in the actual one-electron weak-H1 +domain, with arbitrary complex coefficients in each spin component. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def correctedOneElectronValue (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (c : SpinConfiguration 1 → Fin m → ℂ) (s : SpinConfiguration 1) (x : Configuration 1) : ℂ := + ∑ i, c s i*(correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ) + +private theorem lifted_corrected_mode_C1 (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) : + ContDiff ℝ 1 (fun x : Configuration 1 => + (correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ)) := + Complex.ofRealCLM.contDiff.comp ((correctedLocalizedMode_C1 freq u i).comp + oneElectronCoordinates.contDiff) + +private theorem lifted_corrected_mode_partial (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (x : Configuration 1) (b : Fin 3) : + fderiv ℝ (fun y : Configuration 1 => + (correctedLocalizedMode freq u i (oneElectronCoordinates y) : ℂ)) x + (EuclideanSpace.single (0,b) 1) = + (fderiv ℝ (correctedLocalizedMode freq u i) (oneElectronCoordinates x) + (EuclideanSpace.single b 1) : ℂ) := by + have hr := ((correctedLocalizedMode_C1 freq u i).differentiable (by norm_num) + (oneElectronCoordinates x)).hasFDerivAt.comp x + oneElectronCoordinates.toContinuousLinearEquiv.hasFDerivAt + have h := congrArg (fun L : Configuration 1 →L[ℝ] ℂ => + L (EuclideanSpace.single (0,b) 1)) (Complex.ofRealCLM.hasFDerivAt.comp x hr).fderiv + simpa only [ContinuousLinearMap.comp_apply, Complex.ofRealCLM_apply, + LinearIsometryEquiv.coe_toContinuousLinearEquiv, ContinuousLinearEquiv.coe_coe, + oneElectronCoordinates_single, Function.comp_def] using h + +theorem correctedOneElectronValue_C1 (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (c : SpinConfiguration 1 → Fin m → ℂ) (s : SpinConfiguration 1) : + ContDiff ℝ 1 (correctedOneElectronValue freq u c s) := + ContDiff.sum (fun i _ => contDiff_const.mul (lifted_corrected_mode_C1 freq u i)) + +theorem correctedOneElectronValue_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) : MemLp (correctedOneElectronValue freq u c s) 2 := + memLp_finsetSum Finset.univ (fun i _ => + ((correctedLocalizedMode_memLp hfreq u i).ofReal.comp_measurePreserving + oneElectronCoordinates.measurePreserving).const_mul (c s i)) + +theorem correctedOneElectronValue_partial (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) (x : Configuration 1) (b : Fin 3) : + fderiv ℝ (correctedOneElectronValue freq u c s) x (EuclideanSpace.single (0,b) 1) = + ∑ i, c s i*(fderiv ℝ (correctedLocalizedMode freq u i) (oneElectronCoordinates x) + (EuclideanSpace.single b 1) : ℂ) := by + have hd (i : Fin m) := (lifted_corrected_mode_C1 freq u i).differentiable (by norm_num) x + unfold correctedOneElectronValue + rw [fderiv_fun_sum (fun i _ => (hd i).const_mul (c s i))] + simp only [sum_apply, fderiv_const_mul (hd _), + smul_apply, smul_eq_mul, lifted_corrected_mode_partial] + +theorem correctedOneElectronValue_partial_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) (a : Fin 1 × Fin 3) : + MemLp (fun x => fderiv ℝ (correctedOneElectronValue freq u c s) x + (EuclideanSpace.single a 1)) 2 := by + obtain ⟨a,b⟩ := a + have ha : a = 0 := Subsingleton.elim _ _ + subst a + simp_rw [correctedOneElectronValue_partial] + exact memLp_finsetSum Finset.univ (fun i _ => + ((correctedLocalizedMode_partial_memLp hfreq u i b).ofReal.comp_measurePreserving + oneElectronCoordinates.measurePreserving).const_mul (c s i)) + +def correctedOneElectronState {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) : Coulomb.H1Vector 1 := + classicalH1State (correctedOneElectronValue freq u c) (correctedOneElectronValue_C1 freq u c) + (correctedOneElectronValue_memLp hfreq u c) (correctedOneElectronValue_partial_memLp hfreq u c) + +theorem correctedOneElectronOrbital_orthonormal {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) : + Orthonormal ℂ (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) := by + classical + rw [orthonormal_iff_ite] + intro i j + rw [L2.inner_def] + have hL2 (k : Fin m) : MemLp (fun x : Configuration 1 => + (correctedLocalizedMode freq u k (oneElectronCoordinates x) : ℂ)) 2 := + (correctedLocalizedMode_memLp hfreq u k).ofReal.comp_measurePreserving + oneElectronCoordinates.measurePreserving + have he : (∫ x : Configuration 1, inner ℂ + (oneElectronOrbitalLp (correctedLocalizedMode freq u i) (correctedLocalizedMode_memLp hfreq u i) x) + (oneElectronOrbitalLp (correctedLocalizedMode freq u j) (correctedLocalizedMode_memLp hfreq u j) x)) = + (∫ x : Configuration 1, ((correctedLocalizedMode freq u i (oneElectronCoordinates x)* + correctedLocalizedMode freq u j (oneElectronCoordinates x) : ℝ) : ℂ)) := by + apply integral_congr_ae + filter_upwards [(hL2 i).coeFn_toLp, (hL2 j).coeFn_toLp] with x hi hj + change inner ℂ ((hL2 i).toLp _ x) ((hL2 j).toLp _ x) = _ + rw [hi,hj,RCLike.inner_apply] + simp only [Complex.conj_ofReal, Complex.ofReal_mul] + ring + rw [he, integral_complex_ofReal] + rw [oneElectronCoordinates_integral (fun x => + correctedLocalizedMode freq u i x*correctedLocalizedMode freq u j x), + correctedLocalizedMode_inner hfreq u hsep hs] + split_ifs <;> simp + +theorem correctedOneElectronState_coordinate {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) : + h1Coordinates (correctedOneElectronState hfreq u c) (Sum.inl s) = + ∑ i, c s i • oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i) := by + let w (i : Fin m) := oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i) + have hw (i : Fin m) : (c s i • w i : Lp ℂ 2 (volume : Measure (Configuration 1))) =ᵐ[volume] + fun x => c s i*(correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ) := by + have hmem : MemLp (fun x : Configuration 1 => + (correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ)) 2 := + (correctedLocalizedMode_memLp hfreq u i).ofReal.comp_measurePreserving + oneElectronCoordinates.measurePreserving + have hi := hmem.coeFn_toLp + filter_upwards [Lp.coeFn_smul (c s i) (w i), hi] with x hsm hi + rw [hsm] + change c s i*(w i x) = _ + rw [show w i x = (correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ) from hi] + have hwall := Filter.eventually_all.2 hw + apply Lp.ext + filter_upwards [(h1Coordinate_memLp (correctedOneElectronState hfreq u c) (Sum.inl s)).coeFn_toLp, + Lp.coeFn_fun_finsetSum Finset.univ (fun i => c s i • w i), hwall] with x hx hy hz + change h1Coordinates (correctedOneElectronState hfreq u c) (Sum.inl s) x = _ at hx + rw [hy, hx] + change (∑ i, c s i*(correctedLocalizedMode freq u i (oneElectronCoordinates x) : ℂ)) = _ + apply Finset.sum_congr rfl + intro i _ + exact (hz i).symm + +def correctedOneElectronCoefficients {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) + (s : SpinConfiguration 1) (i : Fin m) : ℂ := + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) + +def correctedOneElectronProjection {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) : Coulomb.H1Vector 1 := + correctedOneElectronState hfreq u (correctedOneElectronCoefficients hfreq u v) + +def correctedOneElectronRemainder {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) : Coulomb.H1Vector 1 := + v.add ((correctedOneElectronProjection hfreq u v).rsmul (-1)) + +theorem correctedOneElectronRemainder_coordinate {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s) = + h1Coordinates v (Sum.inl s)- + ∑ i, correctedOneElectronCoefficients hfreq u v s i • + oneElectronOrbitalLp (correctedLocalizedMode freq u i) (correctedLocalizedMode_memLp hfreq u i) := by + rw [← correctedOneElectronState_coordinate hfreq u (correctedOneElectronCoefficients hfreq u v) s] + apply Lp.ext + filter_upwards [(h1Coordinate_memLp (correctedOneElectronRemainder hfreq u v) (Sum.inl s)).coeFn_toLp, + (h1Coordinate_memLp v (Sum.inl s)).coeFn_toLp, + (h1Coordinate_memLp (correctedOneElectronProjection hfreq u v) (Sum.inl s)).coeFn_toLp, + Lp.coeFn_sub (h1Coordinates v (Sum.inl s)) + (h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s))] with x hr hv hp hs + change h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s) x = + (h1Coordinates v (Sum.inl s)-h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s)) x + rw [hs] + simp only [Pi.sub_apply] + change h1Coordinates v (Sum.inl s) x = v.value s x at hv + change h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s) x = + (correctedOneElectronProjection hfreq u v).value s x at hp + change h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s) x = + (correctedOneElectronRemainder hfreq u v).value s x at hr + rw [hv,hp,hr] + change v.value s x+((-1:ℝ):ℂ)*(correctedOneElectronProjection hfreq u v).value s x = _ + push_cast + ring + +theorem correctedOneElectronRemainder_orthogonal {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (v : Coulomb.H1Vector 1) + (s : SpinConfiguration 1) (i : Fin m) : + inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) + (h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s)) = 0 := by + rw [correctedOneElectronRemainder_coordinate, inner_sub_right] + have ho := correctedOneElectronOrbital_orthonormal hfreq u hsep hs + rw [ho.inner_right_sum (correctedOneElectronCoefficients hfreq u v s) (Finset.mem_univ i)] + exact sub_self _ + +private theorem orthonormal_combination_norm {m : ℕ} + (w : Fin m → Lp ℂ 2 (volume : Measure (Configuration 1))) + (hw : Orthonormal ℂ w) (c : Fin m → ℂ) : + ‖∑ i, c i • w i‖^2 = ∑ i, ‖c i‖^2 := by + have hz (z : ℂ) : (starRingEnd ℂ) z*z = (‖z‖^2 : ℝ) := by + apply Complex.ext + · simp only [Complex.mul_re, Complex.conj_re, Complex.conj_im, Complex.ofReal_re, + Complex.sq_norm, Complex.normSq_apply] + ring + · simp only [Complex.mul_im, Complex.conj_re, Complex.conj_im, Complex.ofReal_im] + ring + have h := congrArg Complex.re (hw.inner_sum c c Finset.univ) + simp only [inner_self_eq_norm_sq_to_K, hz] at h + norm_cast at h + +theorem correctedOneElectronState_mass {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (c : SpinConfiguration 1 → Fin m → ℂ) : + Coulomb.mass (correctedOneElectronState hfreq u c) = ∑ s, ∑ i, ‖c s i‖^2 := by + rw [mass_eq_graphMass] + unfold graphMass + apply Finset.sum_congr rfl + intro s _ + rw [correctedOneElectronState_coordinate] + exact orthonormal_combination_norm _ (correctedOneElectronOrbital_orthonormal hfreq u hsep hs) _ + +theorem correctedOneElectronProjection_mass {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (v : Coulomb.H1Vector 1) : + Coulomb.mass (correctedOneElectronProjection hfreq u v) = + graphOrbitalMass (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v) := + correctedOneElectronState_mass hfreq u hsep hs _ + +theorem correctedOneElectron_mass_decomposition {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (v : Coulomb.H1Vector 1) : + Coulomb.mass v = Coulomb.mass (correctedOneElectronProjection hfreq u v)+ + Coulomb.mass (correctedOneElectronRemainder hfreq u v) := by + simp only [mass_eq_graphMass, graphMass] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro s _ + have hp := correctedOneElectronState_coordinate hfreq u (correctedOneElectronCoefficients hfreq u v) s + change h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s) = _ at hp + have horth : inner ℂ (h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s)) + (h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s)) = 0 := by + rw [hp, sum_inner] + simp only [inner_smul_left, correctedOneElectronRemainder_orthogonal hfreq u hsep hs, + mul_zero, Finset.sum_const_zero] + have he : h1Coordinates v (Sum.inl s) = + h1Coordinates (correctedOneElectronProjection hfreq u v) (Sum.inl s)+ + h1Coordinates (correctedOneElectronRemainder hfreq u v) (Sum.inl s) := by + rw [correctedOneElectronRemainder_coordinate, hp] + abel + rw [he] + simpa only [pow_two] using norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ horth + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedRemainderGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedRemainderGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..5057530ceb265d99ceafeb4962f40431a2b44bdc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedRemainderGap.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedOneElectronProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGrowingGap + +namespace OAI + +/-! The manufactured spectral gap applies to the actual weak-H1 remainder +of the finite corrected-orbital projection, with an exact mass deficit. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufacturedSlab_projected_remainder_gap + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m : ℕ) (D S H scale : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → 0 ≤ scale → ∀ u : Fin m → PlanarPosition, + (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + ∀ v : Coulomb.H1Vector 1, + (-1/2+freq/2+γ/2)*(Coulomb.mass v- + Coulomb.mass (correctedOneElectronProjection (lt_of_lt_of_le zero_lt_one hfreq) u v)) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) + (correctedOneElectronRemainder (lt_of_lt_of_le zero_lt_one hfreq) u v) := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hgap⟩ := + manufacturedSlab_growing_complement_gap hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC, + fun m D S H scale hD hm hS hH hCH hscale u hsep hcoeff v => ?_⟩ + have hs := hover D ((le_max_right _ _).trans hD) m hm + have hmass := correctedOneElectron_mass_decomposition hf u hsep hs v + have h := hgap m D S H scale ((le_max_left _ _).trans hD) hm hS hH hCH hscale + u hsep hcoeff (correctedOneElectronRemainder hf u v) + (correctedOneElectronRemainder_orthogonal hf u hsep hs v) + have he : Coulomb.mass v-Coulomb.mass (correctedOneElectronProjection hf u v) = + Coulomb.mass (correctedOneElectronRemainder hf u v) := by linarith + rw [he] + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedResidualPairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedResidualPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..a022636de8d63c7d0ef25b0d1aa43ea9d70ccf64 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedResidualPairing.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedManufacturedResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteOrbitalLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWeakResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealOrbitalResidual + +namespace OAI + +/-! Actual corrected-orbital mixed forms inherit the manufactured residual +bound on every state in the full one-electron weak-H1 domain. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def oneElectronCorrectedMode (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i : Fin m) (x : Configuration 1) : ℝ := + correctedLocalizedMode freq u i (oneElectronCoordinates x) + +theorem oneElectronCorrectedMode_C2 (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i : Fin m) : ContDiff ℝ 2 (oneElectronCorrectedMode freq u i) := + ((localizedLinearOrbital_C7 freq u (correctedLocalizedCoefficients u i)).of_le (by norm_num)).comp oneElectronCoordinates.contDiff + +theorem oneElectronCorrectedMode_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) : MemLp (oneElectronCorrectedMode freq u i) 2 := + (correctedLocalizedMode_memLp hfreq u i).comp_measurePreserving oneElectronCoordinates.measurePreserving + +theorem oneElectronCorrectedMode_partial_memLp {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) (a : Fin 1 × Fin 3) : + MemLp (configurationRealPartial (oneElectronCorrectedMode freq u i) a) 2 := by + have he : configurationRealPartial (oneElectronCorrectedMode freq u i) a = + (fun x => ∑ j, correctedLocalizedCoefficients u i j* + configurationRealPartial (oneElectronLocalizedMode freq (u j)) a x) := + funext (configurationRealPartial_sum _ _ + (fun j => (oneElectronLocalizedMode_C2 freq (u j)).of_le (by norm_num)) a) + rw [he] + exact memLp_finsetSum Finset.univ (fun j _ => + (oneElectronLocalizedMode_partial_memLp hfreq (u j) a).const_mul _) + +theorem correctedManufacturedResidual_eq {rho freq : ℝ} + (hrelation : freq^2 = 4*Real.pi*rho) (H S scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (x : Configuration 1) : + correctedManufacturedResidual rho H S freq scale u i (oneElectronCoordinates x) = + -(1/2:ℝ)*configurationRealLaplacian (oneElectronCorrectedMode freq u i) x+ + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + oneElectronCorrectedMode freq u i x- + ((-1/2:ℝ)+freq/2)*oneElectronCorrectedMode freq u i x := by + have hlap := configurationRealLaplacian_sum (correctedLocalizedCoefficients u i) + (fun j => oneElectronLocalizedMode freq (u j)) (fun j => oneElectronLocalizedMode_C2 freq (u j)) x + have he (j : Fin m) := manufacturedOrbitalResidual_eq hrelation H S scale u j (oneElectronCoordinates x) + simp_rw [← oneElectronLocalizedMode_laplacian] at he + change (∑ j, correctedLocalizedCoefficients u i j* + manufacturedOrbitalResidual rho H S freq scale u j (oneElectronCoordinates x)) = _ + change configurationRealLaplacian (oneElectronCorrectedMode freq u i) x = _ at hlap + rw [hlap] + change _ = -(1/2:ℝ)*(∑ j, correctedLocalizedCoefficients u i j* + configurationRealLaplacian (oneElectronLocalizedMode freq (u j)) x)+ + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + (∑ j, correctedLocalizedCoefficients u i j*oneElectronLocalizedMode freq (u j) x)- + ((-1/2:ℝ)+freq/2)*(∑ j, correctedLocalizedCoefficients u i j*oneElectronLocalizedMode freq (u j) x) + simp only [Finset.mul_sum,← Finset.sum_add_distrib,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro j _ + rw [he j] + simp only [oneElectronLocalizedMode] + ring + +theorem correctedModePairing_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) (i : Fin m) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + ‖realOrbitalPairing (fun x => manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)) + ((-1/2:ℝ)+freq/2) (oneElectronCorrectedMode freq u i) v s‖^2 ≤ + (4*(m:ℝ)*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j))* + (∫ x, ‖v.value s x‖^2) := by + have hφ := oneElectronCorrectedMode_memLp hfreq u i + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hV : MemLp (fun x : Configuration 1 => + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + oneElectronCorrectedMode freq u i x) 2 := by + apply hφ.of_le_mul (c := B) + ((((manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + oneElectronCoordinates.continuous).mul (oneElectronCorrectedMode_C2 freq u i).continuous).aestronglyMeasurable) + filter_upwards [] with x + change ‖manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + oneElectronCorrectedMode freq u i x‖ ≤ _ + rw [norm_mul,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hB _) (norm_nonneg _) + have hm := (correctedManufacturedResidual_memLp hrho hH.le hS.le hfreq scale u hδ hcoeff i).comp_measurePreserving oneElectronCoordinates.measurePreserving + have hb := realOrbitalPairing_square_bound hdensity _ _ _ _ (oneElectronCorrectedMode_C2 freq u i) + hφ (oneElectronCorrectedMode_partial_memLp hfreq u i) hV hm + (correctedManufacturedResidual_eq hrelation H S scale u i) v s + have hint : (∫ x : Configuration 1, + correctedManufacturedResidual rho H S freq scale u i (oneElectronCoordinates x)^2) = + ∫ x, correctedManufacturedResidual rho H S freq scale u i x^2 := + oneElectronCoordinates_integral (fun x => correctedManufacturedResidual rho H S freq scale u i x^2) + simp only [Function.comp_def] at hb + rw [hint] at hb + exact hb.trans (mul_le_mul_of_nonneg_right + (correctedManufacturedResidual_square_bound hrho hH hS hfreq hR hRH hRS scale u hsep hs hδ hcoeff i) + (integral_nonneg (fun _ => sq_nonneg _))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedStateCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedStateCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..acd19555b5e741a00a59f74a0997fdb805d3997a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CorrectedStateCoordinates.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedOneElectronProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedResidualPairing + +namespace OAI + +/-! Derivative coordinates of an actual corrected-orbital H1 state. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def correctedPartialLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (a : Fin 1 × Fin 3) : + Lp ℂ 2 (volume : Measure (Configuration 1)) := + (oneElectronCorrectedMode_partial_memLp hfreq u i a).ofReal.toLp + (fun x => (configurationRealPartial (oneElectronCorrectedMode freq u i) a x : ℂ)) + +theorem oneElectronCorrectedMode_partial_physical (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (b : Fin 3) (x : Configuration 1) : + configurationRealPartial (oneElectronCorrectedMode freq u i) (0,b) x = + fderiv ℝ (correctedLocalizedMode freq u i) (oneElectronCoordinates x) + (EuclideanSpace.single b 1) := by + change fderiv ℝ (fun y : Configuration 1 => correctedLocalizedMode freq u i (oneElectronCoordinates y)) x + (EuclideanSpace.single (0,b) 1) = _ + have h := ((correctedLocalizedMode_C1 freq u i).differentiable (by norm_num) + (oneElectronCoordinates x)).hasFDerivAt.comp x + oneElectronCoordinates.toContinuousLinearEquiv.hasFDerivAt + simpa only [Function.comp_def, + ContinuousLinearMap.comp_apply,LinearIsometryEquiv.coe_toContinuousLinearEquiv, + ContinuousLinearEquiv.coe_coe,oneElectronCoordinates_single] using + congrArg (fun L : Configuration 1 →L[ℝ] ℝ => L (EuclideanSpace.single (0,b) 1)) h.fderiv + +theorem correctedOneElectronState_gradient {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) (a : Fin 1 × Fin 3) (x : Configuration 1) : + (correctedOneElectronState hfreq u c).gradient s a x = + ∑ i, c s i*(configurationRealPartial (oneElectronCorrectedMode freq u i) a x : ℂ) := by + obtain ⟨a,b⟩ := a + have ha : a = 0 := Subsingleton.elim _ _ + subst a + change fderiv ℝ (correctedOneElectronValue freq u c s) x (EuclideanSpace.single (0,b) 1) = _ + rw [correctedOneElectronValue_partial] + simp only [oneElectronCorrectedMode_partial_physical] + +theorem correctedOneElectronState_gradient_coordinate {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (c : SpinConfiguration 1 → Fin m → ℂ) + (s : SpinConfiguration 1) (a : Fin 1 × Fin 3) : + h1Coordinates (correctedOneElectronState hfreq u c) (Sum.inr (s,a)) = + ∑ i, c s i • correctedPartialLp hfreq u i a := by + have he (i : Fin m) : (c s i • correctedPartialLp hfreq u i a : + Lp ℂ 2 (volume : Measure (Configuration 1))) =ᵐ[volume] + (fun x => c s i*(configurationRealPartial (oneElectronCorrectedMode freq u i) a x : ℂ)) := by + have hm : MemLp (fun x => (configurationRealPartial (oneElectronCorrectedMode freq u i) a x : ℂ)) 2 := + (oneElectronCorrectedMode_partial_memLp hfreq u i a).ofReal + filter_upwards [Lp.coeFn_smul (c s i) (correctedPartialLp hfreq u i a),hm.coeFn_toLp] with x hs hx + rw [hs] + change c s i*(correctedPartialLp hfreq u i a x) = _ + change correctedPartialLp hfreq u i a x = _ at hx + rw [hx] + have hall := Filter.eventually_all.2 he + apply Lp.ext + filter_upwards [(h1Coordinate_memLp (correctedOneElectronState hfreq u c) (Sum.inr (s,a))).coeFn_toLp, + Lp.coeFn_fun_finsetSum Finset.univ (fun i => c s i • correctedPartialLp hfreq u i a),hall] + with x hx hs hh + change h1Coordinates (correctedOneElectronState hfreq u c) (Sum.inr (s,a)) x = _ at hx + rw [hs,hx] + change (correctedOneElectronState hfreq u c).gradient s a x = _ + rw [correctedOneElectronState_gradient] + exact Finset.sum_congr rfl (fun i _ => (hh i).symm) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..30bd0bf76f954814774572b1be9cc45fb461bf4e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCalibration.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarUniformCalibration + +namespace OAI + +/-! Uniform contact calibration for the actual Coulomb profile, with a +single polynomial scale also enforcing the many-site Gram bound. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def coulombHoppingTarget (freq τ K d : ℝ) : ℝ := + τ * Real.sqrt (K * (localizedCoulombProfile freq 0 - localizedCoulombProfile freq d)) + +theorem coulombHoppingTarget_continuous {freq : ℝ} (hfreq : 0 < freq) (τ K : ℝ) : + Continuous (coulombHoppingTarget freq τ K) := + continuous_const.mul ((continuous_const.mul + (continuous_const.sub (localizedCoulombProfile_continuous hfreq))).sqrt) + +theorem localizedCoulombProfile_nonnegative (freq d : ℝ) : 0 ≤ localizedCoulombProfile freq d := by + unfold localizedCoulombProfile + rw [localizedCoulombProfileAt_eq] + exact localizedCoulombCoeff_nonnegative freq _ _ + +theorem coulombHoppingTarget_bounds {freq D τ K d : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + (hleak : 2 * localLeakageBound freq D ≤ localDualMass freq / 2) (hd : D ≤ d) + (hτ : 0 ≤ τ) (hK : 0 ≤ K) : + τ * Real.sqrt (K * localizedGramConstant freq) ≤ coulombHoppingTarget freq τ K d ∧ + coulombHoppingTarget freq τ K d ≤ τ * Real.sqrt (K * localizedCoulombProfile freq 0) := by + constructor + · exact mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt + (mul_le_mul_of_nonneg_left (localizedCoulombProfile_gap hfreq hD hleak hd) hK)) hτ + · exact mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt + (mul_le_mul_of_nonneg_left (sub_le_self _ (localizedCoulombProfile_nonnegative freq d)) hK)) hτ + +theorem exists_uniform_coulomb_calibration {freq ε : ℝ} (hfreq : 0 < freq) + (hε : 0 < ε) (hε₁ : ε < 1) (A S : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ + (∀ d : ℝ, (1 - ε) * ((k : ℝ) * Real.log N) ≤ d → + localizedGramConstant freq ≤ localizedCoulombProfile freq 0 - localizedCoulombProfile freq d) ∧ + (∀ τ K : ℝ, 0 ≤ τ → 0 ≤ K → + (N ^ A)⁻¹ ≤ τ * Real.sqrt (K * localizedGramConstant freq) → + τ * Real.sqrt (K * localizedCoulombProfile freq 0) ≤ N ^ A → + ∃ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), N ^ k * planarHopping d = coulombHoppingTarget freq τ K d) ∧ + (∀ (m : ℕ), (m : ℝ) ≤ N ^ S → ∀ (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → (1 - ε) * ((k : ℝ) * Real.log N) ≤ ‖u i - u j‖) → + ∀ d : Fin m → ℝ, localizedGramConstant freq * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j) := by + obtain ⟨k₀, _, hspacing⟩ := exists_localizedGram_spacing hfreq (S + 1) + obtain ⟨k, hk, hlarge, hcal⟩ := + exists_uniform_planar_calibration_above ((k₀ : ℝ) / (1 - ε)) A hε hε₁ + refine ⟨k, hk, fun N hN => ?_⟩ + have hNp : 0 < N := by linarith + have hN₁ : 1 ≤ N := by linarith + have hlog : 0 ≤ Real.log N := Real.log_nonneg hN₁ + have hlength : (k₀ : ℝ) * Real.log N ≤ (1 - ε) * ((k : ℝ) * Real.log N) := by + have h := mul_le_mul_of_nonneg_right ((div_le_iff₀ (sub_pos.mpr hε₁)).mp hlarge) hlog + nlinarith only [h] + obtain ⟨hD, hleak⟩ := hspacing N hN + have hpow : N ^ S ≤ N ^ (S + 1) := pow_le_pow_right₀ hN₁ (Nat.le_succ S) + have htwo : (2 : ℝ) ≤ N ^ (S + 1) := by + exact hN.trans (by simpa only [pow_one] using pow_le_pow_right₀ hN₁ (show 1 ≤ S + 1 by omega)) + have hleak₂ : 2 * localLeakageBound freq ((k₀ : ℝ) * Real.log N) ≤ localDualMass freq / 2 := + (mul_le_mul_of_nonneg_right htwo (localLeakageBound_nonnegative _ _)).trans hleak + refine ⟨hD.trans hlength, ?_, ?_, ?_⟩ + · intro d hd + exact localizedCoulombProfile_gap hfreq hD hleak₂ (hlength.trans hd) + · intro τ K hτ hK hlo hhi + apply (hcal N hN).2 (coulombHoppingTarget freq τ K) + (coulombHoppingTarget_continuous hfreq τ K).continuousOn + intro d hd + have hb := coulombHoppingTarget_bounds hfreq hD hleak₂ (hlength.trans hd.1) hτ hK + exact ⟨hlo.trans hb.1, hb.2.trans hhi⟩ + · intro m hm u hsep d + apply localizedGram_uniform_coercive hfreq hD u + (fun i j hij => hlength.trans (hsep i j hij)) ?_ d + exact (mul_le_mul_of_nonneg_right (hm.trans hpow) (localLeakageBound_nonnegative _ _)).trans hleak + +theorem calibrated_superexchange {freq scale τ K d : ℝ} (hgap : 0 < + localizedCoulombProfile freq 0 - localizedCoulombProfile freq d) (hK : 0 ≤ K) + (hcal : scale * planarHopping d = coulombHoppingTarget freq τ K d) : + (scale * planarHopping d) ^ 2 / + (localizedCoulombProfile freq 0 - localizedCoulombProfile freq d) = τ ^ 2 * K := by + rw [hcal, coulombHoppingTarget, mul_pow, Real.sq_sqrt (mul_nonneg hK hgap.le)] + field_simp [hgap.ne'] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f2cdd0434d73e8b34cd447a48f0c2d8ca302c2d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeCoordinates.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeMeasure +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedRawDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabSections + +namespace OAI + +/-! Exact Lebesgue coordinates for the two-particle finite Coulomb box. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb +open UniformQuadrature + +def twoParticleCoordinates : (Fin 6 → ℝ) ≃ᵐ Position × Position := + (MeasurableEquiv.piCongrLeft (fun _ : Fin 3 ⊕ Fin 3 => ℝ) + (finSumFinEquiv (m := 3) (n := 3)).symm).trans + ((MeasurableEquiv.sumPiEquivProdPi (fun _ : Fin 3 ⊕ Fin 3 => ℝ)).trans + ((MeasurableEquiv.toLp 2 (Fin 3 → ℝ)).prodCongr + (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)))) + +theorem twoParticleCoordinates_fst (v : Fin 6 → ℝ) (i : Fin 3) : + (twoParticleCoordinates v).1 i = v (i.castAdd 3) := by + fin_cases i <;> rfl + +theorem twoParticleCoordinates_snd (v : Fin 6 → ℝ) (i : Fin 3) : + (twoParticleCoordinates v).2 i = v (i.natAdd 3) := by + fin_cases i <;> rfl + +theorem slabDomain_cube (L : ℝ) : slabDomain L L = coulombNumericalBox L := by + ext x + simp only [slabDomain, coulombNumericalBox, Set.mem_ofPred_eq, Set.mem_iInter] + constructor + · rintro ⟨h0, h1, h2⟩ i + fin_cases i <;> assumption + · intro h + exact ⟨h 0, h 1, h 2⟩ + +theorem twoParticleCoordinates_measurePreserving (L : ℝ) : + MeasurePreserving twoParticleCoordinates (cubeMeasure (-L) L 6) + (volume.restrict (coulombNumericalBox L ×ˢ coulombNumericalBox L)) := by + let μ : Measure ℝ := volume.restrict (Set.Icc (-L) L) + have hindex := measurePreserving_piCongrLeft (fun _ : Fin 3 ⊕ Fin 3 => μ) + (finSumFinEquiv (m := 3) (n := 3)).symm + have hsplit := measurePreserving_sumPiEquivProdPi (fun _ : Fin 3 ⊕ Fin 3 => μ) + have hcube : cubeMeasure (-L) L 3 = slabProductMeasure L L := by + unfold cubeMeasure slabProductMeasure slabAxisMeasure + congr 1 + funext i + simp only [slabSide, ite_self] + have hslot : MeasurePreserving (MeasurableEquiv.toLp 2 (Fin 3 → ℝ)) + (cubeMeasure (-L) L 3) (volume.restrict (coulombNumericalBox L)) := by + rw [hcube, ← slabDomain_cube] + exact slabProduct_measurePreserving L L + have h := (hslot.prod hslot).comp (hsplit.comp hindex) + rw [Measure.prod_restrict, ← Measure.volume_eq_prod] at h + exact h + +theorem localizedRawCoulombBox_cube {freq ε L : ℝ} + (hf : 0 < freq) (hε : 0 < ε) (hL : 0 ≤ L) (u : PlanarPosition) : + localizedRawCoulombBox freq ε L u = cubeIntegral (-L) L 6 + (fun v => cappedPairIntegrand ε (planarCenter u) + (localizedRawDensity freq) (localizedRawDensity freq) (twoParticleCoordinates v)) := by + let f := cappedPairIntegrand ε (planarCenter u) + (localizedRawDensity freq) (localizedRawDensity freq) + have hfi : Integrable f := cappedPairIntegrand_integrable hε (planarCenter u) + (localizedRawDensity_integrable hf) (localizedRawDensity_integrable hf) + have hp := twoParticleCoordinates_measurePreserving L + have hcomp : Integrable (fun v => f (twoParticleCoordinates v)) (cubeMeasure (-L) L 6) := + (hp.integrable_comp_emb twoParticleCoordinates.measurableEmbedding).mpr hfi.restrict + rw [cubeIntegral_eq_integral 6 (by linarith) hcomp] + exact (hp.integral_comp' f).symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..071035f120499f3c2e06881232755ab981158edc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombCubeModulus.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCubeCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedRawModulus + +namespace OAI + +/-! Coordinatewise Lipschitz control of the actual Coulomb box integrand. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb +open UniformQuadrature + +theorem position_norm_le_sum_abs (x : Position) : ‖x‖ ≤ ∑ i, |x i| := by + apply (sq_le_sq₀ (norm_nonneg x) (Finset.sum_nonneg (fun i _ => abs_nonneg (x i)))).mp + rw [EuclideanSpace.real_norm_sq_eq] + simpa only [sq_abs] using + (Finset.sum_sq_le_sq_sum_of_nonneg (s := Finset.univ) (f := fun i : Fin 3 => |x i|) + (fun i _ => abs_nonneg (x i))) + +theorem twoParticleCoordinates_sum_abs (v w : Fin 6 → ℝ) : + (∑ i : Fin 3, |(twoParticleCoordinates v).1 i - (twoParticleCoordinates w).1 i|) + + (∑ i : Fin 3, |(twoParticleCoordinates v).2 i - (twoParticleCoordinates w).2 i|) = + ∑ i : Fin 6, |v i - w i| := by + simp only [twoParticleCoordinates_fst, twoParticleCoordinates_snd] + exact (Fin.sum_univ_add (a := 3) (b := 3) (fun i : Fin 6 => |v i - w i|)).symm + +def rawCoulombSix (freq ε : ℝ) (shift : Position) (v : Fin 6 → ℝ) : ℝ := + cappedPairIntegrand ε shift (localizedRawDensity freq) (localizedRawDensity freq) + (twoParticleCoordinates v) + +theorem rawCoulombSix_modulus {freq ε L : ℝ} (hf : 0 ≤ freq) (hε : 0 < ε) + (hL : 0 ≤ L) (shift : Position) : + cubeModulus (-L) L ((64 + 2 * freq * L) * ε⁻¹ + ε⁻¹ ^ 2) + (rawCoulombSix freq ε shift) := by + intro v hv w hw + have hv0 : |(positionSplitCoordinates (twoParticleCoordinates v).1).2| ≤ L := by + change |(twoParticleCoordinates v).1 2| ≤ L + rw [twoParticleCoordinates_fst] + exact abs_le.mpr (hv _) + have hv1 : |(positionSplitCoordinates (twoParticleCoordinates v).2).2| ≤ L := by + change |(twoParticleCoordinates v).2 2| ≤ L + rw [twoParticleCoordinates_snd] + exact abs_le.mpr (hv _) + have hw0 : |(positionSplitCoordinates (twoParticleCoordinates w).1).2| ≤ L := by + change |(twoParticleCoordinates w).1 2| ≤ L + rw [twoParticleCoordinates_fst] + exact abs_le.mpr (hw _) + have hw1 : |(positionSplitCoordinates (twoParticleCoordinates w).2).2| ≤ L := by + change |(twoParticleCoordinates w).2 2| ≤ L + rw [twoParticleCoordinates_snd] + exact abs_le.mpr (hw _) + have ht := cappedRawPair_modulus hf hε shift + (twoParticleCoordinates v).1 (twoParticleCoordinates v).2 + (twoParticleCoordinates w).1 (twoParticleCoordinates w).2 hv0 hv1 hw0 hw1 + apply ht.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + have hx := position_norm_le_sum_abs ((twoParticleCoordinates v).1 - (twoParticleCoordinates w).1) + have hy := position_norm_le_sum_abs ((twoParticleCoordinates v).2 - (twoParticleCoordinates w).2) + simpa only [PiLp.sub_apply, twoParticleCoordinates_sum_abs] using add_le_add hx hy + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationError.lean new file mode 100644 index 0000000000000000000000000000000000000000..6869677a6ec4b3a082195c19cd3752d41dc5b8ef --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationError.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombRawEvaluation + +namespace OAI + +/-! End-to-end error accounting for the actual Coulomb coefficient. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombEvaluation + +theorem truncation_error (rho P : ℕ) (hrho : 0 < rho) (d : ℚ) : + |localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ) - + localizedCoulombBoxIntegral (GaussianFrequency.frequency rho) + (1 / (denominator rho P : ℚ) : ℝ) (radius rho P : ℝ) ((d : ℝ) • planarAxis 0)| ≤ + (4 * ((P : ℝ) + 1))⁻¹ := by + have hf : 0 < GaussianFrequency.frequency rho := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have ht := CoulombTruncationSchedule.error hf (truncationPrecision P) ((d : ℝ) • planarAxis 0) + rw [← epsilon_eq] at ht + apply ht.trans + apply inv_anti₀ (by positivity) + have h : P ≤ truncationPrecision P := by unfold truncationPrecision; omega + exact mul_le_mul_of_nonneg_left (by exact_mod_cast Nat.add_le_add_right h 1) (by norm_num) + +theorem rawPrecision_one_le (rho P : ℕ) : 1 ≤ (rawPrecision rho P : ℝ) := by + have hc := (normalizationBound_bounds rho).1 + have hp : 1 ≤ (P : ℝ) + 1 := by linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _] + have hprod : 1 ≤ (normalizationBound rho : ℝ) * ((P : ℝ) + 1) := + one_le_mul_of_one_le_of_one_le hc hp + simp only [rawPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + nlinarith + +theorem rawApproximate_bound (rho P : ℕ) (hrho : 0 < rho) (d : ℚ) : + |(rawApproximate rho P d : ℝ)| ≤ (rawMassBound rho : ℝ) * denominator rho P := by + let I := localizedRawCoulombBox (GaussianFrequency.frequency rho) + (1 / (denominator rho P : ℚ) : ℝ) (radius rho P : ℝ) ((d : ℝ) • planarAxis 0) + have hf : 0 < GaussianFrequency.frequency rho := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have hD : (1 : ℝ) ≤ denominator rho P := by exact_mod_cast denominator_positive rho P + have hε : (0 : ℝ) < (1 / (denominator rho P : ℚ) : ℝ) := by + simp only [Rat.cast_natCast] + positivity + have hI := localizedRawCoulombBox_bound hf hε (radius rho P : ℝ) ((d : ℝ) • planarAxis 0) + rw [denominator_inverse] at hI + have he := raw_approximation_error rho P hrho d + have hS := rawPrecision_one_le rho P + have he1 : |(rawApproximate rho P d : ℝ) - I| ≤ 1 := by + apply he.trans + rw [← div_eq_mul_inv] + exact (div_le_one (by positivity : 0 < 4 * (rawPrecision rho P : ℝ))).mpr (by linarith) + have htriangle : |(rawApproximate rho P d : ℝ)| ≤ |(rawApproximate rho P d : ℝ) - I| + |I| := by + calc + _ = |((rawApproximate rho P d : ℝ) - I) + I| := by congr 1; ring + _ ≤ _ := abs_add_le _ _ + have hM := rawMassBound_le rho + have hMD := mul_le_mul_of_nonneg_right hM (show (0 : ℝ) ≤ denominator rho P by linarith) + nlinarith + +theorem raw_normalization_budget (rho P : ℕ) : + CoulombNormalization.coefficient (GaussianFrequency.frequency rho) * + (3 * (4 * (rawPrecision rho P : ℝ))⁻¹) ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + have hC := (normalizationBound_bounds rho).1 + have hα := (normalizationBound_bounds rho).2 + have hp : (0 : ℝ) < P + 1 := by positivity + calc + _ ≤ (normalizationBound rho : ℝ) * (3 * (4 * (rawPrecision rho P : ℝ))⁻¹) := + mul_le_mul_of_nonneg_right hα (by positivity) + _ = (3 / 16 : ℝ) * ((P : ℝ) + 1)⁻¹ := by + simp only [rawPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + have hc0 : (normalizationBound rho : ℝ) ≠ 0 := ne_of_gt (by linarith) + field_simp [hc0, hp.ne'] + ring + _ ≤ _ := by rw [mul_inv]; norm_num; nlinarith [inv_pos.mpr hp] + +theorem normalization_rounding_budget (rho P : ℕ) : + (rawMassBound rho : ℝ) * denominator rho P * + ((normalizationPrecision rho P : ℝ) + 1)⁻¹ ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + have hM : (0 : ℝ) < rawMassBound rho := by + have h := rawMassBound_le rho + nlinarith [sq_nonneg (localizedRawMass (GaussianFrequency.frequency rho))] + have hD : (0 : ℝ) < denominator rho P := by exact_mod_cast denominator_positive rho P + have hp : (0 : ℝ) < P + 1 := by positivity + have hn : (0 : ℝ) < normalizationPrecision rho P := by + simp only [normalizationPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + positivity + calc + _ ≤ (rawMassBound rho : ℝ) * denominator rho P * (normalizationPrecision rho P : ℝ)⁻¹ := + mul_le_mul_of_nonneg_left (inv_anti₀ hn (by linarith)) (by positivity) + _ = (8 * ((P : ℝ) + 1))⁻¹ := by + simp only [normalizationPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + field_simp [hM.ne', hD.ne', hp.ne'] + _ ≤ _ := inv_anti₀ (by positivity) (by linarith) + +theorem approximation_error (rho P : ℕ) (hrho : 0 < rho) (d : ℚ) : + |(approximate rho P d : ℝ) - localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ)| ≤ + ((P : ℝ) + 1)⁻¹ := by + let α := CoulombNormalization.coefficient (GaussianFrequency.frequency rho) + let α' : ℝ := CoulombNormalization.approximate rho (normalizationPrecision rho P) + let q : ℝ := rawApproximate rho P d + let I := localizedRawCoulombBox (GaussianFrequency.frequency rho) + (1 / (denominator rho P : ℚ) : ℝ) (radius rho P : ℝ) ((d : ℝ) • planarAxis 0) + have hf : 0 < GaussianFrequency.frequency rho := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have hα0 : 0 ≤ α := by unfold α CoulombNormalization.coefficient; positivity + have heq : α' * q - α * I = (α' - α) * q + α * (q - I) := by ring + have hfirst : |(α' - α) * q| ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + rw [abs_mul] + have h := mul_le_mul (CoulombNormalization.approximation_error rho (normalizationPrecision rho P)) + (rawApproximate_bound rho P hrho d) (abs_nonneg q) (by positivity) + apply h.trans + simpa only [mul_comm] using normalization_rounding_budget rho P + have hsecond : |α * (q - I)| ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + rw [abs_mul, abs_of_nonneg hα0] + exact (mul_le_mul_of_nonneg_left (raw_approximation_error rho P hrho d) hα0).trans + (raw_normalization_budget rho P) + have hbox := localizedCoulombBox_eq_normalizedRaw hf (1 / (denominator rho P : ℚ) : ℝ) + (radius rho P : ℝ) ((d : ℝ) • planarAxis 0) + have ht := truncation_error rho P hrho d + rw [hbox, abs_sub_comm] at ht + have hinner := (abs_add_le ((α' - α) * q) (α * (q - I))).trans (add_le_add hfirst hsecond) + rw [← heq] at hinner + have hsum := (abs_sub_le (α' * q) (α * I) + (localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ))).trans + (add_le_add hinner ht) + have hfinal : |α' * q - localizedCoulombProfile (GaussianFrequency.frequency rho) (d : ℝ)| ≤ + ((P : ℝ) + 1)⁻¹ := by + apply hsum.trans + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr (show (0 : ℝ) < P + 1 by positivity)] + simpa only [approximate, Rat.cast_mul, α', q] using hfinal + +end ContinuumCoulomb.CoulombEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationParameters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..b25a7927a2f9d9b292621e2ac0ca3b47a9e6c68f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombEvaluationParameters.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombQuadratureBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTruncationSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombMassBound + +namespace OAI + +/-! One fixed set of polynomial precision parameters for the actual +localized Coulomb coefficient. Only the requested accuracy varies. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombEvaluation + +def frequencyBound (rho : ℕ) : ℕ := ⌈GaussianFrequency.frequency rho⌉₊ + 1 +def normalizationBound (rho : ℕ) : ℕ := + ⌈max 1 (CoulombNormalization.coefficient (GaussianFrequency.frequency rho))⌉₊ + 1 +def rawMassBound (rho : ℕ) : ℕ := + ⌈localizedRawMass (GaussianFrequency.frequency rho) ^ 2 + 1⌉₊ + 1 + +def truncationPrecision (P : ℕ) : ℕ := 4 * (P + 1) +def denominator (rho P : ℕ) : ℕ := + CoulombTruncationSchedule.guard (GaussianFrequency.frequency rho) * + CoulombTruncationSchedule.scale (truncationPrecision P) +def radius (rho P : ℕ) : ℕ := + CoulombTruncationSchedule.radius (GaussianFrequency.frequency rho) (truncationPrecision P) +def rawPrecision (rho P : ℕ) : ℕ := 4 * normalizationBound rho * (P + 1) +def mesh (rho P : ℕ) : ℕ := CoulombQuadratureSchedule.mesh + (frequencyBound rho) (radius rho P) (denominator rho P) (rawPrecision rho P) +def samplePrecision (rho P : ℕ) : ℕ := CoulombQuadratureSchedule.accuracy + (radius rho P) (denominator rho P) (rawPrecision rho P) +def kernelPrecision (rho P : ℕ) : ℕ := CoulombQuadratureSchedule.kernelPrecision + (radius rho P) (denominator rho P) (rawPrecision rho P) +def normalizationPrecision (rho P : ℕ) : ℕ := 8 * rawMassBound rho * denominator rho P * (P + 1) + +def input (rho P : ℕ) (d : ℚ) : RationalSixQuadrature.Input RawCoulombSample.Settings := + RawCoulombSample.quadratureInput (radius rho P) (samplePrecision rho P) (kernelPrecision rho P) + (1 / (denominator rho P : ℚ)) (d, 0, 0) (mesh rho P) + +def rawApproximate (rho P : ℕ) (d : ℚ) : ℚ := + RationalSixQuadrature.value (RawCoulombSample.sixEvaluator rho) (input rho P d) + +def approximate (rho P : ℕ) (d : ℚ) : ℚ := + CoulombNormalization.approximate rho (normalizationPrecision rho P) * rawApproximate rho P d + +theorem frequencyBound_le (rho : ℕ) : GaussianFrequency.frequency rho ≤ (frequencyBound rho : ℝ) := by + have h := Nat.le_ceil (GaussianFrequency.frequency rho) + simp only [frequencyBound, Nat.cast_add, Nat.cast_one] + linarith + +theorem normalizationBound_bounds (rho : ℕ) : + 1 ≤ (normalizationBound rho : ℝ) ∧ + CoulombNormalization.coefficient (GaussianFrequency.frequency rho) ≤ normalizationBound rho := by + have h := Nat.le_ceil (max 1 (CoulombNormalization.coefficient (GaussianFrequency.frequency rho))) + have h1 := (le_max_left (1 : ℝ) _).trans h + have h2 := (le_max_right (1 : ℝ) _).trans h + simp only [normalizationBound, Nat.cast_add, Nat.cast_one] + constructor <;> linarith + +theorem rawMassBound_le (rho : ℕ) : + localizedRawMass (GaussianFrequency.frequency rho) ^ 2 + 1 ≤ (rawMassBound rho : ℝ) := by + have h := Nat.le_ceil (localizedRawMass (GaussianFrequency.frequency rho) ^ 2 + 1) + simp only [rawMassBound, Nat.cast_add, Nat.cast_one] + linarith + +theorem denominator_positive (rho P : ℕ) : 0 < denominator rho P := by + have hg := CoulombTruncationSchedule.guard_one_le (GaussianFrequency.frequency rho) + have hs := CoulombTruncationSchedule.scale_eight_le (truncationPrecision P) + have h : (0 : ℝ) < denominator rho P := by + simp only [denominator, Nat.cast_mul] + positivity + exact_mod_cast h + +theorem radius_positive (rho P : ℕ) : 0 < radius rho P := by + exact_mod_cast CoulombTruncationSchedule.radius_positive + (GaussianFrequency.frequency rho) (truncationPrecision P) + +theorem rawPrecision_positive (rho P : ℕ) : 0 < rawPrecision rho P := by + have hc : 0 < normalizationBound rho := by + have h := (normalizationBound_bounds rho).1 + exact_mod_cast (show (0 : ℝ) < normalizationBound rho by linarith) + unfold rawPrecision + positivity + +theorem mesh_positive (rho P : ℕ) : 0 < mesh rho P := by + have hR := radius_positive rho P + have hD := denominator_positive rho P + have hS := rawPrecision_positive rho P + have hA : 0 < 64 + 2 * frequencyBound rho * radius rho P := by omega + have hL : 0 < CoulombQuadratureSchedule.lipschitz (frequencyBound rho) + (radius rho P) (denominator rho P) := by + unfold CoulombQuadratureSchedule.lipschitz + exact lt_of_lt_of_le (Nat.mul_pos hA hD) (Nat.le_add_right _ _) + have hV : 0 < CoulombQuadratureSchedule.volume (radius rho P) := by + change 0 < (2 * radius rho P) ^ 6 + exact pow_pos (Nat.mul_pos (by decide) hR) _ + change 0 < 48 * radius rho P * + CoulombQuadratureSchedule.lipschitz (frequencyBound rho) (radius rho P) (denominator rho P) * + CoulombQuadratureSchedule.volume (radius rho P) * rawPrecision rho P + exact Nat.mul_pos (Nat.mul_pos (Nat.mul_pos (Nat.mul_pos (by decide) hR) hL) hV) hS + +theorem epsilon_eq (rho P : ℕ) : + (1 / (denominator rho P : ℚ) : ℝ) = + (CoulombTruncationSchedule.epsilon (GaussianFrequency.frequency rho) (truncationPrecision P) : ℝ) := by + simp only [denominator, CoulombTruncationSchedule.epsilon, Rat.cast_div, Rat.cast_one, + Rat.cast_natCast, Rat.cast_mul, Nat.cast_mul] + +end ContinuumCoulomb.CoulombEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombFarCell.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombFarCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..e044eead10757d7a34991493d7d1143faa69475d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombFarCell.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussLocalPositionCell + +namespace OAI + +/-! Fourth-order quadrature on a cube separated from an actual Coulomb pole. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem translatedCoulomb_derivative_norm (k : ℕ) (y z : Position) : + ‖iteratedFDeriv ℝ k (fun w => Coulomb.coulombKernel (y-w)) z‖ = + ‖iteratedFDeriv ℝ k Coulomb.coulombKernel (y-z)‖ := by + let e : Position ≃ₗᵢ[ℝ] Position := LinearIsometryEquiv.neg ℝ + have he := e.norm_iteratedFDeriv_comp_right (fun w => Coulomb.coulombKernel (y+w)) z k + change ‖iteratedFDeriv ℝ k (fun w => Coulomb.coulombKernel (y + -w)) z‖ = + ‖iteratedFDeriv ℝ k (fun w => Coulomb.coulombKernel (y+w)) (-z)‖ at he + rw [iteratedFDeriv_comp_add_left] at he + simpa only [sub_eq_add_neg] using he + +theorem coulomb_far_cell_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (y b : Position) (h r : ℝ), 0 ≤ h → 0 < r → + (∀ x ∈ Set.Icc (-1:ℝ) 1, ∀ v ∈ Set.Icc (-1:ℝ) 1, + ∀ z ∈ Set.Icc (-1:ℝ) 1, r ≤ ‖y-cubePoint b (h/2) x v z‖) → + |positionCellGauss b h (fun w => Coulomb.coulombKernel (y-w))- + positionCellIntegral b h (fun w => Coulomb.coulombKernel (y-w))| ≤ + C*h^7/r^5 := by + obtain ⟨C,hC,hbound⟩ := coulombKernel_derivative_decay + refine ⟨C,hC,fun y b h r hh hr hdist => ?_⟩ + have hne (x : ℝ) (hx : x ∈ Set.Icc (-1:ℝ) 1) (v : ℝ) (hv : v ∈ Set.Icc (-1:ℝ) 1) + (z : ℝ) (hz : z ∈ Set.Icc (-1:ℝ) 1) : y-cubePoint b (h/2) x v z ≠ 0 := + norm_pos_iff.mp (hr.trans_le (hdist x hx v hv z hz)) + have hD (x : ℝ) (hx : x ∈ Set.Icc (-1:ℝ) 1) (v : ℝ) (hv : v ∈ Set.Icc (-1:ℝ) 1) + (z : ℝ) (hz : z ∈ Set.Icc (-1:ℝ) 1) : + ‖iteratedFDeriv ℝ 4 (fun w => Coulomb.coulombKernel (y-w)) + (cubePoint b (h/2) x v z)‖ ≤ C/r^5 := by + rw [translatedCoulomb_derivative_norm] + apply (le_div_iff₀ (pow_pos hr 5)).mpr + have hp := hbound (4:Fin 5) _ (hne x hx v hv z hz) + exact (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hr.le (hdist x hx v hv z hz) 5) + (norm_nonneg _)).trans hp + have he := positionCellGauss_error_local (fun w => Coulomb.coulombKernel (y-w)) b hh + (div_nonneg (by linarith) (pow_nonneg hr.le 5)) + (fun x hx v hv z hz => (coulombKernel_contDiffAt (hne x hx v hv z hz)).of_le + (ENat.natCast_le_of_coe_top_le_withTop le_rfl 4) |>.comp _ + (contDiffAt_const.sub contDiffAt_id)) hD + apply he.trans_eq + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e760298eac1f8080432307118a2caf681f1eebf0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGram.lean @@ -0,0 +1,244 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import OAI.Analysis.CoulombRadii.FieldAnalysis.CoulombTest + +namespace OAI + +/-! +# Coercivity of the actual Coulomb Gram matrix from local dual tests + +The unit-charge paper retains all long-range direct interactions. Absolute +row dominance need not hold. Smooth disjoint local tests instead give a +uniform lower bound for the full Gram form. The hypotheses below concern +normalization/localization of the actual densities and the tests; no charge +gap or target spectral comparison is assumed. +-/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +variable {Ω : Set Position} + +def coulombGram {m : ℕ} (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (i j : Fin m) : ℝ := Coulomb.tfCoulomb Ω (density i) (density j) + +def offDiagonalCoulombGram {m : ℕ} (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (i j : Fin m) : ℝ := if i = j then 0 else coulombGram density i j + +theorem offDiagonalCoulombGram_symmetric {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) (i j : Fin m) : + offDiagonalCoulombGram density i j = offDiagonalCoulombGram density j i := by + classical + simp only [offDiagonalCoulombGram, coulombGram, eq_comm] + rw [Coulomb.tfCoulomb_symm] + +theorem offDiagonalCoulombGram_diag {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) (i : Fin m) : + offDiagonalCoulombGram density i i = 0 := by + simp [offDiagonalCoulombGram] + +theorem coulombGram_diagonal_split {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) (d : Fin m → ℝ) : + (∑ i, ∑ j, coulombGram density i j * d i * d j) = + (∑ i, coulombGram density i i * d i ^ 2) + + ∑ i, ∑ j, offDiagonalCoulombGram density i j * d i * d j := by + classical + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + calc + _ = ∑ j, ((if i = j then coulombGram density i i * d i ^ 2 else 0) + + offDiagonalCoulombGram density i j * d i * d j) := by + apply Finset.sum_congr rfl + intro j _ + by_cases hij : i = j + · subst j + simp only [ite_true, offDiagonalCoulombGram_diag, zero_mul, add_zero, pow_two] + ring + · simp only [ite_eq_right hij, offDiagonalCoulombGram, zero_add] + _ = _ := by simp only [Finset.sum_add_distrib, Finset.sum_ite_eq, Finset.mem_univ, + ite_true] + +variable [IsFiniteMeasure (volume.restrict Ω)] + +def smoothTestPacket (χ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) + (hc : HasCompactSupport χ) : Coulomb.TFLp (volume.restrict Ω) := + (((Coulomb.testCharge_continuous hχ).memLp_of_hasCompactSupport + (Coulomb.testCharge_compact hc)).restrict (s := Ω)).toLp (Coulomb.testCharge χ) + +theorem smoothTestPacket_pair (hΩ : MeasurableSet Ω) + (χ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hc : HasCompactSupport χ) + (hs : tsupport χ ⊆ Ω) (density : Coulomb.TFLp (volume.restrict Ω)) : + Coulomb.tfCoulomb Ω density (smoothTestPacket χ hχ hc) = + ∫ x, Coulomb.tfExtend Ω density x * χ x := + Coulomb.tfCoulomb_testCharge hΩ hχ hc hs density + +theorem smoothTestPacket_pair_test (hΩ : MeasurableSet Ω) + (χ ψ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hψ : ContDiff ℝ ∞ ψ) + (hcχ : HasCompactSupport χ) (hcψ : HasCompactSupport ψ) + (hsχ : tsupport χ ⊆ Ω) (hsψ : tsupport ψ ⊆ Ω) : + Coulomb.tfCoulomb Ω (smoothTestPacket χ hχ hcχ) (smoothTestPacket ψ hψ hcψ) = + ∫ x, Coulomb.testCharge χ x * ψ x := by + rw [smoothTestPacket_pair hΩ ψ hψ hcψ hsψ] + have he := Coulomb.tfExtend_toLp hΩ + (((Coulomb.testCharge_continuous hχ).memLp_of_hasCompactSupport + (Coulomb.testCharge_compact hcχ)).restrict (s := Ω)) + (fun x hx => Coulomb.testCharge_zero (fun h => hx (hsχ h))) + exact integral_congr_ae (he.mono (fun x hx => congrArg (· * ψ x) hx)) + +theorem smoothTestPacket_orthogonal (hΩ : MeasurableSet Ω) + (χ ψ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hψ : ContDiff ℝ ∞ ψ) + (hcχ : HasCompactSupport χ) (hcψ : HasCompactSupport ψ) + (hsχ : tsupport χ ⊆ Ω) (hsψ : tsupport ψ ⊆ Ω) + (hdisjoint : Disjoint (tsupport χ) (tsupport ψ)) : + Coulomb.tfCoulomb Ω (smoothTestPacket χ hχ hcχ) (smoothTestPacket ψ hψ hcψ) = 0 := by + rw [smoothTestPacket_pair_test hΩ χ ψ hχ hψ hcχ hcψ hsχ hsψ] + have hz (x : Position) : Coulomb.testCharge χ x * ψ x = 0 := by + by_cases hx : x ∈ tsupport χ + · have hy : x ∉ tsupport ψ := fun hy => Set.disjoint_left.mp hdisjoint hx hy + rw [image_eq_zero_of_notMem_tsupport hy, mul_zero] + · rw [Coulomb.testCharge_zero hx, zero_mul] + simp_rw [hz, integral_zero] + +theorem coulombGram_sum (hΩ : MeasurableSet Ω) {m : ℕ} + (density test : Fin m → Coulomb.TFLp (volume.restrict Ω)) (d e : Fin m → ℝ) : + Coulomb.tfCoulomb Ω (∑ i, d i • density i) (∑ j, e j • test j) = + ∑ i, ∑ j, d i * e j * Coulomb.tfCoulomb Ω (density i) (test j) := by + let B := Coulomb.tfCoulombContinuous hΩ + change B (∑ i, d i • density i) (∑ j, e j • test j) = _ + simp only [map_sum, map_smul, sum_apply, smul_apply, smul_eq_mul] + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + change e j * (d i * Coulomb.tfCoulomb Ω (density i) (test j)) = _ + ring + +omit [IsFiniteMeasure (volume.restrict Ω)] in +/-- A cutoff equal to one on its own packet and disjoint from the other +cutoffs is an exact local dual, including for Lp representatives. -/ +theorem coulombGram_local_duality {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (χ : Fin m → Position → ℝ) + (hmass : ∀ i, (∫ x, Coulomb.tfExtend Ω (density i) x) = 1) + (hown : ∀ i, ∀ᵐ x, Coulomb.tfExtend Ω (density i) x = 0 ∨ χ i x = 1) + (hdisjoint : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + (i j : Fin m) : + (∫ x, Coulomb.tfExtend Ω (density i) x * χ j x) = if i = j then 1 else 0 := by + classical + by_cases hij : i = j + · subst j + rw [ite_eq_left rfl, ← hmass i] + apply integral_congr_ae + filter_upwards [hown i] with x hx + rcases hx with hx | hx + · rw [hx, zero_mul] + · rw [hx, mul_one] + · rw [ite_eq_right hij] + calc + _ = ∫ _ : Position, (0 : ℝ) := by + apply integral_congr_ae + filter_upwards [hown i] with x hx + rcases hx with hx | hx + · rw [hx, zero_mul] + · have hxi : x ∈ tsupport (χ i) := subset_tsupport _ + (Function.mem_support.mpr (by rw [hx]; norm_num)) + have hxj : x ∉ tsupport (χ j) := + fun hxj => Set.disjoint_left.mp (hdisjoint i j hij) hxi hxj + rw [image_eq_zero_of_notMem_tsupport hxj, mul_zero] + _ = 0 := integral_zero _ _ + +/-- Local duality and disjoint compact tests control the entire long-range +Coulomb matrix, with no summability or row-dominance assumption. -/ +theorem coulombGram_coercive (hΩ : MeasurableSet Ω) {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (χ : Fin m → Position → ℝ) (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) + (hc : ∀ i, HasCompactSupport (χ i)) (hs : ∀ i, tsupport (χ i) ⊆ Ω) + (hdisjoint : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + (hdual : ∀ i j, (∫ x, Coulomb.tfExtend Ω (density i) x * χ j x) = + if i = j then 1 else 0) + {K : ℝ} (hK : 0 < K) + (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (d : Fin m → ℝ) : + (1 / K) * ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, coulombGram density i j * d i * d j := by + classical + let test : Fin m → Coulomb.TFLp (volume.restrict Ω) := + fun i => smoothTestPacket (χ i) (hχ i) (hc i) + let ρ := ∑ i, d i • density i + let η := ∑ i, d i • test i + let S := ∑ i, d i ^ 2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun i _ => sq_nonneg (d i)) + have hpair : Coulomb.tfCoulomb Ω ρ η = S := by + rw [coulombGram_sum hΩ] + simp_rw [show ∀ i j, Coulomb.tfCoulomb Ω (density i) (test j) = + if i = j then 1 else 0 from + fun i j => (smoothTestPacket_pair hΩ (χ j) (hχ j) (hc j) (hs j) (density i)).trans + (hdual i j)] + simp [S, mul_ite, pow_two] + have htest : Coulomb.tfCoulomb Ω η η ≤ K * S := by + rw [coulombGram_sum hΩ] + have hentry (i j : Fin m) : Coulomb.tfCoulomb Ω (test i) (test j) = + if i = j then ∫ x, Coulomb.testCharge (χ i) x * χ i x else 0 := by + by_cases hij : i = j + · subst j + simpa only [ite_true] using + smoothTestPacket_pair_test hΩ (χ i) (χ i) (hχ i) (hχ i) + (hc i) (hc i) (hs i) (hs i) + · rw [ite_eq_right hij] + exact smoothTestPacket_orthogonal hΩ (χ i) (χ j) (hχ i) (hχ j) + (hc i) (hc j) (hs i) (hs j) (hdisjoint i j hij) + simp_rw [hentry] + simp only [mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + calc + _ ≤ ∑ i, d i ^ 2 * K := Finset.sum_le_sum (fun i _ => by + simpa only [pow_two] using mul_le_mul_of_nonneg_left (henergy i) (sq_nonneg (d i))) + _ = K * S := by rw [← Finset.sum_mul]; exact mul_comm _ _ + have hQ : 0 ≤ Coulomb.tfCoulomb Ω ρ ρ := Coulomb.tfCoulomb_self_nonneg hΩ ρ + have hCS := Coulomb.tfCoulomb_cauchy hΩ ρ η + rw [hpair] at hCS + have hbound : S ^ 2 ≤ Coulomb.tfCoulomb Ω ρ ρ * (K * S) := + hCS.trans (mul_le_mul_of_nonneg_left htest hQ) + have hcoercive : (1 / K) * S ≤ Coulomb.tfCoulomb Ω ρ ρ := by + by_cases hz : S = 0 + · simpa only [hz, mul_zero] using hQ + · have hspos : 0 < S := lt_of_le_of_ne hS (Ne.symm hz) + have h := (mul_le_mul_iff_right₀ hspos).mp (show S * S ≤ + S * (Coulomb.tfCoulomb Ω ρ ρ * K) by nlinarith [hbound]) + have hh : S / K ≤ Coulomb.tfCoulomb Ω ρ ρ := (div_le_iff₀ hK).mpr h + simpa only [one_div, div_eq_mul_inv, mul_comm, mul_one] using hh + have hform := coulombGram_sum hΩ density density d d + change Coulomb.tfCoulomb Ω ρ ρ = _ at hform + rw [hform] at hcoercive + convert hcoercive using 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + dsimp [coulombGram] + ring + +omit [IsFiniteMeasure (volume.restrict Ω)] in +/-- Separate the common onsite term from the actual full Coulomb matrix, +in exactly the form used by the half-filled Hubbard charge estimate. -/ +theorem coulombGram_uniform_charge_condition {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) (U c : ℝ) + (hdiag : ∀ i, coulombGram density i i = U) + (hcoercive : ∀ d : Fin m → ℝ, + c * ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, coulombGram density i j * d i * d j) + (d : Fin m → ℝ) : + c * ∑ i, d i ^ 2 ≤ U * ∑ i, d i ^ 2 + + ∑ i, ∑ j, offDiagonalCoulombGram density i j * d i * d j := by + have h := hcoercive d + rw [coulombGram_diagonal_split] at h + simp_rw [hdiag] at h + rw [← Finset.mul_sum] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGramApprox.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGramApprox.lean new file mode 100644 index 0000000000000000000000000000000000000000..aee2974ddb691b514f6b69651978c705105208a3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombGramApprox.lean @@ -0,0 +1,162 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGram + +namespace OAI + +/-! Quantitative local duality for overlapping densities. The compact local +tests are disjoint; the electron density packets need not be disjoint. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +theorem dualMatrix_quadratic_lower {m : ℕ} (A : Fin m → Fin m → ℝ) + {a delta : ℝ} (hdelta : 0 ≤ delta) (hdiag : ∀ i, a ≤ A i i) + (hoff : ∀ i j, i ≠ j → |A i j| ≤ delta) (d : Fin m → ℝ) : + (a - m * delta) * ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, A i j * d i * d j := by + classical + have hpoint (i j : Fin m) : + (if i = j then a * d i ^ 2 else 0) - delta / 2 * (d i ^ 2 + d j ^ 2) ≤ + A i j * d i * d j := by + by_cases hij : i = j + · subst j + rw [ite_eq_left rfl] + have h := mul_le_mul_of_nonneg_right (hdiag i) (sq_nonneg (d i)) + have hzero := mul_nonneg hdelta (sq_nonneg (d i)) + nlinarith + · rw [ite_eq_right hij, zero_sub] + have hprod : |A i j * d i * d j| ≤ delta * (|d i| * |d j|) := by + calc + _ = |A i j| * (|d i| * |d j|) := by simp only [abs_mul]; ring + _ ≤ _ := mul_le_mul_of_nonneg_right (hoff i j hij) + (mul_nonneg (abs_nonneg _) (abs_nonneg _)) + have htwo : 2 * (|d i| * |d j|) ≤ d i ^ 2 + d j ^ 2 := by + nlinarith [sq_nonneg (|d i| - |d j|), sq_abs (d i), sq_abs (d j)] + have hscaled := mul_le_mul_of_nonneg_left htwo hdelta + nlinarith [neg_abs_le (A i j * d i * d j)] + have hsum := Finset.sum_le_sum (s := Finset.univ) fun i _ => + Finset.sum_le_sum (s := Finset.univ) fun j _ => hpoint i j + have hrow (i : Fin m) : + (∑ j, ((if i = j then a * d i ^ 2 else 0) - delta / 2 * (d i ^ 2 + d j ^ 2))) = + a * d i ^ 2 - delta / 2 * ((m : ℝ) * d i ^ 2 + ∑ j, d j ^ 2) := by + rw [Finset.sum_sub_distrib, ← Finset.mul_sum, Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + simp_rw [hrow] at hsum + rw [Finset.sum_sub_distrib, ← Finset.mul_sum, ← Finset.mul_sum, + Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hsum + convert hsum using 1 + ring + +variable {Ω : Set Position} [IsFiniteMeasure (volume.restrict Ω)] + +theorem smoothTestPacket_sum_energy (hΩ : MeasurableSet Ω) {m : ℕ} + (χ : Fin m → Position → ℝ) (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) + (hc : ∀ i, HasCompactSupport (χ i)) (hs : ∀ i, tsupport (χ i) ⊆ Ω) + (hdisjoint : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {K : ℝ} (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (d : Fin m → ℝ) : + Coulomb.tfCoulomb Ω (∑ i, d i • smoothTestPacket (χ i) (hχ i) (hc i)) + (∑ i, d i • smoothTestPacket (χ i) (hχ i) (hc i)) ≤ K * ∑ i, d i ^ 2 := by + classical + rw [coulombGram_sum hΩ] + have hentry (i j : Fin m) : + Coulomb.tfCoulomb Ω (smoothTestPacket (χ i) (hχ i) (hc i)) + (smoothTestPacket (χ j) (hχ j) (hc j)) = + if i = j then ∫ x, Coulomb.testCharge (χ i) x * χ i x else 0 := by + by_cases hij : i = j + · subst j + simpa only [ite_true] using smoothTestPacket_pair_test hΩ (χ i) (χ i) + (hχ i) (hχ i) (hc i) (hc i) (hs i) (hs i) + · rw [ite_eq_right hij] + exact smoothTestPacket_orthogonal hΩ (χ i) (χ j) (hχ i) (hχ j) + (hc i) (hc j) (hs i) (hs j) (hdisjoint i j hij) + simp_rw [hentry] + simp only [mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + calc + _ ≤ ∑ i, d i ^ 2 * K := Finset.sum_le_sum (fun i _ => by + simpa only [pow_two] using mul_le_mul_of_nonneg_left (henergy i) (sq_nonneg (d i))) + _ = _ := by rw [← Finset.sum_mul]; exact mul_comm _ _ + +/-- Coercivity from approximate local duality; overlap of the densities is +allowed and all Coulomb interactions remain in the matrix. -/ +theorem coulombGram_coercive_of_dual_lower (hΩ : MeasurableSet Ω) {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (χ : Fin m → Position → ℝ) (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) + (hc : ∀ i, HasCompactSupport (χ i)) (hs : ∀ i, tsupport (χ i) ⊆ Ω) + (hdisjoint : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {K a : ℝ} (hK : 0 < K) (ha : 0 ≤ a) + (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (hdual : ∀ d : Fin m → ℝ, a * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, d i * d j * ∫ x, Coulomb.tfExtend Ω (density i) x * χ j x) + (d : Fin m → ℝ) : + (a ^ 2 / K) * ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, coulombGram density i j * d i * d j := by + let ρ := ∑ i, d i • density i + let η : Coulomb.TFLp (volume.restrict Ω) := ∑ i, d i • smoothTestPacket (χ i) (hχ i) (hc i) + let S := ∑ i, d i ^ 2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun i _ => sq_nonneg (d i)) + have hpair : a * S ≤ Coulomb.tfCoulomb Ω ρ η := by + rw [coulombGram_sum hΩ] + simp_rw [smoothTestPacket_pair hΩ _ _ _ (hs _) ] + exact hdual d + have hpair0 : 0 ≤ Coulomb.tfCoulomb Ω ρ η := (mul_nonneg ha hS).trans hpair + have hsquare : (a * S) ^ 2 ≤ (Coulomb.tfCoulomb Ω ρ η) ^ 2 := + (sq_le_sq₀ (mul_nonneg ha hS) hpair0).mpr hpair + have htest := smoothTestPacket_sum_energy hΩ χ hχ hc hs hdisjoint henergy d + have hQ : 0 ≤ Coulomb.tfCoulomb Ω ρ ρ := Coulomb.tfCoulomb_self_nonneg hΩ ρ + have hCS := Coulomb.tfCoulomb_cauchy hΩ ρ η + have hbound : (a * S) ^ 2 ≤ Coulomb.tfCoulomb Ω ρ ρ * (K * S) := + hsquare.trans (hCS.trans (mul_le_mul_of_nonneg_left htest hQ)) + have hcoercive : (a ^ 2 / K) * S ≤ Coulomb.tfCoulomb Ω ρ ρ := by + by_cases hz : S = 0 + · simpa only [hz, mul_zero] using hQ + · have hSpos : 0 < S := lt_of_le_of_ne hS (Ne.symm hz) + have hcancel := (mul_le_mul_iff_left₀ hSpos).mp + (show (a ^ 2 * S) * S ≤ (Coulomb.tfCoulomb Ω ρ ρ * K) * S by + nlinarith only [hbound]) + rw [div_mul_eq_mul_div] + exact (div_le_iff₀ hK).mpr hcancel + have hform := coulombGram_sum hΩ density density d d + change Coulomb.tfCoulomb Ω ρ ρ = _ at hform + rw [hform] at hcoercive + convert hcoercive using 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + dsimp [coulombGram] + ring + +/-- The diagonal test mass may vary from site to site. Only a common lower +bound and small off-site leakage are needed. -/ +theorem coulombGram_coercive_local_estimates (hΩ : MeasurableSet Ω) {m : ℕ} + (density : Fin m → Coulomb.TFLp (volume.restrict Ω)) + (χ : Fin m → Position → ℝ) (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) + (hc : ∀ i, HasCompactSupport (χ i)) (hs : ∀ i, tsupport (χ i) ⊆ Ω) + (hdisjoint : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {K a delta : ℝ} (hK : 0 < K) (hdelta : 0 ≤ delta) + (hmargin : 0 ≤ a - m * delta) + (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (hdiag : ∀ i, a ≤ ∫ x, Coulomb.tfExtend Ω (density i) x * χ i x) + (hoff : ∀ i j, i ≠ j → |∫ x, Coulomb.tfExtend Ω (density i) x * χ j x| ≤ delta) + (d : Fin m → ℝ) : + ((a - m * delta) ^ 2 / K) * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, coulombGram density i j * d i * d j := by + apply coulombGram_coercive_of_dual_lower hΩ density χ hχ hc hs hdisjoint + hK hmargin henergy ?_ d + intro e + have h := dualMatrix_quadratic_lower + (fun i j => ∫ x, Coulomb.tfExtend Ω (density i) x * χ j x) hdelta hdiag hoff e + convert h using 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombInverseFifth.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombInverseFifth.lean new file mode 100644 index 0000000000000000000000000000000000000000..1579e4530fe16a6ba2f5097557b3b82ee613c487 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombInverseFifth.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombMass +import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals + +namespace OAI + +/-! The inverse-fifth-power tail is integrable in three dimensions, with the +exact inverse-square dependence needed when summing far-cell errors. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def inverseFifthRadial (r : ℝ) : ℝ → ℝ := + (Set.Ioi r).indicator (fun t => t^(-5:ℝ)) + +def inverseFifthTail (r : ℝ) (x : Position) : ℝ := inverseFifthRadial r ‖x‖ + +private theorem inverseFifthRadial_weight {r : ℝ} (hr : 0 < r) (t : ℝ) : + t^2*inverseFifthRadial r t = (Set.Ioi r).indicator (fun t => t^(-3:ℝ)) t := by + by_cases ht : r < t + · simp only [inverseFifthRadial,Set.indicator_of_mem (Set.mem_Ioi.mpr ht)] + have hp : 0 < t := hr.trans ht + rw [show (-3:ℝ) = 2+(-5) by norm_num,Real.rpow_add hp,Real.rpow_two] + · simp [inverseFifthRadial,ht] + +private theorem inverseFifthRadial_weight_integrable {r : ℝ} (hr : 0 < r) : + IntegrableOn (fun t : ℝ => t^2*inverseFifthRadial r t) (Set.Ioi 0) := by + have hi := integrableOn_Ioi_rpow_of_lt (by norm_num : (-3:ℝ) < -1) hr + have h := (integrable_indicator_iff measurableSet_Ioi).mpr hi + simpa only [inverseFifthRadial_weight hr] using h.integrableOn + +private theorem inverseFifthRadial_weight_integral {r : ℝ} (hr : 0 < r) : + (∫ t in Set.Ioi (0:ℝ), t^2*inverseFifthRadial r t) = 1/(2*r^2) := by + simp_rw [inverseFifthRadial_weight hr] + rw [integral_indicator measurableSet_Ioi,Measure.restrict_restrict measurableSet_Ioi, + Set.Ioi_inter_Ioi,max_eq_left hr.le] + have hi := integral_Ioi_rpow_of_lt (by norm_num : (-3:ℝ) < -1) hr + convert hi using 1 + norm_num [Real.rpow_neg,Real.rpow_two] + ring + +theorem inverseFifthTail_integrable {r : ℝ} (hr : 0 < r) : Integrable (inverseFifthTail r) := by + apply (integrable_fun_norm_addHaar (E := Position) volume (f := inverseFifthRadial r)).mpr + simpa only [finrank_euclideanSpace_fin,Nat.reduceSub,smul_eq_mul] using + inverseFifthRadial_weight_integrable hr + +theorem inverseFifthTail_integral {r : ℝ} (hr : 0 < r) : + (∫ x : Position, inverseFifthTail r x) = 2*Real.pi/r^2 := by + change (∫ x : Position, inverseFifthRadial r ‖x‖) = _ + rw [integral_fun_norm_addHaar volume] + simp only [finrank_euclideanSpace_fin,Nat.reduceSub,smul_eq_mul] + rw [inverseFifthRadial_weight_integral hr] + simp only [Measure.real,EuclideanSpace.volume_ball_fin_three,ENNReal.ofReal_one,one_pow, + one_mul,ENNReal.toReal_ofReal (by positivity : 0 ≤ Real.pi*4/3),nsmul_eq_mul] + norm_num [Position,finrank_euclideanSpace_fin] + ring + +theorem inverseFifthTail_of_gt {r : ℝ} (x : Position) (hx : r < ‖x‖) : + inverseFifthTail r x = ‖x‖^(-5:ℝ) := by + unfold inverseFifthTail inverseFifthRadial + exact Set.indicator_of_mem (Set.mem_Ioi.mpr hx) _ + +theorem inverseFifthTail_nonneg (r : ℝ) (x : Position) : 0 ≤ inverseFifthTail r x := by + by_cases hx : r < ‖x‖ + · rw [inverseFifthTail_of_gt x hx] + exact Real.rpow_nonneg (norm_nonneg x) _ + · simp [inverseFifthTail,inverseFifthRadial,hx] + +theorem inverseFifthTail_eq_inv_pow {r : ℝ} (x : Position) (hx : r < ‖x‖) : + inverseFifthTail r x = 1/‖x‖^5 := by + rw [inverseFifthTail_of_gt x hx] + simp + +theorem inverseFifthTail_measurable (r : ℝ) : Measurable (inverseFifthTail r) := by + have he : inverseFifthTail r = {x : Position | r < ‖x‖}.indicator (fun x => 1/‖x‖^5) := by + funext x + by_cases hx : r < ‖x‖ + · rw [inverseFifthTail_eq_inv_pow x hx, + Set.indicator_of_mem (show x ∈ {x : Position | r < ‖x‖} from hx)] + · simp [inverseFifthTail,inverseFifthRadial,hx] + rw [he] + exact (measurable_const.div (continuous_norm.measurable.pow_const 5)).indicator + (isOpen_lt continuous_const continuous_norm).measurableSet + +theorem inverseFifthTail_le {r : ℝ} (hr : 0 < r) (x : Position) : + inverseFifthTail r x ≤ 1/r^5 := by + by_cases hx : r < ‖x‖ + · rw [inverseFifthTail_eq_inv_pow x hx] + exact one_div_le_one_div_of_le (pow_pos hr 5) (pow_le_pow_left₀ hr.le hx.le 5) + · have he : inverseFifthTail r x = 0 := by simp [inverseFifthTail,inverseFifthRadial,hx] + rw [he] + positivity + +theorem translatedInverseFifth_integrable (y : Position) {r : ℝ} (hr : 0 < r) : + Integrable (fun x => inverseFifthTail r (y-x)) := + (volume.measurePreserving_sub_left y).integrable_comp_of_integrable + (inverseFifthTail_integrable hr) + +theorem translatedInverseFifth_integral (y : Position) {r : ℝ} (hr : 0 < r) : + (∫ x, inverseFifthTail r (y-x)) = 2*Real.pi/r^2 := by + rw [integral_sub_left_eq_self,inverseFifthTail_integral hr] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelHomogeneity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelHomogeneity.lean new file mode 100644 index 0000000000000000000000000000000000000000..dec776e5e704417bce2b6c7bc320ce9e1db88eaf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelHomogeneity.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombKernelSmooth +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Dilation + +namespace OAI + +/-! Derivatives through order four of the actual inverse-distance kernel +decay by the appropriate inverse power. -/ + +noncomputable section +open scoped ContDiff +namespace ContinuumCoulomb + +theorem coulombKernel_iteratedFDeriv_scaling (k : ℕ) {c : ℝ} (hc : 0 < c) + {x : Position} (hx : x ≠ 0) : + c^k*‖iteratedFDeriv ℝ k Coulomb.coulombKernel (c • x)‖ = + c⁻¹*‖iteratedFDeriv ℝ k Coulomb.coulombKernel x‖ := by + let e : Position ≃L[ℝ] Position := ContinuousLinearEquiv.smulLeft (Units.mk0 c hc.ne') + have he (z : Position) : e z = c • z := rfl + have hd := e.iteratedFDerivWithin_comp_right Coulomb.coulombKernel uniqueDiffOn_univ + (Set.mem_univ (e x)) k + simp only [Set.preimage_univ,iteratedFDerivWithin_univ] at hd + have hright : iteratedFDeriv ℝ k (Coulomb.coulombKernel ∘ e) x = + c^k • iteratedFDeriv ℝ k Coulomb.coulombKernel (c • x) := by + rw [hd] + ext v + simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply, + smul_apply,ContinuousLinearEquiv.coe_coe,he] + simpa only [Finset.prod_const,Finset.card_univ,Fintype.card_fin] using + (iteratedFDeriv ℝ k Coulomb.coulombKernel (c • x)).map_smul_univ (fun _ => c) v + have hfun : Coulomb.coulombKernel ∘ e = c⁻¹ • Coulomb.coulombKernel := by + funext z + exact coulombKernel_smul z hc + rw [hfun,iteratedFDeriv_const_smul_apply + ((coulombKernel_contDiffAt hx).of_le (ENat.natCast_lt_of_coe_top_le_withTop le_rfl k).le : ContDiffAt ℝ k Coulomb.coulombKernel x)] at hright + have hn := congrArg norm hright.symm + simpa only [norm_smul,Real.norm_eq_abs,abs_of_pos (pow_pos hc k), + abs_of_pos (inv_pos.mpr hc)] using hn + +theorem coulombKernel_derivative_decay : + ∃ C : ℝ, 1 ≤ C ∧ ∀ k : Fin 5, ∀ x : Position, x ≠ 0 → + ‖iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel x‖*‖x‖^((k:ℕ)+1) ≤ C := by + obtain ⟨C,hC,hbound⟩ := coulombKernel_fixed_annulus_bounds + refine ⟨C,hC,fun k x hx => ?_⟩ + let y : Position := ‖x‖⁻¹ • x + have hn : 0 < ‖x‖ := norm_pos_iff.mpr hx + have hy : ‖y‖ = 1 := by + simp only [y,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hn)] + exact inv_mul_cancel₀ hn.ne' + have hyne : y ≠ 0 := by intro he; simp only [he,norm_zero] at hy; norm_num at hy + have hxy : ‖x‖ • y = x := by + simp only [y,smul_smul,mul_inv_cancel₀ hn.ne',one_smul] + have h := coulombKernel_iteratedFDeriv_scaling k hn hyne + rw [hxy] at h + have hb := hbound k y (by rw [hy]; norm_num) (by rw [hy]; norm_num) + calc + _ = ‖x‖*(‖x‖^(k:ℕ)*‖iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel x‖) := by ring + _ = ‖x‖*(‖x‖⁻¹*‖iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel y‖) := by rw [h] + _ = ‖iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel y‖ := by + rw [← mul_assoc,mul_inv_cancel₀ hn.ne',one_mul] + _ ≤ C := hb + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelSmooth.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..efb9d32aa88bbfd10820bdf5a71b673ee4d0c368 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombKernelSmooth.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import Mathlib.Analysis.InnerProductSpace.Calculus + +namespace OAI + +/-! Smoothness of the actual Coulomb kernel away from its pole, with +uniform derivative bounds on the fixed annulus used in cell estimates. -/ + +noncomputable section +open scoped ContDiff BigOperators Classical +namespace ContinuumCoulomb + +theorem coulombKernel_contDiffAt {x : Position} (hx : x ≠ 0) : + ContDiffAt ℝ ∞ Coulomb.coulombKernel x := by + exact (contDiffAt_norm ℝ hx).inv (norm_ne_zero_iff.mpr hx) + +theorem coulombKernel_iteratedFDeriv_continuousAt (k : ℕ) {x : Position} (hx : x ≠ 0) : + ContinuousAt (iteratedFDeriv ℝ k Coulomb.coulombKernel) x := + ((coulombKernel_contDiffAt hx).differentiableAt_iteratedFDeriv (ENat.natCast_lt_of_coe_top_le_withTop le_rfl k)).continuousAt + +theorem coulombKernel_fixed_annulus_bounds : + ∃ C : ℝ, 1 ≤ C ∧ ∀ k : Fin 5, ∀ x : Position, 1/2 ≤ ‖x‖ → ‖x‖ ≤ 2 → + ‖iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel x‖ ≤ C := by + let K := Metric.closedBall (0:Position) 2 \ Metric.ball 0 (1/2) + have hK : IsCompact K := (isCompact_closedBall (0:Position) 2).diff Metric.isOpen_ball + have hk (k : Fin 5) : ContinuousOn (iteratedFDeriv ℝ (k:ℕ) Coulomb.coulombKernel) K := by + intro x hx + apply (coulombKernel_iteratedFDeriv_continuousAt k ?_).continuousWithinAt + intro he + have hn := hx.2 + apply hn + rw [he,Metric.mem_ball,dist_self] + norm_num + choose C hC using fun k : Fin 5 => hK.exists_bound_of_continuousOn (hk k) + refine ⟨1+∑ k, |C k|,?_,fun k x hx₁ hx₂ => ?_⟩ + · exact le_add_of_nonneg_right (Finset.sum_nonneg (fun _ _ => abs_nonneg _)) + · have hx : x ∈ K := by + refine ⟨?_,?_⟩ + · simpa only [Metric.mem_closedBall,dist_zero_right] using hx₂ + · simpa only [Metric.mem_ball,dist_zero_right,not_lt] using hx₁ + have hb := Finset.single_le_sum (fun j (_ : j ∈ (Finset.univ : Finset (Fin 5))) => + abs_nonneg (C j)) (Finset.mem_univ k) + exact (hC k x hx).trans ((le_abs_self _).trans (by linarith)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombNormalizationError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombNormalizationError.lean new file mode 100644 index 0000000000000000000000000000000000000000..d36f7e11d9f3a27188d5e413e3c34e745757af43 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombNormalizationError.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.NormalizationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianFrequencyProgram + +namespace OAI + +/-! Stability of the exact fixed normalization factor ω/(A²π). -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem guarded_inverse_error {C a a' ε : ℝ} (hC : 0 < C) (ha : 0 < a) + (hguard : 2 ≤ C * a) (hε : 0 ≤ ε) (hsmall : C * ε ≤ 1) + (he : |a' - a| ≤ ε) : + 0 < a' ∧ a⁻¹ ≤ C ∧ a'⁻¹ ≤ C ∧ |a'⁻¹ - a⁻¹| ≤ C ^ 2 * ε := by + have hl := mul_le_mul_of_nonneg_left (abs_le.mp he).1 hC.le + have hguard' : 1 ≤ C * a' := by nlinarith + have ha' : 0 < a' := by + by_contra hn + have hm := mul_nonpos_of_nonneg_of_nonpos hC.le (le_of_not_gt hn) + linarith + have hi : a⁻¹ ≤ C := (inv_le_iff_one_le_mul₀ ha).mpr (by linarith) + have hi' : a'⁻¹ ≤ C := (inv_le_iff_one_le_mul₀ ha').mpr hguard' + refine ⟨ha', hi, hi', ?_⟩ + have hid : a'⁻¹ - a⁻¹ = (a - a') * a'⁻¹ * a⁻¹ := by + field_simp [ha.ne', ha'.ne'] + rw [hid, abs_mul, abs_mul, abs_sub_comm a a', + abs_of_pos (inv_pos.mpr ha'), abs_of_pos (inv_pos.mpr ha)] + calc + _ ≤ ε * C * C := by gcongr + _ = _ := by ring + +theorem coulomb_normalization_error {C a a' p p' f f' ε : ℝ} + (hC : 1 ≤ C) (ha : 0 < a) (hp : 0 < p) + (hga : 2 ≤ C * a) (hgp : 2 ≤ C * p) (hf : |f| ≤ C) + (hε : 0 ≤ ε) (hsmall : C * ε ≤ 1) + (hea : |a' - a| ≤ ε) (hep : |p' - p| ≤ ε) (hef : |f' - f| ≤ ε) : + |f' / (a' ^ 2 * p') - f / (a ^ 2 * p)| ≤ (C ^ 3 + 3 * C ^ 5) * ε := by + have hC0 : 0 < C := by linarith + obtain ⟨ha', hia, hia', heia⟩ := guarded_inverse_error hC0 ha hga hε hsmall hea + obtain ⟨hp', hip, hip', heip⟩ := guarded_inverse_error hC0 hp hgp hε hsmall hep + have hsq : |a'⁻¹ ^ 2 - a⁻¹ ^ 2| ≤ 2 * C ^ 3 * ε := by + have hid : a'⁻¹ ^ 2 - a⁻¹ ^ 2 = (a'⁻¹ - a⁻¹) * (a'⁻¹ + a⁻¹) := by ring + rw [hid, abs_mul, abs_of_pos (add_pos (inv_pos.mpr ha') (inv_pos.mpr ha))] + calc + _ ≤ (C ^ 2 * ε) * (C + C) := by gcongr + _ = _ := by ring + have hid : f' / (a' ^ 2 * p') - f / (a ^ 2 * p) = + (f' - f) * a'⁻¹ ^ 2 * p'⁻¹ + + f * (a'⁻¹ ^ 2 - a⁻¹ ^ 2) * p'⁻¹ + + f * a⁻¹ ^ 2 * (p'⁻¹ - p⁻¹) := by + field_simp [ha.ne', ha'.ne', hp.ne', hp'.ne'] + ring + have h1 : |(f' - f) * a'⁻¹ ^ 2 * p'⁻¹| ≤ C ^ 3 * ε := by + rw [abs_mul, abs_mul, abs_of_nonneg (sq_nonneg a'⁻¹), abs_of_pos (inv_pos.mpr hp')] + calc + _ ≤ ε * C ^ 2 * C := by gcongr + _ = _ := by ring + have h2 : |f * (a'⁻¹ ^ 2 - a⁻¹ ^ 2) * p'⁻¹| ≤ 2 * C ^ 5 * ε := by + rw [abs_mul, abs_mul, abs_of_pos (inv_pos.mpr hp')] + calc + _ ≤ C * (2 * C ^ 3 * ε) * C := by gcongr + _ = _ := by ring + have h3 : |f * a⁻¹ ^ 2 * (p'⁻¹ - p⁻¹)| ≤ C ^ 5 * ε := by + rw [abs_mul, abs_mul, abs_of_nonneg (sq_nonneg a⁻¹)] + calc + _ ≤ C * C ^ 2 * (C ^ 2 * ε) := by gcongr + _ = _ := by ring + rw [hid] + exact ((abs_add_le _ _).trans (add_le_add (abs_add_le _ _) le_rfl)).trans + ((add_le_add (add_le_add h1 h2) h3).trans_eq (by ring)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketCoercivity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketCoercivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba463511c75077d4bd38b6e85483bb871d17766d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketCoercivity.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPacketTests + +namespace OAI + +/-! Global Coulomb coercivity from disjoint compact tests and approximate +local duality. All integrals range over the whole Euclidean space. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb.CoulombPacket + +theorem test_combination_energy {m : ℕ} (χ : Fin m → Position → ℝ) + (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) (hc : ∀ i, HasCompactSupport (χ i)) + (hd : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {K : ℝ} (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (d : Fin m → ℝ) : + pair (combination (fun i => test (χ i) (hχ i) (hc i)) d) + (combination (fun i => test (χ i) (hχ i) (hc i)) d) ≤ K * ∑ i, d i ^ 2 := by + classical + rw [pair_combinations] + have hentry (i j : Fin m) : pair (test (χ i) (hχ i) (hc i)) (test (χ j) (hχ j) (hc j)) = + if i = j then ∫ x, Coulomb.testCharge (χ i) x * χ i x else 0 := by + by_cases hij : i = j + · subst j + simpa only [ite_true] using test_pair_test (χ i) (χ i) (hχ i) (hχ i) (hc i) (hc i) + · rw [ite_eq_right hij] + exact test_pair_orthogonal (χ i) (χ j) (hχ i) (hχ j) (hc i) (hc j) (hd i j hij) + simp_rw [hentry] + simp only [mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + calc + _ ≤ ∑ i, d i ^ 2 * K := Finset.sum_le_sum (fun i _ => by + simpa only [pow_two] using mul_le_mul_of_nonneg_left (henergy i) (sq_nonneg (d i))) + _ = _ := by rw [← Finset.sum_mul]; exact mul_comm _ _ + +theorem gram_coercive_of_dual_lower {m : ℕ} (f : Fin m → CoulombPacket) + (χ : Fin m → Position → ℝ) (hχ : ∀ i, ContDiff ℝ ∞ (χ i)) + (hc : ∀ i, HasCompactSupport (χ i)) + (hd : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {K a : ℝ} (hK : 0 < K) (ha : 0 ≤ a) + (henergy : ∀ i, (∫ x, Coulomb.testCharge (χ i) x * χ i x) ≤ K) + (hdual : ∀ d : Fin m → ℝ, a * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, d i * d j * ∫ x, f i x * χ j x) + (d : Fin m → ℝ) : + (a ^ 2 / K) * ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, pair (f i) (f j) * d i * d j := by + let ρ := combination f d + let η := combination (fun i => test (χ i) (hχ i) (hc i)) d + let S := ∑ i, d i ^ 2 + have hS : 0 ≤ S := Finset.sum_nonneg (fun i _ => sq_nonneg (d i)) + have hpair : a * S ≤ pair ρ η := by + rw [pair_combinations] + simp_rw [pair_test] + exact hdual d + have hpair0 : 0 ≤ pair ρ η := (mul_nonneg ha hS).trans hpair + have hsquare : (a * S) ^ 2 ≤ pair ρ η ^ 2 := + (sq_le_sq₀ (mul_nonneg ha hS) hpair0).mpr hpair + have htest := test_combination_energy χ hχ hc hd henergy d + have hQ : 0 ≤ pair ρ ρ := pair_nonnegative ρ + have hbound : (a * S) ^ 2 ≤ pair ρ ρ * (K * S) := + hsquare.trans ((pair_cauchy ρ η).trans (mul_le_mul_of_nonneg_left htest hQ)) + have hcoercive : (a ^ 2 / K) * S ≤ pair ρ ρ := by + by_cases hz : S = 0 + · simpa only [hz, mul_zero] using hQ + · have hSpos : 0 < S := lt_of_le_of_ne hS (Ne.symm hz) + have hcancel := (mul_le_mul_iff_left₀ hSpos).mp + (show (a ^ 2 * S) * S ≤ (pair ρ ρ * K) * S by nlinarith only [hbound]) + rw [div_mul_eq_mul_div] + exact (div_le_iff₀ hK).mpr hcancel + change (a ^ 2 / K) * S ≤ pair (combination f d) (combination f d) at hcoercive + rw [pair_combinations] at hcoercive + convert hcoercive using 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +end ContinuumCoulomb.CoulombPacket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketTests.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..7df1943114a45c17b53b07b16bad057a3101bfe7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPacketTests.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPackets + +namespace OAI + +/-! Finite packet combinations and the exact global Poisson duality for +smooth compact tests. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb.CoulombPacket + +def zero : CoulombPacket where + value _ := 0 + continuous := continuous_const + integrable := integrable_zero Position ℝ volume + bound := 0 + bound_nonnegative := le_rfl + bound_spec _ := by simp + +def sumList : List CoulombPacket → CoulombPacket + | [] => zero + | f :: fs => add f (sumList fs) + +theorem pair_zero_left (f : CoulombPacket) : pair zero f = 0 := by + simp [pair, zero] + +theorem pair_sumList_left (fs : List CoulombPacket) (g : CoulombPacket) : + pair (sumList fs) g = (fs.map (fun f => pair f g)).sum := by + induction fs with + | nil => exact pair_zero_left g + | cons f fs ih => simp only [sumList, pair_add_left, ih, List.map_cons, List.sum_cons] + +def combination {m : ℕ} (f : Fin m → CoulombPacket) (d : Fin m → ℝ) : CoulombPacket := + sumList (List.ofFn (fun i => smul (d i) (f i))) + +theorem pair_combination_left {m : ℕ} (f : Fin m → CoulombPacket) (d : Fin m → ℝ) + (g : CoulombPacket) : pair (combination f d) g = ∑ i, d i * pair (f i) g := by + rw [combination, pair_sumList_left, List.map_ofFn, List.sum_ofFn] + simp only [Function.comp_def, pair_smul_left] + +theorem pair_combination_right {m : ℕ} (f : CoulombPacket) (g : Fin m → CoulombPacket) + (d : Fin m → ℝ) : pair f (combination g d) = ∑ j, d j * pair f (g j) := by + calc + _ = pair (combination g d) f := pair_symmetric _ _ + _ = ∑ j, d j * pair (g j) f := pair_combination_left g d f + _ = _ := Finset.sum_congr rfl (fun j _ => congrArg (fun a => d j * a) (pair_symmetric (g j) f)) + +theorem pair_combinations {m n : ℕ} (f : Fin m → CoulombPacket) (g : Fin n → CoulombPacket) + (d : Fin m → ℝ) (e : Fin n → ℝ) : + pair (combination f d) (combination g e) = + ∑ i, ∑ j, d i * e j * pair (f i) (g j) := by + rw [pair_combination_left] + simp_rw [pair_combination_right, Finset.mul_sum, mul_assoc] + +def ofCompact (f : Position → ℝ) (hf : Continuous f) (hc : HasCompactSupport f) : CoulombPacket where + value := f + continuous := hf + integrable := hf.integrable_of_hasCompactSupport hc + bound := max (Classical.choose (hc.exists_bound_of_continuous hf)) 0 + bound_nonnegative := le_max_right _ _ + bound_spec x := (Classical.choose_spec (hc.exists_bound_of_continuous hf) x).trans (le_max_left _ _) + +def test (χ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hc : HasCompactSupport χ) : CoulombPacket := + ofCompact (Coulomb.testCharge χ) (Coulomb.testCharge_continuous hχ) (Coulomb.testCharge_compact hc) + +theorem pair_test (f : CoulombPacket) (χ : Position → ℝ) + (hχ : ContDiff ℝ ∞ χ) (hc : HasCompactSupport χ) : + pair f (test χ hχ hc) = ∫ x, f x * χ x := by + unfold pair + rw [Measure.volume_eq_prod, integral_prod _ (joint_integrable f (test χ hχ hc))] + apply integral_congr_ae + filter_upwards [] with x + change (∫ y, f x * Coulomb.testCharge χ y * Coulomb.coulombKernel (x - y)) = _ + rw [show (fun y => f x * Coulomb.testCharge χ y * Coulomb.coulombKernel (x - y)) = + (fun y => f x * (Coulomb.coulombKernel (x - y) * Coulomb.testCharge χ y)) by funext y; ring, + integral_const_mul, Coulomb.testCharge_potential hχ hc] + +theorem test_pair_test (χ ψ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hψ : ContDiff ℝ ∞ ψ) + (hcχ : HasCompactSupport χ) (hcψ : HasCompactSupport ψ) : + pair (test χ hχ hcχ) (test ψ hψ hcψ) = ∫ x, Coulomb.testCharge χ x * ψ x := + pair_test _ _ hψ hcψ + +theorem test_pair_orthogonal (χ ψ : Position → ℝ) (hχ : ContDiff ℝ ∞ χ) (hψ : ContDiff ℝ ∞ ψ) + (hcχ : HasCompactSupport χ) (hcψ : HasCompactSupport ψ) + (hd : Disjoint (tsupport χ) (tsupport ψ)) : pair (test χ hχ hcχ) (test ψ hψ hcψ) = 0 := by + rw [test_pair_test] + have hz (x : Position) : Coulomb.testCharge χ x * ψ x = 0 := by + by_cases hx : x ∈ tsupport χ + · rw [image_eq_zero_of_notMem_tsupport (fun hy => Set.disjoint_left.mp hd hx hy), mul_zero] + · rw [Coulomb.testCharge_zero hx, zero_mul] + simp_rw [hz, integral_zero] + +end ContinuumCoulomb.CoulombPacket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPackets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPackets.lean new file mode 100644 index 0000000000000000000000000000000000000000..105a02c160ca3ec6f152548109b9842e8526b285 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPackets.lean @@ -0,0 +1,135 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulomb +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGram + +namespace OAI + +/-! The global Coulomb pairing for the bounded integrable packets used in +the mode construction. Existing Gaussian-kernel positivity applies directly +once the elementary bounded-density estimate supplies joint integrability. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +structure CoulombPacket where + value : Position → ℝ + continuous : Continuous value + integrable : Integrable value + bound : ℝ + bound_nonnegative : 0 ≤ bound + bound_spec : ∀ x, ‖value x‖ ≤ bound + +namespace CoulombPacket + +instance : CoeFun CoulombPacket (fun _ => Position → ℝ) := ⟨CoulombPacket.value⟩ + +def add (f g : CoulombPacket) : CoulombPacket where + value x := f x + g x + continuous := f.continuous.add g.continuous + integrable := f.integrable.add g.integrable + bound := f.bound + g.bound + bound_nonnegative := add_nonneg f.bound_nonnegative g.bound_nonnegative + bound_spec x := (norm_add_le _ _).trans (add_le_add (f.bound_spec x) (g.bound_spec x)) + +def smul (t : ℝ) (f : CoulombPacket) : CoulombPacket where + value x := t * f x + continuous := continuous_const.mul f.continuous + integrable := f.integrable.const_mul t + bound := ‖t‖ * f.bound + bound_nonnegative := mul_nonneg (norm_nonneg t) f.bound_nonnegative + bound_spec x := by + rw [norm_mul] + exact mul_le_mul_of_nonneg_left (f.bound_spec x) (norm_nonneg t) + +theorem joint_integrable (f g : CoulombPacket) : + Integrable (fun p : Position × Position => + f p.1 * g p.2 * Coulomb.coulombKernel (p.1 - p.2)) := by + have hg (x : Position) := NeutralAtom.bounded_density_convolution + NeutralAtom.measurable_coulombKernel NeutralAtom.coulombKernel_nonneg + (NeutralAtom.coulombKernel_integrableOn_ball 1) (fun _ => NeutralAtom.coulombKernel_le_one) + g.integrable.norm (fun _ => norm_nonneg _) g.bound_spec x + let C := g.bound * NeutralAtom.kernelBallMass 1 + ∫ y, ‖g y‖ + have hm : Measurable (fun p : Position × Position => + f p.1 * g p.2 * Coulomb.coulombKernel (p.1 - p.2)) := + ((f.continuous.measurable.comp measurable_fst).mul + (g.continuous.measurable.comp measurable_snd)).mul + (Coulomb.coulombKernel_measurable.comp (measurable_fst.sub measurable_snd)) + apply (integrable_prod_iff hm.aestronglyMeasurable).mpr + constructor + · exact Filter.Eventually.of_forall (fun x => by + have hi := (hg x).1.const_mul ‖f x‖ + apply hi.mono' ((hm.comp ((measurable_const : Measurable (fun _ : Position => x)).prodMk + measurable_id)).aestronglyMeasurable) + exact Filter.Eventually.of_forall (fun y => by + dsimp only [Function.comp_def, Prod.fst, Prod.snd, id_eq] + rw [norm_mul, norm_mul, Real.norm_of_nonneg (Coulomb.coulombKernel_nonneg _)] + change ‖f x‖ * ‖g y‖ * ‖x - y‖⁻¹ ≤ ‖f x‖ * (‖x - y‖⁻¹ * ‖g y‖) + ring_nf + exact le_rfl)) + · apply (f.integrable.norm.const_mul C).mono' + hm.aestronglyMeasurable.norm.integral_prod_right' + exact Filter.Eventually.of_forall (fun x => by + have he : (∫ y, ‖f x * g y * Coulomb.coulombKernel (x - y)‖) = + ‖f x‖ * ∫ y, NeutralAtom.coulombKernel (x - y) * ‖g y‖ := by + have hp (y : Position) : ‖f x * g y * Coulomb.coulombKernel (x - y)‖ = + ‖f x‖ * (NeutralAtom.coulombKernel (x - y) * ‖g y‖) := by + rw [norm_mul, norm_mul, Real.norm_of_nonneg (Coulomb.coulombKernel_nonneg _)] + change ‖f x‖ * ‖g y‖ * ‖x - y‖⁻¹ = ‖f x‖ * (‖x - y‖⁻¹ * ‖g y‖) + ring + simp_rw [hp, integral_const_mul] + rw [Real.norm_of_nonneg (integral_nonneg (fun _ => norm_nonneg _)), he] + calc + _ ≤ ‖f x‖ * C := mul_le_mul_of_nonneg_left (hg x).2 (norm_nonneg (f x)) + _ = _ := mul_comm _ _) + +def pair (f g : CoulombPacket) : ℝ := + ∫ p : Position × Position, f p.1 * g p.2 * Coulomb.coulombKernel (p.1 - p.2) + +theorem pair_nonnegative (f : CoulombPacket) : 0 ≤ pair f f := + Coulomb.coulomb_form_nonneg_of_pair f.integrable f.continuous.measurable (joint_integrable f f) + +theorem pair_symmetric (f g : CoulombPacket) : pair f g = pair g f := by + unfold pair + rw [Measure.volume_eq_prod, integral_prod _ (joint_integrable f g), + integral_prod _ (joint_integrable g f), integral_integral_swap (joint_integrable f g)] + apply integral_congr_ae + filter_upwards [] with y + apply integral_congr_ae + filter_upwards [] with x + simp only [Coulomb.coulombKernel, norm_sub_rev x y] + ring + +theorem pair_add_left (f g h : CoulombPacket) : pair (add f g) h = pair f h + pair g h := by + unfold pair + change (∫ p : Position × Position, (f p.1 + g p.1) * h p.2 * Coulomb.coulombKernel (p.1 - p.2)) = _ + simp_rw [add_mul] + exact integral_add (joint_integrable f h) (joint_integrable g h) + +theorem pair_smul_left (t : ℝ) (f g : CoulombPacket) : pair (smul t f) g = t * pair f g := by + unfold pair + change (∫ p : Position × Position, (t * f p.1) * g p.2 * Coulomb.coulombKernel (p.1 - p.2)) = _ + simp_rw [mul_assoc] + exact integral_const_mul t _ + +theorem pair_add_right (f g h : CoulombPacket) : pair f (add g h) = pair f g + pair f h := by + rw [pair_symmetric, pair_add_left, pair_symmetric g f, pair_symmetric h f] + +theorem pair_smul_right (t : ℝ) (f g : CoulombPacket) : pair f (smul t g) = t * pair f g := by + rw [pair_symmetric, pair_smul_left, pair_symmetric g f] + +theorem pair_cauchy (f g : CoulombPacket) : pair f g ^ 2 ≤ pair f f * pair g g := by + have h (t : ℝ) : 0 ≤ pair g g * (t * t) + (2 * pair f g) * t + pair f f := by + have hn := pair_nonnegative (add f (smul t g)) + rw [pair_add_left, pair_add_right, pair_add_right, pair_smul_left, + pair_smul_right, pair_smul_right, pair_symmetric g f, pair_smul_left] at hn + nlinarith only [hn] + have hd := discrim_le_zero h + dsimp only [discrim] at hd + nlinarith only [hd] + +end CoulombPacket +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..672c0b6697e76ed026cad3be86c2a3f89efc3188 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairEvaluation.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombEvaluationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PlanarForcingProgram + +namespace OAI + +/-! Actual direct Coulomb coefficients at arbitrary rational planar sites. +The distance is computed by the certified dyadic square-root program. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombPairEvaluation + +def lipschitzGuard (rho : ℕ) : ℕ := + ⌈localizedCoulombLipschitzConstant (GaussianFrequency.frequency rho)⌉₊+1 + +theorem lipschitzGuard_positive (rho : ℕ) : 0 < lipschitzGuard rho := by + unfold lipschitzGuard + omega + +theorem lipschitzGuard_bound (rho : ℕ) : + localizedCoulombLipschitzConstant (GaussianFrequency.frequency rho) ≤ (lipschitzGuard rho:ℝ) := by + have h := Nat.le_ceil (localizedCoulombLipschitzConstant (GaussianFrequency.frequency rho)) + unfold lipschitzGuard + push_cast + linarith + +def precision (P : ℕ) : ℕ := 2*(P+1) +def rootPrecision (rho P : ℕ) : ℕ := 4*lipschitzGuard rho*(P+1) +def squaredDistance (a b : ℚ×ℚ) : ℚ := (a.1-b.1)^2+(a.2-b.2)^2 +def distance (rho P : ℕ) (a b : ℚ×ℚ) : ℚ := + RationalSquareRoot.value (rootPrecision rho P,squaredDistance a b) +def approximate (rho P : ℕ) (a b : ℚ×ℚ) : ℚ := + CoulombEvaluation.approximate rho (precision P) (distance rho P a b) + +theorem squaredDistance_cast (a b : ℚ×ℚ) : + (squaredDistance a b:ℝ) = + ‖PlanarForcingProgram.position a-PlanarForcingProgram.position b‖^2 := by + rw [EuclideanSpace.norm_sq_eq] + simp only [squaredDistance,PlanarForcingProgram.position,PiLp.sub_apply, + Fin.sum_univ_two,Matrix.cons_val_zero,Matrix.cons_val_one,Matrix.cons_val_fin_one, + Real.norm_eq_abs,sq_abs,Rat.cast_add,Rat.cast_pow,Rat.cast_sub] + +private theorem nat_pow_bound (n : ℕ) : n+1 ≤ 2^n := by + induction n with + | zero => norm_num + | succ n ih => rw [pow_succ]; omega + +theorem distance_error (rho P : ℕ) (a b : ℚ×ℚ) : + |(distance rho P a b:ℝ)-‖PlanarForcingProgram.position a-PlanarForcingProgram.position b‖| ≤ + ((rootPrecision rho P:ℝ)+1)⁻¹ := by + have h := RationalSquareRoot.value_error (rootPrecision rho P) + (show (0:ℚ) ≤ squaredDistance a b from add_nonneg (sq_nonneg _) (sq_nonneg _)) + rw [squaredDistance_cast,Real.sqrt_sq (norm_nonneg _)] at h + have hb : (2:ℝ)⁻¹^(rootPrecision rho P) ≤ ((rootPrecision rho P:ℝ)+1)⁻¹ := by + rw [inv_pow] + apply inv_anti₀ (by positivity) + exact_mod_cast nat_pow_bound (rootPrecision rho P) + exact h.trans hb + +theorem approximation_error (rho P : ℕ) (hrho : 0 < rho) (a b : ℚ×ℚ) : + |(approximate rho P a b:ℝ)-localizedCoulombCoeff (GaussianFrequency.frequency rho) + (PlanarForcingProgram.position a) (PlanarForcingProgram.position b)| ≤ ((P:ℝ)+1)⁻¹ := by + have hf : 0 < GaussianFrequency.frequency rho := by + apply Real.sqrt_pos.mpr + change 0 < 4*Real.pi*(rho:ℝ) + positivity + have he := CoulombEvaluation.approximation_error rho (precision P) hrho (distance rho P a b) + have hd := localizedCoulombProfile_abs_sub hf (distance rho P a b) + ‖PlanarForcingProgram.position a-PlanarForcingProgram.position b‖ + have hp : (0:ℝ) < (P:ℝ)+1 := by positivity + have hC : (1:ℝ) ≤ lipschitzGuard rho := by exact_mod_cast lipschitzGuard_positive rho + have hCp : (0:ℝ) < lipschitzGuard rho := by linarith + have hmove : localizedCoulombLipschitzConstant (GaussianFrequency.frequency rho) * + |(distance rho P a b:ℝ)-‖PlanarForcingProgram.position a-PlanarForcingProgram.position b‖| ≤ + (4*((P:ℝ)+1))⁻¹ := by + apply (mul_le_mul (lipschitzGuard_bound rho) (distance_error rho P a b) + (abs_nonneg _) hCp.le).trans + simp only [rootPrecision,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_add,Nat.cast_one] + apply (mul_inv_le_iff₀ (by positivity)).mpr + rw [show (4*((P:ℝ)+1))⁻¹*(4*(lipschitzGuard rho:ℝ)*((P:ℝ)+1)+1) = + (4*(lipschitzGuard rho:ℝ)*((P:ℝ)+1)+1)/(4*((P:ℝ)+1)) by ring] + exact (le_div_iff₀ (by positivity)).mpr (by nlinarith) + have heBound : ((precision P:ℝ)+1)⁻¹ ≤ (2*((P:ℝ)+1))⁻¹ := by + apply inv_anti₀ (by positivity) + simp only [precision,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_add,Nat.cast_one] + linarith + rw [localizedCoulombCoeff_distance] + have htriangle := abs_sub_le (approximate rho P a b:ℝ) + (localizedCoulombProfile (GaussianFrequency.frequency rho) (distance rho P a b)) + (localizedCoulombProfile (GaussianFrequency.frequency rho) + ‖PlanarForcingProgram.position a-PlanarForcingProgram.position b‖) + apply htriangle.trans + have hsum := add_le_add (he.trans heBound) (hd.trans hmove) + apply hsum.trans + rw [mul_inv,mul_inv] + norm_num + nlinarith [inv_pos.mpr hp] + +end ContinuumCoulomb.CoulombPairEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairSum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..02c3ffead02bc4ef5d8d9349a31c2d8c46c521a4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPairSum.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CountertermProgram + +namespace OAI + +/-! The actual scalar direct-interaction offset is one half of the +ordered off-diagonal Coulomb sum. The finite list evaluator excludes only +identical coordinates; injectivity identifies that test with the diagonal. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.CoulombPairSum + +abbrev Point := ℚ×ℚ +abbrev Input := ℕ×List Point + +def offsite (rho p : ℕ) (a b : Point) : ℚ := + if CoulombPairEvaluation.squaredDistance a b = 0 then 0 + else CoulombPairEvaluation.approximate rho p a b + +def row (rho p : ℕ) (a : Point) (sites : List Point) : ℚ := + (sites.map (offsite rho p a)).sum + +def total (rho p : ℕ) (sites : List Point) : ℚ := + (sites.map (fun a => row rho p a sites)).sum/2 + +def exactTotal (freq : ℝ) {m : ℕ} (u : Fin m → Point) : ℝ := + (1/2:ℝ)*∑ i, ∑ j, if i=j then 0 else + localizedCoulombCoeff freq (PlanarForcingProgram.position (u i)) + (PlanarForcingProgram.position (u j)) + +theorem row_error (rho p : ℕ) (hrho : 0 < rho) {m : ℕ} + (u : Fin m → Point) (hu : Function.Injective u) (i : Fin m) : + |(row rho p (u i) (List.ofFn u):ℝ)- + ∑ j, if i=j then 0 else localizedCoulombCoeff (GaussianFrequency.frequency rho) + (PlanarForcingProgram.position (u i)) (PlanarForcingProgram.position (u j))| ≤ + (m:ℝ)/(p+1:ℝ) := by + simp only [row,List.map_ofFn,List.sum_ofFn,Function.comp_apply,Rat.cast_sum] + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _j : Fin m, 1/(p+1:ℝ) := by + apply Finset.sum_le_sum + intro j _ + by_cases h : i=j + · subst j + simp only [offsite,CountertermEvaluation.squaredDistance_eq_zero,ite_true, + Rat.cast_zero,sub_self,abs_zero] + positivity + · have hij : u i ≠ u j := fun he => h (hu he) + simpa only [offsite,CountertermEvaluation.squaredDistance_eq_zero, + ite_eq_right hij,ite_eq_right h,one_div] using + CoulombPairEvaluation.approximation_error rho p hrho (u i) (u j) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +theorem total_error (rho p : ℕ) (hrho : 0 < rho) {m : ℕ} + (u : Fin m → Point) (hu : Function.Injective u) : + |(total rho p (List.ofFn u):ℝ)-exactTotal (GaussianFrequency.frequency rho) u| ≤ + (m:ℝ)^2/(2*(p+1:ℝ)) := by + have he : (total rho p (List.ofFn u):ℝ)-exactTotal (GaussianFrequency.frequency rho) u = + (∑ i, ((row rho p (u i) (List.ofFn u):ℝ)- + ∑ j, if i=j then 0 else localizedCoulombCoeff (GaussianFrequency.frequency rho) + (PlanarForcingProgram.position (u i)) (PlanarForcingProgram.position (u j))))/2 := by + simp only [total,exactTotal,List.map_ofFn,List.sum_ofFn,Function.comp_apply, + Rat.cast_div,Rat.cast_sum,Rat.cast_ofNat,Finset.sum_sub_distrib] + ring + rw [he,abs_div,abs_of_pos (by norm_num : (0:ℝ) < 2)] + have hs := (Finset.abs_sum_le_sum_abs _ _).trans + (Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => row_error rho p hrho u hu i)) + apply (div_le_div_of_nonneg_right hs (by norm_num : (0:ℝ) ≤ 2)).trans_eq + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + have hp : (p:ℝ)+1 ≠ 0 := by positivity + field_simp [hp] + +def precision (m P : ℕ) : ℕ := (m+1)^2*(P+1) +def value (rho : ℕ) (x : Input) : ℚ := total rho (precision x.2.length x.1) x.2 + +theorem precision_budget (m P : ℕ) : + (m:ℝ)^2/(2*(precision m P+1:ℝ)) ≤ 1/(P+1:ℝ) := by + have hp : 0 < (P:ℝ)+1 := by positivity + have hd : 0 < 2*((precision m P:ℝ)+1) := by positivity + apply (div_le_div_iff₀ hd hp).mpr + simp only [precision,Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_pow] + have hs : (m:ℝ)^2 ≤ 2*((m:ℝ)+1)^2 := by + nlinarith [show (0:ℝ) ≤ (m:ℝ) from Nat.cast_nonneg m] + nlinarith only [mul_le_mul_of_nonneg_right hs hp.le] + +theorem error (rho P : ℕ) (hrho : 0 < rho) {m : ℕ} + (u : Fin m → Point) (hu : Function.Injective u) : + |(value rho (P,List.ofFn u):ℝ)-exactTotal (GaussianFrequency.frequency rho) u| ≤ + 1/(P+1:ℝ) := by + have h := total_error rho (precision m P) hrho u hu + simpa only [value,List.length_ofFn] using h.trans (precision_budget m P) + +end ContinuumCoulomb.CoulombPairSum + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPoisson.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPoisson.lean new file mode 100644 index 0000000000000000000000000000000000000000..f472c29b8ca16964c524f2075f5b8461e3788e8c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombPoisson.lean @@ -0,0 +1,142 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import OAI.Analysis.CoulombRadii.Packets.CoulombKernel + +namespace OAI + +/-! +# The Coulomb fundamental solution with finite smoothness + +The manufactured planar well in the unit-charge paper has bounded continuous +derivatives through a finite order. Its density synthesis therefore needs +the fundamental-solution identity for compactly supported C² functions. +This extends the smooth-test identity by the same regularized +kernel argument, using only two integrations by parts. +-/ + +noncomputable section +open MeasureTheory Filter +open scoped BigOperators Topology ContDiff +namespace ContinuumCoulomb +open NeutralAtom (dirPartial coordinateLaplacian axis) + +theorem integral_mul_laplacian_C2 (f phi : Position → ℝ) + (hf : ContDiff ℝ 2 f) (hphi : ContDiff ℝ 2 phi) (hc : HasCompactSupport phi) : + (∫ x, f x * coordinateLaplacian phi x) = ∫ x, coordinateLaplacian f x * phi x := by + have hp (g : Position → ℝ) (hg : ContDiff ℝ 2 g) (v : Position) : + ContDiff ℝ 1 (dirPartial g v) := + (hg.fderiv_right (show (1 : WithTop ℕ∞) + 1 ≤ 2 by norm_num)).clm_apply contDiff_const + have hpp (g : Position → ℝ) (hg : ContDiff ℝ 2 g) (v : Position) : + Continuous (dirPartial (dirPartial g v) v) := + (((hp g hg v).fderiv_right (show (0 : WithTop ℕ∞) + 1 ≤ 1 by norm_num)).clm_apply + contDiff_const).continuous + have hpc (v : Position) : HasCompactSupport (dirPartial phi v) := + NeutralAtom.hasCompactSupport_partial hc v + have hppc (v : Position) : HasCompactSupport (dirPartial (dirPartial phi v) v) := + NeutralAtom.hasCompactSupport_partial (hpc v) v + have hleft (v : Position) : Integrable (fun x => f x * dirPartial (dirPartial phi v) v x) := + (hf.continuous.mul (hpp phi hphi v)).integrable_of_hasCompactSupport (hppc v).mul_left + have hright (v : Position) : Integrable (fun x => dirPartial (dirPartial f v) v x * phi x) := + ((hpp f hf v).mul hphi.continuous).integrable_of_hasCompactSupport hc.mul_left + have hcross (v : Position) : Integrable (fun x => dirPartial f v x * dirPartial phi v x) := + ((hp f hf v).continuous.mul (hp phi hphi v).continuous).integrable_of_hasCompactSupport + (hpc v).mul_left + have hfg (v : Position) : Integrable (fun x => f x * dirPartial phi v x) := + (hf.continuous.mul (hp phi hphi v).continuous).integrable_of_hasCompactSupport + (hpc v).mul_left + have hfpg (v : Position) : Integrable (fun x => dirPartial f v x * phi x) := + ((hp f hf v).continuous.mul hphi.continuous).integrable_of_hasCompactSupport hc.mul_left + have hby (v : Position) : + (∫ x, f x * dirPartial (dirPartial phi v) v x) = + ∫ x, dirPartial (dirPartial f v) v x * phi x := by + calc + _ = -(∫ x, dirPartial f v x * dirPartial phi v x) := + integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (hcross v) (hleft v) (hfg v) + (fun x _ => hf.differentiable (by norm_num) x) + (fun x _ => (hp phi hphi v).differentiable (by norm_num) x) + _ = _ := by + have h : (∫ x, dirPartial f v x * dirPartial phi v x) = + -(∫ x, dirPartial (dirPartial f v) v x * phi x) := + integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (hright v) (hcross v) (hfpg v) + (fun x _ => (hp f hf v).differentiable (by norm_num) x) + (fun x _ => hphi.differentiable (by norm_num) x) + rw [h, neg_neg] + have hphi_eq (x : Position) : coordinateLaplacian phi x = + ∑ a : Fin 3, dirPartial (dirPartial phi (axis a)) (axis a) x := + NeutralAtom.coordinateLaplacian_eq_partials hphi.contDiffAt + have hf_eq (x : Position) : coordinateLaplacian f x = + ∑ a : Fin 3, dirPartial (dirPartial f (axis a)) (axis a) x := + NeutralAtom.coordinateLaplacian_eq_partials hf.contDiffAt + simp_rw [hphi_eq, Finset.mul_sum] + rw [integral_finsetSum _ (fun a _ => hleft (axis a))] + simp_rw [hby] + rw [← integral_finsetSum _ (fun a _ => hright (axis a))] + simp_rw [hf_eq, Finset.sum_mul] + +theorem coulomb_laplacian_C2 (phi : Position → ℝ) + (hphi : ContDiff ℝ 2 phi) (hc : HasCompactSupport phi) : + (∫ x, Coulomb.coulombKernel x * coordinateLaplacian phi x) = + -(4 * Real.pi * phi 0) := by + let epsilon : ℕ → ℝ := fun n => ((n : ℝ) + 1)⁻¹ + have hepsilon (n : ℕ) : 0 < epsilon n := by dsimp [epsilon]; positivity + have hlim : Tendsto epsilon atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp + (tendsto_atTop_add_const_right _ 1 tendsto_natCast_atTop_atTop) + have hl := NeutralAtom.regularizedKernel_integral_tendsto hepsilon hlim + (NeutralAtom.continuous_coordinateLaplacian hphi) + (NeutralAtom.hasCompactSupport_coordinateLaplacian hc) + have hr := (NeutralAtom.regularizedCharge_tendsto_dirac hepsilon hlim hphi.continuous hc).neg + have heq : (fun n => ∫ x, NeutralAtom.regularizedKernel (epsilon n) x * + coordinateLaplacian phi x) = + (fun n => -(∫ x, NeutralAtom.regularizedCharge (epsilon n) x * phi x)) := by + funext n + rw [integral_mul_laplacian_C2 _ _ + ((NeutralAtom.contDiff_regularizedKernel (hepsilon n).ne').of_le (by simp)) hphi hc] + simp_rw [NeutralAtom.laplacian_regularizedKernel (hepsilon n).ne', neg_mul, integral_neg] + rw [heq] at hl + exact tendsto_nhds_unique hl hr + +theorem coulomb_translated_laplacian_C2 (phi : Position → ℝ) + (hphi : ContDiff ℝ 2 phi) (hc : HasCompactSupport phi) (a : Position) : + (∫ x, Coulomb.coulombKernel (x - a) * coordinateLaplacian phi x) = + -(4 * Real.pi * phi a) := by + have ht : ContDiff ℝ 2 (fun z => phi (z + a)) := hphi.comp (contDiff_id.add contDiff_const) + have htc : HasCompactSupport (fun z => phi (z + a)) := + hc.comp_homeomorph (Homeomorph.addRight a) + have h := coulomb_laplacian_C2 _ ht htc + simp only [NeutralAtom.coordinateLaplacian_translate, zero_add] at h + rw [← integral_add_right_eq_self + (fun x => Coulomb.coulombKernel (x - a) * coordinateLaplacian phi x) a] + simpa only [add_sub_cancel_right] using h + +def manufacturedCharge (V : Position → ℝ) (x : Position) : ℝ := + coordinateLaplacian V x / (4 * Real.pi) + +theorem manufacturedCharge_integral_zero (V : Position → ℝ) (hV : ContDiff ℝ 2 V) + (hc : HasCompactSupport V) : (∫ x, manufacturedCharge V x) = 0 := by + have h := integral_mul_laplacian_C2 (fun _ => (1 : ℝ)) V contDiff_const hV hc + have hconst (x : Position) : coordinateLaplacian (fun _ => (1 : ℝ)) x = 0 := by + simp [coordinateLaplacian] + simp only [one_mul, hconst, zero_mul, integral_zero] at h + simp only [manufacturedCharge, integral_div, h, zero_div] + +/-- Exact Green identity, with the sign for an attractive positive density. -/ +theorem manufacturedCharge_potential (V : Position → ℝ) (hV : ContDiff ℝ 2 V) + (hc : HasCompactSupport V) (y : Position) : + -(∫ x, Coulomb.coulombKernel (y - x) * manufacturedCharge V x) = V y := by + have h := coulomb_translated_laplacian_C2 V hV hc y + have heq : (fun x => Coulomb.coulombKernel (y - x) * manufacturedCharge V x) = + (fun x => (Coulomb.coulombKernel (x - y) * coordinateLaplacian V x) / (4 * Real.pi)) := by + funext x + dsimp [manufacturedCharge, Coulomb.coulombKernel] + rw [norm_sub_rev] + ring + rw [heq, integral_div, h] + field_simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ec467f94bfecee415cd50cf2a96b5601972e2f9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadrature.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombSampleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCubeModulus + +namespace OAI + +/-! Actual six-coordinate cubature of the finite Coulomb integral. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.RawCoulombSample +open UniformQuadrature + +def quadratureInput (R P b : ℕ) (ε : ℚ) (s : CappedKernelProgram.Triple) (N : ℕ) : + RationalSixQuadrature.Input Settings := + (N, (((R, P), ((b, ε), s)), (-(R : ℚ), 2 * (R : ℚ) / (N : ℚ)))) + +def sampled (rho R P b : ℕ) (ε : ℚ) (s : CappedKernelProgram.Triple) + (a h : ℚ) (w : Fin 6 → ℕ) : ℝ := + value rho R P b ε s + (RationalQuadratureProgram.node a h (w 0), + RationalQuadratureProgram.node a h (w 1), + RationalQuadratureProgram.node a h (w 2)) + (RationalQuadratureProgram.node a h (w 3), + RationalQuadratureProgram.node a h (w 4), + RationalQuadratureProgram.node a h (w 5)) + +theorem quadrature_cast (rho R P b : ℕ) (ε : ℚ) (s : CappedKernelProgram.Triple) (N : ℕ) : + (RationalSixQuadrature.value (sixEvaluator rho) (quadratureInput R P b ε s N) : ℝ) = + cubeSample (2 * (R : ℝ) / (N : ℝ)) N 6 + (sampled rho R P b ε s (-(R : ℚ)) (2 * (R : ℚ) / (N : ℚ))) := by + rw [RationalSixQuadrature.value_cast] + simp only [quadratureInput, sixEvaluator, evaluate, sampled, cubeSample, rectangleSum, + Rat.cast_div, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast, + Fin.cons_zero] + rfl + +theorem position_sampled (a h : ℚ) (w : Fin 6 → ℕ) : + (CappedKernelProgram.position + (RationalQuadratureProgram.node a h (w 0), + RationalQuadratureProgram.node a h (w 1), + RationalQuadratureProgram.node a h (w 2)), + CappedKernelProgram.position + (RationalQuadratureProgram.node a h (w 3), + RationalQuadratureProgram.node a h (w 4), + RationalQuadratureProgram.node a h (w 5))) = + twoParticleCoordinates (fun i => node (a : ℝ) (h : ℝ) (w i)) := by + apply Prod.ext + · ext i + rw [twoParticleCoordinates_fst] + fin_cases i <;> simp [CappedKernelProgram.position, RationalQuadratureProgram.node_cast] + · ext i + rw [twoParticleCoordinates_snd] + fin_cases i <;> simp [CappedKernelProgram.position, RationalQuadratureProgram.node_cast] + +theorem quadrature_error (rho R P b N : ℕ) {ε : ℚ} (hε : 0 < ε) + (hN : 0 < N) (s : CappedKernelProgram.Triple) : + |(RationalSixQuadrature.value (sixEvaluator rho) (quadratureInput R P b ε s N) : ℝ) - + cubeIntegral (-(R : ℝ)) (R : ℝ) 6 + (rawCoulombSix (GaussianFrequency.frequency rho) (ε : ℝ) (CappedKernelProgram.position s))| ≤ + (2 * (R : ℝ)) ^ 6 * + (6 * ((64 + 2 * GaussianFrequency.frequency rho * R) * (ε : ℝ)⁻¹ + (ε : ℝ)⁻¹ ^ 2) * + (2 * (R : ℝ) / N) + + (8 * (ε : ℝ)⁻¹ * ((P : ℝ) + 1)⁻¹ + (ε : ℝ)⁻¹ ^ 2 * (2 : ℝ)⁻¹ ^ b)) := by + let h : ℚ := 2 * (R : ℚ) / (N : ℚ) + have hNr : (0 : ℝ) < N := by exact_mod_cast hN + have hfreq : 0 ≤ GaussianFrequency.frequency rho := Real.sqrt_nonneg _ + have hh : (0 : ℝ) ≤ h := by dsimp only [h]; push_cast; positivity + have he : node (-(R : ℝ)) (h : ℝ) N = R := by + dsimp only [node, h] + push_cast + field_simp [hNr.ne'] + ring + have hεr : (0 : ℝ) < ε := by exact_mod_cast hε + have hmod := rawCoulombSix_modulus hfreq hεr + (Nat.cast_nonneg R) (CappedKernelProgram.position s) + have hsamp : ∀ w : Fin 6 → ℕ, (∀ i, w i < N) → + |sampled rho R P b ε s (-(R : ℚ)) h w - + rawCoulombSix (GaussianFrequency.frequency rho) (ε : ℝ) (CappedKernelProgram.position s) + (fun i => node (-(R : ℝ)) (h : ℝ) (w i))| ≤ + 8 * (ε : ℝ)⁻¹ * ((P : ℝ) + 1)⁻¹ + (ε : ℝ)⁻¹ ^ 2 * (2 : ℝ)⁻¹ ^ b := by + intro w hw + have hbnd (i : Fin 6) : |(RationalQuadratureProgram.node (-(R : ℚ)) h (w i) : ℝ)| ≤ R := by + rw [RationalQuadratureProgram.node_cast] + have hi := node_mem (a := -(R : ℝ)) hh (hw i).le + rw [he] at hi + simpa only [Rat.cast_neg, Rat.cast_natCast] using abs_le.mpr hi + have ht := value_error rho R P b hε s + (RationalQuadratureProgram.node (-(R : ℚ)) h (w 0), + RationalQuadratureProgram.node (-(R : ℚ)) h (w 1), + RationalQuadratureProgram.node (-(R : ℚ)) h (w 2)) + (RationalQuadratureProgram.node (-(R : ℚ)) h (w 3), + RationalQuadratureProgram.node (-(R : ℚ)) h (w 4), + RationalQuadratureProgram.node (-(R : ℚ)) h (w 5)) + ⟨hbnd 0, hbnd 1, hbnd 2⟩ ⟨hbnd 3, hbnd 4, hbnd 5⟩ + rw [position_sampled] at ht + simpa only [sampled, rawCoulombSix, Rat.cast_neg, Rat.cast_natCast] using ht + have ht := cube_quadrature_error 6 + (L := (64 + 2 * GaussianFrequency.frequency rho * R) * (ε : ℝ)⁻¹ + (ε : ℝ)⁻¹ ^ 2) + hh (by positivity) (by positivity) (by simpa only [he] using hmod) hsamp + rw [he] at ht + rw [quadrature_cast] + have hlen : (N : ℝ) * (h : ℝ) = 2 * R := by + dsimp only [h] + push_cast + field_simp [hNr.ne'] + rw [hlen] at ht + simpa only [Nat.cast_ofNat, h, Rat.cast_div, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] using ht + +end ContinuumCoulomb.RawCoulombSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadratureBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadratureBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..05683e1a81f25287f729c10f809c7c14f87cdeac --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombQuadratureBudget.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombQuadrature + +namespace OAI + +/-! Polynomial mesh and precision budgets for the six-coordinate +Coulomb quadrature. All varying parameters below are unary naturals. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombQuadratureSchedule + +def volume (R : ℕ) : ℕ := (2 * R) ^ 6 +def lipschitz (F R D : ℕ) : ℕ := (64 + 2 * F * R) * D + D ^ 2 +def mesh (F R D S : ℕ) : ℕ := 48 * R * lipschitz F R D * volume R * S +def accuracy (R D S : ℕ) : ℕ := 32 * D * volume R * S +def kernelPrecision (R D S : ℕ) : ℕ := 4 * D ^ 2 * volume R * S + +theorem dyadic_le_inverse (b : ℕ) : (2 : ℝ)⁻¹ ^ b ≤ ((b : ℝ) + 1)⁻¹ := by + have hb : (b : ℝ) + 1 ≤ (2 : ℝ) ^ b := by + exact_mod_cast Nat.succ_le_of_lt b.lt_two_pow_self + rw [inv_pow] + exact inv_anti₀ (by positivity) hb + +theorem scalar_budget {R D L S V N Q : ℝ} {b : ℕ} + (hR : 0 < R) (hD : 0 < D) (hL : 0 < L) (hS : 0 < S) + (hV : V = (2 * R) ^ 6) (hN : N = 48 * R * L * V * S) + (hQ : Q = 32 * D * V * S) (hb : (b : ℝ) = 4 * D ^ 2 * V * S) : + V * (6 * L * (2 * R / N) + 8 * D * (Q + 1)⁻¹ + D ^ 2 * (2 : ℝ)⁻¹ ^ b) ≤ + 3 * (4 * S)⁻¹ := by + have hV0 : 0 < V := by rw [hV]; positivity + have hN0 : 0 < N := by rw [hN]; positivity + have hQ0 : 0 < Q := by rw [hQ]; positivity + have hb0 : (0 : ℝ) < b := by rw [hb]; positivity + have hmesh : V * (6 * L * (2 * R / N)) = (4 * S)⁻¹ := by + rw [hN] + field_simp [hR.ne', hL.ne', hV0.ne', hS.ne'] + ring + have hsample : V * (8 * D * (Q + 1)⁻¹) ≤ (4 * S)⁻¹ := by + calc + _ ≤ V * (8 * D * Q⁻¹) := by + gcongr + linarith + _ = _ := by + rw [hQ] + field_simp [hD.ne', hV0.ne', hS.ne'] + ring + have hkernel : V * (D ^ 2 * (2 : ℝ)⁻¹ ^ b) ≤ (4 * S)⁻¹ := by + calc + _ ≤ V * (D ^ 2 * ((b : ℝ) + 1)⁻¹) := by + gcongr + exact dyadic_le_inverse b + _ ≤ V * (D ^ 2 * (b : ℝ)⁻¹) := by + gcongr + linarith + _ = _ := by + rw [hb] + field_simp [hD.ne', hV0.ne', hS.ne'] + nlinarith + +end ContinuumCoulomb.CoulombQuadratureSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombRawEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombRawEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..235f97866b168f647a0a32a0bfec047387be1840 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombRawEvaluation.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombEvaluationParameters + +namespace OAI + +/-! The fixed polynomial schedule approximates the actual unnormalized +Coulomb box integral uniformly in every rational separation. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombEvaluation +open UniformQuadrature + +theorem position_shift (d : ℚ) : + CappedKernelProgram.position (d, 0, 0) = planarCenter ((d : ℝ) • planarAxis 0) := by + apply positionSplitCoordinates.injective + rw [RawDensitySample.position_split] + simp only [planarCenter, ContinuousLinearEquiv.apply_symm_apply] + apply Prod.ext + · ext i + fin_cases i <;> simp [PlanarForcingProgram.position, planarAxis] + · simp + +theorem denominator_inverse (rho P : ℕ) : + (1 / (denominator rho P : ℚ) : ℝ)⁻¹ = (denominator rho P : ℝ) := by + simp only [Rat.cast_natCast, one_div, inv_inv] + +theorem rational_box_quadrature_error (rho R Q b N D : ℕ) (hD : 0 < D) (hN : 0 < N) (d : ℚ) + (hf : 0 < GaussianFrequency.frequency rho) : + |(RationalSixQuadrature.value (RawCoulombSample.sixEvaluator rho) + (RawCoulombSample.quadratureInput R Q b (1 / (D : ℚ)) (d, 0, 0) N) : ℝ) - + localizedRawCoulombBox (GaussianFrequency.frequency rho) (1 / (D : ℝ)) R + ((d : ℝ) • planarAxis 0)| ≤ + (2 * (R : ℝ)) ^ 6 * + (6 * ((64 + 2 * GaussianFrequency.frequency rho * R) * D + (D : ℝ) ^ 2) * + (2 * (R : ℝ) / N) + + (8 * D * ((Q : ℝ) + 1)⁻¹ + (D : ℝ) ^ 2 * (2 : ℝ)⁻¹ ^ b)) := by + have hDr : (0 : ℝ) < D := by exact_mod_cast hD + have hε : (0 : ℚ) < 1 / (D : ℚ) := by positivity + have hεr : (0 : ℝ) < 1 / (D : ℝ) := by positivity + have hq := RawCoulombSample.quadrature_error rho R Q b N hε hN (d, 0, 0) + have hbox := localizedRawCoulombBox_cube hf hεr (Nat.cast_nonneg R) ((d : ℝ) • planarAxis 0) + rw [← position_shift] at hbox + simp only [Rat.cast_div, Rat.cast_one, Rat.cast_natCast] at hq + have hbox' : cubeIntegral (-(R : ℝ)) (R : ℝ) 6 + (rawCoulombSix (GaussianFrequency.frequency rho) (1 / (D : ℝ)) + (CappedKernelProgram.position (d, 0, 0))) = + localizedRawCoulombBox (GaussianFrequency.frequency rho) (1 / (D : ℝ)) + (R : ℝ) ((d : ℝ) • planarAxis 0) := hbox.symm + rw [hbox'] at hq + simpa only [one_div, inv_inv] using hq + +theorem natural_quadrature_budget (F R D S : ℕ) {f : ℝ} + (hRnat : 0 < R) (hDnat : 0 < D) (hSnat : 0 < S) (hf : f ≤ F) : + (2 * (R : ℝ)) ^ 6 * + (6 * ((64 + 2 * f * R) * D + (D : ℝ) ^ 2) * + (2 * (R : ℝ) / CoulombQuadratureSchedule.mesh F R D S) + + (8 * D * ((CoulombQuadratureSchedule.accuracy R D S : ℝ) + 1)⁻¹ + + (D : ℝ) ^ 2 * (2 : ℝ)⁻¹ ^ CoulombQuadratureSchedule.kernelPrecision R D S)) ≤ + 3 * (4 * (S : ℝ))⁻¹ := by + let L := CoulombQuadratureSchedule.lipschitz F R D + let V := CoulombQuadratureSchedule.volume R + have hR : (0 : ℝ) < R := by exact_mod_cast hRnat + have hD : (0 : ℝ) < D := by exact_mod_cast hDnat + have hS : (0 : ℝ) < S := by exact_mod_cast hSnat + have hV : (V : ℝ) = (2 * (R : ℝ)) ^ 6 := by + simp only [V, CoulombQuadratureSchedule.volume, Nat.cast_pow, Nat.cast_mul, Nat.cast_ofNat] + have hL : (L : ℝ) = (64 + 2 * (F : ℝ) * R) * D + (D : ℝ) ^ 2 := by + simp only [L, CoulombQuadratureSchedule.lipschitz, Nat.cast_add, Nat.cast_mul, + Nat.cast_ofNat, Nat.cast_pow] + have hL0 : (0 : ℝ) < L := by rw [hL]; positivity + have hN : (CoulombQuadratureSchedule.mesh F R D S : ℝ) = 48 * R * L * V * S := by + simp only [CoulombQuadratureSchedule.mesh, Nat.cast_mul, Nat.cast_ofNat, L, V] + have hQ : (CoulombQuadratureSchedule.accuracy R D S : ℝ) = 32 * D * V * S := by + simp only [CoulombQuadratureSchedule.accuracy, Nat.cast_mul, Nat.cast_ofNat, V] + have hb : (CoulombQuadratureSchedule.kernelPrecision R D S : ℝ) = 4 * (D : ℝ) ^ 2 * V * S := by + simp only [CoulombQuadratureSchedule.kernelPrecision, + Nat.cast_mul, Nat.cast_ofNat, Nat.cast_pow, V] + have hLip : (64 + 2 * f * R) * D + (D : ℝ) ^ 2 ≤ L := by + rw [hL] + gcongr + have hupper := CoulombQuadratureSchedule.scalar_budget hR hD hL0 hS hV hN hQ hb + apply le_trans _ hupper + rw [hV] + simp only [add_assoc] + gcongr + +theorem raw_approximation_error (rho P : ℕ) (hrho : 0 < rho) (d : ℚ) : + |(rawApproximate rho P d : ℝ) - + localizedRawCoulombBox (GaussianFrequency.frequency rho) + (1 / (denominator rho P : ℚ) : ℝ) (radius rho P : ℝ) ((d : ℝ) • planarAxis 0)| ≤ + 3 * (4 * (rawPrecision rho P : ℝ))⁻¹ := by + have hf : 0 < GaussianFrequency.frequency rho := Real.sqrt_pos.mpr (by + change 0 < 4 * Real.pi * (rho : ℝ) + positivity) + have hq := rational_box_quadrature_error rho (radius rho P) (samplePrecision rho P) + (kernelPrecision rho P) (mesh rho P) (denominator rho P) (denominator_positive rho P) + (mesh_positive rho P) d hf + have hb := natural_quadrature_budget (frequencyBound rho) (radius rho P) + (denominator rho P) (rawPrecision rho P) (radius_positive rho P) + (denominator_positive rho P) (rawPrecision_positive rho P) (frequencyBound_le rho) + have hc := hq.trans hb + simpa only [rawApproximate, input, Rat.cast_natCast] using hc + +end ContinuumCoulomb.CoulombEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombSourceCubature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombSourceCubature.lean new file mode 100644 index 0000000000000000000000000000000000000000..dde5d12cef9696e324e574b83446321ca6385799 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombSourceCubature.lean @@ -0,0 +1,149 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactCoulombSmooth +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeIntegral +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombFarCell + +namespace OAI + +/-! A compact orbital source can be integrated before the nuclear cell rule. +On cells separated from its support, the inverse-fifth-power error survives +integration with only the source's L1 mass as a factor. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem compact_coulomb_integrable {q : Position → ℝ} (hq : Continuous q) + (hc : HasCompactSupport q) (y : Position) : + Integrable (fun x => NeutralAtom.coulombKernel (y-x)*q x) := by + have hi := hc.convolutionExists_right (ContinuousLinearMap.mul ℝ ℝ) + NeutralAtom.locallyIntegrable_coulombKernel hq y + change Integrable (fun x => NeutralAtom.coulombKernel x*q (y-x)) at hi + simpa only [sub_sub_cancel] using hi.comp_sub_left y + +theorem compact_coulomb_eval_eq (q : Position → ℝ) (y : Position) : + NeutralAtom.potentialOf q y = ∫ x, q x*Coulomb.coulombKernel (x-y) := by + apply integral_congr_ae + filter_upwards [] with x + simp only [NeutralAtom.coulombKernel,Coulomb.coulombKernel,norm_sub_rev,mul_comm] + +theorem compact_coulomb_eval_integrable {q : Position → ℝ} (hq : Continuous q) + (hc : HasCompactSupport q) (y : Position) : + Integrable (fun x => q x*Coulomb.coulombKernel (x-y)) := by + convert compact_coulomb_integrable hq hc y using 1 + funext x + simp only [NeutralAtom.coulombKernel,Coulomb.coulombKernel,norm_sub_rev,mul_comm] + +theorem compact_coulomb_cell_gauss {q : Position → ℝ} (hq : Continuous q) + (hc : HasCompactSupport q) (b : Position) (h : ℝ) : + positionCellGauss b h (NeutralAtom.potentialOf q) = + ∫ x, q x*positionCellGauss b h (fun y => Coulomb.coulombKernel (x-y)) := by + simp only [positionCellGauss_eq_node_sum,compact_coulomb_eval_eq] + rw [← integral_finsetSum Finset.univ (fun v _ => compact_coulomb_eval_integrable hq hc _), + ← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with x + rw [← Finset.mul_sum] + ring + +theorem compact_coulomb_cell_integral {q : Position → ℝ} + (hq : ContDiff ℝ 4 q) (hc : HasCompactSupport q) (b : Position) + {h r : ℝ} (hh : 0 ≤ h) (hr : 0 < r) + (hsep : ∀ x, q x ≠ 0 → ∀ y ∈ positionCube b h, r ≤ ‖y-x‖) : + Integrable (fun x => q x * positionCellIntegral b h (fun y => Coulomb.coulombKernel (x-y))) ∧ + positionCellIntegral b h (NeutralAtom.potentialOf q) = + ∫ x, q x * positionCellIntegral b h (fun y => Coulomb.coulombKernel (x-y)) := by + have hvol : IntegrableOn (fun _ : Position => (1:ℝ)) (positionCube b h) := + integrableOn_const ((positionCube_isCompact b hh).measure_lt_top (μ := volume)).ne + have hqI : Integrable q := hq.continuous.integrable_of_hasCompactSupport hc + have hmajor := (hqI.norm.mul_prod hvol).const_mul r⁻¹ + have hi : Integrable (fun p : Position × Position => + q p.1 * NeutralAtom.coulombKernel (p.2-p.1)) + (volume.prod (volume.restrict (positionCube b h))) := by + apply hmajor.mono' (by + exact (hq.continuous.measurable.comp measurable_fst |>.mul + (NeutralAtom.measurable_coulombKernel.comp (measurable_snd.sub measurable_fst))).aestronglyMeasurable) + have hp : ∀ᵐ p : Position × Position ∂(volume.prod (volume.restrict (positionCube b h))), p.2 ∈ positionCube b h := + (Measure.ae_prod_iff_ae_ae ((positionCube_isClosed b h).measurableSet.preimage measurable_snd)).mpr + (Filter.Eventually.of_forall (fun _ => ae_restrict_mem (positionCube_isClosed b h).measurableSet)) + filter_upwards [hp] with p hp + change ‖q p.1 * NeutralAtom.coulombKernel (p.2-p.1)‖ ≤ r⁻¹*(‖q p.1‖*1) + by_cases hq0 : q p.1 = 0 + · simp [hq0] + have hd := hsep p.1 hq0 p.2 hp + rw [norm_mul,Real.norm_of_nonneg (NeutralAtom.coulombKernel_nonneg _),mul_one] + have hk : NeutralAtom.coulombKernel (p.2-p.1) ≤ r⁻¹ := + inv_anti₀ hr hd + exact (mul_le_mul_of_nonneg_left hk (norm_nonneg _)).trans_eq (mul_comm _ _) + have hinner (x : Position) : + (∫ y in positionCube b h, q x*NeutralAtom.coulombKernel (y-x)) = + q x*positionCellIntegral b h (fun y => Coulomb.coulombKernel (x-y)) := by + rw [integral_const_mul] + by_cases hqx : q x = 0 + · simp [hqx] + have hk : IntegrableOn (fun y => Coulomb.coulombKernel (x-y)) (positionCube b h) := by + apply (hvol.const_mul r⁻¹).mono' (by + exact (Coulomb.coulombKernel_measurable.comp (measurable_const.sub measurable_id)).aestronglyMeasurable) + filter_upwards [ae_restrict_mem (positionCube_isClosed b h).measurableSet] with y hy + change ‖Coulomb.coulombKernel (x-y)‖ ≤ r⁻¹*1 + rw [Real.norm_of_nonneg (Coulomb.coulombKernel_nonneg _),mul_one] + apply inv_anti₀ hr + simpa only [norm_sub_rev] using hsep x hqx y hy + rw [positionCellIntegral_eq_setIntegral b hh _ hk] + congr 1 + apply setIntegral_congr_fun (positionCube_isClosed b h).measurableSet + intro y _ + simp only [NeutralAtom.coulombKernel,Coulomb.coulombKernel,norm_sub_rev] + refine ⟨?_,?_⟩ + · exact hi.integral_prod_left.congr (Filter.Eventually.of_forall hinner) + · rw [positionCellIntegral_eq_setIntegral b hh _ + ((compact_coulomb_C4 hq hc).continuous.continuousOn.integrableOn_compact + (positionCube_isCompact b hh))] + change (∫ y in positionCube b h, ∫ x, NeutralAtom.coulombKernel (y-x)*q x) = _ + simp_rw [mul_comm (NeutralAtom.coulombKernel _) (q _)] + rw [← integral_integral_swap hi] + exact integral_congr_ae (Filter.Eventually.of_forall hinner) + +theorem compact_coulomb_cell_gauss_integrable {q : Position → ℝ} (hq : Continuous q) + (hc : HasCompactSupport q) (b : Position) (h : ℝ) : + Integrable (fun x => q x*positionCellGauss b h (fun y => Coulomb.coulombKernel (x-y))) := by + have hi := (integrable_finsetSum Finset.univ (fun (v : Fin 3 → Fin 2) _ => + compact_coulomb_eval_integrable hq hc + (cubePoint b (h/2) (gaussNode (v 0)) (gaussNode (v 1)) (gaussNode (v 2))))).const_mul (h^3/8) + convert hi using 1 + funext x + rw [positionCellGauss_eq_node_sum,← Finset.mul_sum] + ring + +theorem compact_coulomb_far_cell_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (q : Position → ℝ), ContDiff ℝ 4 q → HasCompactSupport q → + ∀ (b : Position) (h r : ℝ), 0 ≤ h → 0 < r → + (∀ x, q x ≠ 0 → ∀ y ∈ positionCube b h, r ≤ ‖y-x‖) → + |positionCellGauss b h (NeutralAtom.potentialOf q)- + positionCellIntegral b h (NeutralAtom.potentialOf q)| ≤ + (C*h^7/r^5)*(∫ x, ‖q x‖) := by + obtain ⟨C,hC,herror⟩ := coulomb_far_cell_error + refine ⟨C,hC,fun q hq hc b h r hh hr hsep => ?_⟩ + have hI := compact_coulomb_cell_integral hq hc b hh hr hsep + have hQ := compact_coulomb_cell_gauss_integrable hq.continuous hc b h + rw [compact_coulomb_cell_gauss hq.continuous hc,hI.2,← integral_sub hQ hI.1] + have hb := norm_integral_le_of_norm_le + (((hq.continuous.integrable_of_hasCompactSupport hc : Integrable q).norm).mul_const (C*h^7/r^5)) + (Filter.Eventually.of_forall (fun x => show + ‖q x*positionCellGauss b h (fun y => Coulomb.coulombKernel (x-y))- + q x*positionCellIntegral b h (fun y => Coulomb.coulombKernel (x-y))‖ ≤ + ‖q x‖*(C*h^7/r^5) from by + by_cases hx : q x = 0 + · simp only [hx,zero_mul,sub_self,norm_zero,le_refl] + rw [← mul_sub,norm_mul,Real.norm_eq_abs] + apply mul_le_mul_of_nonneg_left _ (abs_nonneg _) + apply herror x b h r hh hr + intro a ha d hd e he + simpa only [norm_sub_rev] using hsep x hx + (cubePoint b (h/2) a d e) (cubePoint_mem_positionCube b hh ha hd he))) + simpa only [Real.norm_eq_abs,integral_mul_const,mul_comm] using hb + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetLipschitz.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetLipschitz.lean new file mode 100644 index 0000000000000000000000000000000000000000..eef35f5c3a77edfac823892b819e76302948aaf1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetLipschitz.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombTargetRange + +namespace OAI + +/-! A quantitative modulus for the actual calibrated hopping residual. +The Coulomb gap keeps the square root away from zero, so ordinary dyadic +bisection needs no lower derivative bound. -/ + +noncomputable section +namespace ContinuumCoulomb + +private theorem sqrt_abs_sub_le_of_lower {c a b : ℝ} (hc : 0 < c) + (ha : c ≤ a) (hb : c ≤ b) : + |Real.sqrt a-Real.sqrt b| ≤ |a-b|/(2*Real.sqrt c) := by + have hc' : 0 < Real.sqrt c := Real.sqrt_pos.mpr hc + have ha' : 0 ≤ a := hc.le.trans ha + have hb' : 0 ≤ b := hc.le.trans hb + have hsa := Real.sqrt_le_sqrt ha + have hsb := Real.sqrt_le_sqrt hb + have he : (Real.sqrt a-Real.sqrt b)*(Real.sqrt a+Real.sqrt b) = a-b := by + nlinarith [Real.sq_sqrt ha', Real.sq_sqrt hb'] + have hab : |Real.sqrt a-Real.sqrt b| *(Real.sqrt a+Real.sqrt b) = |a-b| := by + rw [← abs_of_nonneg (add_nonneg (Real.sqrt_nonneg _) (Real.sqrt_nonneg _)), ← abs_mul, he] + apply (le_div_iff₀ (mul_pos (by norm_num : (0:ℝ)<2) hc')).mpr + nlinarith [mul_le_mul_of_nonneg_left (show 2*Real.sqrt c ≤ Real.sqrt a+Real.sqrt b by linarith) + (abs_nonneg (Real.sqrt a-Real.sqrt b))] + +theorem localizedCoulombProfile_abs_sub {freq : ℝ} (hfreq : 0 < freq) (d e : ℝ) : + |localizedCoulombProfile freq d-localizedCoulombProfile freq e| ≤ + localizedCoulombLipschitzConstant freq*|d-e| := by + have h := localizedCoulombProfileAt_norm_sub hfreq (d • planarAxis 0) (e • planarAxis 0) + rw [← sub_smul, norm_smul, planarAxis_zero_norm, mul_one] at h + simpa only [localizedCoulombProfile, Real.norm_eq_abs] using h + +def coulombTargetLipschitzConstant (freq τ K : ℝ) : ℝ := + τ*Real.sqrt K*localizedCoulombLipschitzConstant freq/(2*Real.sqrt (localizedGramConstant freq)) + +theorem coulombTargetLipschitzConstant_nonnegative (freq K : ℝ) {τ : ℝ} (hτ : 0 ≤ τ) : + 0 ≤ coulombTargetLipschitzConstant freq τ K := by + unfold coulombTargetLipschitzConstant + exact div_nonneg + (mul_nonneg (mul_nonneg hτ (Real.sqrt_nonneg _)) + (localizedCoulombLipschitzConstant_nonnegative freq)) + (mul_nonneg (by norm_num) (Real.sqrt_nonneg _)) + +theorem coulombHoppingTarget_abs_sub {freq τ K : ℝ} (hfreq : 0 < freq) + (hτ : 0 ≤ τ) (hK : 0 ≤ K) (d e : ℝ) + (hd : localizedGramConstant freq ≤ localizedCoulombProfile freq 0-localizedCoulombProfile freq d) + (he : localizedGramConstant freq ≤ localizedCoulombProfile freq 0-localizedCoulombProfile freq e) : + |coulombHoppingTarget freq τ K d-coulombHoppingTarget freq τ K e| ≤ + coulombTargetLipschitzConstant freq τ K*|d-e| := by + have hc := localizedGramConstant_positive hfreq + have hs := sqrt_abs_sub_le_of_lower hc hd he + rw [show (localizedCoulombProfile freq 0-localizedCoulombProfile freq d) - + (localizedCoulombProfile freq 0-localizedCoulombProfile freq e) = + localizedCoulombProfile freq e-localizedCoulombProfile freq d by ring, + abs_sub_comm (localizedCoulombProfile freq e) (localizedCoulombProfile freq d)] at hs + have hl := div_le_div_of_nonneg_right (localizedCoulombProfile_abs_sub hfreq d e) + (show 0 ≤ 2*Real.sqrt (localizedGramConstant freq) by positivity) + unfold coulombHoppingTarget + rw [Real.sqrt_mul hK, Real.sqrt_mul hK] + rw [show τ*(Real.sqrt K*Real.sqrt (localizedCoulombProfile freq 0-localizedCoulombProfile freq d)) - + τ*(Real.sqrt K*Real.sqrt (localizedCoulombProfile freq 0-localizedCoulombProfile freq e)) = + (τ*Real.sqrt K)*(Real.sqrt (localizedCoulombProfile freq 0-localizedCoulombProfile freq d) - + Real.sqrt (localizedCoulombProfile freq 0-localizedCoulombProfile freq e)) by ring, + abs_mul, abs_of_nonneg (mul_nonneg hτ (Real.sqrt_nonneg _))] + calc + _ ≤ (τ*Real.sqrt K) * + (localizedCoulombLipschitzConstant freq*|d-e|/(2*Real.sqrt (localizedGramConstant freq))) := + mul_le_mul_of_nonneg_left (hs.trans hl) (mul_nonneg hτ (Real.sqrt_nonneg _)) + _ = _ := by unfold coulombTargetLipschitzConstant; ring + +theorem calibratedResidual_abs_sub {freq τ K scale : ℝ} (hfreq : 0 < freq) + (hτ : 0 ≤ τ) (hK : 0 ≤ K) (hscale : 0 ≤ scale) (d e : ℝ) + (hd : localizedGramConstant freq ≤ localizedCoulombProfile freq 0-localizedCoulombProfile freq d) + (he : localizedGramConstant freq ≤ localizedCoulombProfile freq 0-localizedCoulombProfile freq e) : + |(scale*planarHopping d-coulombHoppingTarget freq τ K d) - + (scale*planarHopping e-coulombHoppingTarget freq τ K e)| ≤ + (scale*(planarHoppingLipschitzConstant : ℝ)+coulombTargetLipschitzConstant freq τ K)*|d-e| := by + have hh : |scale*(planarHopping d-planarHopping e)| ≤ + scale*(planarHoppingLipschitzConstant : ℝ)*|d-e| := by + rw [abs_mul, abs_of_nonneg hscale] + have h := planarHopping_norm_sub d e + simp only [Real.norm_eq_abs] at h + exact (mul_le_mul_of_nonneg_left h hscale).trans_eq (by ring) + have ht := coulombHoppingTarget_abs_sub hfreq hτ hK d e hd he + calc + _ = |scale*(planarHopping d-planarHopping e) - + (coulombHoppingTarget freq τ K d-coulombHoppingTarget freq τ K e)| := by congr 1; ring + _ ≤ |scale*(planarHopping d-planarHopping e)| + + |coulombHoppingTarget freq τ K d-coulombHoppingTarget freq τ K e| := abs_sub _ _ + _ ≤ _ := (add_le_add hh ht).trans_eq (by ring) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetRange.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4b07bdde5097e27910bf2deaa8f7389e4bcc801 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTargetRange.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds + +namespace OAI + +/-! Inverse-polynomial hopping scales give polynomial target ranges for +all polynomially bounded positive spin coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem localizedCoulombProfile_zero_positive {freq : ℝ} (hfreq : 0 < freq) : + 0 < localizedCoulombProfile freq 0 := by + unfold localizedCoulombProfile + rw [zero_smul, localizedCoulombProfileAt_eq] + exact localizedCoulombCoeff_positive hfreq 0 0 + +theorem exists_coulomb_target_polynomial_bounds {freq : ℝ} (hfreq : 0 < freq) (A B : ℕ) : + ∃ L : ℕ, 0 < L ∧ ∀ N : ℝ, 2 ≤ N → ∀ K : ℝ, + (N ^ A)⁻¹ ≤ K → K ≤ N ^ A → + (N ^ (B + A + L))⁻¹ ≤ (N ^ B)⁻¹ * Real.sqrt (K * localizedGramConstant freq) ∧ + (N ^ B)⁻¹ * Real.sqrt (K * localizedCoulombProfile freq 0) ≤ N ^ (B + A + L) := by + obtain ⟨L, hL, hconstants⟩ := exists_polynomial_constant_bounds + (Real.sqrt_pos.mpr (localizedGramConstant_positive hfreq)) + (Real.sqrt (localizedCoulombProfile freq 0)) + refine ⟨L, hL, fun N hN K hKlo hKhi => ?_⟩ + have hN₁ : 1 ≤ N := by linarith + have hNp : 0 < N := by linarith + have hK : 0 ≤ K := (inv_nonneg.mpr (pow_nonneg hNp.le A)).trans hKlo + obtain ⟨hrootlo, hroothi⟩ := sqrt_polynomial_bounds hN₁ hKlo hKhi + obtain ⟨hclo, hUhi⟩ := hconstants N hN + have hτ : 0 ≤ (N ^ B)⁻¹ := inv_nonneg.mpr (pow_nonneg hNp.le B) + constructor + · rw [Real.sqrt_mul hK] + calc + _ = (N ^ B)⁻¹ * ((N ^ A)⁻¹ * (N ^ L)⁻¹) := by + rw [pow_add, pow_add] + simp only [mul_inv_rev] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (mul_le_mul hrootlo hclo (inv_nonneg.mpr (pow_nonneg hNp.le L)) (Real.sqrt_nonneg K)) hτ + · have hτ₁ : (N ^ B)⁻¹ ≤ 1 := (inv_le_one₀ (pow_pos hNp B)).mpr (one_le_pow₀ hN₁) + calc + _ ≤ Real.sqrt (K * localizedCoulombProfile freq 0) := by + simpa only [one_mul] using mul_le_mul_of_nonneg_right hτ₁ + (Real.sqrt_nonneg (K * localizedCoulombProfile freq 0)) + _ = Real.sqrt K * Real.sqrt (localizedCoulombProfile freq 0) := Real.sqrt_mul hK _ + _ ≤ N ^ A * N ^ L := mul_le_mul hroothi hUhi (Real.sqrt_nonneg _) (pow_nonneg hNp.le A) + _ = N ^ (A + L) := (pow_add N A L).symm + _ ≤ _ := pow_le_pow_right₀ hN₁ (by omega) + +theorem exists_inverse_polynomial_coulomb_calibration {freq ε : ℝ} (hfreq : 0 < freq) + (hε : 0 < ε) (hε₁ : ε < 1) (A B : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ + ∀ K : ℝ, (N ^ A)⁻¹ ≤ K → K ≤ N ^ A → + ∃ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), + N ^ k * planarHopping d = coulombHoppingTarget freq (N ^ B)⁻¹ K d := by + obtain ⟨L, _, hrange⟩ := exists_coulomb_target_polynomial_bounds hfreq A B + obtain ⟨k, hk, hcal⟩ := exists_uniform_coulomb_calibration hfreq hε hε₁ (B + A + L) 0 + refine ⟨k, hk, fun N hN => ⟨(hcal N hN).1, fun K hKlo hKhi => ?_⟩⟩ + have hNp : 0 < N := by linarith + obtain ⟨hlo, hhi⟩ := hrange N hN K hKlo hKhi + exact (hcal N hN).2.2.1 (N ^ B)⁻¹ K (by positivity) + ((inv_nonneg.mpr (pow_nonneg hNp.le A)).trans hKlo) hlo hhi + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTruncationSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTruncationSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..58cd94999ff7ed741f257289770fcd11bfdc2994 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CoulombTruncationSchedule.lean @@ -0,0 +1,114 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombBox + +namespace OAI + +/-! Explicit polynomial cap and box schedules. The single natural guard +is fixed by the fixed one-well density; it is not an input or an oracle. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombTruncationSchedule + +def guard (freq : ℝ) : ℕ := Nat.ceil (max 1 + (max (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq))) + 1 + +def scale (P : ℕ) : ℕ := 8 * (P + 1) +def radius (freq : ℝ) (P : ℕ) : ℕ := guard freq * scale P ^ 2 +def epsilon (freq : ℝ) (P : ℕ) : ℚ := 1 / ((guard freq : ℚ) * (scale P : ℚ)) + +theorem guard_one_le (freq : ℝ) : 1 ≤ (guard freq : ℝ) := by + have hc := Nat.le_ceil (max 1 (max (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq))) + have h := (le_max_left (1 : ℝ) _).trans hc + simp only [guard, Nat.cast_add, Nat.cast_one] + linarith + +theorem guard_cap (freq : ℝ) : + 2 * Real.pi * localizedAmplitudeBound freq ^ 2 ≤ (guard freq : ℝ) := by + have hc := Nat.le_ceil (max 1 (max (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq))) + have h := (le_max_left (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq)).trans ((le_max_right (1 : ℝ) _).trans hc) + simp only [guard, Nat.cast_add, Nat.cast_one] + linarith + +theorem guard_tail (freq : ℝ) : + 2 * localizedDensitySecondMoment freq ≤ (guard freq : ℝ) := by + have hc := Nat.le_ceil (max 1 (max (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq))) + have h := (le_max_right (2 * Real.pi * localizedAmplitudeBound freq ^ 2) + (2 * localizedDensitySecondMoment freq)).trans ((le_max_right (1 : ℝ) _).trans hc) + simp only [guard, Nat.cast_add, Nat.cast_one] + linarith + +theorem scale_eight_le (P : ℕ) : (8 : ℝ) ≤ scale P := by + simp only [scale, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _] + +theorem epsilon_positive (freq : ℝ) (P : ℕ) : 0 < (epsilon freq P : ℝ) := by + have hg := guard_one_le freq + have hs := scale_eight_le P + simp only [epsilon, Rat.cast_div, Rat.cast_one, Rat.cast_mul, Rat.cast_natCast] + positivity + +theorem radius_positive (freq : ℝ) (P : ℕ) : 0 < (radius freq P : ℝ) := by + have hg := guard_one_le freq + have hs := scale_eight_le P + simp only [radius, Nat.cast_mul, Nat.cast_pow] + positivity + +theorem scalar_budget {C S B M : ℝ} (hC : 1 ≤ C) (hS : 1 ≤ S) + (hB : B ≤ C) (hM : 2 * M ≤ C) : + B * (1 / (C * S)) ^ 2 + 2 * (1 / (C * S))⁻¹ * M / (C * S ^ 2) ^ 2 ≤ + 2 / S ^ 2 := by + have hC0 : 0 < C := by linarith + have hS0 : 0 < S := by linarith + have hcap : B * (1 / (C * S)) ^ 2 ≤ 1 / S ^ 2 := by + calc + _ ≤ C * (1 / (C * S)) ^ 2 := mul_le_mul_of_nonneg_right hB (sq_nonneg _) + _ = C⁻¹ * (1 / S ^ 2) := by field_simp [hC0.ne', hS0.ne'] + _ ≤ 1 / S ^ 2 := mul_le_of_le_one_left (by positivity) + ((inv_le_one₀ hC0).mpr hC) + have htail : 2 * (1 / (C * S))⁻¹ * M / (C * S ^ 2) ^ 2 ≤ 1 / S ^ 2 := by + calc + _ = (2 * M) * (C * S) / (C * S ^ 2) ^ 2 := by field_simp [hC0.ne', hS0.ne'] + _ ≤ C * (C * S) / (C * S ^ 2) ^ 2 := + div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_right hM (by positivity)) (by positivity) + _ = (1 / S ^ 2) * S⁻¹ := by field_simp [hC0.ne', hS0.ne'] + _ ≤ 1 / S ^ 2 := mul_le_of_le_one_right (by positivity) ((inv_le_one₀ hS0).mpr hS) + calc + _ ≤ 1 / S ^ 2 + 1 / S ^ 2 := add_le_add hcap htail + _ = _ := by ring + +theorem error {freq : ℝ} (hfreq : 0 < freq) (P : ℕ) (u : PlanarPosition) : + |localizedCoulombProfileAt freq u - + localizedCoulombBoxIntegral freq (epsilon freq P : ℝ) (radius freq P : ℝ) u| ≤ + (4 * ((P : ℝ) + 1))⁻¹ := by + have h := localizedCoulombProfile_box_error hfreq (epsilon_positive freq P) + (radius_positive freq P) u + have hg := guard_one_le freq + have hs := scale_eight_le P + have hb := scalar_budget hg (by linarith : (1 : ℝ) ≤ scale P) + (guard_cap freq) (guard_tail freq) + have hcast : (epsilon freq P : ℝ) = 1 / ((guard freq : ℝ) * (scale P : ℝ)) := by + simp only [epsilon, Rat.cast_div, Rat.cast_one, Rat.cast_mul, Rat.cast_natCast] + rw [hcast] at h + simp only [radius, Nat.cast_mul, Nat.cast_pow] at h + rw [hcast] + simp only [radius, Nat.cast_mul, Nat.cast_pow] + apply (h.trans hb).trans + have hP : 1 ≤ (P : ℝ) + 1 := by linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _] + simp only [scale, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + calc + 2 / (8 * ((P : ℝ) + 1)) ^ 2 = + (4 * ((P : ℝ) + 1))⁻¹ * (8 * ((P : ℝ) + 1))⁻¹ := by + field_simp + ring + _ ≤ _ := mul_le_of_le_one_right (by positivity) + ((inv_le_one₀ (by positivity)).mpr (by linarith)) + +end ContinuumCoulomb.CoulombTruncationSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CountertermEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CountertermEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..53e1d94d3ec5fc179120ccf528d24cd4bf57382d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CountertermEvaluation.lean @@ -0,0 +1,152 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombPairProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableHopping +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserVelocityNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarFieldBounds + +namespace OAI + +/-! Actual well-depth counterterms are finite sums of certified Coulomb +entries divided by the fixed onsite hopping. A fixed positive denominator +guard makes every rational evaluation well defined. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.CountertermEvaluation + +private theorem guard_exists (rho : ℕ) : ∃ C : ℕ, 1 ≤ C ∧ + 2 ≤ (C:ℝ)*planarHopping 0 ∧ + localizedPotentialBound (GaussianFrequency.frequency rho) ≤ C ∧ + planarWellDerivativeConstant ≤ C := by + let B := 1+2/planarHopping 0+ + localizedPotentialBound (GaussianFrequency.frequency rho)+planarWellDerivativeConstant + obtain ⟨C,hC⟩ := exists_nat_gt B + have hT := planarHopping_positive 0 + have hV := localizedPotentialBound_nonnegative (GaussianFrequency.frequency rho) + have hW := planarWellDerivativeConstant_positive + have h1 : (1:ℝ) ≤ C := by + dsimp [B] at hC + have hp : 0 ≤ 2/planarHopping 0 := by positivity + linarith + refine ⟨C,by exact_mod_cast h1,?_,?_,?_⟩ + · apply (div_le_iff₀ hT).mp + dsimp [B] at hC + linarith + · dsimp [B] at hC + linarith [div_nonneg (by norm_num : (0:ℝ) ≤ 2) hT.le] + · dsimp [B] at hC + linarith [div_nonneg (by norm_num : (0:ℝ) ≤ 2) hT.le] + +def guard (rho : ℕ) : ℕ := Classical.choose (guard_exists rho) + +theorem guard_bounds (rho : ℕ) : 1 ≤ guard rho ∧ + 2 ≤ (guard rho:ℝ)*planarHopping 0 ∧ + localizedPotentialBound (GaussianFrequency.frequency rho) ≤ guard rho ∧ + planarWellDerivativeConstant ≤ guard rho := Classical.choose_spec (guard_exists rho) + +def denominator (rho p : ℕ) : ℚ := + max 1 ((guard rho:ℚ)*ComputableHopping.approximate ((1,p),0)) + +def entry (rho p : ℕ) (a b : ℚ×ℚ) : ℚ := + (guard rho:ℚ)*CoulombPairEvaluation.approximate rho p a b / denominator rho p + +theorem entry_error (rho p : ℕ) (hrho : 0 < rho) (a b : ℚ×ℚ) : + |(entry rho p a b:ℝ)- + localizedCoulombCoeff (GaussianFrequency.frequency rho) + (PlanarForcingProgram.position a) (PlanarForcingProgram.position b)/planarHopping 0| ≤ + 2*(guard rho:ℝ)^3*((p:ℝ)+1)⁻¹ := by + let C : ℝ := guard rho + let T : ℝ := planarHopping 0 + let A : ℝ := localizedCoulombCoeff (GaussianFrequency.frequency rho) + (PlanarForcingProgram.position a) (PlanarForcingProgram.position b) + let ε : ℝ := ((p:ℝ)+1)⁻¹ + have hC : 1 ≤ C := by dsimp [C]; exact_mod_cast (guard_bounds rho).1 + have hCp : 0 < C := by linarith + have hT : 0 < T := planarHopping_positive 0 + have hCT : 1 ≤ C*T := by have h := (guard_bounds rho).2.1; dsimp [C,T]; linarith + have hf : 0 < GaussianFrequency.frequency rho := by + apply Real.sqrt_pos.mpr + change 0 < 4*Real.pi*(rho:ℝ) + positivity + have hA : |A| ≤ C := by + rw [abs_of_nonneg (localizedCoulombCoeff_nonnegative _ _ _)] + exact (localizedCoulombCoeff_le hf _ _).trans (guard_bounds rho).2.2.1 + have he := CoulombPairEvaluation.approximation_error rho p hrho a b + have ht : |(ComputableHopping.approximate ((1,p),0):ℝ)-T| ≤ ε := by + simpa only [Prod.fst,Prod.snd,Rat.cast_zero,T,ε] using + ComputableHopping.approximation_error ((1,p),0) (by norm_num) + have hden : |(denominator rho p:ℝ)-C*T| ≤ C*ε := by + have hm : |C*(ComputableHopping.approximate ((1,p),0):ℝ)-C*T| ≤ C*ε := by + rw [← mul_sub,abs_mul,abs_of_pos hCp] + exact mul_le_mul_of_nonneg_left ht hCp.le + simpa only [denominator,Rat.cast_max,Rat.cast_one,Rat.cast_mul,Rat.cast_natCast,C,T] + using MoserVelocityNumerics.clamp_error hCT hm + have hden1 : (1:ℝ) ≤ denominator rho p := by + exact_mod_cast le_max_left (1:ℚ) ((guard rho:ℚ)*ComputableHopping.approximate ((1,p),0)) + have hnum : |-(C*(CoulombPairEvaluation.approximate rho p a b:ℝ))- -(C*A)| ≤ C*ε := by + rw [show -(C*(CoulombPairEvaluation.approximate rho p a b:ℝ))- -(C*A) = + -(C*((CoulombPairEvaluation.approximate rho p a b:ℝ)-A)) by ring, + abs_neg,abs_mul,abs_of_pos hCp] + exact mul_le_mul_of_nonneg_left he hCp.le + have hAb : |-(C*A)| ≤ C^2 := by + rw [abs_neg,abs_mul,abs_of_pos hCp] + exact (mul_le_mul_of_nonneg_left hA hCp.le).trans_eq (by ring) + have h := MoserVelocityNumerics.quotient_error hCT hden1 hAb hnum hden + have hid : C*A/(C*T) = A/T := by field_simp + simp only [neg_neg,hid] at h + have hsmall : C*ε+C^2*(C*ε) ≤ 2*C^3*ε := by + have heps : 0 ≤ ε := by dsimp [ε]; positivity + have hc3 : C ≤ C^3 := le_self_pow₀ hC (by decide) + have hm := mul_le_mul_of_nonneg_right hc3 heps + nlinarith only [hm] + exact (show |(entry rho p a b:ℝ)-A/T| ≤ C*ε+C^2*(C*ε) by + simpa only [entry,Rat.cast_div,Rat.cast_mul,Rat.cast_natCast,C] using h).trans hsmall + +theorem squaredDistance_eq_zero (a b : ℚ×ℚ) : + CoulombPairEvaluation.squaredDistance a b = 0 ↔ a=b := by + constructor + · intro h + unfold CoulombPairEvaluation.squaredDistance at h + have h1 : (a.1-b.1)^2 = 0 := by nlinarith [sq_nonneg (a.2-b.2)] + have h2 : (a.2-b.2)^2 = 0 := by nlinarith [sq_nonneg (a.1-b.1)] + apply Prod.ext <;> nlinarith + · rintro rfl + simp [CoulombPairEvaluation.squaredDistance] + +def offsite (rho p : ℕ) (a b : ℚ×ℚ) : ℚ := + if CoulombPairEvaluation.squaredDistance a b = 0 then 0 else entry rho p a b + +def row (rho p : ℕ) (a : ℚ×ℚ) (sites : List (ℚ×ℚ)) : ℚ := + (sites.map (offsite rho p a)).sum + +theorem row_ofFn (rho p : ℕ) {m : ℕ} (u : Fin m → ℚ×ℚ) (i : Fin m) : + row rho p (u i) (List.ofFn u) = ∑ j, offsite rho p (u i) (u j) := by + simp only [row,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + +theorem row_error (rho p : ℕ) (hrho : 0 < rho) {m : ℕ} + (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) (i : Fin m) : + |(row rho p (u i) (List.ofFn u):ℝ)- + localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i| ≤ + (m:ℝ)*2*(guard rho:ℝ)^3*((p:ℝ)+1)⁻¹ := by + rw [row_ofFn] + simp only [Rat.cast_sum,localizedCounterterm,localizedOffsiteSum,Finset.sum_div] + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _j : Fin m, 2*(guard rho:ℝ)^3*((p:ℝ)+1)⁻¹ := by + apply Finset.sum_le_sum + intro j _ + by_cases h : i=j + · subst j + simp only [offsite,squaredDistance_eq_zero,ite_true,Rat.cast_zero,zero_div,sub_self,abs_zero] + positivity + · have huij : u i ≠ u j := fun hij => h (hu hij) + simpa only [offsite,squaredDistance_eq_zero,ite_eq_right huij,ite_eq_right h] + using entry_error rho p hrho (u i) (u j) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; ring + +end ContinuumCoulomb.CountertermEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..1aa4a9683dd876cbe14126708b06eb2bcb166100 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeGeometry.lean @@ -0,0 +1,175 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.GaussEightNodes +import Mathlib.MeasureTheory.Measure.Lebesgue.Basic + +namespace OAI + +/-! Actual Euclidean mesh cells: volume, radius, node containment, and +disjoint interiors. These retain the volume normalization of the Gauss rule. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def positionCube (b : Position) (h : ℝ) : Set Position := + WithLp.ofLp ⁻¹' Set.Icc (fun i => b i-h/2) (fun i => b i+h/2) + +def positionOpenCube (b : Position) (h : ℝ) : Set Position := + WithLp.ofLp ⁻¹' Set.univ.pi (fun i => Set.Ioo (b i-h/2) (b i+h/2)) + +theorem mem_positionCube {x b : Position} {h : ℝ} : + x ∈ positionCube b h ↔ ∀ i, |x i-b i| ≤ h/2 := by + change ((fun i => b i-h/2) ≤ WithLp.ofLp x ∧ + WithLp.ofLp x ≤ (fun i => b i+h/2)) ↔ _ + constructor + · rintro ⟨hl,hu⟩ i + exact abs_le.mpr ⟨by linarith [hl i],by linarith [hu i]⟩ + · intro hx + constructor <;> intro i <;> have hi := abs_le.mp (hx i) <;> linarith + +theorem mem_positionOpenCube {x b : Position} {h : ℝ} : + x ∈ positionOpenCube b h ↔ ∀ i, |x i-b i| < h/2 := by + change (∀ i ∈ Set.univ, x i ∈ Set.Ioo (b i-h/2) (b i+h/2)) ↔ _ + simp only [Set.mem_univ,true_implies,Set.mem_Ioo] + constructor + · intro hx i + exact abs_lt.mpr ⟨by linarith [(hx i).1],by linarith [(hx i).2]⟩ + · intro hx i + have hi := abs_lt.mp (hx i) + constructor <;> linarith + +theorem positionCube_isClosed (b : Position) (h : ℝ) : IsClosed (positionCube b h) := + isClosed_Icc.preimage (PiLp.continuous_ofLp 2 (fun _ : Fin 3 => ℝ)) + +theorem positionOpenCube_measurable (b : Position) (h : ℝ) : + MeasurableSet (positionOpenCube b h) := + (MeasurableSet.univ_pi (fun _ => measurableSet_Ioo)).preimage + (PiLp.continuous_ofLp 2 (fun _ : Fin 3 => ℝ)).measurable + +theorem positionOpenCube_subset (b : Position) (h : ℝ) : + positionOpenCube b h ⊆ positionCube b h := by + intro x hx + exact mem_positionCube.mpr (fun i => (mem_positionOpenCube.mp hx i).le) + +theorem positionCube_volume (b : Position) {h : ℝ} (hh : 0 ≤ h) : + volume.real (positionCube b h) = h^3 := by + have he := (PiLp.volume_preserving_ofLp (Fin 3)).measure_preimage + (s := Set.Icc (fun i => b i-h/2) (fun i => b i+h/2)) measurableSet_Icc.nullMeasurableSet + unfold positionCube Measure.real + rw [he,Real.volume_Icc_pi_toReal (by intro i; linarith)] + simp only [show ∀ i : Fin 3, b i+h/2-(b i-h/2) = h by intro; ring] + simp + +theorem positionOpenCube_volume (b : Position) {h : ℝ} (hh : 0 ≤ h) : + volume.real (positionOpenCube b h) = h^3 := by + have he := (PiLp.volume_preserving_ofLp (Fin 3)).measure_preimage + (s := Set.univ.pi (fun i => Set.Ioo (b i-h/2) (b i+h/2))) + (MeasurableSet.univ_pi (fun _ => measurableSet_Ioo)).nullMeasurableSet + unfold positionOpenCube Measure.real + rw [he,Real.volume_pi_Ioo_toReal (by intro i; linarith)] + simp only [show ∀ i : Fin 3, b i+h/2-(b i-h/2) = h by intro; ring] + simp + +theorem positionOpenCube_ae_eq (b : Position) (h : ℝ) : + positionOpenCube b h =ᵐ[volume] positionCube b h := by + have he := Measure.univ_pi_Ioo_ae_eq_Icc + (μ := fun _ : Fin 3 => (volume : Measure ℝ)) + (f := fun i => b i-h/2) (g := fun i => b i+h/2) + exact (PiLp.volume_preserving_ofLp (Fin 3)).quasiMeasurePreserving.ae he + +theorem cubePoint_mem_positionCube (b : Position) {h : ℝ} (hh : 0 ≤ h) + {x y z : ℝ} (hx : x ∈ Set.Icc (-1:ℝ) 1) + (hy : y ∈ Set.Icc (-1:ℝ) 1) (hz : z ∈ Set.Icc (-1:ℝ) 1) : + cubePoint b (h/2) x y z ∈ positionCube b h := by + rw [mem_positionCube] + intro i + have he : cubePoint b (h/2) x y z i-b i = (h/2)*(![x,y,z] i) := by + fin_cases i <;> simp [cubePoint] <;> ring + rw [he,abs_mul,abs_of_nonneg (by positivity : 0 ≤ h/2)] + apply (mul_le_mul_of_nonneg_left (show |![x,y,z] i| ≤ 1 from ?_) (by positivity)).trans_eq + (mul_one _) + fin_cases i + · exact abs_le.mpr hx + · exact abs_le.mpr hy + · exact abs_le.mpr hz + +theorem positionCube_norm_sub_le {b x : Position} {h : ℝ} (hh : 0 ≤ h) + (hx : x ∈ positionCube b h) : ‖x-b‖ ≤ h := by + have hi := mem_positionCube.mp hx + have hs : ‖x-b‖^2 ≤ 3*(h/2)^2 := by + rw [EuclideanSpace.real_norm_sq_eq] + calc + _ ≤ ∑ _i : Fin 3, (h/2)^2 := by + apply Finset.sum_le_sum + intro i _ + change (x i-b i)^2 ≤ _ + nlinarith [abs_le.mp (hi i),sq_abs (x i-b i)] + _ = _ := by simp + nlinarith [norm_nonneg (x-b)] + +theorem positionCube_isCompact (b : Position) {h : ℝ} (hh : 0 ≤ h) : + IsCompact (positionCube b h) := by + apply (isCompact_closedBall b h).of_isClosed_subset (positionCube_isClosed b h) + intro x hx + exact positionCube_norm_sub_le hh hx + +theorem positionCube_diameter_bound {b x y : Position} {h : ℝ} (hh : 0 ≤ h) + (hx : x ∈ positionCube b h) (hy : y ∈ positionCube b h) : ‖x-y‖ ≤ 2*h := by + have ht := norm_sub_le_norm_sub_add_norm_sub x b y + rw [norm_sub_rev b y] at ht + linarith [positionCube_norm_sub_le hh hx,positionCube_norm_sub_le hh hy] + +theorem grid_openCubes_disjoint {h : ℝ} (hh : 0 < h) {k l : Fin 3 → ℤ} (hkl : k ≠ l) : + Disjoint (positionOpenCube (gaussCellCenter h k) h) + (positionOpenCube (gaussCellCenter h l) h) := by + obtain ⟨i,hi⟩ := Function.ne_iff.mp hkl + apply Set.disjoint_left.mpr + intro x hx hy + have hx := abs_lt.mp (mem_positionOpenCube.mp hx i) + have hy := abs_lt.mp (mem_positionOpenCube.mp hy i) + change -(h/2) < x i-h*(k i:ℝ) ∧ x i-h*(k i:ℝ) < h/2 at hx + change -(h/2) < x i-h*(l i:ℝ) ∧ x i-h*(l i:ℝ) < h/2 at hy + rcases lt_or_gt_of_ne hi with hi | hi + · have hd : (k i:ℝ)+1 ≤ l i := by exact_mod_cast (show k i+1 ≤ l i by omega) + nlinarith [mul_le_mul_of_nonneg_left hd hh.le] + · have hd : (l i:ℝ)+1 ≤ k i := by exact_mod_cast (show l i+1 ≤ k i by omega) + nlinarith [mul_le_mul_of_nonneg_left hd hh.le] + +theorem grid_cell_integral_sum_le {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) (f : Position → ℝ) (hf : Integrable f) + (hpos : ∀ x, 0 ≤ f x) : + (∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, f x) ≤ ∫ x, f x := by + have he (i : ι) := setIntegral_congr_set + (f := f) (positionOpenCube_ae_eq (gaussCellCenter h (index i)) h) + simp_rw [← he] + rw [← integral_iUnion_fintype + (fun i => positionOpenCube_measurable (gaussCellCenter h (index i)) h) + (fun i j hij => grid_openCubes_disjoint hh (fun he => hij (hindex he))) + (fun _ => hf.integrableOn)] + exact setIntegral_le_integral hf (Filter.Eventually.of_forall hpos) + +theorem grid_cell_integral_sum_le_on {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) {B : Set Position} + (hsub : ∀ i, positionCube (gaussCellCenter h (index i)) h ⊆ B) + (f : Position → ℝ) (hf : IntegrableOn f B) (hpos : ∀ x, 0 ≤ f x) : + (∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, f x) ≤ + ∫ x in B, f x := by + have ho (i : ι) : positionOpenCube (gaussCellCenter h (index i)) h ⊆ B := + (positionOpenCube_subset _ _).trans (hsub i) + have he (i : ι) := setIntegral_congr_set + (f := f) (positionOpenCube_ae_eq (gaussCellCenter h (index i)) h) + simp_rw [← he] + rw [← integral_iUnion_fintype + (fun i => positionOpenCube_measurable (gaussCellCenter h (index i)) h) + (fun i j hij => grid_openCubes_disjoint hh (fun he => hij (hindex he))) + (fun i => hf.mono_set (ho i))] + exact setIntegral_mono_set hf (Filter.Eventually.of_forall hpos) + (Filter.Eventually.of_forall (Set.iUnion_subset ho)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeIntegral.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..9065bc7fcf75021de47bc32e36d19bd8825a92ad --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeIntegral.lean @@ -0,0 +1,125 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabCoordinates + +namespace OAI + +/-! The normalized tensor cell integral is the ordinary Euclidean volume +integral on the translated cube, with no change of volume convention. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def cubeTripleBox (b : Position) (h : ℝ) : Set SlabTriple := + Set.Icc (b 0-h/2) (b 0+h/2) ×ˢ + (Set.Icc (b 1-h/2) (b 1+h/2) ×ˢ Set.Icc (b 2-h/2) (b 2+h/2)) + +theorem cubeTripleBox_measurable (b : Position) (h : ℝ) : + MeasurableSet (cubeTripleBox b h) := + measurableSet_Icc.prod (measurableSet_Icc.prod measurableSet_Icc) + +theorem cubeTripleBox_preimage (b : Position) (h : ℝ) : + slabTripleEquiv ⁻¹' cubeTripleBox b h = positionCube b h := by + ext x + simp only [Set.mem_preimage,cubeTripleBox,slabTripleEquiv_apply,Set.mem_prod, + Set.mem_Icc,mem_positionCube] + constructor + · rintro ⟨h0,h1,h2⟩ i + fin_cases i + · change |x 0-b 0| ≤ h/2 + exact abs_le.mpr ⟨by linarith [h0.1],by linarith [h0.2]⟩ + · change |x 1-b 1| ≤ h/2 + exact abs_le.mpr ⟨by linarith [h1.1],by linarith [h1.2]⟩ + · change |x 2-b 2| ≤ h/2 + exact abs_le.mpr ⟨by linarith [h2.1],by linarith [h2.2]⟩ + · intro hx + have h0 := abs_le.mp (hx 0) + have h1 := abs_le.mp (hx 1) + have h2 := abs_le.mp (hx 2) + exact ⟨⟨by linarith,by linarith⟩,⟨by linarith,by linarith⟩, + ⟨by linarith,by linarith⟩⟩ + +theorem cube_setIntegral_triple (b : Position) (h : ℝ) (f : Position → ℝ) : + (∫ x in positionCube b h, f x) = + ∫ p in cubeTripleBox b h, f (slabTripleEquiv.symm p) := by + have hm := slabTripleEquiv_measurePreserving.restrict_preimage (cubeTripleBox_measurable b h) + rw [cubeTripleBox_preimage] at hm + simpa only [Function.comp_apply,MeasurableEquiv.symm_apply_apply] using + hm.integral_comp' (f ∘ slabTripleEquiv.symm) + +theorem centered_interval_integral (c h : ℝ) (f : ℝ → ℝ) : + (h/2)*(∫ t : ℝ in (-1)..1, f (c+h/2*t)) = + ∫ t : ℝ in (c-h/2)..(c+h/2), f t := by + have he := intervalIntegral.smul_integral_comp_add_mul + (f := f) (a := (-1:ℝ)) (b := 1) (h/2) c + simpa only [smul_eq_mul,mul_neg_one,mul_one,← sub_eq_add_neg] using he + +theorem centered_triple_integral (c₀ c₁ c₂ h : ℝ) (f : ℝ → ℝ → ℝ → ℝ) : + (h/2)^3*(∫ x : ℝ in (-1)..1, ∫ y : ℝ in (-1)..1, ∫ z : ℝ in (-1)..1, + f (c₀+h/2*x) (c₁+h/2*y) (c₂+h/2*z)) = + ∫ x : ℝ in (c₀-h/2)..(c₀+h/2), + ∫ y : ℝ in (c₁-h/2)..(c₁+h/2), + ∫ z : ℝ in (c₂-h/2)..(c₂+h/2), f x y z := by + let d := h/2 + have hz (x y : ℝ) : d*(∫ z : ℝ in (-1)..1, f x y (c₂+d*z)) = + ∫ z : ℝ in (c₂-d)..(c₂+d), f x y z := centered_interval_integral c₂ h (f x y) + have hy (x : ℝ) : d^2*(∫ y : ℝ in (-1)..1, ∫ z : ℝ in (-1)..1, + f x (c₁+d*y) (c₂+d*z)) = + ∫ y : ℝ in (c₁-d)..(c₁+d), ∫ z : ℝ in (c₂-d)..(c₂+d), f x y z := by + calc + _ = d*(∫ y : ℝ in (-1)..1, d*(∫ z : ℝ in (-1)..1, f x (c₁+d*y) (c₂+d*z))) := by + rw [intervalIntegral.integral_const_mul] + ring + _ = d*(∫ y : ℝ in (-1)..1, ∫ z : ℝ in (c₂-d)..(c₂+d), f x (c₁+d*y) z) := by + simp_rw [hz] + _ = _ := centered_interval_integral c₁ h (fun y => ∫ z : ℝ in (c₂-d)..(c₂+d), f x y z) + change d^3*_ = _ + calc + _ = d*(∫ x : ℝ in (-1)..1, d^2*(∫ y : ℝ in (-1)..1, + ∫ z : ℝ in (-1)..1, f (c₀+d*x) (c₁+d*y) (c₂+d*z))) := by + rw [intervalIntegral.integral_const_mul] + ring + _ = d*(∫ x : ℝ in (-1)..1, ∫ y : ℝ in (c₁-d)..(c₁+d), + ∫ z : ℝ in (c₂-d)..(c₂+d), f (c₀+d*x) y z) := by simp_rw [hy] + _ = _ := centered_interval_integral c₀ h + (fun x => ∫ y : ℝ in (c₁-d)..(c₁+d), ∫ z : ℝ in (c₂-d)..(c₂+d), f x y z) + +theorem positionCellIntegral_eq_setIntegral (b : Position) {h : ℝ} (hh : 0 ≤ h) + (f : Position → ℝ) (hf : IntegrableOn f (positionCube b h)) : + positionCellIntegral b h f = ∫ x in positionCube b h, f x := by + let F : SlabTriple → ℝ := fun p => f (slabTripleEquiv.symm p) + have hm := slabTripleEquiv_measurePreserving.restrict_preimage (cubeTripleBox_measurable b h) + rw [cubeTripleBox_preimage] at hm + have hF : IntegrableOn F (cubeTripleBox b h) := + (hm.integrable_comp_emb slabTripleEquiv.measurableEmbedding).mp + (by simpa only [IntegrableOn,F,Function.comp_def,MeasurableEquiv.symm_apply_apply] using hf) + have ht : (∫ p in cubeTripleBox b h, F p) = + ∫ x in Set.Icc (b 0-h/2) (b 0+h/2), + ∫ y in Set.Icc (b 1-h/2) (b 1+h/2), + ∫ z in Set.Icc (b 2-h/2) (b 2+h/2), F (x,y,z) := by + rw [cubeTripleBox,Measure.volume_eq_prod] at hF ⊢ + rw [setIntegral_prod _ hF] + apply integral_congr_ae + have hFa := hF + rw [IntegrableOn,← Measure.prod_restrict] at hFa + filter_upwards [hFa.prod_right_ae] with x hx + exact setIntegral_prod _ hx + rw [cube_setIntegral_triple,ht] + have hi (i : Fin 3) : b i-h/2 ≤ b i+h/2 := by linarith + have he (x y z : ℝ) : cubePoint b (h/2) x y z = + slabTripleEquiv.symm (b 0+h/2*x,b 1+h/2*y,b 2+h/2*z) := by + rw [slabTripleEquiv_symm_apply] + ext i + fin_cases i <;> simp [cubePoint] <;> ring + unfold positionCellIntegral + simp_rw [he] + rw [centered_triple_integral (b 0) (b 1) (b 2) h + (fun x y z => f (slabTripleEquiv.symm (x,y,z)))] + simp_rw [intervalIntegral.integral_of_le (hi _),← integral_Icc_eq_integral_Ioc] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeMeasure.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeMeasure.lean new file mode 100644 index 0000000000000000000000000000000000000000..50ff0626642eefdbea3f5825221884898419166f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/CubeMeasure.lean @@ -0,0 +1,55 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteCubeQuadrature +import Mathlib.MeasureTheory.Integral.Pi + +namespace OAI + +/-! The recursive quadrature integral is the actual product Lebesgue +integral on the cube. This identifies the six-coordinate computation with +the finite Coulomb box, rather than a separately defined integral. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.UniformQuadrature + +def cubeMeasure (a b : ℝ) (n : ℕ) : Measure (Fin n → ℝ) := + Measure.pi (fun _ : Fin n => volume.restrict (Set.Icc a b)) + +instance cubeMeasure_finite (a b : ℝ) (n : ℕ) : IsFiniteMeasure (cubeMeasure a b n) := by + unfold cubeMeasure + infer_instance + +theorem cubeIntegral_eq_integral (n : ℕ) {a b : ℝ} (hab : a ≤ b) + {f : (Fin n → ℝ) → ℝ} (hf : Integrable f (cubeMeasure a b n)) : + cubeIntegral a b n f = ∫ x, f x ∂cubeMeasure a b n := by + induction n with + | zero => + have he : f = fun _ => f Fin.elim0 := funext (fun x => congrArg f (Subsingleton.elim x _)) + rw [he] + simp [cubeIntegral, cubeMeasure, Measure.pi_empty_univ, measureReal_def] + | succ n ih => + let μ : Measure ℝ := volume.restrict (Set.Icc a b) + have hp := (measurePreserving_piFinSuccAbove (fun _ : Fin (n + 1) => μ) 0).symm + have hprod : Integrable (fun p : ℝ × (Fin n → ℝ) => f (Fin.cons p.1 p.2)) + (μ.prod (cubeMeasure a b n)) := by + have ht := (hp.integrable_comp_emb + (MeasurableEquiv.piFinSuccAbove (fun _ : Fin (n + 1) => ℝ) 0).symm.measurableEmbedding).mpr hf + simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, + Fin.insertNthEquiv, Equiv.coe_fn_mk, Fin.insertNth_zero', cubeMeasure, μ] using ht + have hsplit : (∫ x, f x ∂cubeMeasure a b (n + 1)) = + ∫ x, ∫ v, f (Fin.cons x v) ∂cubeMeasure a b n ∂μ := by + change (∫ x, f x ∂Measure.pi (fun _ : Fin (n + 1) => μ)) = _ + rw [← hp.integral_comp'] + simpa only [Function.comp_def, MeasurableEquiv.piFinSuccAbove_symm_apply, + Fin.insertNthEquiv, Equiv.coe_fn_mk, Fin.insertNth_zero', cubeMeasure, μ] using integral_prod _ hprod + rw [hsplit] + change (∫ x in a..b, cubeIntegral a b n (fun v => f (Fin.cons x v))) = _ + rw [intervalIntegral.integral_of_le hab, ← integral_Icc_eq_integral_Ioc] + apply integral_congr_ae + filter_upwards [hprod.prod_right_ae] with x hx + exact ih hx + +end ContinuumCoulomb.UniformQuadrature + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DiagonalPenalty.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DiagonalPenalty.lean new file mode 100644 index 0000000000000000000000000000000000000000..51bee4c6b6d04c5e8ca5d83aa41c8d3b38fa91ce --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DiagonalPenalty.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ChargePenalty +import Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Analysis.Normed.Module.FiniteDimension + +namespace OAI + +/-! +# The concrete inverse of a charge-sector penalty + +The high block of the Hubbard penalty is diagonal in the occupation basis. +That block and its inverse are continuous linear maps satisfying the +positivity, symmetry and inverse-norm hypotheses of the second-order +perturbation theorem. +-/ + +noncomputable section +open scoped BigOperators InnerProductSpace +namespace ContinuumCoulomb + +variable {Basis : Type*} [Fintype Basis] + +def diagonalPenaltyLinear (weight : Basis → ℝ) : + EuclideanSpace ℂ Basis →ₗ[ℝ] EuclideanSpace ℂ Basis where + toFun x := WithLp.toLp 2 (fun s => weight s • x s) + map_add' x y := by ext s; simp [smul_add] + map_smul' c x := by + ext s + change (weight s : ℂ) * ((c : ℂ) * x s) = (c : ℂ) * ((weight s : ℂ) * x s) + ring + +def diagonalPenalty (weight : Basis → ℝ) : + EuclideanSpace ℂ Basis →L[ℝ] EuclideanSpace ℂ Basis := + (diagonalPenaltyLinear weight).toContinuousLinearMap + +@[simp] theorem diagonalPenalty_apply (weight : Basis → ℝ) + (x : EuclideanSpace ℂ Basis) (s : Basis) : + diagonalPenalty weight x s = weight s • x s := rfl + +theorem diagonalPenalty_form (weight : Basis → ℝ) (x : EuclideanSpace ℂ Basis) : + ⟪x, diagonalPenalty weight x⟫_ℝ = ∑ s, weight s * ‖x s‖ ^ 2 := by + simp only [PiLp.inner_apply, diagonalPenalty_apply, + real_inner_smul_right, real_inner_self_eq_norm_sq] + +theorem diagonalPenalty_symmetric (weight : Basis → ℝ) + (x y : EuclideanSpace ℂ Basis) : + ⟪x, diagonalPenalty weight y⟫_ℝ = ⟪diagonalPenalty weight x, y⟫_ℝ := by + simp only [PiLp.inner_apply, diagonalPenalty_apply, + real_inner_smul_right, real_inner_smul_left] + +theorem diagonalPenalty_gap (weight : Basis → ℝ) (g : ℝ) + (hgap : ∀ s, g ≤ weight s) (x : EuclideanSpace ℂ Basis) : + g * ‖x‖ ^ 2 ≤ ⟪x, diagonalPenalty weight x⟫_ℝ := by + rw [diagonalPenalty_form, EuclideanSpace.norm_sq_eq, Finset.mul_sum] + exact Finset.sum_le_sum fun s _ => mul_le_mul_of_nonneg_right (hgap s) (sq_nonneg _) + +theorem diagonalPenalty_norm_le (weight : Basis → ℝ) {C : ℝ} + (hC : 0 ≤ C) (hweight : ∀ s, |weight s| ≤ C) : + ‖diagonalPenalty weight‖ ≤ C := by + apply (diagonalPenalty weight).opNorm_le_bound hC + intro x + have hsq : ‖diagonalPenalty weight x‖ ^ 2 ≤ (C * ‖x‖) ^ 2 := by + rw [EuclideanSpace.norm_sq_eq, mul_pow, EuclideanSpace.norm_sq_eq, + Finset.mul_sum] + apply Finset.sum_le_sum + intro s _ + have hw : weight s ^ 2 ≤ C ^ 2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) hC).2 (hweight s) + simpa only [diagonalPenalty_apply, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs] using + mul_le_mul_of_nonneg_right hw (sq_nonneg ‖x s‖) + have hn := norm_nonneg (diagonalPenalty weight x) + have hcx : 0 ≤ C * ‖x‖ := mul_nonneg hC (norm_nonneg _) + nlinarith + +theorem diagonalPenalty_inverse_right (weight : Basis → ℝ) + (hweight : ∀ s, weight s ≠ 0) (x : EuclideanSpace ℂ Basis) : + diagonalPenalty weight (diagonalPenalty (fun s => (weight s)⁻¹) x) = x := by + ext s + simp [hweight s] + +theorem diagonalPenalty_inverse_norm {g : ℝ} (hg : 0 < g) (weight : Basis → ℝ) + (hgap : ∀ s, g ≤ weight s) : + ‖diagonalPenalty (fun s => (weight s)⁻¹)‖ ≤ 1 / g := by + apply diagonalPenalty_norm_le _ (by positivity) + intro s + have hw : 0 < weight s := hg.trans_le (hgap s) + rw [abs_of_pos (inv_pos.mpr hw)] + simpa only [one_div] using one_div_le_one_div_of_le hg (hgap s) + +/-- High occupations exclude the singly occupied spin subspace. -/ +abbrev ChargeHighBasis {m : ℕ} (occupation : Basis → Fin m → Fin 3) := + {s : Basis // ¬ ∀ i, occupation s i = 1} + +/-- The charge-transfer gap gives a concrete bounded inverse on the high +occupation space. -/ +theorem chargePenalty_inverse_data {m : ℕ} (U R : ℝ) + (V : Fin m → Fin m → ℝ) (occupation : Basis → Fin m → Fin 3) + (hsymm : ∀ i j, V i j = V j i) (hrow : ∀ i, ∑ j, |V i j| ≤ R) + (hUR : R < U) (hfill : ∀ s, ∑ i, (occupation s i : ℕ) = m) : + let weight : ChargeHighBasis occupation → ℝ := + fun s => chargePenalty U V (occupation s.val) + (∀ x, diagonalPenalty weight (diagonalPenalty (fun s => (weight s)⁻¹) x) = x) ∧ + ‖diagonalPenalty (fun s => (weight s)⁻¹)‖ ≤ 1 / (U - R) ∧ + (∀ x, (U - R) * ‖x‖ ^ 2 ≤ ⟪x, diagonalPenalty weight x⟫_ℝ) := by + classical + intro weight + have hg : 0 < U - R := sub_pos.mpr hUR + have hgap (s : ChargeHighBasis occupation) : U - R ≤ weight s := + chargePenalty_gap U R V (occupation s.val) hsymm hrow hUR.le (hfill s.val) s.property + exact ⟨diagonalPenalty_inverse_right weight (fun s => ne_of_gt (hg.trans_le (hgap s))), + diagonalPenalty_inverse_norm hg weight hgap, diagonalPenalty_gap weight (U - R) hgap⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DirectionalFourthDerivative.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DirectionalFourthDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..181421fe248deede5f1e22f68596bb8a40ce03e5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/DirectionalFourthDerivative.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombKernelHomogeneity +import Mathlib.Analysis.Calculus.IteratedDeriv.Lemmas + +namespace OAI + +/-! Fourth derivatives along the affine coordinate lines used by cubature. -/ + +noncomputable section +namespace ContinuumCoulomb + +/-- Local smoothness suffices; the function may be singular away from the line point. -/ +theorem fourthDeriv_affine_line (f : Position → ℝ) (b v : Position) (t : ℝ) + (hf : ContDiffAt ℝ 4 f (b+t • v)) : + iteratedDeriv 4 (fun s : ℝ => f (b+s • v)) t = + iteratedFDeriv ℝ 4 f (b+t • v) (fun _ => v) := by + let L : ℝ →L[ℝ] Position := (ContinuousLinearMap.id ℝ ℝ).smulRight v + let g : Position → ℝ := fun z => f (b+z) + have hg : ContDiffAt ℝ 4 g (L t) := + hf.comp (L t) (contDiffAt_const.add contDiffAt_id) + obtain ⟨U,hU,ht,hgU⟩ := hg.contDiffOn' le_rfl (by norm_num) + have hgU : ContDiffOn ℝ 4 g U := by simpa using hgU + have hpre : IsOpen (L ⁻¹' U) := hU.preimage L.continuous + have hgt : ContDiffAt ℝ 4 (g ∘ L) t := hg.comp t L.contDiff.contDiffAt + have h := L.iteratedFDerivWithin_comp_right hgU hU.uniqueDiffOn hpre.uniqueDiffOn ht + (i := 4) le_rfl + rw [iteratedFDerivWithin_eq_iteratedFDeriv hpre.uniqueDiffOn hgt ht, + iteratedFDerivWithin_eq_iteratedFDeriv hU.uniqueDiffOn hg ht] at h + change iteratedFDeriv ℝ 4 (g ∘ L) t (fun _ => 1) = _ + rw [h] + simp only [ContinuousMultilinearMap.compContinuousLinearMap_apply] + have hL (s : ℝ) : L s = s • v := rfl + simp only [hL,one_smul] + change iteratedFDeriv ℝ 4 (fun z => f (b+z)) (t • v) (fun _ => v) = _ + rw [iteratedFDeriv_comp_add_left] + +theorem fourthDeriv_affine_line_bound (f : Position → ℝ) (b v : Position) (t : ℝ) + (hf : ContDiffAt ℝ 4 f (b+t • v)) : + |iteratedDeriv 4 (fun s : ℝ => f (b+s • v)) t| ≤ + ‖iteratedFDeriv ℝ 4 f (b+t • v)‖*‖v‖^4 := by + rw [fourthDeriv_affine_line f b v t hf,← Real.norm_eq_abs] + simpa only [Finset.prod_const,Finset.card_univ,Fintype.card_fin] using + (iteratedFDeriv ℝ 4 f (b+t • v)).le_opNorm (fun _ => v) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExceptionalCellVolume.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExceptionalCellVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4f2d24f175b204bf20dd43f4f8c5677c4a69cc8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExceptionalCellVolume.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCover + +namespace OAI + +/-! Cells meeting the well support have total volume O(m*S), rather than +the volume of the surrounding slab. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem cube_meets_wellCover_subset {b z : Position} {u : PlanarPosition} + {h r S : ℝ} (hh : 0 ≤ h) (hz : z ∈ positionCube b h) + (hzu : z ∈ wellCoverBox u r S) : + positionCube b h ⊆ wellCoverBox u (r+2*h) (S+2*h) := by + intro x hx + have hd := positionCube_diameter_bound hh hx hz + have hi (i : Fin 3) : |x i-z i| ≤ 2*h := by + exact (PiLp.norm_apply_le (x-z) i).trans hd + obtain ⟨hz0,hz1,hz2⟩ := mem_wellCoverBox.mp hzu + apply mem_wellCoverBox.mpr + refine ⟨?_,?_,?_⟩ + · linarith [abs_sub_le (x 0) (z 0) (u 0),hi 0] + · linarith [abs_sub_le (x 1) (z 1) (u 1),hi 1] + · have he := abs_sub_le (x 2) (z 2) 0 + simp only [sub_zero] at he + linarith [hi 2] + +theorem exceptional_cell_volume_bound {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h S : ℝ} (hh : 0 < h) (hh1 : h ≤ 1) (hS : 1 ≤ S) + (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hmeet : ∀ i, ∃ z ∈ positionCube (gaussCellCenter h (index i)) h, + z ∈ tsupport (manufacturedWellField freq scale S u)) : + (Fintype.card ι:ℝ)*h^3 ≤ 216*m*S := by + let A : ι → Set Position := fun i => positionOpenCube (gaussCellCenter h (index i)) h + let B : Fin m → Set Position := fun j => wellCoverBox (u j) (1+2*h) (S+2*h) + have hsub : (⋃ i, A i) ⊆ ⋃ j, B j := by + intro x hx + obtain ⟨i,hi⟩ := Set.mem_iUnion.mp hx + obtain ⟨z,hz,hzs⟩ := hmeet i + obtain ⟨j,hj⟩ := Set.mem_iUnion.mp + (manufacturedWellField_support_cover freq scale (by linarith : 0 < S) u hzs) + exact Set.mem_iUnion.mpr ⟨j,cube_meets_wellCover_subset hh.le hz hj + (positionOpenCube_subset _ _ hi)⟩ + have hBfinite : volume (⋃ j, B j) ≠ ⊤ := by + apply ne_of_lt + apply lt_of_le_of_lt (measure_iUnion_fintype_le volume B) + exact ENNReal.sum_lt_top.mpr (fun j _ => (wellCoverBox_measure_ne_top (u j) _ _).lt_top) + have hA : volume.real (⋃ i, A i) = (Fintype.card ι:ℝ)*h^3 := by + rw [measureReal_iUnion_fintype + (fun i j hij => grid_openCubes_disjoint hh (fun he => hij (hindex he))) + (fun i => positionOpenCube_measurable _ _) + (fun i => by + rw [measure_congr (positionOpenCube_ae_eq (gaussCellCenter h (index i)) h)] + exact (positionCube_isCompact _ hh.le).measure_ne_top)] + simp only [positionOpenCube_volume _ hh.le,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + calc + _ = volume.real (⋃ i, A i) := hA.symm + _ ≤ volume.real (⋃ j, B j) := measureReal_mono hsub hBfinite + _ ≤ 8*m*(1+2*h)^2*(S+2*h) := + wellCover_volume_bound u (by positivity) (by linarith) + _ ≤ 8*m*9*(3*S) := by + gcongr + · nlinarith + · linarith + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExplicitVerticalCutoff.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExplicitVerticalCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..753119fd7fc37a1b9986323411eb037a0211184c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ExplicitVerticalCutoff.lean @@ -0,0 +1,56 @@ +import Mathlib.Analysis.SpecialFunctions.SmoothTransition +import Mathlib.Analysis.Calculus.BumpFunction.Basic + +namespace OAI + +/-! An explicit smooth transverse cutoff. Its formula uses only the fixed +smooth transition function, so rational approximation can use the actual +exponential formula instead of a classically selected bump function. -/ + +noncomputable section +namespace ContinuumCoulomb + +def verticalCutoffBump (z : ℝ) : ℝ := + Real.smoothTransition ((4-z^2)/3) + +namespace verticalCutoffBump + +theorem contDiff {n : ℕ∞} : ContDiff ℝ n verticalCutoffBump := + Real.smoothTransition.contDiff.comp ((contDiff_const.sub (contDiff_id.pow 2)).div_const 3) + +theorem nonneg {z : ℝ} : 0 ≤ verticalCutoffBump z := + Real.smoothTransition.nonneg _ + +theorem le_one {z : ℝ} : verticalCutoffBump z ≤ 1 := + Real.smoothTransition.le_one _ + +theorem one_of_mem_closedBall {z : ℝ} (hz : z ∈ Metric.closedBall (0 : ℝ) 1) : + verticalCutoffBump z = 1 := by + apply Real.smoothTransition.one_of_one_le + have hab : |z| ≤ 1 := by simpa [Metric.mem_closedBall, Real.dist_eq] using hz + have hsq := (sq_le_sq₀ (abs_nonneg z) (by norm_num : (0:ℝ) ≤ 1)).mpr hab + rw [sq_abs] at hsq + linarith + +theorem zero_of_le_dist {z : ℝ} (hz : 2 ≤ dist z 0) : + verticalCutoffBump z = 0 := by + apply Real.smoothTransition.zero_of_nonpos + have hab : 2 ≤ |z| := by simpa [Real.dist_eq] using hz + have hsq := (sq_le_sq₀ (by norm_num : (0:ℝ) ≤ 2) (abs_nonneg z)).mpr hab + rw [sq_abs] at hsq + linarith + +theorem hasCompactSupport : HasCompactSupport verticalCutoffBump := by + apply (isCompact_closedBall (0 : ℝ) 2).of_isClosed_subset (isClosed_tsupport _) + apply closure_minimal _ Metric.isClosed_closedBall + intro z hz + by_contra hn + have hd : 2 ≤ dist z 0 := (lt_of_not_ge (by simpa [Metric.mem_closedBall] using hn)).le + exact hz (zero_of_le_dist hd) + +end verticalCutoffBump +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullSpinTensorCoefficients.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullSpinTensorCoefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e16119513282989c3bdad2c967be7c8d0567a1e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullSpinTensorCoefficients.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorProjection +import OAI.Analysis.CoulombRadii.FormDomain.SmoothCompact +import OAI.Analysis.CoulombRadii.FieldAnalysis.WedgeMultiplicity +import OAI.Analysis.CoulombRadii.FieldAnalysis.PairRegroup + +namespace OAI + +/-! Full spin-space coordinates preserve the actual tensor coefficients +and antisymmetry. No restriction to a fixed spin sector is made. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem spinConfiguration_complex_integral {n : ℕ} + (F : SpinConfiguration n → Configuration n → ℂ) (hF : ∀ s, Integrable (F s)) : + (∫ z, F ((Coulomb.spinCubeEquiv n) z).1 (WithLp.toLp 2 ((Coulomb.spinCubeEquiv n) z).2) + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure)) = ∑ s, ∫ x, F s x := by + rw [(Coulomb.spinCubeEquiv_full_measurePreserving n).integral_comp' + (fun sx => F sx.1 (WithLp.toLp 2 sx.2))] + have hm : MeasurePreserving (MeasurableEquiv.toLp 2 ((Fin n × Fin 3) → ℝ)) volume volume := + PiLp.volume_preserving_toLp _ + rw [Coulomb.integral_finite_count_prod _ (fun s => hm.integrable_comp_of_integrable (hF s))] + apply Finset.sum_congr rfl + intro s _ + exact hm.integral_comp' (F s) + +theorem fullSpin_scalarCoefficient {n : ℕ} {α : Type*} + (u : Coulomb.H1Vector n) (v : α → Position → Fin 2 → ℂ) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) (b : Fin n → α) : + Coulomb.scalarCoefficient (μ := Coulomb.spinSpaceMeasure) (Coulomb.cubeState u) + (fun a => Coulomb.flatSpinOrbital (v a)) b = Coulomb.orbitalCoefficient u v b := by + have h := spinConfiguration_complex_integral + (fun s x => star (Coulomb.tensorOrbital v b s x)*u.value s x) + (fun s => (Coulomb.tensorOrbital_memLp v hL2 b s).star.integrable_mul (u.value_L2 s)) + exact h + +theorem fullSpin_antisymmetric {n : ℕ} (u : Coulomb.H1Vector n) + (hu : Coulomb.Antisymmetric u) : + Coulomb.ProductAntisymmetric (μ := Coulomb.spinSpaceMeasure) (Coulomb.cubeState u) := by + intro p + have hs (s : SpinConfiguration n) : ∀ᵐ x ∂volume, + u.value (s ∘ p) (Coulomb.permute p (WithLp.toLp 2 x)) = + ((p.sign : ℤ):ℂ)*u.value s (WithLp.toLp 2 x) := + (PiLp.volume_preserving_toLp (Fin n × Fin 3)).quasiMeasurePreserving.ae (hu p s) + have hp := (Measure.quasiMeasurePreserving_snd + (μ := (Measure.count : Measure (SpinConfiguration n)))).ae (ae_all_iff.mpr hs) + have ht := (Coulomb.spinCubeEquiv_full_measurePreserving n).quasiMeasurePreserving.ae hp + filter_upwards [ht] with z hz + exact hz (fun i => (z i).1) + +theorem finiteTensorRemainder_antisymmetric {n : ℕ} {α : Type*} [Fintype α] + (v : α → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x + (EuclideanSpace.single b 1)) 2) (u : Coulomb.H1Vector n) (hu : Coulomb.Antisymmetric u) : + Coulomb.Antisymmetric (finiteTensorRemainder v hv hL2 hpartial u) := + hu.add (Coulomb.antisymmetric_scale _ (finiteTensorProjection_antisymmetric v hv hL2 hpartial u hu) _) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullTensorComplement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullTensorComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a62237e88fef578ae1c41bcab6001d456d7c119 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/FullTensorComplement.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.FullSpinTensorCoefficients +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteOrbitalComplement + +namespace OAI + +/-! The actual antisymmetric H1 remainder has a missing orbital occupation +on the full spin-space product measure. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical ENNReal +namespace ContinuumCoulomb + +theorem finiteTensorRemainder_flat_occupation {m n : ℕ} + (v : Fin m → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x + (EuclideanSpace.single b 1)) 2) + (ho : ∀ a b, (∑ t : Fin 2, ∫ y, star (v a y t)*v b y t) = + if a=b then (1:ℂ) else 0) (u : Coulomb.H1Vector (n+1)) (hu : Coulomb.Antisymmetric u) : + let q := finiteTensorRemainder v hv hL2 hpartial u + (n+1:ℕ)*(∑ a, ∫ y, ‖Coulomb.fiberContract (μ := Coulomb.spinSpaceMeasure) + (Coulomb.flatSpinOrbital (v a)) (Coulomb.firstFiber (Coulomb.cubeState q)) y‖^2 + ∂(Measure.pi fun _ : Fin n => Coulomb.spinSpaceMeasure)) ≤ (n:ℝ)*Coulomb.mass q := by + let : Fact ((2:ℝ≥0∞) ≠ ⊤) := ⟨by norm_num⟩ + let q := finiteTensorRemainder v hv hL2 hpartial u + have hflat (a b : Fin m) : + (∫ x, star (Coulomb.flatSpinOrbital (v a) x)*Coulomb.flatSpinOrbital (v b) x + ∂Coulomb.spinSpaceMeasure) = if a=b then (1:ℂ) else 0 := by + rw [Coulomb.flatSpinOrbital_inner _ _ (hL2 a) (hL2 b)] + exact ho a b + have hz (b : Fin (n+1) → Fin m) : + Coulomb.scalarCoefficient (μ := Coulomb.spinSpaceMeasure) (Coulomb.cubeState q) + (fun a => Coulomb.flatSpinOrbital (v a)) b = 0 := by + rw [fullSpin_scalarCoefficient q v hL2 b,Coulomb.orbitalCoefficient_eq_inner q v hL2 b] + exact finiteTensorRemainder_orthogonal v hv hL2 hpartial (by + intro i j + by_cases hij : i=j <;> simpa only [hij,ite_true,ite_false] using ho i j) u b + have h := finite_orbital_complement_bound (fun a => Coulomb.flatSpinOrbital (v a)) + (fun a => Coulomb.flatSpinOrbital_memLp (v a) (hL2 a)) hflat (Coulomb.cubeState q) + q.cubeState_full_memLp (fullSpin_antisymmetric q (finiteTensorRemainder_antisymmetric v hv hL2 hpartial u hu)) hz + simpa only [Coulomb.cubeState_full_mass] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianFrequency.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianFrequency.lean new file mode 100644 index 0000000000000000000000000000000000000000..52d3b3b6b71f8a276bc1db3d0e632a47aed589f3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianFrequency.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PiProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ResolventNumericalBounds + +namespace OAI + +/-! Certified approximation of the manuscript's actual transverse frequency +`sqrt (4*pi*rho)`. The integer density is fixed once for the construction; +it is not assumed that the resulting frequency is rational. -/ + +noncomputable section +namespace ContinuumCoulomb.GaussianFrequency +open scoped BigOperators + +def frequency (rho : ℕ) : ℝ := Real.sqrt (4 * Real.pi * (rho : ℝ)) + +def count (rho P : ℕ) : ℕ := 512 * (rho + 1) * (P + 1) ^ 2 + +def precision (P : ℕ) : ℕ := 8 * (P + 1) + +def radicand (rho P : ℕ) : ℚ := 4 * (rho : ℚ) * PiProgram.approximate (count rho P) + +def approximate (rho P : ℕ) : ℚ := RationalSquareRoot.value (precision P, radicand rho P) + +theorem count_positive (rho P : ℕ) : 0 < count rho P := by unfold count; positivity + +theorem pi_approximate_nonnegative (N : ℕ) : 0 ≤ PiProgram.approximate N := by + unfold PiProgram.approximate RationalQuadratureProgram.value + apply mul_nonneg (by norm_num) + apply mul_nonneg (by dsimp [PiProgram.input]; positivity) + apply Finset.sum_nonneg + intro i _ + dsimp [RationalQuadratureProgram.sample, PiProgram.evaluate] + positivity + +theorem radicand_nonnegative (rho P : ℕ) : 0 ≤ radicand rho P := by + unfold radicand + exact mul_nonneg (by positivity) (pi_approximate_nonnegative _) + +theorem radicand_error (rho P : ℕ) : + |(radicand rho P : ℝ) - 4 * Real.pi * (rho : ℝ)| ≤ + ((4 * ((P : ℝ) + 1))⁻¹) ^ 2 := by + let S := (P : ℝ) + 1 + have hS : 0 < S := by dsimp [S]; positivity + have hrho : (0 : ℝ) ≤ rho := Nat.cast_nonneg _ + have hp := PiProgram.error (count rho P) (count_positive rho P) + have he : (radicand rho P : ℝ) - 4 * Real.pi * (rho : ℝ) = + 4 * (rho : ℝ) * ((PiProgram.approximate (count rho P) : ℝ) - Real.pi) := by + simp only [radicand, Rat.cast_mul, Rat.cast_ofNat, Rat.cast_natCast] + ring + rw [he, abs_mul, abs_of_nonneg (by positivity : 0 ≤ 4 * (rho : ℝ))] + apply (mul_le_mul_of_nonneg_left hp (by positivity)).trans + have hc : (count rho P : ℝ) = 512 * ((rho : ℝ) + 1) * S ^ 2 := by + dsimp [count, S] + push_cast + rfl + rw [hc] + calc + 4 * (rho : ℝ) * (8 / (512 * ((rho : ℝ) + 1) * S ^ 2)) ≤ + 4 * ((rho : ℝ) + 1) * (8 / (512 * ((rho : ℝ) + 1) * S ^ 2)) := by + gcongr + linarith + _ = ((4 * S)⁻¹) ^ 2 := by + field_simp [hS.ne', show (rho : ℝ) + 1 ≠ 0 by positivity] + ring + +theorem root_precision_bound (P : ℕ) : + (2 : ℝ)⁻¹ ^ precision P ≤ (4 * ((P : ℝ) + 1))⁻¹ := by + have hn : 4 * (P + 1) ≤ 2 ^ precision P := by + have hh := ResolventSchedule.succ_le_two_pow (precision P) + unfold precision at * + omega + have hr : 4 * ((P : ℝ) + 1) ≤ (2 : ℝ) ^ precision P := by exact_mod_cast hn + rw [inv_pow] + exact inv_anti₀ (by positivity) hr + +theorem approximation_error (rho P : ℕ) : + |(approximate rho P : ℝ) - frequency rho| ≤ ((P : ℝ) + 1)⁻¹ := by + let S := (P : ℝ) + 1 + have hS : 0 < S := by dsimp [S]; positivity + have hsqrt := RationalSquareRoot.sqrt_perturbation + (show 0 ≤ (radicand rho P : ℝ) by exact_mod_cast radicand_nonnegative rho P) + (show 0 ≤ 4 * Real.pi * (rho : ℝ) by positivity) + have hquad := Real.sqrt_le_sqrt (radicand_error rho P) + rw [Real.sqrt_sq_eq_abs, abs_of_pos (by positivity : 0 < (4 * ((P : ℝ) + 1))⁻¹)] at hquad + have hnum := RationalSquareRoot.value_error (precision P) (radicand_nonnegative rho P) + have h := (abs_sub_le (approximate rho P : ℝ) (Real.sqrt (radicand rho P : ℝ)) + (frequency rho)).trans (add_le_add (hnum.trans (root_precision_bound P)) (hsqrt.trans hquad)) + apply h.trans + change (4 * S)⁻¹ + (4 * S)⁻¹ ≤ S⁻¹ + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr hS] + +end ContinuumCoulomb.GaussianFrequency + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianJetBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianJetBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3419a53a647fa44351e245ba8e9df5764030ec2f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianJetBounds.lean @@ -0,0 +1,132 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalMode + +namespace OAI + +/-! Uniform fourth-order bounds for the actual normalized transverse +Gaussian. Polynomial Gaussian moments bound each explicit derivative. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem power_exponential_bound (k : ℕ) {a t : ℝ} (ha : 0 < a) (ht : 0 ≤ t) : + t^k*Real.exp (-a*t) ≤ (k.factorial:ℝ)/a^k := by + have hf : 0 < (k.factorial:ℝ) := Nat.cast_pos.mpr (Nat.factorial_pos k) + have he := Real.pow_div_factorial_le_exp (a*t) (mul_nonneg ha.le ht) k + have hid : ((a*t)^k/(k.factorial:ℝ))*((k.factorial:ℝ)/a^k) = t^k := by + rw [mul_pow] + field_simp + have hb := mul_le_mul_of_nonneg_right he (show 0 ≤ (k.factorial:ℝ)/a^k by positivity) + rw [hid] at hb + have hb' := mul_le_mul_of_nonneg_right hb (Real.exp_pos (-a*t)).le + have hc : (Real.exp (a*t)*((k.factorial:ℝ)/a^k))*Real.exp (-a*t) = (k.factorial:ℝ)/a^k := by + rw [mul_right_comm,← Real.exp_add] + simp + exact hb'.trans_eq hc + +theorem verticalMode_monomial_bound {freq : ℝ} (hfreq : 0 < freq) (k : ℕ) (z : ℝ) : + |z|^k*‖verticalMode freq z‖ ≤ + (1+(k.factorial:ℝ)/(freq/2)^k)/Real.sqrt (Real.sqrt (Real.pi/freq)) := by + have hd : 0 < Real.sqrt (Real.sqrt (Real.pi/freq)) := by positivity + have hp : |z|^k ≤ 1+z^(2*k) := by + by_cases hz : |z| ≤ 1 + · have ht := pow_le_pow_left₀ (abs_nonneg z) hz k + simp only [one_pow] at ht + linarith [pow_nonneg (sq_nonneg z) k,show z^(2*k) = (z^2)^k by rw [pow_mul]] + · have ht := pow_le_pow_right₀ (le_of_not_ge hz) (show k ≤ 2*k by omega) + rw [pow_mul,sq_abs,← pow_mul] at ht + linarith + have hg := power_exponential_bound k (show 0 < freq/2 by positivity) (sq_nonneg z) + have hh := mul_le_mul_of_nonneg_right hp (Real.exp_pos (-(freq/2)*z^2)).le + have he : Real.exp (-(freq/2)*z^2) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg z]) + have hb : |z|^k*Real.exp (-(freq/2)*z^2) ≤ 1+(k.factorial:ℝ)/(freq/2)^k := by + rw [add_mul,one_mul] at hh + rw [← pow_mul] at hg + linarith + rw [Real.norm_of_nonneg (verticalMode_positive hfreq z).le,verticalMode] + have harg : -freq*z^2/2 = -(freq/2)*z^2 := by ring + rw [harg,← mul_div_assoc] + exact div_le_div_of_nonneg_right hb hd.le + +theorem verticalMode_third_hasDerivAt (freq z : ℝ) : + HasDerivAt (deriv (deriv (verticalMode freq))) + ((3*freq^2*z-freq^3*z^3)*verticalMode freq z) z := by + rw [show deriv (deriv (verticalMode freq)) = + (fun x => (freq^2*x^2-freq)*verticalMode freq x) from funext (verticalMode_second_deriv freq)] + convert (((((hasDerivAt_id z).pow 2).const_mul (freq^2)).sub_const freq).mul + (verticalMode_hasDerivAt freq z)) using 1 <;> (try funext x) <;> + (simp only [id_eq,Pi.mul_apply,Pi.pow_apply,Nat.cast_ofNat,Nat.reduceSub,pow_one,mul_one]; all_goals ring) + +theorem verticalMode_third_deriv (freq z : ℝ) : + deriv (deriv (deriv (verticalMode freq))) z = + (3*freq^2*z-freq^3*z^3)*verticalMode freq z := + (verticalMode_third_hasDerivAt freq z).deriv + +theorem verticalMode_fourth_hasDerivAt (freq z : ℝ) : + HasDerivAt (deriv (deriv (deriv (verticalMode freq)))) + ((3*freq^2-6*freq^3*z^2+freq^4*z^4)*verticalMode freq z) z := by + rw [show deriv (deriv (deriv (verticalMode freq))) = + (fun x => (3*freq^2*x-freq^3*x^3)*verticalMode freq x) from funext (verticalMode_third_deriv freq)] + convert ((((hasDerivAt_id z).const_mul (3*freq^2)).sub + (((hasDerivAt_id z).pow 3).const_mul (freq^3))).mul + (verticalMode_hasDerivAt freq z)) using 1 <;> (try funext x) <;> + (simp only [id_eq,Pi.sub_apply,Pi.mul_apply,Pi.pow_apply,Nat.cast_ofNat,Nat.reduceSub,mul_one]; all_goals ring) + +theorem verticalMode_fourth_deriv (freq z : ℝ) : + deriv (deriv (deriv (deriv (verticalMode freq)))) z = + (3*freq^2-6*freq^3*z^2+freq^4*z^4)*verticalMode freq z := + (verticalMode_fourth_hasDerivAt freq z).deriv + +private def verticalHermiteCoeffs (freq : ℝ) : Fin 5 → Fin 5 → ℝ := + ![![1,0,0,0,0],![0,-freq,0,0,0],![-freq,0,freq^2,0,0], + ![0,3*freq^2,0,-freq^3,0],![3*freq^2,0,-6*freq^3,0,freq^4]] + +private theorem verticalMode_iteratedDeriv (freq z : ℝ) (k : Fin 5) : + iteratedDeriv k.val (verticalMode freq) z = + (∑ j : Fin 5, verticalHermiteCoeffs freq k j*z^(j:ℕ))*verticalMode freq z := by + fin_cases k <;> + simp [verticalHermiteCoeffs,Fin.sum_univ_succ,iteratedDeriv_succ,iteratedDeriv_zero, + verticalMode_deriv,verticalMode_second_deriv,verticalMode_third_deriv,verticalMode_fourth_deriv] <;> ring_nf <;> simp + +theorem vertical_mode_jets_bounded {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ k : ℕ, k ≤ 4 → ∀ z, + ‖iteratedFDeriv ℝ k (verticalMode freq) z‖ ≤ B := by + let P (k : Fin 5) : ℝ := + (1+(k.val.factorial:ℝ)/(freq/2)^k.val)/Real.sqrt (Real.sqrt (Real.pi/freq)) + have hP (k : Fin 5) : 0 ≤ P k := by dsimp [P]; positivity + let M := ∑ k : Fin 5, P k + have hM : 0 ≤ M := Finset.sum_nonneg (fun k _ => hP k) + let A (k : Fin 5) : ℝ := ∑ j : Fin 5, |verticalHermiteCoeffs freq k j| + have hA (k : Fin 5) : 0 ≤ A k := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + let B := M*(∑ k : Fin 5, A k)+1 + have hB : 1 ≤ B := by + dsimp [B] + have hs : 0 ≤ ∑ k : Fin 5, A k := Finset.sum_nonneg (fun k _ => hA k) + nlinarith [mul_nonneg hM hs] + refine ⟨B,hB,fun k hk z => ?_⟩ + let i : Fin 5 := ⟨k,by omega⟩ + have hm (j : Fin 5) : |z|^(j:ℕ)*‖verticalMode freq z‖ ≤ M := + (verticalMode_monomial_bound hfreq j.val z).trans + (Finset.single_le_sum (fun j _ => hP j) (Finset.mem_univ j)) + rw [norm_iteratedFDeriv_eq_norm_iteratedDeriv] + change ‖iteratedDeriv i.val (verticalMode freq) z‖ ≤ B + rw [verticalMode_iteratedDeriv,norm_mul] + calc + _ ≤ (∑ j : Fin 5, ‖verticalHermiteCoeffs freq i j*z^(j:ℕ)‖)*‖verticalMode freq z‖ := + mul_le_mul_of_nonneg_right (norm_sum_le _ _) (norm_nonneg _) + _ = ∑ j : Fin 5, |verticalHermiteCoeffs freq i j| *(|z|^(j:ℕ)*‖verticalMode freq z‖) := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j _ + rw [norm_mul,Real.norm_eq_abs,norm_pow,Real.norm_eq_abs,mul_assoc] + _ ≤ ∑ j : Fin 5, |verticalHermiteCoeffs freq i j| *M := + Finset.sum_le_sum (fun j _ => mul_le_mul_of_nonneg_left (hm j) (abs_nonneg _)) + _ = A i*M := (Finset.sum_mul _ _ _).symm + _ ≤ (∑ j : Fin 5, A j)*M := + mul_le_mul_of_nonneg_right (Finset.single_le_sum (fun j _ => hA j) (Finset.mem_univ i)) hM + _ ≤ B := by dsimp [B]; nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianLine.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianLine.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4a3aa976d9871dc30097ef438212a21eedab321 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianLine.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianPoincare +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalMode + +namespace OAI + +/-! Identifying the one-dimensional Euclidean Gaussian form with the real +line. This fixes the normalization and derivative constants for the oscillator. -/ + +noncomputable section +open MeasureTheory +open scoped Topology ContDiff +namespace ContinuumCoulomb +open LeanBlast.KLS + +def gaussianLineEquiv : Space 1 ≃ₗᵢ[ℝ] ℝ where + toLinearEquiv := (PiLp.equivOfUnique 2 ℝ (fun _ : Fin 1 => ℝ)).toLinearEquiv + norm_map' x := by + change ‖x 0‖ = ‖x‖ + have h : ‖x‖^2 = (x 0)^2 := by + simpa only [Fin.sum_univ_one] using EuclideanSpace.real_norm_sq_eq x + rw [Real.norm_eq_abs] + nlinarith [sq_abs (x 0),norm_nonneg x,abs_nonneg (x 0)] + +@[simp] theorem gaussianLineEquiv_apply (x : Space 1) : gaussianLineEquiv x=x 0 := rfl + +theorem gaussianLine_integral (f : ℝ → ℝ) : + (∫ x : Space 1, f (gaussianLineEquiv x)) = ∫ y : ℝ, f y := + gaussianLineEquiv.measurePreserving.integral_comp + gaussianLineEquiv.toHomeomorph.measurableEmbedding f + +theorem gaussianLine_norm_sq (x : Space 1) : ‖x‖^2=(gaussianLineEquiv x)^2 := by + rw [← gaussianLineEquiv.norm_map,Real.norm_eq_abs,sq_abs] + +theorem gaussianLine_gradient_sq {f : ℝ → ℝ} (hf : Differentiable ℝ f) (x : Space 1) : + ‖gradient (fun y => f (gaussianLineEquiv y)) x‖^2 = + (deriv f (gaussianLineEquiv x))^2 := by + have hd := ((hf (gaussianLineEquiv x)).hasDerivAt.hasFDerivAt.comp x + gaussianLineEquiv.toContinuousLinearEquiv.toContinuousLinearMap.hasFDerivAt).fderiv + change ‖(InnerProductSpace.toDual ℝ (Space 1)).symm + (fderiv ℝ (f ∘ gaussianLineEquiv) x)‖^2 = _ + rw [hd] + rw [(InnerProductSpace.toDual ℝ (Space 1)).symm.norm_map] + have hder : (ContinuousLinearMap.toSpanSingleton ℝ (deriv f (gaussianLineEquiv x))).comp + gaussianLineEquiv.toContinuousLinearEquiv.toContinuousLinearMap = + deriv f (gaussianLineEquiv x) • gaussianLineEquiv.toContinuousLinearEquiv.toContinuousLinearMap := by + ext y + simp + ring + rw [hder,norm_smul,gaussianLineEquiv.norm_toContinuousLinearMap] + simp [sq_abs] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianMollification.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianMollification.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fbf967c9f6eab5fabded03706bd568774b3bd67 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianMollification.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianScalar +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScalarMollification + +namespace OAI + +/-! Passing the proved Gaussian Poincare inequality to compact C¹ tests. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology ContDiff +namespace ContinuumCoulomb + +theorem gaussian_mollification_power_tendsto {freq : ℝ} (hf : 0 < freq) + (f : ℝ → ℝ) (hs : Continuous f) (hc : HasCompactSupport f) (p : ℕ) : + Tendsto (fun k => ∫ z : ℝ, verticalMode freq z^2*(scalarMollification f k z)^p) + atTop (𝓝 (∫ z : ℝ, verticalMode freq z^2*f z^p)) := by + obtain ⟨C,hC⟩ := hs.bounded_above_of_compact_support hc + apply tendsto_integral_of_dominated_convergence + (fun z => verticalMode freq z^2*C^p) + · intro k + exact (((verticalMode_smooth freq).continuous.pow 2).mul + ((scalarMollification_smooth hs k).continuous.pow p)).aestronglyMeasurable + · exact (verticalMode_square_integrable hf).mul_const _ + · intro k + apply Filter.Eventually.of_forall + intro z + have hb := pow_le_pow_left₀ (norm_nonneg (scalarMollification f k z)) + (scalarMollification_bound hC k z) p + simpa only [norm_mul,norm_pow,Real.norm_eq_abs,sq_abs] using + mul_le_mul_of_nonneg_left hb (sq_nonneg (verticalMode freq z)) + · exact Filter.Eventually.of_forall fun z => + ((scalarMollification_tendsto hs z).pow p).const_mul _ + +/-- The normalized Gaussian Poincare inequality on the exact C¹ test domain. -/ +theorem gaussian_scalar_poincare {freq : ℝ} (hf : 0 < freq) + (f : ℝ → ℝ) (hs : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + (2*freq)*((∫ z : ℝ, verticalMode freq z^2*f z^2) - + (∫ z : ℝ, verticalMode freq z^2*f z)^2) ≤ + ∫ z : ℝ, verticalMode freq z^2*(deriv f z)^2 := by + have h2 := gaussian_mollification_power_tendsto hf f hs.continuous hc 2 + have h1 := gaussian_mollification_power_tendsto hf f hs.continuous hc 1 + simp only [pow_one] at h1 + have hd := gaussian_mollification_power_tendsto hf (deriv f) + (hs.continuous_deriv (by norm_num)) hc.deriv 2 + apply le_of_tendsto_of_tendsto ((h2.sub (h1.pow 2)).const_mul (2*freq)) hd + apply Filter.Eventually.of_forall + intro k + have h := gaussian_scalar_poincare_smooth hf (scalarMollification f k) + (scalarMollification_smooth hs.continuous k) (scalarMollification_compact hc k) + simpa only [scalarMollification_deriv hs hc] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPacket.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPacket.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a294890e73e1ebd96531f0cb92339f386124ae1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPacket.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianFrequencyProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalClamp +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalExponentialProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatKernelModulus + +namespace OAI + +/-! A certified rational sample of the actual transverse Gaussian. The +frequency is sqrt(4*pi*rho), with rho fixed, and is evaluated internally. -/ + +noncomputable section +namespace ContinuumCoulomb.GaussianPacket + +abbrev Input := (ℕ × ℕ) × ℚ + +def frequencyPrecision (R P : ℕ) : ℕ := 16 * (R + 1) ^ 2 * (P + 1) +def exponentialPrecision (P : ℕ) : ℕ := 8 * (P + 1) +def magnitude (rho R : ℕ) : ℕ := (4 * rho + 4) * (R + 1) ^ 2 + +def exponent (rho : ℕ) (x : Input) : ℚ := + -GaussianFrequency.approximate rho (frequencyPrecision x.1.1 x.1.2) * x.2 ^ 2 + +def argument (rho : ℕ) (x : Input) : RationalExponentialProgram.Input := + (magnitude rho x.1.1, (exponentialPrecision x.1.2, exponent rho x)) + +def approximate (rho : ℕ) (x : Input) : ℚ := + rationalUnitClamp (RationalExponentialProgram.approximate (argument rho x)) + +theorem frequencyApprox_nonnegative (rho P : ℕ) : + 0 ≤ GaussianFrequency.approximate rho P := by + unfold GaussianFrequency.approximate RationalSquareRoot.value DyadicRootProgram.value + positivity + +theorem frequency_le (rho : ℕ) : GaussianFrequency.frequency rho ≤ 4 * (rho : ℝ) + 2 := by + unfold GaussianFrequency.frequency + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · have hpi := Real.pi_lt_four + nlinarith [sq_nonneg (rho : ℝ), show (0 : ℝ) ≤ rho from Nat.cast_nonneg _] + +theorem frequencyApprox_le (rho P : ℕ) : + (GaussianFrequency.approximate rho P : ℝ) ≤ 4 * (rho : ℝ) + 3 := by + have h := (abs_le.mp (GaussianFrequency.approximation_error rho P)).2 + have hp : ((P : ℝ) + 1)⁻¹ ≤ 1 := + (inv_le_one₀ (by positivity)).mpr (by linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _]) + linarith [frequency_le rho] + +theorem exponent_nonpositive (rho : ℕ) (x : Input) : (exponent rho x : ℝ) ≤ 0 := by + simp only [exponent, Rat.cast_mul, Rat.cast_neg, Rat.cast_pow] + exact mul_nonpos_of_nonpos_of_nonneg + (neg_nonpos.mpr (by exact_mod_cast frequencyApprox_nonnegative rho _)) (sq_nonneg _) + +theorem exponent_abs_le (rho : ℕ) (x : Input) (hz : |(x.2 : ℝ)| ≤ x.1.1) : + |(exponent rho x : ℝ)| ≤ (magnitude rho x.1.1 : ℝ) := by + rw [abs_of_nonpos (exponent_nonpositive rho x)] + simp only [exponent, Rat.cast_mul, Rat.cast_neg, Rat.cast_pow, neg_mul, neg_neg] + have hz'' : (x.2 : ℝ) ^ 2 ≤ ((x.1.1 : ℝ) + 1) ^ 2 := by + have habs := (sq_le_sq₀ (abs_nonneg _) (Nat.cast_nonneg _)).mpr hz + rw [sq_abs] at habs + nlinarith [show (0 : ℝ) ≤ x.1.1 from Nat.cast_nonneg _] + calc + _ ≤ (4 * (rho : ℝ) + 3) * (((x.1.1 : ℝ) + 1) ^ 2) := + mul_le_mul (frequencyApprox_le rho _) hz'' (sq_nonneg _) + (by positivity) + _ ≤ _ := by + simp only [magnitude, Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, Nat.cast_pow, Nat.cast_one] + nlinarith [sq_nonneg ((x.1.1 : ℝ) + 1)] + +theorem exponent_error (rho : ℕ) (x : Input) (hz : |(x.2 : ℝ)| ≤ x.1.1) : + |(exponent rho x : ℝ) - (-GaussianFrequency.frequency rho * (x.2 : ℝ) ^ 2)| ≤ + (8 * ((x.1.2 : ℝ) + 1))⁻¹ := by + have hfreq := GaussianFrequency.approximation_error rho (frequencyPrecision x.1.1 x.1.2) + have hzsq : (x.2 : ℝ) ^ 2 ≤ ((x.1.1 : ℝ) + 1) ^ 2 := by + have habs := (sq_le_sq₀ (abs_nonneg _) (Nat.cast_nonneg _)).mpr hz + rw [sq_abs] at habs + nlinarith [show (0 : ℝ) ≤ x.1.1 from Nat.cast_nonneg _] + have he : (exponent rho x : ℝ) - (-GaussianFrequency.frequency rho * (x.2 : ℝ) ^ 2) = + -(GaussianFrequency.approximate rho (frequencyPrecision x.1.1 x.1.2) - + GaussianFrequency.frequency rho) * (x.2 : ℝ) ^ 2 := by + simp only [exponent, Rat.cast_mul, Rat.cast_neg, Rat.cast_pow] + ring + rw [he, abs_mul, abs_neg, abs_of_nonneg (sq_nonneg (x.2 : ℝ))] + apply (mul_le_mul hfreq hzsq (sq_nonneg _) (by positivity)).trans + have hR : 0 < ((x.1.1 : ℝ) + 1) ^ 2 := by positivity + have hP : 0 < (x.1.2 : ℝ) + 1 := by positivity + have hprec : (frequencyPrecision x.1.1 x.1.2 : ℝ) = + 16 * ((x.1.1 : ℝ) + 1) ^ 2 * ((x.1.2 : ℝ) + 1) := by + simp only [frequencyPrecision, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, + Nat.cast_one, Nat.cast_pow] + rw [hprec] + calc + _ ≤ (16 * ((x.1.1 : ℝ) + 1) ^ 2 * ((x.1.2 : ℝ) + 1))⁻¹ * + ((x.1.1 : ℝ) + 1) ^ 2 := by gcongr; linarith + _ = (16 * ((x.1.2 : ℝ) + 1))⁻¹ := by + field_simp [hR.ne', hP.ne'] + _ ≤ _ := inv_anti₀ (by positivity) (by nlinarith) + +theorem exponential_precision_bound (P : ℕ) : + (2 : ℝ)⁻¹ ^ exponentialPrecision P ≤ (8 * ((P : ℝ) + 1))⁻¹ := by + have hn := ResolventSchedule.succ_le_two_pow (exponentialPrecision P) + have hp : 8 * (P + 1) ≤ 2 ^ exponentialPrecision P := by unfold exponentialPrecision at *; omega + have hr : 8 * ((P : ℝ) + 1) ≤ (2 : ℝ) ^ exponentialPrecision P := by exact_mod_cast hp + rw [inv_pow] + exact inv_anti₀ (by positivity) hr + +theorem approximation_error (rho : ℕ) (x : Input) (hz : |(x.2 : ℝ)| ≤ x.1.1) : + |(approximate rho x : ℝ) - Real.exp (-GaussianFrequency.frequency rho * (x.2 : ℝ) ^ 2)| ≤ + ((x.1.2 : ℝ) + 1)⁻¹ := by + have ht := RationalExponentialProgram.error (argument rho x) (exponent_abs_le rho x hz) + rw [abs_sub_comm] at ht + have hprec := exponential_precision_bound x.1.2 + rw [inv_pow] at hprec + have htaylor := ht.trans hprec + have harg : -GaussianFrequency.frequency rho * (x.2 : ℝ) ^ 2 ≤ 0 := + mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Real.sqrt_nonneg _)) (sq_nonneg _) + have hexp := HeatKernelModulus.exp_nonpositive_lipschitz (exponent_nonpositive rho x) harg + have hbase := (abs_sub_le (RationalExponentialProgram.approximate (argument rho x) : ℝ) + (Real.exp (exponent rho x : ℝ)) + (Real.exp (-GaussianFrequency.frequency rho * (x.2 : ℝ) ^ 2))).trans + (add_le_add htaylor + (hexp.trans (exponent_error rho x hz))) + apply (rationalUnitClamp_error _ (Real.exp_pos _).le + (Real.exp_le_one_iff.mpr harg)).trans + apply hbase.trans + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr (show 0 < (x.1.2 : ℝ) + 1 by positivity)] + +end ContinuumCoulomb.GaussianPacket + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPoincare.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPoincare.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9a527a982678ea7de34cd31f766ec101abbb990 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianPoincare.lean @@ -0,0 +1,69 @@ +import OAI.Analysis.KLS.Spectral.RegularPoincare +import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform + +namespace OAI + +/-! One-dimensional Gaussian Poincare inequality derived from the +Brascamp–Lieb theorem. This is the spectral input needed for the +transverse oscillator; no spectral assertion is assumed here. -/ + +noncomputable section +open MeasureTheory +open scoped Topology ContDiff +namespace ContinuumCoulomb +open LeanBlast.KLS + +private def gaussianPotential (freq : ℝ) (x : Space 1) : ℝ := freq*‖x‖^2 + +private theorem gaussianPotential_derivative (freq : ℝ) : + fderiv ℝ (gaussianPotential freq) = + ⇑((2*freq) • (innerSL ℝ (E := Space 1))) := by + funext x + have h := ((hasStrictFDerivAt_norm_sq x).hasFDerivAt.const_mul freq).fderiv + change fderiv ℝ (fun y : Space 1 => freq*‖y‖^2) x = _ + rw [h] + ext v + simp only [smul_apply,two_smul,add_apply,smul_eq_mul] + ring + +private theorem gaussianPotential_hessian (freq : ℝ) (x v : Space 1) : + fderiv ℝ (fderiv ℝ (gaussianPotential freq)) x v v = (2*freq)*‖v‖^2 := by + rw [gaussianPotential_derivative] + rw [(((2*freq) • (innerSL ℝ (E := Space 1))).hasFDerivAt (x := x)).fderiv] + change (2*freq)*inner ℝ v v = (2*freq)*‖v‖^2 + rw [real_inner_self_eq_norm_sq] + +private theorem gaussianPotential_regular {freq : ℝ} (hf : 0 < freq) : + IsRegularPotential (gaussianPotential freq) (2*freq) (2*freq) where + contDiff := contDiff_const.mul (contDiff_norm_sq ℝ) + lower_pos := by positivity + le_upper := le_rfl + lower_bound x v := (gaussianPotential_hessian freq x v).ge + upper_bound x v := (gaussianPotential_hessian freq x v).le + +private theorem gaussianPotential_integrable {freq : ℝ} (hf : 0 < freq) : + Integrable (fun x => Real.exp (-gaussianPotential freq x)) := by + have h := GaussianFourier.integrable_cexp_neg_mul_sq_norm_add + (V := Space 1) (b := (freq:ℂ)) (by simpa using hf) 0 0 + have hc : Integrable (fun x : Space 1 => Complex.exp ((-freq*‖x‖^2:ℝ):ℂ)) := by + simpa only [zero_mul,add_zero,Complex.ofReal_mul,Complex.ofReal_neg, + Complex.ofReal_pow] using h + simpa only [Complex.norm_exp,Complex.ofReal_re,gaussianPotential,neg_mul] using hc.norm + +theorem gaussian_weight_integrable {freq : ℝ} (hf : 0 < freq) : + Integrable (fun x : Space 1 => Real.exp (-(freq*‖x‖^2))) := + gaussianPotential_integrable hf + +/-- Gaussian variance is bounded by its Dirichlet form with the exact +oscillator gap constant. -/ +theorem gaussian_poincare_test {freq : ℝ} (hf : 0 < freq) + (f : Space 1 → ℝ) (hs : ContDiff ℝ ∞ f) (hc : HasCompactSupport f) : + (2*freq)*variance (potentialMeasure (fun x : Space 1 => freq*‖x‖^2)) f ≤ + dirichletEnergy (potentialMeasure (fun x : Space 1 => freq*‖x‖^2)) f := + (gaussianPotential_regular hf).poincare (gaussianPotential_integrable hf) ⟨hs,hc⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianScalar.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianScalar.lean new file mode 100644 index 0000000000000000000000000000000000000000..06415c907d3be26574cde44b20a5033bcd9d712e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GaussianScalar.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianLine + +namespace OAI + +/-! Normalized Gaussian variance and energy on the real line. -/ + +noncomputable section +open MeasureTheory +open scoped Topology ContDiff +namespace ContinuumCoulomb +open LeanBlast.KLS + +theorem gaussianLine_expectation {freq : ℝ} (hf : 0 < freq) (f : ℝ → ℝ) : + (∫ x : Space 1, f (gaussianLineEquiv x) + ∂potentialMeasure (fun x : Space 1 => freq*‖x‖^2)) = + ∫ z : ℝ, verticalMode freq z^2*f z := by + rw [integral_potentialMeasure] + have hw (x : Space 1) : Real.exp (-(freq*‖x‖^2)) = + Real.exp (-freq*(gaussianLineEquiv x)^2) := by + rw [gaussianLine_norm_sq] + congr 1 + ring + have hp : potentialPartition (fun x : Space 1 => freq*‖x‖^2) = + Real.sqrt (Real.pi/freq) := by + unfold potentialPartition + simp_rw [hw] + rw [gaussianLine_integral (fun z => Real.exp (-freq*z^2)),integral_gaussian] + rw [hp] + simp_rw [hw] + rw [gaussianLine_integral (fun z => Real.exp (-freq*z^2)*f z),← integral_div] + apply integral_congr_ae + exact Filter.Eventually.of_forall fun z => by + dsimp only + rw [verticalMode_square hf] + ring + +/-- The exact weighted Poincare constant for compact smooth real functions. -/ +theorem gaussian_scalar_poincare_smooth {freq : ℝ} (hf : 0 < freq) + (f : ℝ → ℝ) (hs : ContDiff ℝ ∞ f) (hc : HasCompactSupport f) : + (2*freq)*((∫ z : ℝ, verticalMode freq z^2*f z^2) - + (∫ z : ℝ, verticalMode freq z^2*f z)^2) ≤ + ∫ z : ℝ, verticalMode freq z^2*(deriv f z)^2 := by + let F : Space 1 → ℝ := fun x => f (gaussianLineEquiv x) + have hF : IsTestFunction F := ⟨hs.comp gaussianLineEquiv.contDiff, + hc.comp_homeomorph gaussianLineEquiv.toHomeomorph⟩ + let _ := isProbabilityMeasure_potentialMeasure (gaussian_weight_integrable hf) + have h := gaussian_poincare_test hf F hF.1 hF.2 + rw [variance_eq_integral_sq_sub_sq _ (hF.integrable _) (hF.integrable_sq _)] at h + change (2*freq)*((∫ x : Space 1, f (gaussianLineEquiv x)^2 ∂_) - + (∫ x : Space 1, f (gaussianLineEquiv x) ∂_)^2) ≤ + (∫ x : Space 1, ‖gradient F x‖^2 ∂_) at h + simp_rw [show ∀ x, ‖gradient F x‖^2 = (deriv f (gaussianLineEquiv x))^2 from + gaussianLine_gradient_sq (hs.differentiable (by simp))] at h + rw [gaussianLine_expectation hf (fun z => f z^2),gaussianLine_expectation hf f, + gaussianLine_expectation hf (fun z => deriv f z^2)] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GraphCoefficientStability.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GraphCoefficientStability.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf5b963a4b5e8bb71f7e432398ba5f71dec7aa2b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GraphCoefficientStability.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.HeisenbergOffsets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationCoefficientError + +namespace OAI + +/-! The actual shifted Heisenberg spectral bottom is stable under edgewise +coefficient errors. This attaches numerical calibration to Hubbard's exact +second-order identity without choosing a nearby exact root. -/ + +noncomputable section +namespace ContinuumCoulomb.HubbardGlobal +open scoped BigOperators InnerProductSpace +variable {Edge : Type*} [Fintype Edge] + +theorem graphSourceForm_stability (m : ℕ) (left right : Edge → Fin (m + 1)) + (J K : Edge → ℝ) (u : SourceSpinVector (m + 1)) (hu : sourceSpinMass u = 1) : + |graphSourceForm m left right J u - graphSourceForm m left right K u| ≤ + 4 * ∑ e, |J e - K e| := by + unfold graphSourceForm + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ e, 4 * |J e - K e| := by + apply Finset.sum_le_sum + intro e _ + have hf := sourceHeisenbergForm_bounds (left e) (right e) u + have ha : |sourceHeisenbergForm (left e) (right e) u - sourceSpinMass u| ≤ 4 := by + rw [hu] at * + exact abs_le.mpr ⟨by linarith [hf.1], by linarith [hf.2]⟩ + rw [show J e * (sourceHeisenbergForm (left e) (right e) u - sourceSpinMass u) - + K e * (sourceHeisenbergForm (left e) (right e) u - sourceSpinMass u) = + (J e - K e) * (sourceHeisenbergForm (left e) (right e) u - sourceSpinMass u) by ring, + abs_mul] + exact (mul_le_mul_of_nonneg_left ha (abs_nonneg _)).trans_eq (mul_comm _ _) + _ = _ := by rw [Finset.mul_sum] + +theorem graphSourceBottom_minimizer (m : ℕ) (left right : Edge → Fin (m + 1)) (J : Edge → ℝ) : + ∃ u : SourceSpinVector (m + 1), sourceSpinMass u = 1 ∧ + graphSourceBottom m left right J = graphSourceForm m left right J u ∧ + ∀ v : SourceSpinVector (m + 1), sourceSpinMass v = 1 → + graphSourceForm m left right J u ≤ graphSourceForm m left right J v := by + let M := finiteHeisenbergMatrix (m + 1) left right J - ((∑ e, J e : ℝ) : ℂ) • 1 + have heq : graphSourceBottom m left right J = sourceMatrixBottom (m + 1) M := by + dsimp only [M] + rw [graphSourceBottom_offset, sourceMatrixBottom_shift] + rfl + obtain ⟨p, hp, hbottom, hmin⟩ := sourceMatrixBottom_minimizer (m + 1) M + refine ⟨fun s => p s, ?_, ?_, ?_⟩ + · rw [sourceSpinMass_norm_sq, hp] + norm_num + · rw [heq, hbottom] + exact (graphSourceForm_matrix m left right J p).symm + · intro v hv + let q : MediatorLowSpace (m + 1) := WithLp.toLp 2 v + have hq : ‖q‖ = 1 := by + have hsq : ‖q‖ ^ 2 = 1 := (sourceSpinMass_norm_sq q).symm.trans hv + nlinarith [norm_nonneg q] + rw [graphSourceForm_matrix m left right J p] + exact (hmin q hq).trans_eq (graphSourceForm_matrix m left right J q).symm + +theorem graphSourceBottom_stability (m : ℕ) (left right : Edge → Fin (m + 1)) (J K : Edge → ℝ) : + |graphSourceBottom m left right J - graphSourceBottom m left right K| ≤ + 4 * ∑ e, |J e - K e| := by + obtain ⟨u, hu, hJu, hJmin⟩ := graphSourceBottom_minimizer m left right J + obtain ⟨v, hv, hKv, hKmin⟩ := graphSourceBottom_minimizer m left right K + have hp := graphSourceForm_stability m left right J K u hu + have hq := graphSourceForm_stability m left right J K v hv + have hj := hJmin v hv + have hk := hKmin u hu + rw [hJu, hKv] + exact abs_le.mpr ⟨by linarith [(abs_le.mp hp).1], by linarith [(abs_le.mp hq).2]⟩ + +theorem calibrated_graphSourceBottom_error (m : ℕ) (left right : Edge → Fin (m + 1)) + (t K gap ε : Edge → ℝ) {τ : ℝ} (hτ : 0 ≤ τ) + (hK : ∀ e, 0 ≤ K e) (hgap : ∀ e, 0 < gap e) + (hres : ∀ e, |t e - τ * Real.sqrt (K e * gap e)| ≤ ε e) : + |graphSourceBottom m left right (fun e => t e ^ 2 / gap e) - + graphSourceBottom m left right (fun e => τ ^ 2 * K e)| ≤ + 4 * ∑ e, ε e * (2 * τ * Real.sqrt (K e * gap e) + ε e) / gap e := by + apply (graphSourceBottom_stability m left right _ _).trans + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact Finset.sum_le_sum (fun e _ => calibrated_coefficient_error (hK e) (hgap e) hτ (hres e)) + +end ContinuumCoulomb.HubbardGlobal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridGroundUpper.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridGroundUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..922452ae1050ffc6310359eab5d9847ec32a1da2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridGroundUpper.lean @@ -0,0 +1,122 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ShiftedHubbardBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabSections +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGaussLabels + +namespace OAI + +/-! Polynomial size bounds used to choose the precision of the literal +nuclear-coordinate program. The negative slab offset is retained. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb +open HubbardGlobal + +theorem shifted_hubbard_upper {Edge : Type*} [Fintype Edge] + {freq : ℝ} (hf : 0 < freq) (m : ℕ) (u : Fin (m+1) → PlanarPosition) + (left right : Edge → Fin (m+1)) (t : Edge → ℝ) : + hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j) ≤ + (m+1:ℝ)/2*localizedPotentialBound freq+4*(∑ e, |t e|) := by + have hU0 := localizedCoulombProfile_nonnegative freq 0 + have hU : localizedCoulombProfile freq 0 ≤ localizedPotentialBound freq := by + simpa only [localizedCoulombCoeff_distance,sub_self,norm_zero] using + localizedCoulombCoeff_le hf (0 : PlanarPosition) 0 + have h := (le_abs_self _).trans (hubbardFermionBottom_abs_bound m + (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t) + simp_rw [abs_of_nonneg hU0,abs_of_nonneg (localizedOffsiteCoulomb_nonnegative freq u _ _)] at h + have hmul := mul_le_mul_of_nonneg_left hU (show 0 ≤ (m+1:ℝ)/2 by positivity) + linarith only [h,hmul] + +theorem exists_grid_ground_upper_exponent {freq rho a : ℝ} + (hf : 1 ≤ freq) (hrho : 0 ≤ rho) (ha : 0 < a) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ r v p k : ℕ, ∀ N H S : ℝ, 2 ≤ N → + ∀ {Edge : Type} [Fintype Edge] (m : ℕ) (u : Fin (m+1) → PlanarPosition) + (left right : Edge → Fin (m+1)) (t : Edge → ℝ), + (m+1:ℝ) ≤ N^r → (∑ e, |t e|) ≤ N^v → + let scale := a*(N^k)^30 + scale^2*(m+1:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+ + scale*(hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j))+ + scale*(N^p)⁻¹ ≤ N^(q+60*k+r+v) := by + let E0 := (-1/2:ℝ)+freq/2 + let C := a^2*E0+a*localizedPotentialBound freq/2+5*a + have hE0 : 0 ≤ E0 := by dsimp [E0]; linarith + have hP := localizedPotentialBound_nonnegative freq + have hfp : 0 < freq := lt_of_lt_of_le zero_lt_one hf + obtain ⟨q,hq,hconst⟩ := exists_polynomial_constant_bounds (by norm_num : (0:ℝ)<1) C + refine ⟨q,by omega,?_⟩ + intro r v p k N H S hN Edge _ m u left right t hm ht + dsimp only + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + let Z := N^(60*k+r+v) + have hfirst : (a*(N^k)^30)^2*(m+1:ℝ)*E0 ≤ (a^2*E0)*Z := by + calc + _ = (a^2*E0)*((N^k)^60*(m+1:ℝ)) := by ring + _ ≤ (a^2*E0)*((N^k)^60*N^r) := by gcongr + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + dsimp [Z] + rw [← pow_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by omega) + have hMr : (N^k)^30*(m+1:ℝ) ≤ Z := by + calc + _ ≤ (N^k)^30*N^r := by gcongr + _ ≤ _ := by + dsimp [Z] + rw [← pow_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by omega) + have hTr : (N^k)^30*(∑ e, |t e|) ≤ Z := by + calc + _ ≤ (N^k)^30*N^v := by gcongr + _ ≤ _ := by + dsimp [Z] + rw [← pow_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by omega) + have hLast : (N^k)^30*(N^p)⁻¹ ≤ Z := by + calc + _ ≤ (N^k)^30*1 := mul_le_mul_of_nonneg_left + (inv_le_one_of_one_le₀ (one_le_pow₀ hN1)) (by positivity) + _ ≤ _ := by dsimp [Z]; rw [mul_one,← pow_mul]; exact pow_le_pow_right₀ hN1 (by omega) + have hneg := slabPotential_nonpositive hrho H S 0 + have hslab := mul_le_mul_of_nonneg_left (show slabPotential rho H S 0+E0 ≤ E0 by linarith) + (show 0 ≤ (a*(N^k)^30)^2*(m+1:ℝ) by positivity) + have hhub := mul_le_mul_of_nonneg_left (shifted_hubbard_upper hfp m u left right t) + (show 0 ≤ a*(N^k)^30 by positivity) + have hmid := mul_le_mul_of_nonneg_left hMr (show 0 ≤ a*localizedPotentialBound freq/2 by positivity) + have ht' := mul_le_mul_of_nonneg_left hTr (show 0 ≤ 4*a by positivity) + have hend := mul_le_mul_of_nonneg_left hLast ha.le + calc + _ ≤ C*Z := by dsimp only [C,E0] at *; nlinarith only [hslab,hhub,hfirst,hmid,ht',hend] + _ ≤ N^q*Z := mul_le_mul_of_nonneg_right (hconst N hN).2 (by dsimp [Z]; positivity) + _ = _ := by dsimp [Z]; rw [← pow_add]; congr 1; omega + +theorem centered_grid_count_power {N : ℝ} (hN : 2 ≤ N) (k : ℕ) + {r : CenteredGaussLabels.Radii} + (h0 : (r.1:ℝ) ≤ N^(60*k)) (h1 : (r.2.1:ℝ) ≤ N^(60*k)) + (h2 : (r.2.2:ℝ) ≤ N^(15*k)) : + ((CenteredGaussLabels.labels r).length:ℝ) ≤ N^(135*k+8) := by + have hN1 : 1 ≤ N := by linarith + have hp60 : 1 ≤ N^(60*k) := one_le_pow₀ hN1 + have hp15 : 1 ≤ N^(15*k) := one_le_pow₀ hN1 + have ha : 2*(r.1:ℝ)+1 ≤ 3*N^(60*k) := by linarith + have hb : 2*(r.2.1:ℝ)+1 ≤ 3*N^(60*k) := by linarith + have hc : 2*(r.2.2:ℝ)+1 ≤ 3*N^(15*k) := by linarith + have h216 : (216:ℝ) ≤ N^8 := by + have h := pow_le_pow_left₀ (by norm_num : (0:ℝ) ≤ 2) hN 8 + norm_num at h + linarith + rw [CenteredGaussLabels.labels_length] + push_cast + calc + _ ≤ 8*((3*N^(60*k))*(3*N^(60*k))*(3*N^(15*k))) := by gcongr + _ = 216*N^(135*k) := by rw [show 135*k=(60*k+60*k)+15*k by omega,pow_add,pow_add]; ring + _ ≤ _ := by rw [pow_add N (135*k) 8]; nlinarith [pow_nonneg (by linarith : 0 ≤ N) (135*k)] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNodePrecision.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNodePrecision.lean new file mode 100644 index 0000000000000000000000000000000000000000..c690c5b6908e04ef25d2f08798de10db95afda1a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNodePrecision.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridGroundUpper +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.RoundingPolynomialBudget + +namespace OAI + +/-! Explicit polynomial precision for the emitted nodes: separation and the +full-ground rounding budget account for all nuclei in the centered box. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb + +theorem exists_grid_node_separation_offset (J : ℝ≥0) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ k a : ℕ, q+10*k ≤ a → + ∀ (N : ℝ) (P : ℕ), 2 ≤ N → N^a ≤ (P:ℝ) → + 2*(J:ℝ)*((P:ℝ)+1)⁻¹ < (1/(N^k)^10)/3 := by + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds + (by norm_num : (0:ℝ)<1) (6*(J:ℝ)) + refine ⟨q,by omega,fun k a ha N P hN hP => ?_⟩ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hmul : 6*(J:ℝ)*(N^k)^10 < (P:ℝ)+1 := by + calc + _ ≤ N^q*(N^k)^10 := mul_le_mul_of_nonneg_right (hbound N hN).2 (by positivity) + _ = N^(q+10*k) := by rw [pow_add,← pow_mul]; congr 2; omega + _ ≤ N^a := pow_le_pow_right₀ hN1 ha + _ < _ := by linarith only [hP] + rw [← div_eq_mul_inv,div_div] + apply (div_lt_div_iff₀ (by positivity) (by positivity : 0 < (N^k)^10*3)).mpr + nlinarith only [hmul] + +theorem grid_node_rounding_budget {N scale Q M E : ℝ} (hN : 2 ≤ N) (hs : 1 ≤ scale) + {q r v p k a P : ℕ} (ha : q+465*k+2*r+v+p+32 ≤ a) (hP : N^a ≤ (P:ℝ)) + (hQ : 0 ≤ Q) (hQN : Q ≤ N^(135*k+8)) (hM : 0 ≤ M) (hMN : M ≤ N^r) + (hE : E ≤ N^(q+60*k+r+v)) : + 32*(scale⁻¹*((P:ℝ)+1)⁻¹)*Q ≤ 1 ∧ + 32*(scale⁻¹*((P:ℝ)+1)⁻¹)*Q*(E+4*M*Q^2) ≤ (N^p)⁻¹ := by + have hN0 : 0 < N := by linarith + have hs0 : 0 < scale := lt_of_lt_of_le zero_lt_one hs + apply rounding_polynomial_budget hN (a := a) (c := q+60*k+r+v) + (q := 135*k+8) (r := r) (p := p) (by omega) hQ hQN hM hMN hE (by positivity) + calc + _ ≤ 1*((P:ℝ)+1)⁻¹ := mul_le_mul_of_nonneg_right (inv_le_one_of_one_le₀ hs) (by positivity) + _ ≤ (N^a)⁻¹ := by + rw [one_mul] + exact inv_anti₀ (pow_pos hN0 a) (by linarith only [hP]) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNuclei.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNuclei.lean new file mode 100644 index 0000000000000000000000000000000000000000..433550c9ee6b6780df85fb0dccea6845392f33a0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GridNuclei.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridPotential +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ShiftedPhysicalForm + +namespace OAI + +/-! The transported Gauss cloud is an actual collection of distinct unit +nuclei. Its physical form has exactly the slab-origin energy offset. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +private theorem gaussLatticePoint_injective {h : ℝ} (hh : 0 < h) : + Function.Injective (gaussLatticePoint h) := by + intro a b hab + by_contra hne + have hs := gaussLatticePoint_separation hh a b hne + rw [hab,sub_self,norm_zero] at hs + linarith + +def gridNuclei {ι : Type*} [Fintype ι] [Nonempty ι] (index : ι → Fin 3 → ℤ) + (hi : Function.Injective index) (G : Position → Position) (hG : Function.Injective G) + {h : ℝ} (hh : 0 < h) : Coulomb.Nuclei (Fintype.card (ι × (Fin 3 → Fin 2))) where + nonempty := Fintype.card_pos + position a := G (gaussLatticePoint h + (gridGaussIndex index ((Fintype.equivFin (ι × (Fin 3 → Fin 2))).symm a))) + distinct := (hG.comp ((gaussLatticePoint_injective hh).comp + (gridGaussIndex_injective index hi))).comp (Fintype.equivFin _).symm.injective + charge _ := 1 + charge_ge_one _ := le_rfl + +theorem gridNuclei_attraction {ι : Type*} [Fintype ι] [Nonempty ι] + (index : ι → Fin 3 → ℤ) (hi : Function.Injective index) + (G : Position → Position) (hG : Function.Injective G) {h : ℝ} (hh : 0 < h) (y : Position) : + Coulomb.attraction (gridNuclei index hi G hG hh) y = + ∑ a : ι × (Fin 3 → Fin 2), + Coulomb.coulombKernel (y-G (gaussLatticePoint h (gridGaussIndex index a))) := by + simp only [Coulomb.attraction,gridNuclei,one_mul] + exact (Fintype.equivFin (ι × (Fin 3 → Fin 2))).symm.sum_comp + (fun a : ι × (Fin 3 → Fin 2) => + Coulomb.coulombKernel (y-G (gaussLatticePoint h (gridGaussIndex index a)))) + +theorem gridNuclearPotential_attraction {ι : Type*} [Fintype ι] [Nonempty ι] + (index : ι → Fin 3 → ℤ) (hi : Function.Injective index) + (G : Position → Position) (hG : Function.Injective G) {h : ℝ} (hh : 0 < h) + (rho : ℝ) (y : Position) : + gridNuclearPotential index G rho h y = + -(rho*h^3/8)*Coulomb.attraction (gridNuclei index hi G hG hh) y := by + rw [gridNuclei_attraction] + rfl + +theorem manufactured_grid_split {ι : Type*} [Fintype ι] [Nonempty ι] + (index : ι → Fin 3 → ℤ) (hi : Function.Injective index) + (G : Position → Position) (hG : Function.Injective G) {h : ℝ} (hh : 0 < h) + (rho H S freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hscale : rho*h^3/8=scale⁻¹) (y : Position) : + manufacturedSlabPotential rho H S freq scale u y+ + (gridNuclearPotential index G rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y)) = + -scale⁻¹*Coulomb.attraction (gridNuclei index hi G hG hh) y-slabPotential rho H S 0 := by + rw [gridNuclearPotential_attraction index hi G hG hh, hscale] + unfold manufacturedSlabPotential + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GroundRoundingInterval.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GroundRoundingInterval.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca05ec448dc4842b73bf69a7f6003f5e985a6532 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/GroundRoundingInterval.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.FormStability + +namespace OAI + +/-! Rounding a cloud using an already proved two-sided ground-energy +interval. No minimizing eigenvector or independent kinetic bound is needed. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem formGroundEnergy_exists_trial_of_upper {m n : ℕ} (S : Coulomb.Nuclei m) + {C : ℝ} (hC : formGroundEnergy S n ≤ (C:EReal)) : + ∃ trial : FormState n, normSq trial = 1 := by + have htop : formGroundEnergy S n < ⊤ := hC.trans_lt (EReal.coe_lt_top C) + obtain ⟨e,⟨trial,ht,_⟩,_⟩ := sInf_lt_iff.mp htop + exact ⟨trial,ht⟩ + +theorem formGroundEnergy_position_stability_of_upper {m n : ℕ} (S T : Coulomb.Nuclei m) + {C δ : ℝ} (hC : formGroundEnergy S n ≤ (C:EReal)) + (hδ : 0 ≤ δ) (hcharge : S.charge=T.charge) + (hmove : ∀ a, ‖S.position a-T.position a‖ ≤ δ) + (hsmall : 32*δ*Coulomb.totalCharge S ≤ 1) : + |(formGroundEnergy T n).toReal-(formGroundEnergy S n).toReal| ≤ + 32*δ*Coulomb.totalCharge S*(C+4*(n:ℝ)*Coulomb.totalCharge S^2) := by + obtain ⟨trial,ht⟩ := formGroundEnergy_exists_trial_of_upper S hC + have hf := formGroundEnergy_finite S trial ht + have hCr : (formGroundEnergy S n).toReal ≤ C := by + apply EReal.coe_le_coe_iff.mp + simpa only [EReal.coe_toReal hf.1 hf.2] using hC + exact (formGroundEnergy_position_stability S T trial ht hδ hcharge hmove hsmall).trans + (mul_le_mul_of_nonneg_left (add_le_add hCr le_rfl) + (by exact mul_nonneg (mul_nonneg (by norm_num) hδ) (Coulomb.totalCharge_pos S).le)) + +theorem formGroundEnergy_rounding_interval {m n : ℕ} (S T : Coulomb.Nuclei m) + {center error δ roundError : ℝ} + (hlower : ((center-error:ℝ):EReal) ≤ formGroundEnergy S n) + (hupper : formGroundEnergy S n ≤ ((center+error:ℝ):EReal)) + (hδ : 0 ≤ δ) (hcharge : S.charge=T.charge) + (hmove : ∀ a, ‖S.position a-T.position a‖ ≤ δ) + (hsmall : 32*δ*Coulomb.totalCharge S ≤ 1) + (hbudget : 32*δ*Coulomb.totalCharge S* + (center+error+4*(n:ℝ)*Coulomb.totalCharge S^2) ≤ roundError) : + ((center-error-roundError:ℝ):EReal) ≤ formGroundEnergy T n ∧ + formGroundEnergy T n ≤ ((center+error+roundError:ℝ):EReal) := by + obtain ⟨trial,ht⟩ := formGroundEnergy_exists_trial_of_upper S hupper + have hfS := formGroundEnergy_finite S trial ht + have hfT := formGroundEnergy_finite T trial ht + have hslo : center-error ≤ (formGroundEnergy S n).toReal := by + apply EReal.coe_le_coe_iff.mp + simpa only [EReal.coe_toReal hfS.1 hfS.2] using hlower + have hshi : (formGroundEnergy S n).toReal ≤ center+error := by + apply EReal.coe_le_coe_iff.mp + simpa only [EReal.coe_toReal hfS.1 hfS.2] using hupper + have hdiff := (formGroundEnergy_position_stability_of_upper S T hupper hδ hcharge hmove hsmall).trans hbudget + obtain ⟨hdlo,hdhi⟩ := abs_le.mp hdiff + constructor + · rw [← EReal.coe_toReal hfT.1 hfT.2] + exact EReal.coe_le_coe_iff.mpr (by linarith only [hslo,hdlo]) + · rw [← EReal.coe_toReal hfT.1 hfT.2] + exact EReal.coe_le_coe_iff.mpr (by linarith only [hshi,hdhi]) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1BoundedForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1BoundedForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ea2e70cef30ac73f9007a1a2d74bbce01f40f92 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1BoundedForm.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1GraphCore + +namespace OAI + +/-! Continuous kinetic-plus-bounded-operator forms on the full H1 graph. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +abbrev H1Coordinates (n : ℕ) := H1Index n → Lp ℂ 2 (volume : Measure (Configuration n)) + +def graphMass {n : ℕ} (f : H1Coordinates n) : ℝ := + ∑ s, ‖f (Sum.inl s)‖^2 + +def graphKinetic {n : ℕ} (f : H1Coordinates n) : ℝ := + (1/2 : ℝ) * ∑ s, ∑ a, ‖f (Sum.inr (s,a))‖^2 + +theorem h1Coordinates_norm_sq {n : ℕ} (u : Coulomb.H1Vector n) (a : H1Index n) : + ‖h1Coordinates u a‖^2 = ∫ x, ‖h1CoordinateFunction u a x‖^2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [(h1Coordinate_memLp u a).coeFn_toLp] with x hx + simpa only [real_inner_self_eq_norm_sq, h1Coordinates] using congrArg (fun z : ℂ => ‖z‖^2) hx + +theorem mass_eq_graphMass {n : ℕ} (u : Coulomb.H1Vector n) : + Coulomb.mass u = graphMass (h1Coordinates u) := by + simp only [Coulomb.mass, graphMass, h1Coordinates_norm_sq, h1CoordinateFunction] + +theorem kinetic_eq_graphKinetic {n : ℕ} (u : Coulomb.H1Vector n) : + Coulomb.kinetic u = graphKinetic (h1Coordinates u) := by + simp only [Coulomb.kinetic, graphKinetic, h1Coordinates_norm_sq, h1CoordinateFunction] + +theorem graphMass_continuous (n : ℕ) : Continuous (@graphMass n) := + continuous_finsetSum _ (fun s _ => (continuous_apply (Sum.inl s)).norm.pow 2) + +theorem graphKinetic_continuous (n : ℕ) : Continuous (@graphKinetic n) := + continuous_const.mul (continuous_finsetSum _ (fun s _ => + continuous_finsetSum _ (fun a _ => (continuous_apply (Sum.inr (s,a))).norm.pow 2))) + +def graphBoundedForm {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) (f : H1Coordinates n) : ℝ := + graphKinetic f + ∑ s, inner ℝ (f (Sum.inl s)) (A (f (Sum.inl s))) + +theorem graphBoundedForm_continuous {n : ℕ} + (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) : Continuous (graphBoundedForm A) := + (graphKinetic_continuous n).add (continuous_finsetSum _ (fun s _ => + (continuous_apply (Sum.inl s)).inner (A.continuous.comp (continuous_apply (Sum.inl s))))) + +/-- A compact-test lower bound for an actual bounded L2 operator extends +with the kinetic energy to the entire declared weak-H1 domain. -/ +theorem boundedForm_lower_of_compact (hpublished : PublishedSobolevSmoothDensity) + {n : ℕ} (A : Lp ℂ 2 (volume : Measure (Configuration n)) →L[ℝ] + Lp ℂ 2 (volume : Measure (Configuration n))) (E : ℝ) + (hcompact : ∀ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) → + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) → + E*Coulomb.mass v ≤ graphBoundedForm A (h1Coordinates v)) + (u : Coulomb.H1Vector n) : E*Coulomb.mass u ≤ graphBoundedForm A (h1Coordinates u) := by + have hc : Continuous (fun f : H1Coordinates n => graphBoundedForm A f - E*graphMass f) := + (graphBoundedForm_continuous A).sub (continuous_const.mul (graphMass_continuous n)) + have h := h1_continuous_nonnegative_of_compact hpublished + (fun f => graphBoundedForm A f - E*graphMass f) hc + (fun v hv hd => by + rw [← mass_eq_graphMass] + exact sub_nonneg.mpr (hcompact v hv hd)) u + rw [← mass_eq_graphMass] at h + exact sub_nonneg.mp h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1FiniteProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1FiniteProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1c0dd811b33f93a6e7092f0fdb1a20580464b9d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1FiniteProjection.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.BoundedPotentialOperator + +namespace OAI + +/-! Finite orbital penalties pass from compact tests to the complete weak-H1 +domain without asking approximants to preserve exact orthogonality. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def graphOrbitalMass {n : ℕ} {ι : Type*} [Fintype ι] + (ψ : ι → Lp ℂ 2 (volume : Measure (Configuration n))) (f : H1Coordinates n) : ℝ := + ∑ s, ∑ i, ‖inner ℂ (ψ i) (f (Sum.inl s))‖^2 + +theorem graphOrbitalMass_continuous {n : ℕ} {ι : Type*} [Fintype ι] + (ψ : ι → Lp ℂ 2 (volume : Measure (Configuration n))) : + Continuous (graphOrbitalMass ψ) := + continuous_finsetSum _ (fun s _ => continuous_finsetSum _ (fun _i _ => + (continuous_const.inner (continuous_apply (Sum.inl s))).norm.pow 2)) + +theorem graphOrbitalMass_eq_zero {n : ℕ} {ι : Type*} [Fintype ι] + (ψ : ι → Lp ℂ 2 (volume : Measure (Configuration n))) (f : H1Coordinates n) + (horth : ∀ s i, inner ℂ (ψ i) (f (Sum.inl s)) = 0) : + graphOrbitalMass ψ f = 0 := by + simp only [graphOrbitalMass, horth, norm_zero, zero_pow (by norm_num : 2 ≠ 0), + Finset.sum_const_zero] + +/-- The finite projection term is continuous on the same graph as the +kinetic and bounded potential terms. -/ +theorem boundedPotential_projection_lower_of_compact + (hpublished : PublishedSobolevSmoothDensity) {n : ℕ} {ι : Type*} [Fintype ι] + (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) + (hB : ∀ x, |V x| ≤ B) + (ψ : ι → Lp ℂ 2 (volume : Measure (Configuration n))) (E κ : ℝ) + (hcompact : ∀ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) → + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) → + E*Coulomb.mass v - κ*graphOrbitalMass ψ (h1Coordinates v) ≤ boundedPotentialForm V v) + (u : Coulomb.H1Vector n) : + E*Coulomb.mass u - κ*graphOrbitalMass ψ (h1Coordinates u) ≤ boundedPotentialForm V u := by + let A := BoundedPotential.operator V hV B hB + let F : H1Coordinates n → ℝ := fun f => + graphBoundedForm A f - E*graphMass f + κ*graphOrbitalMass ψ f + have hF : Continuous F := + ((graphBoundedForm_continuous A).sub + (continuous_const.mul (graphMass_continuous n))).add + (continuous_const.mul (graphOrbitalMass_continuous ψ)) + have h := h1_continuous_nonnegative_of_compact hpublished F hF + (fun v hv hd => by + dsimp [F, A] + rw [← boundedPotentialForm_eq_graph V hV B hB, ← mass_eq_graphMass] + linarith [hcompact v hv hd]) u + dsimp [F, A] at h + rw [← boundedPotentialForm_eq_graph V hV B hB, ← mass_eq_graphMass] at h + linarith + +theorem boundedPotential_complement_lower_of_compact + (hpublished : PublishedSobolevSmoothDensity) {n : ℕ} {ι : Type*} [Fintype ι] + (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) + (hB : ∀ x, |V x| ≤ B) + (ψ : ι → Lp ℂ 2 (volume : Measure (Configuration n))) (E κ : ℝ) + (hcompact : ∀ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) → + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) → + E*Coulomb.mass v - κ*graphOrbitalMass ψ (h1Coordinates v) ≤ boundedPotentialForm V v) + (u : Coulomb.H1Vector n) + (horth : ∀ s i, inner ℂ (ψ i) (h1Coordinates u (Sum.inl s)) = 0) : + E*Coulomb.mass u ≤ boundedPotentialForm V u := by + have h := boundedPotential_projection_lower_of_compact hpublished V hV B hB ψ E κ hcompact u + simpa only [graphOrbitalMass_eq_zero ψ _ horth, mul_zero, sub_zero] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1GraphCore.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1GraphCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..681f53c188693511e6bd83f96f0ff3a31911323f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1GraphCore.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactSobolevCore + +namespace OAI + +/-! The full weak-H1 graph as finitely many actual L2 coordinates. Compact +C1 states approximate every coordinate simultaneously, so continuous form +inequalities on this graph extend to the full weak-H1 domain. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +abbrev H1Index (n : ℕ) := SpinConfiguration n ⊕ (SpinConfiguration n × (Fin n × Fin 3)) + +def h1CoordinateFunction {n : ℕ} (u : Coulomb.H1Vector n) : + H1Index n → Configuration n → ℂ + | Sum.inl s => u.value s + | Sum.inr (s, a) => u.gradient s a + +theorem h1Coordinate_memLp {n : ℕ} (u : Coulomb.H1Vector n) (a : H1Index n) : + MemLp (h1CoordinateFunction u a) 2 := by + cases a with + | inl s => exact u.value_L2 s + | inr sa => exact u.partial_L2 sa.1 sa.2 + +def h1Coordinates {n : ℕ} (u : Coulomb.H1Vector n) : + H1Index n → Lp ℂ 2 (volume : Measure (Configuration n)) := + fun a => (h1Coordinate_memLp u a).toLp (h1CoordinateFunction u a) + +theorem h1Coordinate_error {n : ℕ} (u v : Coulomb.H1Vector n) (a : H1Index n) : + ‖h1Coordinates u a-h1Coordinates v a‖^2 = + ∫ x, ‖h1CoordinateFunction u a x-h1CoordinateFunction v a x‖^2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (h1Coordinates u a) (h1Coordinates v a), + (h1Coordinate_memLp u a).coeFn_toLp, (h1Coordinate_memLp v a).coeFn_toLp] + with x hs hu hv + rw [real_inner_self_eq_norm_sq] + change ‖(h1Coordinates u a-h1Coordinates v a) x‖^2 = _ + rw [hs] + change ‖h1Coordinates u a x-h1Coordinates v a x‖^2 = _ + change h1Coordinates u a x = h1CoordinateFunction u a x at hu + change h1Coordinates v a x = h1CoordinateFunction v a x at hv + rw [hu, hv] + +theorem h1GraphError_eq_sum {n : ℕ} (u v : Coulomb.H1Vector n) : + h1GraphError u v = ∑ a : H1Index n, ‖h1Coordinates u a-h1Coordinates v a‖^2 := by + simp only [h1Coordinate_error, Fintype.sum_sum_type, Fintype.sum_prod_type, + h1CoordinateFunction, h1GraphError] + +theorem h1Coordinate_error_le {n : ℕ} (u v : Coulomb.H1Vector n) (a : H1Index n) : + ‖h1Coordinates u a-h1Coordinates v a‖^2 ≤ h1GraphError u v := by + rw [h1GraphError_eq_sum] + exact Finset.single_le_sum (fun (i : H1Index n) _ => + sq_nonneg ‖h1Coordinates u i-h1Coordinates v i‖) (Finset.mem_univ a) + +/-- Compact C1 states converge to every actual weak-H1 state in the finite +product of value and derivative L2 spaces. -/ +theorem exists_compact_h1_graph_sequence (hpublished : PublishedSobolevSmoothDensity) + {n : ℕ} (u : Coulomb.H1Vector n) : + ∃ v : ℕ → Coulomb.H1Vector n, + (∀ k s, ContDiff ℝ 1 ((v k).value s) ∧ HasCompactSupport ((v k).value s)) ∧ + (∀ k s a x, (v k).gradient s a x = + fderiv ℝ ((v k).value s) x (EuclideanSpace.single a 1)) ∧ + Tendsto (fun k => h1Coordinates (v k)) atTop (𝓝 (h1Coordinates u)) := by + have he (k : ℕ) := exists_compact_h1_approximation hpublished u + (show (0 : ℝ) < 1/((k : ℝ)+1) by positivity) + choose v hv hd herr using he + refine ⟨v, hv, hd, ?_⟩ + apply tendsto_pi_nhds.2 + intro a + rw [tendsto_iff_dist_tendsto_zero] + have hs : Tendsto (fun k => ‖h1Coordinates (v k) a-h1Coordinates u a‖^2) + atTop (𝓝 0) := by + apply squeeze_zero (fun k => sq_nonneg _) _ + (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)) + intro k + rw [norm_sub_rev] + exact (h1Coordinate_error_le u (v k) a).trans (herr k).le + have ht := (Real.continuous_sqrt.tendsto 0).comp hs + simpa only [Function.comp_def, Real.sqrt_sq (norm_nonneg _), Real.sqrt_zero, + dist_eq_norm] using ht + +/-- Transfer a continuous inequality from compact classical states to the +full declared weak-H1 graph. -/ +theorem h1_continuous_nonnegative_of_compact + (hpublished : PublishedSobolevSmoothDensity) {n : ℕ} + (F : (H1Index n → Lp ℂ 2 (volume : Measure (Configuration n))) → ℝ) + (hF : Continuous F) + (hcompact : ∀ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) → + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) → 0 ≤ F (h1Coordinates v)) + (u : Coulomb.H1Vector n) : 0 ≤ F (h1Coordinates u) := by + obtain ⟨v, hv, hd, ht⟩ := exists_compact_h1_graph_sequence hpublished u + exact ge_of_tendsto (hF.continuousAt.tendsto.comp ht) + (Filter.Eventually.of_forall (fun k => hcompact (v k) (hv k) (hd k))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1PairingBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1PairingBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5372b9b1cdd44e0ad69f2e78b4dbf3ae1d436a0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/H1PairingBound.lean @@ -0,0 +1,35 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Pairing + +namespace OAI + +/-! An L2 residual controls its pairing with every weak-H1 state. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem h1_real_pairing_sq_le {n : ℕ} (v : Coulomb.H1Vector n) + (s : SpinConfiguration n) (φ : Configuration n → ℝ) (hφ : MemLp φ 2) : + ‖∫ x, v.value s x*(φ x : ℂ)‖^2 ≤ + (∫ x, φ x^2)*(∫ x, ‖v.value s x‖^2) := by + let Φ : Lp ℂ 2 (volume : Measure (Configuration n)) := + hφ.ofReal.toLp (fun x => (φ x : ℂ)) + have hm : MemLp (fun x => (φ x : ℂ)) 2 := hφ.ofReal + have hnorm : ‖Φ‖^2 = ∫ x, φ x^2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [hm.coeFn_toLp] with x hx + change Φ x = (φ x : ℂ) at hx + rw [real_inner_self_eq_norm_sq,hx,Complex.norm_real,Real.norm_eq_abs,sq_abs] + rw [← h1_inner_real_orbital v s φ hφ] + change ‖inner ℂ Φ (h1Coordinates v (Sum.inl s))‖^2 ≤ _ + have h := pow_le_pow_left₀ (norm_nonneg (inner ℂ Φ (h1Coordinates v (Sum.inl s)))) + (norm_inner_le_norm (𝕜 := ℂ) Φ (h1Coordinates v (Sum.inl s))) 2 + rw [mul_pow,hnorm,h1Coordinates_norm_sq] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatDensityModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatDensityModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7dee456cad85fb2474ced10890efdc9f8c13c92 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatDensityModulus.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatKernelModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcingModulus + +namespace OAI + +/-! Explicit moduli of the actual forcing-weighted heat density. These +are the constants used for the fixed-dimensional quadrature mesh. -/ + +noncomputable section +namespace ContinuumCoulomb.HeatKernelModulus + +def density (r : PlanarPosition) (t : ℝ) (p : PlanarPosition) : ℝ := + kernel t (‖r - p‖ ^ 2) * planarForcing p + +theorem squared_norm_difference {u v : PlanarPosition} {D : ℝ} + (hu : ‖u‖ ≤ D) (hv : ‖v‖ ≤ D) : + |‖u‖ ^ 2 - ‖v‖ ^ 2| ≤ 2 * D * ‖u - v‖ := by + have hD : 0 ≤ D := (norm_nonneg _).trans hu + have hid : ‖u‖ ^ 2 - ‖v‖ ^ 2 = (‖u‖ - ‖v‖) * (‖u‖ + ‖v‖) := by ring + rw [hid, abs_mul, abs_of_nonneg (add_nonneg (norm_nonneg _) (norm_nonneg _))] + calc + _ ≤ ‖u - v‖ * (‖u‖ + ‖v‖) := + mul_le_mul_of_nonneg_right (abs_norm_sub_norm_le u v) (by positivity) + _ ≤ ‖u - v‖ * (2 * D) := mul_le_mul_of_nonneg_left (by linarith) (norm_nonneg _) + _ = _ := by ring + +theorem density_space_lipschitz {r p q : PlanarPosition} {η t D : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hp : ‖r - p‖ ≤ D) (hq : ‖r - q‖ ≤ D) : + |density r t p - density r t q| ≤ + (2 * D / η ^ 2 + 32 * η⁻¹) * ‖p - q‖ := by + have ht0 : 0 < t := hη.trans_le ht + have hs : |‖r - p‖ ^ 2 - ‖r - q‖ ^ 2| ≤ 2 * D * ‖p - q‖ := by + have h := squared_norm_difference hp hq + simpa only [show (r - p) - (r - q) = -(p - q) by abel, norm_neg] using h + have hk := kernel_space_lipschitz hη ht (sq_nonneg ‖r - p‖) (sq_nonneg ‖r - q‖) + have hk' : |kernel t (‖r - p‖ ^ 2) - kernel t (‖r - q‖ ^ 2)| ≤ + (2 * D / η ^ 2) * ‖p - q‖ := by + calc + _ ≤ |‖r - p‖ ^ 2 - ‖r - q‖ ^ 2| / η ^ 2 := hk + _ ≤ (2 * D * ‖p - q‖) / η ^ 2 := div_le_div_of_nonneg_right hs (sq_nonneg η) + _ = _ := by ring + have hkq := kernel_le_inverse hη ht (sq_nonneg ‖r - q‖) + have hkq0 := kernel_nonnegative (A := ‖r - q‖ ^ 2) ht0 + have hf := planarForcing_norm_sub_explicit p q + have hfp0 := planarForcing_nonnegative p + have hfp1 := planarForcing_le_one p + have hid : density r t p - density r t q = + (kernel t (‖r - p‖ ^ 2) - kernel t (‖r - q‖ ^ 2)) * planarForcing p + + kernel t (‖r - q‖ ^ 2) * (planarForcing p - planarForcing q) := by + unfold density + ring + rw [hid] + calc + _ ≤ |(kernel t (‖r - p‖ ^ 2) - kernel t (‖r - q‖ ^ 2)) * planarForcing p| + + |kernel t (‖r - q‖ ^ 2) * (planarForcing p - planarForcing q)| := abs_add_le _ _ + _ = |kernel t (‖r - p‖ ^ 2) - kernel t (‖r - q‖ ^ 2)| * planarForcing p + + kernel t (‖r - q‖ ^ 2) * |planarForcing p - planarForcing q| := by + rw [abs_mul, abs_mul, abs_of_nonneg hfp0, abs_of_nonneg hkq0] + _ ≤ (2 * D / η ^ 2) * ‖p - q‖ + η⁻¹ * (32 * ‖p - q‖) := by + apply add_le_add + · exact (mul_le_of_le_one_right (abs_nonneg _) hfp1).trans hk' + · exact mul_le_mul hkq hf (abs_nonneg _) (by positivity) + _ = _ := by ring + +theorem density_time_lipschitz {r p : PlanarPosition} {η t s D : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) (hp : ‖r - p‖ ≤ D) : + |density r t p - density r s p| ≤ + (η⁻¹ ^ 2 + η⁻¹ * (1 + D ^ 2 / (4 * η ^ 2))) * |t - s| := by + have hD : 0 ≤ D := (norm_nonneg _).trans hp + have hsq : ‖r - p‖ ^ 2 ≤ D ^ 2 := (sq_le_sq₀ (norm_nonneg _) hD).mpr hp + have h := kernel_time_lipschitz hη ht hs (sq_nonneg ‖r - p‖) + rw [density, density, ← sub_mul, abs_mul, abs_of_nonneg (planarForcing_nonnegative p)] + apply (mul_le_of_le_one_right (abs_nonneg _) (planarForcing_le_one p)).trans + apply h.trans + gcongr + +end ContinuumCoulomb.HeatKernelModulus + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatKernelModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatKernelModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..e53b637710db32867f03342360ec989c2dedfdb7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatKernelModulus.lean @@ -0,0 +1,146 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatKernel +import Mathlib.Analysis.Calculus.MeanValue + +namespace OAI + +/-! Quantitative bounds for the scalar heat-resolvent kernel away from +time zero. Every constant is elementary in the cutoff and radius. -/ + +noncomputable section +namespace ContinuumCoulomb.HeatKernelModulus + +def exponent (t A : ℝ) : ℝ := -t - A / (4 * t) +def kernel (t A : ℝ) : ℝ := Real.exp (exponent t A) / (4 * Real.pi * t) + +theorem kernel_eq_heat (t : ℝ) (r : PlanarPosition) : + kernel t (‖r‖ ^ 2) = Real.exp (-t) * planarHeatKernel t r := by + rw [kernel, exponent, sub_eq_add_neg, Real.exp_add, planarHeatKernel, neg_div] + ring + +theorem exp_nonpositive_lipschitz {x y : ℝ} (hx : x ≤ 0) (hy : y ≤ 0) : + |Real.exp x - Real.exp y| ≤ |x - y| := by + have h := Convex.norm_image_sub_le_of_norm_hasDerivWithin_le + (f := Real.exp) (f' := Real.exp) (s := Set.Iic (0 : ℝ)) (C := 1) + (fun z _ => (Real.hasDerivAt_exp z).hasDerivWithinAt) + (fun z hz => by + rw [Real.norm_eq_abs, abs_of_pos (Real.exp_pos z)] + exact Real.exp_le_one_iff.mpr hz) + (convex_Iic (0 : ℝ)) hy hx + simpa only [Real.norm_eq_abs, one_mul] using h + +theorem reciprocal_lipschitz {η t s : ℝ} (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) : + |t⁻¹ - s⁻¹| ≤ |t - s| / η ^ 2 := by + have ht0 : 0 < t := hη.trans_le ht + have hs0 : 0 < s := hη.trans_le hs + have hid : t⁻¹ - s⁻¹ = (s - t) / (t * s) := by field_simp + rw [hid, abs_div, abs_of_pos (mul_pos ht0 hs0), abs_sub_comm s t] + exact div_le_div_of_nonneg_left (abs_nonneg _) (by positivity) + (by nlinarith [mul_nonneg (sub_nonneg.mpr ht) (sub_nonneg.mpr hs)]) + +theorem exponent_nonpositive {t A : ℝ} (ht : 0 < t) (hA : 0 ≤ A) : + exponent t A ≤ 0 := by + have h := div_nonneg hA (show 0 ≤ 4 * t by positivity) + dsimp only [exponent] + linarith + +theorem exponent_time_lipschitz {η t s A : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) (hA : 0 ≤ A) : + |exponent t A - exponent s A| ≤ (1 + A / (4 * η ^ 2)) * |t - s| := by + have hid : exponent t A - exponent s A = + -(t - s) - (A / 4) * (t⁻¹ - s⁻¹) := by unfold exponent; ring + rw [hid] + calc + _ ≤ |-(t - s)| + |A / 4 * (t⁻¹ - s⁻¹)| := abs_sub _ _ + _ = |t - s| + A / 4 * |t⁻¹ - s⁻¹| := by + rw [abs_neg, abs_mul, abs_of_nonneg (by positivity : (0 : ℝ) ≤ A / 4)] + _ ≤ |t - s| + A / 4 * (|t - s| / η ^ 2) := by + gcongr + exact reciprocal_lipschitz hη ht hs + _ = _ := by ring + +theorem kernel_nonnegative {t A : ℝ} (ht : 0 < t) : 0 ≤ kernel t A := by + unfold kernel + positivity + +theorem kernel_le_inverse {η t A : ℝ} (hη : 0 < η) (ht : η ≤ t) (hA : 0 ≤ A) : + kernel t A ≤ η⁻¹ := by + have ht0 : 0 < t := hη.trans_le ht + have he : Real.exp (exponent t A) ≤ 1 := + Real.exp_le_one_iff.mpr (exponent_nonpositive ht0 hA) + have hp : (1 : ℝ) ≤ 4 * Real.pi := by linarith [Real.two_le_pi] + calc + kernel t A ≤ 1 / (4 * Real.pi * t) := div_le_div_of_nonneg_right he (by positivity) + _ ≤ 1 / η := div_le_div_of_nonneg_left (by norm_num) hη + (by nlinarith [mul_le_mul_of_nonneg_right hp ht0.le]) + _ = _ := one_div _ + +theorem kernel_space_lipschitz {η t A B : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hA : 0 ≤ A) (hB : 0 ≤ B) : + |kernel t A - kernel t B| ≤ |A - B| / η ^ 2 := by + have ht0 : 0 < t := hη.trans_le ht + have hq := exp_nonpositive_lipschitz (exponent_nonpositive ht0 hA) + (exponent_nonpositive ht0 hB) + have he : exponent t A - exponent t B = -(A - B) / (4 * t) := by + unfold exponent + ring + rw [he, abs_div, abs_neg, abs_of_pos (show 0 < 4 * t by positivity)] at hq + have hd : 0 < 4 * Real.pi * t := by positivity + have hp : (1 : ℝ) ≤ 4 * Real.pi := by linarith [Real.two_le_pi] + have hden : η ^ 2 ≤ (4 * t) * (4 * Real.pi * t) := by + have ht1 : η ^ 2 ≤ t ^ 2 := (sq_le_sq₀ hη.le ht0.le).mpr ht + have hm := mul_le_mul_of_nonneg_right hp (show 0 ≤ 4 * t ^ 2 by positivity) + nlinarith + calc + |kernel t A - kernel t B| = + |Real.exp (exponent t A) - Real.exp (exponent t B)| / (4 * Real.pi * t) := by + rw [kernel, kernel, ← sub_div, abs_div, abs_of_pos hd] + _ ≤ (|A - B| / (4 * t)) / (4 * Real.pi * t) := + div_le_div_of_nonneg_right hq hd.le + _ = |A - B| / ((4 * t) * (4 * Real.pi * t)) := by ring + _ ≤ _ := div_le_div_of_nonneg_left (abs_nonneg _) (by positivity) hden + +theorem kernel_time_lipschitz {η t s A : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) (hA : 0 ≤ A) : + |kernel t A - kernel s A| ≤ + (η⁻¹ ^ 2 + η⁻¹ * (1 + A / (4 * η ^ 2))) * |t - s| := by + have ht0 : 0 < t := hη.trans_le ht + have hs0 : 0 < s := hη.trans_le hs + have hqt := exponent_nonpositive ht0 hA + have hqs := exponent_nonpositive hs0 hA + have hEt : Real.exp (exponent t A) ≤ 1 := Real.exp_le_one_iff.mpr hqt + have he := (exp_nonpositive_lipschitz hqt hqs).trans (exponent_time_lipschitz hη ht hs hA) + have hi := reciprocal_lipschitz hη ht hs + have hsInv : s⁻¹ ≤ η⁻¹ := inv_anti₀ hη hs + have hprod : |t⁻¹ * Real.exp (exponent t A) - s⁻¹ * Real.exp (exponent s A)| ≤ + (η⁻¹ ^ 2 + η⁻¹ * (1 + A / (4 * η ^ 2))) * |t - s| := by + have hid : t⁻¹ * Real.exp (exponent t A) - s⁻¹ * Real.exp (exponent s A) = + (t⁻¹ - s⁻¹) * Real.exp (exponent t A) + + s⁻¹ * (Real.exp (exponent t A) - Real.exp (exponent s A)) := by ring + rw [hid] + calc + _ ≤ |(t⁻¹ - s⁻¹) * Real.exp (exponent t A)| + + |s⁻¹ * (Real.exp (exponent t A) - Real.exp (exponent s A))| := abs_add_le _ _ + _ = |t⁻¹ - s⁻¹| * Real.exp (exponent t A) + + s⁻¹ * |Real.exp (exponent t A) - Real.exp (exponent s A)| := by + rw [abs_mul, abs_mul, abs_of_pos (Real.exp_pos _), abs_of_pos (inv_pos.mpr hs0)] + _ ≤ |t - s| / η ^ 2 + η⁻¹ * ((1 + A / (4 * η ^ 2)) * |t - s|) := by + apply add_le_add + · exact (mul_le_of_le_one_right (abs_nonneg _) hEt).trans hi + · exact mul_le_mul hsInv he (abs_nonneg _) (by positivity) + _ = _ := by ring + have hc : 0 ≤ (4 * Real.pi)⁻¹ := by positivity + have hc1 : (4 * Real.pi)⁻¹ ≤ 1 := by + apply (inv_le_one₀ (by positivity)).mpr + linarith [Real.two_le_pi] + have hid : kernel t A - kernel s A = (4 * Real.pi)⁻¹ * + (t⁻¹ * Real.exp (exponent t A) - s⁻¹ * Real.exp (exponent s A)) := by + unfold kernel + ring + rw [hid, abs_mul, abs_of_nonneg hc] + exact (mul_le_of_le_one_left (abs_nonneg _) hc1).trans hprod + +end ContinuumCoulomb.HeatKernelModulus + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatSampleError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatSampleError.lean new file mode 100644 index 0000000000000000000000000000000000000000..a18b96ef229b9a97b2ba09a640057c50d56094b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HeatSampleError.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatSample +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxBounds + +namespace OAI + +/-! Identification and uniform error of the literal rational samples used +in the box quadrature. The required Taylor magnitude follows from the +input radius and the positive time cutoff. -/ + +namespace ContinuumCoulomb + +theorem rationalPosition_eq_pair (q : ℚ × ℚ) : + PlanarForcingProgram.position q = planarPairEquiv.symm ((q.1 : ℝ), (q.2 : ℝ)) := by + rw [planarPairEquiv_symm_apply] + rfl + +namespace RationalHeatSample + +theorem error_density (x : Input) (ht : 0 < (x.2.1 : ℝ)) (hN : 0 < x.1.2.2) + (hM : |(exponent x.2 : ℝ)| ≤ x.1.1) : + |(value x : ℝ) - HeatKernelModulus.density (PlanarForcingProgram.position x.2.2.1) + (x.2.1 : ℝ) (PlanarForcingProgram.position x.2.2.2)| ≤ + ((2 ^ x.1.2.1 : ℝ)⁻¹ + 8 / (x.1.2.2 : ℝ)) / (4 * (x.2.1 : ℝ)) := by + have h := error x ht hN hM + rw [exact_density] at h + simpa only [HeatKernelModulus.density, HeatKernelModulus.kernel_eq_heat] using h + +theorem error_density_uniform (x : Input) {η : ℝ} (hη : 0 < η) (ht : η ≤ (x.2.1 : ℝ)) + (hN : 0 < x.1.2.2) (hM : |(exponent x.2 : ℝ)| ≤ x.1.1) : + |(value x : ℝ) - HeatKernelModulus.density (PlanarForcingProgram.position x.2.2.1) + (x.2.1 : ℝ) (PlanarForcingProgram.position x.2.2.2)| ≤ + ((2 ^ x.1.2.1 : ℝ)⁻¹ + 8 / (x.1.2.2 : ℝ)) / (4 * η) := by + apply (error_density x (hη.trans_le ht) hN hM).trans + apply div_le_div_of_nonneg_left (by positivity) (by positivity) + linarith + +theorem exponent_abs_le (a : Arguments) {η T : ℝ} (hη : 0 < η) + (ht : η ≤ (a.1 : ℝ)) (hT : (a.1 : ℝ) ≤ T) + (hy₁ : (a.2.2.1 : ℝ) ∈ Set.Icc (-1 : ℝ) 1) + (hy₂ : (a.2.2.2 : ℝ) ∈ Set.Icc (-1 : ℝ) 1) : + |(exponent a : ℝ)| ≤ + T + (‖PlanarForcingProgram.position a.2.1‖ + 2) ^ 2 / (4 * η) := by + have ht0 := hη.trans_le ht + have hd := planarPair_distance_bound (PlanarForcingProgram.position a.2.1) + (p := ((a.2.2.1 : ℝ), (a.2.2.2 : ℝ))) ⟨hy₁, hy₂⟩ + rw [← rationalPosition_eq_pair] at hd + have hsq : ‖PlanarForcingProgram.position a.2.1 - PlanarForcingProgram.position a.2.2‖ ^ 2 ≤ + (‖PlanarForcingProgram.position a.2.1‖ + 2) ^ 2 := + (sq_le_sq₀ (norm_nonneg _) (by positivity)).mpr hd + rw [abs_of_nonpos (exponent_nonpos a ht0)] + have he : (exponent a : ℝ) = -(a.1 : ℝ) - + ‖PlanarForcingProgram.position a.2.1 - PlanarForcingProgram.position a.2.2‖ ^ 2 / + (4 * (a.1 : ℝ)) := by + simp only [exponent, Rat.cast_sub, Rat.cast_neg, Rat.cast_div, Rat.cast_add, + Rat.cast_pow, Rat.cast_mul, Rat.cast_ofNat, position_sub_norm_sq] + rw [he] + have h₁ := div_le_div_of_nonneg_right hsq (show 0 ≤ 4 * (a.1 : ℝ) by positivity) + have h₂ := div_le_div_of_nonneg_left + (sq_nonneg (‖PlanarForcingProgram.position a.2.1‖ + 2)) + (show 0 < 4 * η by positivity) (show 4 * η ≤ 4 * (a.1 : ℝ) by linarith) + linarith + +end RationalHeatSample +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingBox.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..5513a8d016aeb5a647b2a85b2adb16d0cce988cd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingBox.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatSampleError + +namespace OAI + +/-! The actual contact numerator is an integral over the fixed forcing +square. Its translated sample point is represented exactly by rational +subtraction, so the concrete resolvent evaluator applies directly. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarHoppingNumerator (d : ℝ) : ℝ := ∫ r, planarHoppingIntegrand d r + +theorem planarHopping_eq_numerator (d : ℝ) : + planarHopping d = planarHoppingNumerator d / (2 * ∫ r, planarResolventMode r ^ 2) := rfl + +theorem planarHoppingNumerator_box (d : ℝ) : + planarHoppingNumerator d = ∫ x in (-1 : ℝ)..1, ∫ y in (-1 : ℝ)..1, + planarHoppingIntegrand d (planarPairEquiv.symm (x, y)) := by + unfold planarHoppingNumerator + rw [planarPair_integral] + let f := fun p : ℝ × ℝ => planarHoppingIntegrand d (planarPairEquiv.symm p) + have hf : Continuous f := (planarHoppingIntegrand_continuous d).comp planarPairEquiv_symm_continuous + have hi : IntegrableOn f (Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1) + ((volume : Measure ℝ).prod volume) := + hf.continuousOn.integrableOn_compact (isCompact_Icc.prod isCompact_Icc) + have hs : (∫ p, f p) = ∫ p in Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1, f p := by + symm + apply setIntegral_eq_integral_of_forall_compl_eq_zero + intro p hp + simp only [f, planarHoppingIntegrand, planarForcing_pair_zero hp, zero_mul] + change (∫ p, f p) = _ + rw [hs, Measure.volume_eq_prod, setIntegral_prod f hi] + simp_rw [integral_Icc_eq_integral_Ioc, + ← intervalIntegral.integral_of_le (by norm_num : (-1 : ℝ) ≤ 1)] + rfl + +theorem rationalPosition_shift_first (d a b : ℚ) : + PlanarForcingProgram.position (a - d, b) = + PlanarForcingProgram.position (a, b) - (d : ℝ) • planarAxis 0 := by + ext i + fin_cases i <;> simp [PlanarForcingProgram.position, planarAxis] + +theorem rationalShift_norm_bound (d a b : ℚ) {R : ℝ} + (hd : |(d : ℝ)| ≤ R) + (ha : (a : ℝ) ∈ Set.Icc (-1 : ℝ) 1) (hb : (b : ℝ) ∈ Set.Icc (-1 : ℝ) 1) : + ‖PlanarForcingProgram.position (a - d, b)‖ ≤ R + 2 := by + rw [rationalPosition_shift_first] + have hnorm : ‖PlanarForcingProgram.position (a, b)‖ ≤ 2 := by + rw [rationalPosition_eq_pair] + exact planarPair_norm_le_two ⟨ha, hb⟩ + have ht : ‖(d : ℝ) • planarAxis 0‖ ≤ R := by + rw [norm_smul, Real.norm_eq_abs, planarAxis_zero_norm, mul_one] + exact hd + exact (norm_sub_le _ _).trans (by linarith) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..11ebf915b31c8071f6d5cd7a67071bc0adfb6717 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingQuadrature.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingBox +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableResolvent +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalRectangleProgram + +namespace OAI + +/-! Literal compact contact quadrature, using the already certified +resolvent program at each translated rational point. -/ + +namespace ContinuumCoulomb.HoppingQuadrature +open ExactQuantumFactoring.BitStackProgram + +abbrev Settings := (ℕ × ℕ) × ℚ +abbrev Input := RationalRectangleProgram.Input Settings + +def settingsCode : Settings → List Bool := + prodCode (prodCode unaryCode unaryCode) ratCode + +def sample (e : Settings) (a b : ℚ) : ℚ := + PlanarForcingProgram.value (a, b) * + ResolventSchedule.approximate (e.1, (a - e.2, b)) + +def value (x : Input) : ℚ := RationalRectangleProgram.value sample x + +noncomputable opaque sampleProgram : + Procedure (prodCode (prodCode settingsCode ratCode) ratCode) ratCode + (fun x => sample x.1.1 x.1.2 x.2) := by + let ax := Procedure.first (prodCode settingsCode ratCode) ratCode + let e := (Procedure.first settingsCode ratCode).comp ax + let a := (Procedure.second settingsCode ratCode).comp ax + let b := Procedure.second (prodCode settingsCode ratCode) ratCode + let par := (Procedure.first (prodCode unaryCode unaryCode) ratCode).comp e + let d := (Procedure.second (prodCode unaryCode unaryCode) ratCode).comp e + let shift := Procedure.ratSub.comp (a.pair d) + let phi := ResolventSchedule.program.comp (par.pair (shift.pair b)) + let forcing := PlanarForcingProgram.program.comp (a.pair b) + exact (Procedure.ratMul.comp (forcing.pair phi)).congrFun (by intro x; rfl) + +noncomputable opaque program : + Procedure (RationalRectangleProgram.inputCode settingsCode) ratCode value := + RationalRectangleProgram.program settingsCode sample sampleProgram + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime (RationalRectangleProgram.inputCode settingsCode) ratCode value := + program.toTM2 + +theorem sample_error (e : Settings) (a b : ℚ) + (hR : ‖PlanarForcingProgram.position (a - e.2, b)‖ ≤ (e.1.1 : ℝ)) : + |(sample e a b : ℝ) - + planarHoppingIntegrand (e.2 : ℝ) (PlanarForcingProgram.position (a, b))| ≤ + ((e.1.2 : ℝ) + 1)⁻¹ := by + rw [sample, Rat.cast_mul, PlanarForcingProgram.value_cast, planarHoppingIntegrand, + ← rationalPosition_shift_first, ← mul_sub, abs_mul, + abs_of_nonneg (planarForcing_nonnegative _)] + exact (mul_le_mul_of_nonneg_left + (ResolventSchedule.approximation_error (e.1, (a - e.2, b)) hR) + (planarForcing_nonnegative _)).trans + (mul_le_of_le_one_left (by positivity) (planarForcing_le_one _)) + +theorem error (x : Input) (hh : 0 ≤ (x.2.2.2 : ℝ)) + (hR : ∀ i < x.1, ∀ j < x.1, + ‖PlanarForcingProgram.position + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i - x.2.1.2, + RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j)‖ ≤ (x.2.1.1.1 : ℝ)) : + |(value x : ℝ) - + ∫ a in (x.2.2.1 : ℝ)..(RationalQuadratureProgram.node x.2.2.1 x.2.2.2 x.1 : ℝ), + ∫ b in (x.2.2.1 : ℝ)..(RationalQuadratureProgram.node x.2.2.1 x.2.2.2 x.1 : ℝ), + planarHoppingIntegrand (x.2.1.2 : ℝ) (planarPairEquiv.symm (a, b))| ≤ + ((x.1 : ℝ) * (x.2.2.2 : ℝ)) ^ 2 * + (128 * (x.2.2.2 : ℝ) + ((x.2.1.1.2 : ℝ) + 1)⁻¹) := by + let f := fun a b => planarHoppingIntegrand (x.2.1.2 : ℝ) (planarPairEquiv.symm (a, b)) + let v := fun i j => (sample x.2.1 + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j) : ℝ) + have hx : ∀ a a' b, |f a b - f a' b| ≤ 64 * |a - a'| := by + intro a a' b + simpa only [f, planarPair_distance_first] using + planarHoppingIntegrand_norm_sub_explicit (x.2.1.2 : ℝ) + (planarPairEquiv.symm (a, b)) (planarPairEquiv.symm (a', b)) + have hy : ∀ a b b', |f a b - f a b'| ≤ 64 * |b - b'| := by + intro a b b' + simpa only [f, planarPair_distance_second] using + planarHoppingIntegrand_norm_sub_explicit (x.2.1.2 : ℝ) + (planarPairEquiv.symm (a, b)) (planarPairEquiv.symm (a, b')) + have hs : ∀ i < x.1, ∀ j < x.1, + |v i j - f (UniformQuadrature.node (x.2.2.1 : ℝ) (x.2.2.2 : ℝ) i) + (UniformQuadrature.node (x.2.2.1 : ℝ) (x.2.2.2 : ℝ) j)| ≤ + ((x.2.1.1.2 : ℝ) + 1)⁻¹ := by + intro i hi j hj + have h := sample_error x.2.1 _ _ (hR i hi j hj) + simpa only [v, f, rationalPosition_eq_pair, RationalQuadratureProgram.node_cast] using h + have h := UniformQuadrature.rectangle_error f v _ _ x.1 _ _ x.1 hh hh + (by norm_num : (0 : ℝ) ≤ 64) (by norm_num : (0 : ℝ) ≤ 64) + (fun a _ a' _ b _ => hx a a' b) (fun a _ b _ b' _ => hy a b b') hs + rw [value, RationalRectangleProgram.value_cast] + simp only [RationalQuadratureProgram.node_cast] + convert h using 1 + ring + +end ContinuumCoulomb.HoppingQuadrature + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..4838b79d3b0c2e2f897c741afb880913dc00a8c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HoppingSchedule.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingQuadrature + +namespace OAI + +/-! An explicit polynomial mesh and inner precision for the actual compact +hopping numerator. The displacement is an input rational, not an oracle. -/ + +noncomputable section +namespace ContinuumCoulomb.HoppingSchedule + +abbrev Input := (ℕ × ℕ) × ℚ + +def mesh (P : ℕ) : ℕ := 4096 * (P + 1) +def accuracy (P : ℕ) : ℕ := 16 * (P + 1) + +def argument (x : Input) : HoppingQuadrature.Input := + (mesh x.1.2, (((x.1.1 + 2, accuracy x.1.2), x.2), + (-1, 2 / (mesh x.1.2 : ℚ)))) + +def approximate (x : Input) : ℚ := HoppingQuadrature.value (argument x) + +theorem mesh_positive (P : ℕ) : 0 < mesh P := by unfold mesh; positivity + +theorem argument_step_nonnegative (x : Input) : 0 ≤ ((argument x).2.2.2 : ℝ) := by + change 0 ≤ ((2 / (mesh x.1.2 : ℚ) : ℚ) : ℝ) + positivity + +theorem argument_endpoint (x : Input) : + RationalQuadratureProgram.node (argument x).2.2.1 (argument x).2.2.2 + (argument x).1 = 1 := by + have hN : (mesh x.1.2 : ℚ) ≠ 0 := by exact_mod_cast (mesh_positive x.1.2).ne' + change -(1 : ℚ) + (mesh x.1.2 : ℚ) * (2 / (mesh x.1.2 : ℚ)) = 1 + field_simp + ring + +theorem argument_node_mem (x : Input) (i : ℕ) (hi : i ≤ (argument x).1) : + (RationalQuadratureProgram.node (argument x).2.2.1 (argument x).2.2.2 i : ℝ) ∈ + Set.Icc (-1 : ℝ) 1 := by + have h := UniformQuadrature.node_mem (a := ((argument x).2.2.1 : ℝ)) + (argument_step_nonnegative x) hi + rw [← RationalQuadratureProgram.node_cast, ← RationalQuadratureProgram.node_cast, + argument_endpoint x] at h + simpa only [argument, Rat.cast_neg, Rat.cast_one] using h + +theorem argument_nodes_norm (x : Input) (hd : |(x.2 : ℝ)| ≤ (x.1.1 : ℝ)) + (i j : ℕ) (hi : i < (argument x).1) (hj : j < (argument x).1) : + ‖PlanarForcingProgram.position + (RationalQuadratureProgram.node (argument x).2.2.1 (argument x).2.2.2 i - + (argument x).2.1.2, + RationalQuadratureProgram.node (argument x).2.2.1 (argument x).2.2.2 j)‖ ≤ + ((argument x).2.1.1.1 : ℝ) := by + have h := rationalShift_norm_bound x.2 _ _ hd + (argument_node_mem x i hi.le) (argument_node_mem x j hj.le) + simpa only [argument, Nat.cast_add, Nat.cast_ofNat] using h + +theorem numerical_budget {S : ℝ} (hS : 0 < S) : + 4 * (128 * (2 / (4096 * S)) + (16 * S + 1)⁻¹) ≤ S⁻¹ := by + have hm : 4 * (128 * (2 / (4096 * S))) = (4 * S)⁻¹ := by + field_simp [hS.ne'] + ring + have ha : 4 * (16 * S + 1)⁻¹ ≤ (4 * S)⁻¹ := by + calc + _ ≤ 4 * (16 * S)⁻¹ := mul_le_mul_of_nonneg_left + (inv_anti₀ (by positivity) (by linarith)) (by norm_num) + _ = _ := by field_simp [hS.ne']; ring + rw [mul_add, hm] + have he : 2 * (4 * S)⁻¹ ≤ S⁻¹ := by + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr hS] + linarith + +theorem approximation_error (x : Input) (hd : |(x.2 : ℝ)| ≤ (x.1.1 : ℝ)) : + |(approximate x : ℝ) - planarHoppingNumerator (x.2 : ℝ)| ≤ ((x.1.2 : ℝ) + 1)⁻¹ := by + have hquad := HoppingQuadrature.error (argument x) (argument_step_nonnegative x) + (fun i hi j hj => argument_nodes_norm x hd i j hi hj) + rw [argument_endpoint x] at hquad + have hlen : (mesh x.1.2 : ℝ) * (2 / (mesh x.1.2 : ℝ)) = 2 := by + have hn : (mesh x.1.2 : ℝ) ≠ 0 := by exact_mod_cast (mesh_positive x.1.2).ne' + field_simp + have hquad' : |(approximate x : ℝ) - planarHoppingNumerator (x.2 : ℝ)| ≤ + 4 * (128 * (2 / (mesh x.1.2 : ℝ)) + ((accuracy x.1.2 : ℝ) + 1)⁻¹) := by + rw [planarHoppingNumerator_box] + simpa only [approximate, argument, Rat.cast_neg, Rat.cast_one, Rat.cast_div, + Rat.cast_ofNat, Rat.cast_natCast, hlen, show (2 : ℝ) ^ 2 = 4 by norm_num] + using hquad + apply hquad'.trans + convert numerical_budget (S := (x.1.2 : ℝ) + 1) (by positivity) using 1 + simp only [mesh, accuracy, Nat.cast_mul, Nat.cast_ofNat, Nat.cast_add, Nat.cast_one] + +end ContinuumCoulomb.HoppingSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HydrogenInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HydrogenInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac69bdd8b5ee0631c458d9bb81b04e68ee0b0832 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/HydrogenInput.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.IsolatedSpectrum + +namespace OAI + +/-! +# Minimal published hydrogen input for isolated-well energies + +Gerald Teschl, *Mathematical Methods in Quantum Mechanics*, second edition, +AMS Graduate Studies in Mathematics 157 (2014), Theorem 10.10, equations +(10.5) and (10.64): the lowest eigenvalue of `-Δ-γ/|x|` is `-γ²/4`. +Set `γ=2`, divide the operator by two, and translate the centre. The exact +specialization used below is `PublishedHydrogenBottom`. Spin contributes two +identical summands and does not alter the bottom. +https://www.mat.univie.ac.at/~gerald/ftp/book-schroe/schroe2.pdf . + +This conditional interface assumes the unperturbed hydrogen bottom. +The isolated-well comparison follows by a variational perturbation argument. +-/ + +noncomputable section +namespace ContinuumCoulomb + +/-- Exact published hydrogen bottom, specialized to the unperturbed well. -/ +def PublishedHydrogenBottom : Prop := + ∀ a : Position, hydrogenEnergy a = ((-1 / 2 : ℝ) : EReal) + +theorem isolatedWellEnergy_near_hydrogen (hhydrogen : PublishedHydrogenBottom) + {m : ℕ} {D q q' epsilon : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hprimary : |1 - q| ≤ epsilon) (hsecondary : q' ≤ epsilon) + (hbackground : 48 * m / D ≤ epsilon) (hsmall : 10 * epsilon ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) : + |(isolatedWellEnergy D q q' center displacement site).toReal + 1 / 2| ≤ + 45 * epsilon := by + have h := isolatedWellEnergy_relative hD hq hq1 hq' hq'1 hprimary hsecondary hbackground + hsmall center displacement hdisp site + rw [hhydrogen (center site), EReal.toReal_coe] at h + calc + _ = |(isolatedWellEnergy D q q' center displacement site).toReal - (-1 / 2)| := by + congr 1 + ring + _ ≤ 10 * epsilon * ((-1 / 2 : ℝ) + 5) := h + _ = _ := by ring + +/-- The actual rationally computed integer charges give the required uniform +energy closeness throughout the displacement cube, conditionally only on the +published unperturbed hydrogen bottom. -/ +theorem binary_isolatedWellEnergy_bound (hhydrogen : PublishedHydrogenBottom) + {D m : ℕ} (hm : 0 < m) (hscale : 10010 * m ≤ D) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) : + |(isolatedWellEnergy D (binaryPrimaryRatio D m) (binarySecondaryRatio D m) + center displacement site).toReal + 1 / 2| ≤ 45045 * m / (D : ℝ) := by + have hscale' : 2002 * m ≤ D := by omega + have h := binaryWellCharges_spec hm hscale' + have hm1 : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hDlarge : (10010 : ℝ) * m ≤ D := by exact_mod_cast hscale + have hD : (0 : ℝ) < D := by linarith + have hr : 0 ≤ (m : ℝ) / D := by positivity + have hs0 : 0 ≤ binarySecondaryRatio D m := + (by positivity : (0 : ℝ) ≤ 999 * m / D).trans h.2.2.2.2.2.1 + have hsmall : 10 * (1001 * m / (D : ℝ)) ≤ 1 := by + have h : (10010 : ℝ) * m / D ≤ 1 := (div_le_iff₀ hD).mpr (by linarith) + convert h using 1 + ring + have hprimary : |1 - binaryPrimaryRatio D m| ≤ 1001 * m / (D : ℝ) := by + apply h.2.2.2.2.1.trans + simpa only [mul_div_assoc] using + mul_le_mul_of_nonneg_right (by norm_num : (501 : ℝ) ≤ 1001) hr + have hbackground : 48 * m / (D : ℝ) ≤ 1001 * m / D := by + simpa only [mul_div_assoc] using + mul_le_mul_of_nonneg_right (by norm_num : (48 : ℝ) ≤ 1001) hr + have hbound := isolatedWellEnergy_near_hydrogen hhydrogen + (by linarith : (128 : ℝ) ≤ D) h.2.2.1 h.2.2.2.1 hs0 h.2.2.2.2.2.2.2 + hprimary h.2.2.2.2.2.2.1 hbackground hsmall center displacement hdisp site + convert hbound using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthCutoffGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthCutoffGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a42aa5128612c1a6635871796796728d03e9318 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthCutoffGrid.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.InverseFifthGrid + +namespace OAI + +/-! Far-grid inverse-fifth sums with the orbital cutoff radius retained. +The bound is independent of both box volume and mesh resolution. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem inverseFifth_cutoff_cube_bound {h R : ℝ} (hh : 0 < h) (hR : 0 < R) + (hhR : h ≤ R) (y b : Position) (hfar : 4*R ≤ ‖y-b‖) : + h^3/‖y-b‖^5 ≤ 32*(∫ x in positionCube b h, inverseFifthTail R (y-x)) := by + have hd : 0 < ‖y-b‖ := lt_of_lt_of_le (by positivity) hfar + have hi := translatedInverseFifth_integrable y hR + have he := setIntegral_mono_on + (integrableOn_const (C := 1/‖y-b‖^5) + ((positionCube_isCompact b hh.le).measure_lt_top (μ := volume)).ne) + (hi.const_mul 32).integrableOn (positionCube_isClosed b h).measurableSet (fun x hx => ?_) + · have hv : (volume.restrict (positionCube b h)).real Set.univ = h^3 := by + simpa only [Measure.real,Measure.restrict_apply_univ] using positionCube_volume b hh.le + simpa only [integral_const,smul_eq_mul,hv,integral_const_mul, + div_eq_mul_inv,mul_one,one_mul] using he + · have hn := positionCube_norm_sub_le hh.le hx + have ha := norm_sub_le_norm_sub_add_norm_sub y x b + have hu := (norm_sub_le_norm_sub_add_norm_sub y b x) + rw [norm_sub_rev b x] at hu + have hdx : R < ‖y-x‖ := by linarith + have hupper : ‖y-x‖ ≤ 2*‖y-b‖ := by linarith + rw [inverseFifthTail_eq_inv_pow _ hdx,mul_one_div] + apply (div_le_div_iff₀ (pow_pos hd 5) (pow_pos (hR.trans hdx) 5)).mpr + have hp := pow_le_pow_left₀ (norm_nonneg (y-x)) hupper 5 + nlinarith [show (2*‖y-b‖)^5 = 32*‖y-b‖^5 by ring] + +theorem inverseFifth_cutoff_grid_sum {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h R : ℝ} (hh : 0 < h) (hR : 0 < R) (hhR : h ≤ R) (y : Position) + (hfar : ∀ i, 4*R ≤ ‖y-gaussCellCenter h (index i)‖) : + (∑ i, h^3/‖y-gaussCellCenter h (index i)‖^5) ≤ 64*Real.pi/R^2 := by + calc + _ ≤ ∑ i, 32*(∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail R (y-x)) := + Finset.sum_le_sum (fun i _ => inverseFifth_cutoff_cube_bound hh hR hhR y _ (hfar i)) + _ = 32*(∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail R (y-x)) := (Finset.mul_sum _ _ _).symm + _ ≤ 32*(∫ x, inverseFifthTail R (y-x)) := + mul_le_mul_of_nonneg_left (grid_cell_integral_sum_le index hindex hh _ + (translatedInverseFifth_integrable y hR) (fun x => inverseFifthTail_nonneg R (y-x))) + (by norm_num) + _ = _ := by rw [translatedInverseFifth_integral y hR]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9cad251468fa87c138b3dd2520335fdf8b81b99 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/InverseFifthGrid.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombInverseFifth +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombFarCell + +namespace OAI + +/-! Inverse-fifth far-cell sums are bounded independently of box volume. +The proof compares each actual cube to the integrable radial tail. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem far_cube_distances {h : ℝ} (hh : 0 < h) {y b x : Position} + (hfar : 4*h ≤ ‖y-b‖) (hx : x ∈ positionCube b h) : + h < ‖y-x‖ ∧ ‖y-b‖/2 ≤ ‖y-x‖ ∧ ‖y-x‖ ≤ 2*‖y-b‖ := by + have hn := positionCube_norm_sub_le hh.le hx + have ha := norm_sub_le_norm_sub_add_norm_sub y x b + have hb := norm_sub_le_norm_sub_add_norm_sub y b x + rw [norm_sub_rev b x] at hb + constructor + · linarith + constructor <;> linarith + +theorem inverseFifth_far_cube_bound {h : ℝ} (hh : 0 < h) (y b : Position) + (hfar : 4*h ≤ ‖y-b‖) : + h^3/‖y-b‖^5 ≤ 32*(∫ x in positionCube b h, inverseFifthTail h (y-x)) := by + have hd : 0 < ‖y-b‖ := lt_of_lt_of_le (by positivity) hfar + have hi := translatedInverseFifth_integrable y hh + have hm := (positionCube_isClosed b h).measurableSet + have hc := ((positionCube_isCompact b hh.le).measure_lt_top (μ := volume)).ne + have he := setIntegral_mono_on + (integrableOn_const (C := 1/‖y-b‖^5) hc) + (hi.const_mul 32).integrableOn hm (fun x hx => ?_) + · have hv : (volume.restrict (positionCube b h)).real Set.univ = h^3 := by + simpa only [Measure.real,Measure.restrict_apply_univ] using positionCube_volume b hh.le + simpa only [integral_const,smul_eq_mul,hv,integral_const_mul, + div_eq_mul_inv,mul_one,one_mul] using he + · obtain ⟨hgt,_hl,hu⟩ := far_cube_distances hh hfar hx + rw [inverseFifthTail_eq_inv_pow _ hgt] + have hdx : 0 < ‖y-x‖ := hh.trans hgt + rw [mul_one_div] + apply (div_le_div_iff₀ (pow_pos hd 5) (pow_pos hdx 5)).mpr + have hp := pow_le_pow_left₀ (norm_nonneg (y-x)) hu 5 + nlinarith [show (2*‖y-b‖)^5 = 32*‖y-b‖^5 by ring] + +theorem inverseFifth_grid_sum_bound {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h : ℝ} (hh : 0 < h) (y : Position) + (hfar : ∀ i, 4*h ≤ ‖y-gaussCellCenter h (index i)‖) : + (∑ i, h^3/‖y-gaussCellCenter h (index i)‖^5) ≤ 64*Real.pi/h^2 := by + calc + _ ≤ ∑ i, 32*(∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail h (y-x)) := + Finset.sum_le_sum (fun i _ => inverseFifth_far_cube_bound hh y _ (hfar i)) + _ = 32*(∑ i, ∫ x in positionCube (gaussCellCenter h (index i)) h, + inverseFifthTail h (y-x)) := (Finset.mul_sum _ _ _).symm + _ ≤ 32*(∫ x, inverseFifthTail h (y-x)) := + mul_le_mul_of_nonneg_left (grid_cell_integral_sum_le index hindex hh _ + (translatedInverseFifth_integrable y hh) (fun x => inverseFifthTail_nonneg h (y-x))) + (by norm_num) + _ = _ := by rw [translatedInverseFifth_integral y hh]; ring + +theorem coulomb_far_grid_error : + ∃ C : ℝ, 1 ≤ C ∧ ∀ {ι : Type} [Fintype ι] + (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → ∀ (y : Position), + (∀ i, 4*h ≤ ‖y-gaussCellCenter h (index i)‖) → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-x)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-x)))| ≤ C*h^2 := by + obtain ⟨C,hC,hbound⟩ := coulomb_far_cell_error + refine ⟨2048*Real.pi*C,?_,?_⟩ + · have hp := Real.pi_gt_three + nlinarith + · intro ι _ index hindex h hh y hfar + have he (i : ι) : + |positionCellGauss (gaussCellCenter h (index i)) h (fun x => Coulomb.coulombKernel (y-x))- + positionCellIntegral (gaussCellCenter h (index i)) h (fun x => Coulomb.coulombKernel (y-x))| ≤ + (32*C*h^4)*(h^3/‖y-gaussCellCenter h (index i)‖^5) := by + have hd : 0 < ‖y-gaussCellCenter h (index i)‖ := lt_of_lt_of_le (by positivity) (hfar i) + have hi := hbound y (gaussCellCenter h (index i)) h + (‖y-gaussCellCenter h (index i)‖/2) hh.le (by positivity) + (fun x hx v hv z hz => (far_cube_distances hh (hfar i) + (cubePoint_mem_positionCube _ hh.le hx hv hz)).2.1) + apply hi.trans_eq + field_simp + ring + calc + _ ≤ ∑ i, |positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-x))- + positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-x))| := by + rw [← Finset.sum_sub_distrib] + exact Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ i, (32*C*h^4)*(h^3/‖y-gaussCellCenter h (index i)‖^5) := + Finset.sum_le_sum (fun i _ => he i) + _ = (32*C*h^4)*(∑ i, h^3/‖y-gaussCellCenter h (index i)‖^5) := + (Finset.mul_sum _ _ _).symm + _ ≤ (32*C*h^4)*(64*Real.pi/h^2) := + mul_le_mul_of_nonneg_left (inverseFifth_grid_sum_bound index hindex hh y hfar) + (by positivity) + _ = _ := by field_simp [hh.ne']; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedForms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedForms.lean new file mode 100644 index 0000000000000000000000000000000000000000..5714925fe44a71369843ba6d923114fb5e1eac68 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedForms.lean @@ -0,0 +1,241 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.BinaryWellCharges + +namespace OAI + +/-! +# Isolated-well energy forms on the actual weak H¹ domain + +The perturbation bounds here concern the full one-electron form, including +both Coulomb poles and the capped background. They give the shifted relative +form comparison used before constructing isolated eigenfunctions. +-/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def singlePoleEnergy (a : Position) (state : Coulomb.H1Vector 1) : ℝ := + ∑ spin, ∫ x, Coulomb.coulombKernel (Coulomb.position x 0 - a) * + ‖state.value spin x‖ ^ 2 + +def hydrogenForm (a : Position) (state : Coulomb.H1Vector 1) : ℝ := + Coulomb.kinetic state - singlePoleEnergy a state + +def backgroundEnergy {m : ℕ} (D q q' : ℝ) (center displacement : Fin m → Position) + (site : Fin m) (state : Coulomb.H1Vector 1) : ℝ := + ∑ spin, ∫ x, backgroundPotential D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2 + +def isolatedWellForm {m : ℕ} (D q q' : ℝ) (center displacement : Fin m → Position) + (site : Fin m) (state : Coulomb.H1Vector 1) : ℝ := + Coulomb.kinetic state - q * singlePoleEnergy (center site) state - + q' * singlePoleEnergy (center site + displacement site) state - + backgroundEnergy D q q' center displacement site state + +theorem singlePoleEnergy_nonneg (a : Position) (state : Coulomb.H1Vector 1) : + 0 ≤ singlePoleEnergy a state := by + apply Finset.sum_nonneg + intro spin _ + exact integral_nonneg fun x => by unfold Coulomb.coulombKernel; positivity + +theorem singlePoleEnergy_bound (a : Position) (state : Coulomb.H1Vector 1) + {eta : ℝ} (heta : 0 < eta) : + singlePoleEnergy a state ≤ 8 * eta * Coulomb.kinetic state + + (1 / (4 * eta)) * Coulomb.mass state := by + have h := Finset.sum_le_sum (s := Finset.univ) fun spin _ => + (state.nuclear_coulomb_integrable_bound spin 0 a heta).2 + apply h.trans_eq + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, Coulomb.kinetic, Coulomb.mass, + Fintype.sum_prod_type, Fin.sum_univ_one] + ring + +theorem hydrogenForm_coercive (a : Position) (state : Coulomb.H1Vector 1) : + Coulomb.kinetic state / 2 - 4 * Coulomb.mass state ≤ hydrogenForm a state := by + have h := singlePoleEnergy_bound a state (by norm_num : (0 : ℝ) < 1 / 16) + norm_num at h + unfold hydrogenForm + linarith + +theorem background_energy_integrable {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) (spin : Coulomb.Spins 1) : + Integrable (fun x => backgroundPotential D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2) := by + have hrho := (state.value_L2 spin).integrable_norm_pow (by norm_num : (2 : ℕ) ≠ 0) + have hcont : Continuous (fun x : Configuration 1 => + backgroundPotential D q q' center displacement site (Coulomb.position x 0)) := by + apply (backgroundPotential_contDiff_two hD center displacement hdisp site).continuous.comp + unfold Coulomb.position + fun_prop + apply (hrho.const_mul (48 * m / D)).mono' + (hcont.aestronglyMeasurable.mul ((state.value_L2 spin).aestronglyMeasurable.norm.pow 2)) + exact Filter.Eventually.of_forall fun x => by + have h := backgroundPotential_bounds hD hq hq1 hq' hq'1 center displacement hdisp site + (Coulomb.position x 0) + dsimp only [Pi.mul_apply, Pi.pow_apply] + rw [Real.norm_eq_abs, abs_mul, abs_of_nonneg h.1, abs_of_nonneg (sq_nonneg _)] + exact mul_le_mul_of_nonneg_right h.2 (sq_nonneg _) + +theorem backgroundEnergy_bounds {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + 0 ≤ backgroundEnergy D q q' center displacement site state ∧ + backgroundEnergy D q q' center displacement site state ≤ + (48 * m / D) * Coulomb.mass state := by + constructor + · exact Finset.sum_nonneg fun spin _ => integral_nonneg fun x => + mul_nonneg (backgroundPotential_bounds hD hq hq1 hq' hq'1 center displacement + hdisp site (Coulomb.position x 0)).1 (sq_nonneg _) + · unfold backgroundEnergy Coulomb.mass + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro spin _ + rw [← integral_const_mul] + apply integral_mono + (background_energy_integrable hD hq hq1 hq' hq'1 center displacement hdisp site state spin) + (((state.value_L2 spin).integrable_norm_pow (by norm_num : (2 : ℕ) ≠ 0)).const_mul _) + intro x + exact mul_le_mul_of_nonneg_right + (backgroundPotential_bounds hD hq hq1 hq' hq'1 center displacement hdisp site + (Coulomb.position x 0)).2 (sq_nonneg _) + +theorem isolatedWellForm_coercive {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + Coulomb.kinetic state / 2 - (16 + 48 * m / D) * Coulomb.mass state ≤ + isolatedWellForm D q q' center displacement site state := by + have hp := singlePoleEnergy_bound (center site) state (by norm_num : (0 : ℝ) < 1 / 32) + have hs := singlePoleEnergy_bound (center site + displacement site) state + (by norm_num : (0 : ℝ) < 1 / 32) + have hqp := mul_le_of_le_one_left (singlePoleEnergy_nonneg (center site) state) hq1 + have hqs := mul_le_of_le_one_left + (singlePoleEnergy_nonneg (center site + displacement site) state) hq'1 + have hb := (backgroundEnergy_bounds hD hq hq1 hq' hq'1 + center displacement hdisp site state).2 + norm_num at hp hs + unfold isolatedWellForm + linarith + +theorem isolatedWellForm_difference {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + isolatedWellForm D q q' center displacement site state - hydrogenForm (center site) state = + ∑ spin, ∫ x, isolatedPerturbation D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2 := by + have heq (spin : Coulomb.Spins 1) : + (∫ x, isolatedPerturbation D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2) = + (1 - q) * (∫ x, Coulomb.coulombKernel (Coulomb.position x 0 - center site) * + ‖state.value spin x‖ ^ 2) - + q' * (∫ x, Coulomb.coulombKernel (Coulomb.position x 0 - (center site + displacement site)) * + ‖state.value spin x‖ ^ 2) - + (∫ x, backgroundPotential D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2) := by + have hp := (state.nuclear_coulomb_integrable_bound spin 0 (center site) + (by norm_num : (0 : ℝ) < 1)).1 + have hs := (state.nuclear_coulomb_integrable_bound spin 0 (center site + displacement site) + (by norm_num : (0 : ℝ) < 1)).1 + have hb := background_energy_integrable hD hq hq1 hq' hq'1 + center displacement hdisp site state spin + have hsub : ∀ x : Configuration 1, + Coulomb.position x 0 - center site - displacement site = + Coulomb.position x 0 - (center site + displacement site) := by intro x; abel + let p := fun x : Configuration 1 => + Coulomb.coulombKernel (Coulomb.position x 0 - center site) * ‖state.value spin x‖ ^ 2 + let s := fun x : Configuration 1 => + Coulomb.coulombKernel (Coulomb.position x 0 - (center site + displacement site)) * + ‖state.value spin x‖ ^ 2 + let b := fun x : Configuration 1 => + backgroundPotential D q q' center displacement site (Coulomb.position x 0) * + ‖state.value spin x‖ ^ 2 + have hpoint : (fun x => isolatedPerturbation D q q' center displacement site + (Coulomb.position x 0) * ‖state.value spin x‖ ^ 2) = + (fun x => (1 - q) * p x - q' * s x - b x) := by + funext x + dsimp [isolatedPerturbation, p, s, b] + rw [hsub] + ring + rw [hpoint] + have hsum := integral_sub ((hp.const_mul (1 - q)).sub (hs.const_mul q')) hb + change (∫ x, (1 - q) * p x - q' * s x - b x) = _ at hsum + have hsum' := integral_sub (hp.const_mul (1 - q)) (hs.const_mul q') + change (∫ x, (1 - q) * p x - q' * s x) = _ at hsum' + rw [hsum] + dsimp only [Pi.sub_apply] + rw [hsum'] + simp only [integral_const_mul] + simp_rw [heq] + simp only [Finset.sum_sub_distrib, ← Finset.mul_sum, + isolatedWellForm, hydrogenForm, singlePoleEnergy, backgroundEnergy] + ring + +theorem isolatedWellForm_small_difference {m : ℕ} {D q q' epsilon : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hprimary : |1 - q| ≤ epsilon) (hsecondary : q' ≤ epsilon) + (hbackground : 48 * m / D ≤ epsilon) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + |isolatedWellForm D q q' center displacement site state - hydrogenForm (center site) state| ≤ + 5 * epsilon * (Coulomb.kinetic state + Coulomb.mass state) := by + have hepsilon : 0 ≤ epsilon := hq'.trans hsecondary + have hp0 := singlePoleEnergy_nonneg (center site) state + have hs0 := singlePoleEnergy_nonneg (center site + displacement site) state + have hp := singlePoleEnergy_bound (center site) state (by norm_num : (0 : ℝ) < 1 / 8) + have hs := singlePoleEnergy_bound (center site + displacement site) state + (by norm_num : (0 : ℝ) < 1 / 8) + norm_num at hp hs + have hb := backgroundEnergy_bounds hD hq hq1 hq' hq'1 center displacement hdisp site state + have hdefect : |1 - q| * singlePoleEnergy (center site) state ≤ + epsilon * (Coulomb.kinetic state + 2 * Coulomb.mass state) := + mul_le_mul hprimary hp hp0 hepsilon + have hsecond : q' * singlePoleEnergy (center site + displacement site) state ≤ + epsilon * (Coulomb.kinetic state + 2 * Coulomb.mass state) := + mul_le_mul hsecondary hs hs0 hepsilon + have hbg := hb.2.trans (mul_le_mul_of_nonneg_right hbackground (Coulomb.mass_nonneg state)) + have heq : isolatedWellForm D q q' center displacement site state - + hydrogenForm (center site) state = + (1 - q) * singlePoleEnergy (center site) state - + q' * singlePoleEnergy (center site + displacement site) state - + backgroundEnergy D q q' center displacement site state := by + unfold isolatedWellForm hydrogenForm + ring + rw [heq] + calc + _ ≤ |(1 - q) * singlePoleEnergy (center site) state| + + |q' * singlePoleEnergy (center site + displacement site) state| + + |backgroundEnergy D q q' center displacement site state| := + (abs_sub _ _).trans (add_le_add (abs_sub _ _) le_rfl) + _ = |1 - q| * singlePoleEnergy (center site) state + + q' * singlePoleEnergy (center site + displacement site) state + + backgroundEnergy D q q' center displacement site state := by + rw [abs_mul, abs_mul, abs_of_nonneg hp0, abs_of_nonneg hq', + abs_of_nonneg hs0, abs_of_nonneg hb.1] + _ ≤ _ := by nlinarith [mul_nonneg hepsilon (Coulomb.kinetic_nonneg state)] + +/-- The actual isolated well is a small relative perturbation of the shifted +hydrogen form. This holds on every spinful weak-H¹ state. -/ +theorem isolatedWellForm_relative {m : ℕ} {D q q' epsilon : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hprimary : |1 - q| ≤ epsilon) (hsecondary : q' ≤ epsilon) + (hbackground : 48 * m / D ≤ epsilon) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + |isolatedWellForm D q q' center displacement site state - hydrogenForm (center site) state| ≤ + 10 * epsilon * (hydrogenForm (center site) state + 5 * Coulomb.mass state) := by + have h := isolatedWellForm_small_difference hD hq hq1 hq' hq'1 hprimary hsecondary + hbackground center displacement hdisp site state + have hc := hydrogenForm_coercive (center site) state + have hepsilon : 0 ≤ epsilon := hq'.trans hsecondary + exact h.trans (by nlinarith [mul_nonneg hepsilon (Coulomb.mass_nonneg state), + mul_le_mul_of_nonneg_left hc hepsilon]) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedPerturbation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f33c200834c6aa8121613768a29c96bf95e67377 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedPerturbation.lean @@ -0,0 +1,209 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCapRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearRounding + +namespace OAI + +/-! +# Actual isolated-well perturbation on weak H¹ states + +The difference from a unit hydrogen centre is the small change of primary +charge, the weak secondary Coulomb pole, and the bounded capped background. +No isolated eigenfunction or perturbative spectral conclusion is assumed. +-/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem nuclear_mul_memLp {n : ℕ} (state : Coulomb.H1Vector n) + (spin : Coulomb.Spins n) (i : Fin n) (a : Position) : + MemLp (fun x => (Coulomb.coulombKernel (Coulomb.position x i - a) : ℂ) * + state.value spin x) 2 := by + have hm := Coulomb.measurable_hardyCoulomb i (Coulomb.nuclearHardyCoordinates i a) + change Measurable (fun x => + Coulomb.hardyCoulomb i (Coulomb.nuclearHardyCoordinates i a) x) at hm + simp only [Coulomb.hardyCoulomb_nuclear] at hm + have hmeas : AEStronglyMeasurable (fun x => + (Coulomb.coulombKernel (Coulomb.position x i - a) : ℂ) * state.value spin x) volume := + hm.complex_ofReal.aestronglyMeasurable.mul (state.value_L2 spin).aestronglyMeasurable + apply (memLp_two_iff_integrable_sq_norm hmeas).2 + simpa only [norm_mul, Complex.norm_real, Real.norm_eq_abs, mul_pow, sq_abs] using + (nuclear_hardy_square state spin i a).1 + +def isolatedPerturbation {m : ℕ} (D q q' : ℝ) (center displacement : Fin m → Position) + (site : Fin m) (x : Position) : ℝ := + (1 - q) * Coulomb.coulombKernel (x - center site) - + q' * Coulomb.coulombKernel (x - center site - displacement site) - + backgroundPotential D q q' center displacement site x + +theorem background_mul_memLp {m n : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector n) (spin : Coulomb.Spins n) (i : Fin n) : + MemLp (fun x => (backgroundPotential D q q' center displacement site + (Coulomb.position x i) : ℂ) * state.value spin x) 2 := by + apply Coulomb.memLp_two_real_mul (state.value_L2 spin) + · apply (backgroundPotential_contDiff_two hD center displacement hdisp site).continuous.comp + unfold Coulomb.position + fun_prop + · intro x + have h := backgroundPotential_bounds hD hq hq1 hq' hq'1 center displacement hdisp site + (Coulomb.position x i) + exact (abs_of_nonneg h.1).trans_le h.2 + +theorem isolatedPerturbation_mul_memLp {m n : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector n) (spin : Coulomb.Spins n) (i : Fin n) : + MemLp (fun x => (isolatedPerturbation D q q' center displacement site + (Coulomb.position x i) : ℂ) * state.value spin x) 2 := by + have hp := (nuclear_mul_memLp state spin i (center site)).const_mul ((1 - q : ℝ) : ℂ) + have hs := (nuclear_mul_memLp state spin i (center site + displacement site)).const_mul (q' : ℂ) + have hb := background_mul_memLp hD hq hq1 hq' hq'1 center displacement hdisp site state spin i + convert (hp.sub hs).sub hb using 1 + funext x + dsimp [isolatedPerturbation] + have he : Coulomb.position x i - center site - displacement site = + Coulomb.position x i - (center site + displacement site) := by abel + rw [he] + push_cast + ring + +private theorem norm_sub_sub_sq_le (a b c : ℂ) : + ‖a - b - c‖ ^ 2 ≤ 3 * (‖a‖ ^ 2 + ‖b‖ ^ 2 + ‖c‖ ^ 2) := by + have htri : ‖a - b - c‖ ≤ ‖a‖ + ‖b‖ + ‖c‖ := + (norm_sub_le _ _).trans (add_le_add (norm_sub_le _ _) le_rfl) + have hsq := (sq_le_sq₀ (norm_nonneg (a - b - c)) + (by positivity : 0 ≤ ‖a‖ + ‖b‖ + ‖c‖)).mpr htri + nlinarith [sq_nonneg (‖a‖ - ‖b‖), sq_nonneg (‖a‖ - ‖c‖), sq_nonneg (‖b‖ - ‖c‖)] + +theorem isolatedPerturbation_spin_norm_bound {m n : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector n) (spin : Coulomb.Spins n) (i : Fin n) : + (∫ x, ‖(isolatedPerturbation D q q' center displacement site + (Coulomb.position x i) : ℂ) * state.value spin x‖ ^ 2) ≤ + 12 * ((1 - q) ^ 2 + q' ^ 2) * + (∑ k : Fin 3, ∫ x, ‖state.gradient spin (i, k) x‖ ^ 2) + + 3 * (48 * m / D) ^ 2 * (∫ x, ‖state.value spin x‖ ^ 2) := by + have hD0 : 0 < D := by linarith + let a := center site + let b := center site + displacement site + let B : ℝ := 48 * m / D + let u := state.value spin + let ka := fun x : Configuration n => Coulomb.coulombKernel (Coulomb.position x i - a) + let kb := fun x : Configuration n => Coulomb.coulombKernel (Coulomb.position x i - b) + have hIa := (nuclear_hardy_square state spin i a).1 + have hIb := (nuclear_hardy_square state spin i b).1 + have hIu := (state.value_L2 spin).integrable_norm_pow (by norm_num : (2 : ℕ) ≠ 0) + change Integrable (fun x => ka x ^ 2 * ‖u x‖ ^ 2) at hIa + change Integrable (fun x => kb x ^ 2 * ‖u x‖ ^ 2) at hIb + change Integrable (fun x => ‖u x‖ ^ 2) at hIu + have hI := (isolatedPerturbation_mul_memLp hD hq hq1 hq' hq'1 + center displacement hdisp site state spin i).integrable_norm_pow (by norm_num : (2 : ℕ) ≠ 0) + let majorant := fun x : Configuration n => 3 * + ((1 - q) ^ 2 * (ka x ^ 2 * ‖u x‖ ^ 2) + + q' ^ 2 * (kb x ^ 2 * ‖u x‖ ^ 2) + B ^ 2 * ‖u x‖ ^ 2) + have hmajorant : Integrable majorant := + (((hIa.const_mul ((1 - q) ^ 2)).add (hIb.const_mul (q' ^ 2))).add + (hIu.const_mul (B ^ 2))).const_mul 3 + have hpoint (x : Configuration n) : + ‖(isolatedPerturbation D q q' center displacement site + (Coulomb.position x i) : ℂ) * u x‖ ^ 2 ≤ majorant x := by + let w := backgroundPotential D q q' center displacement site (Coulomb.position x i) + have hw := backgroundPotential_bounds hD hq hq1 hq' hq'1 center displacement hdisp site + (Coulomb.position x i) + have hB : 0 ≤ B := by dsimp [B]; positivity + have hw2 : w ^ 2 ≤ B ^ 2 := by + change 0 ≤ w ∧ w ≤ B at hw + nlinarith + have he : (isolatedPerturbation D q q' center displacement site + (Coulomb.position x i) : ℂ) * u x = + ((1 - q : ℝ) : ℂ) * ((ka x : ℂ) * u x) - + (q' : ℂ) * ((kb x : ℂ) * u x) - (w : ℂ) * u x := by + dsimp [isolatedPerturbation, ka, kb, a, b, w] + have hsub : Coulomb.position x i - center site - displacement site = + Coulomb.position x i - (center site + displacement site) := by abel + rw [hsub] + push_cast + ring + rw [he] + have hnorm := norm_sub_sub_sq_le + (((1 - q : ℝ) : ℂ) * ((ka x : ℂ) * u x)) + ((q' : ℂ) * ((kb x : ℂ) * u x)) ((w : ℂ) * u x) + simp only [Coulomb.norm_real_mul_sq] at hnorm + apply hnorm.trans + change 3 * (_ + _ + w ^ 2 * ‖u x‖ ^ 2) ≤ 3 * (_ + _ + B ^ 2 * ‖u x‖ ^ 2) + exact mul_le_mul_of_nonneg_left + (add_le_add le_rfl (mul_le_mul_of_nonneg_right hw2 (sq_nonneg _))) (by norm_num) + have hbound := integral_mono hI hmajorant hpoint + have hmaj : (∫ x, majorant x) = 3 * + ((1 - q) ^ 2 * (∫ x, ka x ^ 2 * ‖u x‖ ^ 2) + + q' ^ 2 * (∫ x, kb x ^ 2 * ‖u x‖ ^ 2) + + B ^ 2 * (∫ x, ‖u x‖ ^ 2)) := by + have hsum := integral_add + ((hIa.const_mul ((1 - q) ^ 2)).add (hIb.const_mul (q' ^ 2))) (hIu.const_mul (B ^ 2)) + change (∫ x, (1 - q) ^ 2 * (ka x ^ 2 * ‖u x‖ ^ 2) + + q' ^ 2 * (kb x ^ 2 * ‖u x‖ ^ 2) + B ^ 2 * ‖u x‖ ^ 2) = _ at hsum + have hsum' := integral_add (hIa.const_mul ((1 - q) ^ 2)) (hIb.const_mul (q' ^ 2)) + change (∫ x, (1 - q) ^ 2 * (ka x ^ 2 * ‖u x‖ ^ 2) + + q' ^ 2 * (kb x ^ 2 * ‖u x‖ ^ 2)) = _ at hsum' + rw [integral_const_mul, hsum] + dsimp only [Pi.add_apply] + rw [hsum'] + simp only [integral_const_mul] + rw [hmaj] at hbound + have ha := mul_le_mul_of_nonneg_left (nuclear_hardy_square state spin i a).2 + (sq_nonneg (1 - q)) + have hb := mul_le_mul_of_nonneg_left (nuclear_hardy_square state spin i b).2 (sq_nonneg q') + change (1 - q) ^ 2 * (∫ x, ka x ^ 2 * ‖u x‖ ^ 2) ≤ _ at ha + change q' ^ 2 * (∫ x, kb x ^ 2 * ‖u x‖ ^ 2) ≤ _ at hb + change _ ≤ 12 * _ * _ + 3 * B ^ 2 * (∫ x, ‖u x‖ ^ 2) + linarith + +/-- The operator estimate for an arbitrary one-electron spinful weak-H¹ state. -/ +theorem isolatedPerturbation_norm_bound {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + (∑ spin, ∫ x, ‖(isolatedPerturbation D q q' center displacement site + (Coulomb.position x 0) : ℂ) * state.value spin x‖ ^ 2) ≤ + 24 * ((1 - q) ^ 2 + q' ^ 2) * Coulomb.kinetic state + + 3 * (48 * m / D) ^ 2 * Coulomb.mass state := by + have h := Finset.sum_le_sum (s := Finset.univ) (fun spin _ => + isolatedPerturbation_spin_norm_bound hD hq hq1 hq' hq'1 center displacement hdisp + site state spin 0) + apply h.trans_eq + unfold Coulomb.kinetic Coulomb.mass + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, Fintype.sum_prod_type, Fin.sum_univ_one] + ring + +theorem isolatedPerturbation_small_norm_bound {m : ℕ} {D q q' epsilon : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hprimary : |1 - q| ≤ epsilon) (hsecondary : q' ≤ epsilon) + (hbackground : 48 * m / D ≤ epsilon) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) (state : Coulomb.H1Vector 1) : + (∑ spin, ∫ x, ‖(isolatedPerturbation D q q' center displacement site + (Coulomb.position x 0) : ℂ) * state.value spin x‖ ^ 2) ≤ + 48 * epsilon ^ 2 * (Coulomb.kinetic state + Coulomb.mass state) := by + have hepsilon : 0 ≤ epsilon := hq'.trans hsecondary + have hp : (1 - q) ^ 2 ≤ epsilon ^ 2 := by + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg (1 - q)) hepsilon).mpr hprimary + have hs := (sq_le_sq₀ hq' hepsilon).mpr hsecondary + have hD0 : 0 < D := by linarith + have hB : 0 ≤ 48 * (m : ℝ) / D := by positivity + have hb := (sq_le_sq₀ hB hepsilon).mpr hbackground + have hk : 0 ≤ Coulomb.kinetic state := Coulomb.kinetic_nonneg state + have hm : 0 ≤ Coulomb.mass state := Coulomb.mass_nonneg state + have hkin := mul_le_mul_of_nonneg_right (add_le_add hp hs) hk + have hmass := mul_le_mul_of_nonneg_right hb hm + apply (isolatedPerturbation_norm_bound hD hq hq1 hq' hq'1 center displacement hdisp site state).trans + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedSpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d2dc1d7b37b2fdd0dbf03ebd5f24937b9f2a5e1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/IsolatedSpectrum.lean @@ -0,0 +1,190 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.MovingWells +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronTrial + +namespace OAI + +/-! +# Stability of the unrestricted isolated-well variational bottom + +All infima range over normalized spinful weak-H¹ states. The estimates use +form comparison and a concrete normalized bump trial; no eigenfunction, attainment, or +spectral oracle is supplied as an assumption. +-/ + +noncomputable section +namespace ContinuumCoulomb + +def oneElectronEnergy (form : Coulomb.H1Vector 1 → ℝ) : EReal := + sInf {e | ∃ state : Coulomb.H1Vector 1, + Coulomb.mass state = 1 ∧ e = (form state : EReal)} + +def hydrogenEnergy (a : Position) : EReal := oneElectronEnergy (hydrogenForm a) + +def isolatedWellEnergy {m : ℕ} (D q q' : ℝ) (center displacement : Fin m → Position) + (site : Fin m) : EReal := oneElectronEnergy (isolatedWellForm D q q' center displacement site) + +theorem oneElectronEnergy_le_trial (form : Coulomb.H1Vector 1 → ℝ) + (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + oneElectronEnergy form ≤ (form state : EReal) := + sInf_le ⟨state, hnorm, rfl⟩ + +theorem oneElectronEnergy_lower_of_forall (form : Coulomb.H1Vector 1 → ℝ) (a : ℝ) + (ha : ∀ state : Coulomb.H1Vector 1, Coulomb.mass state = 1 → a ≤ form state) : + (a : EReal) ≤ oneElectronEnergy form := by + apply le_sInf + rintro e ⟨state, hnorm, rfl⟩ + exact EReal.coe_le_coe (ha state hnorm) + +theorem oneElectronEnergy_finite (form : Coulomb.H1Vector 1 → ℝ) + (trial : Coulomb.H1Vector 1) (htrial : Coulomb.mass trial = 1) (a : ℝ) + (ha : ∀ state : Coulomb.H1Vector 1, Coulomb.mass state = 1 → a ≤ form state) : + oneElectronEnergy form ≠ ⊤ ∧ oneElectronEnergy form ≠ ⊥ := by + exact ⟨ne_of_lt ((oneElectronEnergy_le_trial form trial htrial).trans_lt + (EReal.coe_lt_top _)), + ne_of_gt ((EReal.bot_lt_coe a).trans_le (oneElectronEnergy_lower_of_forall form a ha))⟩ + +theorem hydrogenEnergy_finite (a : Position) : hydrogenEnergy a ≠ ⊤ ∧ hydrogenEnergy a ≠ ⊥ := by + apply oneElectronEnergy_finite (hydrogenForm a) oneElectronTrial oneElectronTrial_mass (-4) + intro state hnorm + have h := hydrogenForm_coercive a state + rw [hnorm] at h + linarith [Coulomb.kinetic_nonneg state] + +theorem isolatedWellEnergy_finite {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) : + isolatedWellEnergy D q q' center displacement site ≠ ⊤ ∧ + isolatedWellEnergy D q q' center displacement site ≠ ⊥ := by + apply oneElectronEnergy_finite _ oneElectronTrial oneElectronTrial_mass (-(16 + 48 * m / D)) + intro state hnorm + have h := isolatedWellForm_coercive hD hq hq1 hq' hq'1 + center displacement hdisp site state + rw [hnorm] at h + linarith [Coulomb.kinetic_nonneg state] + +theorem oneElectronEnergy_bounded_perturbation (f g : Coulomb.H1Vector 1 → ℝ) + (hf : oneElectronEnergy f ≠ ⊤ ∧ oneElectronEnergy f ≠ ⊥) + (hg : oneElectronEnergy g ≠ ⊤ ∧ oneElectronEnergy g ≠ ⊥) (delta : ℝ) + (herror : ∀ state : Coulomb.H1Vector 1, Coulomb.mass state = 1 → + |g state - f state| ≤ delta) : + |(oneElectronEnergy g).toReal - (oneElectronEnergy f).toReal| ≤ delta := by + have hfc : ((oneElectronEnergy f).toReal : EReal) = oneElectronEnergy f := + EReal.coe_toReal hf.1 hf.2 + have hgc : ((oneElectronEnergy g).toReal : EReal) = oneElectronEnergy g := + EReal.coe_toReal hg.1 hg.2 + have hfl (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + (oneElectronEnergy f).toReal ≤ f state := by + apply EReal.coe_le_coe_iff.mp + rw [hfc] + exact oneElectronEnergy_le_trial f state hnorm + have hgl (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + (oneElectronEnergy g).toReal ≤ g state := by + apply EReal.coe_le_coe_iff.mp + rw [hgc] + exact oneElectronEnergy_le_trial g state hnorm + have hl : (oneElectronEnergy f).toReal - delta ≤ (oneElectronEnergy g).toReal := by + apply EReal.coe_le_coe_iff.mp + rw [hgc] + apply oneElectronEnergy_lower_of_forall + intro state hnorm + have h := (abs_le.mp (herror state hnorm)).1 + linarith [hfl state hnorm] + have hu : (oneElectronEnergy g).toReal - delta ≤ (oneElectronEnergy f).toReal := by + apply EReal.coe_le_coe_iff.mp + rw [hfc] + apply oneElectronEnergy_lower_of_forall + intro state hnorm + have h := (abs_le.mp (herror state hnorm)).2 + linarith [hgl state hnorm] + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +theorem isolatedWellEnergy_relative {m : ℕ} {D q q' epsilon : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hprimary : |1 - q| ≤ epsilon) (hsecondary : q' ≤ epsilon) + (hbackground : 48 * m / D ≤ epsilon) (hsmall : 10 * epsilon ≤ 1) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) : + |(isolatedWellEnergy D q q' center displacement site).toReal - + (hydrogenEnergy (center site)).toReal| ≤ + 10 * epsilon * ((hydrogenEnergy (center site)).toReal + 5) := by + let E := (hydrogenEnergy (center site)).toReal + let F := (isolatedWellEnergy D q q' center displacement site).toReal + let theta := 10 * epsilon + have hepsilon : 0 ≤ epsilon := hq'.trans hsecondary + have htheta : 0 ≤ theta := by dsimp [theta]; positivity + have hslower : 0 ≤ 1 - theta := by dsimp [theta]; linarith + have hsupper : 0 < 1 + theta := by linarith + have hEcoe : (E : EReal) = hydrogenEnergy (center site) := + EReal.coe_toReal (hydrogenEnergy_finite (center site)).1 + (hydrogenEnergy_finite (center site)).2 + have hFcoe : (F : EReal) = isolatedWellEnergy D q q' center displacement site := + EReal.coe_toReal (isolatedWellEnergy_finite hD hq hq1 hq' hq'1 + center displacement hdisp site).1 + (isolatedWellEnergy_finite hD hq hq1 hq' hq'1 + center displacement hdisp site).2 + have hEtrial (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + E ≤ hydrogenForm (center site) state := by + apply EReal.coe_le_coe_iff.mp + rw [hEcoe] + exact oneElectronEnergy_le_trial _ state hnorm + have hFtrial (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + F ≤ isolatedWellForm D q q' center displacement site state := by + apply EReal.coe_le_coe_iff.mp + rw [hFcoe] + exact oneElectronEnergy_le_trial _ state hnorm + have hpoint (state : Coulomb.H1Vector 1) (hnorm : Coulomb.mass state = 1) : + (1 - theta) * hydrogenForm (center site) state - 5 * theta ≤ + isolatedWellForm D q q' center displacement site state ∧ + isolatedWellForm D q q' center displacement site state ≤ + (1 + theta) * hydrogenForm (center site) state + 5 * theta := by + have h := isolatedWellForm_relative hD hq hq1 hq' hq'1 hprimary hsecondary hbackground + center displacement hdisp site state + rw [hnorm] at h + change |_ - _| ≤ theta * (_ + 5 * 1) at h + obtain ⟨hl, hu⟩ := abs_le.mp h + constructor <;> nlinarith + have hl : (1 - theta) * E - 5 * theta ≤ F := by + apply EReal.coe_le_coe_iff.mp + rw [hFcoe] + apply oneElectronEnergy_lower_of_forall + intro state hnorm + have h := mul_le_mul_of_nonneg_left (hEtrial state hnorm) hslower + linarith [(hpoint state hnorm).1] + have hu : F ≤ (1 + theta) * E + 5 * theta := by + have haux : (F - 5 * theta) / (1 + theta) ≤ E := by + apply EReal.coe_le_coe_iff.mp + rw [hEcoe] + apply oneElectronEnergy_lower_of_forall + intro state hnorm + apply (div_le_iff₀ hsupper).2 + have h := hFtrial state hnorm + nlinarith [(hpoint state hnorm).2] + have h := (div_le_iff₀ hsupper).mp haux + nlinarith + change |F - E| ≤ theta * (E + 5) + exact abs_le.mpr ⟨by nlinarith, by nlinarith⟩ + +/-- Keeping the own secondary nucleus fixed yields the small other-site +energy Lipschitz bound on the actual infimum, without a ground-state premise. -/ +theorem isolatedWellEnergy_other_displacements {m : ℕ} {D q q' delta : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hdelta : 0 ≤ delta) (center a b : Fin m → Position) + (ha : ∀ j, ‖a j‖ ≤ 4) (hb : ∀ j, ‖b j‖ ≤ 4) + (hmove : ∀ j, ‖a j - b j‖ ≤ delta) (site : Fin m) (hown : a site = b site) : + |(isolatedWellEnergy D q q' center b site).toReal - + (isolatedWellEnergy D q q' center a site).toReal| ≤ 2048 * q' * m / D ^ 2 * delta := by + apply oneElectronEnergy_bounded_perturbation _ _ + (isolatedWellEnergy_finite hD hq hq1 hq' hq'1 center a ha site) + (isolatedWellEnergy_finite hD hq hq1 hq' hq'1 center b hb site) + intro state hnorm + have h := isolatedWellForm_displacement_bound hD hq hq1 hq' hq'1 hdelta + center a b ha hb hmove site state + rw [hown, sub_self, norm_zero, mul_zero, zero_mul, zero_add, hnorm, mul_one] at h + simpa only [abs_sub_comm] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedMatrixError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedMatrixError.lean new file mode 100644 index 0000000000000000000000000000000000000000..a15766b2ae92a6e367ffa4b66e32a9d301e523dc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedMatrixError.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCorrectedOneBody + +namespace OAI + +/-! Quantitative comparison of the actual shifted and scaled one-body +matrix with the hopping and Coulomb occupancy counterterm matrix. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedOneBodyTarget (scale freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i j : Fin m) : ℝ := + scale * planarHoppingMatrix u i j - if i=j then localizedOffsiteSum freq u i else 0 + +theorem localizedCorrectedOneBodyMatrix_error {freq scale D : ℝ} (hfreq : 0 < freq) + (hscale : scale ≠ 0) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (i j : Fin m) : + |scale * localizedCorrectedOneBodyMatrix freq scale u i j - localizedOneBodyTarget scale freq u i j| ≤ + (|scale| * m * planarWellMatrixConstant + + (m : ℝ)^2 * localizedCountertermBound freq * planarWellMatrixConstant) * + Real.exp (-(19/10 : ℝ)*D) + + (m : ℝ)^2 * localizedCountertermBound freq * + (PlanarSobolev.wellBound * planarOverlapConstant) * Real.exp (-(9/10 : ℝ)*D) := by + classical + let e₁ := |scale| * m * planarWellMatrixConstant * Real.exp (-(19/10 : ℝ)*D) + let e₂ := (m : ℝ)^2 * localizedCountertermBound freq * planarWellMatrixConstant * + Real.exp (-(19/10 : ℝ)*D) + let e₃ := (m : ℝ)^2 * localizedCountertermBound freq * + (PlanarSobolev.wellBound * planarOverlapConstant) * Real.exp (-(9/10 : ℝ)*D) + have he₂ : 0 ≤ e₂ := by + dsimp [e₂] + exact mul_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (localizedCountertermBound_nonnegative freq)) + planarWellMatrixConstant_nonnegative) (Real.exp_pos _).le + have he₃ : 0 ≤ e₃ := by + dsimp [e₃] + exact mul_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (localizedCountertermBound_nonnegative freq)) + (mul_nonneg PlanarSobolev.wellBound_nonnegative planarOverlapConstant_nonnegative)) (Real.exp_pos _).le + have hb : |scale * (localizedOneBodyMatrix freq u i j - planarHoppingMatrix u i j)| ≤ e₁ := by + rw [abs_mul, localizedOneBodyMatrix_eq hfreq] + exact (mul_le_mul_of_nonneg_left (planarMultiwellMatrix_error_bound u hsep i j) (abs_nonneg scale)).trans_eq + (by dsimp [e₁]; ring) + have hc : |localizedCountertermMatrix freq u i j + + (if i=j then localizedOffsiteSum freq u i else 0)| ≤ e₂+e₃ := by + by_cases hij : i=j + · subst j + simp only [ite_true] + exact (localizedCountertermMatrix_diagonal_error_bound hfreq u hsep i).trans (le_add_of_nonneg_right he₃) + · simp only [hij, ite_false, add_zero] + have h := localizedCountertermMatrix_offdiagonal_bound hfreq u i j + have h' : |localizedCountertermMatrix freq u i j| ≤ e₃ := h.trans (mul_le_mul_of_nonneg_left + (Real.exp_le_exp.mpr (by linarith [hsep i j hij])) (by + exact mul_nonneg (mul_nonneg (sq_nonneg _) (localizedCountertermBound_nonnegative freq)) + (mul_nonneg PlanarSobolev.wellBound_nonnegative planarOverlapConstant_nonnegative))) + exact h'.trans (le_add_of_nonneg_left he₂) + rw [localizedCorrectedOneBodyMatrix_scaled hfreq hscale] + unfold localizedOneBodyTarget + have hid : scale * localizedOneBodyMatrix freq u i j + localizedCountertermMatrix freq u i j - + (scale * planarHoppingMatrix u i j - if i=j then localizedOffsiteSum freq u i else 0) = + scale * (localizedOneBodyMatrix freq u i j - planarHoppingMatrix u i j) + + (localizedCountertermMatrix freq u i j + if i=j then localizedOffsiteSum freq u i else 0) := by ring + rw [hid] + calc + _ ≤ |scale*(localizedOneBodyMatrix freq u i j-planarHoppingMatrix u i j)| + + |localizedCountertermMatrix freq u i j + if i=j then localizedOffsiteSum freq u i else 0| := abs_add_le _ _ + _ ≤ e₁+(e₂+e₃) := add_le_add hb hc + _ = _ := by dsimp [e₁,e₂,e₃]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedOneBody.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedOneBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..97c758609d0869865c36149e628dfae007f33278 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCorrectedOneBody.lean @@ -0,0 +1,85 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOneBody +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCountertermMatrix + +namespace OAI + +/-! The actual one-body operator including well-depth counterterms. Its +shifted matrix is exactly the base multiwell matrix plus the weighted well +matrix divided by the physical scale. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def correctedMultiwellAction (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (f : SplitPosition → ℝ) (p : SplitPosition) : ℝ := + multiwellAction freq u f p + scale⁻¹ * + (∑ k, localizedCounterterm freq u k * manufacturedPlanarWell (p.1 - u k)) * f p + +def localizedCorrectedOneBodyIntegrand (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i j : Fin m) (x : Position) : ℝ := + continuumLocalizedMode freq (u i) x * + (correctedMultiwellAction freq scale u (localizedMode freq (u j)) (positionSplitCoordinates x) - + ((-1 / 2 : ℝ) + freq / 2) * continuumLocalizedMode freq (u j) x) + +theorem localizedCorrectedOneBodyIntegrand_eq (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i j : Fin m) (x : Position) : + localizedCorrectedOneBodyIntegrand freq scale u i j x = localizedOneBodyIntegrand freq u i j x + + scale⁻¹ * ∑ k, localizedCounterterm freq u k * localizedWellIntegrand freq (u i) (u j) (u k) x := by + have hs : continuumLocalizedMode freq (u i) x * + (scale⁻¹ * (∑ k, localizedCounterterm freq u k * + manufacturedPlanarWell ((positionSplitCoordinates x).1 - u k)) * continuumLocalizedMode freq (u j) x) = + scale⁻¹ * ∑ k, localizedCounterterm freq u k * localizedWellIntegrand freq (u i) (u j) (u k) x := by + simp only [Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro k _ + unfold localizedWellIntegrand + ring + unfold localizedCorrectedOneBodyIntegrand correctedMultiwellAction localizedOneBodyIntegrand + change continuumLocalizedMode freq (u i) x * + (multiwellAction freq u (localizedMode freq (u j)) (positionSplitCoordinates x) + + scale⁻¹ * (∑ k, localizedCounterterm freq u k * + manufacturedPlanarWell ((positionSplitCoordinates x).1 - u k)) * continuumLocalizedMode freq (u j) x - + ((-1 / 2 : ℝ) + freq / 2) * continuumLocalizedMode freq (u j) x) = _ + nlinarith only [hs] + +theorem localizedCorrectedOneBodyIntegrand_integrable {freq : ℝ} (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + Integrable (localizedCorrectedOneBodyIntegrand freq scale u i j) := by + have hi : Integrable (fun x => ∑ k, localizedCounterterm freq u k * + localizedWellIntegrand freq (u i) (u j) (u k) x) := + integrable_finsetSum _ (fun k _ => (localizedWellIntegrand_integrable hfreq _ _ _).const_mul _) + change Integrable (fun x => localizedCorrectedOneBodyIntegrand freq scale u i j x) + simp_rw [localizedCorrectedOneBodyIntegrand_eq] + exact (localizedOneBodyIntegrand_integrable hfreq u i j).add (hi.const_mul _) + +def localizedCorrectedOneBodyMatrix (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : ℝ := + ∫ x, localizedCorrectedOneBodyIntegrand freq scale u i j x + +theorem localizedCorrectedOneBodyMatrix_eq {freq : ℝ} (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + localizedCorrectedOneBodyMatrix freq scale u i j = + localizedOneBodyMatrix freq u i j + scale⁻¹ * localizedCountertermMatrix freq u i j := by + have hi (k : Fin m) : Integrable (fun x => localizedCounterterm freq u k * + localizedWellIntegrand freq (u i) (u j) (u k) x) := + (localizedWellIntegrand_integrable hfreq _ _ _).const_mul _ + unfold localizedCorrectedOneBodyMatrix + simp_rw [localizedCorrectedOneBodyIntegrand_eq] + rw [integral_add (localizedOneBodyIntegrand_integrable hfreq u i j) + ((integrable_finsetSum Finset.univ (fun k _ => hi k)).const_mul _), integral_const_mul, + integral_finsetSum Finset.univ (fun k _ => hi k)] + simp only [integral_const_mul, localizedWellIntegrand_integral hfreq] + rfl + +theorem localizedCorrectedOneBodyMatrix_scaled {freq scale : ℝ} (hfreq : 0 < freq) (hscale : scale ≠ 0) + {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + scale * localizedCorrectedOneBodyMatrix freq scale u i j = + scale * localizedOneBodyMatrix freq u i j + localizedCountertermMatrix freq u i j := by + rw [localizedCorrectedOneBodyMatrix_eq hfreq, mul_add, ← mul_assoc, mul_inv_cancel₀ hscale, one_mul] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulomb.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulomb.lean new file mode 100644 index 0000000000000000000000000000000000000000..43a4718a6ed42cadd5fc3f87c038857034cf5c9c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulomb.lean @@ -0,0 +1,118 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitCoordinates +import OAI.Analysis.CoulombRadii.Variational.CorrectionDensity + +namespace OAI + +/-! Finite actual Coulomb interactions of the localized densities. Bounded +probability densities permit the existing elementary near/far Coulomb bound; +no interaction coefficient is introduced as a spectral input. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedAmplitudeBound (freq : ℝ) : ℝ := + (1 / Real.sqrt (∫ r, planarResolventMode r ^ 2)) * + (1 / Real.sqrt (Real.sqrt (Real.pi / freq))) + +theorem localizedAmplitudeBound_positive {freq : ℝ} (hfreq : 0 < freq) : + 0 < localizedAmplitudeBound freq := + mul_pos (one_div_pos.mpr (Real.sqrt_pos.mpr planarResolventMode_square_integral_positive)) + (one_div_pos.mpr (Real.sqrt_pos.mpr (Real.sqrt_pos.mpr (div_pos Real.pi_pos hfreq)))) + +theorem continuumLocalizedMode_le {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : + continuumLocalizedMode freq u x ≤ localizedAmplitudeBound freq := by + have hp (r : PlanarPosition) : normalizedPlanarMode r ≤ + 1 / Real.sqrt (∫ s, planarResolventMode s ^ 2) := + div_le_div_of_nonneg_right (planarResolventMode_le_one r) (Real.sqrt_nonneg _) + have hv (z : ℝ) : verticalMode freq z ≤ 1 / Real.sqrt (Real.sqrt (Real.pi / freq)) := by + apply div_le_div_of_nonneg_right _ (Real.sqrt_nonneg _) + exact Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg z]) + exact mul_le_mul (hp _) (hv _) (verticalMode_positive hfreq _).le + (by positivity) + +def localizedDensity (freq : ℝ) (u : PlanarPosition) (x : Position) : ℝ := + continuumLocalizedMode freq u x ^ 2 + +theorem localizedDensity_continuous (freq : ℝ) (u : PlanarPosition) : + Continuous (localizedDensity freq u) := (continuumLocalizedMode_C7 freq u).continuous.pow 2 + +theorem localizedDensity_nonnegative (freq : ℝ) (u : PlanarPosition) (x : Position) : + 0 ≤ localizedDensity freq u x := sq_nonneg _ + +theorem localizedDensity_positive {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : 0 < localizedDensity freq u x := + sq_pos_of_pos (continuumLocalizedMode_positive hfreq u x) + +theorem localizedDensity_integrable {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + Integrable (localizedDensity freq u) := + (memLp_two_iff_integrable_sq (continuumLocalizedMode_C7 freq u).continuous.aestronglyMeasurable).mp + (continuumLocalizedMode_memLp hfreq u) + +theorem localizedDensity_mass {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + (∫ x, localizedDensity freq u x) = 1 := continuumLocalizedMode_normalized hfreq u + +theorem localizedDensity_bound {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : + localizedDensity freq u x ≤ localizedAmplitudeBound freq ^ 2 := + (sq_le_sq₀ (continuumLocalizedMode_positive hfreq u x).le + (localizedAmplitudeBound_positive hfreq).le).mpr (continuumLocalizedMode_le hfreq u x) + +def localizedPotentialBound (freq : ℝ) : ℝ := + localizedAmplitudeBound freq ^ 2 * NeutralAtom.kernelBallMass 1 + 1 + +theorem localizedDensity_coulomb_integrable_bound {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : + Integrable (fun y => NeutralAtom.coulombKernel (x - y) * localizedDensity freq u y) ∧ + NeutralAtom.potentialOf (localizedDensity freq u) x ≤ localizedPotentialBound freq := by + have h := NeutralAtom.bounded_density_convolution NeutralAtom.measurable_coulombKernel + NeutralAtom.coulombKernel_nonneg (NeutralAtom.coulombKernel_integrableOn_ball 1) + (fun _ => NeutralAtom.coulombKernel_le_one) (localizedDensity_integrable hfreq u) + (localizedDensity_nonnegative freq u) (localizedDensity_bound hfreq u) x + simpa only [localizedDensity_mass hfreq u, localizedPotentialBound, NeutralAtom.kernelBallMass, + NeutralAtom.potentialOf] using h + +theorem localizedDensity_potential_nonnegative (freq : ℝ) (u : PlanarPosition) (x : Position) : + 0 ≤ NeutralAtom.potentialOf (localizedDensity freq u) x := + integral_nonneg (fun _ => mul_nonneg (NeutralAtom.coulombKernel_nonneg _) + (localizedDensity_nonnegative freq u _)) + +theorem localizedDensity_potential_continuous {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : Continuous (NeutralAtom.potentialOf (localizedDensity freq u)) := + NeutralAtom.potentialOf_continuous (localizedDensity_integrable hfreq u) + (localizedDensity_nonnegative freq u) (localizedDensity_bound hfreq u) + +def localizedCoulombCoeff (freq : ℝ) (u v : PlanarPosition) : ℝ := + ∫ x, localizedDensity freq u x * NeutralAtom.potentialOf (localizedDensity freq v) x + +theorem localizedCoulombCoeff_integrable {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : + Integrable (fun x => localizedDensity freq u x * + NeutralAtom.potentialOf (localizedDensity freq v) x) := by + apply (localizedDensity_integrable hfreq u).mul_bdd (c := localizedPotentialBound freq) + (localizedDensity_potential_continuous hfreq v).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun x => by + rw [Real.norm_of_nonneg (localizedDensity_potential_nonnegative freq v x)] + exact (localizedDensity_coulomb_integrable_bound hfreq v x).2) + +theorem localizedCoulombCoeff_nonnegative (freq : ℝ) (u v : PlanarPosition) : + 0 ≤ localizedCoulombCoeff freq u v := + integral_nonneg (fun x => mul_nonneg (localizedDensity_nonnegative freq u x) + (localizedDensity_potential_nonnegative freq v x)) + +theorem localizedCoulombCoeff_le {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + localizedCoulombCoeff freq u v ≤ localizedPotentialBound freq := by + have hi := (localizedDensity_integrable hfreq u).mul_const (localizedPotentialBound freq) + have h := integral_mono (localizedCoulombCoeff_integrable hfreq u v) hi + (fun x => mul_le_mul_of_nonneg_left + (localizedDensity_coulomb_integrable_bound hfreq v x).2 + (localizedDensity_nonnegative freq u x)) + simpa only [integral_mul_const, localizedDensity_mass hfreq u, one_mul, + localizedCoulombCoeff] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombBox.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..92db2040d67e8abb69deaf02ee8da965dd85667b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombBox.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombTruncation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDensityMoment + +namespace OAI + +/-! The actual direct coefficient is approximated by a bounded integral +on a six-dimensional rational cube. The cap and truncation errors are +uniform in the relative displacement of the two fixed density packets. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def coulombNumericalBox (L : ℝ) : Set Position := + ⋂ i : Fin 3, {x : Position | |x i| ≤ L} + +theorem coulombNumericalBox_measurable (L : ℝ) : MeasurableSet (coulombNumericalBox L) := by + apply MeasurableSet.iInter + intro i + exact (isClosed_le (by fun_prop) continuous_const).measurableSet + +theorem coulombNumericalBox_outside (L : ℝ) {x : Position} + (hx : x ∉ coulombNumericalBox L) : L ≤ ‖x‖ := by + simp only [coulombNumericalBox, Set.mem_iInter, Set.mem_ofPred_eq, not_forall] at hx + obtain ⟨i, hi⟩ := hx + exact (lt_of_not_ge hi).le.trans (by + simpa only [Real.norm_eq_abs] using PiLp.norm_apply_le x i) + +def localizedCappedProfile (freq ε : ℝ) (u : PlanarPosition) : ℝ := + ∫ p, cappedPairIntegrand ε (planarCenter u) + (localizedDensity freq 0) (localizedDensity freq 0) p + +theorem localizedCappedProfile_eq {freq ε : ℝ} (hfreq : 0 < freq) (hε : 0 < ε) + (u : PlanarPosition) : + localizedCappedProfile freq ε u = localizedCappedCoulombCoeff freq ε 0 u := by + rw [localizedCappedCoulombCoeff_nested hfreq hε] + unfold localizedCappedProfile + rw [Measure.volume_eq_prod, integral_prod _ (by + simpa only [Measure.volume_eq_prod] using cappedPairIntegrand_integrable hε + (planarCenter u) (localizedDensity_integrable hfreq 0) + (localizedDensity_integrable hfreq 0))] + apply integral_congr_ae + filter_upwards [] with x + simp only [cappedPairIntegrand, cappedCoulombPotential] + simp_rw [mul_assoc] + rw [integral_const_mul] + congr 1 + rw [← integral_add_right_eq_self + (fun y => cappedCoulombKernel ε (x - y) * localizedDensity freq u y) (planarCenter u)] + apply integral_congr_ae + filter_upwards [] with y + rw [localizedDensity_translate freq u, add_sub_cancel_right] + rw [mul_comm] + congr 1 + abel_nf + +def localizedCoulombBoxIntegral (freq ε L : ℝ) (u : PlanarPosition) : ℝ := + ∫ p in coulombNumericalBox L ×ˢ coulombNumericalBox L, + cappedPairIntegrand ε (planarCenter u) + (localizedDensity freq 0) (localizedDensity freq 0) p + +theorem localizedCappedProfile_box_error {freq ε L : ℝ} + (hfreq : 0 < freq) (hε : 0 < ε) (hL : 0 < L) (u : PlanarPosition) : + |localizedCappedProfile freq ε u - localizedCoulombBoxIntegral freq ε L u| ≤ + 2 * ε⁻¹ * localizedDensitySecondMoment freq / L ^ 2 := by + have ht := cappedPair_truncation_error hε (planarCenter u) + (localizedDensity_integrable hfreq 0) (localizedDensity_integrable hfreq 0) + (localizedDensity_nonnegative freq 0) (localizedDensity_nonnegative freq 0) + (coulombNumericalBox_measurable L) (coulombNumericalBox_measurable L) + simp only [localizedDensity_mass hfreq 0, mul_one, one_mul] at ht + have hb := localizedDensity_tail_of_norm hfreq hL (coulombNumericalBox_measurable L) + (fun _ hx => coulombNumericalBox_outside L hx) + apply ht.trans + have hε0 : 0 ≤ ε⁻¹ := inv_nonneg.mpr hε.le + calc + _ ≤ ε⁻¹ * (localizedDensitySecondMoment freq / L ^ 2 + + localizedDensitySecondMoment freq / L ^ 2) := by gcongr + _ = _ := by ring + +theorem localizedCoulombProfile_box_error {freq ε L : ℝ} + (hfreq : 0 < freq) (hε : 0 < ε) (hL : 0 < L) (u : PlanarPosition) : + |localizedCoulombProfileAt freq u - localizedCoulombBoxIntegral freq ε L u| ≤ + 2 * Real.pi * localizedAmplitudeBound freq ^ 2 * ε ^ 2 + + 2 * ε⁻¹ * localizedDensitySecondMoment freq / L ^ 2 := by + have hcap := localizedCappedCoulombCoeff_error hfreq hε 0 u + rw [← localizedCoulombProfileAt_eq, ← localizedCappedProfile_eq hfreq hε] at hcap + exact (abs_sub_le _ (localizedCappedProfile freq ε u) _).trans + (add_le_add hcap (localizedCappedProfile_box_error hfreq hε hL u)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..07db239330d5d2cc4a9be78d696a42099e1e8270 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombGap.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGramSpacing + +namespace OAI + +/-! The two-site specialization gives the positive denominator `U-v` +used by the Hubbard superexchange calibration. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem localizedCoulombCoeff_gap {freq D : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + (hleak : 2 * localLeakageBound freq D ≤ localDualMass freq / 2) + (u v : PlanarPosition) (hsep : D ≤ ‖u - v‖) : + localizedGramConstant freq ≤ localizedCoulombProfile freq 0 - localizedCoulombCoeff freq u v := by + let centers : Fin 2 → PlanarPosition := ![u, v] + let d : Fin 2 → ℝ := ![1, -1] + have hs : ∀ i j : Fin 2, i ≠ j → D ≤ ‖centers i - centers j‖ := by + intro i j hij + fin_cases i <;> fin_cases j + · exact False.elim (hij rfl) + · exact hsep + · change D ≤ ‖v - u‖ + simpa only [norm_sub_rev] using hsep + · exact False.elim (hij rfl) + have h := localizedGram_uniform_coercive hfreq hD centers hs (by simpa using hleak) d + simp only [Fin.sum_univ_two, centers, d, Matrix.cons_val_zero, Matrix.cons_val_one, + one_pow, neg_one_sq, mul_one, mul_neg, neg_neg] at h + rw [localizedCoulombCoeff_symmetric hfreq v u, + localizedCoulombCoeff_distance freq u u, localizedCoulombCoeff_distance freq v v] at h + simp only [sub_self, norm_zero] at h + nlinarith only [h] + +theorem localizedCoulombProfile_gap {freq D d : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + (hleak : 2 * localLeakageBound freq D ≤ localDualMass freq / 2) (hd : D ≤ d) : + localizedGramConstant freq ≤ localizedCoulombProfile freq 0 - localizedCoulombProfile freq d := by + have hn : ‖(0 : PlanarPosition) - d • planarAxis 0‖ = d := by + rw [zero_sub, norm_neg, norm_smul, planarAxis_zero_norm, + Real.norm_of_nonneg (by linarith : 0 ≤ d), mul_one] + have h := localizedCoulombCoeff_gap hfreq hD hleak 0 (d • planarAxis 0) (by rw [hn]; exact hd) + rwa [localizedCoulombCoeff_distance, hn] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombLipschitz.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombLipschitz.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5b4c73b44d24764c14d358219472a4902860509 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombLipschitz.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombTranslation + +namespace OAI + +/-! A uniform Lipschitz estimate for the actual direct-Coulomb profile. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedCoulombLipschitzConstant (freq : ℝ) : ℝ := + localizedAmplitudeBound freq ^ 2 * + (∫ y in Metric.ball (0 : Position) 1, NeutralAtom.coulombKernel y ^ 2) + 1 + +theorem localizedCoulombLipschitzConstant_nonnegative (freq : ℝ) : + 0 ≤ localizedCoulombLipschitzConstant freq := + add_nonneg (mul_nonneg (sq_nonneg _) + (integral_nonneg (fun _ => sq_nonneg _))) zero_le_one + +theorem localizedDensity_potential_norm_sub {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x y : Position) : + ‖NeutralAtom.potentialOf (localizedDensity freq u) x - + NeutralAtom.potentialOf (localizedDensity freq u) y‖ ≤ + localizedCoulombLipschitzConstant freq * ‖x - y‖ := by + simpa only [localizedDensity_mass hfreq u, localizedCoulombLipschitzConstant] using + NeutralAtom.potentialOf_lipschitz_bound (localizedDensity_integrable hfreq u) + (localizedDensity_nonnegative freq u) (localizedDensity_bound hfreq u) x y + +theorem localizedCoulombProfileAt_integrable {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : Integrable (fun x => localizedDensity freq 0 x * + NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter u)) := by + apply (localizedCoulombCoeff_integrable hfreq 0 u).congr + exact Filter.Eventually.of_forall (fun x => + congrArg (fun z => localizedDensity freq 0 x * z) + (localizedDensity_potential_translate freq u x)) + +theorem localizedCoulombProfileAt_norm_sub {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : + ‖localizedCoulombProfileAt freq u - localizedCoulombProfileAt freq v‖ ≤ + localizedCoulombLipschitzConstant freq * ‖u - v‖ := by + have hpt (x : Position) : + ‖localizedDensity freq 0 x * NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter u) - + localizedDensity freq 0 x * NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter v)‖ ≤ + (localizedCoulombLipschitzConstant freq * ‖u - v‖) * localizedDensity freq 0 x := by + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (localizedDensity_nonnegative freq 0 x)] + have h := localizedDensity_potential_norm_sub hfreq 0 (x - planarCenter u) (x - planarCenter v) + rw [show (x - planarCenter u) - (x - planarCenter v) = planarCenter v - planarCenter u by abel, + norm_sub_rev (planarCenter v) (planarCenter u), planarCenter_norm_sub] at h + calc + _ ≤ localizedDensity freq 0 x * + (localizedCoulombLipschitzConstant freq * ‖u - v‖) := + mul_le_mul_of_nonneg_left h (localizedDensity_nonnegative freq 0 x) + _ = _ := mul_comm _ _ + unfold localizedCoulombProfileAt + rw [← integral_sub (localizedCoulombProfileAt_integrable hfreq u) + (localizedCoulombProfileAt_integrable hfreq v)] + have h := norm_integral_le_of_norm_le + (f := fun x => localizedDensity freq 0 x * NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter u) - + localizedDensity freq 0 x * NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter v)) + ((localizedDensity_integrable hfreq 0).const_mul + (localizedCoulombLipschitzConstant freq * ‖u - v‖)) + (Filter.Eventually.of_forall hpt) + simpa only [integral_const_mul, localizedDensity_mass hfreq 0, mul_one] using h + +theorem localizedCoulombProfileAt_continuous {freq : ℝ} (hfreq : 0 < freq) : + Continuous (localizedCoulombProfileAt freq) := + (show LipschitzWith + ⟨localizedCoulombLipschitzConstant freq, localizedCoulombLipschitzConstant_nonnegative freq⟩ + (localizedCoulombProfileAt freq) from + lipschitzWith_iff_norm_sub_le.mpr (localizedCoulombProfileAt_norm_sub hfreq)).continuous + +theorem localizedCoulombProfile_continuous {freq : ℝ} (hfreq : 0 < freq) : + Continuous (localizedCoulombProfile freq) := + (localizedCoulombProfileAt_continuous hfreq).comp (continuous_id.smul continuous_const) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..805779c00f66743727794d1d99a74a74e22ef846 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombMatrix.lean @@ -0,0 +1,142 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.PairSpinOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorFormCompression +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLinearCoulomb +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFockStates + +namespace OAI + +/-! The actual corrected spatial-spin Coulomb tensor differs from its +occupation-diagonal density interaction by the Gram and off-site errors. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem correctedLocalizedFourIndex_error {freq D : ℝ} (hf : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : m*localizedOverlapBound D ≤ 1/2) (i j k l : Fin m) : + |localizedLinearFourIndex hf u (correctedLocalizedCoefficients u i) + (correctedLocalizedCoefficients u k) (correctedLocalizedCoefficients u j) + (correctedLocalizedCoefficients u l)- + (if i=k ∧ j=l then localizedFourIndex freq (u i) (u i) (u j) (u j) else 0)| ≤ + (m:ℝ)^4*(32*(2*m*localizedOverlapBound D)*localizedPotentialBound freq)+ + localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D) := by + have hg := localizedLinearFourIndex_correction hf u (correctedLocalizedCoefficients u) + (show 0 ≤ 2*(m:ℝ)*localizedOverlapBound D by + exact mul_nonneg (by positivity) (localizedOverlapBound_nonnegative D)) + (fun a b => (correctedLocalizedCoefficients_entries u hsep hs a b).2) + (fun a b => (correctedLocalizedCoefficients_entries u hsep hs a b).1) i k j l + have hb : 0 ≤ localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D) := + mul_nonneg (localizedFourIndexConstant_nonnegative freq) (Real.exp_pos _).le + by_cases h : i=k ∧ j=l + · obtain ⟨rfl,rfl⟩ := h + simpa only [and_self,ite_true] using hg.trans (le_add_of_nonneg_right hb) + · have ho : i ≠ k ∨ j ≠ l := by tauto + have he := localizedFourIndex_offsite hf u hsep i k j l ho + simp only [h,ite_false,sub_zero] + have ht := abs_add_le + (localizedLinearFourIndex hf u (correctedLocalizedCoefficients u i) + (correctedLocalizedCoefficients u k) (correctedLocalizedCoefficients u j) + (correctedLocalizedCoefficients u l)-localizedFourIndex freq (u i) (u k) (u j) (u l)) + (localizedFourIndex freq (u i) (u k) (u j) (u l)) + simp only [sub_add_cancel] at ht + exact ht.trans (add_le_add hg he) + +theorem localizedSpinMode_coulomb_integrable {freq : ℝ} (hf : 0 < freq) + {m : ℕ} (u : Fin (m+1) → PlanarPosition) (a b c d : Fin ((2*m+1)+1)) : + Integrable (fun z => flatPairCoulomb z.1 z.2* + ((star (Coulomb.flatSpinOrbital (localizedSpinMode freq u a) z.1)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u c) z.1)* + (star (Coulomb.flatSpinOrbital (localizedSpinMode freq u b) z.2)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u d) z.2))) + (Coulomb.spinSpaceMeasure.prod Coulomb.spinSpaceMeasure) := by + let p := (HubbardGlobal.siteModes m).symm + apply realSpin_coulomb_integrable + convert localizedLinearFourIndex_integrable hf u + (correctedLocalizedCoefficients u (p a).1) (correctedLocalizedCoefficients u (p c).1) + (correctedLocalizedCoefficients u (p b).1) (correctedLocalizedCoefficients u (p d).1) using 1 + funext z + dsimp only [correctedLocalizedMode,p] + ring + +theorem localizedSpinMode_coulomb_tensor {freq : ℝ} (hf : 0 < freq) + {m : ℕ} (u : Fin (m+1) → PlanarPosition) (a b c d : Fin ((2*m+1)+1)) : + flatCoulombTensor (localizedSpinMode freq u) a b c d = + let p := (HubbardGlobal.siteModes m).symm + if (p a).2=(p c).2 ∧ (p b).2=(p d).2 then + (localizedLinearFourIndex hf u (correctedLocalizedCoefficients u (p a).1) + (correctedLocalizedCoefficients u (p c).1) (correctedLocalizedCoefficients u (p b).1) + (correctedLocalizedCoefficients u (p d).1):ℂ) else 0 := by + let p := (HubbardGlobal.siteModes m).symm + have hI : Integrable (fun z : Position × Position => Coulomb.coulombKernel (z.1-z.2)* + ((correctedLocalizedMode freq u (p a).1 z.1*correctedLocalizedMode freq u (p c).1 z.1)* + (correctedLocalizedMode freq u (p b).1 z.2*correctedLocalizedMode freq u (p d).1 z.2))) + (volume.prod volume) := by + convert localizedLinearFourIndex_integrable hf u + (correctedLocalizedCoefficients u (p a).1) (correctedLocalizedCoefficients u (p c).1) + (correctedLocalizedCoefficients u (p b).1) (correctedLocalizedCoefficients u (p d).1) using 1 + funext z + dsimp only [correctedLocalizedMode] + ring + have he : (∫ z : Position × Position, Coulomb.coulombKernel (z.1-z.2)* + ((correctedLocalizedMode freq u (p a).1 z.1*correctedLocalizedMode freq u (p c).1 z.1)* + (correctedLocalizedMode freq u (p b).1 z.2*correctedLocalizedMode freq u (p d).1 z.2)) + ∂(volume.prod volume)) = localizedLinearFourIndex hf u + (correctedLocalizedCoefficients u (p a).1) (correctedLocalizedCoefficients u (p c).1) + (correctedLocalizedCoefficients u (p b).1) (correctedLocalizedCoefficients u (p d).1) := by + rw [localizedLinearFourIndex_integral hf u] + apply integral_congr_ae + filter_upwards [] with z + dsimp only [correctedLocalizedMode] + ring + have h := realSpin_coulomb_integral _ _ _ _ hI (p a).2 (p b).2 (p c).2 (p d).2 + change flatCoulombTensor (localizedSpinMode freq u) a b c d = _ at h + change flatCoulombTensor (localizedSpinMode freq u) a b c d = + if (p a).2=(p c).2 ∧ (p b).2=(p d).2 then _ else 0 + simpa only [he] using h + +def localizedDensityTensor (freq : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (a b c d : Fin ((2*m+1)+1)) : ℂ := + let p := (HubbardGlobal.siteModes m).symm + if a=c ∧ b=d then + (localizedFourIndex freq (u (p a).1) (u (p a).1) (u (p b).1) (u (p b).1):ℂ) else 0 + +theorem localizedSpinMode_coulomb_error {freq D : ℝ} (hf : 0 < freq) + {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) + (a b c d : Fin ((2*m+1)+1)) : + ‖flatCoulombTensor (localizedSpinMode freq u) a b c d-localizedDensityTensor freq u a b c d‖ ≤ + (m+1:ℝ)^4*(32*(2*(m+1:ℝ)*localizedOverlapBound D)*localizedPotentialBound freq)+ + localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D) := by + let p := (HubbardGlobal.siteModes m).symm + have he := correctedLocalizedFourIndex_error hf u hsep hs (p a).1 (p b).1 (p c).1 (p d).1 + rw [localizedSpinMode_coulomb_tensor hf] + change ‖(if (p a).2=(p c).2 ∧ (p b).2=(p d).2 then _ else 0)-_‖ ≤ _ + by_cases hspin : (p a).2=(p c).2 ∧ (p b).2=(p d).2 + · have heq : ((p a).1=(p c).1 ∧ (p b).1=(p d).1) ↔ (a=c ∧ b=d) := by + constructor + · rintro ⟨hac,hbd⟩ + exact ⟨p.injective (Prod.ext hac hspin.1),p.injective (Prod.ext hbd hspin.2)⟩ + · rintro ⟨rfl,rfl⟩ + exact ⟨rfl,rfl⟩ + rw [ite_eq_left hspin] + dsimp only [localizedDensityTensor] + simp only [heq] at he + split_ifs at he ⊢ <;> simpa only [← Complex.ofReal_sub,Complex.norm_real, + Real.norm_eq_abs,Complex.ofReal_zero,sub_zero,Nat.cast_add,Nat.cast_one] using he + · have hne : ¬(a=c ∧ b=d) := by rintro ⟨rfl,rfl⟩; exact hspin ⟨rfl,rfl⟩ + rw [ite_eq_right hspin] + simp only [localizedDensityTensor,ite_eq_right hne,sub_self,norm_zero] + have hp := localizedPotentialBound_nonnegative freq + have hov := localizedOverlapBound_nonnegative D + exact add_nonneg (by positivity) + (mul_nonneg (localizedFourIndexConstant_nonnegative freq) (Real.exp_pos _).le) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombNumerics.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombNumerics.lean new file mode 100644 index 0000000000000000000000000000000000000000..66e9c8805597bb098763b81a8b4dbacfbc14c276 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombNumerics.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombMass +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombSymmetry + +namespace OAI + +/-! The actual six-coordinate bounded integrand for Coulomb quadrature, +with an explicit error to the original full singular coefficient. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedCappedIntegrand (freq ε : ℝ) (u v : PlanarPosition) (p : Position × Position) : ℝ := + localizedDensity freq u p.1 * + (cappedCoulombKernel ε (p.1 - p.2) * localizedDensity freq v p.2) + +def localizedCappedCoulombCoeff (freq ε : ℝ) (u v : PlanarPosition) : ℝ := + ∫ p, localizedCappedIntegrand freq ε u v p + +theorem localizedCappedIntegrand_integrable {freq ε : ℝ} (hfreq : 0 < freq) (hε : 0 < ε) + (u v : PlanarPosition) : Integrable (localizedCappedIntegrand freq ε u v) := by + have hp : Integrable (fun p : Position × Position => + localizedDensity freq u p.1 * localizedDensity freq v p.2) := by + simpa only [Measure.volume_eq_prod] using + (localizedDensity_integrable hfreq u).mul_prod (localizedDensity_integrable hfreq v) + have hk : Continuous (fun p : Position × Position => cappedCoulombKernel ε (p.1 - p.2)) := + (cappedCoulombKernel_continuous hε).comp (continuous_fst.sub continuous_snd) + have h := hp.mul_bdd (c := ε⁻¹) hk.aestronglyMeasurable + (Filter.Eventually.of_forall (fun p => by + rw [Real.norm_of_nonneg (cappedCoulombKernel_nonnegative hε _)] + exact cappedCoulombKernel_le hε _)) + convert h using 1 + funext p + unfold localizedCappedIntegrand + ring + +theorem localizedCappedCoulombCoeff_nested {freq ε : ℝ} (hfreq : 0 < freq) (hε : 0 < ε) + (u v : PlanarPosition) : + localizedCappedCoulombCoeff freq ε u v = + ∫ x, localizedDensity freq u x * cappedCoulombPotential ε (localizedDensity freq v) x := by + unfold localizedCappedCoulombCoeff + rw [Measure.volume_eq_prod, integral_prod _ + (by simpa only [Measure.volume_eq_prod] using localizedCappedIntegrand_integrable hfreq hε u v)] + simp only [localizedCappedIntegrand, integral_const_mul, cappedCoulombPotential] + +theorem localizedCappedCoulombCoeff_error {freq ε : ℝ} (hfreq : 0 < freq) (hε : 0 < ε) + (u v : PlanarPosition) : + |localizedCoulombCoeff freq u v - localizedCappedCoulombCoeff freq ε u v| ≤ + 2 * Real.pi * localizedAmplitudeBound freq ^ 2 * ε ^ 2 := by + have hic : Integrable (fun x => localizedDensity freq u x * + cappedCoulombPotential ε (localizedDensity freq v) x) := by + have h := (localizedCappedIntegrand_integrable hfreq hε u v).integral_prod_left + simpa only [localizedCappedIntegrand, integral_const_mul, cappedCoulombPotential] using h + rw [localizedCappedCoulombCoeff_nested hfreq hε, localizedCoulombCoeff, + ← integral_sub (localizedCoulombCoeff_integrable hfreq u v) hic] + have h := norm_integral_le_of_norm_le + (f := fun x => localizedDensity freq u x * NeutralAtom.potentialOf (localizedDensity freq v) x - + localizedDensity freq u x * cappedCoulombPotential ε (localizedDensity freq v) x) + ((localizedDensity_integrable hfreq u).mul_const + (2 * Real.pi * localizedAmplitudeBound freq ^ 2 * ε ^ 2)) + (Filter.Eventually.of_forall (fun x => by + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (localizedDensity_nonnegative freq u x), + Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left + (cappedCoulombPotential_error_explicit hε (localizedDensity_integrable hfreq v) + (localizedDensity_nonnegative freq v) (localizedDensity_bound hfreq v) x) + (localizedDensity_nonnegative freq u x))) + simpa only [Real.norm_eq_abs, integral_mul_const, localizedDensity_mass hfreq u, one_mul] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombRadial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..186f6fa0e9c90c05c4f550319f793817c99c849e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombRadial.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombLipschitz +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarRadial + +namespace OAI + +/-! The actual direct Coulomb interaction depends only on planar separation. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def liftPlanarIsometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) : Position ≃ₗᵢ[ℝ] Position := + positionSplitIsometry.trans + ((LinearIsometryEquiv.withLpProdCongr 2 L (LinearIsometryEquiv.refl ℝ ℝ)).trans + positionSplitIsometry.symm) + +theorem liftPlanarIsometry_coordinates (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (x : Position) : + positionSplitCoordinates (liftPlanarIsometry L x) = + (L (positionSplitCoordinates x).1, (positionSplitCoordinates x).2) := by + change WithLp.ofLp (positionSplitIsometry (positionSplitIsometry.symm + ((LinearIsometryEquiv.withLpProdCongr 2 L (LinearIsometryEquiv.refl ℝ ℝ)) + (positionSplitIsometry x)))) = _ + rw [positionSplitIsometry.apply_symm_apply] + rfl + +theorem localizedDensity_liftPlanarIsometry (freq : ℝ) + (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (u : PlanarPosition) (x : Position) : + localizedDensity freq (L u) (liftPlanarIsometry L x) = localizedDensity freq u x := by + simp only [localizedDensity, continuumLocalizedMode, localizedMode, + liftPlanarIsometry_coordinates, ← L.map_sub, normalizedPlanarMode_isometry] + +theorem localizedDensity_potential_liftPlanarIsometry (freq : ℝ) + (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (u : PlanarPosition) (x : Position) : + NeutralAtom.potentialOf (localizedDensity freq (L u)) (liftPlanarIsometry L x) = + NeutralAtom.potentialOf (localizedDensity freq u) x := by + unfold NeutralAtom.potentialOf + rw [← MeasureTheory.integral_comp (liftPlanarIsometry L) + (fun y => NeutralAtom.coulombKernel (liftPlanarIsometry L x - y) * localizedDensity freq (L u) y)] + apply integral_congr_ae + filter_upwards [] with y + rw [localizedDensity_liftPlanarIsometry, ← (liftPlanarIsometry L).map_sub] + simp only [NeutralAtom.coulombKernel, LinearIsometryEquiv.norm_map] + +theorem localizedCoulombCoeff_isometry (freq : ℝ) + (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (u v : PlanarPosition) : + localizedCoulombCoeff freq (L u) (L v) = localizedCoulombCoeff freq u v := by + unfold localizedCoulombCoeff + rw [← MeasureTheory.integral_comp (liftPlanarIsometry L) + (fun x => localizedDensity freq (L u) x * NeutralAtom.potentialOf (localizedDensity freq (L v)) x)] + apply integral_congr_ae + filter_upwards [] with x + rw [localizedDensity_liftPlanarIsometry, localizedDensity_potential_liftPlanarIsometry] + +theorem localizedCoulombProfileAt_isometry (freq : ℝ) + (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (u : PlanarPosition) : + localizedCoulombProfileAt freq (L u) = localizedCoulombProfileAt freq u := by + rw [localizedCoulombProfileAt_eq, localizedCoulombProfileAt_eq] + simpa only [map_zero] using localizedCoulombCoeff_isometry freq L 0 u + +theorem localizedCoulombProfileAt_norm (freq : ℝ) (u : PlanarPosition) : + localizedCoulombProfileAt freq u = localizedCoulombProfile freq ‖u‖ := by + have hn : ‖‖u‖ • planarAxis 0‖ = ‖u‖ := by + rw [norm_smul, planarAxis_zero_norm, mul_one, Real.norm_of_nonneg (norm_nonneg u)] + have h := localizedCoulombProfileAt_isometry freq + ((ℝ ∙ (‖u‖ • planarAxis 0 - u))ᗮ.reflection) (‖u‖ • planarAxis 0) + rw [Submodule.reflection_sub hn] at h + exact h + +theorem localizedCoulombCoeff_displacement (freq : ℝ) (u v : PlanarPosition) : + localizedCoulombCoeff freq u v = localizedCoulombProfileAt freq (v - u) := by + unfold localizedCoulombCoeff localizedCoulombProfileAt + rw [← integral_add_right_eq_self + (fun x => localizedDensity freq u x * NeutralAtom.potentialOf (localizedDensity freq v) x) + (planarCenter u)] + apply integral_congr_ae + filter_upwards [] with x + rw [localizedDensity_translate freq u, add_sub_cancel_right, localizedDensity_potential_translate freq v] + congr 2 + rw [planarCenter_sub] + abel + +theorem localizedCoulombCoeff_distance (freq : ℝ) (u v : PlanarPosition) : + localizedCoulombCoeff freq u v = localizedCoulombProfile freq ‖u - v‖ := by + rw [localizedCoulombCoeff_displacement, localizedCoulombProfileAt_norm, norm_sub_rev] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombSymmetry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..63867e944e4d7602670354effccc17fd7af075eb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombSymmetry.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulomb + +namespace OAI + +/-! Actual strict positivity and symmetry of the direct Coulomb coefficients. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem localizedDensity_potential_positive {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : + 0 < NeutralAtom.potentialOf (localizedDensity freq u) x := by + have hn := localizedDensity_potential_nonnegative freq u x + by_contra h + have hz : NeutralAtom.potentialOf (localizedDensity freq u) x = 0 := by linarith + have he := (integral_eq_zero_iff_of_nonneg + (fun y => mul_nonneg (NeutralAtom.coulombKernel_nonneg _) + (localizedDensity_nonnegative freq u y)) + (localizedDensity_coulomb_integrable_bound hfreq u x).1).mp hz + have hf : ∀ᵐ y : Position, False := by + filter_upwards [he, volume.ae_ne x] with y hy hxy + have hk : 0 < NeutralAtom.coulombKernel (x - y) := + inv_pos.mpr (norm_pos_iff.mpr (sub_ne_zero.mpr hxy.symm)) + exact (mul_pos hk (localizedDensity_positive hfreq u y)).ne' hy + obtain ⟨y, hy⟩ := hf.exists + exact hy + +theorem localizedCoulombCoeff_positive {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : 0 < localizedCoulombCoeff freq u v := + integral_pos_of_integrable_nonneg_nonzero + ((localizedDensity_continuous freq u).mul (localizedDensity_potential_continuous hfreq v)) + (localizedCoulombCoeff_integrable hfreq u v) + (fun x => mul_nonneg (localizedDensity_nonnegative freq u x) + (localizedDensity_potential_nonnegative freq v x)) + (mul_pos (localizedDensity_positive hfreq u 0) + (localizedDensity_potential_positive hfreq v 0)).ne' + +theorem localizedCoulomb_product_integrable {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : + Integrable (fun p : Position × Position => localizedDensity freq u p.1 * + (NeutralAtom.coulombKernel (p.1 - p.2) * localizedDensity freq v p.2)) + ((volume : Measure Position).prod volume) := by + have hm : AEStronglyMeasurable + (fun p : Position × Position => localizedDensity freq u p.1 * + (NeutralAtom.coulombKernel (p.1 - p.2) * localizedDensity freq v p.2)) + ((volume : Measure Position).prod volume) := + (((localizedDensity_continuous freq u).measurable.comp measurable_fst).mul + ((NeutralAtom.measurable_coulombKernel.comp (measurable_fst.sub measurable_snd)).mul + ((localizedDensity_continuous freq v).measurable.comp measurable_snd))).aestronglyMeasurable + apply (integrable_prod_iff hm).mpr + constructor + · exact Filter.Eventually.of_forall (fun x => + (localizedDensity_coulomb_integrable_bound hfreq v x).1.const_mul + (localizedDensity freq u x)) + · have hn (x y : Position) : + ‖localizedDensity freq u x * + (NeutralAtom.coulombKernel (x - y) * localizedDensity freq v y)‖ = + localizedDensity freq u x * + (NeutralAtom.coulombKernel (x - y) * localizedDensity freq v y) := + Real.norm_of_nonneg (mul_nonneg (localizedDensity_nonnegative freq u x) + (mul_nonneg (NeutralAtom.coulombKernel_nonneg _) + (localizedDensity_nonnegative freq v y))) + simp_rw [hn, integral_const_mul] + exact localizedCoulombCoeff_integrable hfreq u v + +theorem localizedCoulombCoeff_symmetric {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : localizedCoulombCoeff freq u v = localizedCoulombCoeff freq v u := by + unfold localizedCoulombCoeff NeutralAtom.potentialOf + simp_rw [← integral_const_mul] + rw [integral_integral_swap (localizedCoulomb_product_integrable hfreq u v)] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun y => by + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun x => by + simp only [NeutralAtom.coulombKernel, norm_sub_rev x y] + ring)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombTranslation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombTranslation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2127ab42eb9635e4536183cb20f6259c6fb423a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCoulombTranslation.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombSymmetry + +namespace OAI + +/-! Direct Coulomb coefficients as actual translated-density profiles. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarCenter (u : PlanarPosition) : Position := positionSplitCoordinates.symm (u, 0) + +theorem planarCenter_norm (u : PlanarPosition) : ‖planarCenter u‖ = ‖u‖ := by + have h := positionSplitCoordinates_norm_sq (planarCenter u) + simp only [planarCenter, ContinuousLinearEquiv.apply_symm_apply, zero_pow (by norm_num : 2 ≠ 0), + add_zero] at h + exact (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp h + +theorem planarCenter_sub (u v : PlanarPosition) : planarCenter (u - v) = planarCenter u - planarCenter v := by + change positionSplitCoordinates.symm (u - v, 0) = + positionSplitCoordinates.symm (u, 0) - positionSplitCoordinates.symm (v, 0) + rw [← map_sub] + simp only [Prod.mk_sub_mk, sub_self] + +theorem planarCenter_norm_sub (u v : PlanarPosition) : ‖planarCenter u - planarCenter v‖ = ‖u - v‖ := by + rw [← planarCenter_sub, planarCenter_norm] + +theorem continuumLocalizedMode_translate (freq : ℝ) (u : PlanarPosition) (x : Position) : + continuumLocalizedMode freq u x = continuumLocalizedMode freq 0 (x - planarCenter u) := by + simp only [continuumLocalizedMode, localizedMode, map_sub, planarCenter, + ContinuousLinearEquiv.apply_symm_apply, Prod.fst_sub, Prod.snd_sub, sub_zero] + +theorem localizedDensity_translate (freq : ℝ) (u : PlanarPosition) (x : Position) : + localizedDensity freq u x = localizedDensity freq 0 (x - planarCenter u) := by + simp only [localizedDensity, continuumLocalizedMode_translate freq u] + +theorem localizedDensity_potential_translate (freq : ℝ) (u : PlanarPosition) (x : Position) : + NeutralAtom.potentialOf (localizedDensity freq u) x = + NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter u) := by + unfold NeutralAtom.potentialOf + rw [← integral_add_right_eq_self + (fun y => NeutralAtom.coulombKernel (x - y) * localizedDensity freq u y) (planarCenter u)] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun y => by + dsimp only + rw [localizedDensity_translate freq u, add_sub_cancel_right] + congr 2 + abel) + +def localizedCoulombProfileAt (freq : ℝ) (u : PlanarPosition) : ℝ := + ∫ x, localizedDensity freq 0 x * + NeutralAtom.potentialOf (localizedDensity freq 0) (x - planarCenter u) + +theorem localizedCoulombProfileAt_eq (freq : ℝ) (u : PlanarPosition) : + localizedCoulombProfileAt freq u = localizedCoulombCoeff freq 0 u := by + unfold localizedCoulombProfileAt localizedCoulombCoeff + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun x => + congrArg (fun z => localizedDensity freq 0 x * z) + (localizedDensity_potential_translate freq u x).symm) + +def localizedCoulombProfile (freq d : ℝ) : ℝ := + localizedCoulombProfileAt freq (d • planarAxis 0) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCountertermMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCountertermMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..49a08dedf866f1c255ee46d6330c6300df2e5b5b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCountertermMatrix.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCounterterms +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellOverlap + +namespace OAI + +/-! Actual counterterm matrix estimates: the onsite term is the required +negative direct-interaction sum; other diagonal terms have two tails and +off-diagonal terms have the actual overlap decay. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedCountertermMatrix (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : ℝ := + ∑ k, localizedCounterterm freq u k * planarWellMatrix (u i) (u j) (u k) + +theorem localizedCountertermMatrix_diagonal_error_eq (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) : + localizedCountertermMatrix freq u i i + localizedOffsiteSum freq u i = + ∑ k, if k = i then 0 else localizedCounterterm freq u k * planarWellMatrix (u i) (u i) (u k) := by + classical + have hpoint (k : Fin m) : + localizedCounterterm freq u k * planarWellMatrix (u i) (u i) (u k) = + (if k = i then localizedCounterterm freq u i * planarWellMatrix (u i) (u i) (u i) else 0) + + (if k = i then 0 else localizedCounterterm freq u k * planarWellMatrix (u i) (u i) (u k)) := by + by_cases hk : k = i + · subst k + simp only [ite_true, add_zero] + · simp only [hk, ite_false, zero_add] + have hs := Finset.sum_congr (s₁ := Finset.univ) rfl (fun k _ => hpoint k) + unfold localizedCountertermMatrix + rw [hs, Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, localizedCounterterm_diagonal] + ring + +theorem localizedCountertermMatrix_diagonal_error_bound {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) (i : Fin m) : + |localizedCountertermMatrix freq u i i + localizedOffsiteSum freq u i| ≤ + (m : ℝ) ^ 2 * localizedCountertermBound freq * planarWellMatrixConstant * + Real.exp (-(19 / 10 : ℝ) * D) := by + rw [localizedCountertermMatrix_diagonal_error_eq] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _k : Fin m, (m * localizedCountertermBound freq) * + (planarWellMatrixConstant * Real.exp (-(19 / 10 : ℝ) * D)) := by + apply Finset.sum_le_sum + intro k _ + split_ifs with hk + · rw [abs_zero] + exact mul_nonneg (mul_nonneg (Nat.cast_nonneg m) (localizedCountertermBound_nonnegative freq)) + (mul_nonneg planarWellMatrixConstant_nonnegative (Real.exp_pos _).le) + · rw [abs_mul, abs_of_nonneg (localizedCounterterm_nonnegative freq u k)] + exact mul_le_mul (localizedCounterterm_bound hfreq u k) + (planarWellMatrix_two_far _ _ _ (hsep i k (Ne.symm hk)) (hsep i k (Ne.symm hk))) + (abs_nonneg _) (mul_nonneg (Nat.cast_nonneg m) (localizedCountertermBound_nonnegative freq)) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + +theorem localizedCountertermMatrix_offdiagonal_bound {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + |localizedCountertermMatrix freq u i j| ≤ + (m : ℝ) ^ 2 * localizedCountertermBound freq * + (PlanarSobolev.wellBound * planarOverlapConstant) * Real.exp (-(9 / 10 : ℝ) * ‖u i - u j‖) := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _k : Fin m, (m * localizedCountertermBound freq) * + ((PlanarSobolev.wellBound * planarOverlapConstant) * Real.exp (-(9 / 10 : ℝ) * ‖u i - u j‖)) := by + apply Finset.sum_le_sum + intro k _ + rw [abs_mul, abs_of_nonneg (localizedCounterterm_nonnegative freq u k)] + exact mul_le_mul (localizedCounterterm_bound hfreq u k) (planarWellMatrix_overlap_decay _ _ _) + (abs_nonneg _) (mul_nonneg (Nat.cast_nonneg m) (localizedCountertermBound_nonnegative freq)) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCounterterms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCounterterms.lean new file mode 100644 index 0000000000000000000000000000000000000000..e193ab80638a2b606f27e933ff594ee0576c8f5c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedCounterterms.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFourIndex +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds + +namespace OAI + +/-! The manuscript's actual well-depth counterterms: direct Coulomb sums +divided by the fixed positive onsite well integral. Their diagonal action +cancels the required linear occupancy term exactly. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedOffsiteSum (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : ℝ := + ∑ j, if i = j then 0 else localizedCoulombCoeff freq (u i) (u j) + +def localizedCounterterm (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : ℝ := + localizedOffsiteSum freq u i / planarHopping 0 + +def localizedCountertermBound (freq : ℝ) : ℝ := localizedPotentialBound freq / planarHopping 0 + +theorem localizedOffsiteSum_nonnegative (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : + 0 ≤ localizedOffsiteSum freq u i := by + apply Finset.sum_nonneg + intro j _ + split_ifs + · exact le_rfl + · exact localizedCoulombCoeff_nonnegative freq _ _ + +theorem localizedCounterterm_nonnegative (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : + 0 ≤ localizedCounterterm freq u i := + div_nonneg (localizedOffsiteSum_nonnegative freq u i) (planarHopping_positive 0).le + +theorem localizedCountertermBound_nonnegative (freq : ℝ) : 0 ≤ localizedCountertermBound freq := + div_nonneg (localizedPotentialBound_nonnegative freq) (planarHopping_positive 0).le + +theorem localizedOffsiteSum_bound {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : + localizedOffsiteSum freq u i ≤ m * localizedPotentialBound freq := by + calc + _ ≤ ∑ _j : Fin m, localizedPotentialBound freq := by + apply Finset.sum_le_sum + intro j _ + split_ifs + · exact localizedPotentialBound_nonnegative freq + · exact localizedCoulombCoeff_le hfreq _ _ + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + +theorem localizedCounterterm_bound {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : + localizedCounterterm freq u i ≤ m * localizedCountertermBound freq := by + exact (div_le_div_of_nonneg_right (localizedOffsiteSum_bound hfreq u i) + (planarHopping_positive 0).le).trans_eq (by unfold localizedCountertermBound; ring) + +theorem localizedCounterterm_diagonal (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i : Fin m) : + localizedCounterterm freq u i * planarWellMatrix (u i) (u i) (u i) = -localizedOffsiteSum freq u i := by + rw [planarWellMatrix_hopping, sub_self, norm_zero] + unfold localizedCounterterm + field_simp [(planarHopping_positive 0).ne'] + +theorem exists_uniform_counterterm_scale {freq : ℝ} (hfreq : 0 < freq) (A : ℕ) : + ∃ E : ℕ, 0 < E ∧ ∀ N : ℝ, 2 ≤ N → ∀ (m : ℕ), (m : ℝ) ≤ N ^ A → + ∀ (u : Fin m → PlanarPosition) (i : Fin m), + 0 ≤ localizedCounterterm freq u i / N ^ E ∧ localizedCounterterm freq u i / N ^ E ≤ 1 / 2 := by + obtain ⟨L, hL, hbound⟩ := exists_polynomial_constant_bounds (by norm_num : (0 : ℝ) < 1) + (localizedCountertermBound freq) + refine ⟨A + L + 1, by omega, fun N hN m hm u i => ?_⟩ + have hNp : 0 < N := by linarith + have hb : localizedCounterterm freq u i ≤ N ^ (A + L) := by + calc + _ ≤ m * localizedCountertermBound freq := localizedCounterterm_bound hfreq u i + _ ≤ N ^ A * N ^ L := mul_le_mul hm (hbound N hN).2 + (localizedCountertermBound_nonnegative freq) (pow_nonneg hNp.le A) + _ = _ := (pow_add _ _ _).symm + refine ⟨div_nonneg (localizedCounterterm_nonnegative freq u i) (pow_pos hNp _).le, ?_⟩ + apply (div_le_iff₀ (pow_pos hNp _)).mpr + rw [pow_succ] + have h := mul_le_mul_of_nonneg_left hN (pow_nonneg hNp.le (A + L)) + nlinarith only [hb, h] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDensityMoment.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDensityMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..439832e3f699833531c06b21316b65003acf6b1a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDensityMoment.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombTranslation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarExponentialEnvelope + +namespace OAI + +/-! A fixed finite second moment of the actual localized probability density. +It supplies a polynomial finite-box truncation radius, uniformly in the +relative displacement appearing in a direct Coulomb coefficient. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem quadratic_exponential_bound {t : ℝ} (ht : 0 ≤ t) : + t ^ 2 * Real.exp (-(1 / 2 : ℝ) * t) ≤ 343 := by + have h := exponential_inverse_cubic_bound (by norm_num : (0 : ℝ) < 1 / 2) ht + norm_num at h + have hp : 0 < (1 + t) ^ 3 := by positivity + have hm := (le_div_iff₀ hp).mp h + have hpoly : t ^ 2 ≤ (1 + t) ^ 3 := by + nlinarith [mul_nonneg ht (sq_nonneg t), sq_nonneg t] + calc + _ = Real.exp (-(1 / 2 : ℝ) * t) * t ^ 2 := mul_comm _ _ + _ ≤ Real.exp (-(1 / 2 : ℝ) * t) * (1 + t) ^ 3 := + mul_le_mul_of_nonneg_left hpoly (Real.exp_pos _).le + _ ≤ 343 := by simpa only [neg_mul] using hm + +theorem planarResolventMode_second_moment_integrable : + Integrable (fun r : PlanarPosition => ‖r‖ ^ 2 * planarResolventMode r ^ 2) := by + let C := planarExponentialConstant (1 / 2) ^ 2 * 343 + have hC : 0 ≤ C := by dsimp [C]; positivity + apply ((planar_exp_norm_integrable (by norm_num : (0 : ℝ) < 1 / 2)).const_mul C).mono' + ((continuous_norm.pow 2).mul (planarResolventMode_C7.continuous.pow 2)).aestronglyMeasurable + filter_upwards [] with r + change ‖‖r‖ ^ 2 * planarResolventMode r ^ 2‖ ≤ C * Real.exp (-(1 / 2 : ℝ) * ‖r‖) + rw [Real.norm_of_nonneg (mul_nonneg (sq_nonneg _) (sq_nonneg _))] + have hmode := pow_le_pow_left₀ (planarResolventMode_positive r).le + (planarResolventMode_exponential_envelope (by norm_num : (0 : ℝ) ≤ 1 / 2) + (by norm_num : (1 / 2 : ℝ) < 1) r) 2 + have hsq : Real.exp (-(1 / 2 : ℝ) * ‖r‖) ^ 2 = + Real.exp (-(1 / 2 : ℝ) * ‖r‖) * Real.exp (-(1 / 2 : ℝ) * ‖r‖) := by ring + rw [mul_pow, hsq] at hmode + calc + _ ≤ ‖r‖ ^ 2 * (planarExponentialConstant (1 / 2) ^ 2 * + (Real.exp (-(1 / 2 : ℝ) * ‖r‖) * Real.exp (-(1 / 2 : ℝ) * ‖r‖))) := + mul_le_mul_of_nonneg_left hmode (sq_nonneg _) + _ = (planarExponentialConstant (1 / 2) ^ 2 * + (‖r‖ ^ 2 * Real.exp (-(1 / 2 : ℝ) * ‖r‖))) * + Real.exp (-(1 / 2 : ℝ) * ‖r‖) := by ring + _ ≤ C * Real.exp (-(1 / 2 : ℝ) * ‖r‖) := by + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (quadratic_exponential_bound (norm_nonneg r)) + (sq_nonneg _)) (Real.exp_pos _).le + +theorem normalizedPlanarMode_second_moment_integrable : + Integrable (fun r : PlanarPosition => ‖r‖ ^ 2 * normalizedPlanarMode r ^ 2) := by + simp_rw [normalizedPlanarMode, div_pow, ← mul_div_assoc] + exact planarResolventMode_second_moment_integrable.div_const _ + +theorem localizedDensity_second_moment_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun x : Position => ‖x‖ ^ 2 * localizedDensity freq 0 x) := by + have hsplit : Integrable (fun p : SplitPosition => + (‖p.1‖ ^ 2 + p.2 ^ 2) * localizedMode freq 0 p ^ 2) := by + have hp := normalizedPlanarMode_second_moment_integrable.mul_prod + (verticalMode_square_integrable hfreq) + have hz := normalizedPlanarMode_square_integrable.mul_prod + (verticalMode_moment_integrable hfreq 2) + convert hp.add hz using 1 + funext p + simp only [localizedMode, sub_zero, mul_pow, Pi.add_apply] + ring + have hc := positionSplitCoordinates_measurePreserving.integrable_comp_of_integrable hsplit + convert hc using 1 + funext x + simp only [Function.comp_apply, localizedDensity, continuumLocalizedMode, + positionSplitCoordinates_norm_sq] + +def localizedDensitySecondMoment (freq : ℝ) : ℝ := + ∫ x : Position, ‖x‖ ^ 2 * localizedDensity freq 0 x + +theorem localizedDensitySecondMoment_nonnegative (freq : ℝ) : + 0 ≤ localizedDensitySecondMoment freq := + integral_nonneg (fun _ => mul_nonneg (sq_nonneg _) (localizedDensity_nonnegative _ _ _)) + +theorem localizedDensity_tail_of_norm {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, localizedDensity freq 0 x) ≤ localizedDensitySecondMoment freq / R ^ 2 := by + have hw := localizedDensity_second_moment_integrable hfreq + have hd := (localizedDensity_integrable hfreq 0).const_mul (R ^ 2) + have hle := setIntegral_mono_on hd.integrableOn hw.integrableOn hS.compl + (fun x hx => mul_le_mul_of_nonneg_right + (sq_le_sq₀ hR.le (norm_nonneg x) |>.mpr (hout x hx)) + (localizedDensity_nonnegative freq 0 x)) + have hfull := integral_mono_measure (μ := volume.restrict Sᶜ) + Measure.restrict_le_self (Filter.Eventually.of_forall (fun x => + mul_nonneg (sq_nonneg ‖x‖) (localizedDensity_nonnegative freq 0 x))) hw + rw [integral_const_mul] at hle + apply (le_div_iff₀ (sq_pos_of_pos hR)).mpr + simpa only [localizedDensitySecondMoment, mul_comm] using hle.trans hfull + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDualMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDualMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b1c9d141dd421f352fbf7c23933ce51c4c9c71a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDualMatrix.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGramApprox + +namespace OAI + +/-! Concrete compact bumps supply local duality for the actual mode densities. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +def localDualBump : ContDiffBump (0 : Position) := ⟨1, 2, by norm_num, by norm_num⟩ + +theorem localDualBump_smooth : ContDiff ℝ ∞ (localDualBump : Position → ℝ) := + localDualBump.contDiff + +theorem localDualBump_support : tsupport (localDualBump : Position → ℝ) ⊆ Metric.closedBall 0 2 := by + rw [localDualBump.tsupport_eq] + exact Set.Subset.rfl + +def localDualMass (freq : ℝ) : ℝ := + ∫ x, localizedDensity freq 0 x * localDualBump x + +theorem localDualMass_positive {freq : ℝ} (hfreq : 0 < freq) : 0 < localDualMass freq := by + have h0 : localDualBump (0 : Position) = 1 := + localDualBump.one_of_mem_closedBall (by simp [localDualBump]) + have h := localizedDualPair_diagonal_positive hfreq 0 localDualBump_smooth.continuous + localDualBump.hasCompactSupport localDualBump.nonneg' (by rw [h0]; norm_num) + simpa only [localizedDualPair_diagonal, localDualMass] using h + +def localLeakageBound (freq D : ℝ) : ℝ := + (localizedTailConstant freq * Real.exp (2 - D)) * (∫ x : Position, |localDualBump x|) + +theorem localLeakageBound_nonnegative (freq D : ℝ) : 0 ≤ localLeakageBound freq D := + mul_nonneg (mul_nonneg (localizedTailConstant_nonnegative freq) (Real.exp_pos _).le) + (integral_nonneg (fun _ => abs_nonneg _)) + +theorem localDualPair_offsite {freq D : ℝ} (hfreq : 0 < freq) (hD : 3 ≤ D) + (u v : PlanarPosition) (hsep : D ≤ ‖u - v‖) : + |localizedDualPair freq u v localDualBump| ≤ localLeakageBound freq D := by + have h := localizedDualPair_offsite hfreq u v localDualBump_smooth.continuous + localDualBump.hasCompactSupport localDualBump_support (by linarith : (2 : ℝ) + 1 ≤ ‖u - v‖) + exact h.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (localizedTailConstant_nonnegative freq)) (integral_nonneg (fun _ => abs_nonneg _))) + +theorem localDualTests_disjoint {D : ℝ} (hD : 5 ≤ D) + (u v : PlanarPosition) (hsep : D ≤ ‖u - v‖) : + Disjoint (tsupport (localizedTest localDualBump u)) (tsupport (localizedTest localDualBump v)) := + localizedTest_disjoint localDualBump_support u v (by linarith) + +theorem localizedDualMatrix_lower {freq D : ℝ} (hfreq : 0 < freq) (hD : 3 ≤ D) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (s : Fin m → ℝ) : + (localDualMass freq - m * localLeakageBound freq D) * ∑ i, s i ^ 2 ≤ + ∑ i, ∑ j, localizedDualPair freq (u i) (u j) localDualBump * s i * s j := by + apply dualMatrix_quadratic_lower _ (localLeakageBound_nonnegative freq D) + · intro i + rw [localizedDualPair_diagonal] + exact le_rfl + · intro i j hij + exact localDualPair_offsite hfreq hD (u i) (u j) (hsep i j hij) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDuality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..294e99c599c3aab555dee98c59607fed15b190e5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedDuality.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLeakage + +namespace OAI + +/-! Actual compact local dual tests: a common positive diagonal mass, +disjoint supports and exponentially small off-site pairings. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +def localizedTest (χ : Position → ℝ) (u : PlanarPosition) (x : Position) : ℝ := + χ (x - planarCenter u) + +theorem localizedTest_smooth {χ : Position → ℝ} (hχ : ContDiff ℝ ∞ χ) (u : PlanarPosition) : + ContDiff ℝ ∞ (localizedTest χ u) := hχ.comp (contDiff_id.sub contDiff_const) + +theorem localizedTest_hasCompactSupport {χ : Position → ℝ} (hc : HasCompactSupport χ) + (u : PlanarPosition) : HasCompactSupport (localizedTest χ u) := + hc.comp_homeomorph (Homeomorph.subRight (planarCenter u)) + +theorem localizedTest_support {χ : Position → ℝ} {R : ℝ} + (hs : tsupport χ ⊆ Metric.closedBall 0 R) (u : PlanarPosition) : + tsupport (localizedTest χ u) ⊆ Metric.closedBall (planarCenter u) R := by + apply closure_minimal ?_ Metric.isClosed_closedBall + intro x hx + have hχx : χ (x - planarCenter u) ≠ 0 := hx + have h := hs (subset_tsupport χ hχx) + simpa only [Metric.mem_closedBall, dist_zero_right, dist_eq_norm, sub_zero] using h + +theorem localizedTest_disjoint {χ : Position → ℝ} {R : ℝ} + (hs : tsupport χ ⊆ Metric.closedBall 0 R) (u v : PlanarPosition) + (hsep : 2 * R < ‖u - v‖) : Disjoint (tsupport (localizedTest χ u)) (tsupport (localizedTest χ v)) := by + apply Set.disjoint_left.mpr + intro x hxu hxv + have hu := localizedTest_support hs u hxu + have hv := localizedTest_support hs v hxv + simp only [Metric.mem_closedBall, dist_eq_norm] at hu hv + have h : ‖planarCenter u - planarCenter v‖ ≤ ‖planarCenter u - x‖ + ‖x - planarCenter v‖ := by + simpa only [dist_eq_norm] using dist_triangle (planarCenter u) x (planarCenter v) + rw [norm_sub_rev (planarCenter u) x, planarCenter_norm_sub] at h + linarith + +def localizedDualPair (freq : ℝ) (u v : PlanarPosition) (χ : Position → ℝ) : ℝ := + ∫ x, localizedDensity freq u x * localizedTest χ v x + +theorem localizedDualPair_diagonal (freq : ℝ) (u : PlanarPosition) (χ : Position → ℝ) : + localizedDualPair freq u u χ = ∫ x, localizedDensity freq 0 x * χ x := by + unfold localizedDualPair localizedTest + rw [← integral_add_right_eq_self + (fun x => localizedDensity freq u x * χ (x - planarCenter u)) (planarCenter u)] + apply integral_congr_ae + filter_upwards [] with x + rw [localizedDensity_translate freq u, add_sub_cancel_right] + +theorem localizedDualPair_diagonal_positive {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) {χ : Position → ℝ} (hχ : Continuous χ) (hc : HasCompactSupport χ) + (hn : ∀ x, 0 ≤ χ x) (h0 : 0 < χ 0) : 0 < localizedDualPair freq u u χ := by + rw [localizedDualPair_diagonal] + exact integral_pos_of_integrable_nonneg_nonzero + ((localizedDensity_continuous freq 0).mul hχ) + (((localizedDensity_continuous freq 0).mul hχ).integrable_of_hasCompactSupport hc.mul_left) + (fun x => mul_nonneg (localizedDensity_nonnegative freq 0 x) (hn x)) + (mul_pos (localizedDensity_positive hfreq 0 0) h0).ne' + +theorem localizedDualPair_offsite {freq R : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) {χ : Position → ℝ} (hχ : Continuous χ) (hc : HasCompactSupport χ) + (hs : tsupport χ ⊆ Metric.closedBall 0 R) (hsep : R + 1 ≤ ‖u - v‖) : + |localizedDualPair freq u v χ| ≤ + (localizedTailConstant freq * Real.exp (R - ‖u - v‖)) * (∫ x, |χ x|) := by + have hpt (x : Position) : ‖localizedDensity freq u (x + planarCenter v) * χ x‖ ≤ + (localizedTailConstant freq * Real.exp (R - ‖u - v‖)) * |χ x| := by + by_cases hx : χ x = 0 + · simp only [hx, mul_zero, norm_zero, abs_zero, le_refl] + have hn : ‖x‖ ≤ R := by + simpa only [Metric.mem_closedBall, dist_zero_right] using hs (subset_tsupport χ hx) + have hb := localizedDensity_near_other_center hfreq u v (x + planarCenter v) + (by simpa only [add_sub_cancel_right] using hn) hsep + rw [norm_mul, Real.norm_of_nonneg (localizedDensity_nonnegative freq u _), Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right hb (abs_nonneg _) + unfold localizedDualPair localizedTest + rw [← integral_add_right_eq_self + (fun x => localizedDensity freq u x * χ (x - planarCenter v)) (planarCenter v)] + simp only [add_sub_cancel_right] + have h := norm_integral_le_of_norm_le + (f := fun x => localizedDensity freq u (x + planarCenter v) * χ x) + ((hχ.integrable_of_hasCompactSupport (μ := volume) hc).norm.const_mul + (localizedTailConstant freq * Real.exp (R - ‖u - v‖))) + (Filter.Eventually.of_forall hpt) + simpa only [integral_const_mul, Real.norm_eq_abs] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFockStates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFockStates.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b8b21730defe164781f2589c51963498b41cbd2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFockStates.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlaterSynthesis +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.OrthonormalLocalizedModes + +namespace OAI + +/-! Every state of the actual full half-filled Fock space is realized by +an antisymmetric weak-H1 continuum state in the corrected localized modes. +The continuum mass is exactly the finite occupation norm. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal + +private theorem euclidean_norm_change_fintype {ι : Type*} (F G : Fintype ι) + (c : EuclideanSpace ℂ ι) : + (letI := F; ‖c‖) = (letI := G; ‖c‖) := by + have h : F = G := Subsingleton.elim _ _ + subst G + rfl + +def localizedSpinMode (freq : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (j : Fin ((2*m+1)+1)) : Position → Fin 2 → ℂ := + realSpinOrbital (correctedLocalizedMode freq u ((siteModes m).symm j).1) ((siteModes m).symm j).2 + +theorem localizedSpinMode_C1 (freq : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (j : Fin ((2*m+1)+1)) (s : Fin 2) : ContDiff ℝ 1 (fun x => localizedSpinMode freq u j x s) := + realSpinOrbital_C1 _ (correctedLocalizedMode_C1 freq u _) _ s + +theorem localizedSpinMode_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (j : Fin ((2*m+1)+1)) (s : Fin 2) : + MemLp (fun x => localizedSpinMode freq u j x s) 2 := + realSpinOrbital_memLp _ (correctedLocalizedMode_memLp hfreq u _) _ s + +theorem localizedSpinMode_partial_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (j : Fin ((2*m+1)+1)) (s : Fin 2) (b : Fin 3) : + MemLp (fun x => fderiv ℝ (fun y => localizedSpinMode freq u j y s) x (EuclideanSpace.single b 1)) 2 := + realSpinOrbital_partial_memLp _ (correctedLocalizedMode_C1 freq u _) + (correctedLocalizedMode_partial_memLp hfreq u _) _ s b + +theorem localizedSpinMode_inner {freq D : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1 : ℕ) * localizedOverlapBound D ≤ 1/2) (i j : Fin ((2*m+1)+1)) : + (∑ s : Fin 2, ∫ x, star (localizedSpinMode freq u i x s) * localizedSpinMode freq u j x s) = + if i=j then (1 : ℂ) else 0 := by + exact selectedRealSpinOrbitals_orthonormal (correctedLocalizedMode freq u) (by + intro a b + by_cases hab : a=b + · simpa only [hab, ite_true] using correctedLocalizedMode_inner hfreq u hsep hs a b + · simpa only [hab, ite_false] using correctedLocalizedMode_inner hfreq u hsep hs a b) + (siteModes m).symm (siteModes m).symm.injective i j + +def localizedFockState {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (c : EuclideanSpace ℂ (HalfFilledBasis m)) : Coulomb.H1Vector (m+1) := + classicalSlaterSynthesis (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) c + +theorem localizedFockState_antisymmetric {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (c : EuclideanSpace ℂ (HalfFilledBasis m)) : + Coulomb.Antisymmetric (localizedFockState hfreq u c) := + classicalSlaterSynthesis_antisymmetric _ _ _ _ _ + +theorem localizedFockState_mass {freq D : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1 : ℕ) * localizedOverlapBound D ≤ 1/2) (c : EuclideanSpace ℂ (HalfFilledBasis m)) : + Coulomb.mass (localizedFockState hfreq u c) = ‖c‖^2 := by + have h := classicalSlaterSynthesis_mass (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) + (localizedSpinMode_inner hfreq u hsep hs) c + exact h.trans (congrArg (fun t : ℝ => t^2) + (euclidean_norm_change_fintype + (inferInstance : Fintype (SlaterOccupation.Occupied (2*m+1) (m+1))) + (inferInstance : Fintype (HalfFilledBasis m)) c)) + +def localizedFockFormState {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (c : EuclideanSpace ℂ (HalfFilledBasis m)) : FormState (m+1) := + ⟨localizedFockState hfreq u c, localizedFockState_antisymmetric hfreq u c⟩ + +theorem localizedFockFormState_normalized {freq D : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1 : ℕ) * localizedOverlapBound D ≤ 1/2) (c : EuclideanSpace ℂ (HalfFilledBasis m)) + (hc : ‖c‖=1) : normSq (localizedFockFormState hfreq u c) = 1 := by + change Coulomb.mass (localizedFockState hfreq u c) = 1 + rw [localizedFockState_mass hfreq u hsep hs, hc, one_pow] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFourIndex.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFourIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..03d9fd7444ce84d85c7972854985cc56284507d5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedFourIndex.lean @@ -0,0 +1,130 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTransition + +namespace OAI + +/-! Four-index Coulomb integrals of the actual localized orbitals. Each +unequal-index pair gives exponentially small Coulomb coefficients, uniformly +in the other pair. Diagonal pairs recover the actual direct interaction. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem localizedPotentialBound_nonnegative (freq : ℝ) : 0 ≤ localizedPotentialBound freq := by + unfold localizedPotentialBound NeutralAtom.kernelBallMass + exact add_nonneg (mul_nonneg (sq_nonneg _) (integral_nonneg (fun _ => + NeutralAtom.coulombKernel_nonneg _))) zero_le_one + +theorem localizedTransition_coulomb_integrable_bound {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) (x : Position) : + Integrable (fun y => NeutralAtom.coulombKernel (x - y) * localizedTransition freq u v y) ∧ + NeutralAtom.potentialOf (localizedTransition freq u v) x ≤ localizedPotentialBound freq := by + have h := NeutralAtom.bounded_density_convolution NeutralAtom.measurable_coulombKernel + NeutralAtom.coulombKernel_nonneg (NeutralAtom.coulombKernel_integrableOn_ball 1) + (fun _ => NeutralAtom.coulombKernel_le_one) (localizedTransition_integrable hfreq u v) + (localizedTransition_nonnegative hfreq u v) (localizedTransition_bound hfreq u v) x + refine ⟨h.1, h.2.trans ?_⟩ + exact add_le_add_right (localizedTransition_mass_le_one hfreq u v) _ + +theorem localizedTransition_potential_nonnegative {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) (x : Position) : + 0 ≤ NeutralAtom.potentialOf (localizedTransition freq u v) x := + integral_nonneg (fun _ => mul_nonneg (NeutralAtom.coulombKernel_nonneg _) + (localizedTransition_nonnegative hfreq u v _)) + +theorem localizedTransition_potential_continuous {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) : Continuous (NeutralAtom.potentialOf (localizedTransition freq u v)) := + NeutralAtom.potentialOf_continuous (localizedTransition_integrable hfreq u v) + (localizedTransition_nonnegative hfreq u v) (localizedTransition_bound hfreq u v) + +def localizedFourIndex (freq : ℝ) (u v w z : PlanarPosition) : ℝ := + ∫ x, localizedTransition freq u v x * NeutralAtom.potentialOf (localizedTransition freq w z) x + +theorem localizedFourIndex_integrable {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + Integrable (fun x => localizedTransition freq u v x * + NeutralAtom.potentialOf (localizedTransition freq w z) x) := by + apply (localizedTransition_integrable hfreq u v).mul_bdd (c := localizedPotentialBound freq) + (localizedTransition_potential_continuous hfreq w z).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun x => by + rw [Real.norm_of_nonneg (localizedTransition_potential_nonnegative hfreq w z x)] + exact (localizedTransition_coulomb_integrable_bound hfreq w z x).2) + +theorem localizedFourIndex_nonnegative {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + 0 ≤ localizedFourIndex freq u v w z := + integral_nonneg (fun _ => mul_nonneg (localizedTransition_nonnegative hfreq u v _) + (localizedTransition_potential_nonnegative hfreq w z _)) + +theorem localizedTransitionPacket_pair {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + CoulombPacket.pair (localizedTransitionPacket hfreq u v) (localizedTransitionPacket hfreq w z) = + localizedFourIndex freq u v w z := by + unfold CoulombPacket.pair localizedFourIndex NeutralAtom.potentialOf + rw [Measure.volume_eq_prod, integral_prod _ (CoulombPacket.joint_integrable _ _)] + apply integral_congr_ae + filter_upwards [] with x + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with y + change localizedTransition freq u v x * localizedTransition freq w z y * ‖x - y‖⁻¹ = + localizedTransition freq u v x * (‖x - y‖⁻¹ * localizedTransition freq w z y) + ring + +theorem localizedFourIndex_symmetric {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + localizedFourIndex freq u v w z = localizedFourIndex freq w z u v := by + rw [← localizedTransitionPacket_pair hfreq, CoulombPacket.pair_symmetric, + localizedTransitionPacket_pair hfreq] + +theorem localizedFourIndex_diagonal (freq : ℝ) (u v : PlanarPosition) : + localizedFourIndex freq u u v v = localizedCoulombCoeff freq u v := by + have he (w : PlanarPosition) : localizedTransition freq w w = localizedDensity freq w := by + funext x + exact (pow_two _).symm + simp only [localizedFourIndex, localizedCoulombCoeff, he] + +theorem localizedFourIndex_le_overlap {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + localizedFourIndex freq u v w z ≤ localizedPotentialBound freq * planarModeOverlap u v := by + have h := integral_mono (localizedFourIndex_integrable hfreq u v w z) + ((localizedTransition_integrable hfreq u v).mul_const (localizedPotentialBound freq)) + (fun x => mul_le_mul_of_nonneg_left (localizedTransition_coulomb_integrable_bound hfreq w z x).2 + (localizedTransition_nonnegative hfreq u v x)) + rw [integral_mul_const, localizedTransition_mass hfreq] at h + exact h.trans_eq (mul_comm _ _) + +def localizedFourIndexConstant (freq : ℝ) : ℝ := localizedPotentialBound freq * planarOverlapConstant + +theorem localizedFourIndexConstant_nonnegative (freq : ℝ) : 0 ≤ localizedFourIndexConstant freq := + mul_nonneg (localizedPotentialBound_nonnegative freq) planarOverlapConstant_nonnegative + +theorem localizedFourIndex_decay_left {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + |localizedFourIndex freq u v w z| ≤ + localizedFourIndexConstant freq * Real.exp (-(9 / 10 : ℝ) * ‖u - v‖) := by + rw [abs_of_nonneg (localizedFourIndex_nonnegative hfreq u v w z)] + calc + _ ≤ localizedPotentialBound freq * planarModeOverlap u v := localizedFourIndex_le_overlap hfreq u v w z + _ ≤ localizedPotentialBound freq * (planarOverlapConstant * Real.exp (-(9 / 10 : ℝ) * ‖u - v‖)) := + mul_le_mul_of_nonneg_left (planarModeOverlap_decay u v) (localizedPotentialBound_nonnegative freq) + _ = _ := (mul_assoc _ _ _).symm + +theorem localizedFourIndex_decay_right {freq : ℝ} (hfreq : 0 < freq) (u v w z : PlanarPosition) : + |localizedFourIndex freq u v w z| ≤ + localizedFourIndexConstant freq * Real.exp (-(9 / 10 : ℝ) * ‖w - z‖) := by + rw [localizedFourIndex_symmetric hfreq] + exact localizedFourIndex_decay_left hfreq w z u v + +theorem localizedFourIndex_offsite {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (i j k l : Fin m) (hoff : i ≠ j ∨ k ≠ l) : + |localizedFourIndex freq (u i) (u j) (u k) (u l)| ≤ + localizedFourIndexConstant freq * Real.exp (-(9 / 10 : ℝ) * D) := by + rcases hoff with hij | hkl + · exact (localizedFourIndex_decay_left hfreq _ _ _ _).trans + (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith [hsep i j hij])) + (localizedFourIndexConstant_nonnegative freq)) + · exact (localizedFourIndex_decay_right hfreq _ _ _ _).trans + (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith [hsep k l hkl])) + (localizedFourIndexConstant_nonnegative freq)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGradientMoments.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGradientMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..42aca7f95780e8a0876248314bb76e83ccac094f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGradientMoments.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGradientMoments +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombTranslation + +namespace OAI + +/-! The spatial gradient of the actual localized orbital has a finite +24th moment. This supplies the Sobolev cutoff tail for nuclear replacement. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem verticalMode_deriv_moment_integrable {freq : ℝ} (hfreq : 0 < freq) (k : ℕ) : + Integrable (fun z : ℝ => z^k*deriv (verticalMode freq) z^2) := by + convert (verticalMode_moment_integrable hfreq (k+2)).const_mul (freq^2) using 1 + funext z + rw [verticalMode_deriv,pow_add] + ring + +private theorem split_product_moment_integrable (k : ℕ) {f : PlanarPosition → ℝ} {g : ℝ → ℝ} + (hf : Continuous f) (hg : Continuous g) + (hf0 : Integrable (fun r => f r^2)) (hfk : Integrable (fun r => ‖r‖^(2*k)*f r^2)) + (hg0 : Integrable (fun z => g z^2)) (hgk : Integrable (fun z => z^(2*k)*g z^2)) : + Integrable (fun p : SplitPosition => (‖p.1‖^2+p.2^2)^k*(f p.1*g p.2)^2) := by + have hp := hfk.mul_prod hg0 + have hz := hf0.mul_prod hgk + apply ((hp.add hz).const_mul ((2:ℝ)^(k-1))).mono' + ((((continuous_fst.norm.pow 2).add (continuous_snd.pow 2)).pow k).mul + (((hf.comp continuous_fst).mul (hg.comp continuous_snd)).pow 2)).aestronglyMeasurable + filter_upwards [] with p + change ‖(‖p.1‖^2+p.2^2)^k*(f p.1*g p.2)^2‖ ≤ _ + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (by positivity) _) (sq_nonneg _))] + have h : (‖p.1‖^2+p.2^2)^k ≤ (2:ℝ)^(k-1)*(‖p.1‖^(2*k)+p.2^(2*k)) := by + simpa only [← pow_mul] using add_pow_le (sq_nonneg ‖p.1‖) (sq_nonneg p.2) k + convert mul_le_mul_of_nonneg_right h (sq_nonneg (f p.1*g p.2)) using 1 + simp only [mul_pow,Pi.add_apply] + ring + +theorem continuumLocalizedMode_deriv_even_moment_integrable {freq : ℝ} (hfreq : 0 < freq) + (k : ℕ) (e : Position) : + Integrable (fun x : Position => ‖x‖^(2*k)*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2) := by + let v := positionSplitCoordinates e + have hp := split_product_moment_integrable k + (planarPartial_continuous (normalizedPlanarMode_C7.of_le (by norm_num)) v.1) + (verticalMode_smooth freq).continuous + (normalizedPlanarMode_partial_square_integrable v.1) + (normalizedPlanarMode_partial_moment_integrable v.1 (2*k)) + (verticalMode_square_integrable hfreq) (verticalMode_moment_integrable hfreq (2*k)) + have hz := split_product_moment_integrable k normalizedPlanarMode_C7.continuous + (((verticalMode_smooth freq).continuous_deriv (by simp)).mul_const v.2) + normalizedPlanarMode_square_integrable (normalizedPlanarMode_norm_moment_integrable (2*k)) + (by simpa only [mul_pow] using (verticalMode_deriv_square_integrable hfreq).mul_const (v.2^2)) + (by simpa only [mul_pow,mul_assoc] using + (verticalMode_deriv_moment_integrable hfreq (2*k)).mul_const (v.2^2)) + have hi : Integrable (fun p : SplitPosition => (‖p.1‖^2+p.2^2)^k* + (fderiv ℝ (localizedMode freq 0) p v)^2) := by + apply ((hp.add hz).const_mul 2).mono' (by + exact ((((continuous_fst.norm.pow 2).add (continuous_snd.pow 2)).pow k).mul + ((((localizedMode_C7 freq 0).continuous_fderiv (by norm_num)).clm_apply continuous_const).pow 2)).aestronglyMeasurable) + filter_upwards [] with p + change ‖(‖p.1‖^2+p.2^2)^k*(fderiv ℝ (localizedMode freq 0) p v)^2‖ ≤ _ + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (by positivity) _) (sq_nonneg _))] + have h := sq_nonneg (planarPartial normalizedPlanarMode v.1 p.1*verticalMode freq p.2- + normalizedPlanarMode p.1*(deriv (verticalMode freq) p.2*v.2)) + have hh : (fderiv ℝ (localizedMode freq 0) p v)^2 ≤ + 2*((planarPartial normalizedPlanarMode v.1 p.1*verticalMode freq p.2)^2+ + (normalizedPlanarMode p.1*(deriv (verticalMode freq) p.2*v.2))^2) := by + rw [localizedMode_fderiv,sub_zero] + nlinarith only [h] + convert mul_le_mul_of_nonneg_left hh (show 0 ≤ (‖p.1‖^2+p.2^2)^k by positivity) using 1 + simp only [Pi.add_apply] + ring + have ht := positionSplitCoordinates_measurePreserving.integrable_comp_of_integrable hi + convert ht using 1 + funext x + simp only [Function.comp_apply,continuumLocalizedMode_fderiv] + rw [pow_mul,positionSplitCoordinates_norm_sq] + +theorem continuumLocalizedMode_deriv_twentyFourth_moment_integrable {freq : ℝ} + (hfreq : 0 < freq) (e : Position) : + Integrable (fun x : Position => ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2) := + continuumLocalizedMode_deriv_even_moment_integrable hfreq 12 e + +theorem continuumLocalizedMode_deriv_translate (freq : ℝ) (u : PlanarPosition) (x e : Position) : + fderiv ℝ (continuumLocalizedMode freq u) x e = + fderiv ℝ (continuumLocalizedMode freq 0) (x-planarCenter u) e := by + rw [show continuumLocalizedMode freq u = + (fun y => continuumLocalizedMode freq 0 (y-planarCenter u)) from + funext (continuumLocalizedMode_translate freq u)] + rw [fderiv_comp_sub] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4c2b9b24ed1447798bb46d58a00a6c0f9f44d9f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGram.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDualMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPacketCoercivity + +namespace OAI + +/-! Coercivity of the actual full Coulomb Gram matrix of the localized +resolvent--Gaussian modes. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +def localizedPacket {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : CoulombPacket where + value := localizedDensity freq u + continuous := localizedDensity_continuous freq u + integrable := localizedDensity_integrable hfreq u + bound := localizedAmplitudeBound freq ^ 2 + bound_nonnegative := sq_nonneg _ + bound_spec x := by + rw [Real.norm_of_nonneg (localizedDensity_nonnegative freq u x)] + exact localizedDensity_bound hfreq u x + +theorem localizedPacket_pair {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + CoulombPacket.pair (localizedPacket hfreq u) (localizedPacket hfreq v) = + localizedCoulombCoeff freq u v := by + unfold CoulombPacket.pair localizedCoulombCoeff NeutralAtom.potentialOf + rw [Measure.volume_eq_prod, integral_prod _ (CoulombPacket.joint_integrable _ _)] + apply integral_congr_ae + filter_upwards [] with x + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with y + change localizedDensity freq u x * localizedDensity freq v y * ‖x - y‖⁻¹ = + localizedDensity freq u x * (‖x - y‖⁻¹ * localizedDensity freq v y) + ring + +theorem testCharge_localizedTest (χ : Position → ℝ) (u : PlanarPosition) (x : Position) : + Coulomb.testCharge (localizedTest χ u) x = Coulomb.testCharge χ (x - planarCenter u) := by + unfold Coulomb.testCharge localizedTest + simp only [sub_eq_add_neg, NeutralAtom.coordinateLaplacian_translate] + +theorem localizedTest_energy (χ : Position → ℝ) (u : PlanarPosition) : + (∫ x, Coulomb.testCharge (localizedTest χ u) x * localizedTest χ u x) = + ∫ x, Coulomb.testCharge χ x * χ x := by + simp_rw [testCharge_localizedTest] + exact integral_sub_right_eq_self (fun x => Coulomb.testCharge χ x * χ x) (planarCenter u) + +def localDualEnergyBound : ℝ := |∫ x : Position, Coulomb.testCharge localDualBump x * localDualBump x| + 1 + +theorem localDualEnergyBound_positive : 0 < localDualEnergyBound := by + unfold localDualEnergyBound + positivity + +theorem localizedGram_coercive {freq D : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hmargin : 0 ≤ localDualMass freq - m * localLeakageBound freq D) (d : Fin m → ℝ) : + ((localDualMass freq - m * localLeakageBound freq D) ^ 2 / localDualEnergyBound) * + ∑ i, d i ^ 2 ≤ ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j := by + have h := CoulombPacket.gram_coercive_of_dual_lower (fun i => localizedPacket hfreq (u i)) + (fun i => localizedTest localDualBump (u i)) + (fun i => localizedTest_smooth localDualBump_smooth (u i)) + (fun i => localizedTest_hasCompactSupport localDualBump.hasCompactSupport (u i)) + (fun i j hij => localDualTests_disjoint hD (u i) (u j) (hsep i j hij)) + localDualEnergyBound_positive hmargin ?_ ?_ d + · simpa only [localizedPacket_pair] using h + · intro i + rw [localizedTest_energy] + exact (le_abs_self _).trans (by unfold localDualEnergyBound; linarith) + · intro e + have he := localizedDualMatrix_lower hfreq (by linarith : (3 : ℝ) ≤ D) u hsep e + convert he using 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + change e i * e j * localizedDualPair freq (u i) (u j) localDualBump = _ + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramConstants.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramConstants.lean new file mode 100644 index 0000000000000000000000000000000000000000..495ac13391d1e8e2132f73f98c947329c826b1f3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramConstants.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGram + +namespace OAI + +/-! A fixed positive coercivity constant once the total off-site leakage is +at most half the common diagonal dual mass. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedGramConstant (freq : ℝ) : ℝ := + localDualMass freq ^ 2 / (4 * localDualEnergyBound) + +theorem localizedGramConstant_positive {freq : ℝ} (hfreq : 0 < freq) : + 0 < localizedGramConstant freq := + div_pos (sq_pos_of_pos (localDualMass_positive hfreq)) + (mul_pos (by norm_num) localDualEnergyBound_positive) + +theorem localizedGram_uniform_coercive {freq D : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hleak : m * localLeakageBound freq D ≤ localDualMass freq / 2) (d : Fin m → ℝ) : + localizedGramConstant freq * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j := by + have ha := localDualMass_positive hfreq + have hb : localDualMass freq / 2 ≤ localDualMass freq - m * localLeakageBound freq D := by linarith + have hmargin : 0 ≤ localDualMass freq - m * localLeakageBound freq D := by linarith + have hs := (sq_le_sq₀ (by positivity : 0 ≤ localDualMass freq / 2) hmargin).mpr hb + have hc : localizedGramConstant freq ≤ + (localDualMass freq - m * localLeakageBound freq D) ^ 2 / localDualEnergyBound := by + calc + _ = (localDualMass freq / 2) ^ 2 / localDualEnergyBound := by + unfold localizedGramConstant + ring + _ ≤ _ := div_le_div_of_nonneg_right hs localDualEnergyBound_positive.le + exact (mul_le_mul_of_nonneg_right hc (Finset.sum_nonneg (fun i _ => sq_nonneg (d i)))).trans + (localizedGram_coercive hfreq hD u hsep hmargin d) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramSpacing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramSpacing.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8037b0b8d5e28de9b358bd8197b162d43ee5ce7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGramSpacing.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGramConstants + +namespace OAI + +/-! A fixed logarithmic spacing controls the total leakage for every +polynomial number of sites. The exponent is chosen once for the reduction. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def localLeakageConstant (freq : ℝ) : ℝ := + localizedTailConstant freq * Real.exp 2 * (∫ x : Position, |localDualBump x|) + +theorem localLeakageConstant_nonnegative (freq : ℝ) : 0 ≤ localLeakageConstant freq := + mul_nonneg (mul_nonneg (localizedTailConstant_nonnegative freq) (Real.exp_pos _).le) + (integral_nonneg (fun _ => abs_nonneg _)) + +theorem localLeakageBound_log (freq : ℝ) (k : ℕ) {N : ℝ} (hN : 0 < N) : + localLeakageBound freq ((k : ℝ) * Real.log N) = localLeakageConstant freq / N ^ k := by + unfold localLeakageBound localLeakageConstant + rw [Real.exp_sub, Real.exp_nat_mul, Real.exp_log hN] + ring + +theorem exists_localizedGram_spacing {freq : ℝ} (hfreq : 0 < freq) (A : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 5 ≤ (k : ℝ) * Real.log N ∧ + N ^ A * localLeakageBound freq ((k : ℝ) * Real.log N) ≤ localDualMass freq / 2 := by + let C := localLeakageConstant freq + let a := localDualMass freq + have ha : 0 < a := localDualMass_positive hfreq + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨q, hq⟩ := exists_nat_ge (max (5 / Real.log 2) (2 * C / a)) + have hqD : 5 / Real.log 2 ≤ (q : ℝ) := (le_max_left _ _).trans hq + have hqC : 2 * C / a ≤ (q : ℝ) := (le_max_right _ _).trans hq + have hqpos : (0 : ℝ) < q := (div_pos (by norm_num) hlog).trans_le hqD + have hqNat : 0 < q := by exact_mod_cast hqpos + have hpow : (q : ℝ) ≤ (2 : ℝ) ^ q := by exact_mod_cast (Nat.lt_two_pow_self (n := q)).le + refine ⟨A + q, by omega, fun N hN => ?_⟩ + have hNp : 0 < N := by linarith + have hlogN : Real.log 2 ≤ Real.log N := Real.log_le_log (by norm_num) hN + have hD := (div_le_iff₀ hlog).mp hqD + have hqN : (2 : ℝ) ^ q ≤ N ^ q := pow_le_pow_left₀ (by norm_num) hN q + have hC : 2 * C ≤ a * N ^ q := by + have h := (div_le_iff₀ ha).mp (hqC.trans (hpow.trans hqN)) + nlinarith only [h] + constructor + · have h := mul_le_mul_of_nonneg_left hlogN (Nat.cast_nonneg q) + have hadd := mul_nonneg (Nat.cast_nonneg A) (Real.log_nonneg (by linarith : 1 ≤ N)) + push_cast + nlinarith only [hD, h, hadd] + · rw [localLeakageBound_log freq (A + q) hNp, pow_add] + have hcancel : N ^ A * (C / (N ^ A * N ^ q)) = C / N ^ q := by + field_simp [pow_ne_zero A hNp.ne', pow_ne_zero q hNp.ne'] + change N ^ A * (C / (N ^ A * N ^ q)) ≤ a / 2 + rw [hcancel] + apply (div_le_iff₀ (pow_pos hNp q)).mpr + nlinarith only [hC] + +theorem exists_uniform_localizedGram_coercivity {freq : ℝ} (hfreq : 0 < freq) (A : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ (N : ℝ), 2 ≤ N → ∀ (m : ℕ), (m : ℝ) ≤ N ^ A → + ∀ (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → (k : ℝ) * Real.log N ≤ ‖u i - u j‖) → ∀ d : Fin m → ℝ, + localizedGramConstant freq * ∑ i, d i ^ 2 ≤ + ∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j := by + obtain ⟨k, hk, hspacing⟩ := exists_localizedGram_spacing hfreq A + refine ⟨k, hk, fun N hN m hm u hsep d => ?_⟩ + obtain ⟨hD, hleak⟩ := hspacing N hN + exact localizedGram_uniform_coercive hfreq hD u hsep + ((mul_le_mul_of_nonneg_right hm (localLeakageBound_nonnegative _ _)).trans hleak) d + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGroundUpper.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGroundUpper.lean new file mode 100644 index 0000000000000000000000000000000000000000..388c2db0a34df193133c16751b33c9afd80d8689 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedGroundUpper.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardForm +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.HubbardVariationalWitness +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorTrial +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.PhysicalGroundComparison + +namespace OAI + +/-! The finite Hubbard variational bottom supplies admissible trials for +the full continuum problem, including the exact physical energy offset. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal Laughlin.Fock + +section LocalizedUpper +variable (hdensity : PublishedSobolevSmoothDensity) +variable {Edge : Type*} [Fintype Edge] +variable {n m : ℕ} {rho H S freq scale δ D εK : ℝ} +variable (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hf : 0 < freq) +variable (hrelation : freq^2=4*Real.pi*rho) (hscale : 0 < scale) +variable (u : Fin (m+1) → PlanarPosition) +variable (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) +variable (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) +variable (hδ : 0 ≤ δ) +variable (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) +variable (F : Position → ℝ) +variable (hN : ∀ a b, Integrable (fun z => (F (WithLp.toLp 2 z.2):ℂ)* + (star (Coulomb.flatSpinOrbital (localizedSpinMode freq u a) z)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u b) z)) Coulomb.spinSpaceMeasure) +variable (left right : Edge → Fin (m+1)) (t : Edge → ℝ) +variable (hK : ∀ a b, ‖(scale:ℂ)* + (flatResidualMatrix (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) a b+ + flatNuclearMatrix (localizedSpinMode freq u) F a b)- + hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t a b‖ ≤ εK) +variable (hI : ∀ w : Coulomb.H1Vector (n+2), nuclearFormIntegrable F w) +variable (hNelec : n+2=m+1) + +include hdensity hrho hH hS hf hrelation hscale hsep hs hδ hcoeff hN hK hI hNelec + +theorem localized_hubbard_near_trial (ε : ℝ) (hε : 0 < ε) : + ∃ w : Coulomb.H1Vector (n+2), Coulomb.Antisymmetric w ∧ 0 < Coulomb.mass w ∧ + nuclearPerturbedForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) F w+scale⁻¹*Coulomb.pairEnergy w ≤ + ((n+2:ℝ)*((-1/2:ℝ)+freq/2)+ + (hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)+ + localizedHubbardFormError m freq D εK)/scale+ε)*Coulomb.mass w := by + have ht : ∃ c : Laughlin.State (n+2) (2*m+1), Laughlin.Antisymmetric c ∧ + 0 < fockMass (normalizedTensorExterior (n+2) (2*m+1) c) ∧ + hubbardFermionForm m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t (normalizedTensorExterior (n+2) (2*m+1) c) < + (hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t+scale*ε)*fockMass (normalizedTensorExterior (n+2) (2*m+1) c) := by + rw [hNelec] + exact hubbardFermionBottom_tensor_approximate m + (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t + (mul_pos hscale hε) + obtain ⟨c,hc,hm,ht⟩ := ht + let w := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + have hm' := finiteTensorState_mass_eq_fockMass (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) (localizedSpinMode_inner hf u hsep hs) c hc + refine ⟨w,finiteTensorState_antisymmetric _ _ _ _ c hc,?_,?_⟩ + · change Coulomb.mass w = _ at hm' + rwa [hm'] + · have hu := localizedTensor_hubbard_upper hdensity hrho hH hS hf hrelation hscale u hsep hs + hδ hcoeff F hN left right t hK c hc (hI w) hNelec + (hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t+scale*ε) ht.le + apply (mul_le_mul_iff_right₀ hscale).mp + dsimp only at hu + dsimp only [w] + convert hu using 1 + field_simp [ne_of_gt hscale] + ring + +theorem localized_hubbard_physical_upper {M : ℕ} (nuc : Coulomb.Nuclei M) + (offset : ℝ) + (hsplit : ∀ y, manufacturedSlabPotential rho H S freq scale u y+F y = + -scale⁻¹*Coulomb.attraction nuc y-offset) : + formGroundEnergy (dilatedNuclei nuc scale hscale.ne') (n+2) ≤ + ((scale^2*(n+2:ℝ)*(((-1/2:ℝ)+freq/2)+offset)+ + scale*(hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)+ + localizedHubbardFormError m freq D εK):ℝ):EReal) := by + have hu := formGroundEnergy_dilated_upper nuc (manufacturedSlabPotential rho H S freq scale u) + F hscale offset hsplit hI + ((n+2:ℝ)*((-1/2:ℝ)+freq/2)+ + (hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)+ + localizedHubbardFormError m freq D εK)/scale) + (localized_hubbard_near_trial hdensity hrho hH hS hf hrelation hscale u hsep hs + hδ hcoeff F hN left right t hK hI hNelec) + convert hu using 2 + simp only [Nat.cast_add,Nat.cast_ofNat] + field_simp [ne_of_gt hscale] + ring + +end LocalizedUpper +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHigherMoments.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHigherMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..f95800ebc4015439289b993e92d6562d87e1d534 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHigherMoments.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDensityMoment + +namespace OAI + +/-! The spatial moments needed to control the finite-slab +operator residual. All moments refer to the actual normalized orbital density. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem polynomial_exponential_bound (k : ℕ) {t : ℝ} (ht : 0 ≤ t) : + t^k*Real.exp (-t/2) ≤ (2:ℝ)^k*(k.factorial:ℝ) := by + have hf : 0 < (k.factorial : ℝ) := Nat.cast_pos.mpr (Nat.factorial_pos k) + have he := Real.pow_div_factorial_le_exp (t/2) (by positivity : 0 ≤ t/2) k + have hid : ((t/2)^k/(k.factorial:ℝ))*((2:ℝ)^k*(k.factorial:ℝ)) = t^k := by + rw [div_pow] + field_simp + have h := mul_le_mul_of_nonneg_right he + (show 0 ≤ (2:ℝ)^k*(k.factorial:ℝ) by positivity) + rw [hid] at h + have h' := mul_le_mul_of_nonneg_right h (Real.exp_pos (-t/2)).le + have hc : (Real.exp (t/2)*((2:ℝ)^k*(k.factorial:ℝ)))*Real.exp (-t/2) = + (2:ℝ)^k*(k.factorial:ℝ) := by + rw [mul_right_comm,← Real.exp_add] + rw [show t/2 + -t/2 = 0 by ring, Real.exp_zero, one_mul] + exact h'.trans_eq hc + +theorem normalizedPlanarMode_norm_moment_integrable (k : ℕ) : + Integrable (fun r : PlanarPosition => ‖r‖^k*normalizedPlanarMode r^2) := by + let C := planarExponentialConstant (1/2)^2*((2:ℝ)^k*(k.factorial:ℝ)) + have hmajor := (planar_exp_norm_integrable (by norm_num : (0:ℝ)<1/2)).const_mul C + have hraw : Integrable (fun r : PlanarPosition => ‖r‖^k*planarResolventMode r^2) := by + apply hmajor.mono' + ((continuous_norm.pow k).mul (planarResolventMode_C7.continuous.pow 2)).aestronglyMeasurable + filter_upwards [] with r + change ‖‖r‖^k*planarResolventMode r^2‖ ≤ C*Real.exp (-(1/2:ℝ)*‖r‖) + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (norm_nonneg _) _) (sq_nonneg _))] + have hm := pow_le_pow_left₀ (planarResolventMode_positive r).le + (planarResolventMode_exponential_envelope (by norm_num : (0:ℝ)≤1/2) + (by norm_num : (1/2:ℝ)<1) r) 2 + rw [mul_pow] at hm + have hex : Real.exp (-(1/2:ℝ)*‖r‖)^2 = + Real.exp (-‖r‖/2)*Real.exp (-(1/2:ℝ)*‖r‖) := by + rw [pow_two] + congr 1 + congr 1 + ring + rw [hex] at hm + calc + _ ≤ ‖r‖^k*(planarExponentialConstant (1/2)^2* + (Real.exp (-‖r‖/2)*Real.exp (-(1/2:ℝ)*‖r‖))) := + mul_le_mul_of_nonneg_left hm (pow_nonneg (norm_nonneg _) _) + _ = (planarExponentialConstant (1/2)^2*(‖r‖^k*Real.exp (-‖r‖/2)))* + Real.exp (-(1/2:ℝ)*‖r‖) := by ring + _ ≤ C*Real.exp (-(1/2:ℝ)*‖r‖) := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (polynomial_exponential_bound k (norm_nonneg r)) + (sq_nonneg _)) (Real.exp_pos _).le + simp_rw [normalizedPlanarMode,div_pow,← mul_div_assoc] + exact hraw.div_const _ + +private theorem localizedDensity_even_moment_integrable {freq : ℝ} (hfreq : 0 < freq) + (k : ℕ) : Integrable (fun x : Position => ‖x‖^(2*k)*localizedDensity freq 0 x) := by + have hp := (normalizedPlanarMode_norm_moment_integrable (2*k)).mul_prod (verticalMode_square_integrable hfreq) + have hz := normalizedPlanarMode_square_integrable.mul_prod (verticalMode_moment_integrable hfreq (2*k)) + have hi : Integrable (fun p : SplitPosition => (‖p.1‖^2+p.2^2)^k*localizedMode freq 0 p^2) := by + apply ((hp.add hz).const_mul ((2:ℝ)^(k-1))).mono' + ((((continuous_fst.norm.pow 2).add (continuous_snd.pow 2)).pow k).mul + ((localizedMode_C7 freq 0).continuous.pow 2)).aestronglyMeasurable + filter_upwards [] with p + change ‖(‖p.1‖^2+p.2^2)^k*localizedMode freq 0 p^2‖ ≤ _ + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (by positivity) _) (sq_nonneg _))] + have h : (‖p.1‖^2+p.2^2)^k ≤ (2:ℝ)^(k-1)*(‖p.1‖^(2*k)+p.2^(2*k)) := by + simpa only [← pow_mul] using add_pow_le (sq_nonneg ‖p.1‖) (sq_nonneg p.2) k + have hm := mul_le_mul_of_nonneg_right h (sq_nonneg (localizedMode freq 0 p)) + convert hm using 1 + simp only [localizedMode,sub_zero,mul_pow,Pi.add_apply] + ring + have ht := positionSplitCoordinates_measurePreserving.integrable_comp_of_integrable hi + convert ht using 1 + funext x + simp only [Function.comp_apply,localizedDensity,continuumLocalizedMode] + rw [pow_mul, positionSplitCoordinates_norm_sq] + +theorem localizedDensity_fourth_moment_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun x : Position => ‖x‖^4*localizedDensity freq 0 x) := + localizedDensity_even_moment_integrable hfreq 2 + +theorem localizedDensity_eighth_moment_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun x : Position => ‖x‖^8*localizedDensity freq 0 x) := + localizedDensity_even_moment_integrable hfreq 4 + +/-- This moment absorbs the polynomial growth of the finite slab's global +potential bound when the horizontal radius is the fourth power of its thickness. -/ +theorem localizedDensity_twentyFourth_moment_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun x : Position => ‖x‖^24*localizedDensity freq 0 x) := + localizedDensity_even_moment_integrable hfreq 12 + +/-- A wider horizontal slab is needed for simultaneous nuclear cubature and +compressed-energy accuracy. This moment absorbs its polynomial growth. -/ +theorem localizedDensity_seventySecond_moment_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun x : Position => ‖x‖^72*localizedDensity freq 0 x) := + localizedDensity_even_moment_integrable hfreq 36 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbard.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbard.lean new file mode 100644 index 0000000000000000000000000000000000000000..b58fd809842fa152b34483e72faf67a79ebfe743 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbard.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.GramPenalty + +namespace OAI + +/-! The actual localized direct Coulomb matrix satisfies the full charge +penalty condition used by the complete half-filled Hubbard comparison. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedOffsiteCoulomb {m : ℕ} (freq : ℝ) (u : Fin m → PlanarPosition) + (i j : Fin m) : ℝ := if i = j then 0 else localizedCoulombCoeff freq (u i) (u j) + +theorem localizedOffsiteCoulomb_diagonal {m : ℕ} (freq : ℝ) (u : Fin m → PlanarPosition) (i : Fin m) : + localizedOffsiteCoulomb freq u i i = 0 := by simp [localizedOffsiteCoulomb] + +theorem localizedOffsiteCoulomb_symmetric {m : ℕ} {freq : ℝ} (hfreq : 0 < freq) + (u : Fin m → PlanarPosition) (i j : Fin m) : + localizedOffsiteCoulomb freq u i j = localizedOffsiteCoulomb freq u j i := by + simp only [localizedOffsiteCoulomb, eq_comm] + rw [localizedCoulombCoeff_symmetric hfreq] + +theorem localizedCoulomb_diagonal_split {m : ℕ} (freq : ℝ) (u : Fin m → PlanarPosition) + (d : Fin m → ℝ) : + (∑ i, ∑ j, localizedCoulombCoeff freq (u i) (u j) * d i * d j) = + localizedCoulombProfile freq 0 * ∑ i, d i ^ 2 + + ∑ i, ∑ j, localizedOffsiteCoulomb freq u i j * d i * d j := by + classical + rw [Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + calc + _ = ∑ j, ((if i = j then localizedCoulombProfile freq 0 * d i ^ 2 else 0) + + localizedOffsiteCoulomb freq u i j * d i * d j) := by + apply Finset.sum_congr rfl + intro j _ + by_cases hij : i = j + · subst j + simp only [ite_true, localizedOffsiteCoulomb_diagonal, zero_mul, add_zero, + localizedCoulombCoeff_distance, sub_self, norm_zero, pow_two] + ring + · simp only [ite_eq_right hij, localizedOffsiteCoulomb, zero_add] + _ = _ := by simp only [Finset.sum_add_distrib, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + +theorem localizedCoulomb_charge_condition {freq D : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hleak : m * localLeakageBound freq D ≤ localDualMass freq / 2) (d : Fin m → ℝ) : + localizedGramConstant freq * ∑ i, d i ^ 2 ≤ + localizedCoulombProfile freq 0 * ∑ i, d i ^ 2 + + ∑ i, ∑ j, localizedOffsiteCoulomb freq u i j * d i * d j := by + rw [← localizedCoulomb_diagonal_split] + exact localizedGram_uniform_coercive hfreq hD u hsep hleak d + +namespace HubbardGlobal + +theorem localized_hubbard_Heisenberg {Edge : Type*} [Fintype Edge] + {freq D : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) (m : ℕ) + (u : Fin (m + 1) → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hleak : (m + 1 : ℕ) * localLeakageBound freq D ≤ localDualMass freq / 2) + (left right : Edge → Fin (m + 1)) (t J : Edge → ℝ) + (hloop : ∀ e, left e ≠ right e) + (hsimple : ∀ e f, e ≠ f → + ¬(left e = left f ∧ right e = right f) ∧ ¬(left e = right f ∧ right e = left f)) + (hcal : ∀ e, t e ^ 2 = J e * + (localizedCoulombProfile freq 0 - localizedCoulombCoeff freq (u (left e)) (u (right e)))) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon < 1 / 2) + (ht : 4 * ∑ e, |t e| ≤ epsilon * localizedGramConstant freq) : + |hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t - graphSourceBottom m left right J| ≤ + 2 * localizedGramConstant freq * epsilon ^ 3 := by + apply hubbardFermionBottom_Gram_Heisenberg m (localizedCoulombProfile freq 0) + (localizedGramConstant freq) (localizedOffsiteCoulomb freq u) + (localizedOffsiteCoulomb_symmetric hfreq u) (localizedOffsiteCoulomb_diagonal freq u) + (localizedGramConstant_positive hfreq) (localizedCoulomb_charge_condition hfreq hD u hsep hleak) + left right t J hloop hsimple ?_ hepsilon hsmall ht + intro e + simpa only [localizedOffsiteCoulomb, ite_eq_right (hloop e)] using hcal e + +theorem localized_calibrated_hubbard {Edge : Type*} [Fintype Edge] + {freq D scale τ : ℝ} (hfreq : 0 < freq) (hD : 5 ≤ D) (m : ℕ) + (u : Fin (m + 1) → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hleak : (m + 1 : ℕ) * localLeakageBound freq D ≤ localDualMass freq / 2) + (left right : Edge → Fin (m + 1)) (K : Edge → ℝ) (hK : ∀ e, 0 ≤ K e) + (hloop : ∀ e, left e ≠ right e) + (hsimple : ∀ e f, e ≠ f → + ¬(left e = left f ∧ right e = right f) ∧ ¬(left e = right f ∧ right e = left f)) + (hcal : ∀ e, scale * planarHopping ‖u (left e) - u (right e)‖ = + coulombHoppingTarget freq τ (K e) ‖u (left e) - u (right e)‖) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon < 1 / 2) + (ht : 4 * ∑ e, |scale * planarHopping ‖u (left e) - u (right e)‖| ≤ + epsilon * localizedGramConstant freq) : + |hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right (fun e => scale * planarHopping ‖u (left e) - u (right e)‖) - + graphSourceBottom m left right (fun e => τ ^ 2 * K e)| ≤ + 2 * localizedGramConstant freq * epsilon ^ 3 := by + apply localized_hubbard_Heisenberg hfreq hD m u hsep hleak left right _ _ hloop hsimple ?_ + hepsilon hsmall ht + intro e + have hgap := chargeTransfer_Gram_denominator (localizedCoulombProfile freq 0) + (localizedGramConstant freq) (localizedOffsiteCoulomb freq u) + (localizedCoulomb_charge_condition hfreq hD u hsep hleak) (left e) (right e) (hloop e) + (localizedOffsiteCoulomb_symmetric hfreq u) (localizedOffsiteCoulomb_diagonal freq u) + simp only [localizedOffsiteCoulomb, ite_eq_right (hloop e)] at hgap + have hn := (localizedGramConstant_positive hfreq).le.trans hgap + rw [localizedCoulombCoeff_distance] at hn ⊢ + rw [hcal e, coulombHoppingTarget, mul_pow, Real.sq_sqrt (mul_nonneg (hK e) hn)] + ring + +end HubbardGlobal +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardEntries.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardEntries.lean new file mode 100644 index 0000000000000000000000000000000000000000..73c8d3afae2546cafa184600d82b72798f54b6f0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardEntries.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOneBodyMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardTensor +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockGraphEntries + +namespace OAI + +/-! From the actual spatial one-body error to the full spinful Hubbard +coefficient error. The off-site counterterm is kept exactly. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal + +section Entries +variable {Edge : Type*} [Fintype Edge] +variable {m : ℕ} {rho H S freq scale δ ε η : ℝ} +variable (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hf : 0 < freq) +variable (u : Fin (m+1) → PlanarPosition) (hδ : 0 ≤ δ) +variable (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) +variable (F : Position → ℝ) +variable (hI : ∀ i j, Integrable (fun x => F x*correctedLocalizedMode freq u i x* + correctedLocalizedMode freq u j x)) +variable (left right : Edge → Fin (m+1)) (t : Edge → ℝ) +variable (hε : 0 ≤ ε) (hη : 0 ≤ η) +variable (hmatrix : ∀ i j, |scale*correctedNuclearOneBodyMatrix rho H S freq scale u F i j- + localizedOneBodyTarget scale freq u i j| ≤ ε) +variable (hgraph : ∀ i j, ‖(scale*planarHoppingMatrix u i j:ℂ)- + graphHoppingMatrix m left right (fun e => (t e:ℂ)) i j‖ ≤ η) +include hrho hH hS hf hδ hcoeff hI hε hη hmatrix hgraph + +theorem localizedSpin_hubbard_oneBody_error (a b : Fin ((2*m+1)+1)) : + ‖(scale:ℂ)*(flatResidualMatrix (localizedSpinMode freq u) + (localizedSpinResidual rho H S freq scale u) a b+ + flatNuclearMatrix (localizedSpinMode freq u) F a b)- + hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t a b‖ ≤ ε+η := by + rw [localizedSpin_oneBody_matrix hrho hH hS hf scale u hδ hcoeff F hI] + let p := (siteModes m).symm + change ‖(scale:ℂ)*(if (p a).2=(p b).2 then _ else 0)- + (if (p a).2=(p b).2 then _ else 0)‖ ≤ _ + by_cases hs : (p a).2=(p b).2 + · simp only [hs,ite_true] + have he := hmatrix (p a).1 (p b).1 + have hg := hgraph (p a).1 (p b).1 + have hc : localizedOffsiteSum freq u (p a).1 = + ∑ j, localizedOffsiteCoulomb freq u (p a).1 j := by + rfl + have ht : ((localizedOneBodyTarget scale freq u (p a).1 (p b).1:ℝ):ℂ)- + (graphHoppingMatrix m left right (fun e => (t e:ℂ)) (p a).1 (p b).1- + if (p a).1=(p b).1 then ((∑ j, localizedOffsiteCoulomb freq u (p a).1 j:ℝ):ℂ) else 0) = + (scale*planarHoppingMatrix u (p a).1 (p b).1:ℂ)- + graphHoppingMatrix m left right (fun e => (t e:ℂ)) (p a).1 (p b).1 := by + unfold localizedOneBodyTarget + rw [hc] + split_ifs <;> push_cast <;> ring + calc + _ ≤ ‖(scale:ℂ)*(correctedNuclearOneBodyMatrix rho H S freq scale u F (p a).1 (p b).1:ℂ)- + (localizedOneBodyTarget scale freq u (p a).1 (p b).1:ℂ)‖+ + ‖(localizedOneBodyTarget scale freq u (p a).1 (p b).1:ℂ)- + (graphHoppingMatrix m left right (fun e => (t e:ℂ)) (p a).1 (p b).1- + if (p a).1=(p b).1 then ((∑ j, localizedOffsiteCoulomb freq u (p a).1 j:ℝ):ℂ) else 0)‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ ε+η := by + rw [ht] + apply add_le_add _ hg + simpa only [← Complex.ofReal_mul,← Complex.ofReal_sub,Complex.norm_real, + Real.norm_eq_abs] using he + · simp only [hs,ite_false,mul_zero,sub_self,norm_zero] + exact add_nonneg hε hη +end Entries + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..a215f7e738197e2d44ef5824cc93a280fd398d05 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardForm.lean @@ -0,0 +1,184 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardEntries +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorFormError +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorOccupationSector +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorDiagonal + +namespace OAI + +/-! The actual manufactured continuum form on its localized tensor space +is controlled by the full half-filled Hubbard variational problem. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal Laughlin.Fock + +theorem nuclearFormIntegrable_of_absolute {n : ℕ} (F : Position → ℝ) + (hF : Measurable F) (p : Coulomb.H1Vector n) + (hI : ∀ s i, Integrable (fun x => |F (Coulomb.position x i)| * ‖p.value s x‖^2)) : + nuclearFormIntegrable F p := by + intro s i + have h := (weighted_inner_pairing volume (fun x => F (Coulomb.position x i)) + (p.value s) (p.value s) + (hF.comp (Coulomb.positionCLM i).continuous.measurable).aemeasurable + (p.value_L2 s).aestronglyMeasurable (p.value_L2 s).aestronglyMeasurable + (hI s i) (hI s i)).1 + simpa only [real_inner_self_eq_norm_sq] using h + +def localizedHubbardFormError (m : ℕ) (freq D ε : ℝ) : ℝ := + (2*m+1+1:ℝ)^2*ε+(1/2:ℝ)*(2*m+1+1:ℝ)^4* + ((m+1:ℝ)^4*(32*(2*(m+1:ℝ)*localizedOverlapBound D)*localizedPotentialBound freq)+ + localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D)) + +section LocalizedForm +variable (hdensity : PublishedSobolevSmoothDensity) +variable {Edge : Type*} [Fintype Edge] +variable {n m : ℕ} {rho H S freq scale δ D ε : ℝ} +variable (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hf : 0 < freq) +variable (hrelation : freq^2 = 4*Real.pi*rho) (hscale : 0 < scale) +variable (u : Fin (m+1) → PlanarPosition) +variable (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) +variable (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) +variable (hδ : 0 ≤ δ) +variable (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) +variable (F : Position → ℝ) +variable (hN : ∀ a b, Integrable (fun z => (F (WithLp.toLp 2 z.2):ℂ)* + (star (Coulomb.flatSpinOrbital (localizedSpinMode freq u a) z)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u b) z)) Coulomb.spinSpaceMeasure) +variable (left right : Edge → Fin (m+1)) (t : Edge → ℝ) +variable (hK : ∀ a b, ‖(scale:ℂ)* + (flatResidualMatrix (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) a b+ + flatNuclearMatrix (localizedSpinMode freq u) F a b)- + hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t a b‖ ≤ ε) +variable (c : Laughlin.State (n+2) (2*m+1)) (hc : Laughlin.Antisymmetric c) +variable (hI : nuclearFormIntegrable F (finiteTensorState (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) c)) + +include hdensity hrho hH hS hf hrelation hscale hsep hs hδ hcoeff hN hK hc hI + +theorem localizedTensor_hubbard_form_error : + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + let x := normalizedTensorExterior (n+2) (2*m+1) c + |scale*(nuclearPerturbedForm (fun z => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position z i)) F p+scale⁻¹*Coulomb.pairEnergy p- + (n+2:ℝ)*((-1/2:ℝ)+freq/2)*Coulomb.mass p)- + (occupationInner (2*m+1) x + ((oneBodyOperator (hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t)+ + twoBodyOperator (hubbardCoulombTensor m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u))) x)).re| ≤ + localizedHubbardFormError m freq D ε*Coulomb.mass p := by + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hsum (z : Configuration (n+2)) : + |∑ i, manufacturedSlabPotential rho H S freq scale u (Coulomb.position z i)| ≤ + (n+2:ℝ)*B := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + Nat.cast_add,Nat.cast_ofNat] using Finset.sum_le_sum (s := Finset.univ) + (fun i _ => hB (Coulomb.position z i)) + have he := finiteTensorState_form_approximation (n := n) (Q := 2*m+1) hdensity + (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_C2 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) + (localizedSpinResidual_memLp hrho hH.le hS.le hf scale u hδ hcoeff) + (localizedSpinMode_inner hf u hsep hs) + (manufacturedSlabPotential rho H S freq scale u) + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u) + ((-1/2:ℝ)+freq/2) ((n+2:ℝ)*B) scale⁻¹ hsum + (fun a s x => by + simpa only [Complex.ofReal_add,Complex.ofReal_div,Complex.ofReal_neg, + Complex.ofReal_one,Complex.ofReal_ofNat] using + localizedSpinResidual_operator hrelation H S scale u a s x) + F hN (localizedSpinMode_coulomb_integrable hf u) c hc hI scale ε + ((m+1:ℝ)^4*(32*(2*(m+1:ℝ)*localizedOverlapBound D)*localizedPotentialBound freq)+ + localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D)) + (hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t) + (hubbardCoulombTensor m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u)) hK + (fun a b c d => by + rw [← Complex.ofReal_mul,mul_inv_cancel₀ (ne_of_gt hscale),Complex.ofReal_one,one_mul] + exact localizedSpinMode_hubbard_tensor_error hf u hsep hs a b c d) + simpa only [localizedHubbardFormError,Nat.cast_add,Nat.cast_mul,Nat.cast_one,Nat.cast_ofNat] using he + +theorem localizedTensor_hubbard_lower (hNelec : n+2=m+1) : + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + (scale*(n+2:ℝ)*((-1/2:ℝ)+freq/2)+ + hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)- + localizedHubbardFormError m freq D ε)*Coulomb.mass p ≤ + scale*(nuclearPerturbedForm (fun z => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position z i)) F p+scale⁻¹*Coulomb.pairEnergy p) := by + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + let x := normalizedTensorExterior (n+2) (2*m+1) c + have hx : IsHalfFilled m x := by + intro A hA + exact normalizedTensorExterior_occupationSupport c A (by omega) + have hm := finiteTensorState_occupationMass (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) (localizedSpinMode_inner hf u hsep hs) c hc + rw [occupationNormSq_fockCoordinates,fockCoordinates_norm_sq] at hm + have he := localizedTensor_hubbard_form_error hdensity hrho hH hS hf hrelation hscale u hsep hs + hδ hcoeff F hN left right t hK c hc hI + have hl := hubbardCAR_approximation_lower m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) (localizedOffsiteCoulomb_symmetric hf u) + (localizedOffsiteCoulomb_diagonal freq u) left right t x hx + (scale*(nuclearPerturbedForm (fun z => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position z i)) F p+scale⁻¹*Coulomb.pairEnergy p- + (n+2:ℝ)*((-1/2:ℝ)+freq/2)*Coulomb.mass p)) (localizedHubbardFormError m freq D ε) (by + change Coulomb.mass p = fockMass x at hm + rw [← hm] + exact he) + change Coulomb.mass p = fockMass x at hm + rw [← hm] at hl + dsimp only + nlinarith only [hl] + +theorem localizedTensor_hubbard_upper (hNelec : n+2=m+1) (a : ℝ) + (htrial : hubbardFermionForm m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t + (normalizedTensorExterior (n+2) (2*m+1) c) ≤ + a*fockMass (normalizedTensorExterior (n+2) (2*m+1) c)) : + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + scale*(nuclearPerturbedForm (fun z => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position z i)) F p+scale⁻¹*Coulomb.pairEnergy p) ≤ + (scale*(n+2:ℝ)*((-1/2:ℝ)+freq/2)+a- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)+ + localizedHubbardFormError m freq D ε)*Coulomb.mass p := by + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) c + let x := normalizedTensorExterior (n+2) (2*m+1) c + have hx : IsHalfFilled m x := by + intro A hA + exact normalizedTensorExterior_occupationSupport c A (by omega) + have hm := finiteTensorState_occupationMass (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) (localizedSpinMode_inner hf u hsep hs) c hc + rw [occupationNormSq_fockCoordinates,fockCoordinates_norm_sq] at hm + have he := localizedTensor_hubbard_form_error hdensity hrho hH hS hf hrelation hscale u hsep hs + hδ hcoeff F hN left right t hK c hc hI + have hu := hubbardCAR_approximation_upper m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) (localizedOffsiteCoulomb_symmetric hf u) + (localizedOffsiteCoulomb_diagonal freq u) left right t x hx + (scale*(nuclearPerturbedForm (fun z => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position z i)) F p+scale⁻¹*Coulomb.pairEnergy p- + (n+2:ℝ)*((-1/2:ℝ)+freq/2)*Coulomb.mass p)) (localizedHubbardFormError m freq D ε) a (by + change Coulomb.mass p = fockMass x at hm + rw [← hm] + exact he) htrial + change Coulomb.mass p = fockMass x at hm + rw [← hm] at hu + dsimp only + nlinarith only [hu] + +end LocalizedForm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardTensor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..1608663fa815101ca49e58a9e47bce0f4b2b6070 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedHubbardTensor.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockHubbardForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbard + +namespace OAI + +/-! The actual localized direct-Coulomb tensor has exactly the on-site +and off-site coefficients of the Hubbard charge operator. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal + +theorem localizedDensityTensor_hubbard (freq : ℝ) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) : + localizedDensityTensor freq u = hubbardCoulombTensor m + (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) := by + funext a b c d + by_cases h : a=c ∧ b=d + · simp only [localizedDensityTensor,hubbardCoulombTensor,ite_eq_left h] + rw [localizedFourIndex_diagonal] + by_cases hs : modeSite m a = modeSite m b + · simp only [siteCoulombCoefficient,ite_eq_left hs] + change (localizedCoulombCoeff freq (u (modeSite m a)) + (u (modeSite m b)) : ℂ) = _ + rw [hs,localizedCoulombCoeff_distance,sub_self,norm_zero] + · change (localizedCoulombCoeff freq (u (modeSite m a)) + (u (modeSite m b)) : ℂ) = _ + simp only [siteCoulombCoefficient,ite_eq_right hs,localizedOffsiteCoulomb] + · simp only [localizedDensityTensor,hubbardCoulombTensor,ite_eq_right h] + +theorem localizedSpinMode_hubbard_tensor_error {freq D : ℝ} (hf : 0 < freq) + {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) + (a b c d : Fin ((2*m+1)+1)) : + ‖flatCoulombTensor (localizedSpinMode freq u) a b c d- + hubbardCoulombTensor m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) a b c d‖ ≤ + (m+1:ℝ)^4*(32*(2*(m+1:ℝ)*localizedOverlapBound D)*localizedPotentialBound freq)+ + localizedFourIndexConstant freq*Real.exp (-(9/10:ℝ)*D) := by + rw [← localizedDensityTensor_hubbard] + exact localizedSpinMode_coulomb_error hf u hsep hs a b c d + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLeakage.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLeakage.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce557d8524b301a36be384f4daea63cc34b190fc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLeakage.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombRadial +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDecay + +namespace OAI + +/-! Exponential off-site density leakage for the actual localized modes. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem positionSplitCoordinates_fst_norm_le (x : Position) : + ‖(positionSplitCoordinates x).1‖ ≤ ‖x‖ := by + have h := positionSplitCoordinates_norm_sq x + nlinarith [sq_nonneg (positionSplitCoordinates x).2, norm_nonneg x, + norm_nonneg (positionSplitCoordinates x).1] + +theorem continuumLocalizedMode_planar_tail {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) (hr : 1 ≤ ‖(positionSplitCoordinates x).1 - u‖) : + continuumLocalizedMode freq u x ≤ 4 * localizedAmplitudeBound freq * + Real.exp (-(‖(positionSplitCoordinates x).1 - u‖ - 1) / 2) := by + have hp := div_le_div_of_nonneg_right (planarResolventMode_exponential_tail hr) + (Real.sqrt_nonneg (∫ r, planarResolventMode r ^ 2)) + have hv : verticalMode freq (positionSplitCoordinates x).2 ≤ + 1 / Real.sqrt (Real.sqrt (Real.pi / freq)) := by + apply div_le_div_of_nonneg_right _ (Real.sqrt_nonneg _) + exact Real.exp_le_one_iff.mpr (by nlinarith [sq_nonneg (positionSplitCoordinates x).2]) + change (planarResolventMode ((positionSplitCoordinates x).1 - u) / + Real.sqrt (∫ r, planarResolventMode r ^ 2)) * verticalMode freq (positionSplitCoordinates x).2 ≤ _ + calc + _ ≤ (4 * Real.exp (-(‖(positionSplitCoordinates x).1 - u‖ - 1) / 2) / + Real.sqrt (∫ r, planarResolventMode r ^ 2)) * + (1 / Real.sqrt (Real.sqrt (Real.pi / freq))) := + mul_le_mul hp hv (verticalMode_positive hfreq _).le (by positivity) + _ = _ := by unfold localizedAmplitudeBound; ring + +def localizedTailConstant (freq : ℝ) : ℝ := + (4 * localizedAmplitudeBound freq) ^ 2 * Real.exp 1 + +theorem localizedTailConstant_nonnegative (freq : ℝ) : 0 ≤ localizedTailConstant freq := + mul_nonneg (sq_nonneg _) (Real.exp_pos _).le + +theorem localizedDensity_planar_tail {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) (hr : 1 ≤ ‖(positionSplitCoordinates x).1 - u‖) : + localizedDensity freq u x ≤ localizedTailConstant freq * + Real.exp (-‖(positionSplitCoordinates x).1 - u‖) := by + have h := (sq_le_sq₀ (continuumLocalizedMode_positive hfreq u x).le + (mul_nonneg (mul_nonneg (by norm_num : (0 : ℝ) ≤ 4) + (localizedAmplitudeBound_positive hfreq).le) (Real.exp_pos _).le)).mpr + (continuumLocalizedMode_planar_tail hfreq u x hr) + have he : Real.exp (-(‖(positionSplitCoordinates x).1 - u‖ - 1) / 2) ^ 2 = + Real.exp 1 * Real.exp (-‖(positionSplitCoordinates x).1 - u‖) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + rw [mul_pow, he] at h + simpa only [localizedDensity, localizedTailConstant, mul_assoc] using h + +theorem localizedDensity_near_other_center {freq R : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) (x : Position) (hx : ‖x - planarCenter v‖ ≤ R) + (hsep : R + 1 ≤ ‖u - v‖) : + localizedDensity freq u x ≤ localizedTailConstant freq * Real.exp (R - ‖u - v‖) := by + have hp : ‖(positionSplitCoordinates x).1 - v‖ ≤ R := by + have h := (positionSplitCoordinates_fst_norm_le (x - planarCenter v)).trans hx + simpa only [map_sub, planarCenter, ContinuousLinearEquiv.apply_symm_apply, Prod.fst_sub] using h + have ht : ‖u - v‖ ≤ ‖u - (positionSplitCoordinates x).1‖ + + ‖(positionSplitCoordinates x).1 - v‖ := by + simpa only [dist_eq_norm] using dist_triangle u (positionSplitCoordinates x).1 v + rw [norm_sub_rev u (positionSplitCoordinates x).1] at ht + have hr : 1 ≤ ‖(positionSplitCoordinates x).1 - u‖ := by linarith + exact (localizedDensity_planar_tail hfreq u x hr).trans + (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (localizedTailConstant_nonnegative freq)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearCoulomb.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearCoulomb.lean new file mode 100644 index 0000000000000000000000000000000000000000..dabb1bd20f311eb2dbe9773ed8142fc5c355a088 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearCoulomb.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedLinearOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFourIndex +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPacketTests +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteCoefficientCorrection + +namespace OAI + +/-! Coulomb integrals of actual linear combinations of the localized +orbitals. Bounded-L1 packets make the full four-index change of basis an +exact identity, with joint singular-kernel integrability. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb +namespace CoulombPacket + +theorem sumList_apply (fs : List CoulombPacket) (x : Position) : + sumList fs x = (fs.map (fun f => f x)).sum := by + induction fs with + | nil => rfl + | cons f fs ih => simpa only [sumList, add, List.map_cons, List.sum_cons] using congrArg (fun t => f x + t) ih + +theorem combination_apply {m : ℕ} (f : Fin m → CoulombPacket) (a : Fin m → ℝ) (x : Position) : + combination f a x = ∑ j, a j * f j x := by + rw [combination, sumList_apply, List.map_ofFn, List.sum_ofFn] + rfl + +end CoulombPacket + +def localizedLinearTransitionPacket {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b : Fin m → ℝ) : CoulombPacket := + CoulombPacket.combination + (fun j => CoulombPacket.combination (fun k => localizedTransitionPacket hfreq (u j) (u k)) + (fun k => a j * b k)) (fun _ => 1) + +theorem localizedLinearTransitionPacket_apply {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b : Fin m → ℝ) (x : Position) : + localizedLinearTransitionPacket hfreq u a b x = + localizedLinearOrbital freq u a x * localizedLinearOrbital freq u b x := by + simp only [localizedLinearTransitionPacket, CoulombPacket.combination_apply, one_mul, + localizedTransitionPacket, localizedTransition, localizedLinearOrbital, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro k _ + ring + +def localizedLinearFourIndex {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b c d : Fin m → ℝ) : ℝ := + CoulombPacket.pair (localizedLinearTransitionPacket hfreq u a b) + (localizedLinearTransitionPacket hfreq u c d) + +theorem localizedLinearFourIndex_integrable {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b c d : Fin m → ℝ) : + Integrable (fun p : Position × Position => + (localizedLinearOrbital freq u a p.1 * localizedLinearOrbital freq u b p.1) * + (localizedLinearOrbital freq u c p.2 * localizedLinearOrbital freq u d p.2) * + Coulomb.coulombKernel (p.1 - p.2)) := by + simpa only [localizedLinearTransitionPacket_apply] using + CoulombPacket.joint_integrable (localizedLinearTransitionPacket hfreq u a b) + (localizedLinearTransitionPacket hfreq u c d) + +theorem localizedLinearFourIndex_integral {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b c d : Fin m → ℝ) : + localizedLinearFourIndex hfreq u a b c d = + ∫ p : Position × Position, + (localizedLinearOrbital freq u a p.1 * localizedLinearOrbital freq u b p.1) * + (localizedLinearOrbital freq u c p.2 * localizedLinearOrbital freq u d p.2) * + Coulomb.coulombKernel (p.1 - p.2) := by + simp only [localizedLinearFourIndex, CoulombPacket.pair, localizedLinearTransitionPacket_apply] + +theorem localizedLinearFourIndex_eq {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b c d : Fin m → ℝ) : + localizedLinearFourIndex hfreq u a b c d = + ∑ j, ∑ k, ∑ l, ∑ r, + ((a j * b k) * (c l * d r)) * localizedFourIndex freq (u j) (u k) (u l) (u r) := by + unfold localizedLinearFourIndex localizedLinearTransitionPacket + rw [CoulombPacket.pair_combination_left] + simp_rw [CoulombPacket.pair_combination_left, CoulombPacket.pair_combination_right, + localizedTransitionPacket_pair hfreq, Finset.mul_sum, one_mul] + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro k _ + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro r _ + ring + +theorem localizedLinearFourIndex_correction {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (A : Fin m → Fin m → ℝ) {eta : ℝ} + (he : 0 ≤ eta) (hA : ∀ i j, |A i j| ≤ 2) + (hnear : ∀ i j, |A i j - if i = j then 1 else 0| ≤ eta) (i j k l : Fin m) : + |localizedLinearFourIndex hfreq u (A i) (A j) (A k) (A l) - + localizedFourIndex freq (u i) (u j) (u k) (u l)| ≤ + (m : ℝ)^4 * (32 * eta * localizedPotentialBound freq) := by + have hF (p q r s : Fin m) : + |localizedFourIndex freq (u p) (u q) (u r) (u s)| ≤ localizedPotentialBound freq := by + rw [abs_of_nonneg (localizedFourIndex_nonnegative hfreq _ _ _ _)] + have hov : planarModeOverlap (u p) (u q) ≤ 1 := by + rw [← localizedTransition_mass hfreq] + exact localizedTransition_mass_le_one hfreq _ _ + exact (localizedFourIndex_le_overlap hfreq _ _ _ _).trans + ((mul_le_mul_of_nonneg_left hov (localizedPotentialBound_nonnegative freq)).trans_eq (mul_one _)) + rw [localizedLinearFourIndex_eq] + exact finiteFourIndexChange_bound A (fun p q r s => localizedFourIndex freq (u p) (u q) (u r) (u s)) + he (localizedPotentialBound_nonnegative freq) hA hnear hF i j k l + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearOrbitals.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearOrbitals.lean new file mode 100644 index 0000000000000000000000000000000000000000..9657696d29e0842143de6e4a9b5c32119eb1b07f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedLinearOrbitals.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModeDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTransition + +namespace OAI + +/-! Actual finite linear combinations of localized orbitals. Their +classical partials remain L2, and their integral Gram matrix is the +corresponding finite congruence of the actual overlap matrix. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedLinearOrbital (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (a : Fin m → ℝ) (x : Position) : ℝ := + ∑ j, a j * continuumLocalizedMode freq (u j) x + +theorem localizedLinearOrbital_C7 (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (a : Fin m → ℝ) : ContDiff ℝ 7 (localizedLinearOrbital freq u a) := + ContDiff.sum (fun j _ => contDiff_const.mul (continuumLocalizedMode_C7 freq (u j))) + +theorem localizedLinearOrbital_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a : Fin m → ℝ) : + MemLp (localizedLinearOrbital freq u a) 2 := by + have ht (j : Fin m) : MemLp (fun x => a j * continuumLocalizedMode freq (u j) x) 2 volume := + (continuumLocalizedMode_memLp hfreq (u j)).const_mul (a j) + exact memLp_finsetSum Finset.univ (fun j _ => ht j) + +theorem localizedLinearOrbital_fderiv (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (a : Fin m → ℝ) (x e : Position) : + fderiv ℝ (localizedLinearOrbital freq u a) x e = + ∑ j, a j * fderiv ℝ (continuumLocalizedMode freq (u j)) x e := by + have hd (j : Fin m) : DifferentiableAt ℝ (continuumLocalizedMode freq (u j)) x := + (continuumLocalizedMode_C7 freq (u j)).differentiable (by norm_num) x + unfold localizedLinearOrbital + rw [fderiv_fun_sum (fun j _ => (hd j).const_mul _)] + simp only [sum_apply, fderiv_const_mul (hd _), smul_apply, smul_eq_mul] + +theorem localizedLinearOrbital_fderiv_memLp {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a : Fin m → ℝ) (e : Position) : + MemLp (fun x => fderiv ℝ (localizedLinearOrbital freq u a) x e) 2 := by + have ht (j : Fin m) : MemLp (fun x => a j * + fderiv ℝ (continuumLocalizedMode freq (u j)) x e) 2 volume := + (continuumLocalizedMode_fderiv_memLp hfreq (u j) e).const_mul (a j) + have hs : MemLp (fun x => ∑ j, a j * + fderiv ℝ (continuumLocalizedMode freq (u j)) x e) 2 volume := + memLp_finsetSum Finset.univ (fun j _ => ht j) + simpa only [localizedLinearOrbital_fderiv] using hs + +theorem localizedLinearOrbital_inner {freq : ℝ} (hfreq : 0 < freq) {m : ℕ} + (u : Fin m → PlanarPosition) (a b : Fin m → ℝ) : + (∫ x, localizedLinearOrbital freq u a x * localizedLinearOrbital freq u b x) = + ∑ j, ∑ k, (a j * b k) * planarModeOverlap (u j) (u k) := by + have hi (j k : Fin m) : Integrable (fun x => (a j * b k) * + localizedTransition freq (u j) (u k) x) := + (localizedTransition_integrable hfreq (u j) (u k)).const_mul _ + have he (x : Position) : localizedLinearOrbital freq u a x * localizedLinearOrbital freq u b x = + ∑ j, ∑ k, (a j * b k) * localizedTransition freq (u j) (u k) x := by + unfold localizedLinearOrbital + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro j _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + unfold localizedTransition + ring + simp_rw [he] + rw [integral_finsetSum Finset.univ (fun j _ => + integrable_finsetSum Finset.univ (fun k _ => hi j k))] + apply Finset.sum_congr rfl + intro j _ + rw [integral_finsetSum Finset.univ (fun k _ => hi j k)] + simp only [integral_const_mul, localizedTransition_mass hfreq] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMatrixDecayBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMatrixDecayBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fd1cf31fab71914dcd0f8bef14840c13bd3b337 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMatrixDecayBound.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCorrectedMatrixError + +namespace OAI + +/-! The shifted one-body matrix is itself small. Retaining this decay is +necessary when estimating the Gram correction after physical amplification. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarWellMatrix_uniform_bound (u v w : PlanarPosition) : + |planarWellMatrix u v w| ≤ planarWellMatrixConstant := by + simpa only [mul_zero,neg_zero,Real.exp_zero,mul_one] using + planarWellMatrix_two_far (D := 0) u v w (norm_nonneg _) (norm_nonneg _) + +theorem planarHoppingMatrix_decay {m : ℕ} (u : Fin m → PlanarPosition) {D : ℝ} + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (i j : Fin m) : + |planarHoppingMatrix u i j| ≤ + (PlanarSobolev.wellBound*planarOverlapConstant)*Real.exp (-(9/10:ℝ)*D) := by + classical + unfold planarHoppingMatrix + by_cases hij : i=j + · simp only [hij,ite_true,abs_zero] + exact mul_nonneg (mul_nonneg PlanarSobolev.wellBound_nonnegative + planarOverlapConstant_nonnegative) (Real.exp_pos _).le + · simp only [hij,ite_false] + rw [← planarWellMatrix_hopping] + exact (planarWellMatrix_overlap_decay (u i) (u j) (u i)).trans + (mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith [hsep i j hij])) + (mul_nonneg PlanarSobolev.wellBound_nonnegative planarOverlapConstant_nonnegative)) + +theorem localizedCorrectedOneBodyMatrix_decay {freq D δ : ℝ} + (hf : 0 < freq) (hD : 0 ≤ D) (hδ : 0 ≤ δ) (scale : ℝ) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (i j : Fin m) : + |localizedCorrectedOneBodyMatrix freq scale u i j| ≤ + (PlanarSobolev.wellBound*planarOverlapConstant+(m:ℝ)*planarWellMatrixConstant)* + Real.exp (-(9/10:ℝ)*D)+(m:ℝ)*δ*planarWellMatrixConstant := by + have hC := planarWellMatrixConstant_nonnegative + have hb : |localizedOneBodyMatrix freq u i j| ≤ + (PlanarSobolev.wellBound*planarOverlapConstant+(m:ℝ)*planarWellMatrixConstant)* + Real.exp (-(9/10:ℝ)*D) := by + have hsmall := localizedOneBodyMatrix_error_bound hf u hsep i j + have hh := planarHoppingMatrix_decay u hsep i j + have hexp : Real.exp (-(19/10:ℝ)*D) ≤ Real.exp (-(9/10:ℝ)*D) := + Real.exp_le_exp.mpr (by linarith) + calc + _ ≤ |localizedOneBodyMatrix freq u i j-planarHoppingMatrix u i j|+ + |planarHoppingMatrix u i j| := by + simpa only [sub_zero] using abs_sub_le (localizedOneBodyMatrix freq u i j) (planarHoppingMatrix u i j) 0 + _ ≤ (m:ℝ)*planarWellMatrixConstant*Real.exp (-(9/10:ℝ)*D)+ + (PlanarSobolev.wellBound*planarOverlapConstant)*Real.exp (-(9/10:ℝ)*D) := + add_le_add (hsmall.trans (mul_le_mul_of_nonneg_left hexp (by positivity))) hh + _ = _ := by ring + have he : scale⁻¹*localizedCountertermMatrix freq u i j = + ∑ k, (localizedCounterterm freq u k/scale)*planarWellMatrix (u i) (u j) (u k) := by + simp only [localizedCountertermMatrix,Finset.mul_sum,div_eq_mul_inv] + apply Finset.sum_congr rfl + intro k _ + ring + have hc : |scale⁻¹*localizedCountertermMatrix freq u i j| ≤ (m:ℝ)*δ*planarWellMatrixConstant := by + rw [he] + calc + _ ≤ ∑ k, |(localizedCounterterm freq u k/scale)*planarWellMatrix (u i) (u j) (u k)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _k : Fin m, δ*planarWellMatrixConstant := by + apply Finset.sum_le_sum + intro k _ + rw [abs_mul,abs_of_nonneg (hcoeff k).1] + exact mul_le_mul (hcoeff k).2 (planarWellMatrix_uniform_bound _ _ _) + (abs_nonneg _) hδ + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul]; ring + rw [localizedCorrectedOneBodyMatrix_eq hf] + exact (abs_add_le _ _).trans (add_le_add hb hc) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModeDerivatives.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModeDerivatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..c827202819ac080047eeaab743166081b7ea18fb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModeDerivatives.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitCoordinates + +namespace OAI + +/-! Actual classical first derivatives of the localized modes are L2. +The planar/transverse product formula and the volume-preserving chart give +membership without a smooth-compact-support assumption on the orbitals. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem normalizedPlanarMode_partial (e r : PlanarPosition) : + planarPartial normalizedPlanarMode e r = + (Real.sqrt (∫ s, planarResolventMode s ^ 2))⁻¹ * planarPartial planarResolventMode e r := by + rw [normalizedPlanarMode_eq_const_mul, planarPartial_const_mul + (planarResolventMode_C7.of_le (by norm_num))] + +theorem normalizedPlanarMode_partial_square_integrable (e : PlanarPosition) : + Integrable (fun r => planarPartial normalizedPlanarMode e r ^ 2) := by + simp_rw [normalizedPlanarMode_partial, mul_pow] + exact (planarResolventMode_partial_square_integrable e).const_mul _ + +theorem normalizedPlanarMode_partial_memLp (e : PlanarPosition) : + MemLp (planarPartial normalizedPlanarMode e) 2 := + (memLp_two_iff_integrable_sq (planarPartial_continuous + (normalizedPlanarMode_C7.of_le (by norm_num)) e).aestronglyMeasurable).mpr + (normalizedPlanarMode_partial_square_integrable e) + +theorem localizedMode_fderiv (freq : ℝ) (u : PlanarPosition) (p e : SplitPosition) : + fderiv ℝ (localizedMode freq u) p e = + planarPartial normalizedPlanarMode e.1 (p.1 - u) * verticalMode freq p.2 + + normalizedPlanarMode (p.1 - u) * deriv (verticalMode freq) p.2 * e.2 := by + have hp := (normalizedPlanarMode_C7.differentiable (by norm_num) (p.1 - u)).hasFDerivAt.comp p + (hasFDerivAt_fst.sub_const u) + have hv := (verticalMode_hasDerivAt freq p.2).hasFDerivAt.comp p hasFDerivAt_snd + have h := congrArg (fun L : SplitPosition →L[ℝ] ℝ => L e) (hp.mul hv).fderiv + have hfun : (fun q : SplitPosition => normalizedPlanarMode (q.1 - u) * verticalMode freq q.2) = + localizedMode freq u := rfl + have hh : fderiv ℝ (fun q : SplitPosition => normalizedPlanarMode (q.1 - u) * verticalMode freq q.2) p e = + normalizedPlanarMode (p.1 - u) * (e.2 * (-freq * p.2 * verticalMode freq p.2)) + + verticalMode freq p.2 * fderiv ℝ normalizedPlanarMode (p.1 - u) e.1 := by + simpa only [add_apply, smul_apply, smul_eq_mul, ContinuousLinearMap.comp_apply, + ContinuousLinearMap.coe_fst', ContinuousLinearMap.coe_snd', + ContinuousLinearMap.toSpanSingleton_apply, Function.comp_def, Pi.mul_def] using h + rw [hfun] at hh + rw [verticalMode_deriv] + unfold planarPartial + nlinarith only [hh] + +theorem localizedMode_planarDerivative_memLp {freq : ℝ} (hfreq : 0 < freq) + (u e : PlanarPosition) : + MemLp (fun p : SplitPosition => planarPartial normalizedPlanarMode e (p.1 - u) * verticalMode freq p.2) 2 := by + apply (memLp_two_iff_integrable_sq (by + exact (((planarPartial_continuous (normalizedPlanarMode_C7.of_le (by norm_num)) e).comp + (continuous_fst.sub continuous_const)).mul + ((verticalMode_smooth freq).continuous.comp continuous_snd)).aestronglyMeasurable)).mpr + simp_rw [mul_pow] + rw [Measure.volume_eq_prod] + exact ((normalizedPlanarMode_partial_square_integrable e).comp_sub_right u).mul_prod + (verticalMode_square_integrable hfreq) + +theorem localizedMode_verticalDerivative_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + MemLp (fun p : SplitPosition => normalizedPlanarMode (p.1 - u) * deriv (verticalMode freq) p.2) 2 := by + apply (memLp_two_iff_integrable_sq (by + exact ((normalizedPlanarMode_C7.continuous.comp (continuous_fst.sub continuous_const)).mul + (((verticalMode_smooth freq).continuous_deriv (by simp)).comp continuous_snd)).aestronglyMeasurable)).mpr + simp_rw [mul_pow] + rw [Measure.volume_eq_prod] + exact (normalizedPlanarMode_square_integrable.comp_sub_right u).mul_prod + (verticalMode_deriv_square_integrable hfreq) + +theorem localizedMode_fderiv_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) (e : SplitPosition) : + MemLp (fun p => fderiv ℝ (localizedMode freq u) p e) 2 := by + simp_rw [localizedMode_fderiv] + exact (localizedMode_planarDerivative_memLp hfreq u e.1).add + ((localizedMode_verticalDerivative_memLp hfreq u).mul_const e.2) + +theorem continuumLocalizedMode_fderiv (freq : ℝ) (u : PlanarPosition) (x e : Position) : + fderiv ℝ (continuumLocalizedMode freq u) x e = + fderiv ℝ (localizedMode freq u) (positionSplitCoordinates x) (positionSplitCoordinates e) := by + have h := ((localizedMode_C7 freq u).differentiable (by norm_num) (positionSplitCoordinates x)).hasFDerivAt.comp x + positionSplitCoordinates.hasFDerivAt + exact congrArg (fun L : Position →L[ℝ] ℝ => L e) h.fderiv + +theorem continuumLocalizedMode_fderiv_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) (e : Position) : + MemLp (fun x => fderiv ℝ (continuumLocalizedMode freq u) x e) 2 := by + simp_rw [continuumLocalizedMode_fderiv] + exact (localizedMode_fderiv_memLp hfreq u (positionSplitCoordinates e)).comp_measurePreserving + positionSplitCoordinates_measurePreserving + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModes.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0d5572559a45f431f902a150f3a09b5039ea540 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedModes.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalized +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalEnergy +import Mathlib.MeasureTheory.Integral.Prod + +namespace OAI + +/-! Actual localized modes in planar/transverse coordinates. The measure is +the product of planar Euclidean volume and one-dimensional Lebesgue measure. +The split Laplacian below is the sum of the three coordinate derivatives. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +abbrev SplitPosition := PlanarPosition × ℝ + +def localizedMode (freq : ℝ) (u : PlanarPosition) (p : SplitPosition) : ℝ := + normalizedPlanarMode (p.1 - u) * verticalMode freq p.2 + +def localizedPotential (freq : ℝ) (u : PlanarPosition) (p : SplitPosition) : ℝ := + manufacturedPlanarWell (p.1 - u) + freq ^ 2 * p.2 ^ 2 / 2 + +def splitLaplacian (f : SplitPosition → ℝ) (p : SplitPosition) : ℝ := + planarLaplacian (fun r => f (r, p.2)) p.1 + + deriv (deriv (fun z => f (p.1, z))) p.2 + +theorem localizedMode_C7 (freq : ℝ) (u : PlanarPosition) : + ContDiff ℝ 7 (localizedMode freq u) := + (normalizedPlanarMode_C7.comp (contDiff_fst.sub contDiff_const)).mul + (((verticalMode_smooth freq).of_le (by simp)).comp contDiff_snd) + +theorem localizedMode_positive {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (p : SplitPosition) : 0 < localizedMode freq u p := + mul_pos (normalizedPlanarMode_positive _) (verticalMode_positive hfreq _) + +theorem localizedMode_square_integrable {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : Integrable (fun p => localizedMode freq u p ^ 2) := by + simp_rw [localizedMode, mul_pow] + exact (normalizedPlanarMode_square_integrable.comp_sub_right u).mul_prod + (verticalMode_square_integrable hfreq) + +theorem localizedMode_normalized {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : (∫ p, localizedMode freq u p ^ 2) = 1 := by + simp_rw [localizedMode, mul_pow] + rw [Measure.volume_eq_prod, + integral_prod_mul (fun r => normalizedPlanarMode (r - u) ^ 2) + (fun z => verticalMode freq z ^ 2), + integral_sub_right_eq_self (fun r => normalizedPlanarMode r ^ 2) u, + normalizedPlanarMode_normalized, verticalMode_normalized hfreq, one_mul] + +theorem localizedMode_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + MemLp (localizedMode freq u) 2 := + (memLp_two_iff_integrable_sq (localizedMode_C7 freq u).continuous.aestronglyMeasurable).mpr + (localizedMode_square_integrable hfreq u) + +theorem localizedMode_planar_laplacian (freq : ℝ) (u : PlanarPosition) (p : SplitPosition) : + planarLaplacian (fun r => localizedMode freq u (r, p.2)) p.1 = + (2 * manufacturedPlanarWell (p.1 - u) + 1) * localizedMode freq u p := by + have hc : ContDiff ℝ 2 (fun r => normalizedPlanarMode (r - u)) := + (normalizedPlanarMode_C7.comp (contDiff_id.sub contDiff_const)).of_le (by norm_num) + change planarLaplacian (fun r => normalizedPlanarMode (r - u) * verticalMode freq p.2) p.1 = _ + rw [show (fun r => normalizedPlanarMode (r - u) * verticalMode freq p.2) = + (fun r => verticalMode freq p.2 * normalizedPlanarMode (r - u)) + from funext (fun r => mul_comm _ _), planarLaplacian_const_mul hc, + planarLaplacian_translate, normalizedPlanarMode_eigen_equation] + simp only [localizedMode] + ring + +theorem localizedMode_vertical_second (freq : ℝ) (u : PlanarPosition) (p : SplitPosition) : + deriv (deriv (fun z => localizedMode freq u (p.1, z))) p.2 = + (freq ^ 2 * p.2 ^ 2 - freq) * localizedMode freq u p := by + simp only [localizedMode, deriv_const_mul_field', deriv_const_mul_field, + verticalMode_second_deriv] + ring + +theorem localizedMode_eigen_equation (freq : ℝ) (u : PlanarPosition) (p : SplitPosition) : + -(1 / 2 : ℝ) * splitLaplacian (localizedMode freq u) p + + localizedPotential freq u p * localizedMode freq u p = + ((-1 / 2 : ℝ) + freq / 2) * localizedMode freq u p := by + simp only [splitLaplacian, localizedMode_planar_laplacian, + localizedMode_vertical_second, localizedPotential] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMomentTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMomentTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..f099979aa777240a94c478d34cf5d4c7fe7440b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMomentTail.lean @@ -0,0 +1,155 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHigherMoments + +namespace OAI + +/-! Translated fourth/eighth moments and the weighted tails used in the +finite-slab operator estimate. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedDensityMoment (freq : ℝ) (u : PlanarPosition) (k : ℕ) : ℝ := + ∫ x : Position, ‖x‖^k*localizedDensity freq u x + +theorem localizedDensityMoment_nonnegative (freq : ℝ) (u : PlanarPosition) (k : ℕ) : + 0 ≤ localizedDensityMoment freq u k := + integral_nonneg (fun x => mul_nonneg (pow_nonneg (norm_nonneg x) k) + (localizedDensity_nonnegative freq u x)) + +private theorem translated_moment {freq : ℝ} (hfreq : 0 < freq) (k : ℕ) + (hk : Integrable (fun x : Position => ‖x‖^k*localizedDensity freq 0 x)) + (u : PlanarPosition) : + Integrable (fun x : Position => ‖x‖^k*localizedDensity freq u x) ∧ + localizedDensityMoment freq u k ≤ + (2:ℝ)^(k-1)*(localizedDensityMoment freq 0 k+‖u‖^k) := by + let c := planarCenter u + let F (x : Position) := ‖x‖^k*localizedDensity freq 0 x+ + ‖c‖^k*localizedDensity freq 0 x + have hF : Integrable F := hk.add ((localizedDensity_integrable hfreq 0).const_mul _) + have hmajor : Integrable (fun x => (2:ℝ)^(k-1)*F (x-c)) := + (hF.comp_sub_right c).const_mul _ + have hp (x : Position) : ‖x‖^k*localizedDensity freq u x ≤ (2:ℝ)^(k-1)*F (x-c) := by + have hn : ‖x‖ ≤ ‖x-c‖+‖c‖ := by + simpa only [sub_add_cancel] using norm_add_le (x-c) c + have hb := (pow_le_pow_left₀ (norm_nonneg x) hn k).trans + (add_pow_le (norm_nonneg (x-c)) (norm_nonneg c) k) + have hm := mul_le_mul_of_nonneg_right hb (localizedDensity_nonnegative freq 0 (x-c)) + rw [localizedDensity_translate] + convert hm using 1 + dsimp [F, c] + ring + have hi : Integrable (fun x : Position => ‖x‖^k*localizedDensity freq u x) := by + apply hmajor.mono' ((continuous_norm.pow k).mul (localizedDensity_continuous freq u)).aestronglyMeasurable + filter_upwards [] with x + change ‖‖x‖^k*localizedDensity freq u x‖ ≤ _ + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (norm_nonneg x) k) + (localizedDensity_nonnegative freq u x))] + exact hp x + refine ⟨hi, ?_⟩ + have h := integral_mono hi hmajor hp + change localizedDensityMoment freq u k ≤ _ at h + rw [integral_const_mul, integral_sub_right_eq_self] at h + dsimp [F] at h + rw [integral_add hk ((localizedDensity_integrable hfreq 0).const_mul _), + integral_const_mul, localizedDensity_mass hfreq 0, mul_one] at h + simpa only [c, planarCenter_norm, localizedDensityMoment] using h + +theorem localizedDensity_fourth_moment_translate {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : + Integrable (fun x : Position => ‖x‖^4*localizedDensity freq u x) ∧ + localizedDensityMoment freq u 4 ≤ 8*(localizedDensityMoment freq 0 4+‖u‖^4) := by + convert translated_moment hfreq 4 (localizedDensity_fourth_moment_integrable hfreq) u using 1 + norm_num + +theorem localizedDensity_eighth_moment_translate {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : + Integrable (fun x : Position => ‖x‖^8*localizedDensity freq u x) ∧ + localizedDensityMoment freq u 8 ≤ 128*(localizedDensityMoment freq 0 8+‖u‖^8) := by + convert translated_moment hfreq 8 (localizedDensity_eighth_moment_integrable hfreq) u using 1 + norm_num + +theorem localizedDensity_twentyFourth_moment_translate {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : + Integrable (fun x : Position => ‖x‖^24*localizedDensity freq u x) ∧ + localizedDensityMoment freq u 24 ≤ 8388608*(localizedDensityMoment freq 0 24+‖u‖^24) := by + convert translated_moment hfreq 24 (localizedDensity_twentyFourth_moment_integrable hfreq) u using 1 + norm_num + +theorem localizedDensity_seventySecond_moment_translate {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : + Integrable (fun x : Position => ‖x‖^72*localizedDensity freq u x) ∧ + localizedDensityMoment freq u 72 ≤ + (2:ℝ)^71*(localizedDensityMoment freq 0 72+‖u‖^72) := + translated_moment hfreq 72 (localizedDensity_seventySecond_moment_integrable hfreq) u + +private theorem weighted_tail {freq R : ℝ} (hR : 0 < R) (u : PlanarPosition) + (a b : ℕ) (ha : Integrable (fun x : Position => ‖x‖^a*localizedDensity freq u x)) + (hab : Integrable (fun x : Position => ‖x‖^(a+b)*localizedDensity freq u x)) + {S : Set Position} (hS : MeasurableSet S) (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, ‖x‖^a*localizedDensity freq u x) ≤ + localizedDensityMoment freq u (a+b)/R^b := by + have hp (x : Position) (hx : x ∈ Sᶜ) : + R^b*(‖x‖^a*localizedDensity freq u x) ≤ ‖x‖^(a+b)*localizedDensity freq u x := by + have h := mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ hR.le (hout x hx) b) + (mul_nonneg (pow_nonneg (norm_nonneg x) a) (localizedDensity_nonnegative freq u x)) + simpa only [pow_add, mul_left_comm, mul_assoc] using h + have h := setIntegral_mono_on (ha.const_mul (R^b)).integrableOn hab.integrableOn hS.compl hp + have hfull := integral_mono_measure (μ := volume.restrict Sᶜ) Measure.restrict_le_self + (Filter.Eventually.of_forall (fun x => mul_nonneg (pow_nonneg (norm_nonneg x) (a+b)) + (localizedDensity_nonnegative freq u x))) hab + rw [integral_const_mul] at h + apply (le_div_iff₀ (pow_pos hR b)).mpr + simpa only [localizedDensityMoment, mul_comm] using h.trans hfull + +theorem localizedDensity_mass_tail_eighth {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, localizedDensity freq u x) ≤ localizedDensityMoment freq u 8/R^8 := by + simpa only [pow_zero, one_mul, zero_add] using weighted_tail hR u 0 8 + (by simpa only [pow_zero, one_mul] using localizedDensity_integrable hfreq u) + (localizedDensity_eighth_moment_translate hfreq u).1 hS hout + +theorem localizedDensity_fourth_tail_eighth {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, ‖x‖^4*localizedDensity freq u x) ≤ localizedDensityMoment freq u 8/R^4 := by + exact weighted_tail hR u 4 4 (localizedDensity_fourth_moment_translate hfreq u).1 + (localizedDensity_eighth_moment_translate hfreq u).1 hS hout + +theorem localizedDensity_mass_tail_twentyFourth {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, localizedDensity freq u x) ≤ localizedDensityMoment freq u 24/R^24 := by + simpa only [pow_zero, one_mul, zero_add] using weighted_tail hR u 0 24 + (by simpa only [pow_zero, one_mul] using localizedDensity_integrable hfreq u) + (localizedDensity_twentyFourth_moment_translate hfreq u).1 hS hout + +theorem localizedDensity_fourth_tail_twentyFourth {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, ‖x‖^4*localizedDensity freq u x) ≤ localizedDensityMoment freq u 24/R^20 := by + exact weighted_tail hR u 4 20 (localizedDensity_fourth_moment_translate hfreq u).1 + (localizedDensity_twentyFourth_moment_translate hfreq u).1 hS hout + +theorem localizedDensity_mass_tail_seventySecond {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, localizedDensity freq u x) ≤ localizedDensityMoment freq u 72/R^72 := by + simpa only [pow_zero,one_mul,zero_add] using weighted_tail hR u 0 72 + (by simpa only [pow_zero,one_mul] using localizedDensity_integrable hfreq u) + (localizedDensity_seventySecond_moment_translate hfreq u).1 hS hout + +theorem localizedDensity_fourth_tail_seventySecond {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) {S : Set Position} (hS : MeasurableSet S) + (hout : ∀ x ∉ S, R ≤ ‖x‖) : + (∫ x in Sᶜ, ‖x‖^4*localizedDensity freq u x) ≤ localizedDensityMoment freq u 72/R^68 := by + exact weighted_tail hR u 4 68 (localizedDensity_fourth_moment_translate hfreq u).1 + (localizedDensity_seventySecond_moment_translate hfreq u).1 hS hout + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMultiwellResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMultiwellResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..aae813db7dc618042adf95ee8d4e5d34937d3bc4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedMultiwellResidual.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedWellResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCorrectedOneBody +import Mathlib.Algebra.Order.Chebyshev + +namespace OAI + +/-! L2 bounds on the actual differential residuals of the localized modes. +The estimate is polynomial in the number of wells; it does not sum over a +many-electron occupation basis. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def localizedMultiwellResidual (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) (x : Position) : ℝ := + ∑ k, if k = j then 0 else localizedWellAction freq (u j) (u k) x + +theorem localizedMultiwellResidual_eq (freq : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) (x : Position) : + localizedMultiwellResidual freq u j x = + multiwellAction freq u (localizedMode freq (u j)) (positionSplitCoordinates x) - + ((-1/2 : ℝ)+freq/2)*continuumLocalizedMode freq (u j) x := by + rw [show continuumLocalizedMode freq (u j) x = + localizedMode freq (u j) (positionSplitCoordinates x) from rfl, + multiwellAction_localizedMode] + rfl + +theorem localizedMultiwellResidual_memLp {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (j : Fin m) : + MemLp (localizedMultiwellResidual freq u j) 2 := by + classical + apply memLp_finsetSum + intro k _ + by_cases hk : k = j + · simp only [hk, ite_true] + exact MemLp.zero + · simp only [hk, ite_false] + exact localizedWellAction_memLp hfreq _ _ + +theorem localizedMultiwellResidual_square_integrable {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (j : Fin m) : + Integrable (fun x => localizedMultiwellResidual freq u j x ^ 2) := + (localizedMultiwellResidual_memLp hfreq u j).integrable_sq + +theorem localizedMultiwellResidual_square_bound {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (j : Fin m) : + (∫ x, localizedMultiwellResidual freq u j x ^ 2) ≤ + (m : ℝ)^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)* + Real.exp (-(19/10 : ℝ)*D) := by + classical + let f (k : Fin m) (x : Position) := + if k = j then 0 else localizedWellAction freq (u j) (u k) x + have hi (k : Fin m) : Integrable (fun x => f k x ^ 2) := by + by_cases hk : k = j + · simp only [f, hk, ite_true, zero_pow (by norm_num : 2 ≠ 0)] + exact integrable_zero Position ℝ volume + · simpa only [f, hk, ite_false] using localizedWellAction_square_integrable hfreq (u j) (u k) + have hpoint (x : Position) : localizedMultiwellResidual freq u j x ^ 2 ≤ + (m : ℝ)*(∑ k, f k x ^ 2) := by + simpa only [localizedMultiwellResidual, f, Finset.card_univ, Fintype.card_fin] using + (sq_sum_le_card_mul_sum_sq (s := Finset.univ) (f := fun k => f k x)) + have h := integral_mono (localizedMultiwellResidual_square_integrable hfreq u j) + ((integrable_finsetSum Finset.univ (fun k _ => hi k)).const_mul (m : ℝ)) hpoint + rw [integral_const_mul, integral_finsetSum Finset.univ (fun k _ => hi k)] at h + have hterm (k : Fin m) : (∫ x, f k x ^ 2) ≤ + (PlanarSobolev.wellBound*planarWellMatrixConstant)*Real.exp (-(19/10 : ℝ)*D) := by + by_cases hk : k = j + · simp only [f, hk, ite_true, zero_pow (by norm_num : 2 ≠ 0), integral_zero] + exact mul_nonneg (mul_nonneg PlanarSobolev.wellBound_nonnegative + planarWellMatrixConstant_nonnegative) (Real.exp_pos _).le + · simpa only [f, hk, ite_false] using + localizedWellAction_square_decay hfreq (u j) (u k) (hsep j k (Ne.symm hk)) + calc + _ ≤ (m : ℝ)*(∑ k, ∫ x, f k x ^ 2) := h + _ ≤ (m : ℝ)*(∑ _k : Fin m, + (PlanarSobolev.wellBound*planarWellMatrixConstant)*Real.exp (-(19/10 : ℝ)*D)) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun k _ => hterm k)) (Nat.cast_nonneg m) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedNuclearHardy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedNuclearHardy.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb29288537314a55d07fd2ab116d3f450b351ac4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedNuclearHardy.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearRounding +import OAI.Analysis.CoulombRadii.FieldAnalysis.Space + +namespace OAI + +/-! A cutoff Hardy estimate for the near-node part of the nuclear mesh. The +right side is localized, allowing bounded-overlap summation over nuclei. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem localized_nuclear_hardy {n : ℕ} (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (a : Position) {r D : ℝ} (hr : 0 < r) + (f : Configuration n → ℝ) (hf : ContDiff ℝ (⊤ : ℕ∞) f) + (hfB : ∀ x, |f x| ≤ 1) + (hdfB : ∀ j x, |fderiv ℝ f x (EuclideanSpace.single j 1)| ≤ D) + (A B : Set (Configuration n)) (hA : MeasurableSet A) (hB : MeasurableSet B) + (hnear : ∀ x ∈ A, ‖Coulomb.position x i-a‖ ≤ r) + (hone : ∀ x ∈ A, f x = 1) + (hzero : ∀ x ∉ B, f x = 0) + (hdzero : ∀ k x, x ∉ B → fderiv ℝ f x (EuclideanSpace.single (i,k) 1) = 0) : + (∫ x in A, Coulomb.coulombKernel (Coulomb.position x i-a)*‖u.value s x‖^2) ≤ + 24*r*D^2*(∫ x in B, ‖u.value s x‖^2)+ + 8*r*(∑ k : Fin 3, ∫ x in B, ‖u.gradient s (i,k) x‖^2) := by + let v := u.smoothMul f hf 1 D hfB hdfB + obtain ⟨hvi,hvh⟩ := nuclear_hardy_square v s i a + have hpoint (x : Configuration n) : + A.indicator (fun x => Coulomb.coulombKernel (Coulomb.position x i-a)*‖u.value s x‖^2) x ≤ + r*(Coulomb.coulombKernel (Coulomb.position x i-a)^2*‖v.value s x‖^2) := by + by_cases hx : x ∈ A + · rw [Set.indicator_of_mem hx] + have hv : v.value s x = u.value s x := by + change (f x:ℂ)*u.value s x = _ + rw [hone x hx,Complex.ofReal_one,one_mul] + rw [hv,← mul_assoc] + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + by_cases hz : ‖Coulomb.position x i-a‖ = 0 + · simp only [Coulomb.coulombKernel,hz,inv_zero,zero_pow (by decide : 2 ≠ 0),mul_zero,le_refl] + · have hp : 0 < ‖Coulomb.position x i-a‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hz) + have hh := mul_le_mul_of_nonneg_right (hnear x hx) (sq_nonneg ‖Coulomb.position x i-a‖⁻¹) + have he : ‖Coulomb.position x i-a‖*‖Coulomb.position x i-a‖⁻¹^2 = + ‖Coulomb.position x i-a‖⁻¹ := by field_simp + simpa only [Coulomb.coulombKernel,he] using hh + · rw [Set.indicator_of_notMem hx] + positivity + have hnearint : (∫ x in A, Coulomb.coulombKernel (Coulomb.position x i-a)*‖u.value s x‖^2) ≤ + r*(∫ x, Coulomb.coulombKernel (Coulomb.position x i-a)^2*‖v.value s x‖^2) := by + rw [← integral_indicator hA,← integral_const_mul] + exact integral_mono_of_nonneg (Filter.Eventually.of_forall (fun x => by + apply Set.indicator_nonneg + intro y _ + exact mul_nonneg (inv_nonneg.mpr (norm_nonneg _)) (sq_nonneg _))) + (hvi.const_mul r) (Filter.Eventually.of_forall hpoint) + have hg (k : Fin 3) : + (∫ x, ‖v.gradient s (i,k) x‖^2) ≤ + 2*D^2*(∫ x in B, ‖u.value s x‖^2)+2*(∫ x in B, ‖u.gradient s (i,k) x‖^2) := by + have hp (x : Configuration n) : ‖v.gradient s (i,k) x‖^2 ≤ + B.indicator (fun x => 2*D^2*‖u.value s x‖^2+2*‖u.gradient s (i,k) x‖^2) x := by + by_cases hx : x ∈ B + · rw [Set.indicator_of_mem hx] + have h₁ : ‖(fderiv ℝ f x (EuclideanSpace.single (i,k) 1):ℂ)*u.value s x‖ ≤ D*‖u.value s x‖ := by + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hdfB (i,k) x) (norm_nonneg _) + have h₂ : ‖(f x:ℂ)*u.gradient s (i,k) x‖ ≤ ‖u.gradient s (i,k) x‖ := by + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs] + simpa only [one_mul] using mul_le_mul_of_nonneg_right (hfB x) (norm_nonneg (u.gradient s (i,k) x)) + have ht := norm_add_le ((fderiv ℝ f x (EuclideanSpace.single (i,k) 1):ℂ)*u.value s x) + ((f x:ℂ)*u.gradient s (i,k) x) + change ‖(fderiv ℝ f x (EuclideanSpace.single (i,k) 1):ℂ)*u.value s x+ + (f x:ℂ)*u.gradient s (i,k) x‖^2 ≤ _ + nlinarith [norm_nonneg ((fderiv ℝ f x (EuclideanSpace.single (i,k) 1):ℂ)*u.value s x+ + (f x:ℂ)*u.gradient s (i,k) x),sq_nonneg (D*‖u.value s x‖-‖u.gradient s (i,k) x‖)] + · rw [Set.indicator_of_notMem hx] + change ‖(fderiv ℝ f x (EuclideanSpace.single (i,k) 1):ℂ)*u.value s x+ + (f x:ℂ)*u.gradient s (i,k) x‖^2 ≤ 0 + simp only [hdzero k x hx,hzero x hx,Complex.ofReal_zero,zero_mul,add_zero,norm_zero, + zero_pow (by decide : 2 ≠ 0),le_refl] + have hu := (u.value_L2 s).integrable_norm_pow (p := 2) (by decide) + have hd := (u.partial_L2 s (i,k)).integrable_norm_pow (p := 2) (by decide) + have hb := ((hu.const_mul (2*D^2)).add (hd.const_mul 2)).integrableOn.integrable_indicator hB + have hi := integral_mono_of_nonneg (Filter.Eventually.of_forall (fun x => sq_nonneg ‖v.gradient s (i,k) x‖)) + hb (Filter.Eventually.of_forall hp) + rw [integral_indicator hB] at hi + simp only [Pi.add_apply] at hi + rw [integral_add (hu.integrableOn.const_mul _) (hd.integrableOn.const_mul _), + integral_const_mul,integral_const_mul] at hi + exact hi + have hs := Finset.sum_le_sum (fun k (_ : k ∈ (Finset.univ : Finset (Fin 3))) => hg k) + simp only [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin, + nsmul_eq_mul,← Finset.mul_sum,Nat.cast_ofNat] at hs + have hh := mul_le_mul_of_nonneg_left hvh hr.le + have hsum := mul_le_mul_of_nonneg_left hs (by positivity : 0 ≤ 4*r) + nlinarith only [hnearint,hh,hsum] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBody.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..a950e55e0cd9b7a2620643858ab79fa225c0b0dc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBody.lean @@ -0,0 +1,122 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellMatrix + +namespace OAI + +/-! The actual differential action of the full multiwell operator on the +localized modes. Subtraction of the common ground energy leaves exactly the +sum of other wells, so its matrix is the checked hopping matrix plus the +explicit two-tail error. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def multiwellPotential (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (p : SplitPosition) : ℝ := + (∑ k, manufacturedPlanarWell (p.1 - u k)) + freq ^ 2 * p.2 ^ 2 / 2 + +def multiwellAction (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (f : SplitPosition → ℝ) (p : SplitPosition) : ℝ := + -(1 / 2 : ℝ) * splitLaplacian f p + multiwellPotential freq u p * f p + +theorem multiwellAction_localizedMode (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (j : Fin m) (p : SplitPosition) : + multiwellAction freq u (localizedMode freq (u j)) p - ((-1 / 2 : ℝ) + freq / 2) * localizedMode freq (u j) p = + ∑ k, if k = j then 0 else manufacturedPlanarWell (p.1 - u k) * localizedMode freq (u j) p := by + classical + have hs : (∑ k, manufacturedPlanarWell (p.1 - u k)) = + manufacturedPlanarWell (p.1 - u j) + (∑ k, if k = j then 0 else manufacturedPlanarWell (p.1 - u k)) := by + calc + _ = ∑ k, ((if k = j then manufacturedPlanarWell (p.1 - u j) else 0) + + (if k = j then 0 else manufacturedPlanarWell (p.1 - u k))) := by + apply Finset.sum_congr rfl + intro k _ + by_cases hk : k = j <;> simp [hk] + _ = _ := by rw [Finset.sum_add_distrib]; simp + have he := localizedMode_eigen_equation freq (u j) p + unfold localizedPotential at he + unfold multiwellAction multiwellPotential + rw [hs] + have hm : (∑ k, if k = j then 0 else manufacturedPlanarWell (p.1 - u k)) * localizedMode freq (u j) p = + ∑ k, if k = j then 0 else manufacturedPlanarWell (p.1 - u k) * localizedMode freq (u j) p := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro k _ + split_ifs <;> simp only [zero_mul] + rw [← hm] + nlinarith only [he] + +def localizedOneBodyIntegrand (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i j : Fin m) (x : Position) : ℝ := + continuumLocalizedMode freq (u i) x * + (multiwellAction freq u (localizedMode freq (u j)) (positionSplitCoordinates x) - + ((-1 / 2 : ℝ) + freq / 2) * continuumLocalizedMode freq (u j) x) + +theorem localizedOneBodyIntegrand_eq (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (i j : Fin m) (x : Position) : + localizedOneBodyIntegrand freq u i j x = + ∑ k, if k = j then 0 else localizedWellIntegrand freq (u i) (u j) (u k) x := by + classical + unfold localizedOneBodyIntegrand + change continuumLocalizedMode freq (u i) x * + (multiwellAction freq u (localizedMode freq (u j)) (positionSplitCoordinates x) - + ((-1 / 2 : ℝ) + freq / 2) * localizedMode freq (u j) (positionSplitCoordinates x)) = _ + rw [multiwellAction_localizedMode, Finset.mul_sum] + apply Finset.sum_congr rfl + intro k _ + split_ifs + · simp only [mul_zero] + · unfold localizedWellIntegrand continuumLocalizedMode + ring + +theorem localizedOneBodyIntegrand_integrable {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + Integrable (localizedOneBodyIntegrand freq u i j) := by + classical + change Integrable (fun x => localizedOneBodyIntegrand freq u i j x) + simp_rw [localizedOneBodyIntegrand_eq] + apply integrable_finsetSum + intro k _ + by_cases hk : k = j + · simp only [hk, ite_true] + exact integrable_zero Position ℝ volume + · simp only [hk, ite_false] + exact localizedWellIntegrand_integrable hfreq _ _ _ + +def localizedOneBodyMatrix (freq : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : ℝ := + ∫ x, localizedOneBodyIntegrand freq u i j x + +theorem localizedOneBodyMatrix_eq {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + localizedOneBodyMatrix freq u i j = planarMultiwellMatrix u i j := by + classical + unfold localizedOneBodyMatrix + simp_rw [localizedOneBodyIntegrand_eq] + rw [integral_finsetSum] + · unfold planarMultiwellMatrix + apply Finset.sum_congr rfl + intro k _ + by_cases hk : k = j + · simp only [hk, ite_true, integral_zero] + · simp only [hk, ite_false] + exact localizedWellIntegrand_integral hfreq _ _ _ + · intro k _ + by_cases hk : k = j + · simp only [hk, ite_true] + exact integrable_zero Position ℝ volume + · simp only [hk, ite_false] + exact localizedWellIntegrand_integrable hfreq _ _ _ + +theorem localizedOneBodyMatrix_error_bound {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) (i j : Fin m) : + |localizedOneBodyMatrix freq u i j - planarHoppingMatrix u i j| ≤ + m * planarWellMatrixConstant * Real.exp (-(19 / 10 : ℝ) * D) := by + rw [localizedOneBodyMatrix_eq hfreq] + exact planarMultiwellMatrix_error_bound u hsep i j + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBodyMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBodyMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..019ca454e4cff126f0f157ade438979fd8b1077e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOneBodyMatrix.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorFormCompression +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.WeightedSpinOrbitals +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedSpinOperator +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteOneBodyCorrection + +namespace OAI + +/-! The actual spinful one-body matrix is precisely the corrected spatial +matrix, repeated in the two conserved spin components. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem localizedSpinResidual_matrix {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hf : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) + (a b : Fin ((2*m+1)+1)) : + flatResidualMatrix (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) a b = + let p := (HubbardGlobal.siteModes m).symm + if (p a).2=(p b).2 then + (correctedManufacturedOneBodyMatrix rho H S freq scale u (p a).1 (p b).1:ℂ) else 0 := by + let p := (HubbardGlobal.siteModes m).symm + have hi : Integrable (fun x => correctedLocalizedMode freq u (p a).1 x* + correctedManufacturedResidual rho H S freq scale u (p b).1 x) := + (correctedLocalizedMode_memLp hf u _).integrable_mul + (correctedManufacturedResidual_memLp hrho hH hS hf scale u hδ hcoeff _) + have h := flatWeighted_realSpinOrbital_inner (fun _ => 1) + (correctedLocalizedMode freq u (p a).1) + (correctedManufacturedResidual rho H S freq scale u (p b).1) + (by simpa only [one_mul] using hi) (p a).2 (p b).2 + simpa only [flatResidualMatrix,localizedSpinMode,localizedSpinResidual, + correctedManufacturedOneBodyMatrix,Complex.ofReal_one,one_mul] using h + +theorem localizedSpin_nuclear_integrable {freq : ℝ} {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*correctedLocalizedMode freq u i x* + correctedLocalizedMode freq u j x)) (a b : Fin ((2*m+1)+1)) : + Integrable (fun z => (F (WithLp.toLp 2 z.2):ℂ)* + (star (Coulomb.flatSpinOrbital (localizedSpinMode freq u a) z)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u b) z)) Coulomb.spinSpaceMeasure := by + exact flatWeighted_realSpinOrbital_integrable F _ _ (hI _ _) _ _ + +theorem localizedSpin_nuclear_matrix {freq : ℝ} {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*correctedLocalizedMode freq u i x* + correctedLocalizedMode freq u j x)) (a b : Fin ((2*m+1)+1)) : + flatNuclearMatrix (localizedSpinMode freq u) F a b = + let p := (HubbardGlobal.siteModes m).symm + if (p a).2=(p b).2 then + ((∫ x, F x*correctedLocalizedMode freq u (p a).1 x* + correctedLocalizedMode freq u (p b).1 x : ℝ):ℂ) else 0 := by + exact flatWeighted_realSpinOrbital_inner F _ _ (hI _ _) _ _ + +theorem localizedSpin_oneBody_matrix {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hf : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) + (F : Position → ℝ) + (hI : ∀ i j, Integrable (fun x => F x*correctedLocalizedMode freq u i x* + correctedLocalizedMode freq u j x)) (a b : Fin ((2*m+1)+1)) : + flatResidualMatrix (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) a b+ + flatNuclearMatrix (localizedSpinMode freq u) F a b = + let p := (HubbardGlobal.siteModes m).symm + if (p a).2=(p b).2 then + (correctedNuclearOneBodyMatrix rho H S freq scale u F (p a).1 (p b).1:ℂ) else 0 := by + rw [localizedSpinResidual_matrix hrho hH hS hf scale u hδ hcoeff, + localizedSpin_nuclear_matrix u F hI] + dsimp only + split_ifs <;> simp only [correctedNuclearOneBodyMatrix,Complex.ofReal_add,add_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOrbitalGram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOrbitalGram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e79ef588edaab860b03daf18670d82f289e7650d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOrbitalGram.lean @@ -0,0 +1,119 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTransition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombGramApprox +import Mathlib.Analysis.InnerProductSpace.GramSchmidtOrtho + +namespace OAI + +/-! The actual localized L2 orbitals form a well-conditioned independent +family whenever the exponentially small pair overlaps have a small row sum. +In particular their finite span has an actual orthonormal basis. -/ + +noncomputable section +open MeasureTheory InnerProductSpace +open scoped BigOperators +namespace ContinuumCoulomb + +theorem dualMatrix_quadratic_upper {m : ℕ} (A : Fin m → Fin m → ℝ) + {a delta : ℝ} (hdelta : 0 ≤ delta) (hdiag : ∀ i, A i i ≤ a) + (hoff : ∀ i j, i ≠ j → |A i j| ≤ delta) (d : Fin m → ℝ) : + (∑ i, ∑ j, A i j * d i * d j) ≤ (a + m * delta) * ∑ i, d i ^ 2 := by + have h := dualMatrix_quadratic_lower (fun i j => -A i j) hdelta + (fun i => neg_le_neg (hdiag i)) (fun i j hij => by simpa only [abs_neg] using hoff i j hij) d + simp only [neg_mul, Finset.sum_neg_distrib] at h + linarith + +def localizedOrbitalL2 {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + Lp ℝ 2 (volume : Measure Position) := + (continuumLocalizedMode_memLp hfreq u).toLp (continuumLocalizedMode freq u) + +theorem localizedOrbitalL2_inner {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + inner ℝ (localizedOrbitalL2 hfreq u) (localizedOrbitalL2 hfreq v) = planarModeOverlap u v := by + rw [L2.inner_def, ← localizedTransition_mass hfreq u v] + apply integral_congr_ae + filter_upwards [(continuumLocalizedMode_memLp hfreq u).coeFn_toLp, + (continuumLocalizedMode_memLp hfreq v).coeFn_toLp] with x hu hv + change inner ℝ ((continuumLocalizedMode_memLp hfreq u).toLp (continuumLocalizedMode freq u) x) + ((continuumLocalizedMode_memLp hfreq v).toLp (continuumLocalizedMode freq v) x) = _ + rw [hu, hv, RCLike.inner_apply, conj_trivial] + exact mul_comm _ _ + +theorem localizedOrbitalL2_norm {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + ‖localizedOrbitalL2 hfreq u‖ = 1 := by + have h : ‖localizedOrbitalL2 hfreq u‖ ^ 2 = 1 := by + rw [← real_inner_self_eq_norm_sq, localizedOrbitalL2_inner, planarModeOverlap_diagonal] + nlinarith [norm_nonneg (localizedOrbitalL2 hfreq u)] + +theorem localizedOrbitalL2_sum_norm_sq {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (d : Fin m → ℝ) : + ‖∑ i, d i • localizedOrbitalL2 hfreq (u i)‖ ^ 2 = + ∑ i, ∑ j, planarModeOverlap (u i) (u j) * d i * d j := by + rw [← real_inner_self_eq_norm_sq] + simp_rw [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right, + localizedOrbitalL2_inner] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +def localizedOverlapBound (D : ℝ) : ℝ := planarOverlapConstant * Real.exp (-(9 / 10 : ℝ) * D) + +theorem localizedOverlapBound_nonnegative (D : ℝ) : 0 ≤ localizedOverlapBound D := + mul_nonneg planarOverlapConstant_nonnegative (Real.exp_pos _).le + +theorem planarModeOverlap_offsite {D : ℝ} {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) (i j : Fin m) (hij : i ≠ j) : + |planarModeOverlap (u i) (u j)| ≤ localizedOverlapBound D := by + rw [abs_of_nonneg (planarModeOverlap_nonnegative _ _)] + exact (planarModeOverlap_decay _ _).trans (mul_le_mul_of_nonneg_left + (Real.exp_le_exp.mpr (by linarith [hsep i j hij])) planarOverlapConstant_nonnegative) + +theorem localizedOrbitalL2_sum_bounds {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (d : Fin m → ℝ) : + (1 - m * localizedOverlapBound D) * ∑ i, d i ^ 2 ≤ + ‖∑ i, d i • localizedOrbitalL2 hfreq (u i)‖ ^ 2 ∧ + ‖∑ i, d i • localizedOrbitalL2 hfreq (u i)‖ ^ 2 ≤ + (1 + m * localizedOverlapBound D) * ∑ i, d i ^ 2 := by + rw [localizedOrbitalL2_sum_norm_sq] + exact ⟨dualMatrix_quadratic_lower _ (localizedOverlapBound_nonnegative D) + (fun i => (planarModeOverlap_diagonal (u i)).ge) (planarModeOverlap_offsite u hsep) d, + dualMatrix_quadratic_upper _ (localizedOverlapBound_nonnegative D) + (fun i => (planarModeOverlap_diagonal (u i)).le) (planarModeOverlap_offsite u hsep) d⟩ + +theorem localizedOrbitalL2_linearIndependent {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hsmall : m * localizedOverlapBound D < 1) : + LinearIndependent ℝ (fun i => localizedOrbitalL2 hfreq (u i)) := by + rw [Fintype.linearIndependent_iff] + intro d hd i + have h := (localizedOrbitalL2_sum_bounds hfreq u hsep d).1 + rw [hd, norm_zero, zero_pow (by decide : 2 ≠ 0)] at h + have hs : ∑ j, d j ^ 2 = 0 := by + have hn : 0 ≤ ∑ j, d j ^ 2 := Finset.sum_nonneg (fun j _ => sq_nonneg (d j)) + nlinarith + have hi : d i ^ 2 ≤ ∑ j, d j ^ 2 := Finset.single_le_sum + (fun j _ => sq_nonneg (d j)) (Finset.mem_univ i) + nlinarith [sq_nonneg (d i)] + +def orthonormalLocalizedOrbitals {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) : Fin m → Lp ℝ 2 (volume : Measure Position) := + gramSchmidtNormed ℝ (fun i => localizedOrbitalL2 hfreq (u i)) + +theorem orthonormalLocalizedOrbitals_orthonormal {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (hsmall : m * localizedOverlapBound D < 1) : + Orthonormal ℝ (orthonormalLocalizedOrbitals hfreq u) := + gramSchmidtNormed_orthonormal (localizedOrbitalL2_linearIndependent hfreq u hsep hsmall) + +theorem orthonormalLocalizedOrbitals_span {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) : + Submodule.span ℝ (Set.range (orthonormalLocalizedOrbitals hfreq u)) = + Submodule.span ℝ (Set.range (fun i => localizedOrbitalL2 hfreq (u i))) := by + rw [orthonormalLocalizedOrbitals, span_gramSchmidtNormed_range, span_gramSchmidt] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOverlapSpacing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOverlapSpacing.lean new file mode 100644 index 0000000000000000000000000000000000000000..104234838ab38d0a40c275e0139bd6bea4cccca3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedOverlapSpacing.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOrbitalGram + +namespace OAI + +/-! One fixed logarithmic spacing controls actual orbital Gram row sums +for all polynomial site counts, with no independent small-overlap premise. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem localizedOverlapBound_log (k : ℕ) {N : ℝ} (hN : 0 < N) : + localizedOverlapBound (((10 * k : ℕ) : ℝ) * Real.log N) = planarOverlapConstant / N ^ (9 * k) := by + unfold localizedOverlapBound + rw [show -(9 / 10 : ℝ) * (((10 * k : ℕ) : ℝ) * Real.log N) = + -(((9 * k : ℕ) : ℝ) * Real.log N) by push_cast; ring, + Real.exp_neg, Real.exp_nat_mul, Real.exp_log hN] + rfl + +theorem exists_localizedOverlap_spacing (A : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + N ^ A * localizedOverlapBound ((k : ℝ) * Real.log N) ≤ 1 / 2 := by + obtain ⟨q, hq⟩ := exists_nat_ge (max 1 (2 * planarOverlapConstant)) + have hq₁ : (1 : ℝ) ≤ q := (le_max_left _ _).trans hq + have hqC : 2 * planarOverlapConstant ≤ (q : ℝ) := (le_max_right _ _).trans hq + have hqp : 0 < q := by exact_mod_cast (by linarith : (0 : ℝ) < q) + refine ⟨10 * (A + q), by omega, fun N hN => ?_⟩ + have hNp : 0 < N := by linarith + have hpow : (q : ℝ) ≤ N ^ q := by + have h : (q : ℝ) ≤ (2 : ℝ) ^ q := by exact_mod_cast (Nat.lt_two_pow_self (n := q)).le + exact h.trans (pow_le_pow_left₀ (by norm_num) hN q) + have hC : planarOverlapConstant / N ^ q ≤ 1 / 2 := by + apply (div_le_iff₀ (pow_pos hNp q)).mpr + linarith [hqC.trans hpow] + rw [localizedOverlapBound_log (A + q) hNp] + have hlarge : N ^ (A + q) ≤ N ^ (9 * (A + q)) := + pow_le_pow_right₀ (by linarith : 1 ≤ N) (by omega) + have hdiv := div_le_div_of_nonneg_left planarOverlapConstant_nonnegative (pow_pos hNp (A + q)) hlarge + calc + _ ≤ N ^ A * (planarOverlapConstant / N ^ (A + q)) := + mul_le_mul_of_nonneg_left hdiv (pow_nonneg hNp.le A) + _ = planarOverlapConstant / N ^ q := by + rw [pow_add] + field_simp [pow_ne_zero A hNp.ne', pow_ne_zero q hNp.ne'] + _ ≤ _ := hC + +theorem exists_uniform_localizedOrbitals (A : ℕ) : + ∃ k : ℕ, 0 < k ∧ ∀ (N : ℝ), 2 ≤ N → ∀ (m : ℕ), (m : ℝ) ≤ N ^ A → + ∀ (u : Fin m → PlanarPosition), (∀ i j, i ≠ j → (k : ℝ) * Real.log N ≤ ‖u i - u j‖) → + ∀ (freq : ℝ) (hfreq : 0 < freq), + LinearIndependent ℝ (fun i => localizedOrbitalL2 hfreq (u i)) ∧ + Orthonormal ℝ (orthonormalLocalizedOrbitals hfreq u) := by + obtain ⟨k, hk, hspacing⟩ := exists_localizedOverlap_spacing A + refine ⟨k, hk, fun N hN m hm u hsep freq hfreq => ?_⟩ + have hsmall : m * localizedOverlapBound ((k : ℝ) * Real.log N) < 1 := by + have h := (mul_le_mul_of_nonneg_right hm (localizedOverlapBound_nonnegative _)).trans (hspacing N hN) + linarith + exact ⟨localizedOrbitalL2_linearIndependent hfreq u hsep hsmall, + orthonormalLocalizedOrbitals_orthonormal hfreq u hsep hsmall⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedRawDensity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedRawDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb5d9c11b86f762610bbdf0f9ac88c8cb6b7055e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedRawDensity.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCoulombBox + +namespace OAI + +/-! Unnormalized packets used by the literal Coulomb quadrature. Squaring +the normalization cancels the Gaussian square root, so the final quotient +uses only the already certified planar mass, frequency and pi evaluators. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedRawDensity (freq : ℝ) (x : Position) : ℝ := + planarResolventMode (positionSplitCoordinates x).1 ^ 2 * + Real.exp (-freq * (positionSplitCoordinates x).2 ^ 2) + +def localizedRawMass (freq : ℝ) : ℝ := + (∫ r, planarResolventMode r ^ 2) * Real.sqrt (Real.pi / freq) + +theorem localizedRawMass_positive {freq : ℝ} (hfreq : 0 < freq) : + 0 < localizedRawMass freq := + mul_pos planarResolventMode_square_integral_positive + (Real.sqrt_pos.mpr (div_pos Real.pi_pos hfreq)) + +theorem localizedRawDensity_nonnegative (freq : ℝ) (x : Position) : + 0 ≤ localizedRawDensity freq x := + mul_nonneg (sq_nonneg _) (Real.exp_pos _).le + +theorem localizedRawDensity_le_one {freq : ℝ} (hfreq : 0 ≤ freq) (x : Position) : + localizedRawDensity freq x ≤ 1 := by + have hp := (sq_le_sq₀ (planarResolventMode_positive _).le zero_le_one).mpr + (planarResolventMode_le_one (positionSplitCoordinates x).1) + have he : Real.exp (-freq * (positionSplitCoordinates x).2 ^ 2) ≤ 1 := + Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hfreq) (sq_nonneg _)) + exact (mul_le_mul hp he (Real.exp_pos _).le (by positivity)).trans_eq (by norm_num) + +theorem localizedRawDensity_eq_normalized {freq : ℝ} (hfreq : 0 < freq) (x : Position) : + localizedRawDensity freq x = localizedRawMass freq * localizedDensity freq 0 x := by + have hA := planarResolventMode_square_integral_positive + have hB := Real.sqrt_pos.mpr (div_pos Real.pi_pos hfreq) + simp only [localizedRawDensity, localizedRawMass, localizedDensity, + continuumLocalizedMode, localizedMode, sub_zero, mul_pow, normalizedPlanarMode, + div_pow, verticalMode_square hfreq, Real.sq_sqrt hA.le] + field_simp + +theorem localizedRawDensity_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (localizedRawDensity freq) := by + change Integrable (fun x => localizedRawDensity freq x) + simp_rw [localizedRawDensity_eq_normalized hfreq] + exact (localizedDensity_integrable hfreq 0).const_mul _ + +theorem localizedRawDensity_mass {freq : ℝ} (hfreq : 0 < freq) : + (∫ x, localizedRawDensity freq x) = localizedRawMass freq := by + simp_rw [localizedRawDensity_eq_normalized hfreq] + rw [integral_const_mul, localizedDensity_mass hfreq 0, mul_one] + +theorem localizedRawMass_square {freq : ℝ} (hfreq : 0 < freq) : + localizedRawMass freq ^ 2 = (∫ r, planarResolventMode r ^ 2) ^ 2 * Real.pi / freq := by + rw [localizedRawMass, mul_pow, Real.sq_sqrt (div_pos Real.pi_pos hfreq).le] + ring + +def localizedRawCoulombBox (freq ε L : ℝ) (u : PlanarPosition) : ℝ := + ∫ p in coulombNumericalBox L ×ˢ coulombNumericalBox L, + cappedPairIntegrand ε (planarCenter u) (localizedRawDensity freq) (localizedRawDensity freq) p + +theorem localizedRawCoulombBox_eq {freq : ℝ} (hfreq : 0 < freq) (ε L : ℝ) + (u : PlanarPosition) : + localizedRawCoulombBox freq ε L u = + localizedRawMass freq ^ 2 * localizedCoulombBoxIntegral freq ε L u := by + unfold localizedRawCoulombBox localizedCoulombBoxIntegral + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with p + simp only [cappedPairIntegrand, localizedRawDensity_eq_normalized hfreq] + ring + +theorem localizedRawCoulombBox_quotient {freq : ℝ} (hfreq : 0 < freq) (ε L : ℝ) + (u : PlanarPosition) : + localizedRawCoulombBox freq ε L u * freq / + ((∫ r, planarResolventMode r ^ 2) ^ 2 * Real.pi) = + localizedCoulombBoxIntegral freq ε L u := by + rw [localizedRawCoulombBox_eq hfreq, localizedRawMass_square hfreq] + have hA := planarResolventMode_square_integral_positive.ne' + have hpi := Real.pi_pos.ne' + field_simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedSpinOperator.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedSpinOperator.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab0b005babe0b6c78dfd88c3a2692489f1c15d5d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedSpinOperator.lean @@ -0,0 +1,40 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedTensorResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronComplexLaplacian + +namespace OAI + +/-! Actual one-body differential residual of each corrected spatial-spin mode. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem localizedSpinMode_C2 (freq : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (j : Fin ((2*m+1)+1)) (s : Fin 2) : ContDiff ℝ 2 (fun x => localizedSpinMode freq u j x s) := by + have hf : ContDiff ℝ 2 (correctedLocalizedMode freq u ((HubbardGlobal.siteModes m).symm j).1) := + (localizedLinearOrbital_C7 freq u (correctedLocalizedCoefficients u _)).of_le (by norm_num) + by_cases hs : s=((HubbardGlobal.siteModes m).symm j).2 + · simpa only [localizedSpinMode,realSpinOrbital,hs,ite_true,Function.comp_def, + Complex.ofRealCLM_apply] using Complex.ofRealCLM.contDiff.comp hf + · simpa only [localizedSpinMode,realSpinOrbital,hs,ite_false] using + (contDiff_const : ContDiff ℝ 2 (fun _ : Position => (0:ℂ))) + +theorem localizedSpinResidual_operator {rho freq : ℝ} (hrelation : freq^2 = 4*Real.pi*rho) + (H S scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (j : Fin ((2*m+1)+1)) (s : Fin 2) (x : Position) : + localizedSpinResidual rho H S freq scale u j x s = + (-1/2:ℂ)*positionComplexLaplacian (fun y => localizedSpinMode freq u j y s) x+ + (manufacturedSlabPotential rho H S freq scale u x:ℂ)*localizedSpinMode freq u j x s- + (((-1/2:ℝ)+freq/2):ℂ)*localizedSpinMode freq u j x s := by + by_cases hs : s=((HubbardGlobal.siteModes m).symm j).2 + · simpa only [localizedSpinResidual,localizedSpinMode,realSpinOrbital,hs,ite_true] using + correctedManufacturedResidual_complex_laplacian hrelation H S scale u + ((HubbardGlobal.siteModes m).symm j).1 x + · simp [localizedSpinResidual,localizedSpinMode,realSpinOrbital,hs, + positionComplexLaplacian,positionComplexPartial] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTensorResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTensorResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..0291489fe049f3b6ac22f3ca3bbd589193630027 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTensorResidual.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.SpinTensorResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFockStates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedManufacturedResidual + +namespace OAI + +/-! The actual corrected manufactured orbital residuals, lifted to both spin +components and all electron coordinates, satisfy a polynomial L2 estimate. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +def localizedSpinResidual (rho H S freq scale : ℝ) {m : ℕ} + (u : Fin (m+1) → PlanarPosition) (j : Fin ((2*m+1)+1)) : Position → Fin 2 → ℂ := + realSpinOrbital (correctedManufacturedResidual rho H S freq scale u + ((HubbardGlobal.siteModes m).symm j).1) ((HubbardGlobal.siteModes m).symm j).2 + +theorem localizedSpinResidual_memLp {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) {η : ℝ} (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) (j : Fin ((2*m+1)+1)) (s : Fin 2) : + MemLp (fun x => localizedSpinResidual rho H S freq scale u j x s) 2 := + realSpinOrbital_memLp _ + (correctedManufacturedResidual_memLp hrho hH hS hfreq scale u hη hcoeff _) _ s + +theorem localizedSpinResidual_sum_norm {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) {η : ℝ} (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) : + (∑ j, ∫ x, ‖Coulomb.flatSpinOrbital (localizedSpinResidual rho H S freq scale u j) x‖^2 + ∂Coulomb.spinSpaceMeasure) = + 2*∑ i, ∫ x, correctedManufacturedResidual rho H S freq scale u i x^2 := by + simp only [localizedSpinResidual,flatRealSpinOrbital_norm_sq _ + (correctedManufacturedResidual_memLp hrho hH hS hfreq scale u hη hcoeff _)] + rw [(HubbardGlobal.siteModes m).symm.sum_comp + (fun p : Fin (m+1) × Fin 2 => ∫ x, correctedManufacturedResidual rho H S freq scale u p.1 x^2)] + simp only [Fintype.sum_prod_type,Finset.sum_const,Finset.card_univ,Fintype.card_fin, + nsmul_eq_mul,← Finset.mul_sum] + norm_num + +theorem localizedTensorResidual_L2_bound {rho H S freq η D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (c : (Fin (n+1) → Fin ((2*m+1)+1)) → ℂ) : + (∫ x, ‖tensorTotalReplacement (fun j => Coulomb.flatSpinOrbital (localizedSpinMode freq u j)) + (fun j => Coulomb.flatSpinOrbital (localizedSpinResidual rho H S freq scale u j)) c x‖^2 + ∂(Measure.pi fun _ : Fin (n+1) => Coulomb.spinSpaceMeasure)) ≤ + (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, manufacturedOrbitalSquaredError rho H S freq η D R u j)* + Coulomb.mass (finiteTensorState (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hfreq u) + (localizedSpinMode_partial_memLp hfreq u) c) := by + have h := spinTensorResidual_L2_bound (localizedSpinMode freq u) + (localizedSpinResidual rho H S freq scale u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) + (localizedSpinResidual_memLp hrho hH.le hS.le hfreq scale u hη hcoeff) + (fun a b => by + have h := localizedSpinMode_inner hfreq u hsep hs a b + by_cases hab : a=b <;> simpa only [hab,ite_true,ite_false] using h) c + rw [localizedSpinResidual_sum_norm hrho hH.le hS.le hfreq scale u hη hcoeff] at h + apply h.trans + apply mul_le_mul_of_nonneg_right _ (Coulomb.mass_nonneg _) + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + have he := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + correctedManufacturedResidual_square_bound hrho hH hS hfreq hR hRH hRS + scale u hsep hs hη hcoeff i) + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] at he + nlinarith only [he] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTransition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..6600f96215f86f1e56f19280a2837c75fa0f4cfb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedTransition.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarOverlap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPackets + +namespace OAI + +/-! The actual transition densities of localized three-dimensional modes +have normalized mass bounds and exponentially small off-site L1 mass. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedTransition (freq : ℝ) (u v : PlanarPosition) (x : Position) : ℝ := + continuumLocalizedMode freq u x * continuumLocalizedMode freq v x + +theorem localizedTransition_continuous (freq : ℝ) (u v : PlanarPosition) : + Continuous (localizedTransition freq u v) := + (continuumLocalizedMode_C7 freq u).continuous.mul (continuumLocalizedMode_C7 freq v).continuous + +theorem localizedTransition_nonnegative {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) (x : Position) : 0 ≤ localizedTransition freq u v x := + mul_nonneg (continuumLocalizedMode_positive hfreq u x).le (continuumLocalizedMode_positive hfreq v x).le + +theorem localizedTransition_integrable {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + Integrable (localizedTransition freq u v) := + (continuumLocalizedMode_memLp hfreq u).integrable_mul (continuumLocalizedMode_memLp hfreq v) + +theorem localizedTransition_bound {freq : ℝ} (hfreq : 0 < freq) + (u v : PlanarPosition) (x : Position) : + localizedTransition freq u v x ≤ localizedAmplitudeBound freq ^ 2 := by + have h := mul_le_mul (continuumLocalizedMode_le hfreq u x) (continuumLocalizedMode_le hfreq v x) + (continuumLocalizedMode_positive hfreq v x).le (localizedAmplitudeBound_positive hfreq).le + simpa only [localizedTransition, pow_two] using h + +theorem localizedTransition_mass {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + (∫ x, localizedTransition freq u v x) = planarModeOverlap u v := by + change (∫ x, localizedMode freq u (positionSplitCoordinates x) * + localizedMode freq v (positionSplitCoordinates x)) = _ + rw [positionSplitCoordinates_integral (fun p => localizedMode freq u p * localizedMode freq v p)] + have he : (fun p : SplitPosition => localizedMode freq u p * localizedMode freq v p) = + (fun p => (normalizedPlanarMode (p.1 - u) * normalizedPlanarMode (p.1 - v)) * verticalMode freq p.2 ^ 2) := by + funext p + unfold localizedMode + ring + rw [he, Measure.volume_eq_prod, integral_prod_mul + (fun r => normalizedPlanarMode (r - u) * normalizedPlanarMode (r - v)) + (fun z => verticalMode freq z ^ 2)] + rw [verticalMode_normalized hfreq, mul_one] + rfl + +theorem localizedTransition_mass_le_one {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + (∫ x, localizedTransition freq u v x) ≤ 1 := by + have hi := ((localizedDensity_integrable hfreq u).add (localizedDensity_integrable hfreq v)).div_const 2 + have h := integral_mono (localizedTransition_integrable hfreq u v) hi (fun x => by + simp only [Pi.add_apply, localizedTransition, localizedDensity] + nlinarith [sq_nonneg (continuumLocalizedMode freq u x - continuumLocalizedMode freq v x)]) + simp only [Pi.add_apply] at h + rw [integral_div, integral_add (localizedDensity_integrable hfreq u) (localizedDensity_integrable hfreq v), + localizedDensity_mass hfreq u, localizedDensity_mass hfreq v] at h + norm_num at h + exact h + +theorem localizedTransition_norm_mass {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + (∫ x, ‖localizedTransition freq u v x‖) = planarModeOverlap u v := by + simp_rw [Real.norm_of_nonneg (localizedTransition_nonnegative hfreq u v _)] + exact localizedTransition_mass hfreq u v + +theorem localizedTransition_L1_decay {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : + (∫ x, ‖localizedTransition freq u v x‖) ≤ + planarOverlapConstant * Real.exp (-(9 / 10 : ℝ) * ‖u - v‖) := by + rw [localizedTransition_norm_mass hfreq] + exact planarModeOverlap_decay u v + +def localizedTransitionPacket {freq : ℝ} (hfreq : 0 < freq) (u v : PlanarPosition) : CoulombPacket where + value := localizedTransition freq u v + continuous := localizedTransition_continuous freq u v + integrable := localizedTransition_integrable hfreq u v + bound := localizedAmplitudeBound freq ^ 2 + bound_nonnegative := sq_nonneg _ + bound_spec x := by + rw [Real.norm_of_nonneg (localizedTransition_nonnegative hfreq u v x)] + exact localizedTransition_bound hfreq u v x + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8c6d5a5ab9ae12397947c249662ff64aa06c1a9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellMatrix.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitCoordinates + +namespace OAI + +/-! Actual three-dimensional well matrix elements equal the planar ones: +the transverse Gaussian contributes exactly its unit squared mass. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedWellIntegrand (freq : ℝ) (u v w : PlanarPosition) (x : Position) : ℝ := + continuumLocalizedMode freq u x * manufacturedPlanarWell ((positionSplitCoordinates x).1 - w) * + continuumLocalizedMode freq v x + +theorem localizedWellIntegrand_split (freq : ℝ) (u v w : PlanarPosition) (x : Position) : + localizedWellIntegrand freq u v w x = + (normalizedPlanarMode ((positionSplitCoordinates x).1 - u) * + manufacturedPlanarWell ((positionSplitCoordinates x).1 - w) * + normalizedPlanarMode ((positionSplitCoordinates x).1 - v)) * + verticalMode freq (positionSplitCoordinates x).2 ^ 2 := by + unfold localizedWellIntegrand continuumLocalizedMode localizedMode + ring + +theorem localizedWellIntegrand_integrable {freq : ℝ} (hfreq : 0 < freq) (u v w : PlanarPosition) : + Integrable (localizedWellIntegrand freq u v w) := by + have hi : Integrable (fun p : SplitPosition => + (normalizedPlanarMode (p.1 - u) * manufacturedPlanarWell (p.1 - w) * normalizedPlanarMode (p.1 - v)) * + verticalMode freq p.2 ^ 2) := by + rw [Measure.volume_eq_prod] + exact (planarWellMatrix_integrable u v w).mul_prod (verticalMode_square_integrable hfreq) + have h := positionSplitCoordinates_measurePreserving.integrable_comp_of_integrable hi + simpa only [Function.comp_def, ← localizedWellIntegrand_split] using h + +theorem localizedWellIntegrand_integral {freq : ℝ} (hfreq : 0 < freq) (u v w : PlanarPosition) : + (∫ x, localizedWellIntegrand freq u v w x) = planarWellMatrix u v w := by + simp_rw [localizedWellIntegrand_split] + rw [positionSplitCoordinates_integral (fun p => + (normalizedPlanarMode (p.1 - u) * manufacturedPlanarWell (p.1 - w) * normalizedPlanarMode (p.1 - v)) * + verticalMode freq p.2 ^ 2), Measure.volume_eq_prod, integral_prod_mul + (fun r => normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - w) * normalizedPlanarMode (r - v)) + (fun z => verticalMode freq z ^ 2), verticalMode_normalized hfreq, mul_one] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..887b71e064376ef66df4ce49e90f29451067c6e0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/LocalizedWellResidual.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev + +namespace OAI + +/-! The actual other-well residual has exponentially small L2 mass. +The square of a nonpositive bounded well is controlled by its negative +well matrix element, so the checked two-tail estimate applies directly. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def localizedWellAction (freq : ℝ) (u w : PlanarPosition) (x : Position) : ℝ := + manufacturedPlanarWell ((positionSplitCoordinates x).1-w) * continuumLocalizedMode freq u x + +theorem localizedWellAction_continuous (freq : ℝ) (u w : PlanarPosition) : + Continuous (localizedWellAction freq u w) := + (manufacturedPlanarWell_C7.continuous.comp + ((positionSplitCoordinates.continuous.fst).sub continuous_const)).mul + (continuumLocalizedMode_C7 freq u).continuous + +theorem localizedWellAction_memLp {freq : ℝ} (hfreq : 0 < freq) (u w : PlanarPosition) : + MemLp (localizedWellAction freq u w) 2 := by + apply (continuumLocalizedMode_memLp hfreq u).of_le_mul + (c := PlanarSobolev.wellBound) (localizedWellAction_continuous freq u w).aestronglyMeasurable + filter_upwards [] with x + rw [localizedWellAction, norm_mul] + exact mul_le_mul_of_nonneg_right (PlanarSobolev.wellBound_spec _) (norm_nonneg _) + +theorem localizedWellAction_square_integrable {freq : ℝ} (hfreq : 0 < freq) (u w : PlanarPosition) : + Integrable (fun x => localizedWellAction freq u w x ^ 2) := + (memLp_two_iff_integrable_sq (localizedWellAction_continuous freq u w).aestronglyMeasurable).mp + (localizedWellAction_memLp hfreq u w) + +theorem localizedWellAction_square_le_matrix {freq : ℝ} (hfreq : 0 < freq) (u w : PlanarPosition) : + (∫ x, localizedWellAction freq u w x ^ 2) ≤ PlanarSobolev.wellBound * |planarWellMatrix u u w| := by + have hp (x : Position) : localizedWellAction freq u w x ^ 2 ≤ + PlanarSobolev.wellBound * (-localizedWellIntegrand freq u u w x) := by + have hn := manufacturedPlanarWell_nonpositive ((positionSplitCoordinates x).1-w) + have hb := PlanarSobolev.wellBound_spec ((positionSplitCoordinates x).1-w) + rw [Real.norm_eq_abs, abs_of_nonpos hn] at hb + have hsq : manufacturedPlanarWell ((positionSplitCoordinates x).1-w)^2 ≤ + PlanarSobolev.wellBound * (-manufacturedPlanarWell ((positionSplitCoordinates x).1-w)) := by + nlinarith [mul_nonneg (neg_nonneg.mpr hn) (sub_nonneg.mpr hb)] + have h := mul_le_mul_of_nonneg_right hsq (sq_nonneg (continuumLocalizedMode freq u x)) + unfold localizedWellAction localizedWellIntegrand + nlinarith only [h] + have h := integral_mono (localizedWellAction_square_integrable hfreq u w) + ((localizedWellIntegrand_integrable hfreq u u w).neg.const_mul PlanarSobolev.wellBound) hp + simp only [Pi.neg_apply] at h + rw [integral_const_mul, integral_neg, localizedWellIntegrand_integral hfreq] at h + exact h.trans (mul_le_mul_of_nonneg_left (neg_le_abs _) PlanarSobolev.wellBound_nonnegative) + +theorem localizedWellAction_square_decay {freq D : ℝ} (hfreq : 0 < freq) + (u w : PlanarPosition) (hd : D ≤ ‖u-w‖) : + (∫ x, localizedWellAction freq u w x ^ 2) ≤ + (PlanarSobolev.wellBound * planarWellMatrixConstant) * Real.exp (-(19/10 : ℝ)*D) := by + exact (localizedWellAction_square_le_matrix hfreq u w).trans + ((mul_le_mul_of_nonneg_left (planarWellMatrix_two_far u u w hd hd) + PlanarSobolev.wellBound_nonnegative).trans_eq (mul_assoc _ _ _).symm) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCoercivity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCoercivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9f1cb3a710d3788ebbc598429d67b97f131c3ce --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCoercivity.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoreOrbitalProjection + +namespace OAI + +/-! The positive tensor-complement gap retains kinetic coercivity. The +potential lower bound is uniform in the growing slab dimensions. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem gap_kinetic_coercivity {F K M C g : ℝ} + (hM : 0 ≤ M) (hC : 0 ≤ C) (hg : 0 < g) + (hgap : g*M ≤ F) (hkin : K-C*M ≤ F) : + (g/(2*(C+g+1)))*(M+2*K) ≤ F := by + rw [div_mul_eq_mul_div] + apply (div_le_iff₀ (by positivity : 0 < 2*(C+g+1))).2 + have h₁ := mul_le_mul_of_nonneg_left hkin (by positivity : 0 ≤ 2*g) + have h₂ := mul_le_mul_of_nonneg_left hgap (by positivity : 0 ≤ 2*(C+1)) + nlinarith only [h₁,h₂,mul_nonneg hg.le hM] + +theorem planarWellSum_uniform_lower {m : ℕ} (u : Fin m → PlanarPosition) + (x : PlanarPosition) : -(m:ℝ)*PlanarSobolev.wellBound ≤ planarWellSum u x := by + have h := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + (abs_le.mp (by simpa only [Real.norm_eq_abs] using PlanarSobolev.wellBound_spec (x-u i))).1) + simpa only [planarWellSum,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + mul_neg,neg_mul] using h + +theorem manufacturedSlab_uniform_lower {rho H S freq scale η : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) (hscale : 0 ≤ scale) + (hrelation : freq^2 = 4*Real.pi*rho) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) (x : Position) : + -(((m:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho) ≤ + manufacturedSlabPotential rho H S freq scale u x := by + have h := manufacturedSlabPotential_lower hrho hH hS.le hscale hrelation u hsep hη hcoeff x + have hp := planarWellSum_uniform_lower u (positionSplitCoordinates x).1 + have hv : 0 ≤ verticalCapPotential freq S (positionSplitCoordinates x).2 := by + unfold verticalCapPotential + positivity + have hratio : 6*Real.pi*rho*S^3/H ≤ 6*Real.pi*rho := by + apply (div_le_iff₀ hH).2 + exact mul_le_mul_of_nonneg_left hSH (by positivity) + linarith + +theorem boundedPotentialForm_kinetic_lower {n : ℕ} + (V : Configuration n → ℝ) (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) + (C : ℝ) (hC : ∀ x, -C ≤ V x) (u : Coulomb.H1Vector n) : + Coulomb.kinetic u-C*Coulomb.mass u ≤ boundedPotentialForm V u := by + have hp (s : SpinConfiguration n) := integral_mono + ((u.value_L2 s).norm.integrable_sq.const_mul (-C)) + (bounded_state_potential_integrable u V hV B hB s) + (fun x => mul_le_mul_of_nonneg_right (hC x) (sq_nonneg ‖u.value s x‖)) + have h := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hp s) + simp only [integral_const_mul,← Finset.mul_sum] at h + change (-C)*Coulomb.mass u ≤ Coulomb.potentialForm V u at h + change Coulomb.kinetic u-C*Coulomb.mass u ≤ Coulomb.kinetic u+Coulomb.potentialForm V u + linarith + +theorem manufacturedSlab_manyElectron_kinetic_lower {rho H S freq scale η : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) (hscale : 0 ≤ scale) + (hrelation : freq^2 = 4*Real.pi*rho) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) {n : ℕ} (v : Coulomb.H1Vector n) : + Coulomb.kinetic v-(n:ℝ)*(((m:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v := by + let V (x : Configuration n) := ∑ i, manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + have hV : Continuous V := continuous_finsetSum _ (fun i _ => + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + (Coulomb.positionCLM i).continuous) + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hb (x : Configuration n) : |V x| ≤ (n:ℝ)*B := by + exact (Finset.abs_sum_le_sum_abs _ _).trans (by simpa using Finset.sum_le_sum (s := Finset.univ) (fun i _ => hB (Coulomb.position x i))) + apply boundedPotentialForm_kinetic_lower V hV _ hb + intro x + have h := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + manufacturedSlab_uniform_lower hrho hH hS hSH hscale hrelation u hsep hη hcoeff (Coulomb.position x i)) + simpa only [V,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,mul_neg] using h + +theorem manufacturedSlab_coercive_of_gap {rho H S freq scale η E g : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) (hscale : 0 ≤ scale) + (hrelation : freq^2 = 4*Real.pi*rho) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) {n : ℕ} (v : Coulomb.H1Vector n) + (hE : 0 ≤ E) (hg : 0 < g) + (hgap : ((n:ℝ)*E+g)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v) : + (g/(2*((n:ℝ)*(((m:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+E)+g+1)))* + (Coulomb.mass v+2*Coulomb.kinetic v) ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v-(n:ℝ)*E*Coulomb.mass v := by + have hk := manufacturedSlab_manyElectron_kinetic_lower hrho hH hS hSH hscale + hrelation u hsep hη hcoeff v + have hC : 0 ≤ (n:ℝ)*(((m:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+E) := by + have hw := PlanarSobolev.wellBound_nonnegative + positivity + apply gap_kinetic_coercivity (Coulomb.mass_nonneg v) hC hg + · nlinarith only [hgap] + · nlinarith only [hk] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCompactQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCompactQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fa9a6b48078f398927f4508d1cfd0cbd40e235d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedCompactQuadrature.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceExceptionalVolume + +namespace OAI + +/-! Fourth-order quadrature for a compact orbital density under the actual +manufactured transport. The bound depends on the compact source radius and +the well-support volume, and is independent of the horizontal slab area. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem manufactured_compact_source_quadrature : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (q : Position → ℝ), ContDiff ℝ 4 q → HasCompactSupport q → + ∀ (B : ℝ), 0 ≤ B → + (∀ k : ℕ, k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k q x‖ ≤ B) → + (∀ k : ℕ, k ≤ 4 → (∫ x, ‖iteratedFDeriv ℝ k q x‖) ≤ B) → + ∀ (v : PlanarPosition) (R : ℝ), 1 ≤ R → + (∀ x, q x ≠ 0 → ‖x-planarCenter v‖ ≤ R) → + ∀ (freq scale S : ℝ), 1 ≤ S → ∀ (m : ℕ) (u : Fin m → PlanarPosition), + ∀ (G : Position → Position), ContDiff ℝ 4 G → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x = x) → + ∀ (D : ℝ), 0 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k G x‖ ≤ D^k) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ 1 → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => NeutralAtom.potentialOf q (G x)))| ≤ + (24*((2*Real.pi+1)*B)*D^4*(216*m*S+1728*R^3)+2048*Real.pi*C*B)*h^4 := by + classical + obtain ⟨C,hC,hgrid⟩ := compact_source_grid_error + refine ⟨C,hC,?_⟩ + intro q hq hc B hB hb hi v R hR hsupp freq scale S hS m u G hG hfix D hD hGD + ι _ index hindex h hh hh1 + have hR0 : 0 < R := lt_of_lt_of_le zero_lt_one hR + have hg := hgrid q hq hc B hB hb hi v R hR0 hsupp G hG + (tsupport (manufacturedWellField freq scale S u)) hfix D hD hGD + index hindex h hh (hh1.trans hR) + have hv := source_exceptional_volume index hindex hh hh1 hR0.le hS freq scale u v + have hvol : (Fintype.card {i // sourceExceptionalCell + (tsupport (manufacturedWellField freq scale S u)) v R (gaussCellCenter h (index i)) h}:ℝ)*h^3 ≤ + 216*m*S+1728*R^3 := by + apply hv.trans + have hsize : (4*R+2*h)^3 ≤ (6*R)^3 := by + apply pow_le_pow_left₀ (by positivity) + linarith + nlinarith only [hsize] + have hnearterm := mul_le_mul_of_nonneg_left hvol + (show 0 ≤ 24*((2*Real.pi+1)*B)*D^4*h^4 by positivity) + have hRpow : 1 ≤ R^2 := one_le_pow₀ hR + have hfar : 2048*Real.pi*C*B*h^4/R^2 ≤ 2048*Real.pi*C*B*h^4 := by + exact div_le_self (by positivity) hRpow + apply hg.trans + nlinarith only [hnearterm,hfar] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..8383f4caf27a496506c5851a75fa9fc2dddd454f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplement.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOneElectronGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedComplement + +namespace OAI + +/-! The manufactured field has a positive gap above its one-orbital energy +on the complement of the actual orthonormalized modes. All localization losses +are retained explicitly; they are not charged to the final energy precision. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def manufacturedSpectralLoss (γ : ℝ) (m : ℕ) (D η freq S rho H δ : ℝ) : ℝ := + planarSiteDerivativeBound D^2+ + γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8))+ + verticalCutoffDerivativeBound S^2/2+ + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)+ + freq*η+δ*PlanarSobolev.wellBound+6*Real.pi*rho*S^3/H + +theorem manufacturedSpectralLevel_eq (γ : ℝ) (m : ℕ) (D η freq S rho H δ : ℝ) : + manufacturedSpectralLevel γ m D η freq S rho H δ = + -1/2+freq/2+γ-manufacturedSpectralLoss γ m D η freq S rho H δ := by + unfold manufacturedSpectralLevel manufacturedSpectralLoss planarSpectralLevel verticalSpectralLevel + ring + +theorem manufacturedSpectralLevel_lower {γ D η freq S rho H δ : ℝ} {m : ℕ} + (hloss : manufacturedSpectralLoss γ m D η freq S rho H δ ≤ γ/2) : + -1/2+freq/2+γ/2 ≤ manufacturedSpectralLevel γ m D η freq S rho H δ := by + rw [manufacturedSpectralLevel_eq] + linarith + +theorem manufacturedSlab_corrected_complement_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η freq S rho H scale δ : ℝ), + 8 ≤ D → 0 < η → ∀ hfreq : 0 < freq, 0 < S → 0 ≤ rho → 0 < H → 0 ≤ scale → 0 ≤ δ → + freq^2 = 4*Real.pi*rho → 3*freq/2 ≤ freq^2*S^2/8 → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + γ*(1+η)*(1+m*localizedOverlapBound D) ≤ freq*(1+η) → + m*localizedOverlapBound D ≤ 1/2 → + manufacturedSpectralLoss γ m D η freq S rho H δ ≤ γ/2 → + ∀ v : Coulomb.H1Vector 1, + (∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = 0) → + (-1/2+freq/2+γ/2)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v := by + obtain ⟨γ,hγ,hsmall,hbound⟩ := manufacturedSlab_weakH1_lower hp hv hdensity + refine ⟨γ,hγ,hsmall,fun m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom hover hloss v ho => ?_⟩ + have hb := hbound m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom v + rw [corrected_graph_orthogonal_implies_raw hfreq u hsep hover v ho, + mul_zero,sub_zero] at hb + have hm : 0 ≤ Coulomb.mass v := + Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _)) + exact (mul_le_mul_of_nonneg_right (manufacturedSpectralLevel_lower hloss) hm).trans hb + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplementBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplementBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..f48140ccac58bd29a8eaaa38e10183ab43abd197 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedComplementBudget.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ComplementScaleBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev + +namespace OAI + +/-! Explicit polynomial bounds for the actual kinetic budget and the +coercive complement allowance in the manufactured Hubbard comparison. -/ + +noncomputable section +namespace ContinuumCoulomb + +def manufacturedKineticBudgetConstant (freq rho : ℝ) : ℝ := + 2*PlanarSobolev.wellBound+6*Real.pi*rho+((-1/2:ℝ)+freq/2)+2 + +theorem manufacturedKineticBudgetConstant_positive {freq rho : ℝ} + (hf : 1 ≤ freq) (hrho : 0 ≤ rho) : 0 < manufacturedKineticBudgetConstant freq rho := by + have hW := PlanarSobolev.wellBound_nonnegative + have hA : 0 ≤ (-1/2:ℝ)+freq/2 := by linarith + unfold manufacturedKineticBudgetConstant + positivity + +theorem manufactured_kinetic_complement_budgets {freq rho γ M η ε : ℝ} + (hf : 1 ≤ freq) (hrho : 0 ≤ rho) (hγ : 0 < γ) (hγ1 : γ ≤ 1/4) + (hM : 1 ≤ M) (hη : 0 ≤ η) (hη1 : η ≤ 1) (hε : ε ≤ 1) : + M*((M+η)*PlanarSobolev.wellBound+6*Real.pi*rho+((-1/2:ℝ)+freq/2))+2*M*ε ≤ + manufacturedKineticBudgetConstant freq rho*M^2 ∧ + (γ/(16*manufacturedKineticBudgetConstant freq rho))/M^2 ≤ + (γ/8)/(2*(M*((M+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+γ/8+1)) := by + let A := 6*Real.pi*rho+((-1/2:ℝ)+freq/2) + let C := manufacturedKineticBudgetConstant freq rho + have hW := PlanarSobolev.wellBound_nonnegative + have hA : 0 ≤ A := by + have hE : 0 ≤ (-1/2:ℝ)+freq/2 := by linarith + exact add_nonneg (mul_nonneg (mul_nonneg (by norm_num) Real.pi_pos.le) hrho) hE + have hC : 0 < C := manufacturedKineticBudgetConstant_positive hf hrho + have hM0 : 0 < M := lt_of_lt_of_le zero_lt_one hM + have hT : M*((M+η)*PlanarSobolev.wellBound+A) ≤ (2*PlanarSobolev.wellBound+A)*M^2 := by + have hsum : M+η ≤ 2*M := by linarith + have hterm := add_le_add (mul_le_mul_of_nonneg_right hsum hW) + (le_mul_of_one_le_right hA hM) + have h := mul_le_mul_of_nonneg_left hterm hM0.le + convert h using 1 + ring + have hK : 2*M*ε ≤ 2*M^2 := by + have h := mul_le_mul_of_nonneg_left hε (show 0 ≤ 2*M by positivity) + nlinarith [sq_nonneg (M-1)] + have hγb : γ/8+1 ≤ 2*M^2 := by nlinarith [sq_nonneg (M-1)] + have hden : 2*(M*((M+η)*PlanarSobolev.wellBound+A)+γ/8+1) ≤ 2*C*M^2 := by + dsimp only [C,manufacturedKineticBudgetConstant,A] at * + nlinarith only [hT,hγb] + have hden0 : 0 < 2*(M*((M+η)*PlanarSobolev.wellBound+A)+γ/8+1) := by positivity + constructor + · dsimp only [manufacturedKineticBudgetConstant] + dsimp only [A] at hT + nlinarith only [hT,hK] + · have hfinal : (γ/(16*C))/M^2 ≤ (γ/8)/(2*(M*((M+η)*PlanarSobolev.wellBound+A)+γ/8+1)) := by + calc + _ = (γ/8)/(2*C*M^2) := by field_simp; norm_num + _ ≤ _ := div_le_div_of_nonneg_left (by positivity) hden0 hden + convert hfinal using 1 + dsimp [A,C] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedEuler.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedEuler.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb0a94b25d92b7fd944afa690ff9c306fbc8782c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedEuler.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedVelocityEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserNumericalBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerInitialBox + +namespace OAI + +/-! The literal clipped Euler iteration approximates the actual manufactured +Moser flow. Its step count and denominator are fixed polynomials in the +requested unary precision, uniformly over all valid input geometries. -/ + +noncomputable section +namespace ContinuumCoulomb.ManufacturedEuler +open CappedKernelProgram (Triple position) +open EulerRegisters + +abbrev Environment := ℕ×((ℚ×ℚ)×List (ℚ×ℚ)) + +def evaluate (rho : ℕ) (e : Environment) (t : ℚ) (q : Triple) : Triple := + ManufacturedVelocityEvaluation.value rho e.1 e.2.1.1 e.2.1.2 e.2.2 t q + +def approximate (rho U C P : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) (q : Triple) : Triple := + let N := steps C P + let D := denominator C P + let B := boxNumerator U D q + trajectory (evaluate rho) (N,((scale,S),sites)) N D B (round D B q) N + +theorem approximation_error (rho U C P : ℕ) (hrho : 0 < rho) (hC : 0 < C) + (hExp : Real.exp (U:ℝ) ≤ C) (hUC : (U:ℝ)*(1+(U:ℝ)) ≤ C) + {scale S : ℚ} (hscale : (1:ℝ) ≤ scale) (hS : (1:ℝ) ≤ S) + {m : ℕ} (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖PlanarForcingProgram.position (u i)-PlanarForcingProgram.position (u j)‖) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) + (hcharge : ∀ x, |manufacturedCharge (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) x| ≤ (rho:ℝ)/2) + (hbound : ∀ t ∈ Set.Icc (0:ℝ) 1, ∀ x, + ‖moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) t x‖ ≤ U) + (hLip : ∀ s ∈ Set.Icc (0:ℝ) 1, ∀ t ∈ Set.Icc (0:ℝ) 1, ∀ x y, + ‖moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) s x- + moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) t y‖ ≤ + (U:ℝ)*(|s-t|+‖x-y‖)) + (G : Position → ℝ → Position) + (hG : IsUnitTimeFlow (moserVelocity (rho:ℝ) + (manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)))) G) + (q : Triple) : + ‖position (approximate rho U C P scale S (List.ofFn u) q)-G (position q) 1‖ ≤ + ((P:ℝ)+1)⁻¹ := by + let V := manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) + let N := steps C P + let D := denominator C P + let B := boxNumerator U D q + let e : Environment := (N,((scale,S),List.ofFn u)) + let z := G (position q) + have hN : 0 < N := steps_positive hC + have hD : 0 < D := pow_pos hN _ + have hz0 : z 0 = position q := hG.1 _ + have hz : ∀ t ∈ Set.Icc (0:ℝ) 1, + HasDerivWithinAt z (moserVelocity (rho:ℝ) V t (z t)) (Set.Icc (0:ℝ) 1) t := hG.2 _ + have hzbox : ∀ t ∈ Set.Icc (0:ℝ) 1, ∀ a, |z t a| ≤ (B:ℝ)/(D:ℝ) := by + have hh := trajectory_coordinate_box (moserVelocity (rho:ℝ) V) z + (Nat.cast_nonneg U) hz (fun t ht => hbound t ht _) (fun a => by + rw [hz0] + exact inputRadius_bound q a) + intro t ht a + dsimp [B] + rw [boxNumerator_ratio hD] + exact (hh t ht a).trans (by linarith) + have heval (n : ℕ) (hn : n < N) : + ‖position (evaluate rho e ((n:ℚ)*(N:ℚ)⁻¹) + (trajectory (evaluate rho) e N D B (round D B q) n))- + moserVelocity (rho:ℝ) V ((n:ℝ)/N) + (position (trajectory (evaluate rho) e N D B (round D B q) n))‖ ≤ ((N:ℝ)+1)⁻¹ := by + have htime : (((n:ℚ)*(N:ℚ)⁻¹ : ℚ):ℝ) ∈ Set.Icc (0:ℝ) 1 := by + rw [Rat.cast_mul,Rat.cast_natCast,Rat.cast_inv,Rat.cast_natCast,← div_eq_mul_inv] + constructor + · positivity + · exact (div_le_one (by exact_mod_cast hN)).mpr (by exact_mod_cast hn.le) + have hh := ManufacturedVelocityEvaluation.approximation_error rho N hrho hscale hS u hu + hsep hc hcharge (t := (n:ℚ)*(N:ℚ)⁻¹) htime (trajectory (evaluate rho) e N D B (round D B q) n) + simpa only [evaluate,e,V,Rat.cast_mul,Rat.cast_natCast,Rat.cast_inv,div_eq_mul_inv] using hh + have he := trajectory_error (evaluate rho) e hN hD B (round D B q) + (moserVelocity (rho:ℝ) V) z (Nat.cast_nonneg U) (Nat.cast_nonneg U) + (show 0 ≤ ((N:ℝ)+1)⁻¹ by positivity) hz (fun t ht => hbound t ht _) hLip hzbox heval + rw [hz0] at he + have hinit := initial_round_error (C := U) hD q + have hb : (‖position (point D (round D B q))-position q‖+((N:ℝ)+1)⁻¹+ + (U:ℝ)*(1+(U:ℝ))/(N:ℝ)+3*(N:ℝ)/(D:ℝ))*Real.exp (U:ℝ) ≤ + (3/(D:ℝ)+((N:ℝ)+1)⁻¹+(U:ℝ)*(1+(U:ℝ))/(N:ℝ)+ + 3*(N:ℝ)/(D:ℝ))*Real.exp (U:ℝ) := by + exact mul_le_mul_of_nonneg_right + (add_le_add (add_le_add (add_le_add hinit le_rfl) le_rfl) le_rfl) + (Real.exp_pos _).le + exact he.trans (hb.trans (schedule_budget hC hExp hUC)) + +/-- Fixed program constants work simultaneously for every valid manufactured +field. No oracle for a potential, derivative, or flow value is used. -/ +theorem exists_uniform_constants (rho : ℕ) (hrho : 0 < rho) : + ∃ U C : ℕ, 0 < U ∧ 0 < C ∧ ∀ (P : ℕ) (scale S : ℚ), + (1:ℝ) ≤ scale → (1:ℝ) ≤ S → ∀ (m : ℕ) (u : Fin m → ℚ×ℚ), + Function.Injective u → + (∀ i j, i ≠ j → 3 ≤ ‖PlanarForcingProgram.position (u i)-PlanarForcingProgram.position (u j)‖) → + (∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) → + (∀ x, |manufacturedCharge (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) x| ≤ (rho:ℝ)/2) → + ∀ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i)))) G → + ∀ q : Triple, + ‖position (approximate rho U C P scale S (List.ofFn u) q)-G (position q) 1‖ ≤ + ((P:ℝ)+1)⁻¹ := by + obtain ⟨U,hU,hUb⟩ := exists_uniform_velocity_integer rho hrho + obtain ⟨C,hC⟩ := exists_nat_gt (max (Real.exp (U:ℝ)) ((U:ℝ)*(1+(U:ℝ)))) + have hCp : 0 < C := by + have hp : (0:ℝ) < C := (Real.exp_pos _).trans ((le_max_left _ _).trans_lt hC) + exact_mod_cast hp + refine ⟨U,C,hU,hCp,?_⟩ + intro P scale S hs hS m u hu hsep hc hcharge G hG q + let V := manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 _ _ _ _).of_le (by norm_num) + have hb : ∀ k ≤ 6, ∀ x, ‖iteratedFDeriv ℝ k V x‖ ≤ (MoserDifferenceBudget.guard:ℝ) := by + intro k hk x + exact (manufacturedWellField_derivative_bound (GaussianFrequency.frequency rho) + (show (0:ℝ) < scale by linarith) hS _ hsep hc hk x).trans MoserDifferenceBudget.guard_bound + obtain ⟨hbound,hLip⟩ := hUb V hV hb hcharge + exact approximation_error rho U C P hrho hCp ((le_max_left _ _).trans_lt hC).le + ((le_max_right _ _).trans_lt hC).le hs hS u hu hsep hc hcharge hbound hLip G hG q + +end ContinuumCoulomb.ManufacturedEuler + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFarGrid.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFarGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..5146d383a3c7c57e2607869d8c7cea8f0536938f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFarGrid.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedFarQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserFlowRegularity + +namespace OAI + +/-! The far part of the actual manufactured nuclear quadrature. Its error +has no factor depending on the horizontal area of the enclosing slab. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb + +theorem manufactured_moser_far_grid_error (hpublished : PublishedC4FlowInput) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (rho H S freq scale : ℝ) (m : ℕ) (u : Fin m → PlanarPosition), + 0 < rho → 0 ≤ H → 1 ≤ S → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ rho/2) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ (G : Position → ℝ → Position), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + Function.Bijective (fun x => G x 1) → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ D^k) → + ∀ (L : ℝ≥0), 0 < L → LipschitzWith L (fun x => G x 1) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (y : Position) (h : ℝ), 0 < h → h ≤ 1 → + (∀ i, positionCube (gaussCellCenter h (index i)) h ⊆ slabDomain H S) → + (∀ i, 4*(L:ℝ)*h ≤ ‖y-G (gaussCellCenter h (index i)) 1‖) → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)))| ≤ + 24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4) := by + obtain ⟨C,hC,hbound⟩ := transportedCoulomb_far_grid_hybrid_error + refine ⟨C,hC,?_⟩ + intro rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix D hD hGD L hL hLip + ι _ index hindex y h hh hh1 hsub hfar + let V := manufacturedWellField freq scale S u + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 freq scale S u).of_le (by norm_num) + have hGreg : ContDiff ℝ 4 (fun x => G x 1) := + (moser_flow_C4 hpublished hrho V hV hcharge G hflow).1 1 ⟨by norm_num,le_rfl⟩ + have he := hbound (fun x => G x 1) hGreg (tsupport V) (isClosed_tsupport V) hfix + D hD hGD L hL hLip index y h hh hfar + have ht := moser_inverseFifth_grid_sum_bound hpublished hrho hH (by linarith) V hV hcharge hsupp + G hflow hbij hfix hL hLip index hindex hh hsub y hfar + have hc := manufactured_cellHits_volume_bound index hindex hh hh1 hS freq scale u + have hs : 32*(∑ i, h^3/‖y-G (gaussCellCenter h (index i)) 1‖^5)+ + (∑ i, cellHits (tsupport V) (gaussCellCenter h (index i)) h*h^3) ≤ + 3072*Real.pi/((L:ℝ)*h)^2+216*m*S := by + have hi := add_le_add (mul_le_mul_of_nonneg_left ht (by norm_num : (0:ℝ) ≤ 32)) hc + convert hi using 1 + ring + have hC0 : 0 ≤ C := (by norm_num : (0:ℝ) ≤ 1).trans hC + apply he.trans + apply (mul_le_mul_of_nonneg_left hs (by positivity : 0 ≤ 24*C*D^4*h^4)).trans_eq + have hLn : (L:ℝ) ≠ 0 := ne_of_gt (by exact_mod_cast hL) + field_simp [hh.ne',hLn] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..11fff9b61b525e830ffe3fc6a228e7b2810ce166 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldBounds.lean @@ -0,0 +1,143 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarFieldBounds + +namespace OAI + +/-! Uniform derivatives through order six of the actual three-dimensional +manufactured field. Constants do not grow with the number of wells or slab width. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +private theorem linear_comp_six_bound {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] (L : E →L[ℝ] F) (f : F → ℝ) + (hf : ContDiff ℝ 6 f) {B D : ℝ} (hB : 0 ≤ B) (hD : 1 ≤ D) (hL : ‖L‖ ≤ D) + (hb : ∀ k ≤ 6, ∀ x, ‖iteratedFDeriv ℝ k f x‖ ≤ B) {k : ℕ} (hk : k ≤ 6) (x : E) : + ‖iteratedFDeriv ℝ k (f ∘ L) x‖ ≤ B*D^6 := by + rw [L.iteratedFDeriv_comp_right hf x (by exact_mod_cast hk)] + have h := (iteratedFDeriv ℝ k f (L x)).norm_compContinuousLinearMap_le (fun _ => L) + simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin] at h + calc + _ ≤ ‖iteratedFDeriv ℝ k f (L x)‖ * ‖L‖^k := h + _ ≤ B*D^k := mul_le_mul (hb k hk (L x)) + (pow_le_pow_left₀ (norm_nonneg L) hL k) (pow_nonneg (norm_nonneg L) k) hB + _ ≤ B*D^6 := mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD hk) hB + +def wellPlanarProjection : Position →L[ℝ] PlanarPosition := + (ContinuousLinearMap.fst ℝ PlanarPosition ℝ).comp positionSplitCoordinates.toContinuousLinearMap + +def wellVerticalProjection : Position →L[ℝ] ℝ := + (ContinuousLinearMap.snd ℝ PlanarPosition ℝ).comp positionSplitCoordinates.toContinuousLinearMap + +def wellPlanarDerivativeBound : ℝ := + (2*planarWellDerivativeConstant)*(max 1 ‖wellPlanarProjection‖)^6 + +private theorem cutoff_derivative_bound_exists : ∃ C : ℝ, 0 < C ∧ + ∀ k ≤ 6, ∀ z : ℝ, ‖iteratedFDeriv ℝ k (verticalCutoffBump : ℝ → ℝ) z‖ ≤ C := by + obtain ⟨B,hB,hb⟩ := verticalCutoffBump.hasCompactSupport.exists_bound_iteratedFDeriv + (𝕜 := ℝ) verticalCutoffBump.contDiff 6 + exact ⟨B+1, by linarith, fun k hk z => (hb k hk z).trans (by linarith)⟩ + +def wellCutoffDerivativeConstant : ℝ := Classical.choose cutoff_derivative_bound_exists + +def wellCutoffDerivativeBound : ℝ := + wellCutoffDerivativeConstant*(max 1 (2*‖wellVerticalProjection‖))^6 + +def manufacturedFieldDerivativeConstant : ℝ := + 64*wellCutoffDerivativeBound*wellPlanarDerivativeBound + +theorem manufacturedFieldDerivativeConstant_positive : 0 < manufacturedFieldDerivativeConstant := by + have hp := planarWellDerivativeConstant_positive + have hc := (Classical.choose_spec cutoff_derivative_bound_exists).1 + unfold manufacturedFieldDerivativeConstant wellCutoffDerivativeBound + wellPlanarDerivativeBound wellCutoffDerivativeConstant + positivity + +private theorem wellPlanar_bound_nonnegative : 0 ≤ wellPlanarDerivativeBound := by + have hC := planarWellDerivativeConstant_positive.le + unfold wellPlanarDerivativeBound + positivity + +private theorem wellCutoff_bound_nonnegative : 0 ≤ wellCutoffDerivativeBound := by + have h := (Classical.choose_spec cutoff_derivative_bound_exists).1 + unfold wellCutoffDerivativeBound wellCutoffDerivativeConstant + positivity + +private theorem manufacturedField_planar_bound (freq : ℝ) {scale : ℝ} (hscale : 0 < scale) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) + (hcounter : ∀ i, localizedCounterterm freq u i ≤ scale) + {k : ℕ} (hk : k ≤ 6) (x : Position) : + ‖iteratedFDeriv ℝ k (fun y : Position => + countertermWellSum freq scale u (positionSplitCoordinates y).1) x‖ ≤ + wellPlanarDerivativeBound := by + have hC := planarWellDerivativeConstant_positive.le + exact linear_comp_six_bound wellPlanarProjection (countertermWellSum freq scale u) + ((countertermWellSum_C7 freq scale u).of_le (by norm_num)) + (by positivity) (le_max_left _ _) (le_max_right _ _) + (fun j hj r => countertermWellSum_derivative_bound freq hscale u hsep hcounter hj r) hk x + +private theorem manufacturedField_cutoff_bound {S : ℝ} (hS : 1 ≤ S) + {k : ℕ} (hk : k ≤ 6) (x : Position) : + ‖iteratedFDeriv ℝ k (fun y : Position => slabWellCutoff S (positionSplitCoordinates y).2) x‖ ≤ + wellCutoffDerivativeBound := by + let L : Position →L[ℝ] ℝ := (2/S) • wellVerticalProjection + have hS0 : 0 < S := lt_of_lt_of_le zero_lt_one hS + have hscale : |2/S| ≤ 2 := by + rw [abs_of_nonneg (by positivity)] + exact (div_le_iff₀ hS0).mpr (by linarith) + have hL : ‖L‖ ≤ max 1 (2*‖wellVerticalProjection‖) := by + dsimp only [L] + rw [norm_smul, Real.norm_eq_abs] + exact (mul_le_mul_of_nonneg_right hscale (norm_nonneg _)).trans (le_max_right _ _) + exact linear_comp_six_bound L (verticalCutoffBump : ℝ → ℝ) + (verticalCutoffBump.contDiff : ContDiff ℝ 6 (verticalCutoffBump : ℝ → ℝ)) + (Classical.choose_spec cutoff_derivative_bound_exists).1.le (le_max_left _ _) hL + (Classical.choose_spec cutoff_derivative_bound_exists).2 hk x + +/-- A fixed bound for all six derivatives, uniform over every separated +site family, every admissible counterterm and every slab width at least one. -/ +theorem manufacturedWellField_derivative_bound (freq : ℝ) {scale S : ℝ} + (hscale : 0 < scale) (hS : 1 ≤ S) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) + (hcounter : ∀ i, localizedCounterterm freq u i ≤ scale) + {k : ℕ} (hk : k ≤ 6) (x : Position) : + ‖iteratedFDeriv ℝ k (manufacturedWellField freq scale S u) x‖ ≤ + manufacturedFieldDerivativeConstant := by + have hcut : ContDiff ℝ 6 (fun y : Position => + slabWellCutoff S (positionSplitCoordinates y).2) := + ((slabWellCutoff_smooth S).of_le (by simp)).comp + positionSplitCoordinates.contDiff.snd + have hplan : ContDiff ℝ 6 (fun y : Position => + countertermWellSum freq scale u (positionSplitCoordinates y).1) := + ((countertermWellSum_C7 freq scale u).of_le (show (6 : WithTop ℕ∞) ≤ 7 by norm_num)).comp + positionSplitCoordinates.contDiff.fst + have h := norm_iteratedFDeriv_mul_le hcut hplan x + (show (k : WithTop ℕ∞) ≤ 6 by exact_mod_cast hk) + change ‖iteratedFDeriv ℝ k (manufacturedWellField freq scale S u) x‖ ≤ _ at h + apply h.trans + calc + _ ≤ ∑ i ∈ Finset.range (k+1), (k.choose i : ℝ)*wellCutoffDerivativeBound*wellPlanarDerivativeBound := by + apply Finset.sum_le_sum + intro i hi + have hi' : i ≤ k := Nat.le_of_lt_succ (Finset.mem_range.mp hi) + exact mul_le_mul + (mul_le_mul_of_nonneg_left (manufacturedField_cutoff_bound hS (hi'.trans hk) x) + (Nat.cast_nonneg _)) + (manufacturedField_planar_bound freq hscale u hsep hcounter (Nat.sub_le k i |>.trans hk) x) + (norm_nonneg _) (mul_nonneg (Nat.cast_nonneg _) wellCutoff_bound_nonnegative) + _ = (2:ℝ)^k*wellCutoffDerivativeBound*wellPlanarDerivativeBound := by + rw [← Finset.sum_mul, ← Finset.sum_mul] + congr 2 + exact_mod_cast Nat.sum_range_choose k + _ ≤ 64*wellCutoffDerivativeBound*wellPlanarDerivativeBound := by + apply mul_le_mul_of_nonneg_right _ wellPlanar_bound_nonnegative + apply mul_le_mul_of_nonneg_right _ wellCutoff_bound_nonnegative + exact (pow_le_pow_right₀ (by norm_num : (1:ℝ) ≤ 2) hk).trans_eq (by norm_num) + _ = _ := rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b604765df3d8afe653d41b023a155d76db04c03 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFieldEvaluation.lean @@ -0,0 +1,231 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CountertermEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellNumerics +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.VerticalCutoffProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensitySample + +namespace OAI + +/-! A rational scalar evaluator for the actual manufactured well field. +The well-depth factors are clipped to their proved interval [1,2]. This +stabilizes every encoded input and preserves the valid-instance estimate. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.ManufacturedFieldEvaluation + +def coefficient (rho p : ℕ) (scale : ℚ) (sites : List (ℚ×ℚ)) (a : ℚ×ℚ) : ℚ := + 1+RationalSmoothTransition.clip (CountertermEvaluation.row rho p a sites/scale) + +def translate (r a : ℚ×ℚ) : ℚ×ℚ := (r.1-a.1,r.2-a.2) + +def planar (rho p : ℕ) (scale : ℚ) (sites : List (ℚ×ℚ)) (r : ℚ×ℚ) : ℚ := + (sites.map (fun a => coefficient rho p scale sites a * + PlanarWellNumerics.approximate p (translate r a))).sum + +def rawValue (rho p : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) + (x : CappedKernelProgram.Triple) : ℚ := + RationalSmoothTransition.clip (VerticalCutoffProgram.value (p,(S,x.2.2))) * + planar rho p scale sites (x.1,x.2.1) + +theorem coefficient_bounds (rho p : ℕ) (scale : ℚ) (sites : List (ℚ×ℚ)) (a : ℚ×ℚ) : + 1 ≤ coefficient rho p scale sites a ∧ coefficient rho p scale sites a ≤ 2 := by + have h := RationalSmoothTransition.clip_bounds (CountertermEvaluation.row rho p a sites/scale) + unfold coefficient + constructor <;> linarith + +theorem translate_position (r a : ℚ×ℚ) : + PlanarForcingProgram.position (translate r a) = + PlanarForcingProgram.position r-PlanarForcingProgram.position a := by + ext i + fin_cases i <;> simp [translate,PlanarForcingProgram.position] + +theorem coefficient_error (rho p : ℕ) (hrho : 0 < rho) {scale : ℚ} + (hscale : (1:ℝ) ≤ scale) {m : ℕ} (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) + (i : Fin m) + (hc : localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) : + |(coefficient rho p scale (List.ofFn u) (u i):ℝ)- + (1+localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i/(scale:ℝ))| ≤ + (m:ℝ)*2*(CountertermEvaluation.guard rho:ℝ)^3*((p:ℝ)+1)⁻¹ := by + let c := localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i + let E := (m:ℝ)*2*(CountertermEvaluation.guard rho:ℝ)^3*((p:ℝ)+1)⁻¹ + have hs : (0:ℝ) < scale := by linarith + have he : |((CountertermEvaluation.row rho p (u i) (List.ofFn u)/scale:ℚ):ℝ)- + c/(scale:ℝ)| ≤ E := by + rw [Rat.cast_div,← sub_div,abs_div,abs_of_pos hs] + exact ((div_le_div_of_nonneg_right (CountertermEvaluation.row_error rho p hrho u hu i) + hs.le).trans (div_le_self (by positivity) hscale)) + have hc0 : 0 ≤ c/(scale:ℝ) := div_nonneg (localizedCounterterm_nonnegative _ _ _) hs.le + have hc1 : c/(scale:ℝ) ≤ 1 := (div_le_one hs).mpr hc + simpa only [coefficient,Rat.cast_add,Rat.cast_one,add_sub_add_left_eq_sub] + using RationalSmoothTransition.clip_error _ hc0 hc1 he + +theorem well_abs_le_guard (rho : ℕ) (r : PlanarPosition) : + |manufacturedPlanarWell r| ≤ (CountertermEvaluation.guard rho:ℝ) := by + have h := planarWellDerivativeConstant_bound (k := 0) (by omega) r + rw [norm_iteratedFDeriv_zero,Real.norm_eq_abs] at h + exact h.trans (CountertermEvaluation.guard_bounds rho).2.2.2 + +private theorem product_error {a a' b b' A B ε η : ℝ} + (ha : |a'| ≤ A) (hb : |b| ≤ B) (he : |a'-a| ≤ ε) (hf : |b'-b| ≤ η) : + |a'*b'-a*b| ≤ A*η+ε*B := by + have hA : 0 ≤ A := (abs_nonneg _).trans ha + have he0 : 0 ≤ ε := (abs_nonneg _).trans he + rw [show a'*b'-a*b = a'*(b'-b)+(a'-a)*b by ring] + exact (abs_add_le _ _).trans (by + rw [abs_mul,abs_mul] + exact add_le_add (mul_le_mul ha hf (abs_nonneg _) hA) + (mul_le_mul he hb (abs_nonneg _) he0)) + +theorem planar_error (rho p : ℕ) (hrho : 0 < rho) {scale : ℚ} + (hscale : (1:ℝ) ≤ scale) {m : ℕ} (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) (r : ℚ×ℚ) : + |(planar rho p scale (List.ofFn u) r:ℝ)- + countertermWellSum (GaussianFrequency.frequency rho) scale + (fun i => PlanarForcingProgram.position (u i)) (PlanarForcingProgram.position r)| ≤ + ((m:ℝ)*2+(m:ℝ)^2*2*(CountertermEvaluation.guard rho:ℝ)^4)*((p:ℝ)+1)⁻¹ := by + rw [planar,List.map_ofFn,List.sum_ofFn,Rat.cast_sum] + unfold countertermWellSum + rw [← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + have hs : ∀ i : Fin m, + |(coefficient rho p scale (List.ofFn u) (u i):ℝ) * + (PlanarWellNumerics.approximate p (translate r (u i)):ℝ)- + (1+localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i/(scale:ℝ))* + manufacturedPlanarWell (PlanarForcingProgram.position r-PlanarForcingProgram.position (u i))| ≤ + 2*((p:ℝ)+1)⁻¹+ + ((m:ℝ)*2*(CountertermEvaluation.guard rho:ℝ)^3*((p:ℝ)+1)⁻¹)* + (CountertermEvaluation.guard rho:ℝ) := by + intro i + have hb := coefficient_bounds rho p scale (List.ofFn u) (u i) + have hab : |(coefficient rho p scale (List.ofFn u) (u i):ℝ)| ≤ 2 := by + have hl : (1:ℝ) ≤ coefficient rho p scale (List.ofFn u) (u i) := by exact_mod_cast hb.1 + have hh : (coefficient rho p scale (List.ofFn u) (u i):ℝ) ≤ 2 := by exact_mod_cast hb.2 + rw [abs_of_nonneg (by linarith)] + exact hh + have he := PlanarWellNumerics.approximation_error p (translate r (u i)) + rw [translate_position] at he + exact product_error hab (well_abs_le_guard rho _) (coefficient_error rho p hrho hscale u hu i (hc i)) he + calc + _ ≤ ∑ _i : Fin m, (2*((p:ℝ)+1)⁻¹+ + ((m:ℝ)*2*(CountertermEvaluation.guard rho:ℝ)^3*((p:ℝ)+1)⁻¹)* + (CountertermEvaluation.guard rho:ℝ)) := by + apply Finset.sum_le_sum + intro i _ + simpa only [Function.comp_apply,Rat.cast_mul] using hs i + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +theorem planar_exact_bound (rho : ℕ) {scale : ℚ} (hscale : (1:ℝ) ≤ scale) + {m : ℕ} (u : Fin m → ℚ×ℚ) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) (r : PlanarPosition) : + |countertermWellSum (GaussianFrequency.frequency rho) scale + (fun i => PlanarForcingProgram.position (u i)) r| ≤ + 2*(m:ℝ)*(CountertermEvaluation.guard rho:ℝ) := by + have hs : (0:ℝ) < scale := by linarith + unfold countertermWellSum + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _i : Fin m, 2*(CountertermEvaluation.guard rho:ℝ) := by + apply Finset.sum_le_sum + intro i _ + have hc0 := div_nonneg (localizedCounterterm_nonnegative + (GaussianFrequency.frequency rho) (fun j => PlanarForcingProgram.position (u j)) i) hs.le + have hc1 := (div_le_one hs).mpr (hc i) + rw [abs_mul,abs_of_nonneg (by linarith : 0 ≤ 1+ + localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i/(scale:ℝ))] + exact mul_le_mul (by linarith) (well_abs_le_guard rho _) (abs_nonneg _) (by norm_num) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +theorem raw_error (rho p : ℕ) (hrho : 0 < rho) {scale : ℚ} + (hscale : (1:ℝ) ≤ scale) (S : ℚ) {m : ℕ} (u : Fin m → ℚ×ℚ) + (hu : Function.Injective u) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) + (x : CappedKernelProgram.Triple) : + |(rawValue rho p scale S (List.ofFn u) x:ℝ)- + manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) (CappedKernelProgram.position x)| ≤ + (2*(m:ℝ)+2*(m:ℝ)*(CountertermEvaluation.guard rho:ℝ)+ + 2*(m:ℝ)^2*(CountertermEvaluation.guard rho:ℝ)^4)*((p:ℝ)+1)⁻¹ := by + have hcut := slabWellCutoff_bounds (S:ℝ) (x.2.2:ℝ) + have hecut := RationalSmoothTransition.clip_error + (VerticalCutoffProgram.value (p,(S,x.2.2))) hcut.1 hcut.2 + (VerticalCutoffProgram.approximation_error (p,(S,x.2.2))) + have hcb := RationalSmoothTransition.clip_bounds (VerticalCutoffProgram.value (p,(S,x.2.2))) + have hab : |(RationalSmoothTransition.clip (VerticalCutoffProgram.value (p,(S,x.2.2))):ℝ)| ≤ 1 := by + have hl : (0:ℝ) ≤ RationalSmoothTransition.clip (VerticalCutoffProgram.value (p,(S,x.2.2))) := + by exact_mod_cast hcb.1 + have hh : (RationalSmoothTransition.clip (VerticalCutoffProgram.value (p,(S,x.2.2))):ℝ) ≤ 1 := + by exact_mod_cast hcb.2 + simpa only [abs_of_nonneg hl] using hh + have he := product_error hab + (planar_exact_bound rho hscale u hc (PlanarForcingProgram.position (x.1,x.2.1))) hecut + (planar_error rho p hrho hscale u hu hc (x.1,x.2.1)) + calc + _ ≤ 1*((m:ℝ)*2+(m:ℝ)^2*2*(CountertermEvaluation.guard rho:ℝ)^4)*((p:ℝ)+1)⁻¹+ + ((p:ℝ)+1)⁻¹*(2*(m:ℝ)*(CountertermEvaluation.guard rho:ℝ)) := by + simpa only [rawValue,Rat.cast_mul,manufacturedWellField,RawDensitySample.position_split, + Prod.fst,Prod.snd,one_mul] using he + _ = _ := by ring + +def precision (rho m P : ℕ) : ℕ := 16*(CountertermEvaluation.guard rho)^4*(m+1)^2*(P+1) + +def value (rho P : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) + (x : CappedKernelProgram.Triple) : ℚ := rawValue rho (precision rho sites.length P) scale S sites x + +theorem precision_budget (rho m P : ℕ) : + (2*(m:ℝ)+2*(m:ℝ)*(CountertermEvaluation.guard rho:ℝ)+ + 2*(m:ℝ)^2*(CountertermEvaluation.guard rho:ℝ)^4)* + ((precision rho m P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ := by + let C : ℝ := CountertermEvaluation.guard rho + let M : ℝ := m + have hC : 1 ≤ C := by dsimp [C]; exact_mod_cast (CountertermEvaluation.guard_bounds rho).1 + have hM : 0 ≤ M := Nat.cast_nonneg _ + have hC4 : 1 ≤ C^4 := one_le_pow₀ hC + have hc4 : C ≤ C^4 := le_self_pow₀ hC (by decide) + have hm : M ≤ (M+1)^2 := by nlinarith + have hm2 : M^2 ≤ (M+1)^2 := by nlinarith + have h1 : M ≤ (M+1)^2*C^4 := hm.trans (le_mul_of_one_le_right (sq_nonneg _) hC4) + have h2 : M*C ≤ (M+1)^2*C^4 := mul_le_mul hm hc4 (by linarith) (sq_nonneg _) + have h3 : M^2*C^4 ≤ (M+1)^2*C^4 := mul_le_mul_of_nonneg_right hm2 (by positivity) + have hb : 2*M+2*M*C+2*M^2*C^4 ≤ 16*C^4*(M+1)^2 := by nlinarith + have hP : (0:ℝ) < (P:ℝ)+1 := by positivity + have hprec : (precision rho m P:ℝ) = 16*C^4*(M+1)^2*((P:ℝ)+1) := by + simp only [precision,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_pow,Nat.cast_add,Nat.cast_one,C,M] + change (2*M+2*M*C+2*M^2*C^4)*((precision rho m P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ + apply (mul_inv_le_iff₀ (by positivity : (0:ℝ) < (precision rho m P:ℝ)+1)).mpr + rw [hprec] + have heq : ((P:ℝ)+1)⁻¹*(16*C^4*(M+1)^2*((P:ℝ)+1)+1) = + 16*C^4*(M+1)^2+((P:ℝ)+1)⁻¹ := by field_simp + rw [heq] + exact hb.trans (le_add_of_nonneg_right (inv_nonneg.mpr hP.le)) + +theorem approximation_error (rho P : ℕ) (hrho : 0 < rho) {scale : ℚ} + (hscale : (1:ℝ) ≤ scale) (S : ℚ) {m : ℕ} (u : Fin m → ℚ×ℚ) + (hu : Function.Injective u) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) + (x : CappedKernelProgram.Triple) : + |(value rho P scale S (List.ofFn u) x:ℝ)- + manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) (CappedKernelProgram.position x)| ≤ + ((P:ℝ)+1)⁻¹ := by + unfold value + rw [List.length_ofFn] + exact (raw_error rho (precision rho m P) hrho hscale S u hu hc x).trans (precision_budget rho m P) + +end ContinuumCoulomb.ManufacturedFieldEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFrequency.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFrequency.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e8633b11f1034c6b47c5c5abe266cc189980ae1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedFrequency.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianFrequency + +namespace OAI + +/-! The frequency evaluated by the literal programs satisfies exactly the +oscillator/slab relation and lies in the uniform spectral-gap regime. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufactured_scale_positive {rho : ℕ} (hrho : 0 < rho) + {N : ℝ} (hN : 2 ≤ N) (k : ℕ) : 0 < (8/(rho:ℝ))*(N^k)^30 := by + have hr : (0:ℝ) < rho := by exact_mod_cast hrho + have hNp : 0 < N := by linarith + positivity + +theorem manufactured_mesh_positive {N : ℝ} (hN : 2 ≤ N) (k : ℕ) : + 0 < 1/(N^k)^10 := by + have hNp : 0 < N := by linarith + positivity + +theorem manufactured_frequency_relation (rho : ℕ) : + (GaussianFrequency.frequency rho)^2 = 4*Real.pi*(rho:ℝ) := by + unfold GaussianFrequency.frequency + exact Real.sq_sqrt (by positivity) + +theorem manufactured_frequency_ge_one {rho : ℕ} (hrho : 0 < rho) : + 1 ≤ GaussianFrequency.frequency rho := by + have hr : (1:ℝ) ≤ rho := by exact_mod_cast Nat.succ_le_iff.mpr hrho + have hp : (1:ℝ) ≤ 4*Real.pi := by linarith [Real.pi_gt_three] + unfold GaussianFrequency.frequency + apply Real.le_sqrt_of_sq_le + simpa only [one_mul,one_pow] using mul_le_mul hp hr (by norm_num : (0:ℝ) ≤ 1) (by positivity : 0 ≤ 4*Real.pi) + +theorem manufactured_frequency_positive {rho : ℕ} (hrho : 0 < rho) : + 0 < GaussianFrequency.frequency rho := lt_of_lt_of_le zero_lt_one (manufactured_frequency_ge_one hrho) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGapScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGapScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3e17d0ab31000af8a85d4764a2dea5d95cbdbc9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGapScale.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedComplement +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellScale +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedScale + +namespace OAI + +/-! Fixed localization parameters for the manufactured one-electron gap. +The number of sites enters only through the proved exponential count bound. -/ + +noncomputable section +open Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem planar_projection_loss_threshold {γ η ε : ℝ} + (hγ : 0 < γ) (hη : 0 < η) (hε : 0 < ε) : + ∃ R : ℝ, 8 ≤ R ∧ ∀ D : ℝ, R ≤ D → ∀ m : ℕ, + (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + planarSiteDerivativeBound D^2+ + γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8)) ≤ ε := by + have hexp : Tendsto (fun D : ℝ => Real.exp (-(19/320:ℝ)*D)) atTop (𝓝 0) := by + simpa only [Function.comp_def,id_eq,neg_mul] using + Real.tendsto_exp_neg_atTop_nhds_zero.comp + (tendsto_id.const_mul_atTop (by norm_num : (0:ℝ)<19/320)) + have hl : Tendsto (fun D : ℝ => planarSiteDerivativeBound D^2+ + γ*(1+η⁻¹)*planarSiteTailConstant*Real.exp (-(19/320:ℝ)*D)) atTop (𝓝 0) := by + simpa using (planarSiteDerivativeBound_tendsto.pow 2).add + (hexp.const_mul (γ*(1+η⁻¹)*planarSiteTailConstant)) + obtain ⟨R,hR⟩ := Filter.eventually_atTop.1 (hl.eventually (gt_mem_nhds hε)) + refine ⟨max 8 R,le_max_left _ _,fun D hD m hm => ?_⟩ + have hC : 0 ≤ γ*(1+η⁻¹)*planarSiteTailConstant := by + exact mul_nonneg (mul_nonneg hγ.le (by positivity)) planarSiteTailConstant_nonnegative + have ht : γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8)) ≤ + γ*(1+η⁻¹)*planarSiteTailConstant*Real.exp (-(19/320:ℝ)*D) := by + calc + _ = (γ*(1+η⁻¹)*planarSiteTailConstant)* + ((m:ℝ)*Real.exp (-(19/20:ℝ)*(D/8))) := by ring + _ ≤ (γ*(1+η⁻¹)*planarSiteTailConstant)* + (Real.exp ((19/320:ℝ)*D)*Real.exp (-(19/20:ℝ)*(D/8))) := + mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right hm (Real.exp_pos _).le) hC + _ = _ := by rw [← Real.exp_add]; congr 2; ring + exact (add_le_add le_rfl ht).trans (hR D ((le_max_right _ _).trans hD)).le + +theorem vertical_projection_loss_tendsto {freq : ℝ} (hfreq : 0 < freq) (η : ℝ) : + Tendsto (fun S : ℝ => verticalCutoffDerivativeBound S^2/2+ + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) atTop (𝓝 0) := by + have harg : Tendsto (fun S : ℝ => (freq/8)*S^2) atTop atTop := + (tendsto_pow_atTop (by norm_num : 2 ≠ 0)).const_mul_atTop (by positivity : 0 < freq/8) + have he : Tendsto (fun S : ℝ => Real.exp (-freq*S^2/8)) atTop (𝓝 0) := by + convert Real.tendsto_exp_neg_atTop_nhds_zero.comp harg using 1 + ext S + congr 1 + ring + simpa using ((verticalCutoffDerivativeBound_tendsto.pow 2).div_const 2).add + (he.const_mul (freq*(1+η⁻¹)*verticalCutoffTailConstant freq)) + +theorem vertical_projection_loss_threshold {freq ε : ℝ} + (hfreq : 0 < freq) (η : ℝ) (hε : 0 < ε) : + ∃ R : ℝ, 1 ≤ R ∧ ∀ S : ℝ, R ≤ S → + 3*freq/2 ≤ freq^2*S^2/8 ∧ + verticalCutoffDerivativeBound S^2/2+ + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8) ≤ ε := by + have hbar : Tendsto (fun S : ℝ => (freq^2/8)*S^2) atTop atTop := + (tendsto_pow_atTop (by norm_num : 2 ≠ 0)).const_mul_atTop (by positivity : 0 < freq^2/8) + have hb : ∀ᶠ S : ℝ in atTop, 3*freq/2 ≤ freq^2*S^2/8 := by + filter_upwards [hbar.eventually (eventually_ge_atTop (3*freq/2))] with S hS + convert hS using 1 + ring + have hl := (vertical_projection_loss_tendsto hfreq η).eventually (gt_mem_nhds hε) + obtain ⟨R,hR⟩ := Filter.eventually_atTop.1 (hb.and hl) + refine ⟨max 1 R,le_max_left _ _,fun S hS => ?_⟩ + obtain ⟨hb,hl⟩ := hR S ((le_max_right _ _).trans hS) + exact ⟨hb,hl.le⟩ + +theorem manufactured_gap_parameter_bounds {γ freq : ℝ} + (hγ : 0 < γ) (hsmall : γ ≤ 1/4) (hfreq : 1 ≤ freq) : + 0 < γ/(16*freq) ∧ freq*(γ/(16*freq)) = γ/16 ∧ + ∀ t : ℝ, t ≤ 1/2 → + γ*(1+γ/(16*freq))*(1+t) ≤ freq*(1+γ/(16*freq)) := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + have hη : 0 < γ/(16*freq) := by positivity + refine ⟨hη,by field_simp,fun t ht => ?_⟩ + have hgt : γ*(1+t) ≤ freq := by nlinarith + have hh := mul_le_mul_of_nonneg_right hgt (show 0 ≤ 1+γ/(16*freq) by positivity) + nlinarith only [hh] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridError.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e18fb64df465b17f5b8962724dd403b70ba3478 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridError.lean @@ -0,0 +1,135 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFarGrid +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNearGrid + +namespace OAI + +/-! Pointwise nuclear replacement on any finite grid: the smooth error is +quadratic in the mesh, and the only singular remainder is an explicit sum of +near-node kernels, suitable for the proved weak-H1 estimate. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb + +theorem gaussLatticePoint_mem_cube (h : ℝ) (hh : 0 ≤ h) + (k : Fin 3 → ℤ) (v : Fin 3 → Fin 2) : + gaussLatticePoint h (k,v) ∈ positionCube (gaussCellCenter h k) h := by + rw [← cubePoint_gaussLatticePoint] + have hb (i : Fin 3) : gaussNode (v i) ∈ Set.Icc (-1:ℝ) 1 := by + have hg := gaussNode_bounds (v i) + have ha := gaussAbscissa_bounds + constructor <;> linarith + exact cubePoint_mem_positionCube _ hh (hb 0) (hb 1) (hb 2) + +theorem near_cell_gauss_truncated {h : ℝ} (hh : 0 < h) + (G : Position → Position) {L : ℝ≥0} (hL : 0 < L) (hG : LipschitzWith L G) + (y : Position) (k : Fin 3 → ℤ) + (hnear : ‖y-G (gaussCellCenter h k)‖ ≤ 4*(L:ℝ)*h) : + positionCellGauss (gaussCellCenter h k) h (fun x => Coulomb.coulombKernel (y-G x)) = + (h^3/8)*∑ v : Fin 3 → Fin 2, + Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G (gaussLatticePoint h (k,v))) := by + rw [gaussCell_quadrature_lattice] + congr 1 + apply Finset.sum_congr rfl + intro v _ + exact transported_near_kernel_eq hh G hL hG hnear (gaussLatticePoint_mem_cube h hh.le k v) + +theorem manufactured_moser_grid_error (hpublished : PublishedC4FlowInput) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (rho H S freq scale : ℝ) (m : ℕ) (u : Fin m → PlanarPosition), + 0 < rho → 0 ≤ H → 1 ≤ S → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ rho/2) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ (G : Position → ℝ → Position), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + Function.Bijective (fun x => G x 1) → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ D^k) → + ∀ (L : ℝ≥0), 0 < L → LipschitzWith L (fun x => G x 1) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (y : Position) (h : ℝ), 0 < h → h ≤ 1 → + (∀ i, positionCube (gaussCellCenter h (index i)) h ⊆ slabDomain H S) → + |(∑ i, positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)))- + (∑ i, positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)))| ≤ + 24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4)+108*Real.pi*(L:ℝ)^2*h^2+ + (h^3/8)*∑ i, ∑ v : Fin 3 → Fin 2, + Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G (gaussLatticePoint h (index i,v)) 1) := by + obtain ⟨C,hC,hfar⟩ := manufactured_moser_far_grid_error hpublished + refine ⟨C,hC,?_⟩ + intro rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix D hD hGD L hL hLip + ι _ index hindex y h hh hh1 hsub + let V := manufacturedWellField freq scale S u + let p : ι → Prop := fun i => 4*(L:ℝ)*h ≤ ‖y-G (gaussCellCenter h (index i)) 1‖ + let Q : ι → ℝ := fun i => positionCellGauss (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)) + let I : ι → ℝ := fun i => positionCellIntegral (gaussCellCenter h (index i)) h + (fun x => Coulomb.coulombKernel (y-G x 1)) + let T : ι → ℝ := fun i => ∑ v : Fin 3 → Fin 2, + Coulomb.truncatedCoulomb (6*(L:ℝ)*h) (y-G (gaussLatticePoint h (index i,v)) 1) + have hfi : Function.Injective (fun i : {i // p i} => index i.val) := + fun i j hij => Subtype.ext (hindex hij) + have hni : Function.Injective (fun i : {i // ¬p i} => index i.val) := + fun i j hij => Subtype.ext (hindex hij) + have hn (i : {i // ¬p i}) : ‖y-G (gaussCellCenter h (index i.val)) 1‖ ≤ 4*(L:ℝ)*h := + (lt_of_not_ge i.property).le + have hf := hfar rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix D hD hGD + L hL hLip (fun i : {i // p i} => index i.val) hfi y h hh hh1 + (fun i => hsub i.val) (fun i => i.property) + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 freq scale S u).of_le (by norm_num) + have hnear := moser_near_grid_integral_bound hpublished hrho hH (by linarith) V hV hcharge hsupp + G hflow hbij hfix hL hLip (fun i : {i // ¬p i} => index i.val) hni hh + (fun i => hsub i.val) y hn + have hQn : (∑ i : {i // ¬p i}, Q i.val) ≤ (h^3/8)*∑ i, T i := by + calc + _ = (h^3/8)*∑ i : {i // ¬p i}, T i.val := by + simp only [Q,T,near_cell_gauss_truncated hh (fun x => G x 1) hL hLip y _ (hn _), + Finset.mul_sum] + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + have he := Fintype.sum_subtype_add_sum_subtype p T + have hp : 0 ≤ ∑ i : {i // p i}, T i.val := + Finset.sum_nonneg (fun i _ => Finset.sum_nonneg + (fun v _ => Coulomb.truncatedCoulomb_nonneg _ _)) + linarith + have hIp : 0 ≤ ∑ i : {i // ¬p i}, I i.val := by + apply Finset.sum_nonneg + intro i _ + have hi := moser_coulomb_integrableOn hpublished hrho hH (by linarith) V hV hcharge hsupp + G hflow hbij hfix y + rw [show I i.val = ∫ x in positionCube (gaussCellCenter h (index i.val)) h, + Coulomb.coulombKernel (y-G x 1) from + positionCellIntegral_eq_setIntegral _ hh.le _ (hi.mono_set (hsub i.val))] + exact setIntegral_nonneg (positionCube_isClosed _ _).measurableSet + (fun x _ => Coulomb.coulombKernel_nonneg _) + have hQp : 0 ≤ ∑ i : {i // ¬p i}, Q i.val := by + apply Finset.sum_nonneg + intro i _ + rw [show Q i.val = (h^3/8)*T i.val from + near_cell_gauss_truncated hh (fun x => G x 1) hL hLip y _ (hn i)] + exact mul_nonneg (by positivity) (Finset.sum_nonneg + (fun v _ => Coulomb.truncatedCoulomb_nonneg _ _)) + have heQ := Fintype.sum_subtype_add_sum_subtype p Q + have heI := Fintype.sum_subtype_add_sum_subtype p I + change |(∑ i, Q i)-(∑ i, I i)| ≤ _ + rw [← heQ,← heI] + calc + _ = |((∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val))+ + ((∑ i : {i // ¬p i}, Q i.val)-(∑ i : {i // ¬p i}, I i.val))| := by congr 1; ring + _ ≤ |(∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val)|+ + |(∑ i : {i // ¬p i}, Q i.val)-(∑ i : {i // ¬p i}, I i.val)| := abs_add_le _ _ + _ ≤ _ := by + have hnabs := abs_add_le (∑ i : {i // ¬p i}, Q i.val) (-(∑ i : {i // ¬p i}, I i.val)) + simp only [← sub_eq_add_neg,abs_neg,abs_of_nonneg hQp,abs_of_nonneg hIp] at hnabs + change |(∑ i : {i // p i}, Q i.val)-(∑ i : {i // p i}, I i.val)| ≤ _ at hf + change (∑ i : {i // ¬p i}, I i.val) ≤ _ at hnear + change _ ≤ _ + _ + (h^3/8)*∑ i, T i + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridGroundComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridGroundComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..328bf01ea90998d989779c2ccbb74fed43478399 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridGroundComparison.lean @@ -0,0 +1,123 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedHubbardComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGroundUpper +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridNuclei + +namespace OAI + +/-! The actual transported unit-charge cloud has two-sided physical ground +bounds obtained from the full-domain lower estimate and localized trials. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal + +def manufacturedGridError {ι : Type*} [Fintype ι] (index : ι → Fin 3 → ℤ) + (G : Position → Position) (rho H S freq scale h : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (y : Position) : ℝ := + gridNuclearPotential index G rho h y-(slabPotential rho H S y+manufacturedWellField freq scale S u y) + +theorem manufactured_grid_ground_bounds + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2=4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 1 ≤ C ∧ + ∀ (m n : ℕ) (D S H scale r ε η εM εG : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + ∀ hscale : 0 < scale, 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + 0 ≤ εM → 0 ≤ εG → + ∀ (u : Fin (m+1) → PlanarPosition), (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n+1:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ {ι : Type} [Fintype ι] [Nonempty ι] (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + (G : Position → Position) (hG : Function.Injective G) (h : ℝ) (hh : 0 < h), rho*h^3/8=scale⁻¹ → + ∀ B : ℝ, 0 ≤ B → + (∀ (w : Coulomb.H1Vector (n+2)) s i, + Integrable (fun x => |manufacturedGridError index G rho H S freq scale h u (Coulomb.position x i)| * ‖w.value s x‖^2) ∧ + (∫ x, |manufacturedGridError index G rho H S freq scale h u (Coulomb.position x i)| * ‖w.value s x‖^2) ≤ + B*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (i,k) x‖^2)) → + (∀ i j, Integrable (fun x => manufacturedGridError index G rho H S freq scale h u x* + continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x)) → + (∀ i j, |scale*correctedNuclearOneBodyMatrix rho H S freq scale u + (manufacturedGridError index G rho H S freq scale h u) i j-localizedOneBodyTarget scale freq u i j| ≤ εM) → + ∀ {Edge : Type} [Fintype Edge] (left right : Edge → Fin (m+1)) (t : Edge → ℝ), + (∀ i j, ‖(scale*planarHoppingMatrix u i j:ℂ)-graphHoppingMatrix m left right (fun e => (t e:ℂ)) i j‖ ≤ εG) → + n+2=m+1 → + let Hb := hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t + let Vsum := (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j) + let Eform := localizedHubbardFormError m freq D (εM+εG) + let A := Hb-Vsum-Eform + let e := 2*(n+2:ℝ)*ε + let K := (n+2:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+((-1/2:ℝ)+freq/2))+e + let g₀ := (γ/8)/(2*((n+2:ℕ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) + let center := scale^2*(n+2:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+scale*(Hb-Vsum) + ∀ g : ℝ, 0 < g → B*(n+2)+|A/scale|+g ≤ g₀ → + let I := 3*(e^2+(scale⁻¹)^2*(8*(n+2:ℝ)^3*K)+B^2*((n+2:ℝ)+2*K)*(n+2))/g + ((center-scale*Eform-scale^2*I:ℝ):EReal) ≤ + formGroundEnergy (dilatedNuclei (gridNuclei index hindex G hG hh) scale hscale.ne') (n+2) ∧ + formGroundEnergy (dilatedNuclei (gridNuclei index hindex G hG hh) scale hscale.ne') (n+2) ≤ + ((center+scale*Eform:ℝ):EReal) := by + obtain ⟨γ,R,S₀,δ,C,hγ,hγ1,hR,hS₀,hδ,hC,hlower⟩ := + manufacturedSlab_uniform_hubbard_lower hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,_hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγ1,hR.trans (le_max_left _ _),hS₀,hδ,hC,?_⟩ + intro m n D S H scale r ε η εM εG hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ hεM hεG + u hsep hcoeff herr hsmall ι _ _ index hindex G hG h hh hmatch B hB hfull hraw hmatrix Edge _ left right t hgraph hNe + dsimp only + intro g hg hsmallB + let F := manufacturedGridError index G rho H S freq scale h u + let Hb := hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t + let Vsum := (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j) + let Eform := localizedHubbardFormError m freq D (εM+εG) + let A := Hb-Vsum-Eform + let e := 2*(n+2:ℝ)*ε + let K := (n+2:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+((-1/2:ℝ)+freq/2))+e + let I := 3*(e^2+(scale⁻¹)^2*(8*(n+2:ℝ)^3*K)+B^2*((n+2:ℝ)+2*K)*(n+2))/g + let center := scale^2*(n+2:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+scale*(Hb-Vsum) + have hHp : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hSp : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + have hs := hover D ((le_max_right _ _).trans hD) (m+1) hm + have hcorr (i j : Fin (m+1)) : Integrable (fun x => F x*correctedLocalizedMode freq u i x*correctedLocalizedMode freq u j x) := + localizedLinearOrbital_weighted_integrable freq u F hraw _ _ + have hN := localizedSpin_nuclear_integrable u F hcorr + have hK := localizedSpin_hubbard_oneBody_error hrho hHp.le hSp.le hf u hη hcoeff F hcorr + left right t hεM hεG hmatrix hgraph + have hF : Measurable F := (gridNuclearPotential_measurable index G rho h).sub + (((slabPotential_continuous hrho hHp.le hSp.le).add (manufacturedWellField_C7 freq scale S u).continuous).measurable) + have hI (w : Coulomb.H1Vector (n+2)) : nuclearFormIntegrable F w := + nuclearFormIntegrable_of_absolute F hF w (fun s i => (hfull w s i).1) + have hsplit := manufactured_grid_split index hindex G hG hh rho H S freq scale u hmatch + have hl (w : Coulomb.H1Vector (n+2)) (hw : Coulomb.Antisymmetric w) : + ((n+2:ℝ)*((-1/2:ℝ)+freq/2)+A/scale-I)*Coulomb.mass w ≤ + nuclearPerturbedForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i)) F w+ + scale⁻¹*Coulomb.pairEnergy w := + hlower m n D S H scale r ε η ((le_max_left _ _).trans hD) hm hS hH hCH hscale hr hrH hrS hε hη hηδ + u hsep hcoeff herr hsmall F hF B hB hfull left right t (εM+εG) hN hK hNe w hw g hg hsmallB + have hlphys := formGroundEnergy_dilated_lower (gridNuclei index hindex G hG hh) + (manufacturedSlabPotential rho H S freq scale u) F hscale (slabPotential rho H S 0) hsplit hI + ((n+2:ℝ)*((-1/2:ℝ)+freq/2)+A/scale-I) hl + have huphys := localized_hubbard_physical_upper hdensity hrho hHp hSp hf hrelation hscale u hsep hs hη hcoeff + F hN left right t hK hI hNe (gridNuclei index hindex G hG hh) (slabPotential rho H S 0) hsplit + simp only [Nat.cast_add,Nat.cast_ofNat] at hlphys huphys + constructor + · have hid : scale^2*(((n+2:ℝ)*((-1/2:ℝ)+freq/2)+A/scale-I)+(n+2:ℝ)*slabPotential rho H S 0) = + center-scale*Eform-scale^2*I := by dsimp [center,A]; field_simp [ne_of_gt hscale]; ring + rw [hid] at hlphys + exact hlphys + · have hid : scale^2*(n+2:ℝ)*(((-1/2:ℝ)+freq/2)+slabPotential rho H S 0)+ + scale*(Hb-Vsum+Eform) = center+scale*Eform := by dsimp [center]; ring + change formGroundEnergy (dilatedNuclei (gridNuclei index hindex G hG hh) scale hscale.ne') (n+2) ≤ + ((scale^2*(n+2:ℝ)*(((-1/2:ℝ)+freq/2)+slabPotential rho H S 0)+ + scale*(Hb-Vsum+Eform):ℝ):EReal) at huphys + rw [hid] at huphys + exact huphys + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridParameters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ff3f10aeaf95ca994060f3051e613affd407aa5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridParameters.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridWitness +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ActualOneBodyParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ActualResidualParameters + +namespace OAI + +/-! One actual nuclear cloud simultaneously satisfies the full-domain form, +finite matrix, and differential-residual estimates at fixed polynomial scales. -/ + +noncomputable section +open MeasureTheory +open scoped NNReal +namespace ContinuumCoulomb + +theorem manufactured_grid_parameters (hp : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ ∃ B : ℝ, 1 ≤ B ∧ + ∀ freq : ℝ, 0 < freq → ∃ q : ℕ, 1 ≤ q ∧ + ∀ r s p k : ℕ, q+7*r+72*s+p ≤ k → + ∀ N H S D : ℝ, 2 ≤ N → + (N^k)^50 ≤ H → H ≤ 2*(N^k)^50 → + (N^k)^5 ≤ S → S ≤ 2*(N^k)^5 → 25*(k:ℝ)*Real.log N ≤ D → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), (m:ℝ) ≤ N^r → + (∀ i, ‖u i‖ ≤ N^s) → (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + (⋃ i, positionCube (gaussCellCenter (1/(N^k)^10) (index i)) (1/(N^k)^10)) = slabDomain H S → + let scale := (8/(rho:ℝ))*(N^k)^30 + let η := localizedCountertermBound freq*N^r/scale + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) ∧ + 0 ≤ η ∧ η ≤ 1 ∧ + 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D ((N^k)^5) u j) ≤ + ((N^k)^19)⁻¹^2 ∧ + ∃ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + Function.Bijective (fun x => G x 1) ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ L) ∧ + let F : Position → ℝ := fun y => gridNuclearPotential index (fun x => G x 1) rho (1/(N^k)^10) y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y) + (∀ (n : ℕ) (w : Coulomb.H1Vector n) (t : SpinConfiguration n) (i : Fin n), + Integrable (fun x => |F (Coulomb.position x i)| * ‖w.value t x‖^2) ∧ + (∫ x, |F (Coulomb.position x i)| * ‖w.value t x‖^2) ≤ + (B/(N^k)^20)*((∫ x, ‖w.value t x‖^2)+∑ j : Fin 3, ∫ x, ‖w.gradient t (i,j) x‖^2)) ∧ + (∀ i j, Integrable (fun x => F x*continuumLocalizedMode freq (u i) x*continuumLocalizedMode freq (u j) x)) ∧ + (∀ i j, |scale*correctedNuclearOneBodyMatrix rho H S freq scale u F i j- + localizedOneBodyTarget scale freq u i j| ≤ (N^p)⁻¹) := by + obtain ⟨rho,hrho,L,K,hL,hK,B,hB,hfamily⟩ := manufactured_grid_witness hp + refine ⟨rho,hrho,L,K,hL,hK,B,hB,?_⟩ + intro freq hf + obtain ⟨E,hE,hgrid⟩ := hfamily freq hf + have hrhoR : (0:ℝ) < rho := by exact_mod_cast hrho + have ha : (0:ℝ) < 8/(rho:ℝ) := by positivity + obtain ⟨qR,hqR,hres⟩ := exists_actual_manufactured_residual_parameters hf hrhoR.le ha + obtain ⟨qM,hqM,hmat⟩ := exists_actual_oneBody_parameters hrhoR.le hf ha (zero_le_one.trans hE) + obtain ⟨qD,hqD,hsepD⟩ := exists_logarithmic_scale_threshold 3 + refine ⟨qR+qM+qD+1,by omega,?_⟩ + intro r s p k hk N H S D hN hHlo hHhi hSlo hShi hD m u hm hu hsep ι _ index hi hcover + dsimp only + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hR : 2 ≤ N^k := hN.trans (le_self_pow₀ hN1 (by omega)) + have hR0 : 0 < N^k := by positivity + have hS : 0 < S := (pow_pos hR0 5).trans_le hSlo + have hH : 0 ≤ H := (pow_nonneg hR0.le 50).trans hHlo + have hscale : 0 < (8/(rho:ℝ))*(N^k)^30 := by positivity + obtain ⟨hcoeff,hη,hη1,herr⟩ := hres r s k (by omega) N hN H S D + hHlo hHhi hSlo hShi hD m u hm hu + refine ⟨hcoeff,hη,hη1,herr,?_⟩ + have hmR : (m:ℝ) ≤ (N^k)^14 := hm.trans (by + rw [← pow_mul] + exact pow_le_pow_right₀ hN1 (by omega)) + have h3 : 3 ≤ D := (hsepD k (by omega) N hN).trans hD + have hcounter (i : Fin m) : localizedCounterterm freq u i ≤ (8/(rho:ℝ))*(N^k)^30 := + (div_le_one hscale).mp ((hcoeff i).2.trans hη1) + have hbox : N^s+1 ≤ H := by + calc + _ ≤ 2*N^s := by linarith [one_le_pow₀ hN1 (n := s)] + _ ≤ N^(s+1) := by rw [pow_succ]; nlinarith [mul_le_mul_of_nonneg_right hN (pow_nonneg hN0.le s)] + _ ≤ (N^k)^50 := by rw [← pow_mul]; exact pow_le_pow_right₀ hN1 (by omega) + _ ≤ H := hHlo + have hsupp := manufacturedWellField_support_slab freq ((8/(rho:ℝ))*(N^k)^30) hS hbox u hu + obtain ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,hfull,hentries⟩ := + hgrid (N^k) ((8/(rho:ℝ))*(N^k)^30) S H hR hscale hSlo hShi hH m u hmR + (fun i j hij => h3.trans (hsep i j hij)) hcounter hsupp index hi hcover + refine ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,hfull,?_,?_⟩ + · exact fun i j => (hentries (u i) (u j)).1 + · exact hmat r s p k (by omega) N H S D hN hHlo hHhi hSlo hShi hD m u hm hu hsep _ + (fun i j => (hentries (u i) (u j)).1) (fun i j => (hentries (u i) (u j)).2) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridWitness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..65d51cb4b9bb65ee585478b55c9c7f88d936d039 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGridWitness.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearQuadratureScale + +namespace OAI + +/-! One actual transport supplies both the full weak-H1 error and the +uncut orbital entries, with uniform constants at the physical mesh. -/ + +noncomputable section +open MeasureTheory +open scoped NNReal +namespace ContinuumCoulomb + +theorem manufactured_grid_witness (hp : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ ∃ D : ℝ, 1 ≤ D ∧ + ∀ freq : ℝ, 0 < freq → ∃ E : ℝ, 1 ≤ E ∧ + ∀ R scale S H : ℝ, 2 ≤ R → 0 < scale → R^5 ≤ S → S ≤ 2*R^5 → 0 ≤ H → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), (m:ℝ) ≤ R^14 → + (∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) → + (∀ i, localizedCounterterm freq u i ≤ scale) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + (⋃ i, positionCube (gaussCellCenter (1/R^10) (index i)) (1/R^10)) = slabDomain H S → + ∃ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + Function.Bijective (fun x => G x 1) ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ L) ∧ + let F : Position → ℝ := fun y => gridNuclearPotential index (fun x => G x 1) rho (1/R^10) y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y) + (∀ (n : ℕ) (w : Coulomb.H1Vector n) (s : SpinConfiguration n) (i : Fin n), + Integrable (fun x => |F (Coulomb.position x i)| *‖w.value s x‖^2) ∧ + (∫ x, |F (Coulomb.position x i)| *‖w.value s x‖^2) ≤ + (D/R^20)*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (i,k) x‖^2)) ∧ + (∀ v w : PlanarPosition, + Integrable (fun y => F y*continuumLocalizedMode freq v y*continuumLocalizedMode freq w y) ∧ + |∫ y, F y*continuumLocalizedMode freq v y*continuumLocalizedMode freq w y| ≤ + E*((m:ℝ)+1)/R^32) := by + obtain ⟨rho,hrho,L,K,hL,hK,D,hD,hfamily⟩ := manufactured_orbital_nuclear_error hp + refine ⟨rho,hrho,L,K,hL,hK,D,hD,?_⟩ + intro freq hf + obtain ⟨A,B,C,hA,hB,hC,hgrid⟩ := hfamily freq hf + let e := 2*((rho:ℝ)*24*(2*Real.pi+1)*64*A*(max 1 (L:ℝ))^4*216)+ + (rho:ℝ)*24*(2*Real.pi+1)*64*A*(max 1 (L:ℝ))^4*13824+ + (rho:ℝ)*2048*Real.pi*B*64*A+C + refine ⟨max 1 e,le_max_left _ _,?_⟩ + intro R scale S H hR hscale hSlo hShi hH m u hm hsep hcounter hsupp ι _ index hi hcover + have hR0 : 0 < R := by linarith + have hR1 : 1 ≤ R := by linarith + have hS : 1 ≤ S := (one_le_pow₀ hR1).trans hSlo + obtain ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,hform⟩ := + hgrid scale S hscale hS m u hsep hcounter + refine ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,?_⟩ + have hh : 0 < 1/R^10 := by positivity + have hh1 : 1/R^10 ≤ 1 := (div_le_one (pow_pos hR0 _)).mpr (one_le_pow₀ hR1) + have hmesh : (m:ℝ)*S*(1/R^10)^2 ≤ 1 := by + calc + _ ≤ R^14*(2*R^5)*(1/R^10)^2 := by gcongr + _ = 2/R := by field_simp [ne_of_gt hR0] + _ ≤ 1 := (div_le_one hR0).mpr hR + obtain ⟨hfull,hentries⟩ := hform H hH hsupp index hi (1/R^10) hh hh1 hmesh hcover + constructor + · intro n w s i + have h := hfull n w s i + have he : D*(1/R^10)^2 = D/R^20 := by field_simp [ne_of_gt hR0] + rw [he] at h + exact h + · intro v w + obtain ⟨hi,he⟩ := hentries R hR1 v w + refine ⟨hi,he.trans ?_⟩ + apply (manufactured_orbital_quadrature_physical_scale (Nat.cast_nonneg rho) + (zero_le_one.trans hA) (zero_le_one.trans hB) (zero_le_one.trans hC) hR1 hShi m).trans + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right (le_max_right 1 e) (by positivity)) (by positivity) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGrowingGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGrowingGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7951a4beb1f4daca7446b135c3c311ee325a8c4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedGrowingGap.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedUniformGap + +namespace OAI + +/-! The complementary gap remains uniform when the slab thickness grows +to obtain the required orbital residual accuracy. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufacturedSlab_growing_complement_gap + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m : ℕ) (D S H scale : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → 0 ≤ scale → ∀ u : Fin m → PlanarPosition, + (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + ∀ v : Coulomb.H1Vector 1, + (∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp (lt_of_lt_of_le zero_lt_one hfreq) u i)) + (h1Coordinates v (Sum.inl s)) = 0) → + (-1/2+freq/2+γ/2)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,hγ,hsmall,hbound⟩ := manufacturedSlab_corrected_complement_lower hp hv hdensity + let η := γ/(16*freq) + obtain ⟨hη,hfreqη,hdom⟩ := manufactured_gap_parameter_bounds hγ hsmall hfreq + obtain ⟨R₁,hR₁,hplanar⟩ := planar_projection_loss_threshold hγ hη (by positivity : 0 < γ/16) + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + obtain ⟨S₀,hS₀,hvertical⟩ := vertical_projection_loss_threshold hf η (by positivity : 0 < γ/16) + let δ := γ/(16*(PlanarSobolev.wellBound+1)) + let C := max 1 (96*Real.pi*rho/γ) + have hw := PlanarSobolev.wellBound_nonnegative + have hδ : 0 < δ := by dsimp [δ]; positivity + have hC : 0 < C := lt_of_lt_of_le zero_lt_one (le_max_left _ _) + refine ⟨γ,max R₁ R₂,S₀,δ,C,hγ,hsmall,hR₁.trans (le_max_left _ _),hS₀,hδ,hC, + fun m D S H scale hD hm hS hH hCH hscale u hsep hcoeff v ho => ?_⟩ + have hD₁ : R₁ ≤ D := (le_max_left _ _).trans hD + have hD₂ : R₂ ≤ D := (le_max_right _ _).trans hD + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hHpos : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hδloss : δ*PlanarSobolev.wellBound ≤ γ/16 := by + have hid : δ*(PlanarSobolev.wellBound+1) = γ/16 := by + dsimp [δ] + field_simp + exact (mul_le_mul_of_nonneg_left (by linarith : + PlanarSobolev.wellBound ≤ PlanarSobolev.wellBound+1) hδ.le).trans_eq hid + have hslab : 6*Real.pi*rho*S^3/H ≤ γ/16 := by + have hh : 96*Real.pi*rho*S^3/γ ≤ H := by + calc + _ = (96*Real.pi*rho/γ)*S^3 := by ring + _ ≤ C*S^3 := mul_le_mul_of_nonneg_right (le_max_right _ _) (pow_nonneg hSpos.le _) + _ ≤ H := hCH + have hh' := (div_le_iff₀ hγ).mp hh + apply (div_le_iff₀ hHpos).mpr + nlinarith only [hh'] + have hloss : manufacturedSpectralLoss γ m D η freq S rho H δ ≤ γ/2 := by + have hp' := hplanar D hD₁ m hm + have hv' := (hvertical S hS).2 + unfold manufacturedSpectralLoss + dsimp [η] at hv' ⊢ + linarith [hfreqη] + exact hbound m D η freq S rho H scale δ (hR₁.trans hD₁) hη hf hSpos hrho hHpos + hscale hδ.le hrelation (hvertical S hS).1 u hsep hcoeff + (hdom _ (hover D hD₂ m hm)) (hover D hD₂ m hm) hloss v ho + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedHubbardComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedHubbardComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..68cd0689f5171fbf5d160e15becec4d921262900 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedHubbardComparison.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedNuclearComparison + +namespace OAI + +/-! The actual Hubbard lower bound passes through the full continuum +complement estimate. The only spectral and domain inputs here are the +explicit published planar, oscillator, and smooth-density propositions. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb +open HubbardGlobal + +theorem manufacturedSlab_uniform_hubbard_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 1 ≤ C ∧ + ∀ (m n : ℕ) (D S H scale r ε η : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + 0 < scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin (m+1) → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n+1:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ F : Position → ℝ, Measurable F → ∀ B : ℝ, 0 ≤ B → + (∀ (z : Coulomb.H1Vector (n+2)) s i, + Integrable (fun x => |F (Coulomb.position x i)| * ‖z.value s x‖^2) ∧ + (∫ x, |F (Coulomb.position x i)| * ‖z.value s x‖^2) ≤ + B*((∫ x, ‖z.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖z.gradient s (i,k) x‖^2)) → + ∀ {Edge : Type} [Fintype Edge] (left right : Edge → Fin (m+1)) (t : Edge → ℝ) (εK : ℝ), + (∀ a b, Integrable (fun z => (F (WithLp.toLp 2 z.2):ℂ)* + (star (Coulomb.flatSpinOrbital (localizedSpinMode freq u a) z)* + Coulomb.flatSpinOrbital (localizedSpinMode freq u b) z)) Coulomb.spinSpaceMeasure) → + (∀ a b, ‖(scale:ℂ)*(flatResidualMatrix (localizedSpinMode freq u) + (localizedSpinResidual rho H S freq scale u) a b+ + flatNuclearMatrix (localizedSpinMode freq u) F a b)- + hubbardOneBodyMatrix m (localizedOffsiteCoulomb freq u) left right t a b‖ ≤ εK) → + n+2=m+1 → ∀ w : Coulomb.H1Vector (n+2), Coulomb.Antisymmetric w → + let A := hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)- + localizedHubbardFormError m freq D εK + let V : Configuration (n+2) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+2:ℝ)*((-1/2:ℝ)+freq/2) + let e : ℝ := 2*(n+2:ℝ)*ε + let K : ℝ := (n+2:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+e + let g₀ : ℝ := (γ/8)/(2*((n+2:ℕ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) + ∀ g : ℝ, 0 < g → B*(n+2)+|A/scale|+g ≤ g₀ → + (E+A/scale-3*(e^2+(scale⁻¹)^2*(8*(n+2:ℝ)^3*K)+ + B^2*((n+2:ℝ)+2*K)*(n+2))/g)*Coulomb.mass w ≤ + nuclearPerturbedForm V F w+scale⁻¹*Coulomb.pairEnergy w := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hbase⟩ := + manufacturedSlab_uniform_nuclear_lower hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,_hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC,?_⟩ + intro m n D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ + u hsep hcoeff herr hsmall F hF B hB herror Edge inst left right t εK hN hK hNe w hw + let A := hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) + left right t-(1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)- + localizedHubbardFormError m freq D εK + dsimp only + intro g hg hsmallB + have hSp : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hHp : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hs := hover D ((le_max_right _ _).trans hD) (m+1) hm + let p := finiteTensorProjection (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) w + have hc : Laughlin.Antisymmetric (Coulomb.orbitalCoefficient w (localizedSpinMode freq u)) := by + intro i j hij a + simpa only [Equiv.Perm.sign_swap hij,Units.val_neg,Units.val_one, + Int.cast_neg,Int.cast_one,neg_one_mul] using + Coulomb.orbitalCoefficient_antisymmetric hw (localizedSpinMode freq u) (Equiv.swap i j) a + have hfinite := localizedTensor_hubbard_lower hdensity hrho hHp hSp hf hrelation hscale u hsep hs + hη hcoeff F hN left right t hK (Coulomb.orbitalCoefficient w (localizedSpinMode freq u)) + hc + (nuclearFormIntegrable_of_absolute F hF p (fun s i => (herror p s i).1)) hNe + have hfinite' : ((n+2:ℝ)*((-1/2:ℝ)+freq/2)+A/scale)*Coulomb.mass p ≤ + nuclearPerturbedForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) F p+scale⁻¹*Coulomb.pairEnergy p := by + apply (mul_le_mul_iff_right₀ hscale).mp + have hcancel : A/scale*scale=A := div_mul_cancel₀ A (ne_of_gt hscale) + have he : scale*(((n+2:ℝ)*((-1/2:ℝ)+freq/2)+A/scale)*Coulomb.mass p) = + (scale*(n+2:ℝ)*((-1/2:ℝ)+freq/2)+A)*Coulomb.mass p := by + calc + _ = (scale*(n+2:ℝ)*((-1/2:ℝ)+freq/2)+(A/scale*scale))*Coulomb.mass p := by ring + _ = _ := by rw [hcancel] + rw [he] + dsimp only [A, p, finiteTensorProjection] + convert hfinite using 1 + ring + have hncast : ((n:ℝ)+1)+1=(n:ℝ)+2 := by ring + have hout := hbase m (n+1) D S H scale r ε η ((le_max_left _ _).trans hD) + hm hS hH hCH hscale.le hr hrH hrS hε hη hηδ u hsep hcoeff herr + (by simpa only [Nat.cast_add,Nat.cast_one] using hsmall) F hF B hB herror w hw + (A/scale) g scale⁻¹ hg (inv_nonneg.mpr hscale.le) + (by simpa only [A,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat,hncast] using hsmallB) + (by simpa only [A,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat,hncast] using hfinite') + simpa only [A,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat,hncast] using hout + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedManyElectron.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedManyElectron.lean new file mode 100644 index 0000000000000000000000000000000000000000..7967d4da62601b10bfcc814f3116584ec16d8252 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedManyElectron.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ElectronSlotBound +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOneElectronGap + +namespace OAI + +/-! The actual manufactured Coulomb lower bound on the complete spinful +many-electron weak-H1 domain. The sum of orbital occupations is the sum of +the actual L2 slice contractions, not a restriction on the admitted states. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem manufacturedSlab_manyElectron_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η freq S rho H scale δ : ℝ), + 8 ≤ D → 0 < η → ∀ hfreq : 0 < freq, 0 < S → 0 ≤ rho → 0 < H → 0 ≤ scale → 0 ≤ δ → + freq^2 = 4*Real.pi*rho → 3*freq/2 ≤ freq^2*S^2/8 → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + γ*(1+η)*(1+m*localizedOverlapBound D) ≤ freq*(1+η) → + ∀ (n : ℕ) (v : Coulomb.H1Vector (n+1)), + (n+1:ℕ)*manufacturedSpectralLevel γ m D η freq S rho H δ*Coulomb.mass v- + γ*(1+η)*totalOrbitalMass v + (fun i => oneElectronOrbitalLp (continuumLocalizedMode freq (u i)) + (continuumLocalizedMode_memLp hfreq (u i))) ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v := by + obtain ⟨γ,hγ,hsmall,hbound⟩ := manufacturedSlab_weakH1_lower hp hv hdensity + refine ⟨γ,hγ,hsmall,fun m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom n v => ?_⟩ + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + exact manyElectron_projection_lower _ + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u) B hB + (fun i => oneElectronOrbitalLp (continuumLocalizedMode freq (u i)) + (continuumLocalizedMode_memLp hfreq (u i))) _ _ + (hbound m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom) v + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..d58c854af2a0a96a9784bb7c25e7daba9a04d22a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearComparison.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedNuclearTensorLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorCoercivity + +namespace OAI + +/-! The actual manufactured orbital space retains full-domain complement +control after a singular nuclear perturbation. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_nuclear_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 1 ≤ C ∧ + ∀ (m n : ℕ) (D S H scale r ε η : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin (m+1) → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ F : Position → ℝ, Measurable F → ∀ B : ℝ, 0 ≤ B → + (∀ (z : Coulomb.H1Vector (n+1)) s i, + Integrable (fun x => |F (Coulomb.position x i)| * ‖z.value s x‖^2) ∧ + (∫ x, |F (Coulomb.position x i)| * ‖z.value s x‖^2) ≤ + B*((∫ x, ‖z.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖z.gradient s (i,k) x‖^2)) → + ∀ w : Coulomb.H1Vector (n+1), Coulomb.Antisymmetric w → + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let e : ℝ := 2*(n+1:ℝ)*ε + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+e + let g₀ : ℝ := (γ/8)/(2*((n+1:ℕ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) + ∀ a g t : ℝ, 0 < g → 0 ≤ t → B*(n+1)+|a|+g ≤ g₀ → + (E+a)*Coulomb.mass p ≤ nuclearPerturbedForm V F p+t*Coulomb.pairEnergy p → + (E+a-3*(e^2+t^2*(8*(n+1:ℝ)^3*K)+B^2*((n+1:ℝ)+2*K)*(n+1))/g)*Coulomb.mass w ≤ + nuclearPerturbedForm V F w+t*Coulomb.pairEnergy w := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,_hC,hgap⟩ := + manufacturedSlab_uniform_tensorComplement_coercivity hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,_hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,max C 1,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ, + le_max_right _ _,?_⟩ + intro m n D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall + F hF B hB herror w hw + dsimp only + intro a g t hg ht hsmallB hfinite + have hSp : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hHp : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hCCH : C*S^3 ≤ H := (mul_le_mul_of_nonneg_right (le_max_left C 1) (by positivity)).trans hCH + have hSH : S^3 ≤ H := by + have h := mul_le_mul_of_nonneg_right (le_max_right C 1) (show 0 ≤ S^3 by positivity) + simpa only [one_mul] using h.trans hCH + have hs := hover D ((le_max_right _ _).trans hD) (m+1) hm + have hD₂ : 2 ≤ D := by linarith only [hR,le_max_left R R₂,hD] + let p := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q := finiteTensorRemainder (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let e : ℝ := 2*(n+1:ℝ)*ε + have he : 0 ≤ e := by dsimp [e]; positivity + have herr' : (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, + manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ e^2 := by + have h := mul_le_mul_of_nonneg_left herr (show 0 ≤ 2*(n+1:ℝ)^2 by positivity) + dsimp [e] + nlinarith only [h,sq_nonneg ((n+1:ℝ)*ε)] + have hcoercive := hgap m n D S H scale r ε η ((le_max_left _ _).trans hD) hm hS hH hCCH + hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall w hw + have hsmallB' : B*(n+1:ℕ)+|a|+g ≤ + (γ/8)/(2*((n+1:ℕ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) := by + simpa only [Nat.cast_add,Nat.cast_one] using hsmallB + have hcomp := nuclearPerturbed_coercive_complement (show 1 ≤ n+1 by omega) + V F hB q E a _ g (fun s i => (herror q s i).2) (by simpa only [E,V,q,Nat.cast_add,Nat.cast_one] using hcoercive) hsmallB' + have h := manufacturedTensor_nuclear_interacting_lower hdensity hrho hHp hSp hSH hfreq hrelation + hr hrH hrS scale hscale u hD₂ hsep hs hη hcoeff he herr' F hF B hB herror w a g t hg ht hfinite hcomp + simpa only [e,Nat.cast_add,Nat.cast_one] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..80af18c9fb6fc365d37d31bbb4e84d4916f6e420 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearForm.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearGridPotential +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.WeightedPotentialBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularity + +namespace OAI + +/-! General-form half of the unit-nucleus replacement estimate. It holds +for every spin component of every many-electron weak-H1 state. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem manufactured_grid_form_error (hpublished : PublishedC4FlowInput) + (L K : ℝ≥0) (hL : 0 < L) (hK : 0 < K) : + ∃ C A : ℝ, 1 ≤ C ∧ 1 ≤ A ∧ + ∀ (rho H S freq scale : ℝ) (m : ℕ) (u : Fin m → PlanarPosition), + 0 < rho → 0 ≤ H → 1 ≤ S → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ rho/2) → + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ (G : Position → ℝ → Position), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + Function.Bijective (fun x => G x 1) → + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) → + ∀ (D : ℝ), 1 ≤ D → + (∀ x, ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ D^k) → + LipschitzWith L (fun x => G x 1) → AntilipschitzWith K (fun x => G x 1) → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ (h : ℝ), 0 < h → h ≤ 1 → + (⋃ i, positionCube (gaussCellCenter h (index i)) h) = slabDomain H S → + ∀ (n : ℕ) (w : Coulomb.H1Vector n) (s : SpinConfiguration n) (i : Fin n), + |∫ x, (gridNuclearPotential index (fun x => G x 1) rho h (Coulomb.position x i)- + (slabPotential rho H S (Coulomb.position x i)+ + manufacturedWellField freq scale S u (Coulomb.position x i)))*‖w.value s x‖^2| ≤ + rho*(24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4)+108*Real.pi*(L:ℝ)^2*h^2)* + (∫ x, ‖w.value s x‖^2)+ + rho*A*h^2*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (i,k) x‖^2) := by + obtain ⟨C,hC,hpoint⟩ := manufactured_grid_potential_error hpublished + have hκ : 0 < 6*(L:ℝ) := by positivity + obtain ⟨A,hA,hnear⟩ := transportedGauss_truncated_form hκ K hK + refine ⟨C,A,hC,hA,?_⟩ + intro rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix D hD hGD hLip hAnti + ι _ index hindex h hh hh1 hcover n w s i + let F : Position → ℝ := fun y => gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y) + let B := rho*(24*C*D^4*(3072*Real.pi*h^2/(L:ℝ)^2+216*m*S*h^4)+108*Real.pi*(L:ℝ)^2*h^2) + let R : ι × (Fin 3 → Fin 2) → Position := fun a => G (gaussLatticePoint h (gridGaussIndex index a)) 1 + have hF : Measurable F := (gridNuclearPotential_measurable index (fun x => G x 1) rho h).sub + (((slabPotential_continuous hrho.le hH (by linarith)).add + (manufacturedWellField_C7 freq scale S u).continuous).measurable) + have he := weighted_potential_truncated_bound w s i F hF R (6*(L:ℝ)*h) B (rho*h^3/8) + (hpoint rho H S freq scale m u hrho hH hS hcharge hsupp G hflow hbij hfix + D hD hGD L hL hLip index hindex h hh hh1 hcover) + have hn := hnear n w s i h rho hh hh1 hrho.le (gridGaussIndex index) + (gridGaussIndex_injective index hindex) (fun x => G x 1) hAnti + exact he.2.trans (add_le_add le_rfl hn) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearTensorLower.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearTensorLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..11824f9d05fb8b912ea10fb73af3457a2e21d517 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedNuclearTensorLower.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorVariationalLower +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPerturbedComplement + +namespace OAI + +/-! Singular nuclear perturbations of the actual manufactured tensor projection. +The differential residual and kinetic bounds are discharged from the orbitals. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedTensor_nuclear_interacting_lower + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq η D R ε : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) + (hfreq : 1 ≤ freq) (hrelation : freq^2 = 4*Real.pi*rho) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) (hscale : 0 ≤ scale) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hD : 2 ≤ D) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (hε : 0 ≤ ε) + (herr : (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, + manufacturedOrbitalSquaredError rho H S freq η D R u j) ≤ ε^2) + (F : Position → ℝ) (hF : Measurable F) (B : ℝ) (hB : 0 ≤ B) + (herror : ∀ (z : Coulomb.H1Vector (n+1)) s i, + Integrable (fun x => |F (Coulomb.position x i)| * ‖z.value s x‖^2) ∧ + (∫ x, |F (Coulomb.position x i)| * ‖z.value s x‖^2) ≤ + B*((∫ x, ‖z.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖z.gradient s (i,k) x‖^2)) + (w : Coulomb.H1Vector (n+1)) (a g t : ℝ) (hg : 0 < g) (ht : 0 ≤ t) : + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε + (E+a)*Coulomb.mass p ≤ nuclearPerturbedForm V F p+t*Coulomb.pairEnergy p → + (E+a)*Coulomb.mass q+g*(Coulomb.mass q+2*Coulomb.kinetic q) ≤ nuclearPerturbedForm V F q → + (E+a-3*(ε^2+t^2*(8*(n+1:ℝ)^3*K)+B^2*((n+1:ℝ)+2*K)*(n+1))/g)*Coulomb.mass w ≤ + nuclearPerturbedForm V F w+t*Coulomb.pairEnergy w := by + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε + change (E+a)*Coulomb.mass p ≤ nuclearPerturbedForm V F p+t*Coulomb.pairEnergy p → + (E+a)*Coulomb.mass q+g*(Coulomb.mass q+2*Coulomb.kinetic q) ≤ nuclearPerturbedForm V F q → _ + intro hfinite hcomp + have hV : Continuous V := continuous_finsetSum _ (fun i _ => + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + (Coulomb.positionCLM i).continuous) + obtain ⟨Vbound,hVbound⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hsum (x : Configuration (n+1)) : |V x| ≤ (n+1:ℝ)*Vbound := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + Nat.cast_add,Nat.cast_one] using Finset.sum_le_sum (s := Finset.univ) + (fun i _ => hVbound (Coulomb.position x i)) + have hc := manufacturedTensorProjection_mixed_square_bound hdensity hrho hH hS hf hrelation + hR hRH hRS scale u hsep hs hη hcoeff ((n+1:ℝ)*Vbound) hsum w + have hc' : (graphBoundedCross (BoundedPotential.operator V hV _ hsum) + (h1Coordinates p) (h1Coordinates q))^2 ≤ ε^2*Coulomb.mass p*Coulomb.mass q := + hc.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right herr (Coulomb.mass_nonneg p)) (Coulomb.mass_nonneg q)) + have hk : Coulomb.kinetic p ≤ K*Coulomb.mass p := + localizedTensorState_kinetic_bound hdensity hrho hH hS hSH hf hrelation hR hRH hRS + scale hscale u hD hsep hs hη hcoeff hε herr (Coulomb.orbitalCoefficient w (localizedSpinMode freq u)) + have hK : 0 ≤ K := by + have he : 0 ≤ (-1/2:ℝ)+freq/2 := by linarith only [hfreq] + have hw := PlanarSobolev.wellBound_nonnegative + dsimp only [K] + positivity + have he := nuclearPerturbed_interacting_lower (show 1 ≤ n+1 by omega) + V hV _ hsum F hF B hB herror p q E a g (ε^2) K t hg (sq_nonneg ε) hK ht + hfinite hcomp hk hc' + have hpq : p.add q = w := finiteTensorProjection_add_remainder + (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) w + have hm : Coulomb.mass w = Coulomb.mass p+Coulomb.mass q := + finiteTensorProjection_mass_decomposition (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hf u) (localizedSpinMode_partial_memLp hf u) (fun i j => by + have h := localizedSpinMode_inner hf u hsep hs i j + by_cases hij : i=j <;> simpa only [hij,ite_true,ite_false] using h) w + rw [hpq,← hm] at he + simpa only [E,K,V,Nat.cast_add,Nat.cast_one] using he + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOneElectronGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOneElectronGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfb20ddd6c75e3ff89e4a36b8146631f3c7ce3c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOneElectronGap.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.PhysicalOneElectronLower +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronClosure + +namespace OAI + +/-! The manufactured field's finite-rank lower estimate holds on the entire +spinful weak-H1 domain. No smoothness, compact support, or reality condition is +imposed on the state in this theorem. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def manufacturedSpectralLevel (γ : ℝ) (m : ℕ) (D η freq S rho H δ : ℝ) : ℝ := + planarSpectralLevel γ m D η+verticalSpectralLevel freq S η-freq*(1+η)- + (δ*PlanarSobolev.wellBound+6*Real.pi*rho*S^3/H) + +theorem manufacturedSlab_weakH1_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) + (hdensity : PublishedSobolevSmoothDensity) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η freq S rho H scale δ : ℝ), + 8 ≤ D → 0 < η → ∀ hfreq : 0 < freq, 0 < S → 0 ≤ rho → 0 < H → 0 ≤ scale → 0 ≤ δ → + freq^2 = 4*Real.pi*rho → 3*freq/2 ≤ freq^2*S^2/8 → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + γ*(1+η)*(1+m*localizedOverlapBound D) ≤ freq*(1+η) → + ∀ v : Coulomb.H1Vector 1, + manufacturedSpectralLevel γ m D η freq S rho H δ*Coulomb.mass v- + γ*(1+η)*graphOrbitalMass + (fun i => oneElectronOrbitalLp (continuumLocalizedMode freq (u i)) + (continuumLocalizedMode_memLp hfreq (u i))) (h1Coordinates v) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v := by + obtain ⟨γ,hγ,hsmall,hphysical⟩ := manufacturedSlab_test_lower hp hv + refine ⟨γ,hγ,hsmall,fun m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom v => ?_⟩ + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + exact oneElectron_weakH1_lower hdensity _ + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u) B hB + (fun i => continuumLocalizedMode freq (u i)) + (fun i => continuumLocalizedMode_memLp hfreq (u i)) _ _ + (hphysical m D η freq S rho H scale δ hD hη hfreq hS hrho hH hscale hδ + hrelation hbarrier u hsep hcoeff hdom) v + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalNuclearError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalNuclearError.lean new file mode 100644 index 0000000000000000000000000000000000000000..5322c15c0e077c1c16a3b6f712cc1b5adac2e7cf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalNuclearError.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.UniformAbsoluteNuclearForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalNuclearError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalNuclearTail + +namespace OAI + +/-! Actual uncut orbital matrix elements of the manufactured grid potential. +The only external analytic input is the published C4 flow theorem. -/ + +noncomputable section +open MeasureTheory +open scoped NNReal +namespace ContinuumCoulomb + +theorem manufactured_orbital_nuclear_error (hpublished : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ ∃ D : ℝ, 1 ≤ D ∧ + ∀ freq : ℝ, 0 < freq → ∃ A B C : ℝ, 1 ≤ A ∧ 1 ≤ B ∧ 1 ≤ C ∧ + ∀ (scale S : ℝ), 0 < scale → 1 ≤ S → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) → + (∀ i, localizedCounterterm freq u i ≤ scale) → + ∃ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + Function.Bijective (fun x => G x 1) ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ L) ∧ + ∀ H : ℝ, 0 ≤ H → tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S → + ∀ {ι : Type} [Fintype ι] (index : ι → Fin 3 → ℤ), Function.Injective index → + ∀ h : ℝ, 0 < h → h ≤ 1 → (m:ℝ)*S*h^2 ≤ 1 → + (⋃ i, positionCube (gaussCellCenter h (index i)) h) = slabDomain H S → + (∀ (n : ℕ) (w : Coulomb.H1Vector n) (s : SpinConfiguration n) (i : Fin n), + Integrable (fun x => |gridNuclearPotential index (fun x => G x 1) rho h (Coulomb.position x i)- + (slabPotential rho H S (Coulomb.position x i)+ + manufacturedWellField freq scale S u (Coulomb.position x i))| * ‖w.value s x‖^2) ∧ + (∫ x, |gridNuclearPotential index (fun x => G x 1) rho h (Coulomb.position x i)- + (slabPotential rho H S (Coulomb.position x i)+ + manufacturedWellField freq scale S u (Coulomb.position x i))| * ‖w.value s x‖^2) ≤ + D*h^2*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (i,k) x‖^2)) ∧ + ∀ R : ℝ, 1 ≤ R → ∀ v w : PlanarPosition, + Integrable (fun y => (gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y))* + continuumLocalizedMode freq v y*continuumLocalizedMode freq w y) ∧ + |∫ y, (gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y))* + continuumLocalizedMode freq v y*continuumLocalizedMode freq w y| ≤ + rho*(24*((2*Real.pi+1)*(64*A*R^3))*(max 1 (L:ℝ))^4*(216*m*S+13824*R^3)+ + 2048*Real.pi*B*(64*A*R^3))*h^4+C*h^2/R^12 := by + obtain ⟨rho,hrho,L,K,hL,hK,D,hD,hfamily⟩ := manufactured_uniform_nuclear_absolute_form hpublished + refine ⟨rho,hrho,L,K,hL,hK,D,hD,?_⟩ + intro freq hfreq + obtain ⟨A,B,hA,hB,hcompact⟩ := manufactured_compact_orbital_nuclear_error hpublished hfreq + obtain ⟨T,hT,htail⟩ := orbital_nuclear_cutoff_error hfreq + let C := max 1 (T*D) + have hC : 1 ≤ C := le_max_left _ _ + have hD0 : 0 ≤ D := zero_le_one.trans hD + have hrhoR : (0:ℝ) < rho := by exact_mod_cast hrho + refine ⟨A,B,C,hA,hB,hC,?_⟩ + intro scale S hscale hS m u hsep hcounter + obtain ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,hform⟩ := + hfamily freq scale S hscale hS m u hsep hcounter + refine ⟨G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,?_⟩ + intro H hH hsupp ι _ index hindex h hh hh1 hmesh hcover + have hfull := hform H hH hsupp index hindex h hh hh1 hmesh hcover + refine ⟨hfull,?_⟩ + intro R hR v w + let F : Position → ℝ := fun y => gridNuclearPotential index (fun x => G x 1) rho h y- + (slabPotential rho H S y+manufacturedWellField freq scale S u y) + have hF : Measurable F := (gridNuclearPotential_measurable index (fun x => G x 1) rho h).sub + (((slabPotential_continuous hrhoR.le hH (zero_le_one.trans hS)).add + (manufacturedWellField_C7 freq scale S u).continuous).measurable) + obtain ⟨hi,hic,he⟩ := htail (D*h^2) R (mul_nonneg hD0 (sq_nonneg h)) hR F hF + (fun w s => (hfull 1 w s 0).1) (fun w s => (hfull 1 w s 0).2) v w + refine ⟨hi,?_⟩ + have hmax : 1 ≤ max 1 (L:ℝ) := le_max_left _ _ + have hjet (x : Position) (k : ℕ) (hk : 1 ≤ k) (hk4 : k ≤ 4) : + ‖iteratedFDeriv ℝ k (fun x => G x 1) x‖ ≤ (max 1 (L:ℝ))^k := + (hjets k hk hk4 x).trans ((le_max_right 1 (L:ℝ)).trans + (by simpa only [pow_one] using pow_le_pow_right₀ hmax hk)) + have hc := hcompact R hR v w rho H S scale hrhoR hH hS m u hcharge hsupp + G hflow hbij hreg hfix (max 1 (L:ℝ)) (zero_le_one.trans hmax) hjet + index hindex h hh hh1 hcover + have htriangle := abs_add_le + ((∫ y, F y*continuumLocalizedMode freq v y*continuumLocalizedMode freq w y)- + ∫ y, F y*compactOrbitalDensity freq R v w y) + (∫ y, F y*compactOrbitalDensity freq R v w y) + rw [sub_add_cancel] at htriangle + have htailC : T*(D*h^2)/R^12 ≤ C*h^2/R^12 := by + apply div_le_div_of_nonneg_right _ (by positivity) + simpa only [mul_assoc] using mul_le_mul_of_nonneg_right (le_max_right 1 (T*D)) (sq_nonneg h) + exact htriangle.trans ((add_le_add (he.trans htailC) hc).trans_eq (add_comm _ _)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d2b866b2b91e51088c60863557499ff2a6f76a3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedOrbitalResidual.lean @@ -0,0 +1,117 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedMultiwellResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellFieldOrbitalResidual + +namespace OAI + +/-! The residual for the actual manufactured one-body operator is the sum +of the checked off-site, finite-slab, and cutoff/counterterm residuals. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def manufacturedOrbitalResidual (rho H S freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) (x : Position) : ℝ := + localizedMultiwellResidual freq u j x+slabOrbitalResidual rho H S freq (u j) x+ + wellFieldOrbitalResidual freq scale S u j x + +theorem manufacturedOrbitalResidual_eq {rho freq : ℝ} (hfreq : freq^2 = 4*Real.pi*rho) + (H S scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (j : Fin m) (x : Position) : + manufacturedOrbitalResidual rho H S freq scale u j x = + -(1/2 : ℝ)*splitLaplacian (localizedMode freq (u j)) (positionSplitCoordinates x)+ + manufacturedSlabPotential rho H S freq scale u x*continuumLocalizedMode freq (u j) x- + ((-1/2 : ℝ)+freq/2)*continuumLocalizedMode freq (u j) x := by + rw [manufacturedOrbitalResidual, localizedMultiwellResidual_eq] + unfold multiwellAction multiwellPotential slabOrbitalResidual slabResidualMultiplier + wellFieldOrbitalResidual manufacturedSlabPotential planarWellSum + rw [hfreq] + simp only [continuumLocalizedMode, positionSplitCoordinates_snd] + ring + +private theorem slab_residual_continuous {rho H S : ℝ} (hrho : 0 ≤ rho) + (hH : 0 ≤ H) (hS : 0 ≤ S) (freq : ℝ) (u : PlanarPosition) : + Continuous (slabOrbitalResidual rho H S freq u) := + (((slabPotential_continuous hrho hH hS).sub continuous_const).sub + (continuous_const.mul (positionSplitCoordinates.continuous.snd.pow 2))).mul + (continuumLocalizedMode_C7 freq u).continuous + +private theorem well_residual_continuous (freq scale S : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) : + Continuous (wellFieldOrbitalResidual freq scale S u j) := + ((manufacturedWellField_C7 freq scale S u).continuous.sub + ((planarWellSum_continuous u).comp positionSplitCoordinates.continuous.fst)).mul + (continuumLocalizedMode_C7 freq (u j)).continuous + +theorem manufacturedOrbitalResidual_memLp {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + MemLp (manufacturedOrbitalResidual rho H S freq scale u j) 2 := by + have hs : MemLp (slabOrbitalResidual rho H S freq (u j)) 2 := + (memLp_two_iff_integrable_sq (slab_residual_continuous hrho hH hS freq (u j)).aestronglyMeasurable).mpr + (slabOrbitalResidual_square_integrable hrho hH hS hfreq (u j)) + have hw : MemLp (wellFieldOrbitalResidual freq scale S u j) 2 := + (memLp_two_iff_integrable_sq (well_residual_continuous freq scale S u j).aestronglyMeasurable).mpr + (wellFieldOrbitalResidual_square_integrable hfreq scale S u hδ hcoeff j) + exact ((localizedMultiwellResidual_memLp hfreq u j).add hs).add hw + +theorem manufacturedOrbitalResidual_square_integrable {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 ≤ S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + Integrable (fun x => manufacturedOrbitalResidual rho H S freq scale u j x^2) := + (manufacturedOrbitalResidual_memLp hrho hH hS hfreq scale u hδ hcoeff j).integrable_sq + +/-- The seventy-second-moment tail keeps the residual compatible with the +physical mesh scale even for high-aspect slabs. -/ +def manufacturedOrbitalSquaredError (rho H S freq δ D R : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) : ℝ := + 3*((m : ℝ)^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)*Real.exp (-(19/10 : ℝ)*D)+ + (2*(6*Real.pi*rho*S^3/H)^2+2*(64*rho*S/H)^2*localizedDensityMoment freq (u j) 4+ + 2*(2*slabUniformBound rho H S)^2*(localizedDensityMoment freq (u j) 72/R^72)+ + 2*(2*Real.pi*rho)^2*(localizedDensityMoment freq (u j) 72/R^68))+ + (((m : ℝ)*δ*PlanarSobolev.wellBound)^2+ + ((m : ℝ)*(δ+1)*PlanarSobolev.wellBound)^2* + (localizedDensityMoment freq (u j) 8/(S/2)^8))) + +theorem manufacturedOrbitalResidual_square_bound {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + (∫ x, manufacturedOrbitalResidual rho H S freq scale u j x^2) ≤ + manufacturedOrbitalSquaredError rho H S freq δ D R u j := by + have hpoint (x : Position) : manufacturedOrbitalResidual rho H S freq scale u j x^2 ≤ + 3*(localizedMultiwellResidual freq u j x^2+slabOrbitalResidual rho H S freq (u j) x^2+ + wellFieldOrbitalResidual freq scale S u j x^2) := by + unfold manufacturedOrbitalResidual + nlinarith [sq_nonneg (localizedMultiwellResidual freq u j x-slabOrbitalResidual rho H S freq (u j) x), + sq_nonneg (localizedMultiwellResidual freq u j x-wellFieldOrbitalResidual freq scale S u j x), + sq_nonneg (slabOrbitalResidual rho H S freq (u j) x-wellFieldOrbitalResidual freq scale S u j x)] + have hm := localizedMultiwellResidual_square_integrable hfreq u j + have hs := slabOrbitalResidual_square_integrable hrho hH.le hS.le hfreq (u j) + have hw := wellFieldOrbitalResidual_square_integrable hfreq scale S u hδ hcoeff j + have h := integral_mono + (manufacturedOrbitalResidual_square_integrable hrho hH.le hS.le hfreq scale u hδ hcoeff j) + (((hm.add hs).add hw).const_mul 3) hpoint + simp only [Pi.add_apply] at h + rw [integral_const_mul] at h + have hsum := integral_add (hm.add hs) hw + have hpair := integral_add hm hs + simp only [Pi.add_apply] at hsum hpair + rw [hsum, hpair] at h + exact h.trans (mul_le_mul_of_nonneg_left + (add_le_add (add_le_add (localizedMultiwellResidual_square_bound hfreq u hsep j) + (slabOrbitalResidual_square_bound_seventySecond hrho hH hS.le hfreq hR hRH hRS (u j))) + (wellFieldOrbitalResidual_square_bound hfreq hS scale u hδ hcoeff j)) (by norm_num)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPolynomialComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPolynomialComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..e46bb905634570afe8c34994e66c81c43f8a1ded --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPolynomialComparison.lean @@ -0,0 +1,152 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridGroundComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGridParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedScalarParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFrequency + +namespace OAI + +/-! Uniform polynomial accuracy for the actual unit-charge cloud. All +infinite-dimensional estimates are derived from the cited published inputs. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb +open HubbardGlobal + +theorem manufactured_polynomial_comparison + (hflow : PublishedC4FlowInput) + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) : + ∃ (rho : ℕ) (hrho : 0 < rho), ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ + let freq := GaussianFrequency.frequency rho + ∃ q : ℕ, 1 ≤ q ∧ ∀ r s v p k : ℕ, q+9*r+72*s+v+p ≤ k → + ∀ N H S D : ℝ, ∀ hN : 2 ≤ N, + (N^k)^50 ≤ H → H ≤ 2*(N^k)^50 → + (N^k)^5 ≤ S → S ≤ 2*(N^k)^5 → 25*(k:ℝ)*Real.log N ≤ D → + ∀ (m n : ℕ) (u : Fin (m+1) → PlanarPosition), n+2=m+1 → + (m+1:ℝ) ≤ N^r → (∀ i, ‖u i‖ ≤ N^s) → + (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ {Edge : Type} [Fintype Edge] (left right : Edge → Fin (m+1)) (t : Edge → ℝ), + (∑ e, |t e|) ≤ N^v → + (∀ i j, ‖((((8/(rho:ℝ))*(N^k)^30)*planarHoppingMatrix u i j:ℝ):ℂ)- + graphHoppingMatrix m left right (fun e => (t e:ℂ)) i j‖ ≤ (N^(2*r+p+6))⁻¹) → + ∀ {ι : Type} [Fintype ι] [Nonempty ι] (index : ι → Fin 3 → ℤ) + (hindex : Function.Injective index), + (⋃ i, positionCube (gaussCellCenter (1/(N^k)^10) (index i)) (1/(N^k)^10)) = slabDomain H S → + let scale := (8/(rho:ℝ))*(N^k)^30 + let center := scale^2*(n+2:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+ + scale*(hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)) + ∃ (G : Position → ℝ → Position) (hbij : Function.Bijective (fun x => G x 1)), + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ j : ℕ, 1 ≤ j → j ≤ 4 → ∀ x, ‖iteratedFDeriv ℝ j (fun y => G y 1) x‖ ≤ L) ∧ + (∀ i, localizedCounterterm freq u i ≤ scale) ∧ + ((center-scale*(N^p)⁻¹:ℝ):EReal) ≤ + formGroundEnergy (dilatedNuclei + (gridNuclei index hindex (fun x => G x 1) hbij.injective (manufactured_mesh_positive hN k)) + scale (manufactured_scale_positive hrho hN k).ne') (n+2) ∧ + formGroundEnergy (dilatedNuclei + (gridNuclei index hindex (fun x => G x 1) hbij.injective (manufactured_mesh_positive hN k)) + scale (manufactured_scale_positive hrho hN k).ne') (n+2) ≤ + ((center+scale*(N^p)⁻¹:ℝ):EReal) := by + obtain ⟨rho,hrho,L,K,hL,hK,B,hB,hgrid⟩ := manufactured_grid_parameters hflow + let freq := GaussianFrequency.frequency rho + have hf : 1 ≤ freq := manufactured_frequency_ge_one hrho + have hfp : 0 < freq := lt_of_lt_of_le zero_lt_one hf + have hr : (0:ℝ) < rho := by exact_mod_cast hrho + have ha : (0:ℝ) < 8/(rho:ℝ) := by positivity + obtain ⟨qW,hqW,hwitness⟩ := hgrid freq hfp + obtain ⟨γ,R,S₀,δ,C,hγ,hγ1,hR,hS₀,hδ,hC,hground⟩ := + manufactured_grid_ground_bounds hp hv hdensity hf hr.le (manufactured_frequency_relation rho) + obtain ⟨qT,qG,hqT,_hqG,hscalar⟩ := manufactured_scalar_parameters hf hr.le ha hγ hγ1 hδ (zero_le_one.trans hB) + obtain ⟨qD,hqD,hsepD⟩ := exists_logarithmic_scale_threshold R + obtain ⟨qS,hqS,hslab⟩ := exists_centered_slab_threshold C S₀ + refine ⟨rho,hrho,L,K,hL,hK,qW+qT+qD+qS+7,by omega,?_⟩ + intro r s v p k hk N H S D hN hHlo hHhi hSlo hShi hD m n u hNe hm hu hsep + Edge _ left right t ht hgraph ι _ _ index hindex hcover + dsimp only + let scale := (8/(rho:ℝ))*(N^k)^30 + let η := localizedCountertermBound freq*N^r/scale + let ε := ((N^k)^19)⁻¹ + let tol := (N^(2*r+p+6))⁻¹ + let Eform := localizedHubbardFormError m freq D (tol+tol) + let A := hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)-Eform + let kin := (m+1:ℝ)*(((m+1:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+2*(m+1:ℝ)*ε + let g := (N^(qG+2*r))⁻¹ + let I := 3*((2*(m+1:ℝ)*ε)^2+scale⁻¹^2*(8*(m+1:ℝ)^3*kin)+ + (B/(N^k)^20)^2*((m+1:ℝ)+2*kin)*(m+1:ℝ))/g + let center := scale^2*(n+2:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+ + scale*(hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)) + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hscale : 0 < scale := manufactured_scale_positive hrho hN k + have hh : 0 < 1/(N^k)^10 := manufactured_mesh_positive hN k + have he : 0 ≤ ε := by dsimp [ε]; positivity + have htol : 0 ≤ tol := by dsimp [tol]; positivity + have hmatch : (rho:ℝ)*(1/(N^k)^10)^3/8=scale⁻¹ := by + dsimp [scale] + field_simp + obtain ⟨hcoeff,_hη0,_hη1,hres,G,hflow,hbij,hLip,hAnti,hfix,hcharge,hreg,hjets,hfull,hraw,hmatrix⟩ := + hwitness r s (2*r+p+6) k (by omega) N H S D hN hHlo hHhi hSlo hShi hD + (m+1) u (by simpa only [Nat.cast_add,Nat.cast_one] using hm) hu hsep index hindex hcover + obtain ⟨hη0,_hη1,hηδ,hresSmall,hE,hg,hsmall,hI⟩ := + hscalar r v p k (by omega) N D hN hD m u left right t hm ht + obtain ⟨hS,hH,hCH,hrH⟩ := hslab k (by omega) N hN H S hHlo hSlo hShi + have hsepR : R ≤ D := (hsepD k (by omega) N hN).trans hD + have hcount : (m+1:ℝ) ≤ Real.exp ((19/320:ℝ)*D) := + hm.trans (polynomial_count_le_exp_separation hN (by omega : r ≤ k) hD) + have hNeR : (n+2:ℝ)=(m+1:ℝ) := by exact_mod_cast hNe + have hresSmall' : (n+1:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 := by + have hn : (n+1:ℝ) ≤ (m+1:ℝ) := by linarith only [hNeR] + exact (mul_le_mul_of_nonneg_right hn (by positivity)).trans hresSmall + have hB0 : 0 ≤ B/(N^k)^20 := div_nonneg (zero_le_one.trans hB) (by positivity) + have hground' := hground m n D S H scale ((N^k)^5) ε η tol tol hsepR + (by simpa only [Nat.cast_add,Nat.cast_one] using hcount) hS hH hCH hscale + (by positivity) hrH hSlo he hη0 hηδ htol htol u hsep hcoeff hres hresSmall' + index hindex (fun x => G x 1) hbij.injective (1/(N^k)^10) hh hmatch + (B/(N^k)^20) hB0 (fun w s i => hfull (n+2) w s i) hraw hmatrix left right t (by simpa only [scale,tol,Complex.ofReal_mul] using hgraph) hNe g hg + simp only [Nat.cast_add,Nat.cast_one,Nat.cast_ofNat,hNeR] at hground' + have hbnds := hground' hsmall + have hcenter : scale^2*(m+1:ℝ)*(slabPotential rho H S 0+((-1/2:ℝ)+freq/2))+ + scale*(hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)) = center := by + dsimp only [center] + rw [hNeR] + rw [hcenter] at hbnds + change ((center-scale*Eform-scale^2*I:ℝ):EReal) ≤ _ ∧ _ ≤ ((center+scale*Eform:ℝ):EReal) at hbnds + have hpow : (N^(p+2))⁻¹+(N^(p+2))⁻¹ ≤ (N^p)⁻¹ := by + apply (double_inverse_power_le hN (p+1)).trans + exact inv_anti₀ (by positivity) (pow_le_pow_right₀ hN1 (by omega : p ≤ p+1)) + have htotal : scale*Eform+scale^2*I ≤ scale*(N^p)⁻¹ := by + have hEI := add_le_add hE hI + have hmul := mul_le_mul_of_nonneg_left (hEI.trans hpow) hscale.le + change scale*(Eform+scale*I) ≤ _ at hmul + nlinarith only [hmul] + have hEonly : scale*Eform ≤ scale*(N^p)⁻¹ := by + apply mul_le_mul_of_nonneg_left (hE.trans ?_) hscale.le + exact inv_anti₀ (by positivity) (pow_le_pow_right₀ hN1 (by omega : p ≤ p+2)) + have hcounter (i : Fin (m+1)) : localizedCounterterm freq u i ≤ scale := + (div_le_one hscale).mp ((hcoeff i).2.trans _hη1) + refine ⟨G,hbij,hflow,hLip,hAnti,hfix,hcharge,hreg,hjets,hcounter,?_,?_⟩ + · have hlo : center-scale*(N^p)⁻¹ ≤ center-scale*Eform-scale^2*I := by linarith only [htotal] + exact (EReal.coe_le_coe_iff.mpr hlo).trans hbnds.1 + · have hup : center+scale*Eform ≤ center+scale*(N^p)⁻¹ := by linarith only [hEonly] + exact hbnds.2.trans (EReal.coe_le_coe_iff.mpr hup) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPreciseResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPreciseResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..843b9ab6a652170b54d15bcb33650467d4b6ace2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedPreciseResidual.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualGap + +namespace OAI + +/-! The uniform spectral gap uses a fixed threshold, while residual precision +uses the actual, smaller counterterm ratio chosen by the reduction. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_precise_manyElectron_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m : ℕ) (D S H scale r ε η : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + ∀ (n : ℕ) (v : Coulomb.H1Vector (n+1)), + (n+1:ℕ)*((-1/2:ℝ)+freq/2+γ/4)*Coulomb.mass v- + (γ/4+ε+ε^2/(γ/4))*totalOrbitalMass v + (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp (lt_of_lt_of_le zero_lt_one hfreq) u i)) ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hgap⟩ := + manufacturedSlab_growing_complement_gap hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC, + fun m D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr n v => ?_⟩ + have hs := hover D ((le_max_right _ _).trans hD) m hm + have hbound := manufacturedSlab_residual_finite_rank_lower hdensity hrho + (lt_of_lt_of_le zero_lt_one hH) (lt_of_lt_of_le zero_lt_one (hS₀.trans hS)) + hf hrelation hr hrH hrS hγ scale u hsep hs hη hcoeff hε herr + (hgap m D S H scale ((le_max_left _ _).trans hD) hm hS hH hCH hscale u hsep (fun i => ⟨(hcoeff i).1,(hcoeff i).2.trans hηδ⟩)) + have hHpos : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hHpos.le hSpos freq scale u + exact manyElectron_projection_lower _ + (manufacturedSlabPotential_continuous hrho hHpos.le hSpos.le freq scale u) + B hB _ _ _ hbound v + + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedProjectedLower.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedProjectedLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..061d6567f50a6302d63ecd7954a513a68b2aba68 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedProjectedLower.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronProjectedLower + +namespace OAI + +/-! Uniform projected lower bound for the actual manufactured Coulomb field. +Only the published planar, oscillator and Sobolev-density inputs occur. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_projected_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m : ℕ) (D S H scale r : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + ∀ v : Coulomb.H1Vector 1, + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let P := correctedOneElectronProjection hf u v + let Q := correctedOneElectronRemainder hf u v + let V := fun x : Configuration 1 => + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x) + boundedPotentialForm V P-((-1/2:ℝ)+freq/2)*Coulomb.mass P+ + (γ/4)*Coulomb.mass Q- + ((4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D r u j))/(γ/4))* + Coulomb.mass P ≤ boundedPotentialForm V v-((-1/2:ℝ)+freq/2)*Coulomb.mass v := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hgap⟩ := + manufacturedSlab_growing_complement_gap hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC, + fun m D S H scale r hD hm hS hH hCH hscale hr hrH hrS u hsep hcoeff v => ?_⟩ + have hs := hover D ((le_max_right _ _).trans hD) m hm + have hg := hgap m D S H scale ((le_max_left _ _).trans hD) hm hS hH hCH hscale + u hsep hcoeff (correctedOneElectronRemainder hf u v) + (correctedOneElectronRemainder_orthogonal hf u hsep hs v) + exact manufacturedSlab_projected_lower hdensity hrho + (lt_of_lt_of_le zero_lt_one hH) (lt_of_lt_of_le zero_lt_one (hS₀.trans hS)) + hf hrelation hr hrH hrS hγ scale u hsep hs hδ.le hcoeff v hg + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfcdce68be536eca92b926d2f42710a1489fe996 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualGap.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedDiagonalBound +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ElectronSlotBound + +namespace OAI + +/-! The residual-controlled one-electron estimate and its integral over all +electron slots. The admitted many-electron state remains unrestricted. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem manufacturedSlab_residual_finite_rank_lower + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R γ ε : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (hγ : 0 < γ) (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) + (hε : 0 ≤ ε) (herr : 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) ≤ ε^2) + (hgap : ∀ v : Coulomb.H1Vector 1, + (∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v (Sum.inl s)) = 0) → + ((-1/2:ℝ)+freq/2+γ/2)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v) + (v : Coulomb.H1Vector 1) : + ((-1/2:ℝ)+freq/2+γ/4)*Coulomb.mass v- + (γ/4+ε+ε^2/(γ/4))*graphOrbitalMass + (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hfreq u i)) (h1Coordinates v) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v := by + have hg := hgap (correctedOneElectronRemainder hfreq u v) + (correctedOneElectronRemainder_orthogonal hfreq u hsep hs v) + have hp := manufacturedSlab_projected_lower hdensity hrho hH hS hfreq hrelation hR hRH hRS + hγ scale u hsep hs hδ hcoeff v hg + have hd := corrected_diagonal_lower hdensity hrho hH hS hfreq hrelation hR hRH hRS + scale u hsep hs hδ hcoeff hε herr (correctedOneElectronCoefficients hfreq u v) + have hm := correctedOneElectron_mass_decomposition hfreq u hsep hs v + rw [← correctedOneElectronProjection_mass hfreq u hsep hs v] + have he := mul_le_mul_of_nonneg_right + (div_le_div_of_nonneg_right herr (by positivity : 0 ≤ γ/4)) + (Coulomb.mass_nonneg (correctedOneElectronProjection hfreq u v)) + change (((-1/2:ℝ)+freq/2)-ε)*Coulomb.mass (correctedOneElectronProjection hfreq u v) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) (correctedOneElectronProjection hfreq u v) at hd + rw [hm] at hp ⊢ + nlinarith only [hp,hd,he] + +theorem manufacturedSlab_uniform_residual_manyElectron_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m : ℕ) (D S H scale r ε : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D r u j) ≤ ε^2 → + ∀ (n : ℕ) (v : Coulomb.H1Vector (n+1)), + (n+1:ℕ)*((-1/2:ℝ)+freq/2+γ/4)*Coulomb.mass v- + (γ/4+ε+ε^2/(γ/4))*totalOrbitalMass v + (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp (lt_of_lt_of_le zero_lt_one hfreq) u i)) ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) v := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hgap⟩ := + manufacturedSlab_growing_complement_gap hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC, + fun m D S H scale r ε hD hm hS hH hCH hscale hr hrH hrS hε u hsep hcoeff herr n v => ?_⟩ + have hs := hover D ((le_max_right _ _).trans hD) m hm + have hbound := manufacturedSlab_residual_finite_rank_lower hdensity hrho + (lt_of_lt_of_le zero_lt_one hH) (lt_of_lt_of_le zero_lt_one (hS₀.trans hS)) + hf hrelation hr hrH hrS hγ scale u hsep hs hδ.le hcoeff hε herr + (hgap m D S H scale ((le_max_left _ _).trans hD) hm hS hH hCH hscale u hsep hcoeff) + have hHpos : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hHpos.le hSpos freq scale u + exact manyElectron_projection_lower _ + (manufacturedSlabPotential_continuous hrho hHpos.le hSpos.le freq scale u) + B hB _ _ _ hbound v + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualMajorant.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b1b646e99e8e5f956425cf364cdb7799746688a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualMajorant.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialResidualBudget + +namespace OAI + +/-! A four-term majorant for the actual manufactured differential residual. +The denominator powers are the ones used by the fixed physical schedule. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem manufacturedResidual_four_power_majorant {freq : ℝ} (hf : 0 < freq) + {rho : ℝ} (hrho : 0 ≤ rho) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ R L H S D a d δ M : ℝ, + 2 ≤ R → 1 ≤ L → R^50 ≤ H → H ≤ 2*R^50 → R^5 ≤ S → S ≤ 2*R^5 → + 0 < a → 0 ≤ d → 0 ≤ δ → δ ≤ 1 → δ ≤ d*M/(a*R^30) → + Real.exp (-(19/10:ℝ)*D) ≤ (R^40)⁻¹ → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), (m:ℝ) ≤ M → (∀ j, ‖u j‖ ≤ L) → + 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D (R^5) u j) ≤ + 12*(PlanarSobolev.wellBound*planarWellMatrixConstant)*M^5/R^40+ + 768*C*M^3*L^72/R^70+ + (12*PlanarSobolev.wellBound^2*d^2/a^2)*M^7/R^60+ + 12288*PlanarSobolev.wellBound^2*C*M^5*L^8/R^40 := by + obtain ⟨C,hC,hbound⟩ := manufacturedResidual_polynomial_geometry hf hrho + refine ⟨C,hC,fun R L H S D a d δ M hR hL hHlo hHhi hSlo hShi ha hd hδ hδ1 hδa he m u hm hu => ?_⟩ + have hR0 : 0 < R := by linarith + have hM : 0 ≤ M := (Nat.cast_nonneg m).trans hm + have hW := PlanarSobolev.wellBound_nonnegative + have hP := planarWellMatrixConstant_nonnegative + have hr5 : 2 ≤ R^5 := hR.trans (le_self_pow₀ (by linarith) (by decide)) + have hb := hbound (R^5) L H S δ D hr5 hL + (by simpa only [← pow_mul] using hHlo) (by simpa only [← pow_mul] using hHhi) + hSlo hShi m u hu + have h1 : (m:ℝ)^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)* + Real.exp (-(19/10:ℝ)*D) ≤ M^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)/R^40 := by + calc + _ ≤ M^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)*(R^40)⁻¹ := by gcongr + _ = _ := by rw [div_eq_mul_inv] + have h3 : ((m:ℝ)*δ*PlanarSobolev.wellBound)^2 ≤ + (M*(d*M/(a*R^30))*PlanarSobolev.wellBound)^2 := by gcongr + have h4 : 256*((m:ℝ)*(δ+1)*PlanarSobolev.wellBound)^2*C*L^8/(R^5)^8 ≤ + 1024*M^2*PlanarSobolev.wellBound^2*C*L^8/R^40 := by + calc + _ ≤ 256*(M*2*PlanarSobolev.wellBound)^2*C*L^8/(R^5)^8 := by gcongr; linarith + _ = _ := by rw [← pow_mul]; ring + have h2 : 64*C*L^72/(R^5)^14 = 64*C*L^72/R^70 := by rw [← pow_mul] + have hp := add_le_add (add_le_add (add_le_add h1 (le_of_eq h2)) h3) h4 + have hscaled := mul_le_mul_of_nonneg_left hb (show 0 ≤ 4*(m:ℝ)^2 by positivity) + calc + _ ≤ 12*(m:ℝ)^3*((m:ℝ)^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)* + Real.exp (-(19/10:ℝ)*D)+64*C*L^72/(R^5)^14+ + ((m:ℝ)*δ*PlanarSobolev.wellBound)^2+ + 256*((m:ℝ)*(δ+1)*PlanarSobolev.wellBound)^2*C*L^8/(R^5)^8) := by + convert hscaled using 1 + ring + _ ≤ 12*M^3*(M^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)/R^40+ + 64*C*L^72/R^70+(M*(d*M/(a*R^30))*PlanarSobolev.wellBound)^2+ + 1024*M^2*PlanarSobolev.wellBound^2*C*L^8/R^40) := by + exact mul_le_mul (by gcongr) hp (by positivity) (by positivity) + _ = _ := by + field_simp [ne_of_gt ha,ne_of_gt hR0] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualPairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c58bb20a33502d27db0b9fee77ae01fb55ccb2c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualPairing.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWeakResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1PairingBound + +namespace OAI + +/-! The actual manufactured operator's mixed mode pairing is bounded by +its proved differential residual, uniformly on the full weak-H1 domain. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def manufacturedModePairing (rho H S freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) (v : Coulomb.H1Vector 1) + (s : SpinConfiguration 1) : ℂ := + (1/2:ℂ)*(∑ a, ∫ x, v.gradient s a x* + (configurationRealPartial (oneElectronLocalizedMode freq (u j)) a x : ℂ))+ + (∫ x, v.value s x*(manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)*oneElectronLocalizedMode freq (u j) x : ℝ))- + (((-1/2:ℝ)+freq/2):ℂ)*(∫ x, v.value s x*(oneElectronLocalizedMode freq (u j) x : ℂ)) + +theorem manufacturedModePairing_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + ‖manufacturedModePairing rho H S freq scale u j v s‖^2 ≤ + manufacturedOrbitalSquaredError rho H S freq δ D R u j*(∫ x, ‖v.value s x‖^2) := by + rw [manufacturedModePairing, + manufacturedOrbitalResidual_weak_identity hdensity hrho hH.le hS hfreq hrelation scale u hδ hcoeff] + have hmem := (manufacturedOrbitalResidual_memLp hrho hH.le hS.le hfreq scale u hδ hcoeff j).comp_measurePreserving oneElectronCoordinates.measurePreserving + have h := h1_real_pairing_sq_le v s + (fun x => manufacturedOrbitalResidual rho H S freq scale u j (oneElectronCoordinates x)) hmem + have hint : (∫ x : Configuration 1, + manufacturedOrbitalResidual rho H S freq scale u j (oneElectronCoordinates x)^2) = + ∫ x, manufacturedOrbitalResidual rho H S freq scale u j x^2 := + oneElectronCoordinates_integral (fun x => manufacturedOrbitalResidual rho H S freq scale u j x^2) + rw [hint] at h + exact h.trans (mul_le_mul_of_nonneg_right + (manufacturedOrbitalResidual_square_bound hrho hH hS hfreq hR hRH hRS scale u hsep hδ hcoeff j) + (integral_nonneg (fun _ => sq_nonneg _))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualParameters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..e74e9263bb70b4ffcd90918397c9f00ca3984e23 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualParameters.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedResidualMajorant + +namespace OAI + +/-! Fixed polynomial exponents control the actual differential residual +uniformly in the source size, the site count and the coordinate extent. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem exists_manufactured_residual_parameter_offset {freq rho a d : ℝ} + (hf : 0 < freq) (hrho : 0 ≤ rho) (ha : 0 < a) (hd : 0 ≤ d) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ r s k : ℕ, k₀+7*r+72*s ≤ k → ∀ N : ℝ, 2 ≤ N → + ∀ H S D δ : ℝ, (N^k)^50 ≤ H → H ≤ 2*(N^k)^50 → + (N^k)^5 ≤ S → S ≤ 2*(N^k)^5 → + 25*(k:ℝ)*Real.log N ≤ D → 0 ≤ δ → δ ≤ d*N^r/(a*(N^k)^30) → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), (m:ℝ) ≤ N^r → (∀ j, ‖u j‖ ≤ N^s) → + δ ≤ 1 ∧ 4*(m:ℝ)^2*(∑ j, + manufacturedOrbitalSquaredError rho H S freq δ D ((N^k)^5) u j) ≤ + ((N^k)^19)⁻¹^2 := by + obtain ⟨C,hC,hmajor⟩ := manufacturedResidual_four_power_majorant hf hrho + let A := 12*(PlanarSobolev.wellBound*planarWellMatrixConstant) + let B := 768*C + let V := 12*PlanarSobolev.wellBound^2*d^2/a^2 + let W := 12288*PlanarSobolev.wellBound^2*C + have hwell := PlanarSobolev.wellBound_nonnegative + have hplanar := planarWellMatrixConstant_nonnegative + have hA : 0 ≤ A := by dsimp [A]; positivity + have hB : 0 ≤ B := by dsimp [B]; positivity + have hV : 0 ≤ V := by dsimp [V]; positivity + have hW : 0 ≤ W := by dsimp [W]; positivity + obtain ⟨k₁,hk₁,hsmall⟩ := exists_four_residual_norm_offset A B V W hA hB hV hW + obtain ⟨q,_hq,hcoef⟩ := exists_polynomial_constant_bounds + (show (0:ℝ)<1 by norm_num) (d/a) + refine ⟨k₁+q+2,by omega,?_⟩ + intro r s k hk N hN H S D δ hHlo hHhi hSlo hShi hD hδ hδa m u hm hu + let E := 7*r+72*s + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hk1 : 1 ≤ k := by omega + have hR : 2 ≤ N^k := hN.trans (le_self_pow₀ hN1 (by omega)) + have hδ1 : δ ≤ 1 := by + calc + δ ≤ (d/a)*N^r/N^(k*30) := by + convert hδa using 1 + rw [pow_mul] + ring + _ ≤ N^q*N^r/N^(k*30) := by + apply div_le_div_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_right (hcoef N hN).2 (by positivity) + _ ≤ 1 := by + rw [div_le_one (pow_pos hN0 _),← pow_add] + exact pow_le_pow_right₀ hN1 (by omega) + refine ⟨hδ1,?_⟩ + have hmaj := hmajor (N^k) (N^s) H S D a d δ (N^r) hR (one_le_pow₀ hN1) + hHlo hHhi hSlo hShi ha hd hδ hδ1 hδa (logarithmic_separation_residual hN k hD) m u hm hu + change _ ≤ A*(N^r)^5/(N^k)^40+B*(N^r)^3*(N^s)^72/(N^k)^70+ + V*(N^r)^7/(N^k)^60+W*(N^r)^5*(N^s)^8/(N^k)^40 at hmaj + have hp5 : (N^r)^5 ≤ N^E := by + rw [← pow_mul] + exact pow_le_pow_right₀ hN1 (by dsimp [E]; omega) + have hp3 : (N^r)^3*(N^s)^72 ≤ N^E := by + rw [← pow_mul,← pow_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by dsimp [E]; omega) + have hp7 : (N^r)^7 ≤ N^E := by + rw [← pow_mul] + exact pow_le_pow_right₀ hN1 (by dsimp [E]; omega) + have hp58 : (N^r)^5*(N^s)^8 ≤ N^E := by + rw [← pow_mul,← pow_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by dsimp [E]; omega) + have ht1 : A*(N^r)^5/(N^k)^40 ≤ A*N^E/(N^k)^40 := by gcongr + have ht2 : B*(N^r)^3*(N^s)^72/(N^k)^70 ≤ B*N^E/(N^k)^70 := by + rw [mul_assoc] + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hp3 hB) (by positivity) + have ht3 : V*(N^r)^7/(N^k)^60 ≤ V*N^E/(N^k)^60 := by gcongr + have ht4 : W*(N^r)^5*(N^s)^8/(N^k)^40 ≤ W*N^E/(N^k)^40 := by + rw [mul_assoc] + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hp58 hW) (by positivity) + exact hmaj.trans ((add_le_add (add_le_add (add_le_add ht1 ht2) ht3) ht4).trans + (hsmall E k (by dsimp [E]; omega) N hN)) + +theorem exists_manufactured_residual_parameters {freq rho a d : ℝ} + (hf : 0 < freq) (hrho : 0 ≤ rho) (ha : 0 < a) (hd : 0 ≤ d) (r s : ℕ) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ k : ℕ, k₀ ≤ k → ∀ N : ℝ, 2 ≤ N → + ∀ H S D δ : ℝ, (N^k)^50 ≤ H → H ≤ 2*(N^k)^50 → + (N^k)^5 ≤ S → S ≤ 2*(N^k)^5 → + 25*(k:ℝ)*Real.log N ≤ D → 0 ≤ δ → δ ≤ d*N^r/(a*(N^k)^30) → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), (m:ℝ) ≤ N^r → (∀ j, ‖u j‖ ≤ N^s) → + δ ≤ 1 ∧ 4*(m:ℝ)^2*(∑ j, + manufacturedOrbitalSquaredError rho H S freq δ D ((N^k)^5) u j) ≤ + ((N^k)^19)⁻¹^2 := by + obtain ⟨q,hq,hbound⟩ := exists_manufactured_residual_parameter_offset hf hrho ha hd + exact ⟨q+7*r+72*s,by omega,fun k hk => hbound r s k hk⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f12e881684e517992bf04c21ce5c970863fed8b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedResidualScale.lean @@ -0,0 +1,41 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabHighAspectRatio +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalResidual + +namespace OAI + +/-! A numerical bound on the actual residual expression used by the full +complement theorem, at the high-aspect slab parameters. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem manufacturedOrbitalSquaredError_tenthPower {rho T freq δ D : ℝ} + (hrho : 0 ≤ rho) (hT : 2 ≤ T) {m : ℕ} (u : Fin m → PlanarPosition) (j : Fin m) : + manufacturedOrbitalSquaredError rho (T^10) T freq δ D T u j ≤ + 3*((m:ℝ)^2*(PlanarSobolev.wellBound*planarWellMatrixConstant)*Real.exp (-(19/10:ℝ)*D)+ + slabResidualSeventySecondBound rho freq (u j)/T^14+ + ((m:ℝ)*δ*PlanarSobolev.wellBound)^2+ + 256*((m:ℝ)*(δ+1)*PlanarSobolev.wellBound)^2*localizedDensityMoment freq (u j) 8/T^8) := by + have ht : T ≠ 0 := by linarith + have htail := slabSeventySecondTail_tenthPower_bound (freq := freq) hrho hT (u j) + have he : ((m:ℝ)*(δ+1)*PlanarSobolev.wellBound)^2* + (localizedDensityMoment freq (u j) 8/(T/2)^8) = + 256*((m:ℝ)*(δ+1)*PlanarSobolev.wellBound)^2*localizedDensityMoment freq (u j) 8/T^8 := by + field_simp [ht] + ring + unfold manufacturedOrbitalSquaredError + rw [he] + linarith + +theorem manufacturedResidual_mesh_balance {R a C D B k : ℝ} (hR : 1 ≤ R) : + a*R^30*(C/(R^5)^14+D/(R^5)^8+B*(k/R^30)^2) = + a*C/R^40+a*D/R^10+a*B*k^2/R^30 := by + have hR0 : R ≠ 0 := ne_of_gt (lt_of_lt_of_le zero_lt_one hR) + field_simp [hR0] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScalarParameters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScalarParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..6054e4d369b398efec499b42bad23b93ccfadc7b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScalarParameters.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.HubbardTolerance +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ComplementParameterBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.ComplementSmallness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ShiftedHubbardBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCounterterms + +namespace OAI + +/-! A single polynomial exponent closes the numerical hypotheses of the +full-domain manufactured-grid comparison. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb +open HubbardGlobal + +theorem manufactured_scalar_parameters {freq rho a γ δ B : ℝ} + (hf : 1 ≤ freq) (hrho : 0 ≤ rho) (ha : 0 < a) + (hγ : 0 < γ) (hγ1 : γ ≤ 1/4) (hδ : 0 < δ) (hB : 0 ≤ B) : + ∃ q qG : ℕ, 1 ≤ q ∧ 1 ≤ qG ∧ + ∀ r v p k : ℕ, q+9*r+v+p ≤ k → ∀ N D : ℝ, + 2 ≤ N → 25*(k:ℝ)*Real.log N ≤ D → + ∀ {Edge : Type} [Fintype Edge] (m : ℕ) (u : Fin (m+1) → PlanarPosition) + (left right : Edge → Fin (m+1)) (t : Edge → ℝ), + (m+1:ℝ) ≤ N^r → (∑ e, |t e|) ≤ N^v → + let scale := a*(N^k)^30 + let η := localizedCountertermBound freq*N^r/scale + let ε := ((N^k)^19)⁻¹ + let tol := (N^(2*r+p+6))⁻¹ + let Eform := localizedHubbardFormError m freq D (tol+tol) + let A := hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)-Eform + let K := (m+1:ℝ)*(((m+1:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+2*(m+1:ℝ)*ε + let g₀ := (γ/8)/(2*((m+1:ℝ)*(((m+1:ℝ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) + let g := (N^(qG+2*r))⁻¹ + 0 ≤ η ∧ η ≤ 1 ∧ η ≤ δ ∧ + (m+1:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 ∧ + Eform ≤ (N^(p+2))⁻¹ ∧ 0 < g ∧ + (B/(N^k)^20)*(m+1:ℝ)+|A/scale|+g ≤ g₀ ∧ + scale*(3*((2*(m+1:ℝ)*ε)^2+scale⁻¹^2*(8*(m+1:ℝ)^3*K)+ + (B/(N^k)^20)^2*((m+1:ℝ)+2*K)*(m+1:ℝ))/g) ≤ (N^(p+2))⁻¹ := by + have hfp : 0 < freq := lt_of_lt_of_le zero_lt_one hf + let C := manufacturedKineticBudgetConstant freq rho + let b := γ/(16*C) + have hC : 0 < C := manufacturedKineticBudgetConstant_positive hf hrho + have hb : 0 < b := by dsimp [b]; positivity + obtain ⟨qη,hqη,heta⟩ := exists_polynomial_ratio_offset + (localizedCountertermBound freq/a) (lt_min hδ zero_lt_one) + obtain ⟨qR,hqR,hres⟩ := exists_residual_complement_smallness hγ + obtain ⟨qF,hqF,hform⟩ := exists_hubbardDouble_parameter_offset freq + obtain ⟨qG,hqG,hkin⟩ := exists_manufactured_kinetic_exponent hf hrho hγ hγ1 + obtain ⟨qA,hqA,habs⟩ := exists_shifted_hubbard_polynomial_bound hfp + obtain ⟨qB,hqB,hsmall⟩ := exists_nuclear_complement_smallness ha hb hB + obtain ⟨qI,hqI,herr⟩ := exists_complement_error_scale (b := B) ha + refine ⟨qη+qR+qF+qB+qA+qI+2*qG+3,qG,by omega,hqG,?_⟩ + intro r v p k hk N D hN hD Edge _ m u left right t hm ht + dsimp only + let scale := a*(N^k)^30 + let η := localizedCountertermBound freq*N^r/scale + let ε := ((N^k)^19)⁻¹ + let tol := (N^(2*r+p+6))⁻¹ + let Eform := localizedHubbardFormError m freq D (tol+tol) + let A := hubbardFermionBottom m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)-Eform + let K := (m+1:ℝ)*(((m+1:ℝ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+2*(m+1:ℝ)*ε + let g₀ := (γ/8)/(2*((m+1:ℝ)*(((m+1:ℝ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)) + let g := (N^(qG+2*r))⁻¹ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hR0 : 0 < N^k := by positivity + have hR1 : 1 ≤ N^k := one_le_pow₀ hN1 + have hM : 1 ≤ (m+1:ℝ) := by have := Nat.cast_nonneg (α := ℝ) m; linarith + have hM0 : 0 ≤ (m+1:ℝ) := by positivity + have he0 : 0 ≤ ε := by dsimp [ε]; positivity + have he1 : ε ≤ 1 := by dsimp [ε]; exact inv_le_one_of_one_le₀ (one_le_pow₀ hR1) + have hη0 : 0 ≤ η := by + dsimp [η,scale] + exact div_nonneg (mul_nonneg (localizedCountertermBound_nonnegative freq) (by positivity)) (by positivity) + have hηmin : η ≤ min δ 1 := by + calc + _ = (localizedCountertermBound freq/a)*N^r/(N^k)^30 := by dsimp [η,scale]; ring + _ ≤ (localizedCountertermBound freq/a)*N^r/(N^k)^2 := by + gcongr + · exact mul_nonneg (div_nonneg (localizedCountertermBound_nonnegative freq) ha.le) (pow_nonneg hN0.le r) + · decide + _ ≤ _ := by simpa only [Nat.add_zero,pow_zero,div_one] using heta r 0 k (by omega) N hN + have hη1 : η ≤ 1 := hηmin.trans (min_le_right _ _) + have hE : Eform ≤ (N^(p+2))⁻¹ := hform r p k (by omega) N D hN hD m hm + have hE1 : Eform ≤ 1 := hE.trans (inv_le_one_of_one_le₀ (one_le_pow₀ hN1)) + have hA : |A| ≤ N^(qA+2*r+v) := + habs r v N hN m u left right t D (tol+tol) hm ht (by dsimp [tol]; positivity) hE1 + obtain ⟨hK,hg₀⟩ := hkin N hN r (m+1) η ε hM hm hη0 hη1 he1 + have hgap : b/N^(2*r) ≤ g₀ := by + apply le_trans _ (manufactured_kinetic_complement_budgets hf hrho hγ hγ1 hM hη0 hη1 he1).2 + change b/N^(2*r) ≤ b/(m+1:ℝ)^2 + apply div_le_div_of_nonneg_left hb.le (by positivity) + rw [show 2*r=r*2 by omega,pow_mul] + exact pow_le_pow_left₀ hM0 hm 2 + have hsg := (hsmall r (qA+2*r+v) k (by omega) N (m+1) A hN hM0 hm hA).2 + have hsmall' : (B/(N^k)^20)*(m+1:ℝ)+|A/scale|+g ≤ g₀ := by + change 2*g ≤ g₀ at hg₀ + change (B/(N^k)^20)*(m+1:ℝ)+|A/scale|+b/(2*N^(2*r)) ≤ b/N^(2*r) at hsg + have hid : b/(2*N^(2*r))=(b/N^(2*r))/2 := by ring + rw [hid] at hsg + linarith only [hsg,hgap,hg₀] + have hK0 : 0 ≤ K := by + have hW := PlanarSobolev.wellBound_nonnegative + have hE0 : 0 ≤ (-1/2:ℝ)+freq/2 := by linarith + dsimp [K] + positivity + refine ⟨hη0,hη1,hηmin.trans (min_le_left _ _),?_,hE,by positivity,hsmall',?_⟩ + · simpa only [one_div] using hres r k (by omega) N (m+1) hN hM0 hm + · exact herr r (qG+2*r) (qG+2*r) (p+2) k (by omega) N hN (m+1) K g + hM0 hm hK0 hK le_rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScaleThreshold.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScaleThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e2626ba2b975fa47c90737c50294dbefd69784f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedScaleThreshold.lean @@ -0,0 +1,31 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ScalarScaleBudgets + +namespace OAI + +/-! The physical scale lies in the domain required by the numerical field +program after a fixed, input-independent exponent threshold. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem exists_manufactured_scale_threshold {a : ℝ} (ha : 0 < a) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ k : ℕ, q ≤ k → ∀ N : ℝ, 2 ≤ N → 1 ≤ a*(N^k)^30 := by + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds ha 1 + refine ⟨q,by omega,fun k hk N hN => ?_⟩ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hinv : 1/(N^k)^30 ≤ a := by + calc + _ ≤ (N^q)⁻¹ := by + rw [one_div] + apply inv_anti₀ (by positivity) + rw [← pow_mul] + exact pow_le_pow_right₀ hN1 (by omega) + _ ≤ _ := (hbound N hN).1 + exact (div_le_iff₀ (by positivity : 0 < (N^k)^30)).mp hinv + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedSlabLower.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedSlabLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..df32d886d668834e0d78cbf03847221dd6166d58 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedSlabLower.lean @@ -0,0 +1,40 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabConfinement + +namespace OAI + +/-! Global comparison of the actual manufactured Coulomb field with the +separable capped oscillator and planar wells. -/ + +noncomputable section +namespace ContinuumCoulomb + +def manufacturedSlabPotential (rho H S freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (x : Position) : ℝ := + slabPotential rho H S x-slabPotential rho H S 0+manufacturedWellField freq scale S u x + +theorem manufacturedSlabPotential_lower {rho H S freq scale δ : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 ≤ S) (hscale : 0 ≤ scale) + (hfreq : freq^2 = 4*Real.pi*rho) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i / scale ∧ + localizedCounterterm freq u i / scale ≤ δ) (x : Position) : + planarWellSum u (positionSplitCoordinates x).1 + + verticalCapPotential freq S (positionSplitCoordinates x).2 - + (δ*PlanarSobolev.wellBound+6*Real.pi*rho*S^3/H) ≤ + manufacturedSlabPotential rho H S freq scale u x := by + have hs := slabPotential_confinement hrho hH hS x + have hw := manufacturedWellField_lower freq hscale S u hsep hδ hcoeff x + have he : verticalCapPotential freq S (positionSplitCoordinates x).2 = + 2*Real.pi*rho*min ((x 2)^2) (S^2) := by + rw [verticalCapPotential,hfreq,positionSplitCoordinates_snd] + ring + rw [he] + unfold manufacturedSlabPotential + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorCoercivity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorCoercivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..357c780ba1d309807e312574fadfc3141cac86e6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorCoercivity.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedCoercivity + +namespace OAI + +/-! Uniform kinetic coercivity on the actual spinful tensor complement. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_tensorComplement_coercivity + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 1 ≤ C ∧ + ∀ (m n : ℕ) (D S H scale r ε η : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin (m+1) → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ v : Coulomb.H1Vector (n+1), Coulomb.Antisymmetric v → + let hf := lt_of_lt_of_le zero_lt_one hfreq + let q := finiteTensorRemainder (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) v + ((γ/8)/(2*((n+1:ℕ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+ + 6*Real.pi*rho+((-1/2:ℝ)+freq/2))+γ/8+1)))* + (Coulomb.mass q+2*Coulomb.kinetic q) ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) q-(n+1:ℕ)*((-1/2:ℝ)+freq/2)*Coulomb.mass q := by + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hgap⟩ := + manufacturedSlab_uniform_tensorComplement_gap hp hv hdensity hfreq hrho hrelation + refine ⟨γ,R,S₀,δ,max C 1,hγ,hγsmall,hR,hS₀,hδ,le_max_right _ _, + fun m n D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall v ha => ?_⟩ + have hSpos : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hHpos : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hSbase : S^3 ≤ max C 1*S^3 := by + simpa only [one_mul] using mul_le_mul_of_nonneg_right (le_max_right C 1) + (pow_nonneg hSpos.le 3) + have hSH : S^3 ≤ H := hSbase.trans hCH + have hCH' : C*S^3 ≤ H := + (mul_le_mul_of_nonneg_right (le_max_left C 1) (pow_nonneg hSpos.le 3)).trans hCH + have hsep₂ (i j : Fin (m+1)) (hij : i≠j) : 2 ≤ ‖u i-u j‖ := + (by linarith : 2 ≤ D).trans (hsep i j hij) + have hg := hgap m n D S H scale r ε η hD hm hS hH hCH' hscale hr hrH hrS + hε hη hηδ u hsep hcoeff herr hsmall v ha + exact manufacturedSlab_coercive_of_gap hrho hHpos hSpos hSH hscale hrelation + u hsep₂ hη hcoeff _ (by linarith) (by positivity) hg + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorDiagonal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..128af59baf2ca2ab7d8048a3b8594c3f7d321ce1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorDiagonal.lean @@ -0,0 +1,101 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorProjection + +namespace OAI + +/-! Actual compressed manufactured-field energy and kinetic estimates. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem localizedTensorState_diagonal_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq η D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (c : (Fin (n+1) → Fin ((2*m+1)+1)) → ℂ) : + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) c + (boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) p-(n+1:ℝ)*((-1/2:ℝ)+freq/2)*Coulomb.mass p)^2 ≤ + (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, manufacturedOrbitalSquaredError rho H S freq η D R u j)* + Coulomb.mass p*Coulomb.mass p := by + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hsum (x : Configuration (n+1)) : + |∑ i, manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i)| ≤ + (n+1:ℝ)*B := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + Nat.cast_add,Nat.cast_one] using Finset.sum_le_sum (s := Finset.univ) + (fun i _ => hB (Coulomb.position x i)) + have hc := finiteTensorState_diagonal_square_bound hdensity + (localizedSpinMode freq u) (localizedSpinResidual rho H S freq scale u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_C2 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) + (localizedSpinResidual_memLp hrho hH.le hS.le hfreq scale u hη hcoeff) + (fun a b => by + have h := localizedSpinMode_inner hfreq u hsep hs a b + by_cases hab : a=b <;> simpa only [hab,ite_true,ite_false] using h) + (manufacturedSlabPotential rho H S freq scale u) + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u) + ((-1/2:ℝ)+freq/2) ((n+1:ℝ)*B) hsum + (fun a s x => by + simpa only [Complex.ofReal_add,Complex.ofReal_div,Complex.ofReal_neg, + Complex.ofReal_one,Complex.ofReal_ofNat] using + localizedSpinResidual_operator hrelation H S scale u a s x) c + apply hc.trans + apply mul_le_mul_of_nonneg_right _ (Coulomb.mass_nonneg _) + apply mul_le_mul_of_nonneg_right _ (Coulomb.mass_nonneg _) + exact mul_le_mul_of_nonneg_left + (localizedSpinResidual_sum_bound hrho hH hS hfreq hR hRH hRS scale u hsep hs hη hcoeff) + (sq_nonneg _) + +theorem localizedTensorState_kinetic_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq η D R ε : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) + (hfreq : 0 < freq) (hrelation : freq^2 = 4*Real.pi*rho) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) (hscale : 0 ≤ scale) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hD : 2 ≤ D) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (hε : 0 ≤ ε) + (herr : (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, + manufacturedOrbitalSquaredError rho H S freq η D R u j) ≤ ε^2) + (c : (Fin (n+1) → Fin ((2*m+1)+1)) → ℂ) : + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) c + Coulomb.kinetic p ≤ + ((n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε)*Coulomb.mass p := by + let p := finiteTensorState (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) c + have hb := localizedTensorState_diagonal_square_bound hdensity hrho hH hS hfreq hrelation + hR hRH hRS scale u hsep hs hη hcoeff c + have hb' := hb.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right herr (Coulomb.mass_nonneg p)) (Coulomb.mass_nonneg p)) + have hnonneg : 0 ≤ ε*Coulomb.mass p := mul_nonneg hε (Coulomb.mass_nonneg p) + have hupper : boundedPotentialForm (fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i)) p ≤ + ((n+1:ℝ)*((-1/2:ℝ)+freq/2)+ε)*Coulomb.mass p := by + change (_-(n+1:ℝ)*((-1/2:ℝ)+freq/2)*Coulomb.mass p)^2 ≤ _ at hb' + nlinarith only [hb',hnonneg] + have hk := manufacturedSlab_manyElectron_kinetic_lower hrho hH hS hSH hscale hrelation u + (fun i j hij => hD.trans (hsep i j hij)) hη hcoeff p + change Coulomb.kinetic p ≤ + ((n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε)*Coulomb.mass p + simp only [Nat.cast_add,Nat.cast_one] at hk ⊢ + nlinarith only [hk,hupper] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf70cd7223e428bfdebc5a159b3fbdfc843943d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorGap.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorComplementGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedPreciseResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedFockStates + +namespace OAI + +/-! A fixed positive gap on the actual full-domain tensor complement. +The only analytic inputs are the published planar, oscillator and density +statements; the finite tensor projection and its occupation deficit are proved. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_tensorComplement_gap + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 0 < C ∧ + ∀ (m n : ℕ) (D S H scale r ε η : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin (m+1) → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ v : Coulomb.H1Vector (n+1), Coulomb.Antisymmetric v → + let hf := lt_of_lt_of_le zero_lt_one hfreq + let q := finiteTensorRemainder (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) v + ((n+1:ℕ)*((-1/2:ℝ)+freq/2)+γ/8)*Coulomb.mass q ≤ + boundedPotentialForm (fun x => ∑ i, manufacturedSlabPotential rho H S freq scale u + (Coulomb.position x i)) q := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,hC,hbound⟩ := + manufacturedSlab_uniform_precise_manyElectron_lower hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,C,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ,hC, + fun m n D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall v ha => ?_⟩ + let q := finiteTensorRemainder (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) v + have hs := hover D ((le_max_right _ _).trans hD) (m+1) hm + have hocc := finiteTensorRemainder_totalOccupation (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) (localizedSpinMode_inner hf u hsep hs) + (correctedLocalizedMode freq u) (correctedLocalizedMode_memLp hf u) + (HubbardGlobal.siteModes m).symm (fun _ => rfl) v ha + have he := hbound (m+1) D S H scale r ε η ((le_max_left _ _).trans hD) hm + hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr n q + have hg := tensorComplement_energy_gap q + (fun i => oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp hf u i)) + ((-1/2:ℝ)+freq/2) (γ/4) (ε+ε^2/(γ/4)) _ + (by positivity) (by positivity) hocc (by simpa only [add_assoc] using he) + (by convert hsmall using 1; ring) + convert hg using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorLower.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ce27dfbf6ccae057b0ca715303eca4b69757724 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorLower.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorVariationalLower + +namespace OAI + +/-! Complement elimination for the actual manufactured field. All +off-diagonal and kinetic estimates are discharged from the orbitals. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedTensor_interacting_lower + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq η D R ε : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hSH : S^3 ≤ H) + (hfreq : 1 ≤ freq) (hrelation : freq^2 = 4*Real.pi*rho) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) (hscale : 0 ≤ scale) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hD : 2 ≤ D) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (hε : 0 ≤ ε) + (herr : (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, + manufacturedOrbitalSquaredError rho H S freq η D R u j) ≤ ε^2) + (w : Coulomb.H1Vector (n+1)) (a g t : ℝ) (hg : 0 < g) (ht : 0 ≤ t) : + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε + (E+a)*Coulomb.mass p ≤ boundedPotentialForm V p+t*Coulomb.pairEnergy p → + (E+a+g)*Coulomb.mass q ≤ boundedPotentialForm V q → + (E+a-(2*(ε^2+t^2*(8*(n+1:ℝ)^3*K)))/g)*Coulomb.mass w ≤ + boundedPotentialForm V w+t*Coulomb.pairEnergy w := by + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+ε + change (E+a)*Coulomb.mass p ≤ boundedPotentialForm V p+t*Coulomb.pairEnergy p → + (E+a+g)*Coulomb.mass q ≤ boundedPotentialForm V q → _ + intro hfinite hcomp + have hV : Continuous V := continuous_finsetSum _ (fun i _ => + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + (Coulomb.positionCLM i).continuous) + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hsum (x : Configuration (n+1)) : |V x| ≤ (n+1:ℝ)*B := by + apply (Finset.abs_sum_le_sum_abs _ _).trans + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul, + Nat.cast_add,Nat.cast_one] using Finset.sum_le_sum (s := Finset.univ) + (fun i _ => hB (Coulomb.position x i)) + have hc := manufacturedTensorProjection_mixed_square_bound hdensity hrho hH hS hf hrelation + hR hRH hRS scale u hsep hs hη hcoeff ((n+1:ℝ)*B) hsum w + have hc' : (graphBoundedCross (BoundedPotential.operator V hV _ hsum) + (h1Coordinates p) (h1Coordinates q))^2 ≤ ε^2*Coulomb.mass p*Coulomb.mass q := + hc.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right herr (Coulomb.mass_nonneg p)) (Coulomb.mass_nonneg q)) + have hk : Coulomb.kinetic p ≤ K*Coulomb.mass p := + localizedTensorState_kinetic_bound hdensity hrho hH hS hSH hf hrelation hR hRH hRS + scale hscale u hD hsep hs hη hcoeff hε herr (Coulomb.orbitalCoefficient w (localizedSpinMode freq u)) + have hK : 0 ≤ K := by + have he : 0 ≤ (-1/2:ℝ)+freq/2 := by linarith only [hfreq] + have hw := PlanarSobolev.wellBound_nonnegative + dsimp only [K] + positivity + simpa only [E,K,V,Nat.cast_add,Nat.cast_one] using + tensorProjection_interacting_lower (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) + (fun i j => by + have h := localizedSpinMode_inner hf u hsep hs i j + by_cases hij : i=j <;> simpa only [hij,ite_true,ite_false] using h) + V hV _ hsum w E a g (ε^2) K t + hg (sq_nonneg ε) hK ht hfinite hcomp hk hc' + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce539535ba79d6105b27fb6f5d3b28e7c70e5867 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTensorProjection.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedSpinOperator +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedCoercivity + +namespace OAI + +/-! Bounds on the actual finite tensor projection for the manufactured +potential, including its full weak-H1 orthogonal remainder. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem finiteTensorProjection_inner_remainder {n : ℕ} {α : Type*} [Fintype α] + (v : α → Position → Fin 2 → ℂ) + (hv : ∀ a s, ContDiff ℝ 1 (fun x => v a x s)) + (hL2 : ∀ a s, MemLp (fun x => v a x s) 2) + (hpartial : ∀ a s b, MemLp (fun x => fderiv ℝ (fun y => v a y s) x + (EuclideanSpace.single b 1)) 2) + (ho : ∀ a b, (∑ t : Fin 2, ∫ y, star (v a y t)*v b y t) = + if a=b then (1:ℂ) else 0) (u : Coulomb.H1Vector n) : + inner ℂ (finiteTensorProjection v hv hL2 hpartial u).toHilbert + (finiteTensorRemainder v hv hL2 hpartial u).toHilbert = 0 := by + rw [finiteTensorProjection_toHilbert,sum_inner] + simp only [inner_smul_left,finiteTensorRemainder_orthogonal v hv hL2 hpartial ho u, + mul_zero,Finset.sum_const_zero] + +theorem localizedSpinResidual_sum_bound {rho H S freq η D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) : + (∑ j, ∫ x, ‖Coulomb.flatSpinOrbital (localizedSpinResidual rho H S freq scale u j) x‖^2 + ∂Coulomb.spinSpaceMeasure) ≤ + 8*(m+1:ℕ)^2*∑ j, manufacturedOrbitalSquaredError rho H S freq η D R u j := by + rw [localizedSpinResidual_sum_norm hrho hH.le hS.le hfreq scale u hη hcoeff] + have he := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + correctedManufacturedResidual_square_bound hrho hH hS hfreq hR hRH hRS + scale u hsep hs hη hcoeff i) + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] at he + nlinarith only [he] + +theorem manufacturedTensorProjection_mixed_square_bound + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq η D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m n : ℕ} (u : Fin (m+1) → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hs : (m+1:ℕ)*localizedOverlapBound D ≤ 1/2) (hη : 0 ≤ η) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ η) + (B : ℝ) (hB : ∀ x : Configuration (n+1), + |∑ i, manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i)| ≤ B) + (w : Coulomb.H1Vector (n+1)) : + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let hV : Continuous V := continuous_finsetSum _ (fun i _ => + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + (Coulomb.positionCLM i).continuous) + (graphBoundedCross (BoundedPotential.operator V hV B hB) (h1Coordinates p) (h1Coordinates q))^2 ≤ + (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, manufacturedOrbitalSquaredError rho H S freq η D R u j)* + Coulomb.mass p*Coulomb.mass q := by + let v := localizedSpinMode freq u + have hi := finiteTensorProjection_inner_remainder v (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) + (fun a b => by + have h := localizedSpinMode_inner hfreq u hsep hs a b + by_cases hab : a=b <;> simpa only [hab,ite_true,ite_false] using h) w + have hc := finiteTensorState_mixed_square_bound hdensity v + (localizedSpinResidual rho H S freq scale u) (localizedSpinMode_C1 freq u) + (localizedSpinMode_C2 freq u) (localizedSpinMode_memLp hfreq u) + (localizedSpinMode_partial_memLp hfreq u) + (localizedSpinResidual_memLp hrho hH.le hS.le hfreq scale u hη hcoeff) + (fun a b => by + have h := localizedSpinMode_inner hfreq u hsep hs a b + by_cases hab : a=b <;> simpa only [hab,ite_true,ite_false] using h) + (manufacturedSlabPotential rho H S freq scale u) + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u) + ((-1/2:ℝ)+freq/2) B hB (fun a s x => by + simpa only [Complex.ofReal_add,Complex.ofReal_div,Complex.ofReal_neg, + Complex.ofReal_one,Complex.ofReal_ofNat] using + localizedSpinResidual_operator hrelation H S scale u a s x) + (Coulomb.orbitalCoefficient w v) + (finiteTensorRemainder v (localizedSpinMode_C1 freq u) + (localizedSpinMode_memLp hfreq u) (localizedSpinMode_partial_memLp hfreq u) w) hi + apply hc.trans + apply mul_le_mul_of_nonneg_right _ (Coulomb.mass_nonneg _) + apply mul_le_mul_of_nonneg_right _ (Coulomb.mass_nonneg _) + exact mul_le_mul_of_nonneg_left + (localizedSpinResidual_sum_bound hrho hH hS hfreq hR hRH hRS scale u hsep hs hη hcoeff) + (sq_nonneg _) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTransport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..675c96ca7effece2a7304ea5d7b5f43608a31c47 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedTransport.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedUniformFlow +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserUniformInverse + +namespace OAI + +/-! The actual manufactured fields admit transport maps with common +C4 and inverse Lipschitz constants, chosen before the instance. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb + +theorem manufactured_transport_family_with_charge (hpublished : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ + ∀ (freq scale S : ℝ), 0 < scale → 1 ≤ S → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) → + (∀ i, localizedCounterterm freq u i ≤ scale) → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + ∃ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + Function.Bijective (fun x => G x 1) ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ x, + ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ L) := by + obtain ⟨rho,hrho,D,hD,hfamily⟩ := manufactured_uniform_density_and_flow hpublished + have hrhop : (0:ℝ) < rho := by exact_mod_cast hrho + obtain ⟨K,hK,hKb⟩ := moserFlow_family_inverse_bound hrhop + manufacturedFieldDerivativeConstant_positive.le + refine ⟨rho,hrho,⟨D,hD.le⟩,K,by exact_mod_cast hD,hK,?_⟩ + intro freq scale S hscale hS m u hsep hcounter + let V := manufacturedWellField freq scale S u + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 freq scale S u).of_le (by norm_num) + obtain ⟨hc,hderiv⟩ := hfamily freq scale S hscale hS m u hsep hcounter + refine ⟨hc,?_⟩ + obtain ⟨G,C,Cinv,D',hD',hflow,hbij,hLip,hAnti,hfix,hreg,hderiv'⟩ := + moser_C4_bilipschitz_flow_exists hpublished hrhop V hV + (manufacturedWellField_compact freq scale (lt_of_lt_of_le zero_lt_one hS) u) hc + have h1 : (1:ℝ) ∈ Set.Icc 0 1 := ⟨by norm_num,le_rfl⟩ + have hDb (k : ℕ) (hk : 1 ≤ k) (hk' : k ≤ 4) (x : Position) : + ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ D := hderiv G hflow k hk hk' 1 h1 x + have hLipD : LipschitzWith (⟨D,hD.le⟩ : ℝ≥0) (fun x => G x 1) := + lipschitzWith_of_nnnorm_fderiv_le (hreg.differentiable (by norm_num)) (fun x => by + have h := hDb 1 (by norm_num) (by norm_num) x + rw [norm_iteratedFDeriv_one] at h + exact_mod_cast h) + have hAntiK := hKb V hV + (fun k hk x => manufacturedWellField_derivative_bound freq hscale hS u hsep hcounter hk x) + hc G hflow + exact ⟨G,hflow,hbij,hLipD,hAntiK,hfix,hreg,hDb⟩ + +/-- The original flow interface, retaining the same fixed constants. -/ +theorem manufactured_transport_family (hpublished : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ L K : ℝ≥0, 0 < L ∧ 0 < K ∧ + ∀ (freq scale S : ℝ), 0 < scale → 1 ≤ S → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) → + (∀ i, localizedCounterterm freq u i ≤ scale) → + ∃ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G ∧ + Function.Bijective (fun x => G x 1) ∧ + LipschitzWith L (fun x => G x 1) ∧ AntilipschitzWith K (fun x => G x 1) ∧ + (∀ x, x ∉ tsupport (manufacturedWellField freq scale S u) → G x 1 = x) ∧ + ContDiff ℝ 4 (fun x => G x 1) ∧ + (∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ x, + ‖iteratedFDeriv ℝ k (fun y => G y 1) x‖ ≤ L) := by + obtain ⟨rho,hrho,L,K,hL,hK,hfamily⟩ := manufactured_transport_family_with_charge hpublished + exact ⟨rho,hrho,L,K,hL,hK,fun freq scale S hs hS m u hsep hc => + (hfamily freq scale S hs hS m u hsep hc).2⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..20a700cf177c6cea0329a930e7c9a5f834af9ba6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformComparison.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedTensorLower + +namespace OAI + +/-! For the actual manufactured field, the published one-particle inputs +give a full-domain interacting lower bound from the compressed energy. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem manufacturedSlab_uniform_interacting_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S₀ δ C : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S₀ ∧ 0 < δ ∧ 1 ≤ C ∧ + ∀ (m n : ℕ) (D S H scale r ε η : ℝ), R ≤ D → + (m+1:ℕ) ≤ Real.exp ((19/320:ℝ)*D) → S₀ ≤ S → 1 ≤ H → C*S^3 ≤ H → + 0 ≤ scale → 0 < r → r ≤ H/2 → r ≤ S → 0 ≤ ε → 0 ≤ η → η ≤ δ → + ∀ u : Fin (m+1) → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ η) → + 4*(m+1:ℕ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ ε^2 → + (n:ℝ)*(ε+ε^2/(γ/4)) ≤ γ/8 → + ∀ w : Coulomb.H1Vector (n+1), Coulomb.Antisymmetric w → + ∀ a t : ℝ, a ≤ γ/16 → 0 ≤ t → + let hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let e : ℝ := 2*(n+1:ℝ)*ε + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+e + (E+a)*Coulomb.mass p ≤ boundedPotentialForm V p+t*Coulomb.pairEnergy p → + (E+a-(2*(e^2+t^2*(8*(n+1:ℝ)^3*K)))/(γ/16))*Coulomb.mass w ≤ + boundedPotentialForm V w+t*Coulomb.pairEnergy w := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,R,S₀,δ,C,hγ,hγsmall,hR,hS₀,hδ,_hC,hgap⟩ := + manufacturedSlab_uniform_tensorComplement_gap hp hv hdensity hfreq hrho hrelation + obtain ⟨R₂,_hR₂,hover⟩ := localizedOverlap_row_threshold + refine ⟨γ,max R R₂,S₀,δ,max C 1,hγ,hγsmall,hR.trans (le_max_left _ _),hS₀,hδ, + le_max_right _ _,fun m n D S H scale r ε η hD hm hS hH hCH hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall w hw a t ha ht => ?_⟩ + have hSp : 0 < S := lt_of_lt_of_le zero_lt_one (hS₀.trans hS) + have hHp : 0 < H := lt_of_lt_of_le zero_lt_one hH + have hCCH : C*S^3 ≤ H := + (mul_le_mul_of_nonneg_right (le_max_left C 1) (by positivity)).trans hCH + have hSH : S^3 ≤ H := by + have h := mul_le_mul_of_nonneg_right (le_max_right C 1) (show 0 ≤ S^3 by positivity) + simpa only [one_mul] using h.trans hCH + have hs := hover D ((le_max_right _ _).trans hD) (m+1) hm + have hD₂ : 2 ≤ D := by linarith only [hR,le_max_left R R₂,hD] + let p : Coulomb.H1Vector (n+1) := finiteTensorProjection (localizedSpinMode freq u) + (localizedSpinMode_C1 freq u) (localizedSpinMode_memLp hf u) + (localizedSpinMode_partial_memLp hf u) w + let q : Coulomb.H1Vector (n+1) := w.add (Coulomb.H1Vector.scale (-1) p) + let V : Configuration (n+1) → ℝ := fun x => ∑ i, + manufacturedSlabPotential rho H S freq scale u (Coulomb.position x i) + let E : ℝ := (n+1:ℝ)*((-1/2:ℝ)+freq/2) + let e : ℝ := 2*(n+1:ℝ)*ε + let K : ℝ := (n+1:ℝ)*(((m+1:ℕ)+η)*PlanarSobolev.wellBound+6*Real.pi*rho+ + ((-1/2:ℝ)+freq/2))+e + change (E+a)*Coulomb.mass p ≤ boundedPotentialForm V p+t*Coulomb.pairEnergy p → _ + intro hfinite + have he : 0 ≤ e := by dsimp only [e]; positivity + have herr' : (n+1:ℝ)^2*(8*(m+1:ℕ)^2*∑ j, + manufacturedOrbitalSquaredError rho H S freq η D r u j) ≤ e^2 := by + have h := mul_le_mul_of_nonneg_left herr (show 0 ≤ 2*(n+1:ℝ)^2 by positivity) + dsimp only [e] + nlinarith only [h,sq_nonneg ((n+1:ℝ)*ε)] + have hq := hgap m n D S H scale r ε η ((le_max_left _ _).trans hD) hm hS hH hCCH + hscale hr hrH hrS hε hη hηδ u hsep hcoeff herr hsmall w hw + have hcomp : (E+a+γ/16)*Coulomb.mass q ≤ boundedPotentialForm V q := by + have hmono : E+a+γ/16 ≤ E+γ/8 := by linarith only [ha] + have h := mul_le_mul_of_nonneg_right hmono (Coulomb.mass_nonneg q) + apply h.trans + simpa only [q,p,finiteTensorRemainder,E,V,Nat.cast_add,Nat.cast_one] using hq + have h := manufacturedTensor_interacting_lower hdensity hrho hHp hSp hSH hfreq hrelation + hr hrH hrS scale hscale u hD₂ hsep hs hη hcoeff he herr' w a (γ/16) t + (by positivity) ht hfinite hcomp + simpa only [E,e,K,V,Nat.cast_add,Nat.cast_one] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformFlow.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformFlow.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1591c5fdb579e28385dfc5a89eb7540c4767ff8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformFlow.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserUniformVelocity + +namespace OAI + +/-! The same integer background density and the same flow derivative +constant work for every separated manufactured well family. -/ + +noncomputable section +namespace ContinuumCoulomb + +/-- The background density is selected before the size, sites, field scale, +or slab width. Thus the published flow input has uniform constants. -/ +theorem manufactured_uniform_density_and_flow (hpublished : PublishedC4FlowInput) : + ∃ rho : ℕ, 0 < rho ∧ ∃ C : ℝ, 0 < C ∧ + ∀ (freq scale S : ℝ), 0 < scale → 1 ≤ S → + ∀ (m : ℕ) (u : Fin m → PlanarPosition), + (∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) → + (∀ i, localizedCounterterm freq u i ≤ scale) → + (∀ x, |manufacturedCharge (manufacturedWellField freq scale S u) x| ≤ (rho:ℝ)/2) ∧ + (∀ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity rho (manufacturedWellField freq scale S u)) G → + ∀ k : ℕ, 1 ≤ k → k ≤ 4 → ∀ t ∈ Set.Icc (0 : ℝ) 1, ∀ x, + ‖iteratedFDeriv ℝ k (fun y => G y t) x‖ ≤ C) := by + let B := manufacturedFieldDerivativeConstant + have hB : 0 < B := manufacturedFieldDerivativeConstant_positive + obtain ⟨rho,hrho⟩ := exists_nat_gt (max (1:ℝ) (6*B/(4*Real.pi))) + have hrhop : 0 < rho := by + have h : (1:ℝ) < rho := (le_max_left _ _).trans_lt hrho + exact_mod_cast (lt_trans zero_lt_one h) + have hrhopR : (0:ℝ) < rho := by exact_mod_cast hrhop + obtain ⟨C,hC,hCb⟩ := moserFlow_family_derivative_bound hpublished hrhopR hB.le + refine ⟨rho,hrhop,C,hC,?_⟩ + intro freq scale S hscale hS m u hsep hcounter + let V := manufacturedWellField freq scale S u + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 freq scale S u).of_le (by norm_num) + have hb (k : ℕ) (hk : k ≤ 6) (x : Position) : ‖iteratedFDeriv ℝ k V x‖ ≤ B := + manufacturedWellField_derivative_bound freq hscale hS u hsep hcounter hk x + have hc (x : Position) : |manufacturedCharge V x| ≤ (rho:ℝ)/2 := by + have h := manufacturedCharge_derivative_bound V hV hB.le hb (k := 0) (by norm_num) x + simp only [norm_iteratedFDeriv_zero, Real.norm_eq_abs] at h + have h' : 6*B/(4*Real.pi) < rho := (le_max_right _ _).trans_lt hrho + have he : 6*B/(4*Real.pi) = 2*(3*B/(4*Real.pi)) := by ring + rw [he] at h' + linarith + exact ⟨hc, hCb V hV hb hc⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..045835a7dd75404a5243ced4462289223ce78a35 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedUniformGap.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedGapScale + +namespace OAI + +/-! A single positive complementary gap for every admissible manufactured +configuration. Localization widths and error tolerances are selected before +the instance and before the number of wells. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +theorem localizedOverlap_row_threshold : + ∃ R : ℝ, 8 ≤ R ∧ ∀ D : ℝ, R ≤ D → ∀ m : ℕ, + (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → m*localizedOverlapBound D ≤ 1/2 := by + have he : Tendsto (fun D : ℝ => Real.exp (-(269/320:ℝ)*D)) atTop (𝓝 0) := by + simpa only [Function.comp_def,id_eq,neg_mul] using + Real.tendsto_exp_neg_atTop_nhds_zero.comp + (tendsto_id.const_mul_atTop (by norm_num : (0:ℝ)<269/320)) + have hl : Tendsto (fun D : ℝ => planarOverlapConstant*Real.exp (-(269/320:ℝ)*D)) + atTop (𝓝 0) := by simpa using he.const_mul planarOverlapConstant + obtain ⟨R,hR⟩ := Filter.eventually_atTop.1 + (hl.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/2))) + refine ⟨max 8 R,le_max_left _ _,fun D hD m hm => ?_⟩ + have hb : (m:ℝ)*localizedOverlapBound D ≤ + planarOverlapConstant*Real.exp (-(269/320:ℝ)*D) := by + unfold localizedOverlapBound + calc + _ ≤ Real.exp ((19/320:ℝ)*D)*(planarOverlapConstant*Real.exp (-(9/10:ℝ)*D)) := + mul_le_mul_of_nonneg_right hm + (mul_nonneg planarOverlapConstant_nonnegative (Real.exp_pos _).le) + _ = _ := by rw [mul_left_comm,← Real.exp_add]; congr 2; ring + exact hb.trans (hR D ((le_max_right _ _).trans hD)).le + +theorem manufacturedSlab_uniform_complement_gap + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) (hdensity : PublishedSobolevSmoothDensity) + {freq rho : ℝ} (hfreq : 1 ≤ freq) (hrho : 0 ≤ rho) (hrelation : freq^2 = 4*Real.pi*rho) : + ∃ γ R S δ H₀ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ 1 ≤ S ∧ 0 < δ ∧ 0 < H₀ ∧ + ∀ (m : ℕ) (D H scale : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320:ℝ)*D) → + H₀ ≤ H → 0 ≤ scale → ∀ u : Fin m → PlanarPosition, + (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + (∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ localizedCounterterm freq u i/scale ≤ δ) → + ∀ v : Coulomb.H1Vector 1, + (∀ s i, inner ℂ (oneElectronOrbitalLp (correctedLocalizedMode freq u i) + (correctedLocalizedMode_memLp (lt_of_lt_of_le zero_lt_one hfreq) u i)) + (h1Coordinates v (Sum.inl s)) = 0) → + (-1/2+freq/2+γ/2)*Coulomb.mass v ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v := by + have hf : 0 < freq := lt_of_lt_of_le zero_lt_one hfreq + obtain ⟨γ,hγ,hsmall,hbound⟩ := manufacturedSlab_corrected_complement_lower hp hv hdensity + let η := γ/(16*freq) + obtain ⟨hη,hfreqη,hdom⟩ := manufactured_gap_parameter_bounds hγ hsmall hfreq + obtain ⟨R₁,hR₁,hplanar⟩ := planar_projection_loss_threshold hγ hη (by positivity : 0 < γ/16) + obtain ⟨R₂,hR₂,hover⟩ := localizedOverlap_row_threshold + obtain ⟨S,hS,hvertical⟩ := vertical_projection_loss_threshold hf η (by positivity : 0 < γ/16) + let δ := γ/(16*(PlanarSobolev.wellBound+1)) + let H₀ := max 1 (96*Real.pi*rho*S^3/γ) + have hw := PlanarSobolev.wellBound_nonnegative + have hδ : 0 < δ := by dsimp [δ]; positivity + have hH₀ : 0 < H₀ := lt_of_lt_of_le zero_lt_one (le_max_left _ _) + refine ⟨γ,max R₁ R₂,S,δ,H₀,hγ,hsmall,hR₁.trans (le_max_left _ _),hS,hδ,hH₀, + fun m D H scale hD hm hH hscale u hsep hcoeff v ho => ?_⟩ + have hD₁ : R₁ ≤ D := (le_max_left _ _).trans hD + have hD₂ : R₂ ≤ D := (le_max_right _ _).trans hD + have hHpos : 0 < H := hH₀.trans_le hH + have hδloss : δ*PlanarSobolev.wellBound ≤ γ/16 := by + have hid : δ*(PlanarSobolev.wellBound+1) = γ/16 := by + dsimp [δ] + field_simp + exact (mul_le_mul_of_nonneg_left (by linarith : + PlanarSobolev.wellBound ≤ PlanarSobolev.wellBound+1) hδ.le).trans_eq hid + have hslab : 6*Real.pi*rho*S^3/H ≤ γ/16 := by + have hh : 96*Real.pi*rho*S^3/γ ≤ H := (le_max_right _ _).trans hH + have hh' := (div_le_iff₀ hγ).mp hh + apply (div_le_iff₀ hHpos).mpr + nlinarith only [hh'] + have hloss : manufacturedSpectralLoss γ m D η freq S rho H δ ≤ γ/2 := by + have hp := hplanar D hD₁ m hm + have hv := (hvertical S le_rfl).2 + unfold manufacturedSpectralLoss + dsimp [η] at hv ⊢ + linarith [hfreqη] + exact hbound m D η freq S rho H scale δ (hR₁.trans hD₁) hη hf + (lt_of_lt_of_le zero_lt_one hS) hrho hHpos hscale hδ.le hrelation + (hvertical S le_rfl).1 u hsep hcoeff + (hdom _ (hover D hD₂ m hm)) (hover D hD₂ m hm) hloss v ho + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedVelocityEvaluation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedVelocityEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3be64fc78b225a26e284b0fe5d4c101ea6802289 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedVelocityEvaluation.lean @@ -0,0 +1,152 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserDifferenceBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserVelocityNumerics + +namespace OAI + +/-! The actual manufactured Moser velocity is sampled using rational +coordinate differences, the certified scalar field evaluator and π. +No value or derivative evaluator is assumed. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.ManufacturedVelocityEvaluation +open CappedKernelProgram (Triple position) +open NeutralAtom (dirPartial axis) + +def precision (rho P : ℕ) : ℕ := + 12*(1+MoserDifferenceBudget.guard*(4*rho+1))*(P+1) + +def sample (rho p : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) (q : Triple) : ℚ := + ManufacturedFieldEvaluation.value rho (MoserDifferenceBudget.precision p) scale S sites q + +def gradient (rho p : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) (q : Triple) (a : Fin 3) : ℚ := + RationalFieldDifferences.first (sample rho p scale S sites) (MoserDifferenceBudget.step p) q a + +def laplacian (rho p : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) (q : Triple) : ℚ := + RationalFieldDifferences.laplacian (sample rho p scale S sites) (MoserDifferenceBudget.step p) q + +def pi (p : ℕ) : ℚ := PiProgram.approximate (8*(p+1)) + +def component (rho P : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) + (t : ℚ) (q : Triple) (a : Fin 3) : ℚ := + let p := precision rho P; + -(gradient rho p scale S sites q a) / + max (rho:ℚ) (4*pi p*(rho:ℚ)+t*laplacian rho p scale S sites q) + +def value (rho P : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) (t : ℚ) (q : Triple) : Triple := + (component rho P scale S sites t q 0, + (component rho P scale S sites t q 1,component rho P scale S sites t q 2)) + +theorem pi_error (p : ℕ) : |(pi p:ℝ)-Real.pi| ≤ ((p:ℝ)+1)⁻¹ := by + have h := PiProgram.error (8*(p+1)) (by omega) + have he : 8/((8*(p+1):ℕ):ℝ) = ((p:ℝ)+1)⁻¹ := by + push_cast + field_simp + exact h.trans_eq he + +theorem precision_budget (rho P : ℕ) : + 3*(1+(MoserDifferenceBudget.guard:ℝ)*(4*(rho:ℝ)+1))* + ((precision rho P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ := by + let A : ℝ := 1+(MoserDifferenceBudget.guard:ℝ)*(4*(rho:ℝ)+1) + have hA : 0 < A := by dsimp [A]; positivity + have hP : 0 < (P:ℝ)+1 := by positivity + have hp : (precision rho P:ℝ) = 12*A*((P:ℝ)+1) := by + simp only [precision,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_add,Nat.cast_one,A] + change 3*A*((precision rho P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ + apply (mul_inv_le_iff₀ (by positivity : (0:ℝ) < (precision rho P:ℝ)+1)).mpr + rw [hp] + have he : ((P:ℝ)+1)⁻¹*(12*A*((P:ℝ)+1)+1) = 12*A+((P:ℝ)+1)⁻¹ := by field_simp + rw [he] + linarith [inv_nonneg.mpr hP.le] + +theorem gradient_laplacian_error (rho p : ℕ) (hrho : 0 < rho) + {scale S : ℚ} (hscale : (1:ℝ) ≤ scale) (hS : (1:ℝ) ≤ S) + {m : ℕ} (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖PlanarForcingProgram.position (u i)-PlanarForcingProgram.position (u j)‖) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) (q : Triple) : + (∀ a, |(gradient rho p scale S (List.ofFn u) q a:ℝ)- + dirPartial (manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i))) (axis a) (position q)| ≤ ((p:ℝ)+1)⁻¹) ∧ + |(laplacian rho p scale S (List.ofFn u) q:ℝ)- + NeutralAtom.coordinateLaplacian (manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i))) (position q)| ≤ ((p:ℝ)+1)⁻¹ := by + let V := manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) + have hV : ContDiff ℝ 6 V := (manufacturedWellField_C7 _ _ _ _).of_le (by norm_num) + have hb (k : ℕ) (hk : k ≤ 6) (x : Position) : + ‖iteratedFDeriv ℝ k V x‖ ≤ (MoserDifferenceBudget.guard:ℝ) := + (manufacturedWellField_derivative_bound (GaussianFrequency.frequency rho) + (show (0:ℝ) < scale by linarith) hS _ hsep hc hk x).trans MoserDifferenceBudget.guard_bound + have hs (r : Triple) : |(sample rho p scale S (List.ofFn u) r:ℝ)-V (position r)| ≤ + ((MoserDifferenceBudget.precision p:ℝ)+1)⁻¹ := + ManufacturedFieldEvaluation.approximation_error rho (MoserDifferenceBudget.precision p) + hrho hscale S u hu hc r + have hB : (0:ℝ) ≤ MoserDifferenceBudget.guard := Nat.cast_nonneg _ + have hε : 0 ≤ ((MoserDifferenceBudget.precision p:ℝ)+1)⁻¹ := + inv_nonneg.mpr (add_nonneg (Nat.cast_nonneg _) zero_le_one) + constructor + · intro a + have he := RationalFieldDifferences.first_error V hV _ hB hε + (MoserDifferenceBudget.step_positive p) hb hs q a + apply he.trans + apply (MoserDifferenceBudget.first_budget p).trans + apply inv_anti₀ (by positivity) + linarith [Nat.cast_nonneg (α := ℝ) p] + · exact (RationalFieldDifferences.laplacian_error V hV _ hB hε + (MoserDifferenceBudget.step_positive p) hb hs q).trans (MoserDifferenceBudget.laplacian_budget p) + +theorem approximation_error (rho P : ℕ) (hrho : 0 < rho) + {scale S : ℚ} (hscale : (1:ℝ) ≤ scale) (hS : (1:ℝ) ≤ S) + {m : ℕ} (u : Fin m → ℚ×ℚ) (hu : Function.Injective u) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖PlanarForcingProgram.position (u i)-PlanarForcingProgram.position (u j)‖) + (hc : ∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) + (hcharge : ∀ x, |manufacturedCharge (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) x| ≤ (rho:ℝ)/2) + {t : ℚ} (ht : (t:ℝ) ∈ Set.Icc (0:ℝ) 1) (q : Triple) : + ‖position (value rho P scale S (List.ofFn u) t q)- + moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) t (position q)‖ ≤ ((P:ℝ)+1)⁻¹ := by + let V := manufacturedWellField (GaussianFrequency.frequency rho) scale S + (fun i => PlanarForcingProgram.position (u i)) + let p := precision rho P + let E : ℝ := (1+(MoserDifferenceBudget.guard:ℝ)*(4*(rho:ℝ)+1))*((p:ℝ)+1)⁻¹ + have hE : 0 ≤ E := by dsimp [E]; positivity + have hg := gradient_laplacian_error rho p hrho hscale hS u hu hsep hc q + have hbound (a : Fin 3) : |dirPartial V (axis a) (position q)| ≤ (MoserDifferenceBudget.guard:ℝ) := by + have he := dirPartial_iterated_norm_bound V + ((manufacturedWellField_C7 _ _ _ _).of_le (by norm_num)) (axis a) (k := 0) (by omega) (position q) + rw [norm_iteratedFDeriv_zero,Real.norm_eq_abs,show ‖axis a‖=1 by simp [axis],one_mul] at he + exact he.trans ((manufacturedWellField_derivative_bound (GaussianFrequency.frequency rho) + (show (0:ℝ) < scale by linarith) hS _ hsep hc (k := 1) (by omega) _).trans + MoserDifferenceBudget.guard_bound) + have he (a : Fin 3) : |(component rho P scale S (List.ofFn u) t q a:ℝ)- + moserVelocity (rho:ℝ) V t (position q) a| ≤ E := by + have hh := MoserVelocityNumerics.component_error (rho:ℝ) (by exact_mod_cast (Nat.succ_le_of_lt hrho)) + V hcharge ht (position q) a + (gradient rho p scale S (List.ofFn u) q a) (laplacian rho p scale S (List.ofFn u) q) + (pi p) (hbound a) (hg.1 a) hg.2 (pi_error p) + simpa only [component,Rat.cast_div,Rat.cast_neg,Rat.cast_max,Rat.cast_natCast,Rat.cast_add, + Rat.cast_mul,Rat.cast_ofNat,p,E] using hh + let e : Position := position (value rho P scale S (List.ofFn u) t q)-moserVelocity (rho:ℝ) V t (position q) + have hecoord (a : Fin 3) : |e a| ≤ E := by + fin_cases a + · simpa [e,value,position] using he 0 + · simpa [e,value,position] using he 1 + · simpa [e,value,position] using he 2 + have hsq : ‖e‖^2 ≤ 3*E^2 := by + rw [EuclideanSpace.real_norm_sq_eq] + have h := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset (Fin 3))) => + (sq_le_sq₀ (abs_nonneg _) hE).mpr (hecoord a)) + simpa only [sq_abs,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_ofNat] using h + have hn : ‖e‖ ≤ 3*E := by nlinarith [norm_nonneg e,sq_nonneg E] + apply hn.trans + simpa only [E,p,mul_assoc] using precision_budget rho P + +end ContinuumCoulomb.ManufacturedVelocityEvaluation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWeakResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWeakResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..238326d2fbbabc453843cbbff9f12f6908b0b664 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWeakResidual.lean @@ -0,0 +1,152 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoordinateLaplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedOrbitalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabRegularity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModeDerivatives + +namespace OAI + +/-! The differential residual is an actual weak-H1 kinetic/potential +pairing identity. This is the bridge used for the off-diagonal form bound. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def oneElectronLocalizedMode (freq : ℝ) (u : PlanarPosition) (x : Configuration 1) : ℝ := + continuumLocalizedMode freq u (oneElectronCoordinates x) + +theorem oneElectronLocalizedMode_C2 (freq : ℝ) (u : PlanarPosition) : + ContDiff ℝ 2 (oneElectronLocalizedMode freq u) := + ((continuumLocalizedMode_C7 freq u).of_le (by norm_num)).comp oneElectronCoordinates.contDiff + +theorem oneElectronLocalizedMode_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + MemLp (oneElectronLocalizedMode freq u) 2 := + (continuumLocalizedMode_memLp hfreq u).comp_measurePreserving oneElectronCoordinates.measurePreserving + +theorem oneElectronLocalizedMode_partial (freq : ℝ) (u : PlanarPosition) + (a : Fin 1 × Fin 3) (x : Configuration 1) : + configurationRealPartial (oneElectronLocalizedMode freq u) a x = + fderiv ℝ (continuumLocalizedMode freq u) (oneElectronCoordinates x) + (oneElectronCoordinates (EuclideanSpace.single a 1)) := by + exact congrArg (fun L : Configuration 1 →L[ℝ] ℝ => L (EuclideanSpace.single a 1)) + (((continuumLocalizedMode_C7 freq u).differentiable (by norm_num) _).hasFDerivAt.comp x + oneElectronCoordinates.toContinuousLinearEquiv.hasFDerivAt).fderiv + +theorem oneElectronLocalizedMode_partial_memLp {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (a : Fin 1 × Fin 3) : + MemLp (configurationRealPartial (oneElectronLocalizedMode freq u) a) 2 := by + have he : configurationRealPartial (oneElectronLocalizedMode freq u) a = + (fun x => fderiv ℝ (continuumLocalizedMode freq u) (oneElectronCoordinates x) + (oneElectronCoordinates (EuclideanSpace.single a 1))) := + funext (oneElectronLocalizedMode_partial freq u a) + rw [he] + exact (continuumLocalizedMode_fderiv_memLp hfreq u _).comp_measurePreserving + oneElectronCoordinates.measurePreserving + +theorem oneElectronLocalizedMode_laplacian (freq : ℝ) (u : PlanarPosition) (x : Configuration 1) : + configurationRealLaplacian (oneElectronLocalizedMode freq u) x = + splitLaplacian (localizedMode freq u) (positionSplitCoordinates (oneElectronCoordinates x)) := + oneElectron_split_laplacian _ ((localizedMode_C7 freq u).of_le (by norm_num)) x + +private theorem manufactured_mode_product_memLp {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 < S) (hfreq : 0 < freq) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (j : Fin m) : + MemLp (fun x : Configuration 1 => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)*oneElectronLocalizedMode freq (u j) x) 2 := by + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH hS freq scale u + apply (oneElectronLocalizedMode_memLp hfreq (u j)).of_le_mul (c := B) + ((((manufacturedSlabPotential_continuous hrho hH hS.le freq scale u).comp + oneElectronCoordinates.continuous).mul (oneElectronLocalizedMode_C2 freq (u j)).continuous).aestronglyMeasurable) + filter_upwards [] with x + change ‖manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + oneElectronLocalizedMode freq (u j) x‖ ≤ _ + rw [norm_mul,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hB _) (norm_nonneg _) + +theorem oneElectronLocalizedMode_laplacian_memLp {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + MemLp (configurationRealLaplacian (oneElectronLocalizedMode freq (u j))) 2 := by + have hR := (manufacturedOrbitalResidual_memLp hrho hH hS.le hfreq scale u hδ hcoeff j).comp_measurePreserving oneElectronCoordinates.measurePreserving + have hV := manufactured_mode_product_memLp hrho hH hS hfreq scale u j + have hE := (oneElectronLocalizedMode_memLp hfreq (u j)).const_mul ((-1/2:ℝ)+freq/2) + have he : configurationRealLaplacian (oneElectronLocalizedMode freq (u j)) = + (fun x => 2*(manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x)* + oneElectronLocalizedMode freq (u j) x- + ((-1/2:ℝ)+freq/2)*oneElectronLocalizedMode freq (u j) x- + manufacturedOrbitalResidual rho H S freq scale u j (oneElectronCoordinates x))) := by + funext x + rw [oneElectronLocalizedMode_laplacian] + have h := manufacturedOrbitalResidual_eq hrelation H S scale u j (oneElectronCoordinates x) + change _ = 2*(_*continuumLocalizedMode freq (u j) _- + ((-1/2:ℝ)+freq/2)*continuumLocalizedMode freq (u j) _-_) + linarith + rw [he] + exact ((hV.sub hE).sub hR).const_mul 2 + + +theorem manufacturedOrbitalResidual_weak_identity + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq : ℝ} + (hrho : 0 ≤ rho) (hH : 0 ≤ H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + (1/2:ℂ)*(∑ a, ∫ x, v.gradient s a x* + (configurationRealPartial (oneElectronLocalizedMode freq (u j)) a x : ℂ))+ + (∫ x, v.value s x*(manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)*oneElectronLocalizedMode freq (u j) x : ℝ))- + (((-1/2:ℝ)+freq/2):ℂ)*(∫ x, v.value s x*(oneElectronLocalizedMode freq (u j) x : ℂ)) = + ∫ x, v.value s x*(manufacturedOrbitalResidual rho H S freq scale u j + (oneElectronCoordinates x) : ℂ) := by + let φ := oneElectronLocalizedMode freq (u j) + have hLap := oneElectronLocalizedMode_laplacian_memLp hrho hH hS hfreq hrelation scale u hδ hcoeff j + have hi := weakH1_laplacian_pairing hdensity φ (oneElectronLocalizedMode_C2 freq (u j)) + (oneElectronLocalizedMode_partial_memLp hfreq (u j)) hLap v s + have hLI := (v.value_L2 s).integrable_mul hLap.ofReal + have hVI := (v.value_L2 s).integrable_mul + (manufactured_mode_product_memLp hrho hH hS hfreq scale u j).ofReal + have hPI := (v.value_L2 s).integrable_mul (oneElectronLocalizedMode_memLp hfreq (u j)).ofReal + have he (x : Configuration 1) : + v.value s x*(manufacturedOrbitalResidual rho H S freq scale u j + (oneElectronCoordinates x) : ℂ) = + (-1/2:ℂ)*(v.value s x*(configurationRealLaplacian φ x : ℂ))+ + v.value s x*(manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)*φ x : ℝ)- + (((-1/2:ℝ)+freq/2):ℂ)*(v.value s x*(φ x : ℂ)) := by + have h := manufacturedOrbitalResidual_eq hrelation H S scale u j (oneElectronCoordinates x) + rw [← oneElectronLocalizedMode_laplacian] at h + dsimp only [φ] + rw [h] + push_cast + simp only [oneElectronLocalizedMode] + ring + simp_rw [he] + have hsub := integral_sub ((hLI.const_mul (-1/2:ℂ)).add hVI) + (hPI.const_mul (((-1/2:ℝ)+freq/2):ℂ)) + have hadd := integral_add (hLI.const_mul (-1/2:ℂ)) hVI + simp only [Pi.add_apply,Pi.mul_apply] at hsub hadd + dsimp only [φ] at hi ⊢ + rw [hadd,integral_const_mul,integral_const_mul] at hsub + rw [hi] + let A : ℂ := ∫ x, v.value s x*(configurationRealLaplacian (oneElectronLocalizedMode freq (u j)) x : ℂ) + let B : ℂ := ∫ x, v.value s x*(manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)*oneElectronLocalizedMode freq (u j) x : ℝ) + let C : ℂ := ∫ x, v.value s x*(oneElectronLocalizedMode freq (u j) x : ℂ) + let E : ℂ := (((-1/2:ℝ)+freq/2):ℂ) + change _ = (-1/2:ℂ)*A+B-E*C at hsub + change (1/2:ℂ)*(-A)+B-E*C = _ + calc + _ = (-1/2:ℂ)*A+B-E*C := by ring + _ = _ := hsub.symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWellField.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWellField.lean new file mode 100644 index 0000000000000000000000000000000000000000..984d78e64e6394856cf213f622f6df42c22e9b26 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ManufacturedWellField.lean @@ -0,0 +1,227 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedForm +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellLocalization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedCounterterms +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.DensitySynthesis + +namespace OAI + +/-! The actual compact three-dimensional well field in the unit-charge +construction. Its coefficients are Coulomb counterterms. The cutoff only weakens the attractive uncorrected wells. -/ + +noncomputable section +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +def slabWellCutoff (S z : ℝ) : ℝ := verticalCutoffBump ((2/S)*z) + +theorem slabWellCutoff_bounds (S z : ℝ) : + 0 ≤ slabWellCutoff S z ∧ slabWellCutoff S z ≤ 1 := + ⟨verticalCutoffBump.nonneg, verticalCutoffBump.le_one⟩ + +theorem slabWellCutoff_smooth (S : ℝ) : ContDiff ℝ ∞ (slabWellCutoff S) := + verticalCutoffBump.contDiff.comp (contDiff_const.mul contDiff_id) + +theorem slabWellCutoff_inner {S : ℝ} (hS : 0 < S) {z : ℝ} (hz : |z| ≤ S/2) : + slabWellCutoff S z = 1 := by + apply verticalCutoffBump.one_of_mem_closedBall + change dist ((2/S)*z) 0 ≤ 1 + rw [dist_zero_right, Real.norm_eq_abs, abs_mul, abs_of_pos (div_pos (by norm_num) hS)] + have hm := mul_le_mul_of_nonneg_left hz (div_pos (by norm_num : (0:ℝ)<2) hS).le + have he : (2/S)*(S/2) = (1:ℝ) := by field_simp + exact hm.trans_eq he + +theorem slabWellCutoff_outer {S : ℝ} (hS : 0 < S) {z : ℝ} (hz : S ≤ |z|) : + slabWellCutoff S z = 0 := by + apply verticalCutoffBump.zero_of_le_dist + change 2 ≤ dist ((2/S)*z) 0 + rw [dist_zero_right, Real.norm_eq_abs, abs_mul, abs_of_pos (div_pos (by norm_num) hS)] + have hm := mul_le_mul_of_nonneg_left hz (div_pos (by norm_num : (0:ℝ)<2) hS).le + have he : (2/S)*S = (2:ℝ) := by field_simp + exact he.symm.le.trans hm + +def countertermWellSum (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (r : PlanarPosition) : ℝ := + ∑ i, (1 + localizedCounterterm freq u i / scale) * manufacturedPlanarWell (r-u i) + +def manufacturedWellField (freq scale S : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (x : Position) : ℝ := + slabWellCutoff S (positionSplitCoordinates x).2 * + countertermWellSum freq scale u (positionSplitCoordinates x).1 + +theorem countertermWellSum_C7 (freq scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) : + ContDiff ℝ 7 (countertermWellSum freq scale u) := by + apply ContDiff.sum + intro i _ + exact contDiff_const.mul (manufacturedPlanarWell_C7.comp (contDiff_id.sub contDiff_const)) + +theorem manufacturedWellField_C7 (freq scale S : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) : ContDiff ℝ 7 (manufacturedWellField freq scale S u) := + ((slabWellCutoff_smooth S).of_le (by simp) |>.comp + positionSplitCoordinates.contDiff.snd).mul + ((countertermWellSum_C7 freq scale u).comp positionSplitCoordinates.contDiff.fst) + +theorem countertermWellSum_nonpositive (freq : ℝ) {scale : ℝ} (hscale : 0 ≤ scale) + {m : ℕ} (u : Fin m → PlanarPosition) (r : PlanarPosition) : + countertermWellSum freq scale u r ≤ 0 := by + apply Finset.sum_nonpos + intro i _ + exact mul_nonpos_of_nonneg_of_nonpos + (add_nonneg zero_le_one (div_nonneg (localizedCounterterm_nonnegative freq u i) hscale)) + (manufacturedPlanarWell_nonpositive _) + +theorem manufacturedWellField_nonpositive (freq : ℝ) {scale : ℝ} (hscale : 0 ≤ scale) + (S : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) (x : Position) : + manufacturedWellField freq scale S u x ≤ 0 := + mul_nonpos_of_nonneg_of_nonpos (slabWellCutoff_bounds _ _).1 + (countertermWellSum_nonpositive freq hscale u _) + +theorem manufacturedWellField_inner (freq scale : ℝ) {S : ℝ} (hS : 0 < S) + {m : ℕ} (u : Fin m → PlanarPosition) (x : Position) + (hx : |(positionSplitCoordinates x).2| ≤ S/2) : + manufacturedWellField freq scale S u x = + countertermWellSum freq scale u (positionSplitCoordinates x).1 := by + simp only [manufacturedWellField, slabWellCutoff_inner hS hx, one_mul] + +theorem manufacturedWellField_outer (freq scale : ℝ) {S : ℝ} (hS : 0 < S) + {m : ℕ} (u : Fin m → PlanarPosition) (x : Position) + (hx : S ≤ |(positionSplitCoordinates x).2|) : + manufacturedWellField freq scale S u x = 0 := by + simp only [manufacturedWellField, slabWellCutoff_outer hS hx, zero_mul] + +theorem countertermWellSum_zero_far (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (r : PlanarPosition) + (hr : ∀ i, 1 ≤ ‖r-u i‖) : countertermWellSum freq scale u r = 0 := by + apply Finset.sum_eq_zero + intro i _ + rw [manufacturedPlanarWell_zero_of_norm_ge_one (hr i), mul_zero] + +theorem manufacturedWellField_support (freq scale : ℝ) {S R : ℝ} + (hS : 0 < S) (hR : 0 ≤ R) {m : ℕ} (u : Fin m → PlanarPosition) + (hu : ∀ i, ‖u i‖ ≤ R) : + tsupport (manufacturedWellField freq scale S u) ⊆ + Metric.closedBall (0 : Position) (R+S+1) := by + apply closure_minimal _ Metric.isClosed_closedBall + intro x hx + have hz : |(positionSplitCoordinates x).2| < S := by + by_contra hn + exact hx (manufacturedWellField_outer freq scale hS u x (le_of_not_gt hn)) + have hr : ‖(positionSplitCoordinates x).1‖ < R+1 := by + by_contra hn + apply hx + unfold manufacturedWellField + rw [countertermWellSum_zero_far freq scale u _ (fun i => ?_), mul_zero] + have ht : ‖(positionSplitCoordinates x).1‖ ≤ + ‖(positionSplitCoordinates x).1-u i‖ + ‖u i‖ := by + simpa only [sub_add_cancel] using norm_add_le ((positionSplitCoordinates x).1-u i) (u i) + linarith [hu i, le_of_not_gt hn] + rw [Metric.mem_closedBall, dist_zero_right] + have hs := positionSplitCoordinates_norm_sq x + have hr2 := (sq_le_sq₀ (norm_nonneg _) (by linarith : 0 ≤ R+1)).mpr hr.le + have hz2 := (sq_le_sq₀ (abs_nonneg _) hS.le).mpr hz.le + rw [sq_abs] at hz2 + nlinarith [norm_nonneg x] + +theorem manufacturedWellField_compact (freq scale : ℝ) {S : ℝ} (hS : 0 < S) + {m : ℕ} (u : Fin m → PlanarPosition) : + HasCompactSupport (manufacturedWellField freq scale S u) := by + let R : ℝ := ∑ i, ‖u i‖ + have hR : 0 ≤ R := Finset.sum_nonneg (fun i _ => norm_nonneg _) + have hu (i : Fin m) : ‖u i‖ ≤ R := + Finset.single_le_sum (fun j _ => norm_nonneg _) (Finset.mem_univ i) + exact (isCompact_closedBall (0 : Position) (R+S+1)).of_isClosed_subset + (isClosed_tsupport _) (manufacturedWellField_support freq scale hS hR u hu) + +theorem positionSplitCoordinates_fst_zero (x : Position) : + (positionSplitCoordinates x).1 0 = x 0 := rfl + +theorem positionSplitCoordinates_fst_one (x : Position) : + (positionSplitCoordinates x).1 1 = x 1 := rfl + +theorem positionSplitCoordinates_snd (x : Position) : + (positionSplitCoordinates x).2 = x 2 := rfl + +theorem manufacturedWellField_support_slab (freq scale : ℝ) {S R H : ℝ} + (hS : 0 < S) (hH : R+1 ≤ H) {m : ℕ} (u : Fin m → PlanarPosition) + (hu : ∀ i, ‖u i‖ ≤ R) : + tsupport (manufacturedWellField freq scale S u) ⊆ slabDomain H S := by + apply closure_minimal _ (slabDomain_isClosed H S) + intro x hx + have hz : |(positionSplitCoordinates x).2| ≤ S := by + by_contra hn + exact hx (manufacturedWellField_outer freq scale hS u x (le_of_not_ge hn)) + have hnear : ∃ i, ‖(positionSplitCoordinates x).1-u i‖ < 1 := by + by_contra hn + apply hx + unfold manufacturedWellField + rw [countertermWellSum_zero_far freq scale u _ (fun i => + le_of_not_gt (fun hi => hn ⟨i, hi⟩)), mul_zero] + obtain ⟨i, hi⟩ := hnear + have hr : ‖(positionSplitCoordinates x).1‖ ≤ H := by + have ht : ‖(positionSplitCoordinates x).1‖ ≤ + ‖(positionSplitCoordinates x).1-u i‖ + ‖u i‖ := by + simpa only [sub_add_cancel] using norm_add_le ((positionSplitCoordinates x).1-u i) (u i) + linarith [hu i] + have h0 := (PiLp.norm_apply_le (positionSplitCoordinates x).1 0).trans hr + have h1 := (PiLp.norm_apply_le (positionSplitCoordinates x).1 1).trans hr + exact ⟨by simpa only [Real.norm_eq_abs, positionSplitCoordinates_fst_zero] using h0, + by simpa only [Real.norm_eq_abs, positionSplitCoordinates_fst_one] using h1, + by simpa only [positionSplitCoordinates_snd] using hz⟩ + +private theorem well_zero_away_from_near_site {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) (r : PlanarPosition) + (i : Fin m) (hi : ‖r-u i‖ < 1) (j : Fin m) (hji : j ≠ i) : + manufacturedPlanarWell (r-u j) = 0 := by + apply manufacturedPlanarWell_zero_of_norm_ge_one + have ht : ‖u i-u j‖ ≤ ‖r-u i‖ + ‖r-u j‖ := by + simpa only [dist_eq_norm, norm_sub_rev (u i) r] using dist_triangle (u i) r (u j) + linarith [hsep i j hji.symm] + +/-- Disjoint planar supports prevent the counterterm perturbation from +growing with the number of sites. -/ +theorem countertermWellSum_lower (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) + {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i / scale ∧ + localizedCounterterm freq u i / scale ≤ δ) (r : PlanarPosition) : + planarWellSum u r - δ*PlanarSobolev.wellBound ≤ countertermWellSum freq scale u r := by + classical + by_cases hnear : ∃ i, ‖r-u i‖ < 1 + · obtain ⟨i, hi⟩ := hnear + have hz := well_zero_away_from_near_site u hsep r i hi + have hsum : planarWellSum u r = manufacturedPlanarWell (r-u i) := by + unfold planarWellSum + exact Finset.sum_eq_single i (fun j _ hji => hz j hji) (by simp) + have hsum' : countertermWellSum freq scale u r = + (1+localizedCounterterm freq u i/scale)*manufacturedPlanarWell (r-u i) := by + unfold countertermWellSum + exact Finset.sum_eq_single i (fun j _ hji => by rw [hz j hji, mul_zero]) (by simp) + rw [hsum, hsum'] + have hw : -PlanarSobolev.wellBound ≤ manufacturedPlanarWell (r-u i) := by + exact (abs_le.mp (by simpa only [Real.norm_eq_abs] using + PlanarSobolev.wellBound_spec (r-u i))).1 + have h1 := mul_le_mul_of_nonneg_left hw (hcoeff i).1 + have h2 := mul_le_mul_of_nonneg_right (hcoeff i).2 PlanarSobolev.wellBound_nonnegative + nlinarith only [h1, h2] + · have hz (i : Fin m) : manufacturedPlanarWell (r-u i) = 0 := + manufacturedPlanarWell_zero_of_norm_ge_one (le_of_not_gt (fun hi => hnear ⟨i, hi⟩)) + simp only [planarWellSum, countertermWellSum, hz, mul_zero, Finset.sum_const_zero] + linarith [mul_nonneg hδ PlanarSobolev.wellBound_nonnegative] + +/-- Global lower comparison to the separable uncapped multiwell field. -/ +theorem manufacturedWellField_lower (freq : ℝ) {scale : ℝ} (hscale : 0 ≤ scale) + (S : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 2 ≤ ‖u i-u j‖) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i / scale ∧ + localizedCounterterm freq u i / scale ≤ δ) (x : Position) : + planarWellSum u (positionSplitCoordinates x).1 - δ*PlanarSobolev.wellBound ≤ + manufacturedWellField freq scale S u x := by + apply (countertermWellSum_lower freq scale u hsep hδ hcoeff _).trans + exact le_mul_of_le_one_left (countertermWellSum_nonpositive freq hscale u _) + (slabWellCutoff_bounds S _).2 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MixedSlater.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MixedSlater.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f35a3f9524a1790d69608cd5ea51dad152beeba --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MixedSlater.lean @@ -0,0 +1,267 @@ +import OAI.Analysis.CoulombRadii.FieldAnalysis.SlotTensor +import OAI.Analysis.CoulombRadii.FieldAnalysis.TwoBodyTensorIntegrable + +namespace OAI + +/-! Mixed determinant matrix elements for different occupied orbital +families. Every coefficient is an actual integral; the remaining finite +permutation sums are precisely the minors needed in Fock compression. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb.MixedSlater +open Coulomb + +variable {A : Type*} [MeasurableSpace A] {μ : Measure A} [SigmaFinite μ] {n : ℕ} + +lemma determinant_overlap_integral (v u : Fin n → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hu : ∀ i, MemLp (u i) 2 μ) : + (∫ x : Fin n → A, star (determinantWave v x) * determinantWave u x + ∂(Measure.pi fun _ => μ)) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ∏ i, ∫ a, star (v (p i) a) * u (q i) a ∂μ := by + have hi (p q : Equiv.Perm (Fin n)) : Integrable + (fun x : Fin n → A => star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + (star (∏ i, v (p i) (x i)) * ∏ i, u (q i) (x i))) (Measure.pi fun _ => μ) := + ((scalarTensor_memLp v hv p).star.integrable_mul (scalarTensor_memLp u hu q)).const_mul _ + simp_rw [determinant_bilinear_expansion] + rw [integral_finsetSum _ (fun p _ => integrable_finsetSum _ (fun q _ => hi p q))] + apply Finset.sum_congr rfl + intro p _ + rw [integral_finsetSum _ (fun q _ => hi p q)] + apply Finset.sum_congr rfl + intro q _ + rw [integral_const_mul] + congr 1 + simp only [star_prod, ← Finset.prod_mul_distrib] + exact integral_fintype_prod_eq_prod + (f := fun i a => star (v (p i) a) * u (q i) a) (μ := fun _ => μ) + +lemma oneBodyTensor_integrable (v u : Fin n → A → ℂ) (w : A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hu : ∀ i, MemLp (u i) 2 μ) + (hw : ∀ i j, Integrable (fun a => w a * (star (v i a) * u j a)) μ) + (p q : Equiv.Perm (Fin n)) (i : Fin n) : + Integrable (fun x : Fin n → A => w (x i) * + (star (∏ j, v (p j) (x j)) * ∏ j, u (q j) (x j))) (Measure.pi fun _ => μ) := by + simp only [star_prod, ← Finset.prod_mul_distrib] + exact weighted_tensor_integrable (fun j a => star (v (p j) a) * u (q j) a) w i + (fun j => (hv (p j)).star.integrable_mul (hu (q j))) (hw _ _) + +lemma oneBodyTensor_integral (v u : Fin n → A → ℂ) (w : A → ℂ) + (p q : Equiv.Perm (Fin n)) (i : Fin n) : + (∫ x : Fin n → A, w (x i) * + (star (∏ j, v (p j) (x j)) * ∏ j, u (q j) (x j)) ∂(Measure.pi fun _ => μ)) = + (∫ a, w a * (star (v (p i) a) * u (q i) a) ∂μ) * + ∏ j ∈ Finset.univ.erase i, ∫ a, star (v (p j) a) * u (q j) a ∂μ := by + simp only [star_prod, ← Finset.prod_mul_distrib] + exact weighted_tensor_integral (fun j a => star (v (p j) a) * u (q j) a) w i + +lemma twoBodyTensor_integrable (v u : Fin n → A → ℂ) (w : A → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hu : ∀ i, MemLp (u i) 2 μ) + (hw : ∀ a b c d, Integrable (fun xy : A × A => w xy.1 xy.2 * + ((star (v a xy.1) * u c xy.1) * (star (v b xy.2) * u d xy.2))) (μ.prod μ)) + (p q : Equiv.Perm (Fin n)) (i j : Fin n) (hij : i ≠ j) : + Integrable (fun x : Fin n → A => w (x i) (x j) * + (star (∏ k, v (p k) (x k)) * ∏ k, u (q k) (x k))) (Measure.pi fun _ => μ) := by + simp only [star_prod, ← Finset.prod_mul_distrib] + exact pair_weight_tensor_integrable i j hij (fun k a => star (v (p k) a) * u (q k) a) w + (fun k => (hv (p k)).star.integrable_mul (hu (q k))) (hw _ _ _ _) + +lemma twoBodyTensor_integral (v u : Fin n → A → ℂ) (w : A → A → ℂ) + (p q : Equiv.Perm (Fin n)) (i j : Fin n) (hij : i ≠ j) : + (∫ x : Fin n → A, w (x i) (x j) * + (star (∏ k, v (p k) (x k)) * ∏ k, u (q k) (x k)) ∂(Measure.pi fun _ => μ)) = + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v (p i) xy.1) * u (q i) xy.1) * (star (v (p j) xy.2) * u (q j) xy.2)) + ∂(μ.prod μ)) * ∏ k ∈ (Finset.univ.erase i).erase j, + ∫ a, star (v (p k) a) * u (q k) a ∂μ := by + simp only [star_prod, ← Finset.prod_mul_distrib] + exact pair_weight_tensor_integral i j hij (fun k a => star (v (p k) a) * u (q k) a) w + +lemma slotTensor_integral (v d u e : Fin n → A → ℂ) + (p q : Equiv.Perm (Fin n)) (i : Fin n) : + (∫ x, star (slotTensor v d p i x) * slotTensor u e q i x + ∂(Measure.pi fun _ : Fin n => μ)) = + (∫ a, star (d (p i) a) * e (q i) a ∂μ) * + ∏ j ∈ Finset.univ.erase i, ∫ a, star (v (p j) a) * u (q j) a ∂μ := by + simp only [slotTensor, star_prod, ← Finset.prod_mul_distrib] + rw [integral_fintype_prod_eq_prod (f := fun j a => + star (if j = i then d (p j) a else v (p j) a) * + (if j = i then e (q j) a else u (q j) a)) (μ := fun _ => μ)] + rw [← Finset.mul_prod_erase Finset.univ (fun j => ∫ a, + star (if j = i then d (p j) a else v (p j) a) * + (if j = i then e (q j) a else u (q j) a) ∂μ) (Finset.mem_univ i)] + simp only [ite_true] + congr 1 + apply Finset.prod_congr rfl + intro j hj + simp only [ite_eq_right (Finset.mem_erase.mp hj).1] + +omit [MeasurableSpace A] in +lemma slotDeterminant_expansion (v d u e : Fin n → A → ℂ) (i : Fin n) (x : Fin n → A) : + star (slotDeterminant v d i x) * slotDeterminant u e i x = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + (star (slotTensor v d p i x) * slotTensor u e q i x) := by + simp only [slotDeterminant, star_sum, star_mul] + rw [Finset.sum_mul] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + ring + +lemma slotDeterminant_integral (v d u e : Fin n → A → ℂ) + (hv : ∀ a, MemLp (v a) 2 μ) (hd : ∀ a, MemLp (d a) 2 μ) + (hu : ∀ a, MemLp (u a) 2 μ) (he : ∀ a, MemLp (e a) 2 μ) (i : Fin n) : + (∫ x, star (slotDeterminant v d i x) * slotDeterminant u e i x + ∂(Measure.pi fun _ : Fin n => μ)) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ((∫ a, star (d (p i) a) * e (q i) a ∂μ) * + ∏ j ∈ Finset.univ.erase i, ∫ a, star (v (p j) a) * u (q j) a ∂μ) := by + have hi (p q : Equiv.Perm (Fin n)) : Integrable + (fun x : Fin n → A => star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + (star (slotTensor v d p i x) * slotTensor u e q i x)) (Measure.pi fun _ => μ) := + ((slotTensor_memLp v d hv hd p i).star.integrable_mul + (slotTensor_memLp u e hu he q i)).const_mul _ + simp_rw [slotDeterminant_expansion] + rw [integral_finsetSum _ (fun p _ => integrable_finsetSum _ (fun q _ => hi p q))] + apply Finset.sum_congr rfl + intro p _ + rw [integral_finsetSum _ (fun q _ => hi p q)] + apply Finset.sum_congr rfl + intro q _ + rw [integral_const_mul, slotTensor_integral] + +omit [MeasurableSpace A] in +lemma determinant_oneBody_expansion (v u : Fin n → A → ℂ) (w : A → ℂ) (x : Fin n → A) : + (∑ i, w (x i)) * (star (determinantWave v x) * determinantWave u x) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ∑ i, w (x i) * (star (∏ j, v (p j) (x j)) * ∏ j, u (q j) (x j)) := by + rw [determinant_bilinear_expansion] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + +lemma determinant_oneBody_integral (v u : Fin n → A → ℂ) (w : A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hu : ∀ i, MemLp (u i) 2 μ) + (hw : ∀ i j, Integrable (fun a => w a * (star (v i a) * u j a)) μ) : + (∫ x : Fin n → A, (∑ i, w (x i)) * + (star (determinantWave v x) * determinantWave u x) ∂(Measure.pi fun _ => μ)) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ∑ i, (∫ a, w a * (star (v (p i) a) * u (q i) a) ∂μ) * + ∏ j ∈ Finset.univ.erase i, ∫ a, star (v (p j) a) * u (q j) a ∂μ := by + let F (p q : Equiv.Perm (Fin n)) (i : Fin n) (x : Fin n → A) : ℂ := + w (x i) * (star (∏ j, v (p j) (x j)) * ∏ j, u (q j) (x j)) + let c (p q : Equiv.Perm (Fin n)) : ℂ := star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) + have hi (p q : Equiv.Perm (Fin n)) : Integrable (fun x => ∑ i, F p q i x) (Measure.pi fun _ => μ) := + integrable_finsetSum Finset.univ (fun i _ => oneBodyTensor_integrable v u w hv hu hw p q i) + have hj (p : Equiv.Perm (Fin n)) : Integrable (fun x => ∑ q, c p q * ∑ i, F p q i x) + (Measure.pi fun _ => μ) := + integrable_finsetSum Finset.univ (fun q _ => (hi p q).const_mul (c p q)) + simp_rw [determinant_oneBody_expansion] + rw [integral_finsetSum _ (fun p _ => hj p)] + apply Finset.sum_congr rfl + intro p _ + rw [integral_finsetSum _ (fun q _ => (hi p q).const_mul (c p q))] + apply Finset.sum_congr rfl + intro q _ + rw [integral_const_mul, integral_finsetSum _ + (fun i _ => oneBodyTensor_integrable v u w hv hu hw p q i)] + simp only [oneBodyTensor_integral, c] + +omit [MeasurableSpace A] in +lemma determinant_twoBody_expansion (v u : Fin n → A → ℂ) (w : A → A → ℂ) (x : Fin n → A) : + (∑ i, ∑ j ∈ Finset.univ.erase i, w (x i) (x j)) * + (star (determinantWave v x) * determinantWave u x) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ∑ i, ∑ j ∈ Finset.univ.erase i, w (x i) (x j) * + (star (∏ k, v (p k) (x k)) * ∏ k, u (q k) (x k)) := by + rw [determinant_bilinear_expansion] + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + simp only [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + +lemma determinant_twoBody_integral (v u : Fin n → A → ℂ) (w : A → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hu : ∀ i, MemLp (u i) 2 μ) + (hw : ∀ a b c d, Integrable (fun xy : A × A => w xy.1 xy.2 * + ((star (v a xy.1) * u c xy.1) * (star (v b xy.2) * u d xy.2))) (μ.prod μ)) : + (∫ x : Fin n → A, (∑ i, ∑ j ∈ Finset.univ.erase i, w (x i) (x j)) * + (star (determinantWave v x) * determinantWave u x) ∂(Measure.pi fun _ => μ)) = + ∑ p : Equiv.Perm (Fin n), ∑ q : Equiv.Perm (Fin n), + star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) * + ∑ i, ∑ j ∈ Finset.univ.erase i, + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v (p i) xy.1) * u (q i) xy.1) * + (star (v (p j) xy.2) * u (q j) xy.2)) ∂(μ.prod μ)) * + ∏ k ∈ (Finset.univ.erase i).erase j, + ∫ a, star (v (p k) a) * u (q k) a ∂μ := by + let F (p q : Equiv.Perm (Fin n)) (i j : Fin n) (x : Fin n → A) : ℂ := + w (x i) (x j) * (star (∏ k, v (p k) (x k)) * ∏ k, u (q k) (x k)) + let c (p q : Equiv.Perm (Fin n)) : ℂ := star (((p.sign : ℤ) : ℂ)) * (((q.sign : ℤ) : ℂ)) + have hi (p q : Equiv.Perm (Fin n)) : Integrable + (fun x => ∑ i, ∑ j ∈ Finset.univ.erase i, F p q i j x) (Measure.pi fun _ => μ) := + integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun j hj => + twoBodyTensor_integrable v u w hv hu hw p q i j (Finset.mem_erase.mp hj).1.symm)) + have hj (p : Equiv.Perm (Fin n)) : Integrable + (fun x => ∑ q, c p q * ∑ i, ∑ j ∈ Finset.univ.erase i, F p q i j x) + (Measure.pi fun _ => μ) := integrable_finsetSum _ (fun q _ => (hi p q).const_mul _) + calc + _ = ∫ x : Fin n → A, ∑ p, ∑ q, c p q * ∑ i, ∑ j ∈ Finset.univ.erase i, F p q i j x + ∂(Measure.pi fun _ => μ) := by + apply integral_congr_ae + filter_upwards [] with x + exact determinant_twoBody_expansion v u w x + _ = ∑ p, ∑ q, c p q * ∑ i, ∑ j ∈ Finset.univ.erase i, + ∫ x : Fin n → A, F p q i j x ∂(Measure.pi fun _ => μ) := by + rw [integral_finsetSum _ (fun p _ => hj p)] + apply Finset.sum_congr rfl + intro p _ + rw [integral_finsetSum _ (fun q _ => (hi p q).const_mul _)] + apply Finset.sum_congr rfl + intro q _ + rw [integral_const_mul, integral_finsetSum _ (fun i _ => integrable_finsetSum _ + (fun j hj => twoBodyTensor_integrable v u w hv hu hw p q i j (Finset.mem_erase.mp hj).1.symm))] + congr 1 + apply Finset.sum_congr rfl + intro i _ + exact integral_finsetSum _ (fun j hj => + twoBodyTensor_integrable v u w hv hu hw p q i j (Finset.mem_erase.mp hj).1.symm) + _ = _ := by + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro q _ + congr 1 + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j hj + exact twoBodyTensor_integral v u w p q i j (Finset.mem_erase.mp hj).1.symm + +end ContinuumCoulomb.MixedSlater + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MovingWells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MovingWells.lean new file mode 100644 index 0000000000000000000000000000000000000000..1be58406a023be489ab01e1286e9936cc0c1207c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/MovingWells.lean @@ -0,0 +1,173 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.IsolatedForms + +namespace OAI + +/-! +# Motion of secondary nuclei in capped backgrounds + +The cap depends only on the fixed primary centre. On its nonzero support +every permitted secondary pole is at least `D/32` away. Thus its motion has +a uniform `D⁻²` potential bound, before any isolated eigenstate is chosen. +-/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem cappedSitePotential_displacement_bound {D q q' : ℝ} (hD : 128 ≤ D) + (hq' : 0 ≤ q') (center a b x : Position) (ha : ‖a‖ ≤ 4) (hb : ‖b‖ ≤ 4) : + |cappedSitePotential D q q' center a x - cappedSitePotential D q q' center b x| ≤ + 2048 * q' / D ^ 2 * ‖a - b‖ := by + have hD0 : 0 < D := by linarith + by_cases hc : wellCap (‖x - center‖ / D) = 0 + · simp only [cappedSitePotential, hc, zero_mul, sub_self, abs_zero] + positivity + have hr := wellCap_nonzero_radius hD0 hc + have hdist (c : Position) (hc4 : ‖c‖ ≤ 4) : D / 32 ≤ ‖x - center - c‖ := by + have ht : ‖x - center‖ ≤ ‖x - center - c‖ + ‖c‖ := by + calc + _ = ‖(x - center - c) + c‖ := by congr 1; abel + _ ≤ _ := norm_add_le _ _ + linarith + have hkernel (c : Position) (hc4 : ‖c‖ ≤ 4) : + Coulomb.coulombKernel (x - center - c) ≤ 32 / D := by + unfold Coulomb.coulombKernel + calc + _ ≤ (D / 32)⁻¹ := inv_anti₀ (by positivity) (hdist c hc4) + _ = _ := by ring + have hsq (c : Position) (hc4 : ‖c‖ ≤ 4) : + Coulomb.coulombKernel (x - center - c) ^ 2 ≤ (32 / D) ^ 2 := + (sq_le_sq₀ (by unfold Coulomb.coulombKernel; positivity) (by positivity)).mpr (hkernel c hc4) + have heq : cappedSitePotential D q q' center a x - cappedSitePotential D q q' center b x = + wellCap (‖x - center‖ / D) * q' * + (Coulomb.coulombKernel (x - center - a) - Coulomb.coulombKernel (x - center - b)) := by + unfold cappedSitePotential sitePotential + ring + have hshift := coulomb_kernel_shift_bound (x - center) a b + have hsum : Coulomb.coulombKernel (x - center - a) ^ 2 + + Coulomb.coulombKernel (x - center - b) ^ 2 ≤ 2048 / D ^ 2 := by + have h := add_le_add (hsq a ha) (hsq b hb) + convert h using 1 + ring + rw [heq, abs_mul, abs_mul, abs_of_nonneg (wellCap_bounds _).1, abs_of_nonneg hq'] + calc + _ ≤ q' * |Coulomb.coulombKernel (x - center - a) - + Coulomb.coulombKernel (x - center - b)| := + mul_le_mul_of_nonneg_right + (mul_le_of_le_one_left hq' (wellCap_bounds _).2) (abs_nonneg _) + _ ≤ q' * (‖a - b‖ * (2048 / D ^ 2)) := + mul_le_mul_of_nonneg_left + (hshift.trans (mul_le_mul_of_nonneg_left hsum (norm_nonneg _))) hq' + _ = _ := by ring + +theorem backgroundPotential_displacement_bound {m : ℕ} {D q q' delta : ℝ} + (hD : 128 ≤ D) (hq' : 0 ≤ q') (hdelta : 0 ≤ delta) + (center a b : Fin m → Position) (ha : ∀ j, ‖a j‖ ≤ 4) (hb : ∀ j, ‖b j‖ ≤ 4) + (hmove : ∀ j, ‖a j - b j‖ ≤ delta) (site : Fin m) (x : Position) : + |backgroundPotential D q q' center a site x - + backgroundPotential D q q' center b site x| ≤ + 2048 * q' * m / D ^ 2 * delta := by + unfold backgroundPotential + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j, |(if j = site then 0 else cappedSitePotential D q q' (center j) (a j) x) - + (if j = site then 0 else cappedSitePotential D q q' (center j) (b j) x)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _j : Fin m, 2048 * q' / D ^ 2 * delta := by + apply Finset.sum_le_sum + intro j _ + split_ifs with hj + · simp only [sub_self, abs_zero] + positivity + · exact (cappedSitePotential_displacement_bound hD hq' (center j) (a j) (b j) x + (ha j) (hb j)).trans + (mul_le_mul_of_nonneg_left (hmove j) (by positivity)) + _ = _ := by simp; ring + +theorem singlePoleEnergy_position_bound (a b : Position) (state : Coulomb.H1Vector 1) : + |singlePoleEnergy a state - singlePoleEnergy b state| ≤ + 16 * ‖a - b‖ * Coulomb.kinetic state := by + unfold singlePoleEnergy + rw [← Finset.sum_sub_distrib] + have hterm (spin : Coulomb.Spins 1) : + |(∫ x, Coulomb.coulombKernel (Coulomb.position x 0 - a) * ‖state.value spin x‖ ^ 2) - + (∫ x, Coulomb.coulombKernel (Coulomb.position x 0 - b) * ‖state.value spin x‖ ^ 2)| ≤ + 8 * ‖a - b‖ * ∑ k : Fin 3, ∫ x, ‖state.gradient spin (0, k) x‖ ^ 2 := by + rw [← integral_sub + (state.nuclear_coulomb_integrable_bound spin 0 a (by norm_num : (0 : ℝ) < 1)).1 + (state.nuclear_coulomb_integrable_bound spin 0 b (by norm_num : (0 : ℝ) < 1)).1] + simpa only [← sub_mul] using nuclear_position_rounding_bound state spin 0 a b + apply (Finset.abs_sum_le_sum_abs _ _).trans + apply (Finset.sum_le_sum fun spin _ => hterm spin).trans_eq + simp only [← Finset.mul_sum, Coulomb.kinetic, Fintype.sum_prod_type, Fin.sum_univ_one] + ring + +theorem backgroundEnergy_displacement_bound {m : ℕ} {D q q' delta : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hdelta : 0 ≤ delta) (center a b : Fin m → Position) + (ha : ∀ j, ‖a j‖ ≤ 4) (hb : ∀ j, ‖b j‖ ≤ 4) + (hmove : ∀ j, ‖a j - b j‖ ≤ delta) (site : Fin m) (state : Coulomb.H1Vector 1) : + |backgroundEnergy D q q' center a site state - + backgroundEnergy D q q' center b site state| ≤ + (2048 * q' * m / D ^ 2 * delta) * Coulomb.mass state := by + let C := 2048 * q' * m / D ^ 2 * delta + have hC : 0 ≤ C := by dsimp [C]; positivity + have hterm (spin : Coulomb.Spins 1) : + |(∫ x, backgroundPotential D q q' center a site (Coulomb.position x 0) * + ‖state.value spin x‖ ^ 2) - + (∫ x, backgroundPotential D q q' center b site (Coulomb.position x 0) * + ‖state.value spin x‖ ^ 2)| ≤ C * ∫ x, ‖state.value spin x‖ ^ 2 := by + have hia := background_energy_integrable hD hq hq1 hq' hq'1 center a ha site state spin + have hib := background_energy_integrable hD hq hq1 hq' hq'1 center b hb site state spin + rw [← integral_sub hia hib, ← integral_const_mul] + apply (abs_integral_le_integral_abs).trans + apply integral_mono (hia.sub hib).abs + (((state.value_L2 spin).integrable_norm_pow (by norm_num : (2 : ℕ) ≠ 0)).const_mul C) + intro x + dsimp only [Pi.sub_apply] + rw [← sub_mul, abs_mul, abs_of_nonneg (sq_nonneg ‖state.value spin x‖)] + exact mul_le_mul_of_nonneg_right + (backgroundPotential_displacement_bound hD hq' hdelta center a b ha hb hmove site + (Coulomb.position x 0)) (sq_nonneg _) + unfold backgroundEnergy + rw [← Finset.sum_sub_distrib] + exact (Finset.abs_sum_le_sum_abs _ _).trans + ((Finset.sum_le_sum fun spin _ => hterm spin).trans_eq (by rw [← Finset.mul_sum]; rfl)) + +/-- Motion of the own pole costs a kinetic term; motion of all the other +poles costs only the small bounded-background term. -/ +theorem isolatedWellForm_displacement_bound {m : ℕ} {D q q' delta : ℝ} + (hD : 128 ≤ D) (hq : 0 ≤ q) (hq1 : q ≤ 1) (hq' : 0 ≤ q') (hq'1 : q' ≤ 1) + (hdelta : 0 ≤ delta) (center a b : Fin m → Position) + (ha : ∀ j, ‖a j‖ ≤ 4) (hb : ∀ j, ‖b j‖ ≤ 4) + (hmove : ∀ j, ‖a j - b j‖ ≤ delta) (site : Fin m) (state : Coulomb.H1Vector 1) : + |isolatedWellForm D q q' center a site state - + isolatedWellForm D q q' center b site state| ≤ + 16 * q' * ‖a site - b site‖ * Coulomb.kinetic state + + (2048 * q' * m / D ^ 2 * delta) * Coulomb.mass state := by + have hp := singlePoleEnergy_position_bound (center site + a site) (center site + b site) state + have hcancel : (center site + a site) - (center site + b site) = a site - b site := by abel + rw [hcancel] at hp + have hbg := backgroundEnergy_displacement_bound hD hq hq1 hq' hq'1 hdelta + center a b ha hb hmove site state + have heq : isolatedWellForm D q q' center a site state - + isolatedWellForm D q q' center b site state = + -(q' * (singlePoleEnergy (center site + a site) state - + singlePoleEnergy (center site + b site) state)) - + (backgroundEnergy D q q' center a site state - + backgroundEnergy D q q' center b site state) := by + unfold isolatedWellForm + ring + rw [heq] + apply (abs_sub _ _).trans + rw [abs_neg, abs_mul, abs_of_nonneg hq'] + have h := add_le_add (mul_le_mul_of_nonneg_left hp hq') hbg + convert h using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationArithmetic.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c5a70c36d42717211a93ed952ca3a447f1e9520 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationArithmetic.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationSchedule + +namespace OAI + +/-! Unary arithmetic for the explicit normalization quadrature schedule. -/ + +namespace ContinuumCoulomb.NormalizationSchedule +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque constant4096Program : Procedure unaryCode unaryCode (fun _ => 4096) := + ResolventSchedule.constant4096Program.comp + ((Procedure.identity unaryCode).pair (Procedure.identity unaryCode)) + +noncomputable opaque constant8192Program : Procedure unaryCode unaryCode (fun _ => 8192) := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant unaryCode unaryCode 2).pair constant4096Program)).congrFun + (by intro P; norm_num) + +noncomputable opaque scaleSuccessorProgram (c : ℕ) + (pc : Procedure unaryCode unaryCode (fun _ => c)) : + Procedure unaryCode unaryCode (fun P => c * (P + 1)) := + ResolventSchedule.mulProgram.comp (pc.pair Procedure.unarySuccessor) + +noncomputable opaque radiusProgram : Procedure unaryCode unaryCode radius := + (scaleSuccessorProgram 8192 constant8192Program).congrFun + (by intro P; exact (radius_def P).symm) + +noncomputable opaque cubeProgram : Procedure unaryCode unaryCode (fun n => n ^ 3) := + (ResolventSchedule.mulProgram.comp + ((Procedure.identity unaryCode).pair ResolventSchedule.squareProgram)).congrFun + (by intro n; dsimp; ring) + +noncomputable opaque radiusCubeProgram : Procedure unaryCode unaryCode (fun P => radius P ^ 3) := + cubeProgram.comp radiusProgram + +noncomputable opaque meshPrefixProgram : Procedure unaryCode unaryCode meshPrefix := + (ResolventSchedule.mulProgram.comp (constant4096Program.pair radiusCubeProgram)).congrFun + (by intro P; rfl) + +noncomputable opaque meshFactorsProgram : Procedure unaryCode (prodCode unaryCode unaryCode) + (fun P => (meshPrefix P, P + 1)) := meshPrefixProgram.pair Procedure.unarySuccessor + +noncomputable opaque meshRawProgram : Procedure unaryCode unaryCode + (fun P => meshPrefix P * (P + 1)) := ResolventSchedule.mulProgram.comp meshFactorsProgram + +noncomputable opaque meshProgram : Procedure unaryCode unaryCode mesh := + meshRawProgram.congrFun (by intro P; rfl) + +noncomputable opaque radiusSquareProgram : Procedure unaryCode unaryCode (fun P => radius P ^ 2) := + ResolventSchedule.squareProgram.comp radiusProgram + +noncomputable opaque accuracyPrefixProgram : Procedure unaryCode unaryCode accuracyPrefix := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant unaryCode unaryCode 48).pair radiusSquareProgram)).congrFun + (by intro P; rfl) + +noncomputable opaque accuracyFactorsProgram : Procedure unaryCode (prodCode unaryCode unaryCode) + (fun P => (accuracyPrefix P, P + 1)) := accuracyPrefixProgram.pair Procedure.unarySuccessor + +noncomputable opaque accuracyRawProgram : Procedure unaryCode unaryCode + (fun P => accuracyPrefix P * (P + 1)) := ResolventSchedule.mulProgram.comp accuracyFactorsProgram + +noncomputable opaque accuracyProgram : Procedure unaryCode unaryCode accuracy := + accuracyRawProgram.congrFun (by intro P; rfl) + +noncomputable opaque doubleRadiusProgram : Procedure unaryCode unaryCode (fun P => 2 * radius P) := + ResolventSchedule.mulProgram.comp ((Procedure.constant unaryCode unaryCode 2).pair radiusProgram) + +end ContinuumCoulomb.NormalizationSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..a458db86d8b3bc81e192e1adb84caedf017dccd7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationQuadrature.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableResolvent +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalRectangleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NumericalSquare + +namespace OAI + +/-! Literal quadrature of the actual squared resolvent. Each sample is +computed by the fixed Taylor/heat program, with its proved error. -/ + +namespace ContinuumCoulomb.NormalizationQuadrature +open ExactQuantumFactoring.BitStackProgram + +abbrev Settings := ℕ × ℕ +abbrev Input := RationalRectangleProgram.Input Settings + +def settingsCode : Settings → List Bool := prodCode unaryCode unaryCode + +def sample (e : Settings) (a b : ℚ) : ℚ := + ResolventSchedule.approximate (e, (a, b)) ^ 2 + +def value (x : Input) : ℚ := RationalRectangleProgram.value sample x + +noncomputable opaque sampleProgram : + Procedure (prodCode (prodCode settingsCode ratCode) ratCode) ratCode + (fun x => sample x.1.1 x.1.2 x.2) := by + let ax := Procedure.first (prodCode settingsCode ratCode) ratCode + let e := (Procedure.first settingsCode ratCode).comp ax + let a := (Procedure.second settingsCode ratCode).comp ax + let b := Procedure.second (prodCode settingsCode ratCode) ratCode + let point := a.pair b + let q := ResolventSchedule.program.comp (e.pair point) + exact (Procedure.ratMul.comp (q.pair q)).congrFun (by + intro x + simp only [sample, pow_two] + rfl) + +noncomputable opaque program : + Procedure (RationalRectangleProgram.inputCode settingsCode) ratCode value := + RationalRectangleProgram.program settingsCode sample sampleProgram + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime (RationalRectangleProgram.inputCode settingsCode) ratCode value := + program.toTM2 + +theorem sample_error (e : Settings) (a b : ℚ) + (hR : ‖PlanarForcingProgram.position (a, b)‖ ≤ (e.1 : ℝ)) : + |(sample e a b : ℝ) - planarResolventMode (PlanarForcingProgram.position (a, b)) ^ 2| ≤ + 3 * ((e.2 : ℝ) + 1)⁻¹ := by + rw [sample, Rat.cast_pow] + apply unitInterval_square_error (planarResolventMode_positive _).le (planarResolventMode_le_one _) + · exact (inv_le_one₀ (show (0 : ℝ) < (e.2 : ℝ) + 1 by positivity)).mpr + (show (1 : ℝ) ≤ (e.2 : ℝ) + 1 by + linarith [show (0 : ℝ) ≤ (e.2 : ℝ) from Nat.cast_nonneg _]) + · exact ResolventSchedule.approximation_error (e, (a, b)) hR + +theorem error (x : Input) (hh : 0 ≤ (x.2.2.2 : ℝ)) + (hR : ∀ i < x.1, ∀ j < x.1, + ‖PlanarForcingProgram.position + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i, + RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j)‖ ≤ (x.2.1.1 : ℝ)) : + |(value x : ℝ) - + ∫ a in (x.2.2.1 : ℝ)..(RationalQuadratureProgram.node x.2.2.1 x.2.2.2 x.1 : ℝ), + ∫ b in (x.2.2.1 : ℝ)..(RationalQuadratureProgram.node x.2.2.1 x.2.2.2 x.1 : ℝ), + planarResolventMode (planarPairEquiv.symm (a, b)) ^ 2| ≤ + ((x.1 : ℝ) * (x.2.2.2 : ℝ)) ^ 2 * + (128 * (x.2.2.2 : ℝ) + 3 * ((x.2.1.2 : ℝ) + 1)⁻¹) := by + let f := fun a b => planarResolventMode (planarPairEquiv.symm (a, b)) ^ 2 + let v := fun i j => (sample x.2.1 + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j) : ℝ) + have hx : ∀ a a' b, |f a b - f a' b| ≤ 64 * |a - a'| := by + intro a a' b + simpa only [f, planarPair_distance_first] using + planarResolventMode_square_norm_sub (planarPairEquiv.symm (a, b)) (planarPairEquiv.symm (a', b)) + have hy : ∀ a b b', |f a b - f a b'| ≤ 64 * |b - b'| := by + intro a b b' + simpa only [f, planarPair_distance_second] using + planarResolventMode_square_norm_sub (planarPairEquiv.symm (a, b)) (planarPairEquiv.symm (a, b')) + have hs : ∀ i < x.1, ∀ j < x.1, + |v i j - f (UniformQuadrature.node (x.2.2.1 : ℝ) (x.2.2.2 : ℝ) i) + (UniformQuadrature.node (x.2.2.1 : ℝ) (x.2.2.2 : ℝ) j)| ≤ + 3 * ((x.2.1.2 : ℝ) + 1)⁻¹ := by + intro i hi j hj + have h := sample_error x.2.1 _ _ (hR i hi j hj) + simpa only [v, f, rationalPosition_eq_pair, RationalQuadratureProgram.node_cast] using h + have h := UniformQuadrature.rectangle_error f v _ _ x.1 _ _ x.1 hh hh + (by norm_num : (0 : ℝ) ≤ 64) (by norm_num : (0 : ℝ) ≤ 64) + (fun a _ a' _ b _ => hx a a' b) (fun a _ b _ b' _ => hy a b b') hs + rw [value, RationalRectangleProgram.value_cast] + simp only [RationalQuadratureProgram.node_cast] + convert h using 1 + ring + +end ContinuumCoulomb.NormalizationQuadrature + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d5f64df2e2f15e07d6caa6b4c50d7293e1a0682 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NormalizationSchedule.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalizationBox + +namespace OAI + +/-! A fixed polynomial schedule for the actual normalization integral. +The outer square grows linearly with inverse accuracy; both nested mesh +counts and the inner resolvent accuracy are explicit natural polynomials. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.NormalizationSchedule + +irreducible_def radius (P : ℕ) : ℕ := 8192 * (P + 1) +def meshPrefix (P : ℕ) : ℕ := 4096 * radius P ^ 3 +def mesh (P : ℕ) : ℕ := meshPrefix P * (P + 1) +def accuracyPrefix (P : ℕ) : ℕ := 48 * radius P ^ 2 +def accuracy (P : ℕ) : ℕ := accuracyPrefix P * (P + 1) + +def input (P : ℕ) : NormalizationQuadrature.Input := + (mesh P, ((2 * radius P, accuracy P), + (-(radius P : ℚ), (2 * (radius P : ℚ)) / (mesh P : ℚ)))) + +def approximate (P : ℕ) : ℚ := NormalizationQuadrature.value (input P) + +theorem radius_positive (P : ℕ) : 0 < radius P := by rw [radius_def]; positivity + +theorem mesh_positive (P : ℕ) : 0 < mesh P := by + have h := radius_positive P + unfold mesh meshPrefix + positivity + +theorem input_step_nonnegative (P : ℕ) : 0 ≤ ((input P).2.2.2 : ℝ) := by + have hL : (0 : ℚ) < radius P := by exact_mod_cast radius_positive P + have hN : (0 : ℚ) < mesh P := by exact_mod_cast mesh_positive P + change 0 ≤ (((2 * (radius P : ℚ)) / (mesh P : ℚ) : ℚ) : ℝ) + exact_mod_cast (div_nonneg (by positivity : (0 : ℚ) ≤ 2 * radius P) hN.le) + +theorem input_endpoint (P : ℕ) : + RationalQuadratureProgram.node (input P).2.2.1 (input P).2.2.2 (mesh P) = (radius P : ℚ) := by + have hN : (mesh P : ℚ) ≠ 0 := by exact_mod_cast (mesh_positive P).ne' + change -(radius P : ℚ) + (mesh P : ℚ) * (2 * (radius P : ℚ) / (mesh P : ℚ)) = _ + field_simp + ring + +theorem input_node_mem (P i : ℕ) (hi : i ≤ mesh P) : + (RationalQuadratureProgram.node (input P).2.2.1 (input P).2.2.2 i : ℝ) ∈ + Set.Icc (-(radius P : ℝ)) (radius P : ℝ) := by + have h := UniformQuadrature.node_mem (a := ((input P).2.2.1 : ℝ)) + (input_step_nonnegative P) hi + rw [← RationalQuadratureProgram.node_cast, ← RationalQuadratureProgram.node_cast, + input_endpoint P] at h + simpa only [input, Rat.cast_neg, Rat.cast_natCast] using h + +theorem input_nodes_norm (P i j : ℕ) (hi : i < mesh P) (hj : j < mesh P) : + ‖PlanarForcingProgram.position + (RationalQuadratureProgram.node (input P).2.2.1 (input P).2.2.2 i, + RationalQuadratureProgram.node (input P).2.2.1 (input P).2.2.2 j)‖ ≤ + (2 * radius P : ℕ) := by + rw [rationalPosition_eq_pair, Nat.cast_mul, Nat.cast_ofNat] + exact planarPair_norm_box (by exact_mod_cast (radius_positive P).le) + ⟨input_node_mem P i hi.le, input_node_mem P j hj.le⟩ + +theorem numerical_budget {L S N K : ℝ} (hL : 0 < L) (hS : 0 < S) + (hN : N = 4096 * L ^ 3 * S) (hK : K = 48 * L ^ 2 * S) + (hLS : L = 8192 * S) : + (N * (2 * L / N)) ^ 2 * (128 * (2 * L / N) + 3 / (K + 1)) + + 1024 * Real.exp (-(1 / 2 : ℝ) * L) ≤ S⁻¹ := by + have hN0 : 0 < N := by rw [hN]; positivity + have hK0 : 0 < K := by rw [hK]; positivity + have hlen : N * (2 * L / N) = 2 * L := by field_simp [hN0.ne'] + have hs : (2 * L) ^ 2 * (128 * (2 * L / N)) = (4 * S)⁻¹ := by + rw [hN] + field_simp [hL.ne', hS.ne'] + ring + have hb : (2 * L) ^ 2 * (3 / (K + 1)) ≤ (4 * S)⁻¹ := by + calc + _ ≤ (2 * L) ^ 2 * (3 / K) := mul_le_mul_of_nonneg_left + (div_le_div_of_nonneg_left (by norm_num) hK0 (by linarith)) (sq_nonneg _) + _ = _ := by rw [hK]; field_simp [hL.ne', hS.ne']; ring + have ht : 1024 * Real.exp (-(1 / 2 : ℝ) * L) ≤ (4 * S)⁻¹ := by + calc + _ ≤ 1024 * (L / 2)⁻¹ := by + have he := ResolventSchedule.exp_tail_le_inverse (show 0 < L / 2 by positivity) + have he' : Real.exp (-(1 / 2 : ℝ) * L) ≤ (L / 2)⁻¹ := by + rw [show -(1 / 2 : ℝ) * L = -(L / 2) by ring] + exact he + exact mul_le_mul_of_nonneg_left he' (by norm_num) + _ = _ := by rw [hLS]; field_simp [hS.ne']; ring + rw [hlen, mul_add, hs] + have hsmall : 3 * (4 * S)⁻¹ ≤ S⁻¹ := by + rw [mul_inv] + norm_num + nlinarith [inv_pos.mpr hS] + linarith + +theorem approximation_error (P : ℕ) : + |(approximate P : ℝ) - (∫ r, planarResolventMode r ^ 2)| ≤ ((P : ℝ) + 1)⁻¹ := by + let L := (radius P : ℝ) + let N := (mesh P : ℝ) + let K := (accuracy P : ℝ) + let S := (P : ℝ) + 1 + have hL : 0 < L := by + dsimp only [L] + exact_mod_cast radius_positive P + have hS : 0 < S := by dsimp [S]; positivity + have hN : N = 4096 * L ^ 3 * S := by + dsimp [N, L, S, mesh, meshPrefix] + push_cast + rfl + have hK : K = 48 * L ^ 2 * S := by + dsimp [K, L, S, accuracy, accuracyPrefix] + push_cast + rfl + have hLS : L = 8192 * S := by + dsimp only [L, S] + rw [radius_def] + push_cast + rfl + have hquad := NormalizationQuadrature.error (input P) (input_step_nonnegative P) + (fun i hi j hj => input_nodes_norm P i j hi hj) + have hend : RationalQuadratureProgram.node (input P).2.2.1 (input P).2.2.2 + (input P).1 = (radius P : ℚ) := input_endpoint P + rw [hend] at hquad + have hquad' : |(approximate P : ℝ) - planarNormalizationBox L| ≤ + (N * (2 * L / N)) ^ 2 * (128 * (2 * L / N) + 3 / (K + 1)) := by + dsimp only [L, N, K] + simpa only [approximate, planarNormalizationBox, input, Rat.cast_neg, Rat.cast_natCast, + Rat.cast_div, Rat.cast_mul, Rat.cast_ofNat, div_eq_mul_inv, Rat.cast_inv] using hquad + have htail := planarNormalizationBox_error hL.le + have htotal := (abs_sub_le (approximate P : ℝ) (planarNormalizationBox L) + (∫ r, planarResolventMode r ^ 2)).trans (add_le_add hquad' htail) + exact htotal.trans (numerical_budget hL hS hN hK hLS) + +end ContinuumCoulomb.NormalizationSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalGridRounding.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalGridRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..c362a347fad84d19f6ebc3d057ab8f375df0ce08 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalGridRounding.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EnumeratedGridNuclei +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GroundRoundingInterval +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussList +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalFieldDifferences + +namespace OAI + +/-! Transfer of the full ground-energy interval to the actual rational +Euler/Gauss nodes, with the physical inverse-scale coordinates. -/ + +noncomputable section +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb +open CappedKernelProgram (Triple position) + +def physicalRationalNuclei {m : ℕ} (hm : 0 < m) (q : Fin m → Triple) + (hq : Function.Injective q) {scale : ℝ} (hs : 0 < scale) : Coulomb.Nuclei m where + nonempty := hm + position a := scale⁻¹ • position (q a) + distinct := by + intro a b hab + apply hq + apply RationalFieldDifferences.position_injective + have he := congrArg (fun x : Position => scale • x) hab + simpa only [smul_inv_smul₀ hs.ne'] using he + charge _ := 1 + charge_ge_one _ := le_rfl + +theorem physicalRationalNuclei_totalCharge {m : ℕ} (hm : 0 < m) (q : Fin m → Triple) + (hq : Function.Injective q) {scale : ℝ} (hs : 0 < scale) : + Coulomb.totalCharge (physicalRationalNuclei hm q hq hs)=m := by + simp [Coulomb.totalCharge,physicalRationalNuclei] + +namespace CenteredGaussLabels + +theorem numerical_ground_interval (r : Radii) (rho U C K P : ℕ) {N : ℕ} (hN : 0 < N) + (fieldScale S : ℚ) (sites : List (ℚ×ℚ)) (G : Position → Position) + (hG : Function.Injective G) {J : ℝ≥0} (hAnti : AntilipschitzWith J G) + (herror : ∀ l : TransformedGauss.Label, + ‖position (TransformedGauss.value rho U C K P N fieldScale S sites l.1 l.2)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index l.1 l.2))‖ ≤ ((P:ℝ)+1)⁻¹) + (hprecision : 2*(J:ℝ)*((P:ℝ)+1)⁻¹ < (N:ℝ)⁻¹/3) + {scale : ℝ} (hs : 0 < scale) (n : ℕ) {center error roundError : ℝ} + (hlo : ((center-error:ℝ):EReal) ≤ + formGroundEnergy (dilatedNuclei (nuclei r G hG (by positivity : 0 < (N:ℝ)⁻¹)) scale hs.ne') n) + (hhi : formGroundEnergy (dilatedNuclei (nuclei r G hG (by positivity : 0 < (N:ℝ)⁻¹)) scale hs.ne') n ≤ + ((center+error:ℝ):EReal)) + (hsmall : 32*(scale⁻¹*((P:ℝ)+1)⁻¹)*(labels r).length ≤ 1) + (hbudget : 32*(scale⁻¹*((P:ℝ)+1)⁻¹)*(labels r).length* + (center+error+4*(n:ℝ)*((labels r).length:ℝ)^2) ≤ roundError) : + let q := fun a : Fin (labels r).length => TransformedGauss.value rho U C K P N fieldScale S sites + ((labels r).get a).1 ((labels r).get a).2 + ∃ hq : Function.Injective q, + ((center-error-roundError:ℝ):EReal) ≤ + formGroundEnergy (physicalRationalNuclei (by rw [labels_length]; positivity) q hq hs) n ∧ + formGroundEnergy (physicalRationalNuclei (by rw [labels_length]; positivity) q hq hs) n ≤ + ((center+error+roundError:ℝ):EReal) := by + dsimp only + let q := fun a : Fin (labels r).length => TransformedGauss.value rho U C K P N fieldScale S sites + ((labels r).get a).1 ((labels r).get a).2 + have hlabels : Function.Injective (fun a : Fin (labels r).length => (labels r).get a) := by + intro a b hab + apply (List.Nodup.getEquiv (labels r) (labels_nodup r)).injective + exact Subtype.ext hab + have hq : Function.Injective q := TransformedGauss.value_injective _ hlabels rho U C K P hN + fieldScale S sites G hAnti (fun a => herror ((labels r).get a)) hprecision + refine ⟨hq,?_⟩ + let exactNuc := dilatedNuclei (nuclei r G hG (by positivity : 0 < (N:ℝ)⁻¹)) scale hs.ne' + let approxNuc := physicalRationalNuclei (by rw [labels_length]; positivity) q hq hs + have hcharge : exactNuc.charge=approxNuc.charge := rfl + have htotal : Coulomb.totalCharge exactNuc=(labels r).length := by + change Coulomb.totalCharge (nuclei r G hG (by positivity : 0 < (N:ℝ)⁻¹)) = _ + exact nuclei_totalCharge r G hG (by positivity : 0 < (N:ℝ)⁻¹) + have hmove (a : Fin (labels r).length) : + ‖exactNuc.position a-approxNuc.position a‖ ≤ scale⁻¹*((P:ℝ)+1)⁻¹ := by + change ‖scale⁻¹ • G (gaussLatticePoint (N:ℝ)⁻¹ + (RationalGaussNodes.index ((labels r).get a).1 ((labels r).get a).2))- + scale⁻¹ • position (q a)‖ ≤ _ + rw [← smul_sub,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hs.le),norm_sub_rev] + exact mul_le_mul_of_nonneg_left (herror ((labels r).get a)) (inv_nonneg.mpr hs.le) + apply formGroundEnergy_rounding_interval exactNuc approxNuc hlo hhi (by positivity) + hcharge hmove + · simpa only [htotal] using hsmall + · simpa only [htotal] using hbudget + +end CenteredGaussLabels +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalSquare.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b2215e6ebbdd58a188be4c1a47cbeb8984daa5f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/NumericalSquare.lean @@ -0,0 +1,27 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RectangleQuadrature + +namespace OAI + +/-! Squaring a computed value is uniformly stable on the range of the +constructed planar resolvent. -/ + +namespace ContinuumCoulomb + +theorem unitInterval_square_error {a b ε : ℝ} (hb0 : 0 ≤ b) (hb1 : b ≤ 1) + (hε : ε ≤ 1) (herr : |a - b| ≤ ε) : |a ^ 2 - b ^ 2| ≤ 3 * ε := by + have he0 : 0 ≤ ε := (abs_nonneg _).trans herr + have ha : |a| ≤ 2 := by + have h := abs_add_le (a - b) b + rw [sub_add_cancel, abs_of_nonneg hb0] at h + linarith + have hs : |a + b| ≤ 3 := (abs_add_le a b).trans (by + rw [abs_of_nonneg hb0] + linarith) + rw [show a ^ 2 - b ^ 2 = (a - b) * (a + b) by ring, abs_mul] + calc + _ ≤ ε * 3 := mul_le_mul herr hs (abs_nonneg _) he0 + _ = _ := by ring + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneBodyScaleBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneBodyScaleBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c43126453a6c292843f17c775fdafee25649210 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneBodyScaleBudget.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialResidualBudget + +namespace OAI + +/-! The amplified matrix error decays after retaining the smallness of +the shifted matrix in the change of basis. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem logarithmic_separation_overlap {N D : ℝ} (hN : 2 ≤ N) (k : ℕ) + (hD : 25*(k:ℝ)*Real.log N ≤ D) : + Real.exp (-(9/10:ℝ)*D) ≤ ((N^k)^22)⁻¹ := by + have hN0 : 0 < N := by linarith + have hklog : 0 ≤ (k:ℝ)*Real.log N := + mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by linarith)) + have he := Real.exp_le_exp.mpr + (show -(9/10:ℝ)*D ≤ -22*(k:ℝ)*Real.log N by nlinarith only [hD,hklog]) + apply he.trans_eq + rw [show -22*(k:ℝ)*Real.log N = -((22*k:ℕ):ℝ)*Real.log N by push_cast; ring, + neg_mul,Real.exp_neg,Real.exp_nat_mul,Real.exp_log hN0] + congr 1 + rw [← pow_mul] + congr 1 + omega + +private theorem matrix_monomial_bound {R m c : ℝ} {p q : ℕ} + (hR : 1 ≤ R) (hm : 0 ≤ m) (hc : 0 ≤ c) (hp : p ≤ 5) (hq : 2 ≤ q) : + c*m^p/R^q ≤ c*(m+1)^5/R^2 := by + have hR0 : 0 < R := lt_of_lt_of_le zero_lt_one hR + have hm5 : m^p ≤ (m+1)^5 := (pow_le_pow_left₀ hm (by linarith) p).trans + (pow_le_pow_right₀ (by linarith) hp) + exact div_le_div₀ (show 0 ≤ c*(m+1)^5 by positivity) + (mul_le_mul_of_nonneg_left hm5 hc) (pow_pos hR0 _) + (pow_le_pow_right₀ hR hq) + +theorem one_body_scale_identity {R a d E P O W m : ℝ} + (hR : R ≠ 0) (ha : a ≠ 0) : + let δ := d*m/(a*R^30) + let B := (W*O+m*P)/R^22+m*δ*P + (a*R^30)*(4*m^2/R^32+m^2*(4*(2*m*(O/R^22))*B)+4*m^2*(E*(m+1)/R^32))+ + (a*R^30*m*P+m^2*d*P)/R^40+m^2*d*(W*O)/R^22 = + (4*a)*m^2/R^2+(4*a*E)*m^3/R^2+(4*a*E)*m^2/R^2+ + (8*a*W*O^2)*m^3/R^14+(8*a*O*P)*m^4/R^14+ + (8*d*O*P)*m^5/R^22+(a*P)*m/R^10+(d*P)*m^2/R^40+ + (d*W*O)*m^2/R^22 := by + dsimp only + field_simp [hR,ha] + ring + +theorem one_body_scale_bound {R a d E P O W m : ℝ} + (hR : 1 ≤ R) (ha : 0 < a) (hd : 0 ≤ d) (hE : 0 ≤ E) + (hP : 0 ≤ P) (hO : 0 ≤ O) (hW : 0 ≤ W) (hm : 0 ≤ m) : + let δ := d*m/(a*R^30) + let B := (W*O+m*P)/R^22+m*δ*P + (a*R^30)*(4*m^2/R^32+m^2*(4*(2*m*(O/R^22))*B)+4*m^2*(E*(m+1)/R^32))+ + (a*R^30*m*P+m^2*d*P)/R^40+m^2*d*(W*O)/R^22 ≤ + (4*a+8*a*E+8*a*W*O^2+8*a*O*P+8*d*O*P+a*P+d*P+d*W*O)*(m+1)^5/R^2 := by + dsimp only + rw [one_body_scale_identity (ne_of_gt (lt_of_lt_of_le zero_lt_one hR)) (ne_of_gt ha)] + have h1 := matrix_monomial_bound (p := 2) (q := 2) hR hm (show 0 ≤ 4*a by positivity) (by decide) (by decide) + have h2 := matrix_monomial_bound (p := 3) (q := 2) hR hm (show 0 ≤ 4*a*E by positivity) (by decide) (by decide) + have h3 := matrix_monomial_bound (p := 2) (q := 2) hR hm (show 0 ≤ 4*a*E by positivity) (by decide) (by decide) + have h4 := matrix_monomial_bound (p := 3) (q := 14) hR hm (show 0 ≤ 8*a*W*O^2 by positivity) (by decide) (by decide) + have h5 := matrix_monomial_bound (p := 4) (q := 14) hR hm (show 0 ≤ 8*a*O*P by positivity) (by decide) (by decide) + have h6 := matrix_monomial_bound (p := 5) (q := 22) hR hm (show 0 ≤ 8*d*O*P by positivity) (by decide) (by decide) + have h7 := matrix_monomial_bound (p := 1) (q := 10) hR hm (show 0 ≤ a*P by positivity) (by decide) (by decide) + have h8 := matrix_monomial_bound (p := 2) (q := 40) hR hm (show 0 ≤ d*P by positivity) (by decide) (by decide) + have h9 := matrix_monomial_bound (p := 2) (q := 22) hR hm (show 0 ≤ d*W*O by positivity) (by decide) (by decide) + have hsum := add_le_add (add_le_add (add_le_add (add_le_add (add_le_add + (add_le_add (add_le_add (add_le_add h1 h2) h3) h4) h5) h6) h7) h8) h9 + simp only [pow_one] at hsum + exact hsum.trans_eq (by ring) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronClosure.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2b6d8828e3e2981395171cf230746ff746a66cc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronClosure.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronCoordinates + +namespace OAI + +/-! Transfer of the physical one-electron estimate to the full spinful weak-H1 +form domain. The only approximation input is the published H=W density result. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def oneElectronOrbitalLp (φ : Position → ℝ) (hφ : MemLp φ 2) : + Lp ℂ 2 (volume : Measure (Configuration 1)) := + (hφ.ofReal.comp_measurePreserving oneElectronCoordinates.measurePreserving).toLp + (fun x => (φ (oneElectronCoordinates x) : ℂ)) + +theorem h1_inner_real_orbital {n : ℕ} (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (φ : Configuration n → ℝ) (hφ : MemLp φ 2) : + inner ℂ (hφ.ofReal.toLp (fun x => (φ x : ℂ))) (h1Coordinates u (Sum.inl s)) = + ∫ x, u.value s x*(φ x : ℂ) := by + have hcφ : MemLp (fun x => (φ x : ℂ)) 2 := hφ.ofReal + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hcφ.coeFn_toLp,(h1Coordinate_memLp u (Sum.inl s)).coeFn_toLp] + with x hφx hux + change inner ℂ (hφ.ofReal.toLp (fun x => (φ x : ℂ)) x) + (h1Coordinates u (Sum.inl s) x) = _ + change h1Coordinates u (Sum.inl s) x = u.value s x at hux + rw [hφx,hux,RCLike.inner_apply] + simp only [Complex.conj_ofReal] + +theorem oneElectron_inner_real_orbital (u : Coulomb.H1Vector 1) + (s : SpinConfiguration 1) (φ : Position → ℝ) (hφ : MemLp φ 2) : + inner ℂ (oneElectronOrbitalLp φ hφ) (h1Coordinates u (Sum.inl s)) = + ∫ x, u.value s x*(φ (oneElectronCoordinates x) : ℂ) := + h1_inner_real_orbital u s (fun x => φ (oneElectronCoordinates x)) + (hφ.comp_measurePreserving oneElectronCoordinates.measurePreserving) + +theorem oneElectron_graphOrbitalMass {ι : Type*} [Fintype ι] + (φ : ι → Position → ℝ) (hφ : ∀ i, MemLp (φ i) 2) (u : Coulomb.H1Vector 1) : + graphOrbitalMass (fun i => oneElectronOrbitalLp (φ i) (hφ i)) (h1Coordinates u) = + ∑ s, ∑ i, ‖∫ x, u.value s x*(φ i (oneElectronCoordinates x) : ℂ)‖^2 := by + unfold graphOrbitalMass + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro i _ + exact congrArg (fun z : ℂ => ‖z‖^2) + (h1_inner_real_orbital u s (fun x => φ i (oneElectronCoordinates x)) + ((hφ i).comp_measurePreserving oneElectronCoordinates.measurePreserving)) + +theorem oneElectron_weakH1_lower + (hdensity : PublishedSobolevSmoothDensity) + {ι : Type*} [Fintype ι] (V : Position → ℝ) (hV : Continuous V) + (B : ℝ) (hB : ∀ x, |V x| ≤ B) (φ : ι → Position → ℝ) + (hφ : ∀ i, MemLp (φ i) 2) (E κ : ℝ) + (hphysical : ∀ f : Position → ℂ, ContDiff ℝ 1 f → HasCompactSupport f → + E*(∫ x, ‖f x‖^2)-κ*(∑ i, ‖∫ x, f x*(φ i x : ℂ)‖^2) ≤ positionComplexForm V f) + (u : Coulomb.H1Vector 1) : + E*Coulomb.mass u-κ*graphOrbitalMass (fun i => oneElectronOrbitalLp (φ i) (hφ i)) + (h1Coordinates u) ≤ boundedPotentialForm (fun x => V (oneElectronCoordinates x)) u := by + apply boundedPotential_projection_lower_of_compact hdensity _ + (hV.comp oneElectronCoordinates.continuous) B (fun x => hB _) _ E κ ?_ u + intro v hv hd + have hs (s : SpinConfiguration 1) := hphysical (oneElectronPullback (v.value s)) + (oneElectronPullback_contDiff (hv s).1) (oneElectronPullback_compact (hv s).2) + have hm (s : SpinConfiguration 1) : (∫ x, ‖oneElectronPullback (v.value s) x‖^2) = + ∫ x, ‖v.value s x‖^2 := oneElectronPullback_integral (fun x => ‖v.value s x‖^2) + have ho (s : SpinConfiguration 1) (i : ι) : + (∫ x, oneElectronPullback (v.value s) x*(φ i x : ℂ)) = + ∫ x, v.value s x*(φ i (oneElectronCoordinates x) : ℂ) := by + have h := oneElectronPullback_integral_complex + (fun x => v.value s x*(φ i (oneElectronCoordinates x) : ℂ)) + simpa only [oneElectronPullback,LinearIsometryEquiv.apply_symm_apply] using h + have hs' (s : SpinConfiguration 1) : + E*(∫ x, ‖v.value s x‖^2)-κ*(∑ i, ‖∫ x, v.value s x*(φ i (oneElectronCoordinates x) : ℂ)‖^2) ≤ + (1/2:ℝ)*(∑ a : Fin 3, ∫ x, ‖fderiv ℝ (v.value s) x (EuclideanSpace.single (0,a) 1)‖^2)+ + ∫ x, V (oneElectronCoordinates x)*‖v.value s x‖^2 := by + simpa only [hm,ho,oneElectronPullback_form V (hv s).1] using hs s + have h := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hs' s) + rw [oneElectron_graphOrbitalMass] + unfold Coulomb.mass boundedPotentialForm Coulomb.kinetic + simp_rw [hd,Fintype.sum_prod_type,Fin.sum_univ_one] + simpa only [Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum, + Function.comp_apply] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronComplexLaplacian.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronComplexLaplacian.lean new file mode 100644 index 0000000000000000000000000000000000000000..40f8efa56e7d7468185115c939deb722718c4473 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronComplexLaplacian.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.TensorDifferential +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedResidualPairing + +namespace OAI + +/-! The one-electron coordinate isometry identifies the physical complex +Laplacian with the Laplacian already used for the manufactured real orbitals. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem configurationComplexPartial_ofReal {n : ℕ} (f : Configuration n → ℝ) + (hf : ContDiff ℝ 1 f) (a : Fin n × Fin 3) (x : Configuration n) : + configurationComplexPartial (fun y => (f y:ℂ)) a x = + (configurationRealPartial f a x:ℂ) := by + exact congrArg (fun L : Configuration n →L[ℝ] ℂ => L (EuclideanSpace.single a 1)) + (Complex.ofRealCLM.hasFDerivAt.comp x (hf.differentiable (by norm_num) x).hasFDerivAt).fderiv + +theorem configurationComplexLaplacian_ofReal {n : ℕ} (f : Configuration n → ℝ) + (hf : ContDiff ℝ 2 f) (x : Configuration n) : + configurationComplexLaplacian (fun y => (f y:ℂ)) x = + (configurationRealLaplacian f x:ℂ) := by + have hfirst (a : Fin n × Fin 3) : + configurationComplexPartial (fun y => (f y:ℂ)) a = + (fun y => (configurationRealPartial f a y:ℂ)) := + funext (configurationComplexPartial_ofReal f (hf.of_le (by norm_num)) a) + simp only [configurationComplexLaplacian,hfirst, + configurationComplexPartial_ofReal _ (configurationRealPartial_C1 hf _), + configurationRealLaplacian,Complex.ofReal_sum] + +theorem oneElectron_complex_partial (f : Position → ℂ) (hf : ContDiff ℝ 1 f) + (b : Fin 3) (x : Configuration 1) : + configurationComplexPartial (fun y => f (oneElectronCoordinates y)) (0,b) x = + positionComplexPartial f b (oneElectronCoordinates x) := by + have h := (hf.differentiable (by norm_num) (oneElectronCoordinates x)).hasFDerivAt.comp x + oneElectronCoordinates.toContinuousLinearEquiv.hasFDerivAt + simpa only [configurationComplexPartial,positionComplexPartial,Function.comp_def, + ContinuousLinearMap.comp_apply,LinearIsometryEquiv.coe_toContinuousLinearEquiv, + ContinuousLinearEquiv.coe_coe,oneElectronCoordinates_single] using + congrArg (fun L : Configuration 1 →L[ℝ] ℂ => L (EuclideanSpace.single (0,b) 1)) h.fderiv + +theorem oneElectron_complex_laplacian (f : Position → ℂ) (hf : ContDiff ℝ 2 f) + (x : Configuration 1) : + configurationComplexLaplacian (fun y => f (oneElectronCoordinates y)) x = + positionComplexLaplacian f (oneElectronCoordinates x) := by + have hfirst (b : Fin 3) : + configurationComplexPartial (fun y => f (oneElectronCoordinates y)) (0,b) = + (fun y => positionComplexPartial f b (oneElectronCoordinates y)) := + funext (oneElectron_complex_partial f (hf.of_le (by norm_num)) b) + unfold configurationComplexLaplacian + rw [Fintype.sum_prod_type,Fin.sum_univ_one] + simp only [hfirst,oneElectron_complex_partial _ (positionComplexPartial_C1 f hf _), + positionComplexLaplacian] + +theorem correctedManufacturedResidual_complex_laplacian {rho freq : ℝ} + (hrelation : freq^2 = 4*Real.pi*rho) (H S scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (i : Fin m) (x : Position) : + (correctedManufacturedResidual rho H S freq scale u i x:ℂ) = + (-1/2:ℂ)*positionComplexLaplacian (fun y => (correctedLocalizedMode freq u i y:ℂ)) x+ + (manufacturedSlabPotential rho H S freq scale u x:ℂ)*(correctedLocalizedMode freq u i x:ℂ)- + (((-1/2:ℝ)+freq/2):ℂ)*(correctedLocalizedMode freq u i x:ℂ) := by + have hf : ContDiff ℝ 2 (correctedLocalizedMode freq u i) := + (localizedLinearOrbital_C7 freq u (correctedLocalizedCoefficients u i)).of_le (by norm_num) + have hx := correctedManufacturedResidual_eq hrelation H S scale u i (oneElectronCoordinates.symm x) + have hL := oneElectron_complex_laplacian (fun y => (correctedLocalizedMode freq u i y:ℂ)) + (Complex.ofRealCLM.contDiff.comp hf) (oneElectronCoordinates.symm x) + change configurationComplexLaplacian (fun y => (oneElectronCorrectedMode freq u i y:ℂ)) + (oneElectronCoordinates.symm x) = _ at hL + rw [configurationComplexLaplacian_ofReal _ (oneElectronCorrectedMode_C2 freq u i)] at hL + simp only [LinearIsometryEquiv.apply_symm_apply] at hx hL + rw [← hL, hx] + simp only [oneElectronCorrectedMode,LinearIsometryEquiv.apply_symm_apply] + push_cast + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..53804485b1e26c50eb60b5435ae3c689a46de255 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronCoordinates.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ComplexFormSplit +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1FiniteProjection + +namespace OAI + +/-! Volume- and kinetic-energy-preserving identification of one-electron +configuration space with physical three-dimensional space. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def oneElectronCoordinates : Configuration 1 ≃ₗᵢ[ℝ] Position := + LinearIsometryEquiv.piLpCongrLeft 2 ℝ ℝ (Equiv.uniqueProd (Fin 3) (Fin 1)) + +theorem oneElectronCoordinates_apply (x : Configuration 1) : + oneElectronCoordinates x = Coulomb.position x 0 := rfl + +theorem oneElectronCoordinates_single (a : Fin 3) : + oneElectronCoordinates (EuclideanSpace.single (0,a) (1:ℝ)) = EuclideanSpace.single a 1 := by + exact LinearIsometryEquiv.piLpCongrLeft_single _ _ _ + +theorem oneElectronCoordinates_symm_single (a : Fin 3) : + oneElectronCoordinates.symm (EuclideanSpace.single a (1:ℝ)) = + EuclideanSpace.single (0,a) 1 := by + apply oneElectronCoordinates.injective + rw [LinearIsometryEquiv.apply_symm_apply,oneElectronCoordinates_single] + +theorem oneElectronCoordinates_integral (f : Position → ℝ) : + (∫ x : Configuration 1, f (oneElectronCoordinates x)) = ∫ y, f y := + oneElectronCoordinates.measurePreserving.integral_comp + oneElectronCoordinates.toHomeomorph.measurableEmbedding f + +theorem oneElectronCoordinates_integral_complex (f : Position → ℂ) : + (∫ x : Configuration 1, f (oneElectronCoordinates x)) = ∫ y, f y := + oneElectronCoordinates.measurePreserving.integral_comp + oneElectronCoordinates.toHomeomorph.measurableEmbedding f + +def oneElectronPullback (f : Configuration 1 → ℂ) (y : Position) : ℂ := + f (oneElectronCoordinates.symm y) + +theorem oneElectronPullback_contDiff {f : Configuration 1 → ℂ} (hf : ContDiff ℝ 1 f) : + ContDiff ℝ 1 (oneElectronPullback f) := hf.comp oneElectronCoordinates.symm.contDiff + +theorem oneElectronPullback_compact {f : Configuration 1 → ℂ} (hc : HasCompactSupport f) : + HasCompactSupport (oneElectronPullback f) := + hc.comp_homeomorph oneElectronCoordinates.symm.toHomeomorph + +theorem oneElectronPullback_partial {f : Configuration 1 → ℂ} (hf : ContDiff ℝ 1 f) + (a : Fin 3) (y : Position) : + fderiv ℝ (oneElectronPullback f) y (EuclideanSpace.single a 1) = + fderiv ℝ f (oneElectronCoordinates.symm y) (EuclideanSpace.single (0,a) 1) := by + have h := ((hf.differentiable (by norm_num)) (oneElectronCoordinates.symm y)).hasFDerivAt.comp y + oneElectronCoordinates.symm.toContinuousLinearEquiv.hasFDerivAt + have he := congrArg (fun L => L (EuclideanSpace.single a 1)) h.fderiv + unfold oneElectronPullback + simpa only [Function.comp_def,ContinuousLinearMap.comp_apply,ContinuousLinearEquiv.coe_coe, + LinearIsometryEquiv.coe_toContinuousLinearEquiv,LinearIsometryEquiv.coe_coe, + oneElectronCoordinates_symm_single] using he + +theorem oneElectronPullback_integral (g : Configuration 1 → ℝ) : + (∫ y, g (oneElectronCoordinates.symm y)) = ∫ x, g x := by + rw [← oneElectronCoordinates_integral (fun y => g (oneElectronCoordinates.symm y))] + simp only [LinearIsometryEquiv.symm_apply_apply] + +theorem oneElectronPullback_integral_complex (g : Configuration 1 → ℂ) : + (∫ y, g (oneElectronCoordinates.symm y)) = ∫ x, g x := by + rw [← oneElectronCoordinates_integral_complex (fun y => g (oneElectronCoordinates.symm y))] + simp only [LinearIsometryEquiv.symm_apply_apply] + +theorem oneElectronPullback_form (V : Position → ℝ) {f : Configuration 1 → ℂ} + (hf : ContDiff ℝ 1 f) : + positionComplexForm V (oneElectronPullback f) = + (1/2:ℝ)*(∑ a : Fin 3, ∫ x, ‖fderiv ℝ f x (EuclideanSpace.single (0,a) 1)‖^2)+ + ∫ x, V (oneElectronCoordinates x)*‖f x‖^2 := by + unfold positionComplexForm positionComplexKinetic + simp_rw [oneElectronPullback_partial hf] + have hi (a : Fin 3) : (∫ y, ‖fderiv ℝ f (oneElectronCoordinates.symm y) + (EuclideanSpace.single (0,a) 1)‖^2) = + ∫ x, ‖fderiv ℝ f x (EuclideanSpace.single (0,a) 1)‖^2 := + oneElectronPullback_integral (fun x => ‖fderiv ℝ f x (EuclideanSpace.single (0,a) 1)‖^2) + simp_rw [hi] + congr 1 + have h := oneElectronPullback_integral + (fun x => V (oneElectronCoordinates x)*‖f x‖^2) + simpa only [oneElectronPullback,LinearIsometryEquiv.apply_symm_apply] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronFormDecomposition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronFormDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..d02468a3a98c00f4074803d266a4697cd257d50f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronFormDecomposition.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedCrossBound + +namespace OAI + +/-! Exact full-graph decomposition into the corrected orbital component and +its orthogonal remainder. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem correctedOneElectron_graph_decomposition {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) : + h1Coordinates v = h1Coordinates (correctedOneElectronProjection hfreq u v)+ + h1Coordinates (correctedOneElectronRemainder hfreq u v) := by + funext a + apply Lp.ext + filter_upwards [(h1Coordinate_memLp v a).coeFn_toLp, + (h1Coordinate_memLp (correctedOneElectronProjection hfreq u v) a).coeFn_toLp, + (h1Coordinate_memLp (correctedOneElectronRemainder hfreq u v) a).coeFn_toLp, + Lp.coeFn_add (h1Coordinates (correctedOneElectronProjection hfreq u v) a) + (h1Coordinates (correctedOneElectronRemainder hfreq u v) a)] with x hv hp hr ha + change h1Coordinates v a x = _ at hv + change h1Coordinates (correctedOneElectronProjection hfreq u v) a x = _ at hp + change h1Coordinates (correctedOneElectronRemainder hfreq u v) a x = _ at hr + change h1Coordinates v a x = (h1Coordinates (correctedOneElectronProjection hfreq u v) a+ + h1Coordinates (correctedOneElectronRemainder hfreq u v) a) x + rw [ha] + simp only [Pi.add_apply] + rw [hv,hp,hr] + cases a <;> simp only [h1CoordinateFunction,correctedOneElectronRemainder,Coulomb.H1Vector.add, + Coulomb.H1Vector.rsmul,Complex.ofReal_neg,Complex.ofReal_one] <;> ring + +theorem correctedOneElectron_form_decomposition {freq : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) (v : Coulomb.H1Vector 1) + (V : Configuration 1 → ℝ) (hV : Continuous V) (B : ℝ) (hB : ∀ x, |V x| ≤ B) : + boundedPotentialForm V v = + boundedPotentialForm V (correctedOneElectronProjection hfreq u v)+ + boundedPotentialForm V (correctedOneElectronRemainder hfreq u v)+ + 2*graphBoundedCross (BoundedPotential.operator V hV B hB) + (h1Coordinates (correctedOneElectronProjection hfreq u v)) + (h1Coordinates (correctedOneElectronRemainder hfreq u v)) := by + simp only [boundedPotentialForm_eq_graph V hV B hB] + rw [correctedOneElectron_graph_decomposition hfreq u v] + exact graphBoundedForm_add _ (boundedPotential_operator_symmetric V hV B hB) _ _ + +/-- Scalar absorption of a mixed form; the denominator is the retained +complement gap and no square root is introduced into the reduction. -/ +theorem absorb_cross_term {c B p q δ : ℝ} + (hB : 0 ≤ B) (hp : 0 ≤ p) (hq : 0 ≤ q) (hδ : 0 < δ) + (hc : c^2 ≤ B*p*q) : -(B/δ)*p-δ*q ≤ 2*c := by + let a := B/δ*p + let b := δ*q + have ha : 0 ≤ a := by dsimp [a]; positivity + have hb : 0 ≤ b := mul_nonneg hδ.le hq + have hab : a*b = B*p*q := by dsimp [a,b]; field_simp + have hc' : c^2 ≤ a*b := by rwa [hab] + have h : -a-b ≤ 2*c := by + by_contra hh + have hneg : 2*c < -a-b := lt_of_not_ge hh + have hprod := mul_pos (by linarith : 0 < -2*c-(a+b)) + (by linarith : 0 < -2*c+(a+b)) + nlinarith only [hc',sq_nonneg (a-b),hprod] + simpa only [a,b,neg_mul] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronProjectedLower.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronProjectedLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..65d0d039e926c5d0f9abff6e0b5fc2f54b6696bf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronProjectedLower.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronFormDecomposition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CorrectedRemainderGap + +namespace OAI + +/-! Absorption of the actual differential residual into the complementary +spectral gap on the full spinful weak-H1 domain. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem manufacturedOrbitalSquaredError_nonneg {rho H S freq δ D R : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + 0 ≤ manufacturedOrbitalSquaredError rho H S freq δ D R u j := + (integral_nonneg (fun _ => sq_nonneg _)).trans + (manufacturedOrbitalResidual_square_bound hrho hH hS hfreq hR hRH hRS + scale u hsep hδ hcoeff j) + +theorem manufacturedSlab_projected_lower + (hdensity : PublishedSobolevSmoothDensity) {rho H S freq δ D R γ : ℝ} + (hrho : 0 ≤ rho) (hH : 0 < H) (hS : 0 < S) (hfreq : 0 < freq) + (hrelation : freq^2 = 4*Real.pi*rho) (hR : 0 < R) (hRH : R ≤ H/2) (hRS : R ≤ S) + (hγ : 0 < γ) (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (hs : m*localizedOverlapBound D ≤ 1/2) + (hδ : 0 ≤ δ) (hcoeff : ∀ j, 0 ≤ localizedCounterterm freq u j/scale ∧ + localizedCounterterm freq u j/scale ≤ δ) + (v : Coulomb.H1Vector 1) + (hgap : ((-1/2:ℝ)+freq/2+γ/2)* + Coulomb.mass (correctedOneElectronRemainder hfreq u v) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) (correctedOneElectronRemainder hfreq u v)) : + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) (correctedOneElectronProjection hfreq u v)- + ((-1/2:ℝ)+freq/2)*Coulomb.mass (correctedOneElectronProjection hfreq u v)+ + (γ/4)*Coulomb.mass (correctedOneElectronRemainder hfreq u v)- + ((4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j))/(γ/4))* + Coulomb.mass (correctedOneElectronProjection hfreq u v) ≤ + boundedPotentialForm (fun x => manufacturedSlabPotential rho H S freq scale u + (oneElectronCoordinates x)) v-((-1/2:ℝ)+freq/2)*Coulomb.mass v := by + let V : Configuration 1 → ℝ := fun x => + manufacturedSlabPotential rho H S freq scale u (oneElectronCoordinates x) + have hV : Continuous V := + (manufacturedSlabPotential_continuous hrho hH.le hS.le freq scale u).comp + oneElectronCoordinates.continuous + obtain ⟨B,hB⟩ := manufacturedSlabPotential_bounded hrho hH.le hS freq scale u + have hB' : ∀ x, |V x| ≤ B := fun x => hB (oneElectronCoordinates x) + have hcross := corrected_cross_square_bound hdensity hrho hH hS hfreq hrelation hR + hRH hRS scale u hsep hs hδ hcoeff (correctedOneElectronCoefficients hfreq u v) + (correctedOneElectronRemainder hfreq u v) + (correctedOneElectronRemainder_orthogonal hfreq u hsep hs v) B hB' + have herr : 0 ≤ 4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j) := + mul_nonneg (mul_nonneg (by norm_num) (sq_nonneg _)) + (Finset.sum_nonneg (fun j _ => manufacturedOrbitalSquaredError_nonneg hrho hH hS + hfreq hR hRH hRS scale u hsep hδ hcoeff j)) + have ha := absorb_cross_term herr + (Coulomb.mass_nonneg (correctedOneElectronProjection hfreq u v)) + (Coulomb.mass_nonneg (correctedOneElectronRemainder hfreq u v)) + (show 0 < γ/4 by positivity) hcross + have hf := correctedOneElectron_form_decomposition hfreq u v V hV B hB' + have hm := correctedOneElectron_mass_decomposition hfreq u hsep hs v + change boundedPotentialForm V _-((-1/2:ℝ)+freq/2)*_+(γ/4)*_-_ ≤ + boundedPotentialForm V _-((-1/2:ℝ)+freq/2)*_ + change ((-1/2:ℝ)+freq/2+γ/2)*_ ≤ boundedPotentialForm V _ at hgap + change -(4*(m:ℝ)^2*(∑ j, manufacturedOrbitalSquaredError rho H S freq δ D R u j)/(γ/4))* + Coulomb.mass (correctedOneElectronProjection hfreq u v)- + (γ/4)*Coulomb.mass (correctedOneElectronRemainder hfreq u v) ≤ + 2*graphBoundedCross (BoundedPotential.operator V hV B hB') + (h1Coordinates (correctedOneElectronProjection hfreq u v)) + (h1Coordinates (correctedOneElectronRemainder hfreq u v)) at ha + rw [hm,hf] + nlinarith only [hgap,ha] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronTrial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronTrial.lean new file mode 100644 index 0000000000000000000000000000000000000000..39aeb3d3c4a51ff3af3a4204fcd58a3cac0a2bd6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OneElectronTrial.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Model +import OAI.Analysis.CoulombRadii.FormDomain.SmoothCompact + +namespace OAI + +/-! A concrete normalized weak-H¹ trial, independent of all nuclear data. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def oneElectronBump : ContDiffBump (0 : Configuration 1) := + ⟨1, 2, by norm_num, by norm_num⟩ + +def oneElectronBumpState : Coulomb.H1Vector 1 := + Coulomb.H1Vector.ofSmoothCompact + (fun _ x => (oneElectronBump x : ℂ)) + (fun _ => Complex.ofRealCLM.contDiff.comp oneElectronBump.contDiff) + (fun _ => oneElectronBump.hasCompactSupport.comp_left Complex.ofReal_zero) + +theorem oneElectronBumpState_mass_pos : 0 < Coulomb.mass oneElectronBumpState := by + have hzero : (fun t : ℝ => t ^ 2) 0 = 0 := zero_pow (by decide) + have hc : HasCompactSupport (fun x : Configuration 1 => oneElectronBump x ^ 2) := + oneElectronBump.hasCompactSupport.comp_left (g := fun t : ℝ => t ^ 2) hzero + have hI : Integrable (fun x : Configuration 1 => oneElectronBump x ^ 2) := + (oneElectronBump.continuous.pow 2).integrable_of_hasCompactSupport hc + have hb0 : oneElectronBump (0 : Configuration 1) = 1 := + oneElectronBump.one_of_mem_closedBall (by simp [oneElectronBump]) + have hpos : 0 < ∫ x : Configuration 1, oneElectronBump x ^ 2 := + integral_pos_of_integrable_nonneg_nonzero (oneElectronBump.continuous.pow 2) + hI (fun _ => sq_nonneg _) (by rw [hb0]; norm_num) + have hmass : Coulomb.mass oneElectronBumpState = + (Fintype.card (Coulomb.Spins 1) : ℝ) * ∫ x : Configuration 1, oneElectronBump x ^ 2 := by + simp only [Coulomb.mass, oneElectronBumpState, Coulomb.H1Vector.ofSmoothCompact, + Complex.norm_real, Real.norm_eq_abs, sq_abs, Finset.sum_const, Finset.card_univ, + nsmul_eq_mul] + rw [hmass] + exact mul_pos (by norm_num [Coulomb.Spins]) hpos + +def oneElectronTrial : Coulomb.H1Vector 1 := + oneElectronBumpState.rsmul (Real.sqrt (Coulomb.mass oneElectronBumpState))⁻¹ + +theorem oneElectronTrial_mass : Coulomb.mass oneElectronTrial = 1 := by + rw [oneElectronTrial, Coulomb.mass_rsmul, inv_pow, + Real.sq_sqrt oneElectronBumpState_mass_pos.le, + inv_mul_cancel₀ oneElectronBumpState_mass_pos.ne'] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalBasisExtension.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalBasisExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..b20e18dcb6d28d749d87dcd71012aff8274cfc7a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalBasisExtension.lean @@ -0,0 +1,30 @@ +import OAI.Analysis.CoulombRadii.FormDomain.HilbertBasisContaining + +namespace OAI + +/-! Extending the finitely many chosen orbitals supplies Parseval for +arbitrary continuum states, including their orthogonal remainder. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem finite_orbitals_basis_extension {A : Type*} [MeasurableSpace A] + {μ : Measure A} [SecondCountableTopology (Lp ℂ 2 μ)] {m : ℕ} + (v : Fin m → Lp ℂ 2 μ) (hv : Orthonormal ℂ v) : + ∃ (S : Set (Lp ℂ 2 μ)) (b : HilbertBasis S ℂ (Lp ℂ 2 μ)) (e : Fin m ↪ S), + Countable S ∧ ∀ i, b (e i) = v i := by + obtain ⟨S,b,hS,hb⟩ := hv.toSubtypeRange.exists_hilbertBasis_extension + let e : Fin m ↪ S := + ⟨fun i => ⟨v i,hS (Set.mem_range_self i)⟩, + fun i j hij => hv.linearIndependent.injective (congrArg Subtype.val hij)⟩ + refine ⟨S,b,e,?_,?_⟩ + · exact Coulomb.orthonormal_subtype_countable (by simpa only [hb] using b.orthonormal) + · intro i + exact congrFun hb (e i) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCellVolume.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCellVolume.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc309646c9ad4c5f629234fb84ebcaba8e68606c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCellVolume.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ExceptionalCellVolume +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDensityMoment + +namespace OAI + +/-! Mesh cells near one localized orbital occupy a volume bounded by its +cutoff radius, independently of the surrounding slab's horizontal area. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem orbital_near_cell_volume {ι : Type*} [Fintype ι] + (index : ι → Fin 3 → ℤ) (hindex : Function.Injective index) + {h R : ℝ} (hh : 0 < h) (hR : 0 ≤ R) (u : PlanarPosition) + (hnear : ∀ i, ‖gaussCellCenter h (index i)-planarCenter u‖ ≤ R) : + (Fintype.card ι:ℝ)*h^3 ≤ 8*(R+2*h)^3 := by + let A : ι → Set Position := fun i => positionOpenCube (gaussCellCenter h (index i)) h + have hb (i : ι) : gaussCellCenter h (index i) ∈ wellCoverBox u R R := by + apply mem_wellCoverBox.mpr + have hc (j : Fin 3) := (PiLp.norm_apply_le + (gaussCellCenter h (index i)-planarCenter u) j).trans (hnear i) + have h0 : planarCenter u 0 = u 0 := by + simpa only [planarCenter,ContinuousLinearEquiv.apply_symm_apply] using + (positionSplitCoordinates_fst_zero (planarCenter u)).symm + have h1 : planarCenter u 1 = u 1 := by + simpa only [planarCenter,ContinuousLinearEquiv.apply_symm_apply] using + (positionSplitCoordinates_fst_one (planarCenter u)).symm + have h2 : planarCenter u 2 = 0 := by + simpa only [planarCenter,ContinuousLinearEquiv.apply_symm_apply] using + (positionSplitCoordinates_snd (planarCenter u)).symm + exact ⟨by simpa only [PiLp.sub_apply,h0,Real.norm_eq_abs] using hc 0, + by simpa only [PiLp.sub_apply,h1,Real.norm_eq_abs] using hc 1, + by simpa only [PiLp.sub_apply,h2,sub_zero,Real.norm_eq_abs] using hc 2⟩ + have hsub : (⋃ i, A i) ⊆ wellCoverBox u (R+2*h) (R+2*h) := by + intro x hx + obtain ⟨i,hi⟩ := Set.mem_iUnion.mp hx + exact cube_meets_wellCover_subset hh.le + (mem_positionCube.mpr (fun _ => by simp; positivity)) (hb i) + (positionOpenCube_subset _ _ hi) + have hA : volume.real (⋃ i, A i) = (Fintype.card ι:ℝ)*h^3 := by + rw [measureReal_iUnion_fintype + (fun i j hij => grid_openCubes_disjoint hh (fun he => hij (hindex he))) + (fun i => positionOpenCube_measurable _ _) + (fun i => by + rw [measure_congr (positionOpenCube_ae_eq (gaussCellCenter h (index i)) h)] + exact (positionCube_isCompact _ hh.le).measure_ne_top)] + simp only [positionOpenCube_volume _ hh.le,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + calc + _ = volume.real (⋃ i, A i) := hA.symm + _ ≤ volume.real (wellCoverBox u (R+2*h) (R+2*h)) := + measureReal_mono hsub (wellCoverBox_measure_ne_top _ _ _) + _ = 8*(R+2*h)^3 := by + rw [wellCoverBox_volume u (by positivity) (by positivity)] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalComplementCount.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalComplementCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..2140e07ae4e65f6c824312979cc60ec5cc936187 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalComplementCount.lean @@ -0,0 +1,66 @@ +import OAI.Analysis.CoulombRadii.FieldAnalysis.FermionicCoefficients + +namespace OAI + +/-! A coefficient array orthogonal to all tensors of the chosen orbitals +has at least one particle outside them. This counts particles, not basis +configurations, and so introduces no exponential dimension factor. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem complement_coefficient_pointwise {α : Type*} {n : ℕ} + (S : Set α) (c : (Fin (n+1) → α) → ℂ) + (hzero : ∀ b, (∀ i, b i ∈ S) → c b = 0) (b : Fin (n+1) → α) : + (∑ i, if b i ∈ S then ‖c b‖^2 else (0:ℝ)) ≤ (n:ℝ)*‖c b‖^2 := by + by_cases hz : c b = 0 + · simp [hz] + obtain ⟨j,hj⟩ : ∃ j, b j ∉ S := by + by_contra! hh + exact hz (hzero b hh) + rw [← Finset.sum_erase_add _ _ (Finset.mem_univ j),ite_eq_right hj,add_zero] + calc + _ ≤ ∑ _i ∈ Finset.univ.erase j, ‖c b‖^2 := + Finset.sum_le_sum (fun i _ => by split_ifs <;> first | exact le_rfl | exact sq_nonneg _) + _ = _ := by simp + +theorem complement_coefficient_occupation_sum {α : Type*} {n : ℕ} + (S : Set α) (c : (Fin (n+1) → α) → ℂ) + (hzero : ∀ b, (∀ i, b i ∈ S) → c b = 0) + (hs : Summable (fun b => ‖c b‖^2)) : + (∑ i, ∑' b, if b i ∈ S then ‖c b‖^2 else (0:ℝ)) ≤ + (n:ℝ)*(∑' b, ‖c b‖^2) := by + have hi (i : Fin (n+1)) : Summable (fun b => if b i ∈ S then ‖c b‖^2 else (0:ℝ)) := + Summable.of_nonneg_of_le (fun b => by positivity) + (fun b => by split_ifs <;> first | exact le_rfl | exact sq_nonneg _) hs + rw [← Summable.tsum_finsetSum (fun i _ => hi i),← tsum_mul_left] + exact Summable.tsum_le_tsum (complement_coefficient_pointwise S c hzero) + (summable_sum (fun i _ => hi i)) (hs.mul_left (n:ℝ)) + +theorem coefficient_set_occupation_eq {α : Type*} {n : ℕ} + {c : (Fin n → α) → ℂ} (hc : Coulomb.FermionicCoefficients c) + (S : Set α) (i j : Fin n) : + (∑' b, if b i ∈ S then ‖c b‖^2 else (0:ℝ)) = + ∑' b, if b j ∈ S then ‖c b‖^2 else (0:ℝ) := by + let p := Equiv.swap i j + have he := (Coulomb.coefficientPermEquiv (α := α) p).tsum_eq + (fun b => if b i ∈ S then ‖c b‖^2 else (0:ℝ)) + change (∑' b, if (b ∘ p) i ∈ S then ‖c (b ∘ p)‖^2 else (0:ℝ)) = _ at he + simpa only [Function.comp_apply,p,Equiv.swap_apply_left,hc.norm_permute] using he.symm + +theorem complement_coefficient_single_occupation {α : Type*} {n : ℕ} + (S : Set α) (c : (Fin (n+1) → α) → ℂ) (hc : Coulomb.FermionicCoefficients c) + (hzero : ∀ b, (∀ i, b i ∈ S) → c b = 0) + (hs : Summable (fun b => ‖c b‖^2)) (i : Fin (n+1)) : + (n+1:ℕ)*(∑' b, if b i ∈ S then ‖c b‖^2 else (0:ℝ)) ≤ + (n:ℝ)*(∑' b, ‖c b‖^2) := by + have h := complement_coefficient_occupation_sum S c hzero hs + simp_rw [coefficient_set_occupation_eq hc S _ i] at h + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoff.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..190551be54241e9efee04bd9fae2f33774ecf5e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoff.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalJetBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedDensityMoment + +namespace OAI + +/-! Expanding smooth cutoffs for the actual orbitals. Their first four +jets are bounded independently of the radius and center. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +def orbitalCutoffBump : ContDiffBump (0 : Position) := ⟨1,2,by norm_num,by norm_num⟩ + +def orbitalCutoff (R : ℝ) (u : PlanarPosition) (x : Position) : ℝ := + orbitalCutoffBump (R⁻¹ • (x-planarCenter u)) + +theorem orbitalCutoff_smooth (R : ℝ) (u : PlanarPosition) : + ContDiff ℝ ∞ (orbitalCutoff R u) := + orbitalCutoffBump.contDiff.comp ((contDiff_id.sub contDiff_const).const_smul _) + +theorem orbitalCutoff_nonnegative (R : ℝ) (u : PlanarPosition) (x : Position) : + 0 ≤ orbitalCutoff R u x := orbitalCutoffBump.nonneg + +theorem orbitalCutoff_le_one (R : ℝ) (u : PlanarPosition) (x : Position) : + orbitalCutoff R u x ≤ 1 := orbitalCutoffBump.le_one + +theorem orbitalCutoff_eq_one {R : ℝ} (hR : 0 < R) (u : PlanarPosition) + {x : Position} (hx : ‖x-planarCenter u‖ ≤ R) : orbitalCutoff R u x = 1 := by + apply orbitalCutoffBump.one_of_mem_closedBall + change dist (R⁻¹ • (x-planarCenter u)) 0 ≤ 1 + rw [dist_zero_right,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hR)] + rw [← div_eq_inv_mul] + exact (div_le_one hR).mpr hx + +theorem orbitalCutoff_support {R : ℝ} (hR : 0 < R) (u : PlanarPosition) : + tsupport (orbitalCutoff R u) ⊆ Metric.closedBall (planarCenter u) (2*R) := by + apply closure_minimal _ Metric.isClosed_closedBall + intro x hx + by_contra hn + apply hx + apply orbitalCutoffBump.zero_of_le_dist + change 2 ≤ dist (R⁻¹ • (x-planarCenter u)) 0 + rw [dist_zero_right,norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hR)] + rw [← div_eq_inv_mul] + have hh : 2*R < ‖x-planarCenter u‖ := by + simpa only [Metric.mem_closedBall,dist_eq_norm,not_le] using hn + exact (le_div_iff₀ hR).mpr hh.le + +theorem orbitalCutoff_hasCompactSupport {R : ℝ} (hR : 0 < R) (u : PlanarPosition) : + HasCompactSupport (orbitalCutoff R u) := + (isCompact_closedBall (planarCenter u) (2*R)).of_isClosed_subset (isClosed_tsupport _) + (orbitalCutoff_support hR u) + +theorem orbitalCutoff_jets_bounded : + ∃ B : ℝ, 1 ≤ B ∧ ∀ R, 1 ≤ R → ∀ u k, k ≤ 4 → ∀ x, + ‖iteratedFDeriv ℝ k (orbitalCutoff R u) x‖ ≤ B := by + obtain ⟨B,hB,hb⟩ := orbitalCutoffBump.hasCompactSupport.exists_bound_iteratedFDeriv + (𝕜 := ℝ) orbitalCutoffBump.contDiff 4 + refine ⟨B+1,by linarith,?_⟩ + intro R hR u k hk x + have hR0 : 0 < R := lt_of_lt_of_le zero_lt_one hR + let L : Position →L[ℝ] Position := R⁻¹ • ContinuousLinearMap.id ℝ Position + have hL : ‖L‖ ≤ 1 := by + dsimp [L] + rw [norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hR0),ContinuousLinearMap.norm_id] + simpa only [mul_one] using inv_le_one_of_one_le₀ hR + change ‖iteratedFDeriv ℝ k (fun y => (orbitalCutoffBump ∘ L) (y-planarCenter u)) x‖ ≤ B+1 + rw [iteratedFDeriv_comp_sub] + have h := fourJet_linear_comp L orbitalCutoffBump (orbitalCutoffBump.contDiff : ContDiff ℝ 4 (orbitalCutoffBump : Position → ℝ)) + hB (show (1:ℝ) ≤ 1 from le_rfl) hL hb hk (x-planarCenter u) + simpa only [one_pow,mul_one] using h.trans (show B*1^4 ≤ B+1 by nlinarith) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoffTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoffTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..4dd5fee9f0930164dd759725c54d3781a34f85ec --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalCutoffTail.lean @@ -0,0 +1,188 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCutoff +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedGradientMoments + +namespace OAI + +/-! Quantitative Sobolev tails of the localized orbitals. The 24th +moments give a twelfth-power decay in the H1 norm of the removed tail. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem orbitalCutoff_fderiv_zero {R : ℝ} (hR : 0 < R) (u : PlanarPosition) + {x : Position} (hx : ‖x-planarCenter u‖ < R) : fderiv ℝ (orbitalCutoff R u) x = 0 := by + have he : orbitalCutoff R u =ᶠ[𝓝 x] (fun _ => (1:ℝ)) := by + filter_upwards [Metric.isOpen_ball.mem_nhds (show x ∈ Metric.ball (planarCenter u) R from hx)] with y hy + exact orbitalCutoff_eq_one hR u hy.le + rw [he.fderiv_eq] + exact fderiv_const_apply 1 + +theorem localized_weighted_coefficient_tail {R A : ℝ} (hR : 0 < R) (_hA : 0 ≤ A) + (c : Position) {a f : Position → ℝ} (ha : Continuous a) (hf : Continuous f) + (hbound : ∀ x, |a x| ≤ A) (hzero : ∀ x, ‖x-c‖ < R → a x = 0) + (hm : Integrable (fun x => ‖x-c‖^24*f x^2)) : + Integrable (fun x => (a x*f x)^2) ∧ + (∫ x, (a x*f x)^2) ≤ A^2/R^24*(∫ x, ‖x-c‖^24*f x^2) := by + have hp (x : Position) : (a x*f x)^2 ≤ A^2/R^24*(‖x-c‖^24*f x^2) := by + by_cases hx : ‖x-c‖ < R + · rw [hzero x hx,zero_mul,pow_two,zero_mul] + positivity + have hd : R ≤ ‖x-c‖ := le_of_not_gt hx + have hs : (a x)^2 ≤ A^2 := by + have h := pow_le_pow_left₀ (abs_nonneg (a x)) (hbound x) 2 + simpa only [sq_abs] using h + have hr : 1 ≤ ‖x-c‖^24/R^24 := + (le_div_iff₀ (pow_pos hR 24)).mpr (by simpa only [one_mul] using pow_le_pow_left₀ hR.le hd 24) + calc + _ ≤ A^2*f x^2 := by rw [mul_pow]; exact mul_le_mul_of_nonneg_right hs (sq_nonneg _) + _ ≤ (A^2*f x^2)*(‖x-c‖^24/R^24) := le_mul_of_one_le_right (by positivity) hr + _ = _ := by ring + have hi : Integrable (fun x => (a x*f x)^2) := by + apply (hm.const_mul (A^2/R^24)).mono' ((ha.mul hf).pow 2).aestronglyMeasurable + filter_upwards [] with x + change ‖(a x*f x)^2‖ ≤ _ + rw [Real.norm_of_nonneg (sq_nonneg _)] + exact hp x + refine ⟨hi,?_⟩ + have h := integral_mono hi (hm.const_mul (A^2/R^24)) hp + simpa only [integral_const_mul] using h + +theorem continuumLocalizedMode_centered_twentyFourth_moment_integrable {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + Integrable (fun x : Position => ‖x-planarCenter u‖^24*continuumLocalizedMode freq u x^2) := by + have hi := (localizedDensity_twentyFourth_moment_integrable hfreq).comp_sub_right (planarCenter u) + simpa only [localizedDensity,continuumLocalizedMode_translate freq u] using hi + +private theorem centered_deriv_moment {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) (e : Position) : + Integrable (fun x : Position => ‖x-planarCenter u‖^24*(fderiv ℝ (continuumLocalizedMode freq u) x e)^2) := by + have hi := (continuumLocalizedMode_deriv_twentyFourth_moment_integrable hfreq e).comp_sub_right (planarCenter u) + simpa only [continuumLocalizedMode_deriv_translate freq u] using hi + +theorem orbitalCutoff_value_tail {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) (u : PlanarPosition) : + Integrable (fun x => ((1-orbitalCutoff R u x)*continuumLocalizedMode freq u x)^2) ∧ + (∫ x, ((1-orbitalCutoff R u x)*continuumLocalizedMode freq u x)^2) ≤ + (∫ x, ‖x‖^24*continuumLocalizedMode freq 0 x^2)/R^24 := by + have h := localized_weighted_coefficient_tail (a := fun x => 1-orbitalCutoff R u x) hR (show (0:ℝ) ≤ 1 by norm_num) (planarCenter u) + (continuous_const.sub (orbitalCutoff_smooth R u).continuous) (continuumLocalizedMode_C7 freq u).continuous + (fun x => by rw [abs_of_nonneg (sub_nonneg.mpr (orbitalCutoff_le_one R u x))]; linarith [orbitalCutoff_nonnegative R u x]) + (fun x hx => by rw [orbitalCutoff_eq_one hR u hx.le,sub_self]) (continuumLocalizedMode_centered_twentyFourth_moment_integrable hfreq u) + refine ⟨h.1,?_⟩ + apply h.2.trans_eq + simp_rw [continuumLocalizedMode_translate freq u] + rw [integral_sub_right_eq_self (μ := volume) (fun x : Position => ‖x‖^24*continuumLocalizedMode freq 0 x^2) (planarCenter u)] + ring + +theorem orbitalCutoff_deriv_tail {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ R, 1 ≤ R → ∀ (u : PlanarPosition) (e : Position), + Integrable (fun x => (fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x)^2) ∧ + (∫ x, (fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x)^2) ≤ + (B*‖e‖)^2/R^24*(∫ x, ‖x‖^24*continuumLocalizedMode freq 0 x^2) := by + obtain ⟨B,hB,hb⟩ := orbitalCutoff_jets_bounded + refine ⟨B,hB,?_⟩ + intro R hR u e + have hR0 : 0 < R := by linarith + have hbound (x : Position) : |fderiv ℝ (orbitalCutoff R u) x e| ≤ B*‖e‖ := by + have hd := hb R hR u 1 (by norm_num) x + rw [norm_iteratedFDeriv_one] at hd + exact ((fderiv ℝ (orbitalCutoff R u) x).le_opNorm e).trans + (mul_le_mul_of_nonneg_right hd (norm_nonneg e)) + have h := localized_weighted_coefficient_tail hR0 (show 0 ≤ B*‖e‖ by positivity) (planarCenter u) + (((orbitalCutoff_smooth R u).continuous_fderiv (by simp)).clm_apply continuous_const) + (continuumLocalizedMode_C7 freq u).continuous hbound + (fun x hx => by rw [orbitalCutoff_fderiv_zero hR0 u hx]; rfl) (continuumLocalizedMode_centered_twentyFourth_moment_integrable hfreq u) + refine ⟨h.1,?_⟩ + apply h.2.trans_eq + simp_rw [continuumLocalizedMode_translate freq u] + rw [integral_sub_right_eq_self (μ := volume) (fun x : Position => ‖x‖^24*continuumLocalizedMode freq 0 x^2) (planarCenter u)] + +theorem orbitalCutoff_deriv_remainder_tail {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) + (u : PlanarPosition) (e : Position) : + Integrable (fun x => ((1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e)^2) ∧ + (∫ x, ((1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e)^2) ≤ + (∫ x, ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2)/R^24 := by + have h := localized_weighted_coefficient_tail (a := fun x => 1-orbitalCutoff R u x) hR (show (0:ℝ) ≤ 1 by norm_num) (planarCenter u) + (continuous_const.sub (orbitalCutoff_smooth R u).continuous) + (((continuumLocalizedMode_C7 freq u).continuous_fderiv (by norm_num)).clm_apply continuous_const) + (fun x => by rw [abs_of_nonneg (sub_nonneg.mpr (orbitalCutoff_le_one R u x))]; linarith [orbitalCutoff_nonnegative R u x]) + (fun x hx => by rw [orbitalCutoff_eq_one hR u hx.le,sub_self]) (centered_deriv_moment hfreq u e) + refine ⟨h.1,?_⟩ + apply h.2.trans_eq + simp_rw [continuumLocalizedMode_deriv_translate freq u] + rw [integral_sub_right_eq_self (μ := volume) (fun x : Position => ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2) (planarCenter u)] + ring + +def orbitalRemainder (freq R : ℝ) (u : PlanarPosition) (x : Position) : ℝ := + (1-orbitalCutoff R u x)*continuumLocalizedMode freq u x + +theorem orbitalRemainder_C1 (freq R : ℝ) (u : PlanarPosition) : + ContDiff ℝ 1 (orbitalRemainder freq R u) := + (contDiff_const.sub ((orbitalCutoff_smooth R u).of_le (by simp))).mul + ((continuumLocalizedMode_C7 freq u).of_le (by norm_num)) + +theorem orbitalRemainder_deriv (freq R : ℝ) (u : PlanarPosition) (x e : Position) : + fderiv ℝ (orbitalRemainder freq R u) x e = + -(fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x)+ + (1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e := by + have hc := ((orbitalCutoff_smooth R u).differentiable (by simp) x).hasFDerivAt + have hu := ((continuumLocalizedMode_C7 freq u).differentiable (by norm_num) x).hasFDerivAt + have h := congrArg (fun L : Position →L[ℝ] ℝ => L e) + (((hasFDerivAt_const (1:ℝ) x).sub hc).mul hu).fderiv + change fderiv ℝ (orbitalRemainder freq R u) x e = _ at h + convert h using 1 + simp only [add_apply,smul_apply,sub_apply,zero_apply,smul_eq_mul,Pi.sub_apply] + ring + +theorem orbitalRemainder_deriv_tail {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ R, 1 ≤ R → ∀ (u : PlanarPosition) (e : Position), + Integrable (fun x => (fderiv ℝ (orbitalRemainder freq R u) x e)^2) ∧ + (∫ x, (fderiv ℝ (orbitalRemainder freq R u) x e)^2) ≤ + 2*((B*‖e‖)^2*(∫ x, ‖x‖^24*continuumLocalizedMode freq 0 x^2)+ + (∫ x, ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2))/R^24 := by + obtain ⟨B,hB,hb⟩ := orbitalCutoff_deriv_tail hfreq + refine ⟨B,hB,?_⟩ + intro R hR u e + obtain ⟨hi1,h1⟩ := hb R hR u e + obtain ⟨hi2,h2⟩ := orbitalCutoff_deriv_remainder_tail (R := R) hfreq (by linarith) u e + have hpoint (x : Position) : (fderiv ℝ (orbitalRemainder freq R u) x e)^2 ≤ + 2*((fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x)^2+ + ((1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e)^2) := by + rw [orbitalRemainder_deriv] + nlinarith [sq_nonneg (fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x+ + (1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e)] + have hi : Integrable (fun x => (fderiv ℝ (orbitalRemainder freq R u) x e)^2) := by + apply ((hi1.add hi2).const_mul 2).mono' (by + exact (((orbitalRemainder_C1 freq R u).continuous_fderiv (by norm_num)).clm_apply continuous_const).pow 2 |>.aestronglyMeasurable) + filter_upwards [] with x + rw [Real.norm_of_nonneg (sq_nonneg _)] + exact hpoint x + refine ⟨hi,?_⟩ + have h := integral_mono hi ((hi1.add hi2).const_mul 2) hpoint + rw [integral_const_mul] at h + simp only [Pi.add_apply] at h + rw [integral_add hi1 hi2] at h + calc + _ ≤ 2*((∫ x, (fderiv ℝ (orbitalCutoff R u) x e*continuumLocalizedMode freq u x)^2)+ + (∫ x, ((1-orbitalCutoff R u x)*fderiv ℝ (continuumLocalizedMode freq u) x e)^2)) := h + _ ≤ 2*((B*‖e‖)^2/R^24*(∫ x, ‖x‖^24*continuumLocalizedMode freq 0 x^2)+ + (∫ x, ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x e)^2)/R^24) := by linarith + _ = _ := by ring + +theorem orbitalRemainder_memLp {freq R : ℝ} (hfreq : 0 < freq) (hR : 0 < R) (u : PlanarPosition) : + MemLp (orbitalRemainder freq R u) 2 := by + apply (memLp_two_iff_integrable_sq (orbitalRemainder_C1 freq R u).continuous.aestronglyMeasurable).mpr + exact (orbitalCutoff_value_tail hfreq hR u).1 + +theorem orbitalRemainder_deriv_memLp {freq R : ℝ} (hfreq : 0 < freq) (hR : 1 ≤ R) + (u : PlanarPosition) (e : Position) : + MemLp (fun x => fderiv ℝ (orbitalRemainder freq R u) x e) 2 := by + apply (memLp_two_iff_integrable_sq + (((orbitalRemainder_C1 freq R u).continuous_fderiv (by norm_num)).clm_apply continuous_const).aestronglyMeasurable).mpr + obtain ⟨B,_,hb⟩ := orbitalRemainder_deriv_tail hfreq + exact (hb R hR u e).1 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalDerivative.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..f20f7a1b81f50e75adee0844e2fe23c7dd5292e4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalDerivative.lean @@ -0,0 +1,169 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalTensor + +namespace OAI + +/-! Actual L2 derivative-slot tensors and their exact kinetic matrix +compression to CAR one-body operators. Derivative families are concrete +functions with L2 hypotheses, so spatial partial derivatives can be used +directly without assuming a kinetic-energy matrix identity. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb.OrbitalDerivative +open Laughlin FockSlaterTensor SlaterOccupation + +private lemma basisTensor_substitution {Q n : ℕ} (S : Occupied Q n) + (f : Laughlin.Configuration n Q → ℂ) : + (∑ a, basisTensor S a * f a) = + (Real.sqrt (n.factorial : ℝ) : ℂ)⁻¹ * + ∑ p : Equiv.Perm (Fin n), (((p.sign : ℤ) : ℂ)) * f (fun i => selection S (p i)) := by + classical + simp_rw [basisTensor_expansion, mul_assoc, Finset.sum_mul] + rw [← Finset.mul_sum] + congr 1 + rw [Finset.sum_comm] + simp only [mul_ite, mul_one, mul_zero, ite_mul, zero_mul] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] + +def derivativeTensorValue {A : Type*} {Q n : ℕ} (v d : Fin (Q + 1) → A → ℂ) + (ψ : State n Q) (slot : Fin n) (x : Fin n → A) : ℂ := + ∑ a : Laughlin.Configuration n Q, ψ a * + Coulomb.slotTensor (fun j => v (a j)) (fun j => d (a j)) 1 slot x + +def normalizedSlotWave {A : Type*} {Q n : ℕ} (v d : Fin (Q + 1) → A → ℂ) + (S : Occupied Q n) (slot : Fin n) (x : Fin n → A) : ℂ := + (Real.sqrt (n.factorial : ℝ) : ℂ)⁻¹ * + Coulomb.slotDeterminant (selectedOrbitals v S) (selectedOrbitals d S) slot x + +lemma derivativeTensorValue_basisTensor {A : Type*} {Q n : ℕ} + (v d : Fin (Q + 1) → A → ℂ) (S : Occupied Q n) (slot : Fin n) (x : Fin n → A) : + derivativeTensorValue v d (basisTensor S) slot x = normalizedSlotWave v d S slot x := by + unfold derivativeTensorValue + rw [basisTensor_substitution] + rfl + +lemma derivativeTensorValue_occupationTensor {A : Type*} {Q n : ℕ} + (v d : Fin (Q + 1) → A → ℂ) (c : EuclideanSpace ℂ (Occupied Q n)) + (slot : Fin n) (x : Fin n → A) : + derivativeTensorValue v d (occupationTensor c) slot x = + ∑ S, c S * normalizedSlotWave v d S slot x := by + unfold derivativeTensorValue occupationTensor + simp_rw [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S _ + rw [← derivativeTensorValue_basisTensor v d S slot x] + unfold derivativeTensorValue + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + +variable {A : Type*} [MeasurableSpace A] {μ : Measure A} [SigmaFinite μ] {Q n : ℕ} + +lemma derivativeTensorValue_memLp (v d : Fin (Q + 1) → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hd : ∀ i, MemLp (d i) 2 μ) + (ψ : State n Q) (slot : Fin n) : + MemLp (derivativeTensorValue v d ψ slot) 2 (Measure.pi fun _ => μ) := by + exact memLp_finsetSum Finset.univ (fun a _ => + (Coulomb.slotTensor_memLp (fun j => v (a j)) (fun j => d (a j)) + (fun j => hv (a j)) (fun j => hd (a j)) 1 slot).const_mul (ψ a)) + +omit [MeasurableSpace A] in +lemma derivative_bilinear_expansion (v d e : Fin (Q + 1) → A → ℂ) + (ψ φ : State n Q) (slot : Fin n) (x : Fin n → A) : + star (derivativeTensorValue v d ψ slot x) * derivativeTensorValue v e φ slot x = + ∑ a : Laughlin.Configuration n Q, ∑ b : Laughlin.Configuration n Q, + (star (ψ a) * φ b) * + (star (Coulomb.slotTensor (fun j => v (a j)) (fun j => d (a j)) 1 slot x) * + Coulomb.slotTensor (fun j => v (b j)) (fun j => e (b j)) 1 slot x) := by + simp only [derivativeTensorValue, star_sum, star_mul, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + ring + +lemma head_derivative_integral (v d e : Fin (Q + 1) → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hd : ∀ i, MemLp (d i) 2 μ) (he : ∀ i, MemLp (e i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (ψ φ : State (n + 1) Q) : + (∫ x : Fin (n + 1) → A, star (derivativeTensorValue v d ψ 0 x) * + derivativeTensorValue v e φ 0 x ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, star (d i x) * e j x ∂μ) * + ∑ a : Laughlin.Configuration n Q, star (ψ (Fin.cons i a)) * φ (Fin.cons j a) := by + have ht (a b : Laughlin.Configuration (n + 1) Q) : Integrable + (fun x : Fin (n + 1) → A => (star (ψ a) * φ b) * + (star (Coulomb.slotTensor (fun j => v (a j)) (fun j => d (a j)) 1 0 x) * + Coulomb.slotTensor (fun j => v (b j)) (fun j => e (b j)) 1 0 x)) + (Measure.pi fun _ => μ) := + ((Coulomb.slotTensor_memLp (fun j => v (a j)) (fun j => d (a j)) + (fun j => hv (a j)) (fun j => hd (a j)) 1 0).star.integrable_mul + (Coulomb.slotTensor_memLp (fun j => v (b j)) (fun j => e (b j)) + (fun j => hv (b j)) (fun j => he (b j)) 1 0)).const_mul _ + simp_rw [derivative_bilinear_expansion] + rw [integral_finsetSum _ (fun a _ => integrable_finsetSum _ (fun b _ => ht a b))] + simp_rw [integral_finsetSum _ (fun b _ => ht _ b), integral_const_mul] + have hI (a b : Laughlin.Configuration (n + 1) Q) : + (∫ x : Fin (n + 1) → A, + star (Coulomb.slotTensor (fun j => v (a j)) (fun j => d (a j)) 1 0 x) * + Coulomb.slotTensor (fun j => v (b j)) (fun j => e (b j)) 1 0 x + ∂(Measure.pi fun _ => μ)) = + (∫ x, star (d (a 0) x) * e (b 0) x ∂μ) * + ∏ j ∈ Finset.univ.erase 0, ∫ x, star (v (a j) x) * v (b j) x ∂μ := by + exact MixedSlater.slotTensor_integral (fun j => v (a j)) (fun j => d (a j)) + (fun j => v (b j)) (fun j => e (b j)) 1 1 0 + simp_rw [hI] + simp only [ho, OrbitalTensor.prod_erase_zero] + rw [OrbitalTensor.head_pair_sum] + simp only [Fin.cons_zero, Fin.cons_succ, OrbitalTensor.delta_product] + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + +lemma derivative_CAR_compression (v d e : Fin (Q + 1) → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hd : ∀ i, MemLp (d i) 2 μ) (he : ∀ i, MemLp (e i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (ψ φ : State (n + 1) Q) (hψ : Laughlin.Antisymmetric ψ) (hφ : Laughlin.Antisymmetric φ) : + (n + 1 : ℂ) * (∫ x : Fin (n + 1) → A, star (derivativeTensorValue v d ψ 0 x) * + derivativeTensorValue v e φ 0 x ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, star (d i x) * e j x ∂μ) * + Laughlin.Fock.occupationInner Q (Laughlin.Fock.normalizedTensorExterior (n + 1) Q ψ) + (Laughlin.Fock.create i (Laughlin.Fock.annihilate j + (Laughlin.Fock.normalizedTensorExterior (n + 1) Q φ))) := by + rw [head_derivative_integral v d e hv hd he ho ψ φ] + simp only [FockTensorCompression.oneBody_inner n Q ψ φ hψ hφ, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring_nf + +lemma slater_derivative_CAR_compression (v d e : Fin (Q + 1) → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) (hd : ∀ i, MemLp (d i) 2 μ) (he : ∀ i, MemLp (e i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (c b : EuclideanSpace ℂ (Occupied Q (n + 1))) : + (n + 1 : ℂ) * (∫ x : Fin (n + 1) → A, + star (∑ S, c S * normalizedSlotWave v d S 0 x) * + (∑ T, b T * normalizedSlotWave v e T 0 x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, star (d i x) * e j x ∂μ) * + Laughlin.Fock.occupationInner Q (∑ S, c S • Laughlin.Fock.occupationBasis Q S.val) + (Laughlin.Fock.create i (Laughlin.Fock.annihilate j + (∑ T, b T • Laughlin.Fock.occupationBasis Q T.val))) := by + have h := derivative_CAR_compression v d e hv hd he ho (occupationTensor c) (occupationTensor b) + (occupationTensor_antisymmetric c) (occupationTensor_antisymmetric b) + simpa only [derivativeTensorValue_occupationTensor, normalizedTensorExterior_occupationTensor] using h + +end ContinuumCoulomb.OrbitalDerivative + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalGraphBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalGraphBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..a24d18971a760384bcb1f3879ae7270883d970d8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalGraphBounds.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalCutoffTail + +namespace OAI + +/-! Uniform H1 graph bounds for actual orbitals and their removed tails. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def positionGraphSquare (f : Position → ℝ) : ℝ := + (∫ x, f x^2)+∑ k : Fin 3, ∫ x, (fderiv ℝ f x (EuclideanSpace.single k 1))^2 + +theorem positionGraphSquare_nonnegative (f : Position → ℝ) : 0 ≤ positionGraphSquare f := + add_nonneg (integral_nonneg (fun _ => sq_nonneg _)) + (Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _))) + +theorem continuumLocalizedMode_graph_uniform (freq : ℝ) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ u, positionGraphSquare (continuumLocalizedMode freq u) ≤ B := by + refine ⟨positionGraphSquare (continuumLocalizedMode freq 0)+1,by + linarith [positionGraphSquare_nonnegative (continuumLocalizedMode freq 0)],?_⟩ + intro u + have he : positionGraphSquare (continuumLocalizedMode freq u) = + positionGraphSquare (continuumLocalizedMode freq 0) := by + unfold positionGraphSquare + simp_rw [continuumLocalizedMode_translate freq u,continuumLocalizedMode_deriv_translate freq u] + rw [integral_sub_right_eq_self (μ := volume) (fun x : Position => continuumLocalizedMode freq 0 x^2) (planarCenter u)] + congr 1 + apply Finset.sum_congr rfl + intro k _ + rw [integral_sub_right_eq_self (μ := volume) (fun x : Position => (fderiv ℝ (continuumLocalizedMode freq 0) x (EuclideanSpace.single k 1))^2) (planarCenter u)] + rw [he] + linarith + +theorem orbitalRemainder_graph_bound {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ R, 1 ≤ R → ∀ u, + positionGraphSquare (orbitalRemainder freq R u) ≤ B/R^24 := by + obtain ⟨D,_hD,hd⟩ := orbitalRemainder_deriv_tail hfreq + let M := ∫ x, ‖x‖^24*continuumLocalizedMode freq 0 x^2 + let A (k : Fin 3) := ∫ x, ‖x‖^24*(fderiv ℝ (continuumLocalizedMode freq 0) x + (EuclideanSpace.single k 1))^2 + let B := 1+M+∑ k : Fin 3, 2*(D^2*M+A k) + have hM : 0 ≤ M := integral_nonneg (fun _ => mul_nonneg (by positivity) (sq_nonneg _)) + have hA (k : Fin 3) : 0 ≤ A k := integral_nonneg (fun _ => mul_nonneg (by positivity) (sq_nonneg _)) + have hsum : 0 ≤ ∑ k : Fin 3, 2*(D^2*M+A k) := Finset.sum_nonneg (fun k _ => + mul_nonneg (by norm_num) (add_nonneg (mul_nonneg (sq_nonneg D) hM) (hA k))) + refine ⟨B,by dsimp [B]; linarith,?_⟩ + intro R hR u + have hR0 : 0 < R := by linarith + have hm : (∫ x, orbitalRemainder freq R u x^2) ≤ M/R^24 := + (orbitalCutoff_value_tail hfreq hR0 u).2 + have hgrad (k : Fin 3) : + (∫ x, (fderiv ℝ (orbitalRemainder freq R u) x (EuclideanSpace.single k 1))^2) ≤ + 2*(D^2*M+A k)/R^24 := by + simpa only [PiLp.norm_single,norm_one,mul_one,M,A] using + (hd R hR u (EuclideanSpace.single k 1)).2 + calc + _ ≤ M/R^24+∑ k : Fin 3, 2*(D^2*M+A k)/R^24 := add_le_add hm (Finset.sum_le_sum (fun k _ => hgrad k)) + _ = (M+∑ k : Fin 3, 2*(D^2*M+A k))/R^24 := by rw [add_div,Finset.sum_div] + _ ≤ B/R^24 := div_le_div_of_nonneg_right (by dsimp [B]; linarith) (by positivity) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalJetBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalJetBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c304ea46e4a040b06edbfb9501c6a84921cd91b9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalJetBounds.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianJetBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeJets +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldBounds + +namespace OAI + +/-! Uniform fourth-order bounds for the actual localized orbitals and +products used in the compressed nuclear coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem fourJet_linear_comp {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [NormedAddCommGroup F] [NormedSpace ℝ F] (L : E →L[ℝ] F) (f : F → ℝ) + (hf : ContDiff ℝ 4 f) {B D : ℝ} (hB : 0 ≤ B) (hD : 1 ≤ D) (hL : ‖L‖ ≤ D) + (hb : ∀ k ≤ 4, ∀ x, ‖iteratedFDeriv ℝ k f x‖ ≤ B) {k : ℕ} (hk : k ≤ 4) (x : E) : + ‖iteratedFDeriv ℝ k (f ∘ L) x‖ ≤ B*D^4 := by + rw [L.iteratedFDeriv_comp_right hf x (by exact_mod_cast hk)] + have h := (iteratedFDeriv ℝ k f (L x)).norm_compContinuousLinearMap_le (fun _ => L) + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin] at h + calc + _ ≤ ‖iteratedFDeriv ℝ k f (L x)‖*‖L‖^k := h + _ ≤ B*D^k := mul_le_mul (hb k hk (L x)) + (pow_le_pow_left₀ (norm_nonneg L) hL k) (pow_nonneg (norm_nonneg L) k) hB + _ ≤ B*D^4 := mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hD hk) hB + +theorem fourJet_mul {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + {f g : E → ℝ} (hf : ContDiff ℝ 4 f) (hg : ContDiff ℝ 4 g) + {A B : ℝ} (hA : 0 ≤ A) (hB : 0 ≤ B) + (ha : ∀ k ≤ 4, ∀ x, ‖iteratedFDeriv ℝ k f x‖ ≤ A) + (hb : ∀ k ≤ 4, ∀ x, ‖iteratedFDeriv ℝ k g x‖ ≤ B) + {k : ℕ} (hk : k ≤ 4) (x : E) : + ‖iteratedFDeriv ℝ k (fun x => f x*g x) x‖ ≤ 16*A*B := by + apply (norm_iteratedFDeriv_mul_le hf hg x (by exact_mod_cast hk)).trans + calc + _ ≤ ∑ i ∈ Finset.range (k+1), (k.choose i : ℝ)*A*B := by + apply Finset.sum_le_sum + intro i hi + have hi' : i ≤ k := Nat.le_of_lt_succ (Finset.mem_range.mp hi) + exact mul_le_mul (mul_le_mul_of_nonneg_left (ha i (hi'.trans hk) x) (Nat.cast_nonneg _)) + (hb (k-i) ((Nat.sub_le k i).trans hk) x) (norm_nonneg _) + (mul_nonneg (Nat.cast_nonneg _) hA) + _ = (2:ℝ)^k*A*B := by + rw [← Finset.sum_mul,← Finset.sum_mul] + congr 2 + exact_mod_cast Nat.sum_range_choose k + _ ≤ 16*A*B := by + apply mul_le_mul_of_nonneg_right _ hB + apply mul_le_mul_of_nonneg_right _ hA + exact (pow_le_pow_right₀ (by norm_num : (1:ℝ) ≤ 2) hk).trans_eq (by norm_num) + +theorem continuumLocalizedMode_jets_bounded {freq : ℝ} (hfreq : 0 < freq) : + ∃ B : ℝ, 1 ≤ B ∧ ∀ u k, k ≤ 4 → ∀ x, + ‖iteratedFDeriv ℝ k (continuumLocalizedMode freq u) x‖ ≤ B := by + obtain ⟨A,hA,ha⟩ := normalized_planar_mode_jets_bounded + obtain ⟨B,hB,hb⟩ := vertical_mode_jets_bounded hfreq + let P := max 1 ‖wellPlanarProjection‖ + let Q := max 1 ‖wellVerticalProjection‖ + have hP : 1 ≤ P := le_max_left _ _ + have hQ : 1 ≤ Q := le_max_left _ _ + have hPA : 0 ≤ A*P^4 := by positivity + have hQB : 0 ≤ B*Q^4 := by positivity + refine ⟨16*(A*P^4)*(B*Q^4)+1,by nlinarith [mul_nonneg hPA hQB],?_⟩ + intro u k hk x + let f : Position → ℝ := (fun r => normalizedPlanarMode (r-u)) ∘ wellPlanarProjection + let g : Position → ℝ := verticalMode freq ∘ wellVerticalProjection + have hf : ContDiff ℝ 4 f := + ((normalizedPlanarMode_C7.of_le (by norm_num)).comp (contDiff_id.sub contDiff_const)).comp + wellPlanarProjection.contDiff + have hg : ContDiff ℝ 4 g := ((verticalMode_smooth freq).of_le (by simp)).comp wellVerticalProjection.contDiff + have hfa (j : ℕ) (hj : j ≤ 4) (y : Position) : ‖iteratedFDeriv ℝ j f y‖ ≤ A*P^4 := by + apply fourJet_linear_comp wellPlanarProjection _ + ((normalizedPlanarMode_C7.of_le (by norm_num)).comp (contDiff_id.sub contDiff_const)) + (by linarith) hP (le_max_right _ _) _ hj y + intro l hl r + change ‖iteratedFDeriv ℝ l (fun x => normalizedPlanarMode (x-u)) r‖ ≤ A + rw [iteratedFDeriv_comp_sub] + exact ha l hl (r-u) + have hgb (j : ℕ) (hj : j ≤ 4) (y : Position) : ‖iteratedFDeriv ℝ j g y‖ ≤ B*Q^4 := + fourJet_linear_comp wellVerticalProjection _ ((verticalMode_smooth freq).of_le (by simp)) + (by linarith) hQ (le_max_right _ _) hb hj y + exact (fourJet_mul hf hg hPA hQB hfa hgb hk x).trans (by linarith) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalNuclearTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalNuclearTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..752114640e7e772df62ec165a3c075b22d033574 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalNuclearTail.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RealOneElectronState +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OrbitalGraphBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.WeightedSourcePairing +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CompactOrbitalDensity + +namespace OAI + +/-! Removal of the compact cutoff in the nuclear matrix element. The +full weak-H1 absolute form estimate controls the removed orbital tail. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem orbital_nuclear_cutoff_error {freq : ℝ} (hfreq : 0 < freq) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (B R : ℝ), 0 ≤ B → 1 ≤ R → + ∀ (F : Position → ℝ), Measurable F → + (∀ (w : Coulomb.H1Vector 1) (s : SpinConfiguration 1), + Integrable (fun x => |F (Coulomb.position x 0)| * ‖w.value s x‖^2)) → + (∀ (w : Coulomb.H1Vector 1) (s : SpinConfiguration 1), + (∫ x, |F (Coulomb.position x 0)| * ‖w.value s x‖^2) ≤ + B*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (0,k) x‖^2)) → + ∀ u v : PlanarPosition, + Integrable (fun x => F x*continuumLocalizedMode freq u x*continuumLocalizedMode freq v x) ∧ + Integrable (fun x => F x*compactOrbitalDensity freq R u v x) ∧ + |(∫ x, F x*continuumLocalizedMode freq u x*continuumLocalizedMode freq v x)- + ∫ x, F x*compactOrbitalDensity freq R u v x| ≤ C*B/R^12 := by + obtain ⟨T,hT,ht⟩ := orbitalRemainder_graph_bound hfreq + obtain ⟨A,hA,ha⟩ := continuumLocalizedMode_graph_uniform freq + let C := T+A + have hT0 : 0 ≤ T := zero_le_one.trans hT + have hA0 : 0 ≤ A := zero_le_one.trans hA + have hC0 : 0 ≤ C := add_nonneg hT0 hA0 + refine ⟨C,by dsimp [C]; linarith,?_⟩ + intro B R hB hR F hF hI hbound u v + have hR0 : 0 < R := by linarith + have hu := (continuumLocalizedMode_C7 freq u).of_le (show (1 : WithTop ℕ∞) ≤ 7 by norm_num) + have hv := (continuumLocalizedMode_C7 freq v).of_le (show (1 : WithTop ℕ∞) ≤ 7 by norm_num) + have hrem := orbitalRemainder_C1 freq R u + have hIr := real_nuclear_integrable_transfer F hI _ hrem + (orbitalRemainder_memLp hfreq hR0 u) (orbitalRemainder_deriv_memLp hfreq hR u) + have hIu := real_nuclear_integrable_transfer F hI _ hu + (continuumLocalizedMode_memLp hfreq u) (continuumLocalizedMode_fderiv_memLp hfreq u) + have hIv := real_nuclear_integrable_transfer F hI _ hv + (continuumLocalizedMode_memLp hfreq v) (continuumLocalizedMode_fderiv_memLp hfreq v) + have hbr : (∫ x, |F x| *orbitalRemainder freq R u x^2) ≤ B*(T/R^24) := by + exact (real_nuclear_form_transfer F B hbound _ hrem + (orbitalRemainder_memLp hfreq hR0 u) (orbitalRemainder_deriv_memLp hfreq hR u)).trans + (mul_le_mul_of_nonneg_left (ht R hR u) hB) + have hbv : (∫ x, |F x| *continuumLocalizedMode freq v x^2) ≤ B*A := by + exact (real_nuclear_form_transfer F B hbound _ hv + (continuumLocalizedMode_memLp hfreq v) (continuumLocalizedMode_fderiv_memLp hfreq v)).trans + (mul_le_mul_of_nonneg_left (ha v) hB) + obtain ⟨hir,hsq⟩ := weighted_source_pairing F _ _ hF hrem.continuous.measurable hv.continuous.measurable hIr hIv + have hiuv := (weighted_source_pairing F _ _ hF hu.continuous.measurable hv.continuous.measurable hIu hIv).1 + have he (x : Position) : F x*compactOrbitalDensity freq R u v x = + F x*continuumLocalizedMode freq u x*continuumLocalizedMode freq v x- + F x*orbitalRemainder freq R u x*continuumLocalizedMode freq v x := by + dsimp [compactOrbitalDensity,orbitalRemainder] + ring + have hic : Integrable (fun x => F x*compactOrbitalDensity freq R u v x) := by + simp_rw [he] + exact hiuv.sub hir + refine ⟨hiuv,hic,?_⟩ + have heI : (∫ x, F x*continuumLocalizedMode freq u x*continuumLocalizedMode freq v x)- + (∫ x, F x*compactOrbitalDensity freq R u v x) = + ∫ x, F x*orbitalRemainder freq R u x*continuumLocalizedMode freq v x := by + simp_rw [he] + rw [integral_sub hiuv hir] + ring + rw [heI] + apply (sq_le_sq₀ (abs_nonneg _) (div_nonneg (mul_nonneg hC0 hB) (pow_nonneg hR0.le 12))).mp + have hp := mul_le_mul hbr hbv + (integral_nonneg (fun x => mul_nonneg (abs_nonneg (F x)) (sq_nonneg _))) + (mul_nonneg hB (div_nonneg hT0 (pow_nonneg hR0.le 24))) + apply hsq.trans (hp.trans ?_) + have hTA : T*A ≤ C^2 := by dsimp [C]; nlinarith [sq_nonneg T,sq_nonneg A] + calc + (B*(T/R^24))*(B*A) = (T*A)*B^2/(R^12)^2 := by rw [← pow_mul]; norm_num; ring + _ ≤ C^2*B^2/(R^12)^2 := div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_right hTA (sq_nonneg B)) (sq_nonneg _) + _ = (C*B/R^12)^2 := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalTensor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee37469221ea2c14d2b9dd91abf8206af0a3c819 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/OrbitalTensor.lean @@ -0,0 +1,332 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockSlaterTensor +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockTensorCompression + +namespace OAI + +/-! Integrals of actual finite orbital tensors, including the exact +one-body head-slot contraction. All coefficients come from the orbital +integrals; no effective matrix identity is a premise. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb.OrbitalTensor +open Laughlin FockSlaterTensor + +lemma delta_product {Q n : ℕ} (a b : Laughlin.Configuration n Q) : + (∏ i, if a i = b i then (1 : ℂ) else 0) = if a = b then 1 else 0 := by + classical + by_cases h : a = b + · subst b + simp + · rw [ite_eq_right h] + obtain ⟨i, hi⟩ := Function.ne_iff.mp h + exact Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + +lemma prod_erase_zero {n : ℕ} (f : Fin (n + 1) → ℂ) : + (∏ j ∈ Finset.univ.erase 0, f j) = ∏ j : Fin n, f j.succ := by + classical + let g : Fin (n + 1) → ℂ := fun j => if j = 0 then 1 else f j + have h : (∏ j, g j) = ∏ j ∈ Finset.univ.erase 0, f j := by + rw [← Finset.mul_prod_erase Finset.univ g (Finset.mem_univ 0)] + simp only [g, ite_true, one_mul] + apply Finset.prod_congr rfl + intro j hj + exact ite_eq_right (Finset.mem_erase.mp hj).1 + rw [← h, Fin.prod_univ_succ] + simp only [g, ite_true, Fin.succ_ne_zero, ite_false, one_mul] + +lemma head_pair_sum {Q n : ℕ} (f : Laughlin.Configuration (n + 1) Q → + Laughlin.Configuration (n + 1) Q → ℂ) : + (∑ a, ∑ b, f a b) = ∑ i, ∑ j, ∑ a : Laughlin.Configuration n Q, + ∑ b : Laughlin.Configuration n Q, f (Fin.cons i a) (Fin.cons j b) := by + rw [sum_config_cons] + apply Finset.sum_congr rfl + intro i _ + simp_rw [sum_config_cons] + rw [Finset.sum_comm] + +private lemma prod_erase_zero_one {n : ℕ} (f : Fin (n + 2) → ℂ) : + (∏ j ∈ (Finset.univ.erase 0).erase 1, f j) = ∏ j : Fin n, f j.succ.succ := by + classical + let g : Fin (n + 2) → ℂ := fun j => if j = 1 then 1 else f j + have h : (∏ j ∈ Finset.univ.erase 0, g j) = + ∏ j ∈ (Finset.univ.erase 0).erase 1, f j := by + rw [← Finset.mul_prod_erase (Finset.univ.erase 0) g (a := 1) (by simp)] + simp only [g, ite_true, one_mul] + apply Finset.prod_congr rfl + intro j hj + exact ite_eq_right (Finset.mem_erase.mp hj).1 + rw [← h, prod_erase_zero, Fin.prod_univ_succ] + simp only [g, Fin.succ_zero_eq_one, ite_true, one_mul] + apply Finset.prod_congr rfl + intro j _ + apply ite_eq_right + intro he + have hv := congrArg Fin.val he + simp only [Fin.val_succ, Fin.val_one] at hv + omega + +lemma headTwo_pair_sum {Q n : ℕ} (f : Laughlin.Configuration (n + 2) Q → + Laughlin.Configuration (n + 2) Q → ℂ) : + (∑ a, ∑ b, f a b) = ∑ i, ∑ k, ∑ j, ∑ l, + ∑ a : Laughlin.Configuration n Q, ∑ b : Laughlin.Configuration n Q, + f (Fin.cons i (Fin.cons j a)) (Fin.cons k (Fin.cons l b)) := by + rw [head_pair_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + exact head_pair_sum _ + +variable {A : Type*} [MeasurableSpace A] {μ : Measure A} [SigmaFinite μ] {Q n : ℕ} + +lemma tensorValue_memLp (v : Fin (Q + 1) → A → ℂ) (hv : ∀ i, MemLp (v i) 2 μ) + (ψ : State n Q) : MemLp (tensorValue v ψ) 2 (Measure.pi fun _ => μ) := by + have ht (a : Laughlin.Configuration n Q) : MemLp (fun x : Fin n → A => + ψ a * ∏ i, v (a i) (x i)) 2 (Measure.pi fun _ => μ) := by + simpa only [Equiv.Perm.one_apply] using + (Coulomb.scalarTensor_memLp (fun i => v (a i)) (fun i => hv (a i)) + (1 : Equiv.Perm (Fin n))).const_mul (ψ a) + exact memLp_finsetSum Finset.univ (fun a _ => ht a) + +omit [MeasurableSpace A] in +lemma bilinear_expansion (v : Fin (Q + 1) → A → ℂ) (ψ φ : State n Q) (x : Fin n → A) : + star (tensorValue v ψ x) * tensorValue v φ x = + ∑ a : Laughlin.Configuration n Q, ∑ b : Laughlin.Configuration n Q, + (star (ψ a) * φ b) * (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i)) := by + simp only [tensorValue, star_sum, star_mul, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + ring + +lemma inner_integral (v : Fin (Q + 1) → A → ℂ) (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (ψ φ : State n Q) : + (∫ x : Fin n → A, star (tensorValue v ψ x) * tensorValue v φ x + ∂(Measure.pi fun _ => μ)) = ∑ a, star (ψ a) * φ a := by + have ht (a b : Laughlin.Configuration n Q) : Integrable (fun x : Fin n → A => + (star (ψ a) * φ b) * (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i))) + (Measure.pi fun _ => μ) := by + have ha := Coulomb.scalarTensor_memLp (fun i => v (a i)) (fun i => hv (a i)) + (1 : Equiv.Perm (Fin n)) + have hb := Coulomb.scalarTensor_memLp (fun i => v (b i)) (fun i => hv (b i)) + (1 : Equiv.Perm (Fin n)) + exact (ha.star.integrable_mul hb).const_mul _ + simp_rw [bilinear_expansion] + rw [integral_finsetSum _ (fun a _ => integrable_finsetSum _ (fun b _ => ht a b))] + apply Finset.sum_congr rfl + intro a _ + rw [integral_finsetSum _ (fun b _ => ht a b)] + have hI (b : Laughlin.Configuration n Q) : + (∫ x : Fin n → A, star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i) + ∂(Measure.pi fun _ => μ)) = ∏ i, ∫ y, star (v (a i) y) * v (b i) y ∂μ := by + simp only [star_prod, ← Finset.prod_mul_distrib] + exact integral_fintype_prod_eq_prod (f := fun i y => star (v (a i) y) * v (b i) y) + (μ := fun _ => μ) + simp only [integral_const_mul, hI, ho, delta_product] + simp + +lemma head_oneBody_integral (v : Fin (Q + 1) → A → ℂ) (w : A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j, Integrable (fun x => w x * (star (v i x) * v j x)) μ) + (ψ φ : State (n + 1) Q) : + (∫ x : Fin (n + 1) → A, w (x 0) * + (star (tensorValue v ψ x) * tensorValue v φ x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, w x * (star (v i x) * v j x) ∂μ) * + ∑ a : Laughlin.Configuration n Q, star (ψ (Fin.cons i a)) * φ (Fin.cons j a) := by + have ht (a b : Laughlin.Configuration (n + 1) Q) : Integrable + (fun x : Fin (n + 1) → A => (star (ψ a) * φ b) * (w (x 0) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i)))) (Measure.pi fun _ => μ) := by + simpa only [Equiv.Perm.one_apply] using + (MixedSlater.oneBodyTensor_integrable (fun i => v (a i)) (fun i => v (b i)) w + (fun i => hv (a i)) (fun i => hv (b i)) (fun i j => hw (a i) (b j)) + (1 : Equiv.Perm (Fin (n + 1))) 1 0).const_mul (star (ψ a) * φ b) + have he (x : Fin (n + 1) → A) : w (x 0) * + (star (tensorValue v ψ x) * tensorValue v φ x) = + ∑ a : Laughlin.Configuration (n + 1) Q, ∑ b : Laughlin.Configuration (n + 1) Q, + (star (ψ a) * φ b) * (w (x 0) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i))) := by + rw [bilinear_expansion, Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun a _ => integrable_finsetSum _ (fun b _ => ht a b))] + simp_rw [integral_finsetSum _ (fun b _ => ht _ b), integral_const_mul] + have hI (a b : Laughlin.Configuration (n + 1) Q) : + (∫ x : Fin (n + 1) → A, w (x 0) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i)) ∂(Measure.pi fun _ => μ)) = + (∫ y, w y * (star (v (a 0) y) * v (b 0) y) ∂μ) * + ∏ j ∈ Finset.univ.erase 0, ∫ y, star (v (a j) y) * v (b j) y ∂μ := by + exact MixedSlater.oneBodyTensor_integral (fun i => v (a i)) (fun i => v (b i)) w + (1 : Equiv.Perm (Fin (n + 1))) 1 0 + simp_rw [hI] + simp only [ho, prod_erase_zero] + rw [head_pair_sum] + simp only [Fin.cons_zero, Fin.cons_succ, delta_product] + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + +lemma oneBody_CAR_compression (v : Fin (Q + 1) → A → ℂ) (w : A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j, Integrable (fun x => w x * (star (v i x) * v j x)) μ) + (ψ φ : State (n + 1) Q) (hψ : Laughlin.Antisymmetric ψ) (hφ : Laughlin.Antisymmetric φ) : + (n + 1 : ℂ) * (∫ x : Fin (n + 1) → A, w (x 0) * + (star (tensorValue v ψ x) * tensorValue v φ x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, w x * (star (v i x) * v j x) ∂μ) * + Laughlin.Fock.occupationInner Q (Laughlin.Fock.normalizedTensorExterior (n + 1) Q ψ) + (Laughlin.Fock.create i (Laughlin.Fock.annihilate j + (Laughlin.Fock.normalizedTensorExterior (n + 1) Q φ))) := by + rw [head_oneBody_integral v w hv ho hw ψ φ] + simp only [FockTensorCompression.oneBody_inner n Q ψ φ hψ hφ, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring_nf + +lemma head_twoBody_integral (v : Fin (Q + 1) → A → ℂ) (w : A → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j k l, Integrable (fun xy : A × A => w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2))) (μ.prod μ)) + (ψ φ : State (n + 2) Q) : + (∫ x : Fin (n + 2) → A, w (x 0) (x 1) * + (star (tensorValue v ψ x) * tensorValue v φ x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ k, ∑ j, ∑ l, + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2)) ∂(μ.prod μ)) * + ∑ a : Laughlin.Configuration n Q, + star (ψ (Fin.cons i (Fin.cons j a))) * φ (Fin.cons k (Fin.cons l a)) := by + have hij : (0 : Fin (n + 2)) ≠ 1 := by norm_num + have ht (a b : Laughlin.Configuration (n + 2) Q) : Integrable + (fun x : Fin (n + 2) → A => (star (ψ a) * φ b) * (w (x 0) (x 1) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i)))) (Measure.pi fun _ => μ) := by + simpa only [Equiv.Perm.one_apply] using + (MixedSlater.twoBodyTensor_integrable (fun i => v (a i)) (fun i => v (b i)) w + (fun i => hv (a i)) (fun i => hv (b i)) (fun i j k l => hw (a i) (a j) (b k) (b l)) + (1 : Equiv.Perm (Fin (n + 2))) 1 0 1 hij).const_mul (star (ψ a) * φ b) + have he (x : Fin (n + 2) → A) : w (x 0) (x 1) * + (star (tensorValue v ψ x) * tensorValue v φ x) = + ∑ a : Laughlin.Configuration (n + 2) Q, ∑ b : Laughlin.Configuration (n + 2) Q, + (star (ψ a) * φ b) * (w (x 0) (x 1) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i))) := by + rw [bilinear_expansion, Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b _ + ring + simp_rw [he] + rw [integral_finsetSum _ (fun a _ => integrable_finsetSum _ (fun b _ => ht a b))] + simp_rw [integral_finsetSum _ (fun b _ => ht _ b), integral_const_mul] + have hI (a b : Laughlin.Configuration (n + 2) Q) : + (∫ x : Fin (n + 2) → A, w (x 0) (x 1) * + (star (∏ i, v (a i) (x i)) * ∏ i, v (b i) (x i)) ∂(Measure.pi fun _ => μ)) = + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v (a 0) xy.1) * v (b 0) xy.1) * + (star (v (a 1) xy.2) * v (b 1) xy.2)) ∂(μ.prod μ)) * + ∏ j ∈ (Finset.univ.erase 0).erase 1, ∫ y, star (v (a j) y) * v (b j) y ∂μ := by + exact MixedSlater.twoBodyTensor_integral (fun i => v (a i)) (fun i => v (b i)) w + (1 : Equiv.Perm (Fin (n + 2))) 1 0 1 hij + simp_rw [hI] + simp only [ho, prod_erase_zero_one] + rw [headTwo_pair_sum] + simp only [Fin.cons_zero, Fin.cons_succ, Fin.cons_one, delta_product] + simp only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ite_true] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro l _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + +lemma twoBody_CAR_compression (v : Fin (Q + 1) → A → ℂ) (w : A → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j k l, Integrable (fun xy : A × A => w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2))) (μ.prod μ)) + (ψ φ : State (n + 2) Q) (hψ : Laughlin.Antisymmetric ψ) (hφ : Laughlin.Antisymmetric φ) : + ((n + 2 : ℂ) * (n + 1 : ℂ)) * (∫ x : Fin (n + 2) → A, w (x 0) (x 1) * + (star (tensorValue v ψ x) * tensorValue v φ x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ k, ∑ j, ∑ l, + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2)) ∂(μ.prod μ)) * + Laughlin.Fock.occupationInner Q (Laughlin.Fock.normalizedTensorExterior (n + 2) Q ψ) + (Laughlin.Fock.create i (Laughlin.Fock.create j (Laughlin.Fock.annihilate l + (Laughlin.Fock.annihilate k (Laughlin.Fock.normalizedTensorExterior (n + 2) Q φ))))) := by + rw [head_twoBody_integral v w hv ho hw ψ φ] + simp only [FockTensorCompression.twoBody_inner n Q ψ φ hψ hφ, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro l _ + ring_nf + +lemma slater_oneBody_CAR_compression (v : Fin (Q + 1) → A → ℂ) (w : A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j, Integrable (fun x => w x * (star (v i x) * v j x)) μ) + (c d : EuclideanSpace ℂ (SlaterOccupation.Occupied Q (n + 1))) : + (n + 1 : ℂ) * (∫ x : Fin (n + 1) → A, w (x 0) * + (star (∑ S, c S * SlaterOccupation.wave v S x) * + ∑ T, d T * SlaterOccupation.wave v T x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ j, (∫ x, w x * (star (v i x) * v j x) ∂μ) * + Laughlin.Fock.occupationInner Q (∑ S, c S • Laughlin.Fock.occupationBasis Q S.val) + (Laughlin.Fock.create i (Laughlin.Fock.annihilate j + (∑ T, d T • Laughlin.Fock.occupationBasis Q T.val))) := by + have h := oneBody_CAR_compression v w hv ho hw (occupationTensor c) (occupationTensor d) + (occupationTensor_antisymmetric c) (occupationTensor_antisymmetric d) + simpa only [tensorValue_occupationTensor, normalizedTensorExterior_occupationTensor] using h + +lemma slater_twoBody_CAR_compression (v : Fin (Q + 1) → A → ℂ) (w : A → A → ℂ) + (hv : ∀ i, MemLp (v i) 2 μ) + (ho : ∀ i j, (∫ x, star (v i x) * v j x ∂μ) = if i = j then (1 : ℂ) else 0) + (hw : ∀ i j k l, Integrable (fun xy : A × A => w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2))) (μ.prod μ)) + (c d : EuclideanSpace ℂ (SlaterOccupation.Occupied Q (n + 2))) : + ((n + 2 : ℂ) * (n + 1 : ℂ)) * (∫ x : Fin (n + 2) → A, w (x 0) (x 1) * + (star (∑ S, c S * SlaterOccupation.wave v S x) * + ∑ T, d T * SlaterOccupation.wave v T x) ∂(Measure.pi fun _ => μ)) = + ∑ i, ∑ k, ∑ j, ∑ l, + (∫ xy : A × A, w xy.1 xy.2 * + ((star (v i xy.1) * v k xy.1) * (star (v j xy.2) * v l xy.2)) ∂(μ.prod μ)) * + Laughlin.Fock.occupationInner Q (∑ S, c S • Laughlin.Fock.occupationBasis Q S.val) + (Laughlin.Fock.create i (Laughlin.Fock.create j (Laughlin.Fock.annihilate l + (Laughlin.Fock.annihilate k (∑ T, d T • Laughlin.Fock.occupationBasis Q T.val))))) := by + have h := twoBody_CAR_compression v w hv ho hw (occupationTensor c) (occupationTensor d) + (occupationTensor_antisymmetric c) (occupationTensor_antisymmetric d) + simpa only [tensorValue_occupationTensor, normalizedTensorExterior_occupationTensor] using h + +end ContinuumCoulomb.OrbitalTensor + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a7148a54890a64d9640b44b967e1d36c1c1b444 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCalibration.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHoppingBounds +import Mathlib.Topology.Order.IntermediateValue + +namespace OAI + +/-! Endpoint brackets and an actual contact-hopping calibration. Quantitative +scale selection and the polynomial-time numerical implementation remain +separate steps; no calibration output is assumed. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem planarHopping_short_scaled {D ε : ℝ} (hd : 2 ≤ (1 - ε) * D) : + planarHoppingLowerConstant / ((1 - ε) * D + 3) * Real.exp (ε * D) ≤ + Real.exp D * planarHopping ((1 - ε) * D) := by + have h := mul_le_mul_of_nonneg_left (planarHopping_sharp_lower hd) (Real.exp_pos D).le + convert h using 1 + calc + _ = (planarHoppingLowerConstant / ((1 - ε) * D + 3)) * + (Real.exp D * Real.exp (-((1 - ε) * D))) := by + rw [← Real.exp_add] + congr 1 + congr 1 + ring + _ = _ := by ring + +theorem planarHopping_long_scaled {D ε : ℝ} (hd : 2 ≤ (1 + ε) * D) : + Real.exp D * planarHopping ((1 + ε) * D) ≤ + planarHoppingUpperConstant * ((1 + ε) * D + 1) * Real.exp (-ε * D) := by + have h := mul_le_mul_of_nonneg_left (planarHopping_sharp_upper hd) (Real.exp_pos D).le + convert h using 1 + calc + _ = (planarHoppingUpperConstant * ((1 + ε) * D + 1)) * + (Real.exp D * Real.exp (-((1 + ε) * D))) := by + rw [← Real.exp_add] + congr 1 + congr 1 + ring + _ = _ := by ring + +/-- The paper's actual hopping profile attains the distance-dependent +superexchange target inside the permitted contact-length interval. Only +continuity of the direct Coulomb profile and the explicit endpoint numerical +brackets remain as premises here. -/ +theorem planarHopping_contact_calibration {D ε τ K U : ℝ} (v : ℝ → ℝ) + (hD : 0 ≤ D) (hε : 0 ≤ ε) (hd : 2 ≤ (1 - ε) * D) + (hv : ContinuousOn v (Set.Icc ((1 - ε) * D) ((1 + ε) * D))) + (hshort : τ * Real.sqrt (K * (U - v ((1 - ε) * D))) ≤ + planarHoppingLowerConstant / ((1 - ε) * D + 3) * Real.exp (ε * D)) + (hlong : planarHoppingUpperConstant * ((1 + ε) * D + 1) * Real.exp (-ε * D) ≤ + τ * Real.sqrt (K * (U - v ((1 + ε) * D)))) : + ∃ d ∈ Set.Icc ((1 - ε) * D) ((1 + ε) * D), + Real.exp D * planarHopping d = τ * Real.sqrt (K * (U - v d)) := by + have hab : (1 - ε) * D ≤ (1 + ε) * D := by nlinarith + have hlong₂ : 2 ≤ (1 + ε) * D := hd.trans hab + let F : ℝ → ℝ := fun d => Real.exp D * planarHopping d - τ * Real.sqrt (K * (U - v d)) + have hc : ContinuousOn F (Set.Icc ((1 - ε) * D) ((1 + ε) * D)) := + (continuous_const.mul planarHopping_lipschitz.continuous).continuousOn.sub + (continuousOn_const.mul (Real.continuous_sqrt.comp_continuousOn + (continuousOn_const.mul (continuousOn_const.sub hv)))) + have h₀ : F ((1 + ε) * D) ≤ 0 := by + have h := (planarHopping_long_scaled hlong₂).trans hlong + dsimp [F] + linarith + have h₁ : 0 ≤ F ((1 - ε) * D) := by + have h := hshort.trans (planarHopping_short_scaled hd) + dsimp [F] + linarith + obtain ⟨d, hdmem, heq⟩ := intermediate_value_Icc' hab hc ⟨h₀, h₁⟩ + exact ⟨d, hdmem, sub_eq_zero.mp heq⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCompactnessEstimates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCompactnessEstimates.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a03c1d0c1d9794369981d860d7c6b2ea01b394e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCompactnessEstimates.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarProjectionGap + +namespace OAI + +/-! Compactness estimates for the actual manufactured planar well. They +reduce the positive gap to uniqueness of its attained ground vector. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.PlanarSobolev + +local instance instPlanarCompactnessEstimatesMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarCompactnessEstimatesBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarCompactnessEstimatesMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem shiftedForm_parallelogram (u v : Target) : + shiftedForm (u+v)+shiftedForm (u-v) = 2*shiftedForm u+2*shiftedForm v := by + have hp := shiftedForm_add_smul u v 1 + have hm := shiftedForm_add_smul u v (-1) + simp only [one_smul,one_mul,one_pow] at hp + simp only [neg_one_smul,neg_one_mul,neg_one_sq,one_mul] at hm + rw [sub_eq_add_neg] + linarith + +theorem shiftedForm_sub_le (u v : Sobolev) : + shiftedForm (u-v).val ≤ 2*shiftedForm u.val+2*shiftedForm v.val := by + have he := shiftedForm_parallelogram u.val v.val + have hn := shiftedForm_nonnegative (u+v) + change 0 ≤ shiftedForm (u.val+v.val) at hn + change shiftedForm (u.val-v.val) ≤ _ + linarith + +theorem shiftedForm_controls_norm (u : Sobolev) : + ‖u‖^2 ≤ 2*shiftedForm u.val + + 2*‖u.val.1‖*‖wellMultiplier u.val.1‖ := by + have hi := (abs_le.mp (abs_real_inner_le_norm u.val.1 (wellMultiplier u.val.1))).1 + change (max ‖u.val.1‖ ‖u.val.2‖)^2 ≤ _ + unfold shiftedForm form + rcases le_total ‖u.val.1‖ ‖u.val.2‖ with h | h + · rw [max_eq_right h] + nlinarith [sq_nonneg ‖u.val.1‖] + · rw [max_eq_left h] + nlinarith [sq_nonneg ‖u.val.2‖] + +theorem nearGround_norm_bound (u : Sobolev) (hm : ‖u.val.1‖ ≤ 1) + (hs : shiftedForm u.val ≤ 1) : ‖u‖ ≤ 3+2*‖wellMultiplier‖ := by + have he := shiftedForm_controls_norm u + have hw := wellMultiplier.le_opNorm u.val.1 + have hW := norm_nonneg wellMultiplier + have hmul : ‖u.val.1‖*‖wellMultiplier u.val.1‖ ≤ ‖wellMultiplier‖ := by + calc + _ ≤ 1*(‖wellMultiplier‖*1) := mul_le_mul hm + (hw.trans (mul_le_mul_of_nonneg_left hm hW)) (norm_nonneg _) (by norm_num) + _ = _ := by ring + nlinarith [norm_nonneg u,sq_nonneg ‖wellMultiplier‖] + +theorem nearGround_distance_bound (u v : Sobolev) + (hu : ‖u.val.1‖ ≤ 1) (hv : ‖v.val.1‖ ≤ 1) : + dist u v ^ 2 ≤ 4*shiftedForm u.val+4*shiftedForm v.val+ + 4*dist (wellMultiplier u.val.1) (wellMultiplier v.val.1) := by + have hs := shiftedForm_controls_norm (u-v) + have hd := shiftedForm_sub_le u v + have hm : ‖(u-v).val.1‖ ≤ 2 := (norm_sub_le _ _).trans (by linarith) + have hmul := mul_le_mul_of_nonneg_right hm (norm_nonneg (wellMultiplier (u-v).val.1)) + rw [dist_eq_norm,dist_eq_norm,← map_sub] + change ‖u-v‖^2 ≤ _ + change ‖u-v‖^2 ≤ 2*shiftedForm (u-v).val+ + 2*‖u.val.1-v.val.1‖*‖wellMultiplier (u.val.1-v.val.1)‖ at hs + change shiftedForm (u-v).val ≤ _ at hd + change ‖u.val.1-v.val.1‖*‖wellMultiplier (u.val.1-v.val.1)‖ ≤ + 2*‖wellMultiplier (u.val.1-v.val.1)‖ at hmul + linarith + +end ContinuumCoulomb.PlanarSobolev + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCutoffTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCutoffTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..1044600cede44ce6298104d413e5b78ab34dd7e3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarCutoffTail.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSiteCutoffs +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarOverlap + +namespace OAI + +/-! The actual site cutoff changes its normalized ground mode by an +exponentially small L2 vector. This controls the rank-one terms in IMS. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planar_l2_pair_sq_le (f g : PlanarPosition → ℝ) (hf : MemLp f 2) (hg : MemLp g 2) : + (∫ x, f x * g x)^2 ≤ (∫ x, f x^2) * (∫ x, g x^2) := by + have hpair (a b : PlanarPosition → ℝ) (ha : MemLp a 2) (hb : MemLp b 2) : + inner ℝ (ha.toLp a) (hb.toLp b) = ∫ x, a x * b x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [ha.coeFn_toLp, hb.coeFn_toLp] with x hx hy + rw [hx, hy, RCLike.inner_apply, conj_trivial] + ring + have h := real_inner_mul_inner_self_le (hf.toLp f) (hg.toLp g) + rw [hpair f g hf hg, hpair f f hf hf, hpair g g hg hg] at h + simpa only [pow_two] using h + +def planarSiteCutoffError (D : ℝ) (u x : PlanarPosition) : ℝ := + (Real.sin (planarSiteAngle D u x) - 1) * normalizedPlanarMode (x-u) + +theorem planarSiteCutoff_deviation_bound (D : ℝ) (u x : PlanarPosition) : + |Real.sin (planarSiteAngle D u x) - 1| ≤ 2 := by + have h := abs_sub (Real.sin (planarSiteAngle D u x)) (1 : ℝ) + have hs := Real.abs_sin_le_one (planarSiteAngle D u x) + norm_num only [abs_one] at h + linarith + +theorem planarSiteCutoffError_memLp (D : ℝ) (u : PlanarPosition) : + MemLp (planarSiteCutoffError D u) 2 := by + have hm := normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u) + apply hm.of_le_mul (c := 2) + ((((planarSiteAngle_C1 D u).sin.continuous.sub continuous_const).mul + (normalizedPlanarMode_C7.continuous.comp (continuous_id.sub continuous_const))).aestronglyMeasurable) + filter_upwards [] with x + change ‖(Real.sin (planarSiteAngle D u x) - 1) * normalizedPlanarMode (x-u)‖ ≤ _ + rw [norm_mul, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (planarSiteCutoff_deviation_bound D u x) (norm_nonneg _) + +def planarSiteTailConstant : ℝ := + 4 * normalizedPlanarExponentialConstant (19/20) ^ 2 * + ∫ r : PlanarPosition, Real.exp (-(19/20 : ℝ) * ‖r‖) + +theorem planarSiteTailConstant_nonnegative : 0 ≤ planarSiteTailConstant := by + unfold planarSiteTailConstant + exact mul_nonneg (mul_nonneg (by norm_num) (sq_nonneg _)) + (integral_nonneg (fun _ => (Real.exp_pos _).le)) + +theorem planarSiteCutoffError_square_bound {D : ℝ} (hD : 0 < D) (u x : PlanarPosition) : + planarSiteCutoffError D u x ^ 2 ≤ + (4 * normalizedPlanarExponentialConstant (19/20)^2 * Real.exp (-(19/20 : ℝ) * (D/8))) * + Real.exp (-(19/20 : ℝ) * ‖x-u‖) := by + by_cases hx : ‖x-u‖ ≤ D/8 + · rw [planarSiteCutoffError, planarSiteAngle_inner hD u x hx, Real.sin_pi_div_two, + sub_self, zero_mul, zero_pow (by decide : 2 ≠ 0)] + positivity + · have hr : D/8 ≤ ‖x-u‖ := (le_of_not_ge hx) + have hdev : (Real.sin (planarSiteAngle D u x) - 1)^2 ≤ (4 : ℝ) := by + have h := planarSiteCutoff_deviation_bound D u x + have hs := (sq_le_sq₀ (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 2)).mpr h + simpa only [sq_abs, show (2 : ℝ)^2 = 4 by norm_num] using hs + have hmode := pow_le_pow_left₀ (normalizedPlanarMode_positive (x-u)).le + (normalizedPlanarMode_exponential_envelope (by norm_num : (0 : ℝ) ≤ 19/20) + (by norm_num : (19/20 : ℝ) < 1) (x-u)) 2 + have he : Real.exp (-(19/20 : ℝ) * ‖x-u‖)^2 ≤ + Real.exp (-(19/20 : ℝ) * (D/8)) * Real.exp (-(19/20 : ℝ) * ‖x-u‖) := by + rw [← Real.exp_nat_mul, ← Real.exp_add] + apply Real.exp_le_exp.mpr + norm_num only [Nat.cast_ofNat] + linarith + rw [mul_pow] at hmode + have hmode' := hmode.trans (mul_le_mul_of_nonneg_left he + (sq_nonneg (normalizedPlanarExponentialConstant (19/20)))) + unfold planarSiteCutoffError + rw [mul_pow] + calc + _ ≤ 4 * (normalizedPlanarExponentialConstant (19/20)^2 * + (Real.exp (-(19/20 : ℝ) * (D/8)) * Real.exp (-(19/20 : ℝ) * ‖x-u‖))) := + mul_le_mul hdev hmode' (sq_nonneg _) (by norm_num) + _ = _ := by ring + +theorem planarSiteCutoffError_integral_bound {D : ℝ} (hD : 0 < D) (u : PlanarPosition) : + (∫ x, planarSiteCutoffError D u x ^ 2) ≤ + planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8)) := by + have hi : Integrable (fun x => planarSiteCutoffError D u x ^ 2) := + (memLp_two_iff_integrable_sq (planarSiteCutoffError_memLp D u).aestronglyMeasurable).mp + (planarSiteCutoffError_memLp D u) + have he := ((planar_exp_norm_integrable (by norm_num : (0 : ℝ) < 19/20)).comp_sub_right u).const_mul + (4 * normalizedPlanarExponentialConstant (19/20)^2 * Real.exp (-(19/20 : ℝ) * (D/8))) + have h := integral_mono hi he (planarSiteCutoffError_square_bound hD u) + rw [integral_const_mul, integral_sub_right_eq_self + (fun r : PlanarPosition => Real.exp (-(19/20 : ℝ) * ‖r‖)) u] at h + convert h using 1 + unfold planarSiteTailConstant + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarDistributionAxes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarDistributionAxes.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e8080fa6c0da4214c00b7ec33d1f8ca8340ec1e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarDistributionAxes.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWeakConstant + +namespace OAI + +/-! The two coordinate distributional derivatives determine the full planar +weak gradient. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators ContDiff +namespace ContinuumCoulomb + +local instance instPlanarDistributionAxesMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarDistributionAxesBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarDistributionAxesMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem planar_axis_expansion (e : PlanarPosition) : + e = ∑ a : Fin 2, e a • planarAxis a := by + ext j + fin_cases j <;> simp [planarAxis] + +theorem planar_zero_axis_distribution_constant (f : PlanarPosition → ℝ) + (hf : LocallyIntegrable f) + (hw : ∀ (ψ : PlanarPosition → ℝ), ContDiff ℝ ∞ ψ → HasCompactSupport ψ → + ∀ a : Fin 2, (∫ x, f x*planarPartial ψ (planarAxis a) x) = 0) : + ∃ c : ℝ, f =ᵐ[volume] fun _ => c := by + apply planar_weak_gradient_zero_constant f hf + intro ψ hψ hc e + have hi (a : Fin 2) : Integrable (fun x => f x*planarPartial ψ (planarAxis a) x) := by + simpa only [smul_eq_mul] using hf.integrable_smul_right_of_hasCompactSupport + (planarPartial_continuous (hψ.of_le (by simp)) _) + (hc.fderiv_apply ℝ (planarAxis a)) + have he : (fun x => f x*fderiv ℝ ψ x e) = + (fun x => ∑ a : Fin 2, e a*(f x*planarPartial ψ (planarAxis a) x)) := by + funext x + have hd : fderiv ℝ ψ x e = ∑ a : Fin 2, e a*planarPartial ψ (planarAxis a) x := by + calc + _ = fderiv ℝ ψ x (∑ a : Fin 2, e a • planarAxis a) := + congrArg (fderiv ℝ ψ x) (planar_axis_expansion e) + _ = _ := by simp only [map_sum,map_smul,smul_eq_mul,planarPartial] + rw [hd,Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + rw [he,integral_finsetSum _ (fun a _ => (hi a).const_mul _)] + simp_rw [integral_const_mul,hw ψ hψ hc,mul_zero] + simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarExponentialEnvelope.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarExponentialEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..b25fb0170ae7ce4c390e0c9c78c00f92a4918ae5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarExponentialEnvelope.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSharpDecay +import Mathlib.Analysis.SpecialFunctions.JapaneseBracket + +namespace OAI + +/-! Global exponential envelopes at every fixed rate below one, and +integrability of their planar radial envelopes. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarExponentialConstant (a : ℝ) : ℝ := Real.exp a / (1 - a ^ 2) + +theorem planarExponentialConstant_positive {a : ℝ} (ha : 0 ≤ a) (ha₁ : a < 1) : + 0 < planarExponentialConstant a := div_pos (Real.exp_pos _) (by nlinarith) + +theorem planarResolventMode_exponential_envelope {a : ℝ} (ha : 0 ≤ a) (ha₁ : a < 1) + (r : PlanarPosition) : planarResolventMode r ≤ planarExponentialConstant a * Real.exp (-a * ‖r‖) := by + have hd : 0 < 1 - a ^ 2 := by nlinarith + by_cases hr : r = 0 + · subst r + simp only [norm_zero, mul_zero, Real.exp_zero, mul_one] + apply (planarResolventMode_le_one 0).trans + apply (le_div_iff₀ hd).mpr + have h := Real.one_le_exp ha + nlinarith [sq_nonneg a] + have hnorm : 0 < ‖r‖ := norm_pos_iff.mpr hr + let e : PlanarPosition := (a / ‖r‖) • r + have he : ‖e‖ = a := by + dsimp [e] + rw [norm_smul, Real.norm_of_nonneg (div_nonneg ha hnorm.le)] + field_simp + have hi : inner ℝ e r = a * ‖r‖ := by + dsimp [e] + rw [real_inner_smul_left, real_inner_self_eq_norm_sq] + field_simp + have h := planarResolventMode_tilt_bound e r (by rw [he]; exact ha₁) + rw [he, hi] at h + convert h using 1 + unfold planarExponentialConstant + rw [show a - a * ‖r‖ = a + -a * ‖r‖ by ring, Real.exp_add] + ring + +theorem exponential_inverse_cubic_bound {c : ℝ} (hc : 0 < c) {t : ℝ} (ht : 0 ≤ t) : + Real.exp (-c * t) ≤ (1 + 3 / c) ^ 3 / (1 + t) ^ 3 := by + have hq : 0 < c / 3 := by positivity + have he := Real.add_one_le_exp (c / 3 * t) + have ht' : t ≤ (3 / c) * Real.exp (c / 3 * t) := by + have h : t * c ≤ 3 * Real.exp (c / 3 * t) := by nlinarith only [he] + calc + _ ≤ (3 * Real.exp (c / 3 * t)) / c := (le_div_iff₀ hc).mpr h + _ = _ := by ring + have h₁ : 1 ≤ Real.exp (c / 3 * t) := Real.one_le_exp (mul_nonneg hq.le ht) + have hb : 1 + t ≤ (1 + 3 / c) * Real.exp (c / 3 * t) := by nlinarith only [ht', h₁] + have hp := pow_le_pow_left₀ (by linarith : 0 ≤ 1 + t) hb 3 + rw [mul_pow, ← Real.exp_nat_mul] at hp + norm_num only [Nat.cast_ofNat] at hp + have harg : (3 : ℝ) * (c / 3 * t) = c * t := by ring + rw [harg] at hp + have hm := mul_le_mul_of_nonneg_left hp (Real.exp_pos (-c * t)).le + have hexp : Real.exp (-c * t) * Real.exp (c * t) = 1 := by + rw [← Real.exp_add] + simp + have hbound : Real.exp (-c * t) * (1 + t) ^ 3 ≤ (1 + 3 / c) ^ 3 := by + calc + _ ≤ Real.exp (-c * t) * ((1 + 3 / c) ^ 3 * Real.exp (c * t)) := hm + _ = _ := by rw [mul_left_comm, hexp, mul_one] + exact (le_div_iff₀ (pow_pos (by linarith : 0 < 1 + t) 3)).mpr hbound + +theorem planar_exp_norm_integrable {c : ℝ} (hc : 0 < c) : + Integrable (fun r : PlanarPosition => Real.exp (-c * ‖r‖)) := by + have hi : Integrable (fun r : PlanarPosition => (1 + ‖r‖) ^ (-(3 : ℝ))) := + integrable_one_add_norm (by norm_num [PlanarPosition]) + apply (hi.const_mul ((1 + 3 / c) ^ 3)).mono' (by fun_prop) + exact Filter.Eventually.of_forall (fun r => by + rw [Real.norm_of_nonneg (Real.exp_pos _).le, Real.rpow_neg (by positivity)] + simpa only [Real.rpow_ofNat, div_eq_mul_inv] using exponential_inverse_cubic_bound hc (norm_nonneg r)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFieldBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFieldBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c04ea5262c69258e86e8addd00d42a578aea166 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFieldBounds.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField +import Mathlib.Analysis.Calculus.ContDiff.Bounds + +namespace OAI + +/-! The actual planar counterterm field has uniform derivative bounds, +independent of the number of sites. Separated unit supports leave at most +one nonzero summand at every point. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +private theorem planarWell_derivatives_bounded : + ∃ C : ℝ, 0 < C ∧ ∀ k : ℕ, k ≤ 6 → ∀ r : PlanarPosition, + ‖iteratedFDeriv ℝ k manufacturedPlanarWell r‖ ≤ C := by + have hb (k : Fin 7) : ∃ C : ℝ, ∀ r : PlanarPosition, + ‖iteratedFDeriv ℝ k.val manufacturedPlanarWell r‖ ≤ C := + (manufacturedPlanarWell_C7.continuous_iteratedFDeriv (by exact_mod_cast k.isLt.le)).bounded_above_of_compact_support + (manufacturedPlanarWell_hasCompactSupport.iteratedFDeriv k.val) + choose B hB using hb + let C : ℝ := 1+∑ k : Fin 7, max (B k) 0 + have hn : 0 ≤ ∑ k : Fin 7, max (B k) 0 := + Finset.sum_nonneg (fun _ _ => le_max_right _ _) + refine ⟨C, by dsimp [C]; linarith, ?_⟩ + intro k hk r + let j : Fin 7 := ⟨k, by omega⟩ + have hs : max (B j) 0 ≤ ∑ k : Fin 7, max (B k) 0 := + Finset.single_le_sum (fun _ _ => le_max_right _ _) (Finset.mem_univ j) + exact (hB j r).trans ((le_max_left _ _).trans (by dsimp [C]; linarith)) + +def planarWellDerivativeConstant : ℝ := Classical.choose planarWell_derivatives_bounded + +theorem planarWellDerivativeConstant_positive : 0 < planarWellDerivativeConstant := + (Classical.choose_spec planarWell_derivatives_bounded).1 + +theorem planarWellDerivativeConstant_bound {k : ℕ} (hk : k ≤ 6) (r : PlanarPosition) : + ‖iteratedFDeriv ℝ k manufacturedPlanarWell r‖ ≤ planarWellDerivativeConstant := + (Classical.choose_spec planarWell_derivatives_bounded).2 k hk r + +private theorem well_derivative_near {k : ℕ} {r : PlanarPosition} + (hr : iteratedFDeriv ℝ k manufacturedPlanarWell r ≠ 0) : ‖r‖ ≤ 1 := by + have hs := (support_iteratedFDeriv_subset (𝕜 := ℝ) (f := manufacturedPlanarWell) k) hr + have hb := (manufacturedPlanarWell_support.trans planarForcing_support) hs + simpa only [Metric.mem_closedBall, dist_zero_right] using hb + +private theorem countertermWellSum_derivative (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) {k : ℕ} (hk : k ≤ 6) (r : PlanarPosition) : + iteratedFDeriv ℝ k (countertermWellSum freq scale u) r = + ∑ i, (1+localizedCounterterm freq u i/scale) • + iteratedFDeriv ℝ k manufacturedPlanarWell (r-u i) := by + have hw : ContDiff ℝ k manufacturedPlanarWell := + manufacturedPlanarWell_C7.of_le (by exact_mod_cast (show k ≤ 7 by omega)) + unfold countertermWellSum + rw [iteratedFDeriv_fun_sum_apply + (f := fun i x => (1+localizedCounterterm freq u i/scale)*manufacturedPlanarWell (x-u i)) + (fun i _ => (contDiff_const.mul (hw.comp (contDiff_id.sub contDiff_const))).contDiffAt)] + apply Finset.sum_congr rfl + intro i _ + change iteratedFDeriv ℝ k (fun x => (1+localizedCounterterm freq u i/scale) • + manufacturedPlanarWell (x-u i)) r = _ + rw [iteratedFDeriv_const_smul_apply' (f := fun x => manufacturedPlanarWell (x-u i)) + (a := 1+localizedCounterterm freq u i/scale) + (hw.comp (contDiff_id.sub contDiff_const)).contDiffAt, + iteratedFDeriv_comp_sub] + +/-- Uniformity in the number of separated sites is essential for the +polynomial-time transport/cubature constants. -/ +theorem countertermWellSum_derivative_bound (freq : ℝ) {scale : ℝ} (hscale : 0 < scale) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → 3 ≤ ‖u i-u j‖) + (hcounter : ∀ i, localizedCounterterm freq u i ≤ scale) + {k : ℕ} (hk : k ≤ 6) (r : PlanarPosition) : + ‖iteratedFDeriv ℝ k (countertermWellSum freq scale u) r‖ ≤ + 2*planarWellDerivativeConstant := by + rw [countertermWellSum_derivative freq scale u hk r] + have hcoef (i : Fin m) : |1+localizedCounterterm freq u i/scale| ≤ 2 := by + have hlo := div_nonneg (localizedCounterterm_nonnegative freq u i) hscale.le + have hhi := (div_le_one hscale).mpr (hcounter i) + rw [abs_of_nonneg (by linarith)] + linarith + by_cases h : ∃ i, iteratedFDeriv ℝ k manufacturedPlanarWell (r-u i) ≠ 0 + · obtain ⟨i, hi⟩ := h + have hzero (j : Fin m) (hji : j ≠ i) : + iteratedFDeriv ℝ k manufacturedPlanarWell (r-u j) = 0 := by + by_contra hj + have hri := well_derivative_near hi + have hrj := well_derivative_near hj + have ht : ‖u i-u j‖ ≤ ‖r-u i‖+‖r-u j‖ := by + calc + _ = ‖(u i-r)+(r-u j)‖ := by congr 1; abel + _ ≤ ‖u i-r‖+‖r-u j‖ := norm_add_le _ _ + _ = _ := by rw [norm_sub_rev (u i) r] + have hd := hsep i j hji.symm + linarith + rw [Finset.sum_eq_single i (fun j _ hji => by rw [hzero j hji, smul_zero]) + (fun hn => (hn (Finset.mem_univ i)).elim), norm_smul, Real.norm_eq_abs] + exact mul_le_mul (hcoef i) (planarWellDerivativeConstant_bound hk _) (norm_nonneg _) + (by norm_num) + · have hzero (i : Fin m) : iteratedFDeriv ℝ k manufacturedPlanarWell (r-u i) = 0 := by + by_contra hi + exact h ⟨i, hi⟩ + simp only [hzero, smul_zero, Finset.sum_const_zero, norm_zero] + exact mul_nonneg (by norm_num) planarWellDerivativeConstant_positive.le + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcing.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbf7b8c905c6981311ad1b78759e6e3c3ec19cbc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcing.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundTransform +import Mathlib.Analysis.SpecialFunctions.Pow.Deriv + +namespace OAI + +/-! The manuscript's explicit planar forcing `(1-|r|²)₊¹⁶`, including finite +smoothness at its support boundary. The positive-part power is represented +by a polynomial plus a fractional power of a square, avoiding a nonsmooth +positive-part differentiation rule. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def positivePartSixteen (x : ℝ) : ℝ := max x 0 ^ 16 + +theorem positivePartSixteen_formula (x : ℝ) : + positivePartSixteen x = (x ^ 16 + x * (x ^ 2 : ℝ) ^ (15 / 2 : ℝ)) / 2 := by + have hp : (x ^ 2 : ℝ) ^ (15 / 2 : ℝ) = |x| ^ 15 := by + rw [Real.rpow_div_two_eq_sqrt (15 : ℝ) (sq_nonneg x), Real.sqrt_sq_eq_abs] + norm_cast + rw [hp] + rcases le_total 0 x with hx | hx + · rw [positivePartSixteen, max_eq_left hx, abs_of_nonneg hx] + ring + · rw [positivePartSixteen, max_eq_right hx, abs_of_nonpos hx] + norm_num + ring + +theorem positivePartSixteen_C7 : ContDiff ℝ 7 positivePartSixteen := by + have hs : ContDiff ℝ 7 (fun x : ℝ => x ^ 2) := contDiff_id.pow 2 + have hp : ContDiff ℝ 7 (fun x : ℝ => (x ^ 2 : ℝ) ^ (15 / 2 : ℝ)) := + hs.rpow_const_of_le (by norm_num : (7 : ℝ) ≤ 15 / 2) + have heq : positivePartSixteen = + fun x : ℝ => (x ^ 16 + x * (x ^ 2 : ℝ) ^ (15 / 2 : ℝ)) / 2 := + funext positivePartSixteen_formula + rw [heq] + exact ((contDiff_id.pow 16).add (contDiff_id.mul hp)).div_const 2 + +def planarForcing (r : PlanarPosition) : ℝ := positivePartSixteen (1 - ‖r‖ ^ 2) + +theorem planarForcing_C7 : ContDiff ℝ 7 planarForcing := + positivePartSixteen_C7.comp (contDiff_const.sub (contDiff_norm_sq ℝ)) + +theorem planarForcing_nonnegative (r : PlanarPosition) : 0 ≤ planarForcing r := + pow_nonneg (le_max_right _ _) _ + +theorem planarForcing_le_one (r : PlanarPosition) : planarForcing r ≤ 1 := by + have hm : max (1 - ‖r‖ ^ 2) 0 ≤ 1 := max_le (by nlinarith [sq_nonneg ‖r‖]) zero_le_one + change max (1 - ‖r‖ ^ 2) 0 ^ 16 ≤ 1 + simpa only [one_pow] using pow_le_pow_left₀ (le_max_right _ _) hm 16 + +theorem planarForcing_zero_of_norm_ge_one {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + planarForcing r = 0 := by + have hsq : 1 ≤ ‖r‖ ^ 2 := by nlinarith + rw [planarForcing, positivePartSixteen, max_eq_right (by linarith)] + norm_num + +theorem planarForcing_support : tsupport planarForcing ⊆ Metric.closedBall 0 1 := by + apply closure_minimal _ Metric.isClosed_closedBall + intro r hr + rw [Metric.mem_closedBall, dist_zero_right] + by_contra hn + exact hr (planarForcing_zero_of_norm_ge_one (by linarith)) + +theorem planarForcing_hasCompactSupport : HasCompactSupport planarForcing := + (isCompact_closedBall (0 : PlanarPosition) 1).of_isClosed_subset + (isClosed_tsupport _) planarForcing_support + +theorem planarForcing_zero : planarForcing 0 = 1 := by + norm_num [planarForcing, positivePartSixteen] + +theorem planarForcing_integrable : Integrable planarForcing := + planarForcing_C7.continuous.integrable_of_hasCompactSupport planarForcing_hasCompactSupport + +theorem planarForcing_integral_positive : 0 < ∫ r, planarForcing r := + integral_pos_of_integrable_nonneg_nonzero planarForcing_C7.continuous + planarForcing_integrable planarForcing_nonnegative (by rw [planarForcing_zero]; norm_num) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcingModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcingModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba23735dc2345a4360fb0d1e050f2246a6bb20b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarForcingModulus.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcing + +namespace OAI + +/-! An explicit global modulus for the forcing used by the numerical +quadrature. Unlike an unspecified compact-support derivative bound, the +constant is a fixed integer usable by the literal sample-count program. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem clippedSquare_formula {r : ℝ} (hr : 0 ≤ r) : + max (1 - r ^ 2) 0 = 1 - (min r 1) ^ 2 := by + by_cases h : r ≤ 1 + · rw [min_eq_left h, max_eq_left] + nlinarith + · rw [min_eq_right (le_of_not_ge h), max_eq_right] + · norm_num + · nlinarith + +theorem clippedSquare_lipschitz {r s : ℝ} (hr : 0 ≤ r) (hs : 0 ≤ s) : + |max (1 - r ^ 2) 0 - max (1 - s ^ 2) 0| ≤ 2 * |r - s| := by + have har : 0 ≤ min r 1 := le_min hr zero_le_one + have hbr : 0 ≤ min s 1 := le_min hs zero_le_one + have hau : min r 1 ≤ 1 := min_le_right _ _ + have hbu : min s 1 ≤ 1 := min_le_right _ _ + have hmin : |min r 1 - min s 1| ≤ |r - s| := by + simpa only [max_neg_neg, neg_sub_neg, abs_sub_comm] using + abs_max_sub_max_le_abs (-r) (-s) (-1) + rw [clippedSquare_formula hr, clippedSquare_formula hs] + have heq : (1 - min r 1 ^ 2) - (1 - min s 1 ^ 2) = + (min s 1 - min r 1) * (min s 1 + min r 1) := by ring + rw [heq, abs_mul, abs_of_nonneg (add_nonneg hbr har), abs_sub_comm (min s 1) (min r 1)] + have hsum : min s 1 + min r 1 ≤ 2 := by linarith + calc + _ ≤ |min r 1 - min s 1| * 2 := + mul_le_mul_of_nonneg_left hsum (abs_nonneg _) + _ ≤ |r - s| * 2 := mul_le_mul_of_nonneg_right hmin (by norm_num) + _ = _ := by ring + +theorem planarForcing_norm_sub_explicit (x y : PlanarPosition) : + |planarForcing x - planarForcing y| ≤ 32 * ‖x - y‖ := by + let a := max (1 - ‖x‖ ^ 2) 0 + let b := max (1 - ‖y‖ ^ 2) 0 + have ha0 : 0 ≤ a := le_max_right _ _ + have hb0 : 0 ≤ b := le_max_right _ _ + have ha1 : a ≤ 1 := max_le (by nlinarith [sq_nonneg ‖x‖]) zero_le_one + have hb1 : b ≤ 1 := max_le (by nlinarith [sq_nonneg ‖y‖]) zero_le_one + have hab : |a - b| ≤ 2 * |‖x‖ - ‖y‖| := + clippedSquare_lipschitz (norm_nonneg x) (norm_nonneg y) + have hm : max |a| |b| ≤ 1 := by + rw [abs_of_nonneg ha0, abs_of_nonneg hb0] + exact max_le ha1 hb1 + have hp := abs_pow_sub_pow_le a b 16 + have hp' : |a ^ 16 - b ^ 16| ≤ |a - b| * 16 := by + calc + _ ≤ |a - b| * 16 * max |a| |b| ^ (16 - 1) := hp + _ ≤ |a - b| * 16 * 1 := mul_le_mul_of_nonneg_left + (by simpa using pow_le_pow_left₀ (le_max_of_le_left (abs_nonneg a)) hm 15) + (by positivity) + _ = _ := mul_one _ + change |a ^ 16 - b ^ 16| ≤ _ + have hnorm := abs_norm_sub_norm_le x y + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFrameBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFrameBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d6f703116f310521c78d345d1d371bd0b8fd085 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarFrameBound.lean @@ -0,0 +1,105 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedOrbitalGram + +namespace OAI + +/-! The actual uncut planar modes satisfy the finite-frame bound needed +when combining planar and transverse spectral estimates. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +private theorem frame_bound_from_synthesis {E : Type*} [NormedAddCommGroup E] + [InnerProductSpace ℝ E] {m : ℕ} (v : Fin m → E) {C : ℝ} (hC : 0 ≤ C) + (hsynth : ∀ d : Fin m → ℝ, ‖∑ i, d i • v i‖^2 ≤ C*∑ i, (d i)^2) + (f : E) : ∑ i, (inner ℝ (v i) f)^2 ≤ C*‖f‖^2 := by + let d : Fin m → ℝ := fun i => inner ℝ (v i) f + let S : ℝ := ∑ i, (d i)^2 + let g : E := ∑ i, d i • v i + have hS : 0 ≤ S := Finset.sum_nonneg (fun i _ => sq_nonneg _) + have hg : ‖g‖^2 ≤ C*S := hsynth d + have hpair : inner ℝ g f = S := by + simp only [g, S, sum_inner, real_inner_smul_left, d, pow_two] + have hcs : S^2 ≤ ‖g‖^2*‖f‖^2 := by + rw [← hpair] + simpa only [pow_two, real_inner_self_eq_norm_sq] using real_inner_mul_inner_self_le g f + have hh : S^2 ≤ C*S*‖f‖^2 := hcs.trans + (mul_le_mul_of_nonneg_right hg (sq_nonneg _)) + change S ≤ C*‖f‖^2 + rcases eq_or_lt_of_le hS with hs | hs + · rw [← hs] + exact mul_nonneg hC (sq_nonneg _) + · nlinarith + +def planarOrbitalL2 (u : PlanarPosition) : Lp ℝ 2 (volume : Measure PlanarPosition) := + (normalizedPlanarMode_memLp.comp_measurePreserving + (measurePreserving_sub_right volume u)).toLp (fun r => normalizedPlanarMode (r-u)) + +theorem planarOrbitalL2_inner (u v : PlanarPosition) : + inner ℝ (planarOrbitalL2 u) (planarOrbitalL2 v) = planarModeOverlap u v := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [ + (normalizedPlanarMode_memLp.comp_measurePreserving + (measurePreserving_sub_right volume u)).coeFn_toLp, + (normalizedPlanarMode_memLp.comp_measurePreserving + (measurePreserving_sub_right volume v)).coeFn_toLp] with r hu hv + change inner ℝ (planarOrbitalL2 u r) (planarOrbitalL2 v r) = _ + change planarOrbitalL2 u r = normalizedPlanarMode (r-u) at hu + change planarOrbitalL2 v r = normalizedPlanarMode (r-v) at hv + rw [hu,hv, RCLike.inner_apply, conj_trivial] + exact mul_comm _ _ + +theorem planarOrbitalL2_frame_bound {D : ℝ} {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : Lp ℝ 2 (volume : Measure PlanarPosition)) : + ∑ i, (inner ℝ (planarOrbitalL2 (u i)) f)^2 ≤ + (1+m*localizedOverlapBound D)*‖f‖^2 := by + apply frame_bound_from_synthesis (fun i => planarOrbitalL2 (u i)) + (by have h := localizedOverlapBound_nonnegative D; positivity) + intro d + have he : ‖∑ i, d i • planarOrbitalL2 (u i)‖^2 = + ∑ i, ∑ j, planarModeOverlap (u i) (u j)*d i*d j := by + rw [← real_inner_self_eq_norm_sq] + simp_rw [sum_inner, inner_sum, real_inner_smul_left, real_inner_smul_right, + planarOrbitalL2_inner] + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro j _ + ring + rw [he] + exact dualMatrix_quadratic_upper _ (localizedOverlapBound_nonnegative D) + (fun i => (planarModeOverlap_diagonal (u i)).le) (planarModeOverlap_offsite u hsep) d + +/-- Integral form, usable on almost-everywhere L2 slices. -/ +theorem planar_modes_frame_bound {D : ℝ} {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : PlanarPosition → ℝ) (hf : MemLp f 2) : + ∑ i, (∫ r, f r*normalizedPlanarMode (r-u i))^2 ≤ + (1+m*localizedOverlapBound D)*(∫ r, f r^2) := by + have h := planarOrbitalL2_frame_bound u hsep (hf.toLp f) + have hi (i : Fin m) : inner ℝ (planarOrbitalL2 (u i)) (hf.toLp f) = + ∫ r, f r*normalizedPlanarMode (r-u i) := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hf.coeFn_toLp, + (normalizedPlanarMode_memLp.comp_measurePreserving + (measurePreserving_sub_right volume (u i))).coeFn_toLp] with r hfr hmr + change inner ℝ (planarOrbitalL2 (u i) r) (hf.toLp f r) = _ + change planarOrbitalL2 (u i) r = normalizedPlanarMode (r-u i) at hmr + rw [hfr, hmr, RCLike.inner_apply, conj_trivial] + have hn : ‖hf.toLp f‖^2 = ∫ r, f r^2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [hf.coeFn_toLp] with r hr + rw [hr, RCLike.inner_apply, conj_trivial] + ring + simpa only [hi, hn] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGapFromUniqueness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGapFromUniqueness.lean new file mode 100644 index 0000000000000000000000000000000000000000..6533672c7005d84c888ffba51d36713a9c58ed8a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGapFromUniqueness.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNearGroundCompactness + +namespace OAI + +/-! The actual planar well has a positive excitation gap once its zero-form +space is the line of the proved normalized ground mode. Compactness here is +proved directly, with no spectral or planar-gap input used. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb.PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance instPlanarGapFromUniquenessMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarGapFromUniquenessBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarGapFromUniquenessMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem normalized_gap_of_ground_uniqueness + (hker : ∀ u : Sobolev, shiftedForm u.val = 0 → + inner ℝ u.val.1 normalizedMode.val.1 = 0 → u = 0) : + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, ‖u.val.1‖^2 = 1 → + inner ℝ u.val.1 normalizedMode.val.1 = 0 → γ ≤ shiftedForm u.val := by + by_contra h + push Not at h + have hex (n : ℕ) : ∃ u : Sobolev, ‖u.val.1‖^2 = 1 ∧ + inner ℝ u.val.1 normalizedMode.val.1 = 0 ∧ + shiftedForm u.val < 1/((n:ℝ)+1) := + h (1/((n:ℝ)+1)) (by positivity) + choose u hm ho hs using hex + have ht : Tendsto (fun n => shiftedForm (u n).val) atTop (𝓝 0) := + squeeze_zero (fun n => shiftedForm_nonnegative (u n)) (fun n => (hs n).le) + (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)) + have hmass (n : ℕ) : ‖(u n).val.1‖ ≤ 1 := by + nlinarith [hm n,norm_nonneg (u n).val.1] + have hbound (n : ℕ) : shiftedForm (u n).val ≤ 1 := by + apply (hs n).le.trans + exact (div_le_one (by positivity)).mpr (by linarith [Nat.cast_nonneg (α := ℝ) n]) + obtain ⟨v,φ,hφ,hv⟩ := nearGround_subsequence u hmass hbound ht + have hcv : Continuous (fun u : Sobolev => ‖u.val.1‖^2) := + (h1ToL2 (μ := volume) (E := PlanarPosition)).continuous.norm.pow 2 + have hmassv : ‖v.val.1‖^2 = 1 := by + apply tendsto_nhds_unique (hcv.continuousAt.tendsto.comp hv) + change Tendsto (fun n => ‖(u (φ n)).val.1‖^2) atTop (𝓝 1) + simp_rw [hm] + exact tendsto_const_nhds + have hcs : Continuous (fun u : Sobolev => shiftedForm u.val) := + (form_continuous.comp continuous_subtype_val).add (continuous_const.mul hcv) + have hzero : shiftedForm v.val = 0 := + tendsto_nhds_unique (hcs.continuousAt.tendsto.comp hv) (ht.comp hφ.tendsto_atTop) + have hco : Continuous (fun u : Sobolev => inner ℝ u.val.1 normalizedMode.val.1) := + (h1ToL2 (μ := volume) (E := PlanarPosition)).continuous.inner continuous_const + have hov : inner ℝ v.val.1 normalizedMode.val.1 = 0 := by + apply tendsto_nhds_unique (hco.continuousAt.tendsto.comp hv) + change Tendsto (fun n => inner ℝ (u (φ n)).val.1 normalizedMode.val.1) atTop (𝓝 0) + simp_rw [ho] + exact tendsto_const_nhds + have hz := hker v hzero hov + norm_num [hz] at hmassv + +theorem shiftedForm_smul (c : ℝ) (u : Target) : + shiftedForm (c • u) = c^2*shiftedForm u := by + unfold shiftedForm + rw [form_smul] + change c^2*form u+(1/2:ℝ)*‖c • u.1‖^2 = _ + rw [norm_smul,mul_pow,Real.norm_eq_abs,sq_abs] + ring + +theorem planar_gap_of_ground_uniqueness + (hker : ∀ u : Sobolev, shiftedForm u.val = 0 → + inner ℝ u.val.1 normalizedMode.val.1 = 0 → u = 0) : + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, + inner ℝ u.val.1 normalizedMode.val.1 = 0 → + ((-1/2:ℝ)+γ)*‖u.val.1‖^2 ≤ form u.val := by + obtain ⟨γ,hγ,hgap⟩ := normalized_gap_of_ground_uniqueness hker + refine ⟨γ,hγ,fun u ho => ?_⟩ + have h : γ*‖u.val.1‖^2 ≤ shiftedForm u.val := by + by_cases hn : ‖u.val.1‖ = 0 + · simpa only [hn,zero_pow (by decide : (2:ℕ) ≠ 0),mul_zero] using shiftedForm_nonnegative u + let v : Sobolev := ‖u.val.1‖⁻¹ • u + have hm : ‖v.val.1‖^2 = 1 := by + change ‖‖u.val.1‖⁻¹ • u.val.1‖^2 = 1 + rw [norm_smul,mul_pow,Real.norm_eq_abs,sq_abs,inv_pow] + exact inv_mul_cancel₀ (pow_ne_zero 2 hn) + have hov : inner ℝ v.val.1 normalizedMode.val.1 = 0 := by + change inner ℝ (‖u.val.1‖⁻¹ • u.val.1) normalizedMode.val.1 = 0 + rw [real_inner_smul_left,ho,mul_zero] + calc + _ ≤ shiftedForm v.val*‖u.val.1‖^2 := + mul_le_mul_of_nonneg_right (hgap v hm hov) (sq_nonneg _) + _ = shiftedForm u.val := by + change shiftedForm (‖u.val.1‖⁻¹ • u.val)*‖u.val.1‖^2 = _ + rw [shiftedForm_smul] + field_simp [hn] + unfold shiftedForm at h + linarith + +end ContinuumCoulomb.PlanarSobolev + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGradientMoments.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGradientMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0b9d229dbfb9f6a8a688ed960ba271f8dfafe92 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGradientMoments.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHigherMoments +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModeDerivatives +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventTails +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianJetBounds + +namespace OAI + +/-! Polynomially weighted square integrability of the actual orbital's +planar derivatives, using the published construction's compact forcing. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem planarResolventOf_half_envelope {g : PlanarPosition → ℝ} {B : ℝ} + (hg : Continuous g) (hs : tsupport g ⊆ Metric.closedBall 0 1) + (hB : ∀ x, ‖g x‖ ≤ B) (r : PlanarPosition) : + ‖planarResolventOf g r‖ ≤ B*planarExponentialConstant (1/2)*Real.exp (-‖r‖/2) := by + have hB0 : 0 ≤ B := (norm_nonneg (g 0)).trans (hB 0) + by_cases hr : r = 0 + · subst r + simp only [norm_zero,neg_zero,zero_div,Real.exp_zero,mul_one] + apply (planarResolventOf_bound hB 0).trans + apply le_mul_of_one_le_right hB0 + unfold planarExponentialConstant + have he := Real.one_le_exp (by norm_num : (0:ℝ) ≤ 1/2) + apply (le_div_iff₀ (by norm_num : (0:ℝ) < 1-(1/2)^2)).mpr + nlinarith only [he] + have hr0 : 0 < ‖r‖ := norm_pos_iff.mpr hr + let e : PlanarPosition := ((1/2)/‖r‖) • r + have he : ‖e‖ = 1/2 := by + dsimp [e] + rw [norm_smul,Real.norm_of_nonneg (by positivity)] + field_simp + have hi : inner ℝ e r = ‖r‖/2 := by + dsimp [e] + rw [real_inner_smul_left,real_inner_self_eq_norm_sq] + field_simp + have ht := planarResolventOf_tilt_bound hg hs hB e r (by rw [he]; norm_num) + rw [he,hi] at ht + convert ht using 1 + unfold planarExponentialConstant + rw [show (1/2:ℝ)-‖r‖/2 = 1/2+(-‖r‖/2) by ring,Real.exp_add] + ring + +private theorem planarResolventOf_weighted_square_integrable {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) + (hs : tsupport g ⊆ Metric.closedBall 0 1) (k : ℕ) : + Integrable (fun r : PlanarPosition => ‖r‖^k*planarResolventOf g r^2) := by + obtain ⟨B,hB⟩ := hg.bounded_above_of_compact_support hc + let C := (B*planarExponentialConstant (1/2))^2*((k.factorial:ℝ)/(1/2)^k) + have hi := (planar_exp_norm_integrable (by norm_num : (0:ℝ)<1/2)).const_mul C + apply hi.mono' (((continuous_norm.pow k).mul + ((planarResolventOf_continuous hg hc).pow 2)).aestronglyMeasurable) + filter_upwards [] with r + change ‖‖r‖^k*planarResolventOf g r^2‖ ≤ C*Real.exp (-(1/2:ℝ)*‖r‖) + rw [Real.norm_of_nonneg (mul_nonneg (pow_nonneg (norm_nonneg _) _) (sq_nonneg _))] + have he := pow_le_pow_left₀ (norm_nonneg (planarResolventOf g r)) + (planarResolventOf_half_envelope hg hs hB r) 2 + rw [Real.norm_eq_abs,sq_abs] at he + have hex : Real.exp (-‖r‖/2)^2 = Real.exp (-(1/2:ℝ)*‖r‖)*Real.exp (-(1/2:ℝ)*‖r‖) := by + rw [pow_two] + congr 1 <;> congr 1 <;> ring + rw [mul_pow,hex] at he + have hp := power_exponential_bound k (by norm_num : (0:ℝ)<1/2) (norm_nonneg r) + have hm := mul_le_mul_of_nonneg_left he (pow_nonneg (norm_nonneg r) k) + calc + _ ≤ ‖r‖^k*((B*planarExponentialConstant (1/2))^2* + (Real.exp (-(1/2:ℝ)*‖r‖)*Real.exp (-(1/2:ℝ)*‖r‖))) := hm + _ = (B*planarExponentialConstant (1/2))^2*(‖r‖^k*Real.exp (-(1/2:ℝ)*‖r‖))* + Real.exp (-(1/2:ℝ)*‖r‖) := by ring + _ ≤ C*Real.exp (-(1/2:ℝ)*‖r‖) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hp (sq_nonneg _)) (Real.exp_pos _).le + +theorem normalizedPlanarMode_partial_moment_integrable (e : PlanarPosition) (k : ℕ) : + Integrable (fun r => ‖r‖^k*planarPartial normalizedPlanarMode e r^2) := by + have hi := planarResolventOf_weighted_square_integrable + (planarPartial_continuous (planarForcing_C7.of_le (by norm_num)) e) + (planarForcing_hasCompactSupport.fderiv_apply ℝ e) + ((tsupport_fderiv_apply_subset ℝ e).trans planarForcing_support) k + simp_rw [normalizedPlanarMode_partial,planarResolventMode_partial,mul_pow] + convert hi.const_mul ((Real.sqrt (∫ s, planarResolventMode s^2))⁻¹^2) using 1 + funext r + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundDuality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7747ece481df626413a20ba31babcb12f4cb4d5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundDuality.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarTestCauchy + +namespace OAI + +/-! A compact-test distributional gradient is controlled by the exact +ground-state energy. This estimate survives closure of the Sobolev graph. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planar_ground_dual_bound (u ψ : PlanarPosition → ℝ) + (hu : ContDiff ℝ 1 u) (huc : HasCompactSupport u) + (hψ : ContDiff ℝ 1 ψ) (hψc : HasCompactSupport ψ) (a : Fin 2) : + (∫ x, planarGroundQuotient u x*planarPartial ψ (planarAxis a) x)^2 ≤ + (∫ x, (ψ x/planarResolventMode x)^2)* + (2*planarTestForm manufacturedPlanarWell u+∫ x, u x^2) := by + let v := planarGroundQuotient u + have hv : ContDiff ℝ 1 v := planarGroundQuotient_C1 hu + have hvc : HasCompactSupport v := planarGroundQuotient_compact huc + have hdc : HasCompactSupport (planarPartial v (planarAxis a)) := + hvc.fderiv_apply ℝ _ + have hd : Continuous (planarPartial v (planarAxis a)) := planarPartial_continuous hv _ + have hψd : Continuous (planarPartial ψ (planarAxis a)) := planarPartial_continuous hψ _ + have hiA : Integrable (fun x => planarPartial v (planarAxis a) x*ψ x) := + (hd.mul hψ.continuous).integrable_of_hasCompactSupport hdc.mul_right + have hiB : Integrable (fun x => v x*planarPartial ψ (planarAxis a) x) := + (hv.continuous.mul hψd).integrable_of_hasCompactSupport hvc.mul_right + have hiFG : Integrable (fun x => v x*ψ x) := + (hv.continuous.mul hψ.continuous).integrable_of_hasCompactSupport hvc.mul_right + have hibp := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hiA hiB hiFG + (fun x _ => hv.differentiable (by norm_num) x) + (fun x _ => hψ.differentiable (by norm_num) x) + change (∫ x, v x*planarPartial ψ (planarAxis a) x) = + -(∫ x, planarPartial v (planarAxis a) x*ψ x) at hibp + let F := fun x => planarResolventMode x*planarPartial v (planarAxis a) x + let G := fun x => ψ x/planarResolventMode x + have hF : Continuous F := planarResolventMode_C7.continuous.mul hd + have hG : Continuous G := hψ.continuous.div planarResolventMode_C7.continuous + (fun x => (planarResolventMode_positive x).ne') + have hFc : HasCompactSupport F := hdc.mul_left + have hGc : HasCompactSupport G := planarGroundQuotient_compact hψc + have he (x : PlanarPosition) : F x*G x = planarPartial v (planarAxis a) x*ψ x := by + dsimp [F,G] + field_simp [(planarResolventMode_positive x).ne'] + have hCS := planar_test_cauchy_square F G hF hG hFc hGc + simp_rw [he] at hCS + have hf2 : (∫ x, F x^2) = + ∫ x, planarResolventMode x^2*planarPartial v (planarAxis a) x^2 := by + simp only [F,mul_pow] + rw [hf2] at hCS + have hsingle : (∫ x, planarResolventMode x^2*planarPartial v (planarAxis a) x^2) ≤ + 2*planarTestForm manufacturedPlanarWell u+∫ x, u x^2 := by + rw [← planarGroundQuotient_energy u hu huc] + apply Finset.single_le_sum (f := fun b : Fin 2 => ∫ x : PlanarPosition, + planarResolventMode x^2*planarPartial v (planarAxis b) x^2) + · intro b _ + exact integral_nonneg (fun x => mul_nonneg (sq_nonneg _) (sq_nonneg _)) + · exact Finset.mem_univ a + have hn : 0 ≤ ∫ x, G x^2 := integral_nonneg (fun _ => sq_nonneg _) + have hb := hCS.trans (mul_le_mul_of_nonneg_right hsingle hn) + change (∫ x, v x*planarPartial ψ (planarAxis a) x)^2 ≤ _ + rw [hibp,neg_sq] + exact hb.trans_eq (mul_comm _ _) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundIdentity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ef3e0748fcfa837b40a8dde62f75bb8fc776a47 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundIdentity.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellBottom + +namespace OAI + +/-! Exact ground-state transform for the actual manufactured planar well. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def planarGroundQuotient (u : PlanarPosition → ℝ) (x : PlanarPosition) : ℝ := + u x/planarResolventMode x + +theorem planarGroundQuotient_C1 {u : PlanarPosition → ℝ} (hu : ContDiff ℝ 1 u) : + ContDiff ℝ 1 (planarGroundQuotient u) := + hu.div (planarResolventMode_C7.of_le (by norm_num)) + (fun x => (planarResolventMode_positive x).ne') + +theorem planarGroundQuotient_compact {u : PlanarPosition → ℝ} (hc : HasCompactSupport u) : + HasCompactSupport (planarGroundQuotient u) := by + change HasCompactSupport (fun x => u x*(planarResolventMode x)⁻¹) + exact hc.mul_right + +theorem planarGroundQuotient_energy (u : PlanarPosition → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (∑ a : Fin 2, ∫ x, planarResolventMode x^2 * + planarPartial (planarGroundQuotient u) (planarAxis a) x^2) = + 2*planarTestForm manufacturedPlanarWell u + ∫ x, u x^2 := by + let phi := planarResolventMode + let v := planarGroundQuotient u + have hp : ContDiff ℝ 2 phi := planarResolventMode_C7.of_le (by norm_num) + have hv : ContDiff ℝ 1 v := planarGroundQuotient_C1 hu + have hvc : HasCompactSupport v := planarGroundQuotient_compact hc + have hfactor (x : PlanarPosition) : phi x*v x = u x := by + dsimp [phi,v,planarGroundQuotient] + field_simp [(planarResolventMode_positive x).ne'] + have hf : (fun x => phi x*v x) = u := funext hfactor + have hB (x : PlanarPosition) : phi x*planarLaplacian phi x*v x^2 = + (2*manufacturedPlanarWell x+1)*u x^2 := by + rw [manufacturedPlanarWell_eigen_equation] + calc + _ = (2*manufacturedPlanarWell x+1)*(phi x*v x)^2 := by ring + _ = _ := by rw [hfactor] + have hc2 : HasCompactSupport (fun x => u x^2) := + hc.comp_left (g := fun t : ℝ => t^2) (by norm_num) + have hiP : Integrable (fun x => manufacturedPlanarWell x*u x^2) := + (manufacturedPlanarWell_C7.continuous.mul (hu.continuous.pow 2)).integrable_of_hasCompactSupport + hc2.mul_left + have hiM : Integrable (fun x => u x^2) := + (hu.continuous.pow 2).integrable_of_hasCompactSupport hc2 + have hpot : (∫ x, (2*manufacturedPlanarWell x+1)*u x^2) = + 2*(∫ x, manufacturedPlanarWell x*u x^2)+(∫ x, u x^2) := by + rw [show (fun x => (2*manufacturedPlanarWell x+1)*u x^2) = + (fun x => 2*(manufacturedPlanarWell x*u x^2)+u x^2) from by funext x; ring] + rw [integral_add (hiP.const_mul 2) hiM,integral_const_mul] + calc + _ = ∑ a : Fin 2, ∫ x, planarPartial (fun y => phi y*v y) (planarAxis a) x^2+ + phi x*planarPartial (planarPartial phi (planarAxis a)) (planarAxis a) x*v x^2 := by + exact Finset.sum_congr rfl (fun a _ => (planar_ground_transform_direction phi v hp hv hvc _).symm) + _ = (∑ a : Fin 2, ∫ x, planarPartial u (planarAxis a) x^2)+ + ∫ x, (2*manufacturedPlanarWell x+1)*u x^2 := by + rw [planar_transform_energy_split phi v hp hv hvc,hf] + simp_rw [hB] + _ = _ := by + rw [hpot] + unfold planarTestForm + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundTransform.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0fe36cda3e1543bdb09b4584a31b3249e2fd3d8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundTransform.lean @@ -0,0 +1,212 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPoisson + +namespace OAI + +/-! The planar manufactured well's ground-state transform. Integration by +parts establishes positivity on actual compact C¹ test functions. Existence, +decay and the excitation gap of the specific resolvent-generated mode remain +separate analytic steps. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +abbrev PlanarPosition := EuclideanSpace ℝ (Fin 2) + +def planarPartial (f : PlanarPosition → ℝ) (e : PlanarPosition) (x : PlanarPosition) : ℝ := + fderiv ℝ f x e + +def planarAxis (a : Fin 2) : PlanarPosition := EuclideanSpace.single a 1 + +def planarLaplacian (f : PlanarPosition → ℝ) (x : PlanarPosition) : ℝ := + ∑ a : Fin 2, planarPartial (planarPartial f (planarAxis a)) (planarAxis a) x + +theorem planarPartial_C1 {phi : PlanarPosition → ℝ} (hphi : ContDiff ℝ 2 phi) + (e : PlanarPosition) : ContDiff ℝ 1 (planarPartial phi e) := + (hphi.fderiv_right (show (1 : WithTop ℕ∞) + 1 ≤ 2 by norm_num)).clm_apply contDiff_const + +theorem planarPartial_continuous {v : PlanarPosition → ℝ} (hv : ContDiff ℝ 1 v) + (e : PlanarPosition) : Continuous (planarPartial v e) := + ((hv.fderiv_right (show (0 : WithTop ℕ∞) + 1 ≤ 1 by norm_num)).clm_apply + contDiff_const).continuous + +theorem planarPartial_mul (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 1 phi) (hv : ContDiff ℝ 1 v) (e x : PlanarPosition) : + planarPartial (fun y => phi y * v y) e x = + phi x * planarPartial v e x + v x * planarPartial phi e x := by + dsimp [planarPartial] + rw [fderiv_fun_mul (hphi.differentiable (by norm_num) x) (hv.differentiable (by norm_num) x)] + rfl + +theorem planarPartial_mul_square (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 1 phi) (hv : ContDiff ℝ 1 v) (e x : PlanarPosition) : + planarPartial (fun y => phi y * v y ^ 2) e x = + planarPartial phi e x * v x ^ 2 + 2 * phi x * v x * planarPartial v e x := by + rw [planarPartial_mul phi (fun y => v y ^ 2) hphi (hv.pow 2)] + have hp : planarPartial (fun y => v y ^ 2) e x = 2 * v x * planarPartial v e x := by + dsimp [planarPartial] + rw [fderiv_fun_pow 2 (hv.differentiable (by norm_num) x)] + simp only [smul_apply, smul_eq_mul, nsmul_eq_mul, Nat.reduceSub, pow_one, Nat.cast_ofNat] + rw [hp] + ring + +theorem planar_transform_integrable (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hv : ContDiff ℝ 1 v) (hc : HasCompactSupport v) + (e : PlanarPosition) : + Integrable (fun x => planarPartial (fun y => phi y * v y ^ 2) e x * planarPartial phi e x) ∧ + Integrable (fun x => (phi x * v x ^ 2) * planarPartial (planarPartial phi e) e x) ∧ + Integrable (fun x => (phi x * v x ^ 2) * planarPartial phi e x) ∧ + Integrable (fun x => phi x ^ 2 * planarPartial v e x ^ 2) := by + have hphi1 : ContDiff ℝ 1 phi := hphi.of_le (by norm_num) + have hp := planarPartial_C1 hphi e + have hvc : HasCompactSupport (planarPartial v e) := hc.fderiv_apply ℝ e + have hv2c : HasCompactSupport (fun x => v x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hf : ContDiff ℝ 1 (fun x => phi x * v x ^ 2) := hphi1.mul (hv.pow 2) + have hfc : HasCompactSupport (fun x => phi x * v x ^ 2) := hv2c.mul_left + refine ⟨?_, ?_, ?_, ?_⟩ + · exact ((planarPartial_continuous hf e).mul hp.continuous).integrable_of_hasCompactSupport + (hfc.fderiv_apply ℝ e).mul_right + · exact (hf.continuous.mul (planarPartial_continuous hp e)).integrable_of_hasCompactSupport + hfc.mul_right + · exact (hf.continuous.mul hp.continuous).integrable_of_hasCompactSupport hfc.mul_right + · have hsq : HasCompactSupport (fun x => planarPartial v e x ^ 2) := + hvc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hcompact : HasCompactSupport (fun x => phi x ^ 2 * planarPartial v e x ^ 2) := + hsq.mul_left + exact ((hphi.continuous.pow 2).mul ((planarPartial_continuous hv e).pow 2)).integrable_of_hasCompactSupport hcompact + +theorem planar_transform_ibp (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hv : ContDiff ℝ 1 v) (hc : HasCompactSupport v) + (e : PlanarPosition) : + (∫ x, (phi x * v x ^ 2) * planarPartial (planarPartial phi e) e x) = + -(∫ x, planarPartial (fun y => phi y * v y ^ 2) e x * planarPartial phi e x) := by + obtain ⟨hA, hB, hfg, hR⟩ := planar_transform_integrable phi v hphi hv hc e + have hf : ContDiff ℝ 1 (fun x => phi x * v x ^ 2) := + (hphi.of_le (by norm_num)).mul (hv.pow 2) + exact integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hA hB hfg + (fun x _ => hf.differentiable (by norm_num) x) + (fun x _ => (planarPartial_C1 hphi e).differentiable (by norm_num) x) + +theorem planar_ground_transform_direction (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hv : ContDiff ℝ 1 v) (hc : HasCompactSupport v) + (e : PlanarPosition) : + (∫ x, planarPartial (fun y => phi y * v y) e x ^ 2 + + phi x * planarPartial (planarPartial phi e) e x * v x ^ 2) = + ∫ x, phi x ^ 2 * planarPartial v e x ^ 2 := by + have hphi1 : ContDiff ℝ 1 phi := hphi.of_le (by norm_num) + obtain ⟨hA, hB, hfg, hR⟩ := planar_transform_integrable phi v hphi hv hc e + have heq : (fun x => planarPartial (fun y => phi y * v y) e x ^ 2 + + phi x * planarPartial (planarPartial phi e) e x * v x ^ 2) = + (fun x => (phi x ^ 2 * planarPartial v e x ^ 2 + + planarPartial (fun y => phi y * v y ^ 2) e x * planarPartial phi e x) + + (phi x * v x ^ 2) * planarPartial (planarPartial phi e) e x) := by + funext x + rw [planarPartial_mul phi v hphi1 hv, planarPartial_mul_square phi v hphi1 hv] + ring + rw [heq] + change (∫ x, ((fun y => phi y ^ 2 * planarPartial v e y ^ 2) + + (fun y => planarPartial (fun z => phi z * v z ^ 2) e y * planarPartial phi e y)) x + + (fun y => phi y * v y ^ 2 * planarPartial (planarPartial phi e) e y) x) = _ + rw [integral_add (hR.add hA) hB, integral_add' hR hA, + planar_transform_ibp phi v hphi hv hc e] + ring + +/-- Nonnegativity of the shifted manufactured-well form on compact C¹ +tests follows from the actual directional integration-by-parts identities. -/ +theorem planar_ground_transform_nonnegative (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hv : ContDiff ℝ 1 v) (hc : HasCompactSupport v) : + 0 ≤ ∑ a : Fin 2, ∫ x, + planarPartial (fun y => phi y * v y) (planarAxis a) x ^ 2 + + phi x * planarPartial (planarPartial phi (planarAxis a)) (planarAxis a) x * v x ^ 2 := by + apply Finset.sum_nonneg + intro a _ + rw [planar_ground_transform_direction phi v hphi hv hc] + exact integral_nonneg (fun _ => mul_nonneg (sq_nonneg _) (sq_nonneg _)) + +def planarTestForm (W u : PlanarPosition → ℝ) : ℝ := + (1 / 2 : ℝ) * (∑ a : Fin 2, ∫ x, planarPartial u (planarAxis a) x ^ 2) + + ∫ x, W x * u x ^ 2 + +theorem planar_partial_square_integrable (u : PlanarPosition → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) (e : PlanarPosition) : + Integrable (fun x => planarPartial u e x ^ 2) := by + have hpc : HasCompactSupport (planarPartial u e) := hc.fderiv_apply ℝ e + have hsq : HasCompactSupport (fun x => planarPartial u e x ^ 2) := + hpc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + exact ((planarPartial_continuous hu e).pow 2).integrable_of_hasCompactSupport hsq + +theorem planar_transform_energy_split (phi v : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hv : ContDiff ℝ 1 v) (hc : HasCompactSupport v) : + (∑ a : Fin 2, ∫ x, + planarPartial (fun y => phi y * v y) (planarAxis a) x ^ 2 + + phi x * planarPartial (planarPartial phi (planarAxis a)) (planarAxis a) x * v x ^ 2) = + (∑ a : Fin 2, ∫ x, planarPartial (fun y => phi y * v y) (planarAxis a) x ^ 2) + + ∫ x, phi x * planarLaplacian phi x * v x ^ 2 := by + have hu : ContDiff ℝ 1 (fun x => phi x * v x) := (hphi.of_le (by norm_num)).mul hv + have huc : HasCompactSupport (fun x => phi x * v x) := hc.mul_left + have hvc : HasCompactSupport (fun x => v x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hb (a : Fin 2) : Integrable (fun x => + phi x * planarPartial (planarPartial phi (planarAxis a)) (planarAxis a) x * v x ^ 2) := by + have hs : HasCompactSupport (fun x => + phi x * planarPartial (planarPartial phi (planarAxis a)) (planarAxis a) x * v x ^ 2) := hvc.mul_left + exact ((hphi.continuous.mul (planarPartial_continuous (planarPartial_C1 hphi _) _)).mul + (hv.continuous.pow 2)).integrable_of_hasCompactSupport hs + have hd (a : Fin 2) := planar_partial_square_integrable _ hu huc (planarAxis a) + simp_rw [integral_add (hd _) (hb _)] + rw [Finset.sum_add_distrib, ← integral_finsetSum _ (fun a _ => hb a)] + congr 1 + apply integral_congr_ae + filter_upwards [] with x + simp only [planarLaplacian, Finset.mul_sum, Finset.sum_mul] + +/-- A positive classical mode at energy `-1/2` gives the lower bound on +every compact C¹ test, without assuming the well's spectral conclusion. -/ +theorem planar_positive_mode_form_lower (phi W u : PlanarPosition → ℝ) + (hphi : ContDiff ℝ 2 phi) (hpos : ∀ x, 0 < phi x) (hW : Continuous W) + (heigen : ∀ x, planarLaplacian phi x = (2 * W x + 1) * phi x) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + -(1 / 2 : ℝ) * (∫ x, u x ^ 2) ≤ planarTestForm W u := by + let v : PlanarPosition → ℝ := fun x => u x / phi x + have hv : ContDiff ℝ 1 v := hu.div (hphi.of_le (by norm_num)) (fun x => (hpos x).ne') + have hvc : HasCompactSupport v := by + change HasCompactSupport (fun x => u x / phi x) + simp only [div_eq_mul_inv] + exact hc.mul_right + have hv2c : HasCompactSupport (fun x => v x ^ 2) := + hvc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hu2c : HasCompactSupport (fun x => u x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hfactor (x : PlanarPosition) : phi x * v x = u x := by + dsimp [v] + field_simp [(hpos x).ne'] + have hfactor_fun : (fun x => phi x * v x) = u := funext hfactor + have hB (x : PlanarPosition) : + phi x * planarLaplacian phi x * v x ^ 2 = (2 * W x + 1) * u x ^ 2 := by + rw [heigen] + calc + _ = (2 * W x + 1) * (phi x * v x) ^ 2 := by ring + _ = _ := by rw [hfactor] + have hnonneg := planar_ground_transform_nonnegative phi v hphi hv hvc + rw [planar_transform_energy_split phi v hphi hv hvc, hfactor_fun] at hnonneg + simp_rw [hB] at hnonneg + have hpot : Integrable (fun x => W x * u x ^ 2) := + (hW.mul (hu.continuous.pow 2)).integrable_of_hasCompactSupport hu2c.mul_left + have hmass : Integrable (fun x => u x ^ 2) := + (hu.continuous.pow 2).integrable_of_hasCompactSupport hu2c + have heq : (∫ x, (2 * W x + 1) * u x ^ 2) = + 2 * (∫ x, W x * u x ^ 2) + ∫ x, u x ^ 2 := by + rw [show (fun x => (2 * W x + 1) * u x ^ 2) = + (fun x => 2 * (W x * u x ^ 2) + u x ^ 2) from by funext x; ring] + rw [integral_add (hpot.const_mul 2) hmass, integral_const_mul] + rw [heq] at hnonneg + dsimp [planarTestForm] + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundUniqueness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundUniqueness.lean new file mode 100644 index 0000000000000000000000000000000000000000..84b11c847961986568611bcd22d96abd88efb86e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarGroundUniqueness.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolevDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarDistributionAxes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGapFromUniqueness + +namespace OAI + +/-! Uniqueness and the actual manufactured planar ground gap, proved on the +full closed Sobolev graph without the published spectral hypothesis. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.PlanarSobolev + +local instance instPlanarGroundUniquenessMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarGroundUniquenessBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarGroundUniquenessMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem zero_ground_form_multiple (u : Sobolev) (hzero : shiftedForm u.val = 0) : + ∃ c : ℝ, u.val.1 = c • mode.val.1 := by + have hloc : LocallyIntegrable (fun x => u.val.1 x/planarResolventMode x) := by + have hli : LocallyIntegrable (fun x : PlanarPosition => u.val.1 x) := + (Lp.memLp u.val.1).locallyIntegrable (by norm_num) + have hi : Continuous (fun x : PlanarPosition => (planarResolventMode x)⁻¹) := + planarResolventMode_C7.continuous.inv₀ + (fun x => (planarResolventMode_positive x).ne') + have hh : LocallyIntegrable (fun x : PlanarPosition => u.val.1 x*(planarResolventMode x)⁻¹) := + LocallyIntegrable.mul_continuous hi hli + simpa only [div_eq_mul_inv] using hh + obtain ⟨c,hc⟩ := planar_zero_axis_distribution_constant + (fun x => u.val.1 x/planarResolventMode x) hloc (fun ψ hψ hψc a => + zero_ground_form_axis_distribution u hzero ψ (hψ.of_le (by simp)) hψc a) + refine ⟨c,Lp.ext ?_⟩ + have hmode : mode.val.1 =ᵐ[volume] planarResolventMode := mode_memLp.coeFn_toLp + filter_upwards [hc,hmode,Lp.coeFn_smul c mode.val.1] with x hx hm hs + rw [hs] + change u.val.1 x = c*mode.val.1 x + rw [hm] + exact (div_eq_iff (planarResolventMode_positive x).ne').mp hx + +theorem zero_ground_form_orthogonal (u : Sobolev) (hzero : shiftedForm u.val = 0) + (ho : inner ℝ u.val.1 normalizedMode.val.1 = 0) : u = 0 := by + obtain ⟨c,hu⟩ := zero_ground_form_multiple u hzero + rw [hu] at ho + change inner ℝ (c • mode.val.1) ((Real.sqrt (‖mode.val.1‖^2))⁻¹ • mode.val.1) = 0 at ho + rw [real_inner_smul_left,real_inner_smul_right,real_inner_self_eq_norm_sq] at ho + have hcoef : (Real.sqrt (‖mode.val.1‖^2))⁻¹*‖mode.val.1‖^2 ≠ 0 := + mul_ne_zero (inv_ne_zero (Real.sqrt_pos.mpr mode_mass_positive).ne') mode_mass_positive.ne' + have hc : c = 0 := (mul_eq_zero.mp ho).resolve_right hcoef + have hu0 : u.val.1 = 0 := by simpa only [hc,zero_smul] using hu + have hgrad : ‖u.val.2‖^2 = 0 := by + simp only [shiftedForm,form,hu0,map_zero,inner_zero_left,norm_zero,zero_pow (by decide : (2:ℕ) ≠ 0), + mul_zero,add_zero] at hzero + linarith + have hg0 : u.val.2 = 0 := norm_eq_zero.mp (sq_eq_zero_iff.mp hgrad) + apply Subtype.ext + exact Prod.ext hu0 hg0 + +/-- Positive gap above the actual manufactured well's attained ground mode. -/ +theorem manufacturedPlanarWell_gap_proved : + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, + inner ℝ u.val.1 normalizedMode.val.1 = 0 → + ((-1/2:ℝ)+γ)*‖u.val.1‖^2 ≤ form u.val := + planar_gap_of_ground_uniqueness zero_ground_form_orthogonal + +end ContinuumCoulomb.PlanarSobolev + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..283271f58608e097bb89d3feeac40ab36aa92482 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxBounds.lean @@ -0,0 +1,101 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatDensityModulus + +namespace OAI + +/-! Explicit coordinate bounds on the fixed forcing square. They turn +the kernel estimates into concrete quadrature constants for every input +point, with polynomial dependence on its magnitude. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem planarPair_norm_sq (p : ℝ × ℝ) : + ‖planarPairEquiv.symm p‖ ^ 2 = p.1 ^ 2 + p.2 ^ 2 := by + rw [EuclideanSpace.norm_sq_eq, planarPairEquiv_symm_apply] + simp only [Fin.sum_univ_two, Matrix.cons_val_zero, + Matrix.cons_val_one, Matrix.cons_val_fin_one, Real.norm_eq_abs, sq_abs] + +theorem planarPair_norm_le_two {p : ℝ × ℝ} + (hp : p ∈ Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1) : + ‖planarPairEquiv.symm p‖ ≤ 2 := by + have h1 : p.1 ^ 2 ≤ 1 := by + have hz := mul_nonneg (sub_nonneg.mpr hp.1.2) (show 0 ≤ 1 + p.1 by linarith [hp.1.1]) + nlinarith + have h2 : p.2 ^ 2 ≤ 1 := by + have hz := mul_nonneg (sub_nonneg.mpr hp.2.2) (show 0 ≤ 1 + p.2 by linarith [hp.2.1]) + nlinarith + have hn := planarPair_norm_sq p + nlinarith [norm_nonneg (planarPairEquiv.symm p)] + +theorem planarPair_distance_first (x x' y : ℝ) : + ‖planarPairEquiv.symm (x, y) - planarPairEquiv.symm (x', y)‖ = |x - x'| := by + have heq : planarPairEquiv.symm (x, y) - planarPairEquiv.symm (x', y) = + planarPairEquiv.symm (x - x', 0) := by + rw [planarPairEquiv_symm_apply, planarPairEquiv_symm_apply, planarPairEquiv_symm_apply] + ext i + fin_cases i <;> simp + rw [heq] + have h := planarPair_norm_sq (x - x', 0) + nlinarith [norm_nonneg (planarPairEquiv.symm (x - x', 0)), abs_nonneg (x - x'), sq_abs (x - x')] + +theorem planarPair_distance_second (x y y' : ℝ) : + ‖planarPairEquiv.symm (x, y) - planarPairEquiv.symm (x, y')‖ = |y - y'| := by + have heq : planarPairEquiv.symm (x, y) - planarPairEquiv.symm (x, y') = + planarPairEquiv.symm (0, y - y') := by + rw [planarPairEquiv_symm_apply, planarPairEquiv_symm_apply, planarPairEquiv_symm_apply] + ext i + fin_cases i <;> simp + rw [heq] + have h := planarPair_norm_sq (0, y - y') + nlinarith [norm_nonneg (planarPairEquiv.symm (0, y - y')), abs_nonneg (y - y'), sq_abs (y - y')] + +theorem planarPair_distance_bound (r : PlanarPosition) {p : ℝ × ℝ} + (hp : p ∈ Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1) : + ‖r - planarPairEquiv.symm p‖ ≤ ‖r‖ + 2 := + (norm_sub_le _ _).trans (add_le_add_right (planarPair_norm_le_two hp) _) + +def planarBoxSpatialConstant (r : PlanarPosition) (η : ℝ) : ℝ := + 2 * (‖r‖ + 2) / η ^ 2 + 32 * η⁻¹ + +def planarBoxTimeConstant (r : PlanarPosition) (η : ℝ) : ℝ := + η⁻¹ ^ 2 + η⁻¹ * (1 + (‖r‖ + 2) ^ 2 / (4 * η ^ 2)) + +theorem planarBox_spatial_first (r : PlanarPosition) {η t x x' y : ℝ} + (hη : 0 < η) (ht : η ≤ t) + (hx : x ∈ Set.Icc (-1 : ℝ) 1) (hx' : x' ∈ Set.Icc (-1 : ℝ) 1) + (hy : y ∈ Set.Icc (-1 : ℝ) 1) : + |HeatKernelModulus.density r t (planarPairEquiv.symm (x, y)) - + HeatKernelModulus.density r t (planarPairEquiv.symm (x', y))| ≤ + planarBoxSpatialConstant r η * |x - x'| := by + simpa only [planarPair_distance_first, planarBoxSpatialConstant] using + HeatKernelModulus.density_space_lipschitz hη ht + (planarPair_distance_bound r (p := (x, y)) ⟨hx, hy⟩) + (planarPair_distance_bound r (p := (x', y)) ⟨hx', hy⟩) + +theorem planarBox_spatial_second (r : PlanarPosition) {η t x y y' : ℝ} + (hη : 0 < η) (ht : η ≤ t) + (hx : x ∈ Set.Icc (-1 : ℝ) 1) (hy : y ∈ Set.Icc (-1 : ℝ) 1) + (hy' : y' ∈ Set.Icc (-1 : ℝ) 1) : + |HeatKernelModulus.density r t (planarPairEquiv.symm (x, y)) - + HeatKernelModulus.density r t (planarPairEquiv.symm (x, y'))| ≤ + planarBoxSpatialConstant r η * |y - y'| := by + simpa only [planarPair_distance_second, planarBoxSpatialConstant] using + HeatKernelModulus.density_space_lipschitz hη ht + (planarPair_distance_bound r (p := (x, y)) ⟨hx, hy⟩) + (planarPair_distance_bound r (p := (x, y')) ⟨hx, hy'⟩) + +theorem planarBox_time (r : PlanarPosition) {η t s x y : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) + (hx : x ∈ Set.Icc (-1 : ℝ) 1) (hy : y ∈ Set.Icc (-1 : ℝ) 1) : + |HeatKernelModulus.density r t (planarPairEquiv.symm (x, y)) - + HeatKernelModulus.density r s (planarPairEquiv.symm (x, y))| ≤ + planarBoxTimeConstant r η * |t - s| := + HeatKernelModulus.density_time_lipschitz hη ht hs + (planarPair_distance_bound r (p := (x, y)) ⟨hx, hy⟩) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2517d8cd2fe38859ec490587d07041adb2da860 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatBoxCoordinates.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatKernelModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatEvolution +import Mathlib.MeasureTheory.Constructions.Pi + +namespace OAI + +/-! Exact two-coordinate box formula for the actual heat average. +The forcing vanishes outside this fixed square, so spatial truncation +introduces no error. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarPairEquiv : PlanarPosition ≃ᵐ ℝ × ℝ := + (MeasurableEquiv.toLp 2 (Fin 2 → ℝ)).symm.trans + (MeasurableEquiv.piFinTwo (fun _ : Fin 2 => ℝ)) + +theorem planarPairEquiv_apply (r : PlanarPosition) : planarPairEquiv r = (r 0, r 1) := rfl + +theorem planarPairEquiv_symm_apply (p : ℝ × ℝ) : + planarPairEquiv.symm p = WithLp.toLp 2 ![p.1, p.2] := by + ext i + fin_cases i <;> rfl + +theorem planarPairEquiv_measurePreserving : MeasurePreserving planarPairEquiv := + (volume_preserving_piFinTwo (fun _ : Fin 2 => ℝ)).comp + (EuclideanSpace.volume_preserving_symm_measurableEquiv_toLp (Fin 2)) + +theorem planarPairEquiv_symm_continuous : Continuous planarPairEquiv.symm := by + rw [show (planarPairEquiv.symm : (ℝ × ℝ) → PlanarPosition) = + (fun p => WithLp.toLp 2 ![p.1, p.2]) from funext planarPairEquiv_symm_apply] + exact (PiLp.continuous_toLp 2 (fun _ : Fin 2 => ℝ)).comp (by fun_prop) + +theorem planarPair_integral (f : PlanarPosition → ℝ) : + (∫ r, f r) = ∫ p, f (planarPairEquiv.symm p) := by + have h := planarPairEquiv_measurePreserving.integral_comp' (f ∘ planarPairEquiv.symm) + simpa only [Function.comp_apply, MeasurableEquiv.symm_apply_apply] using h + +theorem planarForcing_pair_zero {p : ℝ × ℝ} + (hp : p ∉ Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1) : + planarForcing (planarPairEquiv.symm p) = 0 := by + apply planarForcing_zero_of_norm_ge_one + have h0 : |p.1| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_zero, + Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 0 + have h1 : |p.2| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_one, + Matrix.cons_val_fin_one, Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 1 + by_contra h + have hn : ‖planarPairEquiv.symm p‖ < 1 := lt_of_not_ge h + apply hp + exact ⟨⟨by linarith [neg_abs_le p.1], by linarith [le_abs_self p.1]⟩, + ⟨by linarith [neg_abs_le p.2], by linarith [le_abs_self p.2]⟩⟩ + +theorem planarHeatAverage_box (t : ℝ) (r : PlanarPosition) : + planarHeatAverage t r = ∫ x in (-1 : ℝ)..1, ∫ y in (-1 : ℝ)..1, + planarHeatKernel t (r - planarPairEquiv.symm (x, y)) * + planarForcing (planarPairEquiv.symm (x, y)) := by + rw [planarHeatAverage_flip, planarPair_integral] + let f := fun p : ℝ × ℝ => planarHeatKernel t (r - planarPairEquiv.symm p) * + planarForcing (planarPairEquiv.symm p) + have hf : Continuous f := + ((planarHeatKernel_continuous t).comp (continuous_const.sub planarPairEquiv_symm_continuous)).mul + (planarForcing_C7.continuous.comp planarPairEquiv_symm_continuous) + have hi : IntegrableOn f (Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1) + ((volume : Measure ℝ).prod volume) := + hf.continuousOn.integrableOn_compact (isCompact_Icc.prod isCompact_Icc) + have hs : (∫ p, f p) = ∫ p in Set.Icc (-1 : ℝ) 1 ×ˢ Set.Icc (-1 : ℝ) 1, f p := by + symm + apply setIntegral_eq_integral_of_forall_compl_eq_zero + intro p hp + simp only [f, planarForcing_pair_zero hp, mul_zero] + change (∫ p, f p) = _ + rw [hs] + rw [Measure.volume_eq_prod, setIntegral_prod f hi] + simp_rw [integral_Icc_eq_integral_Ioc, + ← intervalIntegral.integral_of_le (by norm_num : (-1 : ℝ) ≤ 1)] + rfl + +theorem planarHeatResolvent_box (t : ℝ) (r : PlanarPosition) : + Real.exp (-t) * planarHeatAverage t r = + ∫ x in (-1 : ℝ)..1, ∫ y in (-1 : ℝ)..1, + HeatKernelModulus.kernel t (‖r - planarPairEquiv.symm (x, y)‖ ^ 2) * + planarForcing (planarPairEquiv.symm (x, y)) := by + rw [planarHeatAverage_box, ← intervalIntegral.integral_const_mul] + congr 1 + funext x + rw [← intervalIntegral.integral_const_mul] + congr 1 + funext y + rw [HeatKernelModulus.kernel_eq_heat] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatDifferential.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatDifferential.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dcc249eb900a83d7e10becaa823910820b36a5d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatDifferential.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatLimit +import Mathlib.Analysis.Calculus.ParametricIntegral + +namespace OAI + +/-! Pointwise differential identities for the actual two-dimensional Gaussian +kernel. Its time derivative is its coordinate Laplacian. -/ + +noncomputable section +open MeasureTheory +open scoped RealInnerProductSpace BigOperators +namespace ContinuumCoulomb + +theorem planarHeatKernel_C2 (t : ℝ) : ContDiff ℝ 2 (planarHeatKernel t) := by + unfold planarHeatKernel + exact contDiff_const.mul (((contDiff_norm_sq ℝ).neg.div_const (4 * t)).exp) + +def planarHeatTimeDerivative (t : ℝ) (r : PlanarPosition) : ℝ := + (‖r‖ ^ 2 / (4 * t ^ 2) - 1 / t) * planarHeatKernel t r + +theorem planarHeatKernel_hasDerivAt {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + HasDerivAt (fun s => planarHeatKernel s r) (planarHeatTimeDerivative t r) t := by + have hi := hasDerivAt_inv ht.ne' + have h := (hi.const_mul ((4 * Real.pi)⁻¹)).mul + ((hi.const_mul (-‖r‖ ^ 2 / 4)).exp) + convert h using 1 + · funext s + change planarHeatKernel s r = (4 * Real.pi)⁻¹ * s⁻¹ * Real.exp (-‖r‖ ^ 2 / 4 * s⁻¹) + unfold planarHeatKernel + congr 1 <;> ring_nf + · dsimp [planarHeatTimeDerivative, planarHeatKernel] + have he : -‖r‖ ^ 2 / (4 * t) = -‖r‖ ^ 2 / 4 * t⁻¹ := by ring + rw [he] + field_simp + ring + +theorem planarHeatKernel_partial (t : ℝ) (e r : PlanarPosition) : + planarPartial (planarHeatKernel t) e r = + (-inner ℝ e r / (2 * t)) * planarHeatKernel t r := by + have hd := ((((hasStrictFDerivAt_norm_sq r).hasFDerivAt.neg).mul_const (4 * t)⁻¹).exp).const_mul + ((4 * Real.pi * t)⁻¹) + change fderiv ℝ (planarHeatKernel t) r e = _ + rw [show fderiv ℝ (planarHeatKernel t) r = _ from hd.fderiv] + simp only [smul_apply, smul_eq_mul, neg_apply, Pi.neg_apply, + innerSL_apply_apply, planarHeatKernel] + rw [real_inner_comm r e] + ring_nf + +theorem planarHeatKernel_partial_partial (t : ℝ) (e r : PlanarPosition) : + planarPartial (planarPartial (planarHeatKernel t) e) e r = + ((inner ℝ e r) ^ 2 / (4 * t ^ 2) - ‖e‖ ^ 2 / (2 * t)) * planarHeatKernel t r := by + have hlin : ContDiff ℝ 1 (fun s : PlanarPosition => -inner ℝ e s / (2 * t)) := + ((innerSL ℝ e).contDiff.neg).div_const _ + have heq : planarPartial (planarHeatKernel t) e = + fun s => (-inner ℝ e s / (2 * t)) * planarHeatKernel t s := + funext (planarHeatKernel_partial t e) + rw [heq, planarPartial_mul _ _ hlin ((planarHeatKernel_C2 t).of_le (by norm_num)), + planarHeatKernel_partial] + have hpart : planarPartial (fun s : PlanarPosition => -inner ℝ e s / (2 * t)) e r = + -‖e‖ ^ 2 / (2 * t) := by + have hd := ((innerSL ℝ e).hasFDerivAt (x := r)).neg.mul_const (2 * t)⁻¹ + have hd' : HasFDerivAt (fun s : PlanarPosition => -inner ℝ e s / (2 * t)) + ((2 * t)⁻¹ • -(innerSL ℝ e)) r := by + simpa only [Pi.neg_apply, innerSL_apply_apply, div_eq_mul_inv] using hd + change fderiv ℝ (fun s : PlanarPosition => -inner ℝ e s / (2 * t)) r e = _ + rw [hd'.fderiv] + simp only [smul_apply, smul_eq_mul, neg_apply, + innerSL_apply_apply, real_inner_self_eq_norm_sq] + ring + rw [hpart] + ring + +theorem planarHeatKernel_laplacian (t : ℝ) (r : PlanarPosition) : + planarLaplacian (planarHeatKernel t) r = planarHeatTimeDerivative t r := by + have hn : ‖r‖ ^ 2 = ∑ a : Fin 2, (r a) ^ 2 := by + simpa only [Real.norm_eq_abs, sq_abs] using EuclideanSpace.norm_sq_eq r + have ha (a : Fin 2) : inner ℝ (planarAxis a) r = r a := by + simp [planarAxis, EuclideanSpace.inner_single_left] + have he (a : Fin 2) : ‖planarAxis a‖ ^ 2 = 1 := by simp [planarAxis] + simp only [planarLaplacian, planarHeatKernel_partial_partial, ha, he, + planarHeatTimeDerivative, hn, Fin.sum_univ_two] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatEvolution.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatEvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4499ee52b6684764f3f6c35254220c7ca3e7825 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatEvolution.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatDifferential + +namespace OAI + +/-! Differentiation in time of the actual heat average. The compact forcing +allows a fixed compact dominating set on every positive time neighborhood. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem planarHeatAverage_flip (t : ℝ) (r : PlanarPosition) : + planarHeatAverage t r = ∫ b, planarHeatKernel t (r - b) * planarForcing b := by + unfold planarHeatAverage + rw [← integral_sub_left_eq_self _ volume r] + simp only [sub_sub_self] + +theorem planarHeatKernel_joint_continuousAt {p : ℝ × PlanarPosition} (hp : 0 < p.1) : + ContinuousAt (fun q : ℝ × PlanarPosition => planarHeatKernel q.1 q.2) p := by + have h4 : 4 * p.1 ≠ 0 := by positivity + have hpi : 4 * Real.pi * p.1 ≠ 0 := by positivity + unfold planarHeatKernel + fun_prop + +theorem planarHeatTimeDerivative_joint_continuousAt {p : ℝ × PlanarPosition} (hp : 0 < p.1) : + ContinuousAt (fun q : ℝ × PlanarPosition => planarHeatTimeDerivative q.1 q.2) p := by + have h4 : 4 * p.1 ^ 2 ≠ 0 := by positivity + have hne : p.1 ≠ 0 := hp.ne' + unfold planarHeatTimeDerivative + exact ((continuous_snd.norm.pow 2).continuousAt.div + (continuous_const.mul (continuous_fst.pow 2)).continuousAt h4).sub + (continuous_const.continuousAt.div continuous_fst.continuousAt hne) |>.mul + (planarHeatKernel_joint_continuousAt hp) + +theorem planarHeatTimeDerivative_forcing_continuous (t : ℝ) (r : PlanarPosition) : + Continuous (fun b => planarHeatTimeDerivative t (r - b) * planarForcing b) := by + have hg : Continuous (fun b : PlanarPosition => planarHeatTimeDerivative t (r - b)) := by + unfold planarHeatTimeDerivative planarHeatKernel + fun_prop + exact hg.mul planarForcing_C7.continuous + +theorem planarHeatTimeDerivative_forcing_joint_continuousAt (r : PlanarPosition) + {p : ℝ × PlanarPosition} (hp : 0 < p.1) : + ContinuousAt (fun q : ℝ × PlanarPosition => + planarHeatTimeDerivative q.1 (r - q.2) * planarForcing q.2) p := by + have h4 : 4 * p.1 ≠ 0 := by positivity + have h42 : 4 * p.1 ^ 2 ≠ 0 := by positivity + have hpi : 4 * Real.pi * p.1 ≠ 0 := by positivity + have hne : p.1 ≠ 0 := hp.ne' + have hcomp : ContinuousAt (fun q : ℝ × PlanarPosition => planarHeatTimeDerivative q.1 (r - q.2)) p := by + unfold planarHeatTimeDerivative planarHeatKernel + fun_prop + have hf : Continuous (fun q : ℝ × PlanarPosition => planarForcing q.2) := + planarForcing_C7.continuous.comp continuous_snd + exact hcomp.mul hf.continuousAt + +theorem planarHeatTimeDerivative_local_bound {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + ∃ bound : PlanarPosition → ℝ, Integrable bound ∧ + ∀ b s, s ∈ Set.Ioo (t / 2) (3 * t / 2) → + ‖planarHeatTimeDerivative s (r - b) * planarForcing b‖ ≤ bound b := by + let S : Set (ℝ × PlanarPosition) := Set.Icc (t / 2) (3 * t / 2) ×ˢ tsupport planarForcing + let F : ℝ × PlanarPosition → ℝ := fun p => + planarHeatTimeDerivative p.1 (r - p.2) * planarForcing p.2 + have hS : IsCompact S := isCompact_Icc.prod planarForcing_hasCompactSupport + have hF : ContinuousOn F S := by + intro p hp + have hpos : 0 < p.1 := lt_of_lt_of_le (by linarith) hp.1.1 + exact (planarHeatTimeDerivative_forcing_joint_continuousAt r hpos).continuousWithinAt + obtain ⟨C, hC⟩ := hS.bddAbove_image hF.norm + let bound : PlanarPosition → ℝ := (tsupport planarForcing).indicator (fun _ => max 0 C) + refine ⟨bound, ?_, ?_⟩ + · exact (integrable_indicator_iff (isClosed_tsupport _).measurableSet).mpr + (integrableOn_const planarForcing_hasCompactSupport.measure_ne_top) + · intro b s hs + by_cases hb : b ∈ tsupport planarForcing + · have hf : ‖F (s, b)‖ ≤ C := hC ⟨(s, b), ⟨⟨hs.1.le, hs.2.le⟩, hb⟩, rfl⟩ + simpa only [bound, Set.indicator_of_mem hb] using hf.trans (le_max_right 0 C) + · simp only [bound, Set.indicator_of_notMem hb, image_eq_zero_of_notMem_tsupport hb, + mul_zero, norm_zero, le_refl] + +theorem planarHeatAverage_hasDerivAt {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + HasDerivAt (fun s => planarHeatAverage s r) + (∫ b, planarHeatTimeDerivative t (r - b) * planarForcing b) t := by + obtain ⟨bound, hbi, hb⟩ := planarHeatTimeDerivative_local_bound ht r + have hn : Set.Ioo (t / 2) (3 * t / 2) ∈ 𝓝 t := Ioo_mem_nhds (by linarith) (by linarith) + have hi : Integrable (fun b => planarHeatKernel t (r - b) * planarForcing b) := + ((planarHeatKernel_continuous t).comp (continuous_const.sub continuous_id) + |>.mul planarForcing_C7.continuous).integrable_of_hasCompactSupport + planarForcing_hasCompactSupport.mul_left + have hmeas : ∀ᶠ s in 𝓝 t, + AEStronglyMeasurable (fun b => planarHeatKernel s (r - b) * planarForcing b) := + Eventually.of_forall (fun s => ((planarHeatKernel_continuous s).comp + (continuous_const.sub continuous_id) |>.mul planarForcing_C7.continuous).aestronglyMeasurable) + have hd := hasDerivAt_integral_of_dominated_loc_of_deriv_le + (F := fun s b => planarHeatKernel s (r - b) * planarForcing b) + (F' := fun s b => planarHeatTimeDerivative s (r - b) * planarForcing b) + hn hmeas hi (planarHeatTimeDerivative_forcing_continuous t r).aestronglyMeasurable + (Eventually.of_forall hb) hbi + (Eventually.of_forall (fun b s hs => (planarHeatKernel_hasDerivAt + (by linarith [hs.1] : 0 < s) (r - b)).mul_const (planarForcing b))) + simpa only [← planarHeatAverage_flip] using hd.2 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatKernel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc668da121d93642a9365bab85d8a23a81bc25e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatKernel.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcing +import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform + +namespace OAI + +/-! The actual normalized two-dimensional Gaussian heat kernel and its +convolution with the paper's explicit forcing. These prepare the positive +resolvent mode, rather than assuming the manufactured well exists. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarHeatKernel (t : ℝ) (r : PlanarPosition) : ℝ := + (4 * Real.pi * t)⁻¹ * Real.exp (-‖r‖ ^ 2 / (4 * t)) + +theorem planarHeatKernel_positive {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + 0 < planarHeatKernel t r := by + exact mul_pos (inv_pos.mpr (by positivity)) (Real.exp_pos _) + +theorem planarHeatKernel_continuous (t : ℝ) : Continuous (planarHeatKernel t) := by + unfold planarHeatKernel + fun_prop + +theorem planar_gaussian_integrable {b : ℝ} (hb : 0 < b) : + Integrable (fun r : PlanarPosition => Real.exp (-b * ‖r‖ ^ 2)) := by + have h := GaussianFourier.integrable_cexp_neg_mul_sq_norm_add + (V := PlanarPosition) (b := (b : ℂ)) (by simpa using hb) 0 0 + have hc : Integrable (fun r : PlanarPosition => Complex.exp ((-b * ‖r‖ ^ 2 : ℝ) : ℂ)) := by + simpa only [zero_mul, add_zero, Complex.ofReal_mul, Complex.ofReal_neg, + Complex.ofReal_pow] using h + simpa only [Complex.norm_exp, Complex.ofReal_re] using hc.norm + +theorem planarHeatKernel_integrable {t : ℝ} (ht : 0 < t) : + Integrable (planarHeatKernel t) := by + unfold planarHeatKernel + have h := (planar_gaussian_integrable (b := (4 * t)⁻¹) (by positivity)).const_mul + ((4 * Real.pi * t)⁻¹) + convert h using 1 + funext r + congr 2 + ring + +theorem planarHeatKernel_integral {t : ℝ} (ht : 0 < t) : + (∫ r, planarHeatKernel t r) = 1 := by + have heq : (fun r : PlanarPosition => Real.exp (-‖r‖ ^ 2 / (4 * t))) = + (fun r : PlanarPosition => Real.exp (-(4 * t)⁻¹ * ‖r‖ ^ 2)) := by + funext r + congr 1 + ring + unfold planarHeatKernel + rw [integral_const_mul, heq, + GaussianFourier.integral_rexp_neg_mul_sq_norm (by positivity : 0 < (4 * t)⁻¹)] + norm_num [finrank_euclideanSpace_fin] + field_simp [ht.ne', Real.pi_ne_zero] + +def planarHeatAverage (t : ℝ) (r : PlanarPosition) : ℝ := + ∫ b, planarHeatKernel t b * planarForcing (r - b) + +theorem planarHeatAverage_integrand_integrable {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + Integrable (fun b => planarHeatKernel t b * planarForcing (r - b)) := by + apply (planarHeatKernel_integrable ht).mul_bdd + ((planarForcing_C7.continuous.comp (continuous_const.sub continuous_id)).aestronglyMeasurable) + exact Filter.Eventually.of_forall (fun b => by + change ‖planarForcing (r - b)‖ ≤ (1 : ℝ) + rw [Real.norm_eq_abs, abs_of_nonneg (planarForcing_nonnegative _)] + exact planarForcing_le_one _) + +theorem planarHeatAverage_positive {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + 0 < planarHeatAverage t r := by + apply integral_pos_of_integrable_nonneg_nonzero + ((planarHeatKernel_continuous t).mul + (planarForcing_C7.continuous.comp (continuous_const.sub continuous_id))) + (planarHeatAverage_integrand_integrable ht r) + (fun b => mul_nonneg (planarHeatKernel_positive ht b).le (planarForcing_nonnegative _)) + change planarHeatKernel t r * planarForcing (r - r) ≠ 0 + simpa only [sub_self, planarForcing_zero, mul_one] using (planarHeatKernel_positive ht r).ne' + +theorem planarHeatAverage_le_one {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + planarHeatAverage t r ≤ 1 := by + rw [← planarHeatKernel_integral ht] + apply integral_mono (planarHeatAverage_integrand_integrable ht r) (planarHeatKernel_integrable ht) + intro b + exact mul_le_of_le_one_right (planarHeatKernel_positive ht b).le (planarForcing_le_one _) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatLimit.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatLimit.lean new file mode 100644 index 0000000000000000000000000000000000000000..d37114035e1fe90db047a5a5b6a8f55117328ef5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatLimit.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatKernel +import Mathlib.MeasureTheory.Integral.DominatedConvergence +import Mathlib.MeasureTheory.Measure.Haar.NormedSpace + +namespace OAI + +/-! The Gaussian change of scale and the actual time-zero limit of the heat +average. The bound by the normalized time-one Gaussian permits dominated +convergence even though the Gaussian has noncompact support. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem planarHeatKernel_sqrt_scale {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + planarHeatKernel t (Real.sqrt t • r) = t⁻¹ * planarHeatKernel 1 r := by + have hs : Real.sqrt t ^ 2 = t := Real.sq_sqrt ht.le + rw [planarHeatKernel, planarHeatKernel, norm_smul, Real.norm_eq_abs, + abs_of_nonneg (Real.sqrt_nonneg _), mul_pow, hs] + have he : -(t * ‖r‖ ^ 2) / (4 * t) = -‖r‖ ^ 2 / (4 * 1) := by + field_simp + rw [he] + ring + +theorem planarHeatAverage_scaled {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + planarHeatAverage t r = ∫ b, planarHeatKernel 1 b * planarForcing (r - Real.sqrt t • b) := by + have hi := Measure.integral_comp_smul_of_nonneg (volume : Measure PlanarPosition) + (fun b => planarHeatKernel t b * planarForcing (r - b)) (Real.sqrt t) + (hR := Real.sqrt_nonneg t) + simp only [finrank_euclideanSpace_fin, Real.sq_sqrt ht.le, smul_eq_mul, + planarHeatKernel_sqrt_scale ht] at hi + simp_rw [mul_assoc] at hi + rw [integral_const_mul] at hi + exact (mul_left_cancel₀ (inv_ne_zero ht.ne') hi).symm + +theorem planarScaledHeatIntegrand_measurable (t : ℝ) (r : PlanarPosition) : + AEStronglyMeasurable (fun b => planarHeatKernel 1 b * + planarForcing (r - Real.sqrt t • b)) := by + have hc : Continuous (fun b : PlanarPosition => r - Real.sqrt t • b) := by fun_prop + exact ((planarHeatKernel_continuous 1).mul + (planarForcing_C7.continuous.comp hc)).aestronglyMeasurable + +theorem planarScaledHeatIntegrand_bound (t : ℝ) (r b : PlanarPosition) : + ‖planarHeatKernel 1 b * planarForcing (r - Real.sqrt t • b)‖ ≤ planarHeatKernel 1 b := by + have hk : 0 < planarHeatKernel 1 b := planarHeatKernel_positive (by norm_num) b + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg hk.le (planarForcing_nonnegative _))] + exact mul_le_of_le_one_right hk.le (planarForcing_le_one _) + +theorem planarScaledHeatIntegrand_tendsto (r b : PlanarPosition) : + Tendsto (fun t : ℝ => planarHeatKernel 1 b * planarForcing (r - Real.sqrt t • b)) + (𝓝[>] (0 : ℝ)) (𝓝 (planarHeatKernel 1 b * planarForcing r)) := by + have hs : Tendsto (fun t : ℝ => Real.sqrt t • b) (𝓝[>] 0) (𝓝 (0 : PlanarPosition)) := by + have hs0 : Tendsto Real.sqrt (𝓝 (0 : ℝ)) (𝓝 (Real.sqrt 0)) := + Real.continuous_sqrt.continuousAt.tendsto + simpa only [Real.sqrt_zero, zero_smul] using + (hs0.mono_left nhdsWithin_le_nhds).smul_const b + have hr : Tendsto (fun t : ℝ => r - Real.sqrt t • b) (𝓝[>] 0) (𝓝 r) := by + simpa only [sub_zero] using tendsto_const_nhds.sub hs + exact tendsto_const_nhds.mul (planarForcing_C7.continuous.continuousAt.tendsto.comp hr) + +theorem planarHeatAverage_tendsto_zero (r : PlanarPosition) : + Tendsto (fun t => planarHeatAverage t r) (𝓝[>] (0 : ℝ)) (𝓝 (planarForcing r)) := by + have hconv : Tendsto + (fun t : ℝ => ∫ b, planarHeatKernel 1 b * planarForcing (r - Real.sqrt t • b)) + (𝓝[>] (0 : ℝ)) (𝓝 (∫ b, planarHeatKernel 1 b * planarForcing r)) := by + apply tendsto_integral_filter_of_dominated_convergence + (F := fun t b => planarHeatKernel 1 b * planarForcing (r - Real.sqrt t • b)) + (f := fun b => planarHeatKernel 1 b * planarForcing r) + (bound := planarHeatKernel 1) + · exact Eventually.of_forall (fun t => planarScaledHeatIntegrand_measurable t r) + · exact Eventually.of_forall (fun t => Eventually.of_forall (fun b => + planarScaledHeatIntegrand_bound t r b)) + · exact planarHeatKernel_integrable (by norm_num) + · exact Eventually.of_forall (planarScaledHeatIntegrand_tendsto r) + have hv : (∫ b, planarHeatKernel 1 b * planarForcing r) = planarForcing r := by + rw [integral_mul_const, planarHeatKernel_integral (by norm_num), one_mul] + rw [hv] at hconv + apply hconv.congr' + filter_upwards [self_mem_nhdsWithin] with t ht + exact (planarHeatAverage_scaled ht r).symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTimeModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTimeModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..457a869bc2ad9f2a154e81d1000e38efded657ad --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTimeModulus.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.UniformSamplesOn + +namespace OAI + +/-! A concrete time modulus for the actual planar heat average, obtained +by integrating the pointwise density modulus over the fixed square. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarHeatTime_lipschitz (r : PlanarPosition) {η t s : ℝ} + (hη : 0 < η) (ht : η ≤ t) (hs : η ≤ s) : + |Real.exp (-t) * planarHeatAverage t r - Real.exp (-s) * planarHeatAverage s r| ≤ + 4 * planarBoxTimeConstant r η * |t - s| := by + let f := fun u x y => HeatKernelModulus.density r u (planarPairEquiv.symm (x, y)) + have hsec (u : ℝ) (hu : η ≤ u) (x : ℝ) (hx : x ∈ Set.Icc (-1 : ℝ) 1) : + ContinuousOn (f u x) (Set.Icc (-1 : ℝ) 1) := by + apply UniformQuadrature.continuousOn_of_abs_sub_le + intro y hy y' hy' + exact planarBox_spatial_second r hη hu hx hy hy' + have houter (u : ℝ) (hu : η ≤ u) : + ContinuousOn (fun x => ∫ y in (-1 : ℝ)..1, f u x y) (Set.Icc (-1 : ℝ) 1) := by + apply UniformQuadrature.continuousOn_of_abs_sub_le + intro x hx x' hx' + have h := UniformQuadrature.integral_parameter_lipschitz (f u) (by norm_num : (-1 : ℝ) ≤ 1) + (hsec u hu) (by + intro z hz z' hz' y hy + exact planarBox_spatial_first r hη hu hz hz' hy) hx hx' + convert h using 1 + have hinner (x : ℝ) (hx : x ∈ Set.Icc (-1 : ℝ) 1) : + |(∫ y in (-1 : ℝ)..1, f t x y) - ∫ y in (-1 : ℝ)..1, f s x y| ≤ + 2 * planarBoxTimeConstant r η * |t - s| := by + rw [← intervalIntegral.integral_sub + ((hsec t ht x hx).intervalIntegrable_of_Icc (by norm_num)) + ((hsec s hs x hx).intervalIntegrable_of_Icc (by norm_num))] + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (f := fun y => f t x y - f s x y) (a := -1) (b := 1) + (C := planarBoxTimeConstant r η * |t - s|) (by + intro y hy + have hy' : y ∈ Set.Icc (-1 : ℝ) 1 := by + have hy'' : y ∈ Set.Ioc (-1 : ℝ) 1 := by + simpa only [Set.uIoc_of_le (by norm_num : (-1 : ℝ) ≤ 1)] using hy + exact ⟨hy''.1.le, hy''.2⟩ + simpa only [Real.norm_eq_abs] using planarBox_time r hη ht hs hx hy') + rw [show (1 : ℝ) - -1 = 2 by norm_num, + abs_of_pos (by norm_num : (0 : ℝ) < 2), Real.norm_eq_abs] at h + convert h using 1 + ring + rw [planarHeatResolvent_box, planarHeatResolvent_box] + change |(∫ x in (-1 : ℝ)..1, ∫ y in (-1 : ℝ)..1, f t x y) - + ∫ x in (-1 : ℝ)..1, ∫ y in (-1 : ℝ)..1, f s x y| ≤ _ + rw [← intervalIntegral.integral_sub + ((houter t ht).intervalIntegrable_of_Icc (by norm_num)) + ((houter s hs).intervalIntegrable_of_Icc (by norm_num))] + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (f := fun x => (∫ y in (-1 : ℝ)..1, f t x y) - ∫ y in (-1 : ℝ)..1, f s x y) + (a := -1) (b := 1) (C := 2 * planarBoxTimeConstant r η * |t - s|) (by + intro x hx + have hx' : x ∈ Set.Icc (-1 : ℝ) 1 := by + have hx'' : x ∈ Set.Ioc (-1 : ℝ) 1 := by + simpa only [Set.uIoc_of_le (by norm_num : (-1 : ℝ) ≤ 1)] using hx + exact ⟨hx''.1.le, hx''.2⟩ + simpa only [Real.norm_eq_abs] using hinner x hx') + rw [show (1 : ℝ) - -1 = 2 by norm_num, + abs_of_pos (by norm_num : (0 : ℝ) < 2), Real.norm_eq_abs] at h + convert h using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTruncation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTruncation.lean new file mode 100644 index 0000000000000000000000000000000000000000..3308b3e587835dc1c9c98028a5a629119d485c8e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHeatTruncation.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolvent + +namespace OAI + +/-! Explicit time truncation for the actual resolvent representation. +The omitted short-time interval costs at most its length; the long-time +tail is at most the elementary exponential tail. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarTruncatedHeat (r : PlanarPosition) (η T : ℝ) : ℝ := + ∫ t in η..T, Real.exp (-t) * planarHeatAverage t r + +theorem planarHeatTime_nonnegative (r : PlanarPosition) {t : ℝ} (ht : 0 < t) : + 0 ≤ Real.exp (-t) * planarHeatAverage t r := + mul_nonneg (Real.exp_pos _).le (planarHeatAverage_positive ht r).le + +theorem planarHeatTime_le_exp (r : PlanarPosition) {t : ℝ} (ht : 0 < t) : + Real.exp (-t) * planarHeatAverage t r ≤ Real.exp (-t) := + mul_le_of_le_one_right (Real.exp_pos _).le (planarHeatAverage_le_one ht r) + +theorem planarHeatTime_short (r : PlanarPosition) {η : ℝ} (hη : 0 ≤ η) : + |∫ t in (0 : ℝ)..η, Real.exp (-t) * planarHeatAverage t r| ≤ η := by + have h := intervalIntegral.norm_integral_le_of_norm_le_const + (f := fun t => Real.exp (-t) * planarHeatAverage t r) (a := 0) (b := η) (C := 1) + (by + intro t ht + have ht' : t ∈ Set.Ioc (0 : ℝ) η := by simpa only [Set.uIoc_of_le hη] using ht + rw [Real.norm_eq_abs, abs_of_nonneg (planarHeatTime_nonnegative r ht'.1)] + exact (planarHeatTime_le_exp r ht'.1).trans + (Real.exp_le_one_iff.mpr (by linarith [ht'.1]))) + simpa only [Real.norm_eq_abs, sub_zero, abs_of_nonneg hη, one_mul] using h + +theorem planarHeatTime_tail (r : PlanarPosition) {T : ℝ} (hT : 0 ≤ T) : + |∫ t in Set.Ioi T, Real.exp (-t) * planarHeatAverage t r| ≤ Real.exp (-T) := by + have hn : 0 ≤ ∫ t in Set.Ioi T, Real.exp (-t) * planarHeatAverage t r := + integral_nonneg_of_ae (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact planarHeatTime_nonnegative r (lt_of_le_of_lt hT ht)) + rw [abs_of_nonneg hn] + have hi := (planarResolventMode_heat_integrable r).mono_set (Set.Ioi_subset_Ioi hT) + have he : IntegrableOn (fun t : ℝ => Real.exp (-t)) (Set.Ioi T) := by + simpa only [neg_mul, one_mul] using exp_neg_integrableOn_Ioi T (by norm_num : (0 : ℝ) < 1) + have hb := integral_mono_ae hi he (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact planarHeatTime_le_exp r (lt_of_le_of_lt hT ht)) + have ht : (∫ t in Set.Ioi T, Real.exp (-t)) = Real.exp (-T) := by + simpa using integral_exp_mul_Ioi (by norm_num : (-1 : ℝ) < 0) T + exact hb.trans_eq ht + +theorem planarTruncatedHeat_error (r : PlanarPosition) {η T : ℝ} + (hη : 0 ≤ η) (hηT : η ≤ T) : + |planarResolventMode r - planarTruncatedHeat r η T| ≤ η + Real.exp (-T) := by + let f := fun t => Real.exp (-t) * planarHeatAverage t r + have hi : IntegrableOn f (Set.Ioi 0) := planarResolventMode_heat_integrable r + have hηi : IntegrableOn f (Set.Ioi η) := hi.mono_set (Set.Ioi_subset_Ioi hη) + have hT : 0 ≤ T := hη.trans hηT + have hfirst := intervalIntegral.integral_Ioi_sub_Ioi hi hη + have hsecond := intervalIntegral.integral_Ioi_sub_Ioi hηi hηT + have heq : planarResolventMode r - planarTruncatedHeat r η T = + (∫ t in (0 : ℝ)..η, f t) + ∫ t in Set.Ioi T, f t := by + rw [planarResolventMode_heat_representation] + unfold planarTruncatedHeat + change (∫ t in Set.Ioi 0, f t) - (∫ t in η..T, f t) = _ + linarith + rw [heq] + exact (abs_add_le _ _).trans (add_le_add (planarHeatTime_short r hη) (planarHeatTime_tail r hT)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHopping.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHopping.lean new file mode 100644 index 0000000000000000000000000000000000000000..08e1dceefe7bdea8b3b362aadfa397c144f5fe36 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHopping.lean @@ -0,0 +1,129 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLowerTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDerivatives +import Mathlib.Analysis.Calculus.ContDiff.RCLike + +namespace OAI + +/-! The actual positive contact hopping integral. Its Lipschitz control is +inherited from the compact forcing through the mass-one resolvent kernel. -/ + +noncomputable section +open MeasureTheory +open scoped NNReal +namespace ContinuumCoulomb + +private theorem forcing_lipschitz_exists : ∃ C : ℝ≥0, LipschitzWith C planarForcing := + ContDiff.lipschitzWith_of_hasCompactSupport planarForcing_hasCompactSupport + planarForcing_C7 (by norm_num) + +def planarForcingLipschitzConstant : ℝ≥0 := Classical.choose forcing_lipschitz_exists + +theorem planarForcing_lipschitz : LipschitzWith planarForcingLipschitzConstant planarForcing := + Classical.choose_spec forcing_lipschitz_exists + +theorem planarResolventMode_integrand_integrable (r : PlanarPosition) : + Integrable (fun b => planarResolventKernel b * planarForcing (r - b)) := by + apply planarResolventKernel_integrable.mul_bdd (c := 1) + (planarForcing_C7.continuous.comp (continuous_const.sub continuous_id)).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun b => by + change ‖planarForcing (r - b)‖ ≤ (1 : ℝ) + rw [Real.norm_of_nonneg (planarForcing_nonnegative _)] + exact planarForcing_le_one _) + +theorem planarResolventMode_norm_sub (x y : PlanarPosition) : + ‖planarResolventMode x - planarResolventMode y‖ ≤ + planarForcingLipschitzConstant * ‖x - y‖ := by + unfold planarResolventMode + rw [← integral_sub (planarResolventMode_integrand_integrable x) + (planarResolventMode_integrand_integrable y)] + have h := norm_integral_le_of_norm_le + (f := fun b => planarResolventKernel b * planarForcing (x - b) - + planarResolventKernel b * planarForcing (y - b)) + (planarResolventKernel_integrable.mul_const + ((planarForcingLipschitzConstant : ℝ) * ‖x - y‖)) + (Filter.Eventually.of_forall (fun b => by + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (planarResolventKernel_nonnegative b)] + apply mul_le_mul_of_nonneg_left _ (planarResolventKernel_nonnegative b) + have h := planarForcing_lipschitz.norm_sub_le (x - b) (y - b) + simpa only [show x - b - (y - b) = x - y by abel] using h)) + simpa only [integral_mul_const, planarResolventKernel_integral, one_mul] using h + +theorem planarResolventMode_lipschitz : + LipschitzWith planarForcingLipschitzConstant planarResolventMode := + LipschitzWith.of_dist_le_mul (by simpa only [dist_eq_norm] using planarResolventMode_norm_sub) + +def planarHoppingIntegrand (d : ℝ) (r : PlanarPosition) : ℝ := + planarForcing r * planarResolventMode (r - d • planarAxis 0) + +theorem planarHoppingIntegrand_continuous (d : ℝ) : Continuous (planarHoppingIntegrand d) := + planarForcing_C7.continuous.mul + (planarResolventMode_C7.continuous.comp (continuous_id.sub continuous_const)) + +theorem planarHoppingIntegrand_integrable (d : ℝ) : Integrable (planarHoppingIntegrand d) := + (planarHoppingIntegrand_continuous d).integrable_of_hasCompactSupport + planarForcing_hasCompactSupport.mul_right + +theorem planarHoppingIntegrand_nonnegative (d : ℝ) (r : PlanarPosition) : + 0 ≤ planarHoppingIntegrand d r := + mul_nonneg (planarForcing_nonnegative r) (planarResolventMode_positive _).le + +def planarHopping (d : ℝ) : ℝ := + (∫ r, planarHoppingIntegrand d r) / (2 * ∫ r, planarResolventMode r ^ 2) + +theorem planarHopping_positive (d : ℝ) : 0 < planarHopping d := by + apply div_pos _ (mul_pos (by norm_num) planarResolventMode_square_integral_positive) + apply integral_pos_of_integrable_nonneg_nonzero + (planarHoppingIntegrand_continuous d) (planarHoppingIntegrand_integrable d) + (planarHoppingIntegrand_nonnegative d) + change planarForcing 0 * planarResolventMode (0 - d • planarAxis 0) ≠ 0 + rw [planarForcing_zero, one_mul] + exact (planarResolventMode_positive _).ne' + +theorem planarAxis_zero_norm : ‖planarAxis 0‖ = 1 := by + simp [planarAxis] + +def planarHoppingLipschitzConstant : ℝ≥0 := + ⟨planarForcingLipschitzConstant * (∫ r, planarForcing r) / + (2 * ∫ r, planarResolventMode r ^ 2), by + exact div_nonneg (mul_nonneg (NNReal.coe_nonneg _) planarForcing_integral_positive.le) + (mul_nonneg (by norm_num) planarResolventMode_square_integral_positive.le)⟩ + +theorem planarHopping_norm_sub (d e : ℝ) : + ‖planarHopping d - planarHopping e‖ ≤ planarHoppingLipschitzConstant * ‖d - e‖ := by + have hden : 0 < 2 * ∫ r, planarResolventMode r ^ 2 := + mul_pos (by norm_num) planarResolventMode_square_integral_positive + have hb (r : PlanarPosition) : + ‖planarHoppingIntegrand d r - planarHoppingIntegrand e r‖ ≤ + planarForcing r * (planarForcingLipschitzConstant * ‖d - e‖) := by + unfold planarHoppingIntegrand + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (planarForcing_nonnegative r)] + apply mul_le_mul_of_nonneg_left _ (planarForcing_nonnegative r) + have h := planarResolventMode_norm_sub (r - d • planarAxis 0) (r - e • planarAxis 0) + have heq : ‖r - d • planarAxis 0 - (r - e • planarAxis 0)‖ = ‖d - e‖ := by + rw [show r - d • planarAxis 0 - (r - e • planarAxis 0) = + (e - d) • planarAxis 0 by rw [sub_smul]; abel, + norm_smul, planarAxis_zero_norm, mul_one, Real.norm_eq_abs, abs_sub_comm] + rfl + simpa only [heq] using h + have hi := norm_integral_le_of_norm_le + (planarForcing_integrable.mul_const ((planarForcingLipschitzConstant : ℝ) * ‖d - e‖)) + (Filter.Eventually.of_forall hb) + rw [integral_sub (planarHoppingIntegrand_integrable d) (planarHoppingIntegrand_integrable e), + integral_mul_const] at hi + unfold planarHopping + rw [← sub_div, norm_div, Real.norm_of_nonneg hden.le] + change _ ≤ (planarForcingLipschitzConstant * (∫ r, planarForcing r) / + (2 * ∫ r, planarResolventMode r ^ 2)) * ‖d - e‖ + calc + _ ≤ ((∫ r, planarForcing r) * (planarForcingLipschitzConstant * ‖d - e‖)) / + (2 * ∫ r, planarResolventMode r ^ 2) := div_le_div_of_nonneg_right hi hden.le + _ = _ := by ring + +theorem planarHopping_lipschitz : LipschitzWith planarHoppingLipschitzConstant planarHopping := + LipschitzWith.of_dist_le_mul (by simpa only [dist_eq_norm] using planarHopping_norm_sub) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHoppingBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHoppingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..71395e27f11a891ad292ecc5738ffa99264dc6bb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarHoppingBounds.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHopping + +namespace OAI + +/-! Matching exponential brackets for the actual contact hopping integral. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planar_contact_distance_bounds {r : PlanarPosition} {d : ℝ} + (hr : ‖r‖ ≤ 1) (hd : 2 ≤ d) : + d - 1 ≤ ‖r - d • planarAxis 0‖ ∧ ‖r - d • planarAxis 0‖ ≤ d + 1 := by + have hn : ‖d • planarAxis 0‖ = d := by + rw [norm_smul, planarAxis_zero_norm, mul_one, Real.norm_of_nonneg (by linarith)] + have h₁ : d ≤ ‖r‖ + ‖r - d • planarAxis 0‖ := by + calc + _ = ‖r - (r - d • planarAxis 0)‖ := by rw [show r - (r - d • planarAxis 0) = + d • planarAxis 0 by abel, hn] + _ ≤ _ := norm_sub_le _ _ + have h₂ := norm_sub_le r (d • planarAxis 0) + rw [hn] at h₂ + constructor <;> linarith + +theorem planarHopping_mode_upper {r : PlanarPosition} {d : ℝ} + (hr : ‖r‖ ≤ 1) (hd : 2 ≤ d) : + planarResolventMode (r - d • planarAxis 0) ≤ (d + 1) * Real.exp (3 - d) := by + obtain ⟨hlo, hhi⟩ := planar_contact_distance_bounds hr hd + calc + _ ≤ ‖r - d • planarAxis 0‖ * Real.exp (2 - ‖r - d • planarAxis 0‖) := + planarResolventMode_sharp_upper (by linarith) + _ ≤ _ := mul_le_mul hhi (Real.exp_le_exp.mpr (by linarith)) + (Real.exp_pos _).le (by linarith) + +theorem planarHopping_mode_lower {r : PlanarPosition} {d : ℝ} + (hr : ‖r‖ ≤ 1) (hd : 2 ≤ d) : + planarLowerTailConstant / (d + 3) * Real.exp (-(d + 1)) ≤ + planarResolventMode (r - d • planarAxis 0) := by + obtain ⟨hlo, hhi⟩ := planar_contact_distance_bounds hr hd + have hfrac : planarLowerTailConstant / (d + 3) ≤ + planarLowerTailConstant / (‖r - d • planarAxis 0‖ + 2) := + div_le_div_of_nonneg_left planarLowerTailConstant_positive.le (by positivity) (by linarith) + calc + _ ≤ planarLowerTailConstant / (‖r - d • planarAxis 0‖ + 2) * + Real.exp (-‖r - d • planarAxis 0‖) := + mul_le_mul hfrac (Real.exp_le_exp.mpr (by linarith)) (Real.exp_pos _).le + (div_nonneg planarLowerTailConstant_positive.le (by positivity)) + _ ≤ _ := planarResolventMode_sharp_lower (by linarith) + +def planarHoppingUpperConstant : ℝ := + Real.exp 3 * (∫ r, planarForcing r) / (2 * ∫ r, planarResolventMode r ^ 2) + +def planarHoppingLowerConstant : ℝ := + planarLowerTailConstant * Real.exp (-1) * (∫ r, planarForcing r) / + (2 * ∫ r, planarResolventMode r ^ 2) + +theorem planarHoppingUpperConstant_positive : 0 < planarHoppingUpperConstant := by + unfold planarHoppingUpperConstant + exact div_pos (mul_pos (Real.exp_pos _) planarForcing_integral_positive) + (mul_pos (by norm_num) planarResolventMode_square_integral_positive) + +theorem planarHoppingLowerConstant_positive : 0 < planarHoppingLowerConstant := by + unfold planarHoppingLowerConstant + exact div_pos (mul_pos (mul_pos planarLowerTailConstant_positive (Real.exp_pos _)) + planarForcing_integral_positive) + (mul_pos (by norm_num) planarResolventMode_square_integral_positive) + +theorem planarHopping_sharp_upper {d : ℝ} (hd : 2 ≤ d) : + planarHopping d ≤ planarHoppingUpperConstant * (d + 1) * Real.exp (-d) := by + have hpt (r : PlanarPosition) : planarHoppingIntegrand d r ≤ + planarForcing r * ((d + 1) * Real.exp (3 - d)) := by + by_cases hf : planarForcing r = 0 + · simp only [planarHoppingIntegrand, hf, zero_mul, le_refl] + have hr : ‖r‖ ≤ 1 := le_of_lt (lt_of_not_ge + (fun h => hf (planarForcing_zero_of_norm_ge_one h))) + exact mul_le_mul_of_nonneg_left (planarHopping_mode_upper hr hd) (planarForcing_nonnegative r) + have hi := integral_mono (planarHoppingIntegrand_integrable d) + (planarForcing_integrable.mul_const ((d + 1) * Real.exp (3 - d))) hpt + rw [integral_mul_const] at hi + have hden : 0 ≤ 2 * ∫ r, planarResolventMode r ^ 2 := by + positivity + have h := div_le_div_of_nonneg_right hi hden + unfold planarHopping planarHoppingUpperConstant + convert h using 1 + rw [show 3 - d = 3 + -d by ring, Real.exp_add] + ring + +theorem planarHopping_sharp_lower {d : ℝ} (hd : 2 ≤ d) : + planarHoppingLowerConstant / (d + 3) * Real.exp (-d) ≤ planarHopping d := by + have hpt (r : PlanarPosition) : + planarForcing r * (planarLowerTailConstant / (d + 3) * Real.exp (-(d + 1))) ≤ + planarHoppingIntegrand d r := by + by_cases hf : planarForcing r = 0 + · simp only [planarHoppingIntegrand, hf, zero_mul, le_refl] + have hr : ‖r‖ ≤ 1 := le_of_lt (lt_of_not_ge + (fun h => hf (planarForcing_zero_of_norm_ge_one h))) + exact mul_le_mul_of_nonneg_left (planarHopping_mode_lower hr hd) (planarForcing_nonnegative r) + have hi := integral_mono + (planarForcing_integrable.mul_const + (planarLowerTailConstant / (d + 3) * Real.exp (-(d + 1)))) + (planarHoppingIntegrand_integrable d) hpt + rw [integral_mul_const] at hi + have hden : 0 ≤ 2 * ∫ r, planarResolventMode r ^ 2 := by + positivity + have h := div_le_div_of_nonneg_right hi hden + unfold planarHopping planarHoppingLowerConstant + convert h using 1 + rw [show -(d + 1) = -1 + -d by ring, Real.exp_add] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMS.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMS.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b5d500ed851ab231e4e3ca1b7e043f22554d894 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMS.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundTransform + +namespace OAI + +/-! IMS localization for the actual planar kinetic and potential integrals. +The partition functions need not have compact support; the test function +does. In particular the exterior member of a multiwell partition is allowed. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarPartial_finsetSum {ι : Type*} (s : Finset ι) + (f : ι → PlanarPosition → ℝ) (hf : ∀ i ∈ s, ContDiff ℝ 1 (f i)) + (e x : PlanarPosition) : + planarPartial (fun y => ∑ i ∈ s, f i y) e x = ∑ i ∈ s, planarPartial (f i) e x := by + unfold planarPartial + rw [fderiv_fun_sum (fun i hi => (hf i hi).differentiable (by norm_num) x)] + simp only [sum_apply] + +theorem planar_partition_cross {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) (e x : PlanarPosition) : + ∑ i, θ i x * planarPartial (θ i) e x = 0 := by + have he : (fun y => ∑ i, θ i y * θ i y) = (fun _ : PlanarPosition => (1 : ℝ)) := by + funext y + simpa only [← sq] using hpart y + have hd := congrArg (fun f : PlanarPosition → ℝ => planarPartial f e x) he + rw [planarPartial_finsetSum _ _ (fun i _ => (hθ i).mul (hθ i))] at hd + simp_rw [planarPartial_mul _ _ (hθ _) (hθ _)] at hd + have hz : planarPartial (fun _ : PlanarPosition => (1 : ℝ)) e x = 0 := by + simp [planarPartial] + rw [hz, Finset.sum_add_distrib] at hd + linarith + +theorem planar_partition_gradient_identity {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (u : PlanarPosition → ℝ) (hu : ContDiff ℝ 1 u) (e x : PlanarPosition) : + (∑ i, planarPartial (fun y => θ i y * u y) e x ^ 2) = + planarPartial u e x ^ 2 + (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2 := by + simp_rw [planarPartial_mul _ _ (hθ _) hu] + calc + (∑ i, (θ i x * planarPartial u e x + u x * planarPartial (θ i) e x) ^ 2) = + (∑ i, θ i x ^ 2) * planarPartial u e x ^ 2 + + (2 * u x * planarPartial u e x) * (∑ i, θ i x * planarPartial (θ i) e x) + + (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2 := by + simp only [Finset.sum_mul, Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro i _ + ring + _ = _ := by rw [hpart x, planar_partition_cross θ hθ hpart e x]; ring + +theorem planar_partition_potential_identity {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (W u : PlanarPosition → ℝ) (x : PlanarPosition) : + (∑ i, W x * (θ i x * u x) ^ 2) = W x * u x ^ 2 := by + calc + (∑ i, W x * (θ i x * u x) ^ 2) = (W x * u x ^ 2) * ∑ i, θ i x ^ 2 := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + _ = _ := by rw [hpart x, mul_one] + +theorem planar_partition_direction_integral {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (u : PlanarPosition → ℝ) (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) + (e : PlanarPosition) : + (∑ i, ∫ x, planarPartial (fun y => θ i y * u y) e x ^ 2) = + (∫ x, planarPartial u e x ^ 2) + + ∫ x, (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2 := by + have hi (i : ι) : Integrable (fun x => planarPartial (fun y => θ i y * u y) e x ^ 2) := + planar_partial_square_integrable _ ((hθ i).mul hu) hc.mul_left e + have he : Integrable (fun x => (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2) := by + have hs : HasCompactSupport (fun x => u x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hm : HasCompactSupport (fun x => (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2) := + hs.mul_left + have hd : Continuous (fun x => ∑ i, planarPartial (θ i) e x ^ 2) := + continuous_finsetSum _ (fun i _ => (planarPartial_continuous (hθ i) e).pow 2) + exact (hd.mul (hu.continuous.pow 2)).integrable_of_hasCompactSupport hm + rw [← integral_finsetSum _ (fun i _ => hi i), + ← integral_add (planar_partial_square_integrable u hu hc e) he] + exact integral_congr_ae (Filter.Eventually.of_forall + (planar_partition_gradient_identity θ hθ hpart u hu e)) + +theorem planar_potential_test_integrable (W u : PlanarPosition → ℝ) (hW : Continuous W) + (hu : Continuous u) (hc : HasCompactSupport u) : Integrable (fun x => W x * u x ^ 2) := by + have hs : HasCompactSupport (fun x => u x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hm : HasCompactSupport (fun x => W x * u x ^ 2) := hs.mul_left + exact (hW.mul (hu.pow 2)).integrable_of_hasCompactSupport hm + +/-- Exact IMS formula, with the localization cost expressed through the +actual classical directional derivatives of the partition. -/ +theorem planar_IMS {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (W u : PlanarPosition → ℝ) (hW : Continuous W) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (∑ i, planarTestForm W (fun x => θ i x * u x)) = + planarTestForm W u + (1/2 : ℝ) * + ∑ a : Fin 2, ∫ x, (∑ i, planarPartial (θ i) (planarAxis a) x ^ 2) * u x ^ 2 := by + have hi (i : ι) : Integrable (fun x => W x * (θ i x * u x) ^ 2) := by + have hm : HasCompactSupport (fun x => θ i x * u x) := hc.mul_left + exact planar_potential_test_integrable W _ hW ((hθ i).continuous.mul hu.continuous) hm + have hp : (∑ i, ∫ x, W x * (θ i x * u x) ^ 2) = ∫ x, W x * u x ^ 2 := by + rw [← integral_finsetSum _ (fun i _ => hi i)] + exact integral_congr_ae (Filter.Eventually.of_forall + (planar_partition_potential_identity θ hpart W u)) + unfold planarTestForm + rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_comm] + simp_rw [planar_partition_direction_integral θ hθ hpart u hu hc] + rw [Finset.sum_add_distrib, hp] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMSBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMSBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a505c96ab31d002a86cab78d4692ad7758e817a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarIMSBounds.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSiteCutoffs + +namespace OAI + +/-! Quantitative IMS lower bounds, attached to the actual separated-site +partition. The error constant depends on one fixed bump and D, not on the +number of sites. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planar_localization_cost_integrable {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (u : PlanarPosition → ℝ) (hu : Continuous u) (hc : HasCompactSupport u) + (e : PlanarPosition) : + Integrable (fun x => (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2) := by + have hs : HasCompactSupport (fun x => u x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + have hm : HasCompactSupport (fun x => (∑ i, planarPartial (θ i) e x ^ 2) * u x ^ 2) := hs.mul_left + have hd : Continuous (fun x => ∑ i, planarPartial (θ i) e x ^ 2) := + continuous_finsetSum _ (fun i _ => (planarPartial_continuous (hθ i) e).pow 2) + exact (hd.mul (hu.pow 2)).integrable_of_hasCompactSupport hm + +theorem planar_IMS_cost_bound {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (u : PlanarPosition → ℝ) (hu : Continuous u) (hc : HasCompactSupport u) + {C : ℝ} (hbound : ∀ x, (∑ a : Fin 2, ∑ i, planarPartial (θ i) (planarAxis a) x ^ 2) ≤ C) : + (∑ a : Fin 2, ∫ x, (∑ i, planarPartial (θ i) (planarAxis a) x ^ 2) * u x ^ 2) ≤ + C * ∫ x, u x ^ 2 := by + have hi (a : Fin 2) := planar_localization_cost_integrable θ hθ u hu hc (planarAxis a) + have hs : Integrable (fun x => ∑ a : Fin 2, + (∑ i, planarPartial (θ i) (planarAxis a) x ^ 2) * u x ^ 2) := + integrable_finsetSum _ (fun a _ => hi a) + have hm : Integrable (fun x => C * u x ^ 2) := + planar_potential_test_integrable (fun _ => C) u continuous_const hu hc + rw [← integral_finsetSum _ (fun a _ => hi a), ← integral_const_mul] + apply integral_mono hs hm + intro x + dsimp only + rw [← Finset.sum_mul] + exact mul_le_mul_of_nonneg_right (hbound x) (sq_nonneg _) + +theorem planar_IMS_lower {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, ContDiff ℝ 1 (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (W u : PlanarPosition → ℝ) (hW : Continuous W) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) + {C : ℝ} (hbound : ∀ x, (∑ a : Fin 2, ∑ i, planarPartial (θ i) (planarAxis a) x ^ 2) ≤ C) : + (∑ i, planarTestForm W (fun x => θ i x * u x)) - (C/2) * (∫ x, u x ^ 2) ≤ + planarTestForm W u := by + have he := planar_IMS θ hθ hpart W u hW hu hc + have hb := planar_IMS_cost_bound θ hθ u hu.continuous hc hbound + linarith + +/-- An actual multiwell localization estimate with fixed bump constant and +quadratic inverse-separation error. -/ +theorem planarSitePartition_IMS_lower {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (W f : PlanarPosition → ℝ) (hW : Continuous W) + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + (∑ i, planarTestForm W (fun x => planarSitePartition D u i x * f x)) - + planarSiteDerivativeBound D ^ 2 * (∫ x, f x ^ 2) ≤ planarTestForm W f := by + have h := planar_IMS_lower (planarSitePartition D u) (planarSitePartition_C1 D u) + (planarSitePartition_square_sum hD u hsep) W f hW hf hc + (planarSitePartition_gradient_bound hD u hsep) + convert h using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLaplaceIBP.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLaplaceIBP.lean new file mode 100644 index 0000000000000000000000000000000000000000..63fb1d5c5b415a84c32008834f36b7fb9f996617 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLaplaceIBP.lean @@ -0,0 +1,132 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatEvolution + +namespace OAI + +/-! Two integrations by parts transfer the planar Laplacian from the +Gaussian kernel to the compact forcing. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarPartial_reflect {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 1 f) + (r e x : PlanarPosition) : + planarPartial (fun y => f (r - y)) e x = -planarPartial f e (r - x) := by + have hd := ((hf.differentiable (by norm_num) (r - x)).hasFDerivAt).comp x + ((hasFDerivAt_const r x).sub (hasFDerivAt_id x)) + change fderiv ℝ (fun y => f (r - y)) x e = -(fderiv ℝ f (r - x) e) + rw [show fderiv ℝ (fun y => f (r - y)) x = _ from hd.fderiv] + simp only [ContinuousLinearMap.comp_apply, zero_sub, neg_apply, + ContinuousLinearMap.id_apply, map_neg] + +theorem planarPartial_neg {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 1 f) + (e x : PlanarPosition) : + planarPartial (fun y => -f y) e x = -planarPartial f e x := by + have hd := (hf.differentiable (by norm_num) x).hasFDerivAt.neg + change fderiv ℝ (fun y => -f y) x e = -(fderiv ℝ f x e) + rw [show fderiv ℝ (fun y => -f y) x = _ from hd.fderiv] + simp only [neg_apply] + +theorem planarLaplacian_reflect {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 2 f) + (r x : PlanarPosition) : + planarLaplacian (fun y => f (r - y)) x = planarLaplacian f (r - x) := by + apply Finset.sum_congr rfl + intro a _ + have hp := planarPartial_C1 hf (planarAxis a) + have hpr : ContDiff ℝ 1 (fun y => planarPartial f (planarAxis a) (r - y)) := + hp.comp (contDiff_const.sub contDiff_id) + rw [show planarPartial (fun y => f (r - y)) (planarAxis a) = + fun y => -planarPartial f (planarAxis a) (r - y) from + funext (planarPartial_reflect (hf.of_le (by norm_num)) r (planarAxis a)), + planarPartial_neg hpr, planarPartial_reflect hp, neg_neg] + +theorem planar_integral_mul_laplacian_C2 (f phi : PlanarPosition → ℝ) + (hf : ContDiff ℝ 2 f) (hphi : ContDiff ℝ 2 phi) (hc : HasCompactSupport phi) : + (∫ x, f x * planarLaplacian phi x) = ∫ x, planarLaplacian f x * phi x := by + have hp (g : PlanarPosition → ℝ) (hg : ContDiff ℝ 2 g) (v : PlanarPosition) : + ContDiff ℝ 1 (planarPartial g v) := + (hg.fderiv_right (show (1 : WithTop ℕ∞) + 1 ≤ 2 by norm_num)).clm_apply contDiff_const + have hpp (g : PlanarPosition → ℝ) (hg : ContDiff ℝ 2 g) (v : PlanarPosition) : + Continuous (planarPartial (planarPartial g v) v) := + (((hp g hg v).fderiv_right (show (0 : WithTop ℕ∞) + 1 ≤ 1 by norm_num)).clm_apply + contDiff_const).continuous + have hpc (v : PlanarPosition) : HasCompactSupport (planarPartial phi v) := + hc.fderiv_apply ℝ v + have hppc (v : PlanarPosition) : HasCompactSupport (planarPartial (planarPartial phi v) v) := + (hpc v).fderiv_apply ℝ v + have hleft (v : PlanarPosition) : Integrable (fun x => f x * planarPartial (planarPartial phi v) v x) := + (hf.continuous.mul (hpp phi hphi v)).integrable_of_hasCompactSupport (hppc v).mul_left + have hright (v : PlanarPosition) : Integrable (fun x => planarPartial (planarPartial f v) v x * phi x) := + ((hpp f hf v).mul hphi.continuous).integrable_of_hasCompactSupport hc.mul_left + have hcross (v : PlanarPosition) : Integrable (fun x => planarPartial f v x * planarPartial phi v x) := + ((hp f hf v).continuous.mul (hp phi hphi v).continuous).integrable_of_hasCompactSupport + (hpc v).mul_left + have hfg (v : PlanarPosition) : Integrable (fun x => f x * planarPartial phi v x) := + (hf.continuous.mul (hp phi hphi v).continuous).integrable_of_hasCompactSupport + (hpc v).mul_left + have hfpg (v : PlanarPosition) : Integrable (fun x => planarPartial f v x * phi x) := + ((hp f hf v).continuous.mul hphi.continuous).integrable_of_hasCompactSupport hc.mul_left + have hby (v : PlanarPosition) : + (∫ x, f x * planarPartial (planarPartial phi v) v x) = + ∫ x, planarPartial (planarPartial f v) v x * phi x := by + calc + _ = -(∫ x, planarPartial f v x * planarPartial phi v x) := + integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (hcross v) (hleft v) (hfg v) + (fun x _ => hf.differentiable (by norm_num) x) + (fun x _ => (hp phi hphi v).differentiable (by norm_num) x) + _ = _ := by + have h : (∫ x, planarPartial f v x * planarPartial phi v x) = + -(∫ x, planarPartial (planarPartial f v) v x * phi x) := + integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (hright v) (hcross v) (hfpg v) + (fun x _ => (hp f hf v).differentiable (by norm_num) x) + (fun x _ => hphi.differentiable (by norm_num) x) + rw [h, neg_neg] + simp_rw [planarLaplacian, Finset.mul_sum] + rw [integral_finsetSum _ (fun a _ => hleft (planarAxis a))] + simp_rw [hby] + rw [← integral_finsetSum _ (fun a _ => hright (planarAxis a))] + simp_rw [Finset.sum_mul] + +theorem planarLaplacian_continuous {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 2 f) : + Continuous (planarLaplacian f) := + continuous_finsetSum _ (fun a _ => + planarPartial_continuous (planarPartial_C1 hf (planarAxis a)) (planarAxis a)) + +theorem planarLaplacian_hasCompactSupport {f : PlanarPosition → ℝ} (hc : HasCompactSupport f) : + HasCompactSupport (planarLaplacian f) := by + change HasCompactSupport (fun x => ∑ a : Fin 2, + fderiv ℝ (fun y => fderiv ℝ f y (planarAxis a)) x (planarAxis a)) + have h := HasCompactSupport.finset_sum (s := Finset.univ) + (fun a _ => (hc.fderiv_apply ℝ (planarAxis a)).fderiv_apply ℝ (planarAxis a)) + simpa only [Finset.sum_fn] using h + +theorem planarHeatAverage_hasDerivAt_laplacian {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + HasDerivAt (fun s => planarHeatAverage s r) + (∫ b, planarHeatKernel t b * planarLaplacian planarForcing (r - b)) t := by + have hf2 : ContDiff ℝ 2 planarForcing := planarForcing_C7.of_le (by norm_num) + have hr : ContDiff ℝ 2 (fun b : PlanarPosition => planarForcing (r - b)) := + hf2.comp (contDiff_const.sub contDiff_id) + have hrc : HasCompactSupport (fun b : PlanarPosition => planarForcing (r - b)) := + planarForcing_hasCompactSupport.comp_homeomorph (Homeomorph.subLeft r) + have heq : (∫ b, planarHeatTimeDerivative t (r - b) * planarForcing b) = + ∫ b, planarHeatKernel t b * planarLaplacian planarForcing (r - b) := by + calc + _ = ∫ b, planarHeatTimeDerivative t b * planarForcing (r - b) := by + rw [← integral_sub_left_eq_self _ volume r] + simp only [sub_sub_self] + _ = ∫ b, planarLaplacian (planarHeatKernel t) b * planarForcing (r - b) := by + simp only [planarHeatKernel_laplacian] + _ = ∫ b, planarHeatKernel t b * planarLaplacian (fun y => planarForcing (r - y)) b := + (planar_integral_mul_laplacian_C2 _ _ (planarHeatKernel_C2 t) hr hrc).symm + _ = _ := by simp only [planarLaplacian_reflect hf2] + rw [← heq] + exact planarHeatAverage_hasDerivAt ht r + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLocalization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLocalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..28b42e75a060470a3a075a2c5ea54b883a950015 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLocalization.lean @@ -0,0 +1,241 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeH1 +import RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean.Rellich + +namespace OAI + +/-! Actual compact localization on the planar Sobolev graph. Multiplication +by a compactly supported C¹ function is constructed on L² classes and their gradients, +then factored through the proved supported Rellich inclusion. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Topology +namespace ContinuumCoulomb +namespace PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance instLocalizationMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instLocalizationBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instLocalizationMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +section LinearField +variable {F G : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] + [NormedAddCommGroup G] [NormedSpace ℝ G] + +structure BoundedLinearField (F G : Type*) [NormedAddCommGroup F] [NormedSpace ℝ F] + [NormedAddCommGroup G] [NormedSpace ℝ G] where + value : PlanarPosition → F →L[ℝ] G + continuous : Continuous value + bound : ℝ + bound_spec : ∀ x, ‖value x‖ ≤ bound + +theorem BoundedLinearField.memLp (A : BoundedLinearField F G) + (u : Lp F 2 (volume : Measure PlanarPosition)) : + MemLp (fun x => A.value x (u x)) 2 := by + apply (Lp.memLp u).of_le_mul (c := A.bound) + (isBoundedBilinearMap_apply.continuous.comp_aestronglyMeasurable₂ + A.continuous.aestronglyMeasurable (Lp.aestronglyMeasurable u)) + exact Filter.Eventually.of_forall (fun x => (A.value x).le_opNorm (u x) |>.trans + (mul_le_mul_of_nonneg_right (A.bound_spec x) (norm_nonneg _))) + +def BoundedLinearField.applyLp (A : BoundedLinearField F G) + (u : Lp F 2 (volume : Measure PlanarPosition)) : Lp G 2 (volume : Measure PlanarPosition) := + (A.memLp u).toLp (fun x => A.value x (u x)) + +theorem BoundedLinearField.applyLp_ae (A : BoundedLinearField F G) + (u : Lp F 2 (volume : Measure PlanarPosition)) : + A.applyLp u =ᵐ[volume] fun x => A.value x (u x) := (A.memLp u).coeFn_toLp + +private def BoundedLinearField.linear (A : BoundedLinearField F G) : + Lp F 2 (volume : Measure PlanarPosition) →ₗ[ℝ] Lp G 2 (volume : Measure PlanarPosition) where + toFun := A.applyLp + map_add' u v := by + apply Lp.ext + filter_upwards [A.applyLp_ae (u + v), A.applyLp_ae u, A.applyLp_ae v, + Lp.coeFn_add u v, Lp.coeFn_add (A.applyLp u) (A.applyLp v)] with x h h₁ h₂ h₃ h₄ + simp only [h, h₄, h₃, Pi.add_apply, h₁, h₂, map_add] + map_smul' c u := by + apply Lp.ext + change (A.applyLp (c • u) : PlanarPosition → G) =ᵐ[volume] + (c • A.applyLp u : Lp G 2 volume) + filter_upwards [A.applyLp_ae (c • u), A.applyLp_ae u, + Lp.coeFn_smul c u, Lp.coeFn_smul c (A.applyLp u)] with x h h₁ h₂ h₃ + simp only [h, h₃, h₁, h₂, Pi.smul_apply, map_smul] + +def BoundedLinearField.operator (A : BoundedLinearField F G) : + Lp F 2 (volume : Measure PlanarPosition) →L[ℝ] Lp G 2 (volume : Measure PlanarPosition) := + A.linear.mkContinuous A.bound (fun u => Lp.norm_le_mul_norm_of_ae_le_mul (by + filter_upwards [A.applyLp_ae u] with x hx + change ‖A.applyLp u x‖ ≤ A.bound * ‖u x‖ + rw [hx] + exact ((A.value x).le_opNorm (u x)).trans + (mul_le_mul_of_nonneg_right (A.bound_spec x) (norm_nonneg _)))) + +end LinearField + +private theorem test_norm_bounded (h : Test) : ∃ B : ℝ, ∀ x, ‖h.val x‖ ≤ B := + h.property.1.continuous.bounded_above_of_compact_support h.property.2 + +private theorem test_grad_bounded (h : Test) : ∃ B : ℝ, ∀ x, ‖grad h.val x‖ ≤ B := + (continuous_grad h.property.1).bounded_above_of_compact_support (hasCompactSupport_grad h.property.2) + +def testNormBound (h : Test) : ℝ := Classical.choose (test_norm_bounded h) + +theorem testNormBound_spec (h : Test) (x : PlanarPosition) : ‖h.val x‖ ≤ testNormBound h := + Classical.choose_spec (test_norm_bounded h) x + +def testGradBound (h : Test) : ℝ := Classical.choose (test_grad_bounded h) + +theorem testGradBound_spec (h : Test) (x : PlanarPosition) : ‖grad h.val x‖ ≤ testGradBound h := + Classical.choose_spec (test_grad_bounded h) x + +def testScalarField (h : Test) (F : Type*) [NormedAddCommGroup F] [NormedSpace ℝ F] : + BoundedLinearField F F where + value x := h.val x • ContinuousLinearMap.id ℝ F + continuous := h.property.1.continuous.smul continuous_const + bound := testNormBound h + bound_spec x := by + rw [norm_smul] + exact (mul_le_mul_of_nonneg_left ContinuousLinearMap.norm_id_le (norm_nonneg (h.val x))).trans + (by simpa only [mul_one] using testNormBound_spec h x) + +def testGradientField (h : Test) : BoundedLinearField ℝ PlanarPosition where + value x := ContinuousLinearMap.toSpanSingleton ℝ (grad h.val x) + continuous := (ContinuousLinearMap.toSpanSingletonLIE ℝ PlanarPosition).continuous.comp + (continuous_grad h.property.1) + bound := testGradBound h + bound_spec x := by + rw [ContinuousLinearMap.norm_toSpanSingleton] + exact testGradBound_spec h x + +def testTargetMultiplier (h : Test) : Target →L[ℝ] Target := + ((testScalarField h ℝ).operator.comp (ContinuousLinearMap.fst ℝ _ _)).prod + (((testScalarField h PlanarPosition).operator.comp (ContinuousLinearMap.snd ℝ _ _)) + + ((testGradientField h).operator.comp (ContinuousLinearMap.fst ℝ _ _))) + +def testProduct (h u : Test) : Test := ⟨fun x => h.val x * u.val x, + ⟨h.property.1.mul u.property.1, h.property.2.mul_right⟩⟩ + +theorem testProduct_grad (h u : Test) (x : PlanarPosition) : + grad (testProduct h u).val x = h.val x • grad u.val x + u.val x • grad h.val x := by + ext a + rw [grad_coordinate] + change planarPartial (fun y => h.val y * u.val y) (planarAxis a) x = _ + rw [planarPartial_mul _ _ h.property.1 u.property.1] + simp only [PiLp.add_apply, PiLp.smul_apply, smul_eq_mul, grad_coordinate] + +theorem testTargetMultiplier_graph (h u : Test) : + testTargetMultiplier h (graph (μ := volume) u) = graph (μ := volume) (testProduct h u) := by + apply Prod.ext + · apply Lp.ext + filter_upwards [(testScalarField h ℝ).applyLp_ae (toL2 (μ := volume) u), + (memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp, + (memLp_of_mem_C1c (μ := volume) (testProduct h u).property).coeFn_toLp] with x hx hu hv + change (testScalarField h ℝ).applyLp (toL2 (μ := volume) u) x = + toL2 (μ := volume) (testProduct h u) x + change toL2 (μ := volume) u x = u.val x at hu + change toL2 (μ := volume) (testProduct h u) x = (testProduct h u).val x at hv + rw [hx, hu, hv] + rfl + · apply Lp.ext + filter_upwards [(testScalarField h PlanarPosition).applyLp_ae (toL2Grad (μ := volume) u), + (testGradientField h).applyLp_ae (toL2 (μ := volume) u), + Lp.coeFn_add ((testScalarField h PlanarPosition).applyLp (toL2Grad (μ := volume) u)) + ((testGradientField h).applyLp (toL2 (μ := volume) u)), + (memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp, + (memLp_grad_of_mem_C1c (μ := volume) u.property).coeFn_toLp, + (memLp_grad_of_mem_C1c (μ := volume) (testProduct h u).property).coeFn_toLp] + with x hx hx' hadd hu hg hv + change (((testScalarField h PlanarPosition).applyLp (toL2Grad (μ := volume) u)) + + (testGradientField h).applyLp (toL2 (μ := volume) u)) x = toL2Grad (μ := volume) (testProduct h u) x + change toL2 (μ := volume) u x = u.val x at hu + change toL2Grad (μ := volume) u x = grad u.val x at hg + change toL2Grad (μ := volume) (testProduct h u) x = grad (testProduct h u).val x at hv + rw [hadd] + change (testScalarField h PlanarPosition).applyLp (toL2Grad (μ := volume) u) x + + (testGradientField h).applyLp (toL2 (μ := volume) u) x = _ + rw [hx, hx', hu, hg, hv, testProduct_grad] + rfl + +theorem testTargetMultiplier_mem (h : Test) (u : Sobolev) : testTargetMultiplier h u.val ∈ Sobolev := by + have hc : IsClosed {v : Target | testTargetMultiplier h v ∈ Sobolev} := + (isClosed_h1 (μ := volume) (E := PlanarPosition)).preimage (testTargetMultiplier h).continuous + apply closure_minimal (s := (LinearMap.range (graph (μ := volume) (E := PlanarPosition)) : Set Target)) + (t := {v : Target | testTargetMultiplier h v ∈ Sobolev}) ?_ hc u.property + rintro _ ⟨v, rfl⟩ + change testTargetMultiplier h (graph (μ := volume) v) ∈ Sobolev + rw [testTargetMultiplier_graph] + exact subset_closure ⟨testProduct h v, rfl⟩ + +def testSobolevMultiplier (h : Test) : Sobolev →L[ℝ] Sobolev := + ((testTargetMultiplier h).comp Sobolev.subtypeL).codRestrict Sobolev (testTargetMultiplier_mem h) + +def testLocalizedL2 (h : Test) : Sobolev →L[ℝ] Lp ℝ 2 (volume : Measure PlanarPosition) := + (h1ToL2 (μ := volume) (E := PlanarPosition)).comp (testSobolevMultiplier h) + +theorem testLocalizedL2_ae (h : Test) (u : Sobolev) : + testLocalizedL2 h u =ᵐ[volume] fun x => h.val x * u.val.1 x := by + exact (testScalarField h ℝ).applyLp_ae u.val.1 + +private theorem mem_extendByZero_range {K : Set PlanarPosition} (hK : MeasurableSet K) + (f : Lp ℝ 2 (volume : Measure PlanarPosition)) + (hf : ∀ᵐ x ∂volume, x ∉ K → f x = 0) : + f ∈ LinearMap.range + (Lp.extendByZeroₗᵢ (μ := volume) (E := ℝ) (p := 2) hK).toLinearMap := by + let g : Lp ℝ 2 ((volume : Measure PlanarPosition).restrict K) := + ((Lp.memLp f).restrict K).toLp f + have hg : ∀ᵐ x ∂volume, x ∈ K → g x = f x := + (ae_restrict_iff' hK).1 ((Lp.memLp f).restrict K).coeFn_toLp + refine ⟨g, Lp.ext ?_⟩ + filter_upwards [Lp.extendByZeroₗᵢ_ae_eq hK g, hg, hf] with x he hgx hfx + change Lp.extendByZeroₗᵢ hK g x = f x + rw [he] + by_cases hx : x ∈ K + · simpa only [Set.indicator_of_mem hx] using hgx hx + · simp only [Set.indicator_of_notMem hx, hfx hx] + +theorem testSobolevMultiplier_supported (h : Test) (u : Sobolev) : + testSobolevMultiplier h u ∈ h1On (tsupport h.val) (isClosed_tsupport h.val).measurableSet := by + apply mem_extendByZero_range + filter_upwards [testLocalizedL2_ae h u] with x hx + intro hxs + change testLocalizedL2 h u x = 0 + rw [hx, image_eq_zero_of_notMem_tsupport hxs, zero_mul] + +def testSupportedMultiplier (h : Test) : + Sobolev →L[ℝ] h1On (tsupport h.val) (isClosed_tsupport h.val).measurableSet := + (testSobolevMultiplier h).codRestrict _ (testSobolevMultiplier_supported h) + +theorem testLocalizedL2_compact (h : Test) : IsCompactOperator (testLocalizedL2 h) := by + exact (isCompactOperator_h1OnToL2 h.property.2 + (isClosed_tsupport h.val).measurableSet).comp_clm (testSupportedMultiplier h) + +def wellTest : Test := ⟨manufacturedPlanarWell, + ⟨manufacturedPlanarWell_C7.of_le (by norm_num), manufacturedPlanarWell_hasCompactSupport⟩⟩ + +theorem wellTest_operator : (testScalarField wellTest ℝ).operator = wellMultiplier := by + apply ContinuousLinearMap.ext + intro u + apply Lp.ext + filter_upwards [(testScalarField wellTest ℝ).applyLp_ae u, wellMultiply_ae u] with x h₁ h₂ + change (testScalarField wellTest ℝ).applyLp u x = wellMultiply u x + rw [h₁, h₂] + rfl + +theorem wellMultiplier_compact : + IsCompactOperator (wellMultiplier.comp (h1ToL2 (μ := volume) (E := PlanarPosition))) := by + have he : testLocalizedL2 wellTest = + wellMultiplier.comp (h1ToL2 (μ := volume) (E := PlanarPosition)) := by + apply ContinuousLinearMap.ext + intro u + change (testScalarField wellTest ℝ).operator u.val.1 = wellMultiplier u.val.1 + rw [wellTest_operator] + rw [← he] + exact testLocalizedL2_compact wellTest + +end PlanarSobolev +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLowerTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLowerTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..f63c007a8da8a6be0aca0ee95f49e81ea4d0e8dc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarLowerTail.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSharpDecay + +namespace OAI + +/-! A matching lower exponential tail for the actual planar mode. Only the +positive forcing mass and the heat-time interval `[|r|/2,|r|/2+1]` are used. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarHeatAverage_other_integrable {t : ℝ} (ht : 0 < t) (r : PlanarPosition) : + Integrable (fun a => planarHeatKernel t (r - a) * planarForcing a) := by + have h := (planarHeatAverage_integrand_integrable ht r).comp_sub_left r + convert h using 1 + funext a + rw [show r - (r - a) = a by abel] + +theorem planarHeatAverage_other (t : ℝ) (r : PlanarPosition) : + planarHeatAverage t r = ∫ a, planarHeatKernel t (r - a) * planarForcing a := by + have h := integral_sub_left_eq_self + (fun b => planarHeatKernel t b * planarForcing (r - b)) volume r + unfold planarHeatAverage + convert h.symm using 1 + congr 1 + funext a + rw [show r - (r - a) = a by abel] + +theorem planar_heat_lower_exponent {R t d : ℝ} (hR : 1 ≤ R) + (ht₀ : R / 2 ≤ t) (ht₁ : t ≤ R / 2 + 1) (hd₀ : 0 ≤ d) (hd₁ : d ≤ R + 1) : + t + d ^ 2 / (4 * t) ≤ R + 2 := by + have ht : 0 < t := by linarith + have hs : d ^ 2 ≤ (R + 1) ^ 2 := by nlinarith + have hp : 0 ≤ (t - R / 2) * (R / 2 + 2 - t) := + mul_nonneg (by linarith) (by linarith) + have hd : d ^ 2 / (4 * t) ≤ R + 2 - t := + (div_le_iff₀ (by positivity : 0 < 4 * t)).2 (by nlinarith) + linarith + +theorem planarHeatKernel_weighted_lower {r a : PlanarPosition} {t : ℝ} + (hr : 1 ≤ ‖r‖) (ha : ‖a‖ ≤ 1) + (ht₀ : ‖r‖ / 2 ≤ t) (ht₁ : t ≤ ‖r‖ / 2 + 1) : + Real.exp (-(‖r‖ + 2)) / (2 * Real.pi * (‖r‖ + 2)) ≤ + Real.exp (-t) * planarHeatKernel t (r - a) := by + have ht : 0 < t := by linarith + have hnorm : ‖r - a‖ ≤ ‖r‖ + 1 := (norm_sub_le r a).trans (by linarith) + have he : Real.exp (-(‖r‖ + 2)) ≤ Real.exp (-t + -‖r - a‖ ^ 2 / (4 * t)) := by + apply Real.exp_le_exp.mpr + have h := planar_heat_lower_exponent hr ht₀ ht₁ (norm_nonneg _) hnorm + rw [neg_div] + linarith + have hden : 4 * Real.pi * t ≤ 2 * Real.pi * (‖r‖ + 2) := by + nlinarith [Real.pi_pos] + have hinv : (2 * Real.pi * (‖r‖ + 2))⁻¹ ≤ (4 * Real.pi * t)⁻¹ := + inv_anti₀ (by positivity) hden + unfold planarHeatKernel + rw [div_eq_mul_inv] + calc + _ ≤ Real.exp (-t + -‖r - a‖ ^ 2 / (4 * t)) * (4 * Real.pi * t)⁻¹ := + mul_le_mul he hinv (by positivity) (Real.exp_pos _).le + _ = _ := by rw [Real.exp_add]; ring + +theorem planarHeatForcing_weighted_lower {r : PlanarPosition} {t : ℝ} + (hr : 1 ≤ ‖r‖) (ht₀ : ‖r‖ / 2 ≤ t) (ht₁ : t ≤ ‖r‖ / 2 + 1) + (a : PlanarPosition) : + (Real.exp (-(‖r‖ + 2)) / (2 * Real.pi * (‖r‖ + 2))) * planarForcing a ≤ + (Real.exp (-t) * planarHeatKernel t (r - a)) * planarForcing a := by + by_cases hf : planarForcing a = 0 + · simp only [hf, mul_zero, le_refl] + have ha : ‖a‖ ≤ 1 := le_of_lt (lt_of_not_ge + (fun h => hf (planarForcing_zero_of_norm_ge_one h))) + exact mul_le_mul_of_nonneg_right (planarHeatKernel_weighted_lower hr ha ht₀ ht₁) + (planarForcing_nonnegative a) + +theorem planarHeatAverage_weighted_lower {r : PlanarPosition} {t : ℝ} + (hr : 1 ≤ ‖r‖) (ht₀ : ‖r‖ / 2 ≤ t) (ht₁ : t ≤ ‖r‖ / 2 + 1) : + (Real.exp (-(‖r‖ + 2)) / (2 * Real.pi * (‖r‖ + 2))) * (∫ a, planarForcing a) ≤ + Real.exp (-t) * planarHeatAverage t r := by + have ht : 0 < t := by linarith + have h := integral_mono + (planarForcing_integrable.const_mul + (Real.exp (-(‖r‖ + 2)) / (2 * Real.pi * (‖r‖ + 2)))) + ((planarHeatAverage_other_integrable ht r).const_mul (Real.exp (-t))) + (fun a => by simpa only [mul_assoc] using planarHeatForcing_weighted_lower hr ht₀ ht₁ a) + simpa only [integral_const_mul, ← planarHeatAverage_other] using h + +theorem planarResolventMode_sharp_lower_raw {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + (Real.exp (-(‖r‖ + 2)) / (2 * Real.pi * (‖r‖ + 2))) * (∫ a, planarForcing a) ≤ + planarResolventMode r := by + have hsub : Set.Icc (‖r‖ / 2) (‖r‖ / 2 + 1) ⊆ Set.Ioi (0 : ℝ) := by + intro t ht + change 0 < t + linarith [ht.1] + have hi := (planarResolventMode_heat_integrable r).mono_set hsub + have hl := setIntegral_ge_of_const_le_real measurableSet_Icc + isCompact_Icc.measure_lt_top.ne + (fun t ht => planarHeatAverage_weighted_lower hr ht.1 ht.2) hi + have hm := setIntegral_mono_set (planarResolventMode_heat_integrable r) + (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact mul_nonneg (Real.exp_pos _).le (planarHeatAverage_positive ht r).le) + (Filter.Eventually.of_forall hsub) + rw [Real.volume_real_Icc_of_le (by linarith), show ‖r‖ / 2 + 1 - ‖r‖ / 2 = 1 by ring, + mul_one] at hl + rw [planarResolventMode_heat_representation] + exact hl.trans hm + +def planarLowerTailConstant : ℝ := + Real.exp (-2) * (∫ a, planarForcing a) / (2 * Real.pi) + +theorem planarLowerTailConstant_positive : 0 < planarLowerTailConstant := by + unfold planarLowerTailConstant + exact div_pos (mul_pos (Real.exp_pos _) planarForcing_integral_positive) (by positivity) + +theorem planarResolventMode_sharp_lower {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + planarLowerTailConstant / (‖r‖ + 2) * Real.exp (-‖r‖) ≤ planarResolventMode r := by + convert planarResolventMode_sharp_lower_raw hr using 1 + unfold planarLowerTailConstant + rw [show -(‖r‖ + 2) = -2 + -‖r‖ by ring, Real.exp_add] + field_simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDecay.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..737837302f336346dca686353b6e2195903cc094 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDecay.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeProperties + +namespace OAI + +/-! An explicit exponential tail of the actual positive planar mode. Splitting +the Gaussian exponent avoids any assumed asymptotics for a special function. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarHeatKernel_double_time (t : ℝ) (b : PlanarPosition) : + planarHeatKernel t b = + 2 * Real.exp (-‖b‖ ^ 2 / (8 * t)) * planarHeatKernel (2 * t) b := by + unfold planarHeatKernel + have h1 : -‖b‖ ^ 2 / (4 * t) = -‖b‖ ^ 2 / (8 * t) + -‖b‖ ^ 2 / (8 * t) := by ring + have h2 : -‖b‖ ^ 2 / (4 * (2 * t)) = -‖b‖ ^ 2 / (8 * t) := by ring + rw [h1, h2, Real.exp_add] + ring + +theorem planarHeatForcing_tail {t : ℝ} (ht : 0 < t) {r : PlanarPosition} (hr : 1 ≤ ‖r‖) + (b : PlanarPosition) : + planarHeatKernel t b * planarForcing (r - b) ≤ + (2 * Real.exp (-((‖r‖ - 1) ^ 2) / (8 * t))) * planarHeatKernel (2 * t) b := by + by_cases hf : planarForcing (r - b) = 0 + · rw [hf, mul_zero] + exact mul_nonneg (by positivity) (planarHeatKernel_positive (by positivity) b).le + · have hs : ‖r - b‖ < 1 := lt_of_not_ge + (fun h => hf (planarForcing_zero_of_norm_ge_one h)) + have hn : ‖r‖ - 1 ≤ ‖b‖ := by + have htriangle := norm_add_le (r - b) b + rw [sub_add_cancel] at htriangle + linarith + have hsq : (‖r‖ - 1) ^ 2 ≤ ‖b‖ ^ 2 := by nlinarith [norm_nonneg b] + have he : Real.exp (-‖b‖ ^ 2 / (8 * t)) ≤ + Real.exp (-((‖r‖ - 1) ^ 2) / (8 * t)) := by + apply Real.exp_le_exp.mpr + gcongr + calc + _ ≤ planarHeatKernel t b := + mul_le_of_le_one_right (planarHeatKernel_positive ht b).le (planarForcing_le_one _) + _ = 2 * Real.exp (-‖b‖ ^ 2 / (8 * t)) * planarHeatKernel (2 * t) b := + planarHeatKernel_double_time t b + _ ≤ _ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left he (by norm_num)) + (planarHeatKernel_positive (by positivity) b).le + +theorem planarHeatAverage_tail {t : ℝ} (ht : 0 < t) {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + planarHeatAverage t r ≤ 2 * Real.exp (-((‖r‖ - 1) ^ 2) / (8 * t)) := by + have hi := (planarHeatKernel_integrable (by positivity : 0 < 2 * t)).const_mul + (2 * Real.exp (-((‖r‖ - 1) ^ 2) / (8 * t))) + have h := integral_mono (planarHeatAverage_integrand_integrable ht r) hi + (planarHeatForcing_tail ht hr) + simpa only [integral_const_mul, planarHeatKernel_integral (by positivity : 0 < 2 * t), + mul_one, planarHeatAverage] using h + +theorem planar_heat_tail_exponent {t d : ℝ} (ht : 0 < t) : + d / 2 ≤ t / 2 + d ^ 2 / (8 * t) := by + have he : t / 2 + d ^ 2 / (8 * t) - d / 2 = (2 * t - d) ^ 2 / (8 * t) := by + field_simp + ring + have hp : 0 ≤ (2 * t - d) ^ 2 / (8 * t) := by positivity + linarith + +theorem planarHeatResolvent_tail {t : ℝ} (ht : 0 < t) {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + Real.exp (-t) * planarHeatAverage t r ≤ + (2 * Real.exp (-(‖r‖ - 1) / 2)) * Real.exp (-(1 / 2 : ℝ) * t) := by + have he : -t + (-((‖r‖ - 1) ^ 2) / (8 * t)) ≤ -(‖r‖ - 1) / 2 + -(1 / 2 : ℝ) * t := by + have hA : (‖r‖ - 1) / 2 ≤ t / 2 + (‖r‖ - 1) ^ 2 / (8 * t) := + planar_heat_tail_exponent ht + rw [neg_div] + linarith + calc + _ ≤ Real.exp (-t) * (2 * Real.exp (-((‖r‖ - 1) ^ 2) / (8 * t))) := + mul_le_mul_of_nonneg_left (planarHeatAverage_tail ht hr) (Real.exp_pos _).le + _ = 2 * Real.exp (-t + (-((‖r‖ - 1) ^ 2) / (8 * t))) := by rw [Real.exp_add]; ring + _ ≤ 2 * Real.exp (-(‖r‖ - 1) / 2 + -(1 / 2 : ℝ) * t) := by gcongr + _ = _ := by rw [Real.exp_add]; ring + +theorem planarResolventMode_exponential_tail {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + planarResolventMode r ≤ 4 * Real.exp (-(‖r‖ - 1) / 2) := by + have hi : IntegrableOn (fun t : ℝ => Real.exp (-(1 / 2 : ℝ) * t)) (Set.Ioi (0 : ℝ)) := + exp_neg_integrableOn_Ioi 0 (by norm_num : (0 : ℝ) < 1 / 2) + rw [planarResolventMode_heat_representation] + have h := integral_mono_ae (planarResolventMode_heat_integrable r) + (hi.const_mul (2 * Real.exp (-(‖r‖ - 1) / 2))) + (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact planarHeatResolvent_tail ht hr) + have he : (∫ t : ℝ in Set.Ioi 0, Real.exp (-(1 / 2 : ℝ) * t)) = 2 := by + rw [integral_exp_mul_Ioi (by norm_num : -(1 / 2 : ℝ) < 0)] + norm_num + rw [integral_const_mul, he] at h + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDerivatives.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDerivatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac8994c87b52041ef948dcb11bbb25ff361cfbbf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeDerivatives.lean @@ -0,0 +1,122 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeProperties + +namespace OAI + +/-! Actual first and second directional derivatives of the resolvent mode. +Differentiation is transferred to the compact forcing, which also gives +finite L¹ and L² derivatives without differentiating the singular kernel. -/ + +noncomputable section +open MeasureTheory +open scoped Convolution +namespace ContinuumCoulomb + +theorem planarResolventKernel_nonnegative (r : PlanarPosition) : + 0 ≤ planarResolventKernel r := by + apply integral_nonneg_of_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact mul_nonneg (Real.exp_pos _).le (planarHeatKernel_positive ht r).le + +def planarResolventOf (g : PlanarPosition → ℝ) (r : PlanarPosition) : ℝ := + ∫ b, planarResolventKernel b * g (r - b) + +theorem planarResolventOf_integrable {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) : Integrable (planarResolventOf g) := + planarResolventKernel_integrable.integrable_convolution (ContinuousLinearMap.mul ℝ ℝ) + (hg.integrable_of_hasCompactSupport hc) + +theorem planarResolventOf_continuous {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) : Continuous (planarResolventOf g) := + hc.continuous_convolution_right (ContinuousLinearMap.mul ℝ ℝ) + planarResolventKernel_integrable.locallyIntegrable hg + +theorem planarResolventOf_bound {g : PlanarPosition → ℝ} {B : ℝ} + (hB : ∀ x, ‖g x‖ ≤ B) (r : PlanarPosition) : ‖planarResolventOf g r‖ ≤ B := by + have h := norm_integral_le_of_norm_le (planarResolventKernel_integrable.mul_const B) + (Filter.Eventually.of_forall (fun b => show + ‖planarResolventKernel b * g (r - b)‖ ≤ planarResolventKernel b * B by + rw [norm_mul, Real.norm_eq_abs, abs_of_nonneg (planarResolventKernel_nonnegative b)] + exact mul_le_mul_of_nonneg_left (hB _) (planarResolventKernel_nonnegative b))) + simpa only [integral_mul_const, planarResolventKernel_integral, one_mul, + planarResolventOf] using h + +theorem planarResolventOf_square_integrable {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) : + Integrable (fun r => planarResolventOf g r ^ 2) := by + obtain ⟨B, hB⟩ := hg.bounded_above_of_compact_support hc + have hi := (planarResolventOf_integrable hg hc).norm.const_mul B + apply hi.mono' ((planarResolventOf_continuous hg hc).pow 2).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun r => by + change ‖planarResolventOf g r ^ 2‖ ≤ B * ‖planarResolventOf g r‖ + have hb := planarResolventOf_bound hB r + rw [norm_pow] + exact (pow_two (‖planarResolventOf g r‖)).trans_le + (mul_le_mul_of_nonneg_right hb (norm_nonneg _))) + +theorem planarResolventOf_partial {g : PlanarPosition → ℝ} + (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) (e r : PlanarPosition) : + planarPartial (planarResolventOf g) e r = planarResolventOf (planarPartial g e) r := by + have hd := hc.hasFDerivAt_convolution_right (ContinuousLinearMap.mul ℝ ℝ) + planarResolventKernel_integrable.locallyIntegrable hg r + have hi := (hc.fderiv ℝ).convolutionExists_right + ((ContinuousLinearMap.mul ℝ ℝ).precompR PlanarPosition) + planarResolventKernel_integrable.locallyIntegrable + (hg.continuous_fderiv (by norm_num)) r + change fderiv ℝ (planarResolventOf g) r e = _ + rw [show fderiv ℝ (planarResolventOf g) r = + (planarResolventKernel ⋆[((ContinuousLinearMap.mul ℝ ℝ).precompR PlanarPosition), volume] + fderiv ℝ g) r from hd.fderiv] + change (∫ b, (ContinuousLinearMap.mul ℝ ℝ).precompR PlanarPosition + (planarResolventKernel b) (fderiv ℝ g (r - b))) e = _ + rw [ContinuousLinearMap.integral_apply hi e] + rfl + +theorem planarResolventMode_partial (e r : PlanarPosition) : + planarPartial planarResolventMode e r = planarResolventOf (planarPartial planarForcing e) r := + planarResolventOf_partial (planarForcing_C7.of_le (by norm_num)) + planarForcing_hasCompactSupport e r + +theorem planarResolventMode_partial_integrable (e : PlanarPosition) : + Integrable (planarPartial planarResolventMode e) := by + change Integrable (fun r => planarPartial planarResolventMode e r) + simp_rw [planarResolventMode_partial] + exact planarResolventOf_integrable + (planarPartial_continuous (planarForcing_C7.of_le (by norm_num)) e) + (planarForcing_hasCompactSupport.fderiv_apply ℝ e) + +theorem planarResolventMode_partial_square_integrable (e : PlanarPosition) : + Integrable (fun r => planarPartial planarResolventMode e r ^ 2) := by + simp_rw [planarResolventMode_partial] + exact planarResolventOf_square_integrable + (planarPartial_continuous (planarForcing_C7.of_le (by norm_num)) e) + (planarForcing_hasCompactSupport.fderiv_apply ℝ e) + +theorem planarResolventMode_partial_partial (e v r : PlanarPosition) : + planarPartial (planarPartial planarResolventMode e) v r = + planarResolventOf (planarPartial (planarPartial planarForcing e) v) r := by + rw [show planarPartial planarResolventMode e = + planarResolventOf (planarPartial planarForcing e) from funext (planarResolventMode_partial e)] + exact planarResolventOf_partial + (planarPartial_C1 (planarForcing_C7.of_le (by norm_num)) e) + (planarForcing_hasCompactSupport.fderiv_apply ℝ e) v r + +theorem planarResolventMode_partial_partial_square_integrable (e v : PlanarPosition) : + Integrable (fun r => planarPartial (planarPartial planarResolventMode e) v r ^ 2) := by + simp_rw [planarResolventMode_partial_partial] + exact planarResolventOf_square_integrable + (planarPartial_continuous (planarPartial_C1 (planarForcing_C7.of_le (by norm_num)) e) v) + ((planarForcing_hasCompactSupport.fderiv_apply ℝ e).fderiv_apply ℝ v) + +theorem planarResolventMode_partial_partial_integrable (e v : PlanarPosition) : + Integrable (planarPartial (planarPartial planarResolventMode e) v) := by + change Integrable (fun r => planarPartial (planarPartial planarResolventMode e) v r) + simp_rw [planarResolventMode_partial_partial] + exact planarResolventOf_integrable + (planarPartial_continuous (planarPartial_C1 (planarForcing_C7.of_le (by norm_num)) e) v) + ((planarForcing_hasCompactSupport.fderiv_apply ℝ e).fderiv_apply ℝ v) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..285bcff31f81bdf7485d5343114950a705f527dd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeEnergy.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeH1 + +namespace OAI + +/-! The actual manufactured planar mode attains energy `-1/2`. +The integration by parts uses its proved square-integrable first and second +derivatives, rather than imposing an eigenvalue or normalization hypothesis. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarResolventMode_partial_memLp (e : PlanarPosition) : + MemLp (planarPartial planarResolventMode e) 2 := + (memLp_two_iff_integrable_sq + (planarPartial_continuous (planarResolventMode_C7.of_le (by norm_num)) e).aestronglyMeasurable).mpr + (planarResolventMode_partial_square_integrable e) + +theorem planarResolventMode_second_memLp (e : PlanarPosition) : + MemLp (planarPartial (planarPartial planarResolventMode e) e) 2 := + (memLp_two_iff_integrable_sq + (planarPartial_continuous (planarPartial_C1 (planarResolventMode_C7.of_le (by norm_num)) e) + e).aestronglyMeasurable).mpr (planarResolventMode_partial_partial_square_integrable e e) + +theorem planarResolventMode_energy_ibp (e : PlanarPosition) : + (∫ x, planarResolventMode x * planarPartial (planarPartial planarResolventMode e) e x) = + -(∫ x, planarPartial planarResolventMode e x ^ 2) := by + have hi := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (planarResolventMode_partial_memLp e |>.integrable_mul (planarResolventMode_partial_memLp e)) + (planarResolventMode_memLp.integrable_mul (planarResolventMode_second_memLp e)) + (planarResolventMode_memLp.integrable_mul (planarResolventMode_partial_memLp e)) + (fun x _ => (planarResolventMode_C7.differentiable (by norm_num)) x) + (fun x _ => (planarPartial_C1 (planarResolventMode_C7.of_le (by norm_num)) e).differentiable + (by norm_num) x) + simpa only [planarPartial, pow_two] using hi + +theorem planarResolventMode_energy : + planarTestForm manufacturedPlanarWell planarResolventMode = + -(1 / 2 : ℝ) * ∫ x, planarResolventMode x ^ 2 := by + have hi (a : Fin 2) : Integrable (fun x => planarResolventMode x * + planarPartial (planarPartial planarResolventMode (planarAxis a)) (planarAxis a) x) := + planarResolventMode_memLp.integrable_mul (planarResolventMode_second_memLp (planarAxis a)) + have hsum : (∫ x, planarResolventMode x * planarLaplacian planarResolventMode x) = + -(∑ a : Fin 2, ∫ x, planarPartial planarResolventMode (planarAxis a) x ^ 2) := by + simp only [planarLaplacian, Finset.mul_sum] + rw [integral_finsetSum Finset.univ (fun a _ => hi a)] + simp only [planarResolventMode_energy_ibp, Finset.sum_neg_distrib] + have hpot : Integrable (fun x => manufacturedPlanarWell x * planarResolventMode x ^ 2) := + (manufacturedPlanarWell_C7.continuous.mul (planarResolventMode_C7.continuous.pow 2)).integrable_of_hasCompactSupport + manufacturedPlanarWell_hasCompactSupport.mul_right + have heq : (∫ x, planarResolventMode x * planarLaplacian planarResolventMode x) = + 2 * (∫ x, manufacturedPlanarWell x * planarResolventMode x ^ 2) + + ∫ x, planarResolventMode x ^ 2 := by + simp_rw [manufacturedPlanarWell_eigen_equation] + rw [show (fun x => planarResolventMode x * ((2 * manufacturedPlanarWell x + 1) * planarResolventMode x)) = + (fun x => 2 * (manufacturedPlanarWell x * planarResolventMode x ^ 2) + planarResolventMode x ^ 2) + from by funext x; ring] + rw [integral_add (hpot.const_mul 2) planarResolventMode_square_integrable, integral_const_mul] + unfold planarTestForm + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeH1.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeH1.lean new file mode 100644 index 0000000000000000000000000000000000000000..283c31a836ed966577acfe919c312aa2d57deb3b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeH1.lean @@ -0,0 +1,271 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev + +namespace OAI + +/-! Membership of the manufactured mode in the closed planar Sobolev +graph, obtained by expanding compact cutoffs. -/ + +noncomputable section +open MeasureTheory Filter +open scoped BigOperators Topology ContDiff +namespace ContinuumCoulomb +namespace PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +def cutoffBump : ContDiffBump (0 : PlanarPosition) := ⟨1, 2, by norm_num, by norm_num⟩ + +theorem cutoffBump_smooth : ContDiff ℝ ∞ (cutoffBump : PlanarPosition → ℝ) := cutoffBump.contDiff + +def cutoffScale (n : ℕ) : ℝ := ((n : ℝ) + 1)⁻¹ + +def cutoff (n : ℕ) (x : PlanarPosition) : ℝ := cutoffBump (cutoffScale n • x) + +theorem cutoffScale_positive (n : ℕ) : 0 < cutoffScale n := inv_pos.mpr (by positivity) + +theorem cutoffScale_le_one (n : ℕ) : cutoffScale n ≤ 1 := by + unfold cutoffScale + apply inv_le_one_of_one_le₀ + linarith [Nat.cast_nonneg (α := ℝ) n] + +theorem cutoffScale_tendsto : Tendsto cutoffScale atTop (𝓝 0) := + tendsto_inv_atTop_zero.comp + (tendsto_natCast_atTop_atTop.atTop_add tendsto_const_nhds) + +theorem cutoff_smooth (n : ℕ) : ContDiff ℝ ∞ (cutoff n) := + cutoffBump_smooth.comp (contDiff_const_smul (cutoffScale n)) + +theorem cutoff_nonnegative (n : ℕ) (x : PlanarPosition) : 0 ≤ cutoff n x := cutoffBump.nonneg + +theorem cutoff_le_one (n : ℕ) (x : PlanarPosition) : cutoff n x ≤ 1 := cutoffBump.le_one + +theorem cutoff_hasCompactSupport (n : ℕ) : HasCompactSupport (cutoff n) := by + apply HasCompactSupport.intro (isCompact_closedBall (0 : PlanarPosition) (2 * (n + 1 : ℝ))) + intro x hx + have hdist : 2 * (n + 1 : ℝ) < ‖x‖ := by + simpa only [Metric.mem_closedBall, dist_zero_right, not_le] using hx + apply cutoffBump.zero_of_le_dist + change 2 ≤ dist (cutoffScale n • x) 0 + rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_of_pos (cutoffScale_positive n)] + change 2 ≤ (n + 1 : ℝ)⁻¹ * ‖x‖ + rw [← div_eq_inv_mul] + exact (le_div_iff₀ (by positivity)).mpr hdist.le + +theorem cutoff_tendsto (x : PlanarPosition) : + Tendsto (fun n => cutoff n x) atTop (𝓝 1) := by + have h := (cutoffBump_smooth.continuous.tendsto 0).comp + (by simpa only [zero_smul] using cutoffScale_tendsto.smul_const x) + have hzero : cutoffBump (0 : PlanarPosition) = 1 := + cutoffBump.one_of_mem_closedBall (by simp [cutoffBump]) + simpa only [Function.comp_def, cutoff, hzero] using h + +theorem cutoff_fderiv (n : ℕ) (x : PlanarPosition) : + fderiv ℝ (cutoff n) x = cutoffScale n • fderiv ℝ cutoffBump (cutoffScale n • x) := by + have h := (cutoffBump_smooth.differentiable (by simp) (cutoffScale n • x)).hasFDerivAt.comp x + ((hasFDerivAt_id (𝕜 := ℝ) x).const_smul (cutoffScale n)) + change fderiv ℝ (cutoffBump ∘ fun y => cutoffScale n • y) x = _ + rw [h.fderiv] + ext e + simp + +theorem cutoff_grad (n : ℕ) (x : PlanarPosition) : + grad (cutoff n) x = cutoffScale n • grad cutoffBump (cutoffScale n • x) := by + simp only [grad, cutoff_fderiv, map_smul] + +theorem cutoff_grad_tendsto (x : PlanarPosition) : + Tendsto (fun n => grad (cutoff n) x) atTop (𝓝 0) := by + simp_rw [cutoff_grad] + have h := ((continuous_grad (cutoffBump_smooth.of_le (by simp))).tendsto 0).comp + (by simpa only [zero_smul] using cutoffScale_tendsto.smul_const x) + simpa only [zero_smul, Function.comp_def] using cutoffScale_tendsto.smul h + +private theorem bump_grad_bounded : ∃ C : ℝ, ∀ x, ‖grad cutoffBump x‖ ≤ C := + (continuous_grad (cutoffBump_smooth.of_le (by simp))).bounded_above_of_compact_support + (hasCompactSupport_grad cutoffBump.hasCompactSupport) + +def cutoffGradBound : ℝ := Classical.choose bump_grad_bounded + +theorem cutoffGradBound_spec (x : PlanarPosition) : ‖grad cutoffBump x‖ ≤ cutoffGradBound := + Classical.choose_spec bump_grad_bounded x + +theorem cutoffGradBound_nonnegative : 0 ≤ cutoffGradBound := + (norm_nonneg (grad cutoffBump 0)).trans (Classical.choose_spec bump_grad_bounded 0) + +theorem cutoff_grad_bound (n : ℕ) (x : PlanarPosition) : + ‖grad (cutoff n) x‖ ≤ cutoffGradBound := by + rw [cutoff_grad, norm_smul, Real.norm_eq_abs, abs_of_pos (cutoffScale_positive n)] + exact (mul_le_mul_of_nonneg_left (Classical.choose_spec bump_grad_bounded _) + (cutoffScale_positive n).le).trans + (mul_le_of_le_one_left cutoffGradBound_nonnegative (cutoffScale_le_one n)) + +theorem mode_square_integrable : Integrable (fun x => planarResolventMode x ^ 2) := + (planar_integrable_change_borel (borel PlanarPosition) ⟨rfl⟩ _).mpr + planarResolventMode_square_integrable + +theorem mode_memLp : MemLp planarResolventMode 2 := + (memLp_two_iff_integrable_sq planarResolventMode_C7.continuous.aestronglyMeasurable).mpr + mode_square_integrable + +theorem grad_norm_sq (f : PlanarPosition → ℝ) (x : PlanarPosition) : + ‖grad f x‖ ^ 2 = ∑ a : Fin 2, planarPartial f (planarAxis a) x ^ 2 := by + rw [EuclideanSpace.real_norm_sq_eq] + exact Finset.sum_congr rfl (fun a _ => congrArg (fun t : ℝ => t ^ 2) (grad_coordinate f x a)) + +theorem mode_grad_square_integrable : Integrable (fun x => ‖grad planarResolventMode x‖ ^ 2) := by + have hi (a : Fin 2) : Integrable (fun x => planarPartial planarResolventMode (planarAxis a) x ^ 2) := + (planar_integrable_change_borel (borel PlanarPosition) ⟨rfl⟩ _).mpr + (planarResolventMode_partial_square_integrable (planarAxis a)) + have h := integrable_finsetSum Finset.univ (fun a _ => hi a) + exact h.congr (Filter.Eventually.of_forall (fun x => (grad_norm_sq planarResolventMode x).symm)) + +theorem mode_grad_memLp : MemLp (grad planarResolventMode) 2 := + (memLp_two_iff_integrable_sq_norm + (continuous_grad (planarResolventMode_C7.of_le (by norm_num))).aestronglyMeasurable).mpr + mode_grad_square_integrable + +def cutoffMode (n : ℕ) : Test := ⟨fun x => cutoff n x * planarResolventMode x, + ⟨((cutoff_smooth n).of_le (by simp)).mul (planarResolventMode_C7.of_le (by norm_num)), + (cutoff_hasCompactSupport n).mul_right⟩⟩ + +theorem cutoffMode_grad (n : ℕ) (x : PlanarPosition) : + grad (cutoffMode n).val x = cutoff n x • grad planarResolventMode x + + planarResolventMode x • grad (cutoff n) x := by + ext a + rw [grad_coordinate] + change planarPartial (fun y => cutoff n y * planarResolventMode y) (planarAxis a) x = _ + rw [planarPartial_mul _ _ ((cutoff_smooth n).of_le (by simp)) + (planarResolventMode_C7.of_le (by norm_num))] + simp only [PiLp.add_apply, PiLp.smul_apply, smul_eq_mul, grad_coordinate] + +theorem cutoffMode_grad_tendsto (x : PlanarPosition) : + Tendsto (fun n => grad (cutoffMode n).val x) atTop (𝓝 (grad planarResolventMode x)) := by + simp_rw [cutoffMode_grad] + simpa only [one_smul, smul_zero, add_zero] using + ((cutoff_tendsto x).smul_const (grad planarResolventMode x)).add + ((tendsto_const_nhds (x := planarResolventMode x)).smul (cutoff_grad_tendsto x)) + +private theorem toLp_sub_norm_sq {F : Type*} [NormedAddCommGroup F] + [InnerProductSpace ℝ F] {f g : PlanarPosition → F} + (hf : MemLp f 2 (volume : Measure PlanarPosition)) + (hg : MemLp g 2 (volume : Measure PlanarPosition)) : + ‖hf.toLp f - hg.toLp g‖ ^ 2 = ∫ x, ‖f x - g x‖ ^ 2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [Lp.coeFn_sub (hf.toLp f) (hg.toLp g), hf.coeFn_toLp, hg.coeFn_toLp] + with x hx hxf hxg + simp only [real_inner_self_eq_norm_sq, hx, Pi.sub_apply, hxf, hxg] + +private theorem toLp_tendsto_of_integral_sub_sq {F : Type*} [NormedAddCommGroup F] + [InnerProductSpace ℝ F] {f : ℕ → PlanarPosition → F} {g : PlanarPosition → F} + (hf : ∀ n, MemLp (f n) 2 (volume : Measure PlanarPosition)) + (hg : MemLp g 2 (volume : Measure PlanarPosition)) + (hlim : Tendsto (fun n => ∫ x, ‖f n x - g x‖ ^ 2) atTop (𝓝 0)) : + Tendsto (fun n => (hf n).toLp (f n)) atTop (𝓝 (hg.toLp g)) := by + rw [tendsto_iff_dist_tendsto_zero] + have hs : Tendsto (fun n => ‖(hf n).toLp (f n) - hg.toLp g‖ ^ 2) atTop (𝓝 0) := by + simpa only [toLp_sub_norm_sq] using hlim + have hroot := (Real.continuous_sqrt.tendsto 0).comp hs + simpa only [Function.comp_def, Real.sqrt_sq (norm_nonneg _), Real.sqrt_zero, + dist_eq_norm] using hroot + +theorem cutoffMode_value_integral_tendsto : + Tendsto (fun n => ∫ x, ‖(cutoffMode n).val x - planarResolventMode x‖ ^ 2) + atTop (𝓝 0) := by + have h : Tendsto (fun n => ∫ x, ‖(cutoffMode n).val x - planarResolventMode x‖ ^ 2) + atTop (𝓝 (∫ _ : PlanarPosition, (0 : ℝ))) := by + apply tendsto_integral_of_dominated_convergence (fun x => planarResolventMode x ^ 2) + · intro n + exact (((cutoffMode n).property.1.continuous.sub + planarResolventMode_C7.continuous).norm.pow 2).aestronglyMeasurable + · exact mode_square_integrable + · intro n + filter_upwards [] with x + change ‖‖(cutoffMode n).val x - planarResolventMode x‖ ^ 2‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _), Real.norm_eq_abs, sq_abs] + change (cutoff n x * planarResolventMode x - planarResolventMode x) ^ 2 ≤ _ + have ha := mul_nonneg (cutoff_nonnegative n x) (planarResolventMode_positive x).le + have hb := mul_le_of_le_one_left (planarResolventMode_positive x).le (cutoff_le_one n x) + have hab := mul_nonneg ha (sub_nonneg.mpr hb) + nlinarith + · filter_upwards [] with x + change Tendsto (fun n => ‖cutoff n x * planarResolventMode x - planarResolventMode x‖ ^ 2) + atTop (𝓝 0) + have hlim := ((cutoff_tendsto x).mul_const (planarResolventMode x)).sub + (tendsto_const_nhds (x := planarResolventMode x)) + simpa only [one_mul, sub_self, norm_zero, zero_pow (by decide : 2 ≠ 0)] using + hlim.norm.pow 2 + simpa only [integral_zero] using h + +theorem cutoffMode_grad_integral_tendsto : + Tendsto (fun n => ∫ x, ‖grad (cutoffMode n).val x - grad planarResolventMode x‖ ^ 2) + atTop (𝓝 0) := by + have hi : Integrable (fun x => 8 * ‖grad planarResolventMode x‖ ^ 2 + + 2 * cutoffGradBound ^ 2 * planarResolventMode x ^ 2) := + (mode_grad_square_integrable.const_mul 8).add + (mode_square_integrable.const_mul (2 * cutoffGradBound ^ 2)) + have h : Tendsto (fun n => ∫ x, ‖grad (cutoffMode n).val x - grad planarResolventMode x‖ ^ 2) + atTop (𝓝 (∫ _ : PlanarPosition, (0 : ℝ))) := by + apply tendsto_integral_of_dominated_convergence + (fun x => 8 * ‖grad planarResolventMode x‖ ^ 2 + + 2 * cutoffGradBound ^ 2 * planarResolventMode x ^ 2) + · intro n + exact (((continuous_grad (cutoffMode n).property.1).sub + (continuous_grad (planarResolventMode_C7.of_le (by norm_num)))).norm.pow 2).aestronglyMeasurable + · exact hi + · intro n + filter_upwards [] with x + change ‖‖grad (cutoffMode n).val x - grad planarResolventMode x‖ ^ 2‖ ≤ _ + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have hb : ‖grad (cutoffMode n).val x - grad planarResolventMode x‖ ≤ + 2 * ‖grad planarResolventMode x‖ + cutoffGradBound * ‖planarResolventMode x‖ := by + apply (norm_sub_le _ _).trans + rw [cutoffMode_grad] + have ha := norm_add_le (cutoff n x • grad planarResolventMode x) + (planarResolventMode x • grad (cutoff n) x) + rw [norm_smul, norm_smul, Real.norm_eq_abs, abs_of_nonneg (cutoff_nonnegative n x)] at ha + have h₁ := mul_le_of_le_one_left (norm_nonneg (grad planarResolventMode x)) + (cutoff_le_one n x) + have h₂ := mul_le_mul_of_nonneg_left (cutoff_grad_bound n x) (norm_nonneg (planarResolventMode x)) + nlinarith + have hb2 := pow_le_pow_left₀ (norm_nonneg _) hb 2 + have hs := sq_nonneg (2 * ‖grad planarResolventMode x‖ - cutoffGradBound * ‖planarResolventMode x‖) + simp only [Real.norm_eq_abs, abs_of_pos (planarResolventMode_positive x)] at hb2 hs + nlinarith + · filter_upwards [] with x + have hlim := (cutoffMode_grad_tendsto x).sub + (tendsto_const_nhds (x := grad planarResolventMode x)) + simpa only [sub_self, norm_zero, zero_pow (by decide : 2 ≠ 0)] using hlim.norm.pow 2 + simpa only [integral_zero] using h + +def modeTarget : Target := ⟨mode_memLp.toLp planarResolventMode, + mode_grad_memLp.toLp (grad planarResolventMode)⟩ + +theorem cutoffMode_graph_tendsto : + Tendsto (fun n => graph (μ := volume) (cutoffMode n)) atTop (𝓝 modeTarget) := by + have hval := toLp_tendsto_of_integral_sub_sq + (fun n => memLp_of_mem_C1c (μ := volume) (cutoffMode n).property) mode_memLp + cutoffMode_value_integral_tendsto + have hgrad := toLp_tendsto_of_integral_sub_sq + (fun n => memLp_grad_of_mem_C1c (μ := volume) (cutoffMode n).property) mode_grad_memLp + cutoffMode_grad_integral_tendsto + exact hval.prodMk_nhds hgrad + +theorem modeTarget_mem : modeTarget ∈ Sobolev := by + apply (isClosed_h1 (μ := volume) (E := PlanarPosition)).mem_of_tendsto cutoffMode_graph_tendsto + exact Filter.Eventually.of_forall (fun n => subset_closure + (show graph (μ := volume) (cutoffMode n) ∈ + (LinearMap.range (graph (μ := volume) (E := PlanarPosition)) : Set Target) from + ⟨cutoffMode n, rfl⟩)) + +/-- The positive resolvent mode belongs to the closed H¹ graph. -/ +def mode : Sobolev := ⟨modeTarget, modeTarget_mem⟩ + +end PlanarSobolev +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeJets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeJets.lean new file mode 100644 index 0000000000000000000000000000000000000000..767ffd09dc06294883406849b0e4822c8a14f860 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeJets.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDerivatives + +namespace OAI + +/-! Uniform derivatives through order four of the manufactured planar +orbital. Derivatives are transferred to its fixed compact forcing. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem forcing_jet_compact (k : ℕ) (v : Fin k → PlanarPosition) : + HasCompactSupport (fun x => iteratedFDeriv ℝ k planarForcing x v) := + (planarForcing_hasCompactSupport.iteratedFDeriv (𝕜 := ℝ) k).comp_left + (g := fun T : ContinuousMultilinearMap ℝ (fun _ : Fin k => PlanarPosition) ℝ => T v) + (by simp) + +theorem planar_mode_jet_transfer : ∀ k : ℕ, k ≤ 4 → ∀ (v : Fin k → PlanarPosition) r, + iteratedFDeriv ℝ k planarResolventMode r v = + planarResolventOf (fun x => iteratedFDeriv ℝ k planarForcing x v) r := by + intro k + induction k with + | zero => + intro _ v r + simp only [iteratedFDeriv_zero_apply] + rfl + | succ k ih => + intro hk v r + have hk7 : (k : WithTop ℕ∞) < 7 := by exact_mod_cast (show k < 7 by omega) + have hm := planarResolventMode_C7.differentiable_iteratedFDeriv hk7 + have hf := planarForcing_C7.differentiable_iteratedFDeriv hk7 + have hr : ContDiff ℝ 1 (fun x => iteratedFDeriv ℝ k planarForcing x (Fin.tail v)) := + (ContinuousMultilinearMap.apply ℝ (fun _ : Fin k => PlanarPosition) ℝ (Fin.tail v)).contDiff.comp + (planarForcing_C7.iteratedFDeriv_right (by exact_mod_cast (show 1+k ≤ 7 by omega))) + rw [(hm r).iteratedFDeriv_succ_apply_left'] + have he : (fun x => iteratedFDeriv ℝ k planarResolventMode x (Fin.tail v)) = + planarResolventOf (fun x => iteratedFDeriv ℝ k planarForcing x (Fin.tail v)) := + funext (ih (by omega) (Fin.tail v)) + rw [he] + change planarPartial _ (v 0) r = _ + rw [planarResolventOf_partial hr (forcing_jet_compact k (Fin.tail v))] + congr 1 + funext x + exact ((hf x).iteratedFDeriv_succ_apply_left').symm + +theorem planar_mode_jets_bounded : + ∃ B : ℝ, 1 ≤ B ∧ ∀ k : ℕ, k ≤ 4 → ∀ r, + ‖iteratedFDeriv ℝ k planarResolventMode r‖ ≤ B := by + have he (k : Fin 5) : ∃ A : ℝ, ∀ r, + ‖iteratedFDeriv ℝ k.val planarForcing r‖ ≤ A := + (planarForcing_C7.continuous_iteratedFDeriv (by exact_mod_cast (show k.val ≤ 7 by omega))).bounded_above_of_compact_support + (planarForcing_hasCompactSupport.iteratedFDeriv k.val) + choose A hA using he + let B := ∑ k : Fin 5, max (A k) 0 + have hB : 0 ≤ B := Finset.sum_nonneg (fun _ _ => le_max_right _ _) + have hb (k : ℕ) (hk : k ≤ 4) (r : PlanarPosition) : + ‖iteratedFDeriv ℝ k planarForcing r‖ ≤ B := by + let j : Fin 5 := ⟨k,by omega⟩ + exact (hA j r).trans ((le_max_left _ _).trans + (Finset.single_le_sum (fun _ _ => le_max_right _ _) (Finset.mem_univ j))) + refine ⟨B+1,by linarith,fun k hk r => ?_⟩ + apply ContinuousMultilinearMap.opNorm_le_bound (by linarith) + intro v + rw [planar_mode_jet_transfer k hk] + apply (planarResolventOf_bound (fun x => ?_) r).trans + · exact mul_le_mul_of_nonneg_right (by linarith : B ≤ B+1) + (Finset.prod_nonneg (fun _ _ => norm_nonneg _)) + · exact ((iteratedFDeriv ℝ k planarForcing x).le_opNorm v).trans + (mul_le_mul_of_nonneg_right (hb k hk x) (Finset.prod_nonneg (fun _ _ => norm_nonneg _))) + +theorem normalized_planar_mode_jets_bounded : + ∃ B : ℝ, 1 ≤ B ∧ ∀ k : ℕ, k ≤ 4 → ∀ r, + ‖iteratedFDeriv ℝ k normalizedPlanarMode r‖ ≤ B := by + obtain ⟨B,hB,hb⟩ := planar_mode_jets_bounded + let a : ℝ := (Real.sqrt (∫ x, planarResolventMode x^2))⁻¹ + have he : normalizedPlanarMode = fun x => a • planarResolventMode x := by + funext x + simp only [normalizedPlanarMode,a,smul_eq_mul,div_eq_mul_inv,mul_comm] + refine ⟨‖a‖*B+1,by nlinarith [mul_nonneg (norm_nonneg a) (show 0 ≤ B by linarith)],fun k hk r => ?_⟩ + rw [he,iteratedFDeriv_const_smul_apply' + (planarResolventMode_C7.of_le (show (k : WithTop ℕ∞) ≤ 7 by exact_mod_cast (show k ≤ 7 by omega))).contDiffAt, + norm_smul] + exact (mul_le_mul_of_nonneg_left (hb k hk r) (norm_nonneg a)).trans (by linarith) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeProperties.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeProperties.lean new file mode 100644 index 0000000000000000000000000000000000000000..37f5d9f7a39fb4ee8cac061cea09cc9fab9f2475 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarModeProperties.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolvent + +namespace OAI + +/-! Positivity, finite L² normalization and compact support of the actual +manufactured planar potential. The differential eigen-equation and gap are +not assumed by these declarations. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarResolventKernel_integral : (∫ r, planarResolventKernel r) = 1 := by + unfold planarResolventKernel + rw [← integral_integral_swap (f := fun t r => planarResolventIntegrand (t, r)) + planarResolventIntegrand_integrable] + calc + _ = ∫ t in Set.Ioi (0 : ℝ), Real.exp (-t) := by + apply integral_congr_ae + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + simp only [planarResolventIntegrand, integral_const_mul, planarHeatKernel_integral ht, mul_one] + _ = 1 := integral_exp_neg_Ioi_zero + +theorem planarResolventMode_integrable : Integrable planarResolventMode := + planarResolventKernel_integrable.integrable_convolution (ContinuousLinearMap.mul ℝ ℝ) + planarForcing_integrable + +theorem planarResolventMode_integral : (∫ r, planarResolventMode r) = ∫ r, planarForcing r := by + have h := integral_convolution (ContinuousLinearMap.mul ℝ ℝ) + planarResolventKernel_integrable planarForcing_integrable + simpa only [planarResolventKernel_integral, ContinuousLinearMap.mul_apply', one_mul, + planarResolventMode, convolution] using h + +theorem planarResolventMode_square_integrable : Integrable (fun r => planarResolventMode r ^ 2) := by + apply planarResolventMode_integrable.mono' + (planarResolventMode_C7.continuous.pow 2).aestronglyMeasurable + exact Filter.Eventually.of_forall (fun r => by + change ‖planarResolventMode r ^ 2‖ ≤ planarResolventMode r + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have hp := planarResolventMode_positive r + have hb := planarResolventMode_le_one r + nlinarith) + +theorem planarResolventMode_memLp : MemLp planarResolventMode 2 := + (memLp_two_iff_integrable_sq planarResolventMode_C7.continuous.aestronglyMeasurable).mpr + planarResolventMode_square_integrable + +theorem planarResolventMode_square_integral_positive : + 0 < ∫ r, planarResolventMode r ^ 2 := + integral_pos_of_integrable_nonneg_nonzero (planarResolventMode_C7.continuous.pow 2) + planarResolventMode_square_integrable (fun _ => sq_nonneg _) + (sq_pos_of_pos (planarResolventMode_positive 0)).ne' + +def normalizedPlanarMode (r : PlanarPosition) : ℝ := + planarResolventMode r / Real.sqrt (∫ s, planarResolventMode s ^ 2) + +theorem normalizedPlanarMode_C7 : ContDiff ℝ 7 normalizedPlanarMode := + planarResolventMode_C7.div_const _ + +theorem normalizedPlanarMode_positive (r : PlanarPosition) : 0 < normalizedPlanarMode r := + div_pos (planarResolventMode_positive r) (Real.sqrt_pos.mpr planarResolventMode_square_integral_positive) + +theorem normalizedPlanarMode_normalized : (∫ r, normalizedPlanarMode r ^ 2) = 1 := by + simp_rw [normalizedPlanarMode, div_pow] + rw [integral_div, Real.sq_sqrt planarResolventMode_square_integral_positive.le, + div_self planarResolventMode_square_integral_positive.ne'] + +def manufacturedPlanarWell (r : PlanarPosition) : ℝ := + -planarForcing r / (2 * planarResolventMode r) + +theorem manufacturedPlanarWell_C7 : ContDiff ℝ 7 manufacturedPlanarWell := + planarForcing_C7.neg.div (contDiff_const.mul planarResolventMode_C7) + (fun r => mul_ne_zero (by norm_num) (planarResolventMode_positive r).ne') + +theorem manufacturedPlanarWell_nonpositive (r : PlanarPosition) : manufacturedPlanarWell r ≤ 0 := + div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (planarForcing_nonnegative r)) + (mul_nonneg (by norm_num) (planarResolventMode_positive r).le) + +theorem manufacturedPlanarWell_support : tsupport manufacturedPlanarWell ⊆ tsupport planarForcing := by + apply closure_minimal _ (isClosed_tsupport _) + intro r hr + by_contra hn + apply hr + change -planarForcing r / (2 * planarResolventMode r) = 0 + rw [image_eq_zero_of_notMem_tsupport hn, neg_zero, zero_div] + +theorem manufacturedPlanarWell_hasCompactSupport : HasCompactSupport manufacturedPlanarWell := + planarForcing_hasCompactSupport.of_isClosed_subset (isClosed_tsupport _) + manufacturedPlanarWell_support + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..558f40e4550a36bf9cae6432e8792923106c7bc1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellGap.lean @@ -0,0 +1,138 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellLocalization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarTranslatedGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCutoffTail + +namespace OAI + +/-! The actual planar multiwell form has a fixed excitation gap away from +the span of the translated manufactured modes, up to explicit inverse-square +localization and exponential tail errors. No multiwell spectral input is used. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planar_partition_mass {ι : Type*} [Fintype ι] + (θ : ι → PlanarPosition → ℝ) (hθ : ∀ i, Continuous (θ i)) + (hpart : ∀ x, ∑ i, θ i x ^ 2 = 1) + (f : PlanarPosition → ℝ) (hf : Continuous f) (hc : HasCompactSupport f) : + (∑ i, ∫ x, (θ i x * f x)^2) = ∫ x, f x^2 := by + have hi (i : ι) : Integrable (fun x => (θ i x * f x)^2) := by + have hm : HasCompactSupport (fun x => θ i x * f x) := hc.mul_left + have hs : HasCompactSupport (fun x => (θ i x * f x)^2) := + hm.comp_left (g := fun t : ℝ => t^2) (by norm_num) + exact (((hθ i).mul hf).pow 2).integrable_of_hasCompactSupport hs + rw [← integral_finsetSum _ (fun i _ => hi i)] + apply integral_congr_ae + filter_upwards [] with x + calc + (∑ i, (θ i x * f x)^2) = (∑ i, θ i x^2) * f x^2 := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + ring + _ = _ := by rw [hpart x, one_mul] + +theorem planar_free_form_nonnegative (f : PlanarPosition → ℝ) : + 0 ≤ planarTestForm (fun _ => 0) f := by + unfold planarTestForm + simp only [zero_mul, integral_zero, add_zero] + apply mul_nonneg (by norm_num) + exact Finset.sum_nonneg (fun a _ => integral_nonneg (fun x => sq_nonneg _)) + +theorem planarWellSum_projection_lower {γ : ℝ} (hsmall : γ ≤ 1/4) + (hgap : ∀ (u : PlanarPosition) (f : PlanarPosition → ℝ), + ContDiff ℝ 1 f → HasCompactSupport f → + ((-1/2 : ℝ)+γ) * (∫ x, f x^2) - γ * (∫ x, f x * normalizedPlanarMode (x-u))^2 ≤ + planarTestForm (fun x => manufacturedPlanarWell (x-u)) f) + {m : ℕ} {D : ℝ} (hD : 8 ≤ D) (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : PlanarPosition → ℝ) (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + ((-1/2 : ℝ)+γ) * (∫ x, f x^2) - + γ * (∑ i, (∫ x, (planarSitePartition D u (some i) x * f x) * normalizedPlanarMode (x-u i))^2) - + planarSiteDerivativeBound D ^ 2 * (∫ x, f x^2) ≤ planarTestForm (planarWellSum u) f := by + have hsite (i : Fin m) := hgap (u i) (fun x => planarSitePartition D u (some i) x * f x) + ((planarSitePartition_C1 D u (some i)).mul hf) + (show HasCompactSupport (fun x => planarSitePartition D u (some i) x * f x) from hc.mul_left) + have hs := Finset.sum_le_sum (fun i (_ : i ∈ (Finset.univ : Finset (Fin m))) => hsite i) + simp only [Finset.sum_sub_distrib, ← Finset.mul_sum] at hs + have he : ((-1/2 : ℝ)+γ) * (∫ x, (planarSitePartition D u none x * f x)^2) ≤ + planarTestForm (fun _ => 0) (fun x => planarSitePartition D u none x * f x) := by + have hneg : (-1/2 : ℝ)+γ ≤ 0 := by linarith + exact (mul_nonpos_of_nonpos_of_nonneg hneg (integral_nonneg (fun x => sq_nonneg _))).trans + (planar_free_form_nonnegative _) + have hm := planar_partition_mass (planarSitePartition D u) + (fun i => (planarSitePartition_C1 D u i).continuous) + (planarSitePartition_square_sum (by linarith : 0 < D) u hsep) f hf.continuous hc + rw [Fintype.sum_option] at hm + have hl := planarWellSum_localization_lower hD u hsep f hf hc + calc + _ = (((-1/2 : ℝ)+γ) * (∫ x, (planarSitePartition D u none x * f x)^2) + + (((-1/2 : ℝ)+γ) * (∑ i, ∫ x, (planarSitePartition D u (some i) x * f x)^2) - + γ * (∑ i, (∫ x, (planarSitePartition D u (some i) x * f x) * normalizedPlanarMode (x-u i))^2))) - + planarSiteDerivativeBound D^2 * (∫ x, f x^2) := by rw [← hm]; ring + _ ≤ _ := (sub_le_sub_right (add_le_add he hs) _).trans hl + +theorem planarSiteCutoff_pair_of_orthogonal {D : ℝ} (hD : 0 < D) (u : PlanarPosition) + (f : PlanarPosition → ℝ) (hL2 : MemLp f 2) + (ho : (∫ x, f x * normalizedPlanarMode (x-u)) = 0) : + (∫ x, (Real.sin (planarSiteAngle D u x) * f x) * normalizedPlanarMode (x-u))^2 ≤ + (∫ x, f x^2) * (planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8))) := by + have hmode := normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u) + have hi₀ : Integrable (fun x => f x * normalizedPlanarMode (x-u)) := + hL2.integrable_mul hmode + have hi₁ : Integrable (fun x => f x * planarSiteCutoffError D u x) := + hL2.integrable_mul (planarSiteCutoffError_memLp D u) + have hp : (∫ x, (Real.sin (planarSiteAngle D u x) * f x) * normalizedPlanarMode (x-u)) = + ∫ x, f x * planarSiteCutoffError D u x := by + calc + _ = (∫ x, f x * normalizedPlanarMode (x-u)) + (∫ x, f x * planarSiteCutoffError D u x) := by + rw [← integral_add hi₀ hi₁] + apply integral_congr_ae + filter_upwards [] with x + unfold planarSiteCutoffError + ring + _ = _ := by rw [ho, zero_add] + rw [hp] + exact (planar_l2_pair_sq_le f (planarSiteCutoffError D u) hL2 + (planarSiteCutoffError_memLp D u)).trans + (mul_le_mul_of_nonneg_left (planarSiteCutoffError_integral_bound hD u) + (integral_nonneg (fun x => sq_nonneg _))) + +/-- Quantitative actual test-domain multiwell complement bound. The only +conditional input is the cited isolated planar gap; every localization and +cutoff loss in this formula has been proved for the manufactured functions. -/ +theorem planarWellSum_test_complement_bound + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D : ℝ), 8 ≤ D → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ f : PlanarPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + (∀ i, (∫ x, f x * normalizedPlanarMode (x-u i)) = 0) → + ((-1/2 : ℝ)+γ - planarSiteDerivativeBound D^2 - + γ * m * planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8))) * (∫ x, f x^2) ≤ + planarTestForm (planarWellSum u) f := by + obtain ⟨γ, hγ, hsmall, hgap⟩ := manufacturedPlanarWell_translated_projection_gap hpublished + refine ⟨γ, hγ, hsmall, fun m D hD u hsep f hf hc ho => ?_⟩ + have hL2 : MemLp f 2 := hf.continuous.memLp_of_hasCompactSupport hc + have hp := planarWellSum_projection_lower hsmall hgap hD u hsep f hf hc + have hs : (∑ i : Fin m, + (∫ x, (planarSitePartition D u (some i) x * f x) * normalizedPlanarMode (x-u i))^2) ≤ + m * (∫ x, f x^2) * (planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8))) := by + calc + _ ≤ ∑ i : Fin m, (∫ x, f x^2) * (planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8))) := + Finset.sum_le_sum (fun i _ => planarSiteCutoff_pair_of_orthogonal + (by linarith : 0 < D) (u i) f hL2 (ho i)) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring + have hγs := mul_le_mul_of_nonneg_left hs hγ.le + calc + _ = ((-1/2 : ℝ)+γ) * (∫ x, f x^2) - + γ * (m * (∫ x, f x^2) * (planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8)))) - + planarSiteDerivativeBound D^2 * (∫ x, f x^2) := by ring + _ ≤ _ := (sub_le_sub_right (sub_le_sub_left hγs _) _).trans hp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..239f631cd3f09f36e5311f44f7bf02ed1bacffd4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellMatrix.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellMatrix + +namespace OAI + +/-! The unperturbed shifted multiwell matrix: its leading off-diagonal +entry is the actual hopping, and every remaining term has two tail factors. +No independent matrix approximation is assumed. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def planarMultiwellMatrix {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : ℝ := + ∑ k, if k = j then 0 else planarWellMatrix (u i) (u j) (u k) + +def planarHoppingMatrix {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : ℝ := + if i = j then 0 else -planarHopping ‖u i - u j‖ + +theorem planarMultiwellMatrix_error_eq {m : ℕ} (u : Fin m → PlanarPosition) (i j : Fin m) : + planarMultiwellMatrix u i j - planarHoppingMatrix u i j = + ∑ k, if k ≠ i ∧ k ≠ j then planarWellMatrix (u i) (u j) (u k) else 0 := by + classical + have hpoint (k : Fin m) : + (if k = j then 0 else planarWellMatrix (u i) (u j) (u k)) = + (if k = i then (if i = j then 0 else planarWellMatrix (u i) (u j) (u i)) else 0) + + (if k ≠ i ∧ k ≠ j then planarWellMatrix (u i) (u j) (u k) else 0) := by + by_cases hki : k = i + · subst k + by_cases hij : i = j + · subst j + simp only [ite_true, ne_eq, not_true_eq_false, false_and, ite_false, add_zero] + · simp only [hij, ite_false, ite_true, ne_eq, not_true_eq_false, false_and, add_zero] + · by_cases hkj : k = j + · subst k + simp only [hki, ite_false, ite_true, ne_eq, not_true_eq_false, and_false, add_zero] + · simp only [hki, hkj, ite_false, ne_eq, not_false_eq_true, and_self, ite_true, zero_add] + have hsum := Finset.sum_congr (s₁ := Finset.univ) rfl (fun k _ => hpoint k) + unfold planarMultiwellMatrix planarHoppingMatrix + rw [hsum, Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq', Finset.mem_univ, ite_true, planarWellMatrix_hopping] + ring + +theorem planarMultiwellMatrix_error_bound {D : ℝ} {m : ℕ} + (u : Fin m → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (i j : Fin m) : + |planarMultiwellMatrix u i j - planarHoppingMatrix u i j| ≤ + m * planarWellMatrixConstant * Real.exp (-(19 / 10 : ℝ) * D) := by + rw [planarMultiwellMatrix_error_eq] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _k : Fin m, planarWellMatrixConstant * Real.exp (-(19 / 10 : ℝ) * D) := + Finset.sum_le_sum (fun k _ => by + split_ifs with hk + · exact planarWellMatrix_two_far _ _ _ (hsep i k hk.1.symm) (hsep j k hk.2.symm) + · rw [abs_zero] + exact mul_nonneg planarWellMatrixConstant_nonnegative (Real.exp_pos _).le) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..df03977600705ffded957803ba196a7355176145 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellProjection.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellScale + +namespace OAI + +/-! A global multiwell lower bound on every test function, with actual +uncut orbital coefficients. This form of the estimate is stable under H1 +approximation and tensor products; no exact orthogonality of approximants +is needed. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +private theorem cutoff_add_sq_le {η : ℝ} (hη : 0 < η) (a b : ℝ) : + (a+b)^2 ≤ (1+η)*a^2 + (1+η⁻¹)*b^2 := by + have he : (((1+η)*a^2 + (1+η⁻¹)*b^2) - (a+b)^2)*η = (η*a-b)^2 := by + field_simp [hη.ne'] + ring + have hn : 0 ≤ (((1+η)*a^2 + (1+η⁻¹)*b^2) - (a+b)^2)*η := by + rw [he] + exact sq_nonneg _ + exact sub_nonneg.mp ((nonneg_of_mul_nonneg_left hn hη)) + +theorem planarSiteCutoff_pair_error {D : ℝ} (hD : 0 < D) (u : PlanarPosition) + (f : PlanarPosition → ℝ) (hf : MemLp f 2) : + ((∫ x, (Real.sin (planarSiteAngle D u x)*f x)*normalizedPlanarMode (x-u)) - + (∫ x, f x*normalizedPlanarMode (x-u)))^2 ≤ + (∫ x, f x^2)*(planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8))) := by + have hm := normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u) + have hi₀ : Integrable (fun x => f x*normalizedPlanarMode (x-u)) := hf.integrable_mul hm + have hi₁ : Integrable (fun x => f x*planarSiteCutoffError D u x) := + hf.integrable_mul (planarSiteCutoffError_memLp D u) + have he : (∫ x, (Real.sin (planarSiteAngle D u x)*f x)*normalizedPlanarMode (x-u)) - + (∫ x, f x*normalizedPlanarMode (x-u)) = ∫ x, f x*planarSiteCutoffError D u x := by + have hp : (fun x => (Real.sin (planarSiteAngle D u x)*f x)*normalizedPlanarMode (x-u)) = + (fun x => f x*normalizedPlanarMode (x-u) + f x*planarSiteCutoffError D u x) := by + funext x + unfold planarSiteCutoffError + ring + rw [hp, integral_add hi₀ hi₁] + ring + rw [he] + exact (planar_l2_pair_sq_le f (planarSiteCutoffError D u) hf + (planarSiteCutoffError_memLp D u)).trans + (mul_le_mul_of_nonneg_left (planarSiteCutoffError_integral_bound hD u) + (integral_nonneg (fun x => sq_nonneg _))) + +theorem planarSiteCutoff_pair_bound {D η : ℝ} (hD : 0 < D) (hη : 0 < η) + (u : PlanarPosition) (f : PlanarPosition → ℝ) (hf : MemLp f 2) : + (∫ x, (Real.sin (planarSiteAngle D u x)*f x)*normalizedPlanarMode (x-u))^2 ≤ + (1+η)*(∫ x, f x*normalizedPlanarMode (x-u))^2 + + (1+η⁻¹)*(∫ x, f x^2)*(planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8))) := by + have hy := cutoff_add_sq_le hη (∫ x, f x*normalizedPlanarMode (x-u)) + ((∫ x, (Real.sin (planarSiteAngle D u x)*f x)*normalizedPlanarMode (x-u)) - + (∫ x, f x*normalizedPlanarMode (x-u))) + have he := mul_le_mul_of_nonneg_left (planarSiteCutoff_pair_error hD u f hf) + (show 0 ≤ 1+η⁻¹ by positivity) + nlinarith + +/-- Global lower bound with explicitly controlled finite orbital form and +cutoff error. The only spectral input is the published isolated-well gap. -/ +theorem planarWellSum_test_projection_bound + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η : ℝ), 8 ≤ D → 0 < η → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ f : PlanarPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + ((-1/2:ℝ)+γ-planarSiteDerivativeBound D^2- + γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8)))*(∫ x, f x^2) - + γ*(1+η)*(∑ i, (∫ x, f x*normalizedPlanarMode (x-u i))^2) ≤ + planarTestForm (planarWellSum u) f := by + obtain ⟨γ, hγ, hsmall, hgap⟩ := manufacturedPlanarWell_translated_projection_gap hpublished + refine ⟨γ, hγ, hsmall, fun m D η hD hη u hsep f hf hc => ?_⟩ + have hL2 : MemLp f 2 := hf.continuous.memLp_of_hasCompactSupport hc + have h := planarWellSum_projection_lower hsmall hgap hD u hsep f hf hc + have hs : (∑ i, (∫ x, (planarSitePartition D u (some i) x*f x)* + normalizedPlanarMode (x-u i))^2) ≤ + (1+η)*(∑ i, (∫ x, f x*normalizedPlanarMode (x-u i))^2) + + (1+η⁻¹)*m*(∫ x, f x^2)*(planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8))) := by + calc + _ ≤ ∑ i, ((1+η)*(∫ x, f x*normalizedPlanarMode (x-u i))^2 + + (1+η⁻¹)*(∫ x, f x^2)*(planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8)))) := + Finset.sum_le_sum (fun i _ => planarSiteCutoff_pair_bound (by linarith) hη (u i) f hL2) + _ = _ := by + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + ring + have hm := mul_le_mul_of_nonneg_left hs hγ.le + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3ee2ad293712a092b2f6c81217da68480a62c12 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarMultiwellScale.lean @@ -0,0 +1,128 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellGap +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! A fixed planar excitation gap for exponentially many separated sites. +The scale is chosen once from the isolated-well gap, independently of the +number of sites and the input instance. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +theorem planarSiteDerivativeBound_tendsto : + Tendsto planarSiteDerivativeBound atTop (𝓝 0) := by + have h := (tendsto_inv_atTop_zero.const_mul (6 : ℝ)).const_mul (Real.pi / 2) + have h' := h.mul_const PlanarSobolev.cutoffGradBound + change Tendsto (fun D : ℝ => (Real.pi / 2 * (6 / D)) * PlanarSobolev.cutoffGradBound) + atTop (𝓝 0) + simpa only [div_eq_mul_inv, mul_zero, zero_mul] using h' + +/-- One fixed separation threshold controls both the IMS loss and the sum +of cutoff tails for all site counts at most `exp(19 D / 320)`. -/ +theorem exists_planar_multiwell_loss_threshold {γ : ℝ} (hγ : 0 < γ) : + ∃ R : ℝ, 8 ≤ R ∧ ∀ D : ℝ, R ≤ D → ∀ m : ℕ, + (m : ℝ) ≤ Real.exp ((19/320 : ℝ) * D) → + planarSiteDerivativeBound D ^ 2 + + γ * m * planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8)) ≤ γ / 2 := by + have hexp : Tendsto (fun D : ℝ => Real.exp (-(19/320 : ℝ) * D)) atTop (𝓝 0) := by + simpa only [Function.comp_def, id_eq, neg_mul] using Real.tendsto_exp_neg_atTop_nhds_zero.comp + (tendsto_id.const_mul_atTop (by norm_num : (0 : ℝ) < 19/320)) + have hlim : Tendsto (fun D : ℝ => planarSiteDerivativeBound D ^ 2 + + γ * planarSiteTailConstant * Real.exp (-(19/320 : ℝ) * D)) atTop (𝓝 0) := by + simpa using (planarSiteDerivativeBound_tendsto.pow 2).add + (hexp.const_mul (γ * planarSiteTailConstant)) + have hevent : ∀ᶠ D : ℝ in atTop, planarSiteDerivativeBound D ^ 2 + + γ * planarSiteTailConstant * Real.exp (-(19/320 : ℝ) * D) < γ / 2 := + hlim.eventually (gt_mem_nhds (by linarith)) + obtain ⟨R, hR⟩ := Filter.eventually_atTop.1 hevent + refine ⟨max 8 R, le_max_left _ _, fun D hD m hm => ?_⟩ + have htail : γ * m * planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8)) ≤ + γ * planarSiteTailConstant * Real.exp (-(19/320 : ℝ) * D) := by + have hC : 0 ≤ γ * planarSiteTailConstant := + mul_nonneg hγ.le planarSiteTailConstant_nonnegative + calc + _ = (γ * planarSiteTailConstant) * + ((m : ℝ) * Real.exp (-(19/20 : ℝ) * (D/8))) := by ring + _ ≤ (γ * planarSiteTailConstant) * + (Real.exp ((19/320 : ℝ) * D) * Real.exp (-(19/20 : ℝ) * (D/8))) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hm (Real.exp_pos _).le) hC + _ = _ := by rw [← Real.exp_add]; congr 2; ring + have hh := (hR D ((le_max_right _ _).trans hD)).le + linarith + + +/-- A single polynomial exponent meets the fixed separation cutoff and +supports every polynomial site count for every input size at least two. -/ +theorem exists_uniform_multiwell_scale (A : ℕ) (R : ℝ) {c : ℝ} (hc : 0 < c) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + R ≤ c * ((k : ℝ) * Real.log N) ∧ + N ^ A ≤ Real.exp ((19/320 : ℝ) * (c * ((k : ℝ) * Real.log N))) := by + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hp : 0 < (19/320 : ℝ) * c := mul_pos (by norm_num) hc + obtain ⟨k, hk⟩ := exists_nat_gt + (max 0 (max (R / (c * Real.log 2)) ((A : ℝ) / ((19/320 : ℝ) * c)))) + have hk0 : (0 : ℝ) < k := (le_max_left _ _).trans_lt hk + have hkR : R / (c * Real.log 2) ≤ k := + ((le_max_left _ _).trans (le_max_right _ _)).trans hk.le + have hkA : (A : ℝ) / ((19/320 : ℝ) * c) ≤ k := + ((le_max_right _ _).trans (le_max_right _ _)).trans hk.le + have hR := (div_le_iff₀ (mul_pos hc hlog)).mp hkR + have hA := (div_le_iff₀ hp).mp hkA + refine ⟨k, by exact_mod_cast hk0, fun N hN => ?_⟩ + have hN0 : 0 < N := by linarith + have hln : Real.log 2 ≤ Real.log N := Real.log_le_log (by norm_num) hN + have hln0 : 0 ≤ Real.log N := Real.log_nonneg (by linarith) + constructor + · calc + R ≤ c * ((k : ℝ) * Real.log 2) := by nlinarith [hR] + _ ≤ _ := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hln hk0.le) hc.le + · calc + N ^ A = Real.exp ((A : ℝ) * Real.log N) := by + rw [Real.exp_nat_mul, Real.exp_log hN0] + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith [mul_le_mul_of_nonneg_right hA hln0]) + +/-- Conditional only on the published isolated-well gap. The full spatial +multiwell geometry and the aggregate tail error have already been bounded. -/ +theorem planarWellSum_uniform_test_complement_gap + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ R : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ 8 ≤ R ∧ + ∀ (m : ℕ) (D : ℝ), R ≤ D → (m : ℝ) ≤ Real.exp ((19/320 : ℝ) * D) → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ f : PlanarPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + (∀ i, (∫ x, f x * normalizedPlanarMode (x-u i)) = 0) → + ((-1/2 : ℝ) + γ/2) * (∫ x, f x^2) ≤ planarTestForm (planarWellSum u) f := by + obtain ⟨γ, hγ, hsmall, hgap⟩ := planarWellSum_test_complement_bound hpublished + obtain ⟨R, hR, hloss⟩ := exists_planar_multiwell_loss_threshold hγ + refine ⟨γ, R, hγ, hsmall, hR, fun m D hD hm u hsep f hf hc ho => ?_⟩ + have hl := hloss D hD m hm + have hcoef : (-1/2 : ℝ) + γ/2 ≤ (-1/2 : ℝ) + γ - planarSiteDerivativeBound D^2 - + γ * m * planarSiteTailConstant * Real.exp (-(19/20 : ℝ) * (D/8)) := by linarith + exact (mul_le_mul_of_nonneg_right hcoef (integral_nonneg (fun x => sq_nonneg _))).trans + (hgap m D (hR.trans hD) u hsep f hf hc ho) + +/-- Reduction-scale version: a fixed exponent works uniformly for all +input sizes and every separated configuration with polynomially many sites. -/ +theorem planarWellSum_polynomial_test_complement_gap + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) + (A : ℕ) {c : ℝ} (hc : 0 < c) : + ∃ γ : ℝ, 0 < γ ∧ ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + ∀ m : ℕ, (m : ℝ) ≤ N ^ A → ∀ u : Fin m → PlanarPosition, + (∀ i j, i ≠ j → c*((k : ℝ)*Real.log N) ≤ ‖u i-u j‖) → + ∀ f : PlanarPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + (∀ i, (∫ x, f x*normalizedPlanarMode (x-u i)) = 0) → + ((-1/2 : ℝ)+γ) * (∫ x, f x^2) ≤ planarTestForm (planarWellSum u) f := by + obtain ⟨γ, R, hγ, _, _, hgap⟩ := planarWellSum_uniform_test_complement_gap hpublished + obtain ⟨k, hk, hscale⟩ := exists_uniform_multiwell_scale A R hc + refine ⟨γ/2, by positivity, k, hk, fun N hN m hm u hsep f hf hcf ho => ?_⟩ + obtain ⟨hR, hcount⟩ := hscale N hN + exact hgap m (c*((k : ℝ)*Real.log N)) hR (hm.trans hcount) u hsep f hf hcf ho + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNearGroundCompactness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNearGroundCompactness.lean new file mode 100644 index 0000000000000000000000000000000000000000..079dcac58eff76996a2e9afb009a061b8ad909a7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNearGroundCompactness.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCompactnessEstimates + +namespace OAI + +/-! Compactness of normalized near-ground sequences for the actual well. +The positive free form makes compactness of the potential multiplier enough. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb.PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance instPlanarNearGroundCompactnessMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarNearGroundCompactnessBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarNearGroundCompactnessMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem nearGround_cauchy_of_potential_cauchy (u : ℕ → Sobolev) + (hm : ∀ n, ‖(u n).val.1‖ ≤ 1) + (hs : Tendsto (fun n => shiftedForm (u n).val) atTop (𝓝 0)) + (hw : CauchySeq (fun n => wellMultiplier (u n).val.1)) : CauchySeq u := by + apply Metric.cauchySeq_iff.mpr + intro ε hε + have hδ : 0 < ε^2/16 := by positivity + obtain ⟨N,hN⟩ := Metric.tendsto_atTop.mp hs (ε^2/16) hδ + obtain ⟨M,hM⟩ := Metric.cauchySeq_iff.mp hw (ε^2/16) hδ + refine ⟨max N M,fun n hn m hm' => ?_⟩ + have hn' : shiftedForm (u n).val < ε^2/16 := by + have h := hN n ((le_max_left _ _).trans hn) + simpa only [dist_zero_right,Real.norm_eq_abs, + abs_of_nonneg (shiftedForm_nonnegative (u n))] using h + have hm'' : shiftedForm (u m).val < ε^2/16 := by + have h := hN m ((le_max_left _ _).trans hm') + simpa only [dist_zero_right,Real.norm_eq_abs, + abs_of_nonneg (shiftedForm_nonnegative (u m))] using h + have hd := hM n ((le_max_right _ _).trans hn) m ((le_max_right _ _).trans hm') + have he := nearGround_distance_bound (u n) (u m) (hm n) (hm m) + nlinarith [(dist_nonneg : 0 ≤ dist (u n) (u m))] + +theorem nearGround_subsequence (u : ℕ → Sobolev) + (hm : ∀ n, ‖(u n).val.1‖ ≤ 1) (hb : ∀ n, shiftedForm (u n).val ≤ 1) + (hs : Tendsto (fun n => shiftedForm (u n).val) atTop (𝓝 0)) : + ∃ v : Sobolev, ∃ φ : ℕ → ℕ, StrictMono φ ∧ Tendsto (u ∘ φ) atTop (𝓝 v) := by + let W := wellMultiplier.comp (h1ToL2 (μ := volume) (E := PlanarPosition)) + obtain ⟨K,hK,hWK⟩ := wellMultiplier_compact.image_closedBall_subset_compact + (3+2*‖wellMultiplier‖) + have hmem (n : ℕ) : W (u n) ∈ K := by + apply hWK + refine ⟨u n,?_,rfl⟩ + rw [Metric.mem_closedBall,dist_zero_right] + exact nearGround_norm_bound (u n) (hm n) (hb n) + obtain ⟨w,_hw,φ,hφ,hlim⟩ := hK.tendsto_subseq hmem + have hW : CauchySeq (fun n => wellMultiplier (u (φ n)).val.1) := hlim.cauchySeq + have hc := nearGround_cauchy_of_potential_cauchy (u ∘ φ) + (fun n => hm (φ n)) (hs.comp hφ.tendsto_atTop) hW + obtain ⟨v,hv⟩ := cauchySeq_tendsto_of_complete hc + exact ⟨v,φ,hφ,hv⟩ + +end ContinuumCoulomb.PlanarSobolev + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationBox.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfc76adb5ce45425e17455b9433445aa5fea5223 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationBox.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalizationTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxBounds + +namespace OAI + +/-! A finite square approximates the actual normalization integral with +an explicit exponential error; no compact-support surrogate is used. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarNormalizationBox (L : ℝ) : ℝ := + ∫ x in (-L)..L, ∫ y in (-L)..L, + planarResolventMode (planarPairEquiv.symm (x, y)) ^ 2 + +theorem planarPair_norm_box {L : ℝ} (hL : 0 ≤ L) {p : ℝ × ℝ} + (hp : p ∈ Set.Icc (-L) L ×ˢ Set.Icc (-L) L) : + ‖planarPairEquiv.symm p‖ ≤ 2 * L := by + have hx : p.1 ^ 2 ≤ L ^ 2 := by + have h := (sq_le_sq₀ (abs_nonneg p.1) hL).mpr (abs_le.mpr hp.1) + simpa only [sq_abs] using h + have hy : p.2 ^ 2 ≤ L ^ 2 := by + have h := (sq_le_sq₀ (abs_nonneg p.2) hL).mpr (abs_le.mpr hp.2) + simpa only [sq_abs] using h + have heq := planarPair_norm_sq p + nlinarith [norm_nonneg (planarPairEquiv.symm p)] + +theorem planarNormalizationBox_error {L : ℝ} (hL : 0 ≤ L) : + |planarNormalizationBox L - (∫ r, planarResolventMode r ^ 2)| ≤ + 1024 * Real.exp (-(1 / 2 : ℝ) * L) := by + let f := fun p : ℝ × ℝ => planarResolventMode (planarPairEquiv.symm p) ^ 2 + let S := Set.Icc (-L) L ×ˢ Set.Icc (-L) L + let C := planarExponentialConstant (1 / 2) ^ 2 * Real.exp (-(1 / 2 : ℝ) * L) + have hC : 0 ≤ C := by dsimp [C]; positivity + have hf : Continuous f := + (planarResolventMode_C7.continuous.comp planarPairEquiv_symm_continuous).pow 2 + have hfi : Integrable f := by + apply (planarPairEquiv_measurePreserving.integrable_comp hf.aestronglyMeasurable).mp + change Integrable (fun r : PlanarPosition => + planarResolventMode (planarPairEquiv.symm (planarPairEquiv r)) ^ 2) + simpa only [MeasurableEquiv.symm_apply_apply] using planarResolventMode_square_integrable + have hg : Continuous (fun p : ℝ × ℝ => Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖)) := by + exact Real.continuous_exp.comp (continuous_const.mul planarPairEquiv_symm_continuous.norm) + have hgi : Integrable (fun p : ℝ × ℝ => Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖)) := by + apply (planarPairEquiv_measurePreserving.integrable_comp hg.aestronglyMeasurable).mp + change Integrable (fun r : PlanarPosition => + Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm (planarPairEquiv r)‖)) + simpa only [MeasurableEquiv.symm_apply_apply] using + planar_exp_norm_integrable (by norm_num : (0 : ℝ) < 1 / 2) + have hS : MeasurableSet S := measurableSet_Icc.prod measurableSet_Icc + have hbox : (∫ p in S, f p) = planarNormalizationBox L := by + change (∫ p in Set.Icc (-L) L ×ˢ Set.Icc (-L) L, f p) = _ + rw [Measure.volume_eq_prod, setIntegral_prod f hfi.integrableOn] + simp_rw [integral_Icc_eq_integral_Ioc, + ← intervalIntegral.integral_of_le (by linarith : -L ≤ L)] + rfl + have hnorm (p : ℝ × ℝ) (hp : p ∈ Sᶜ) : L ≤ ‖planarPairEquiv.symm p‖ := by + have h0 : |p.1| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_zero, + Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 0 + have h1 : |p.2| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_one, + Matrix.cons_val_fin_one, Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 1 + by_contra hn + have hn' : ‖planarPairEquiv.symm p‖ < L := lt_of_not_ge hn + apply hp + exact ⟨⟨by linarith [neg_abs_le p.1], by linarith [le_abs_self p.1]⟩, + ⟨by linarith [neg_abs_le p.2], by linarith [le_abs_self p.2]⟩⟩ + have hout := setIntegral_mono_on hfi.integrableOn (hgi.const_mul C).integrableOn + hS.compl (fun p hp => planarResolvent_square_tail_pointwise (planarPairEquiv.symm p) (hnorm p hp)) + have htotal := integral_mono_measure (μ := volume.restrict Sᶜ) Measure.restrict_le_self + (Filter.Eventually.of_forall (fun p => + mul_nonneg hC (Real.exp_pos (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖)).le)) + (hgi.const_mul C) + have heval : (∫ p : ℝ × ℝ, C * Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖)) = + planarNormalizationTailConstant * Real.exp (-(1 / 2 : ℝ) * L) := by + rw [integral_const_mul, + ← planarPair_integral (fun r : PlanarPosition => Real.exp (-(1 / 2 : ℝ) * ‖r‖))] + unfold C planarNormalizationTailConstant + ring + have houtBound : (∫ p in Sᶜ, f p) ≤ 1024 * Real.exp (-(1 / 2 : ℝ) * L) := + ((hout.trans htotal).trans_eq heval).trans + (mul_le_mul_of_nonneg_right planarNormalizationTailConstant_le (Real.exp_pos _).le) + have hout0 : 0 ≤ ∫ p in Sᶜ, f p := integral_nonneg (fun p => sq_nonneg _) + have heq := integral_add_compl hS hfi + have hfull : (∫ p, f p) = ∫ r, planarResolventMode r ^ 2 := + (planarPair_integral (fun r => planarResolventMode r ^ 2)).symm + rw [hbox, hfull] at heq + rw [show planarNormalizationBox L - (∫ r, planarResolventMode r ^ 2) = + -(∫ p in Sᶜ, f p) by linarith, abs_neg, abs_of_nonneg hout0] + exact houtBound + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba9c94d31cc0d8776e060be496d8b88b48c0061b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalizationTail.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarExponentialEnvelope +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatBoxCoordinates + +namespace OAI + +/-! Quantitative truncation of the actual planar normalization integral. +All constants below depend only on the fixed manufactured forcing. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarNormalizationTailConstant : ℝ := + planarExponentialConstant (1 / 2) ^ 2 * + ∫ r : PlanarPosition, Real.exp (-(1 / 2 : ℝ) * ‖r‖) + +theorem planarNormalizationTailConstant_nonnegative : + 0 ≤ planarNormalizationTailConstant := by + unfold planarNormalizationTailConstant + exact mul_nonneg (sq_nonneg _) (integral_nonneg (fun _ => (Real.exp_pos _).le)) + +theorem real_quarter_exponential_integral : + (∫ x : ℝ, Real.exp (-(1 / 4 : ℝ) * |x|)) = 8 := by + rw [integral_comp_abs (f := fun x : ℝ => Real.exp (-(1 / 4 : ℝ) * x))] + have h := integral_exp_mul_Ioi (by norm_num : -(1 / 4 : ℝ) < 0) 0 + norm_num at h ⊢ + linarith + +theorem planar_half_exponential_integral_le : + (∫ r : PlanarPosition, Real.exp (-(1 / 2 : ℝ) * ‖r‖)) ≤ 64 := by + let g := fun x : ℝ => Real.exp (-(1 / 4 : ℝ) * |x|) + have hg : Integrable g := Integrable.of_integral_ne_zero (by + change (∫ x : ℝ, Real.exp (-(1 / 4 : ℝ) * |x|)) ≠ 0 + rw [real_quarter_exponential_integral] + norm_num) + have hprod : Integrable (fun p : ℝ × ℝ => g p.1 * g p.2) := by + simpa only [Measure.volume_eq_prod] using hg.mul_prod hg + have hbound (p : ℝ × ℝ) : Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖) ≤ + g p.1 * g p.2 := by + have h0 : |p.1| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_zero, + Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 0 + have h1 : |p.2| ≤ ‖planarPairEquiv.symm p‖ := by + simpa only [planarPairEquiv_symm_apply, PiLp.toLp_apply, Matrix.cons_val_one, + Matrix.cons_val_fin_one, Real.norm_eq_abs] using PiLp.norm_apply_le (planarPairEquiv.symm p) 1 + dsimp only [g] + rw [← Real.exp_add] + exact Real.exp_le_exp.mpr (by linarith) + have hi : Integrable (fun p : ℝ × ℝ => + Real.exp (-(1 / 2 : ℝ) * ‖planarPairEquiv.symm p‖)) := by + apply hprod.mono' (by fun_prop) + exact Filter.Eventually.of_forall (fun p => by + rw [Real.norm_of_nonneg (Real.exp_pos _).le] + exact hbound p) + rw [planarPair_integral] + apply (integral_mono hi hprod hbound).trans_eq + rw [Measure.volume_eq_prod, integral_prod_mul] + change (∫ x : ℝ, Real.exp (-(1 / 4 : ℝ) * |x|)) * + (∫ x : ℝ, Real.exp (-(1 / 4 : ℝ) * |x|)) = 64 + rw [real_quarter_exponential_integral] + norm_num + +theorem planarNormalizationTailConstant_le : planarNormalizationTailConstant ≤ 1024 := by + have he := Real.exp_bound_div_one_sub_of_interval (by norm_num : (0 : ℝ) ≤ 1 / 2) + (by norm_num : (1 / 2 : ℝ) < 1) + norm_num at he + have hC : 0 ≤ planarExponentialConstant (1 / 2) := + (planarExponentialConstant_positive (by norm_num) (by norm_num)).le + have hC' : planarExponentialConstant (1 / 2) ≤ 4 := by + unfold planarExponentialConstant + norm_num + linarith + have hm := planar_half_exponential_integral_le + have hm0 : 0 ≤ ∫ r : PlanarPosition, Real.exp (-(1 / 2 : ℝ) * ‖r‖) := + integral_nonneg (fun _ => (Real.exp_pos _).le) + unfold planarNormalizationTailConstant + nlinarith + +theorem planarResolvent_square_tail_pointwise {L : ℝ} (r : PlanarPosition) + (hr : L ≤ ‖r‖) : + planarResolventMode r ^ 2 ≤ + (planarExponentialConstant (1 / 2) ^ 2 * Real.exp (-(1 / 2 : ℝ) * L)) * + Real.exp (-(1 / 2 : ℝ) * ‖r‖) := by + have he := pow_le_pow_left₀ (planarResolventMode_positive r).le + (planarResolventMode_exponential_envelope (by norm_num : (0 : ℝ) ≤ 1 / 2) + (by norm_num : (1 / 2 : ℝ) < 1) r) 2 + rw [mul_pow, ← Real.exp_nat_mul] at he + have hexp : Real.exp ((2 : ℝ) * (-(1 / 2 : ℝ) * ‖r‖)) ≤ + Real.exp (-(1 / 2 : ℝ) * L) * Real.exp (-(1 / 2 : ℝ) * ‖r‖) := by + rw [← Real.exp_add] + exact Real.exp_le_exp.mpr (by linarith) + exact he.trans ((mul_le_mul_of_nonneg_left hexp + (sq_nonneg (planarExponentialConstant (1 / 2)))).trans_eq (by ring)) + +theorem planarNormalization_tail (L : ℝ) : + (∫ r in {r : PlanarPosition | L ≤ ‖r‖}, planarResolventMode r ^ 2) ≤ + planarNormalizationTailConstant * Real.exp (-(1 / 2 : ℝ) * L) := by + let C := planarExponentialConstant (1 / 2) ^ 2 * Real.exp (-(1 / 2 : ℝ) * L) + have hC : 0 ≤ C := by dsimp [C]; positivity + have hi := (planar_exp_norm_integrable (by norm_num : (0 : ℝ) < 1 / 2)).const_mul C + have h := setIntegral_mono_on planarResolventMode_square_integrable.integrableOn + hi.integrableOn (isClosed_le continuous_const continuous_norm).measurableSet + (fun r hr => planarResolvent_square_tail_pointwise r hr) + have h' := integral_mono_measure + (μ := volume.restrict {r : PlanarPosition | L ≤ ‖r‖}) (Measure.restrict_le_self) (Filter.Eventually.of_forall (fun r => + mul_nonneg hC (Real.exp_pos _).le)) hi + calc + _ ≤ ∫ r in {r : PlanarPosition | L ≤ ‖r‖}, C * Real.exp (-(1 / 2 : ℝ) * ‖r‖) := h + _ ≤ ∫ r : PlanarPosition, C * Real.exp (-(1 / 2 : ℝ) * ‖r‖) := h' + _ = _ := by rw [integral_const_mul]; unfold planarNormalizationTailConstant C; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalized.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalized.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c17ccfcc27797125bca31f05ce61211976d20d9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarNormalized.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventEquation + +namespace OAI + +/-! Analytic identities for the actual normalized planar mode. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarPartial_const_mul {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 1 f) + (c : ℝ) (e r : PlanarPosition) : + planarPartial (fun x => c * f x) e r = c * planarPartial f e r := by + unfold planarPartial + rw [fderiv_const_mul (hf.differentiable (by norm_num) r) c] + rfl + +theorem planarLaplacian_const_mul {f : PlanarPosition → ℝ} (hf : ContDiff ℝ 2 f) + (c : ℝ) (r : PlanarPosition) : + planarLaplacian (fun x => c * f x) r = c * planarLaplacian f r := by + have h (e : PlanarPosition) : planarPartial (fun x => c * f x) e = + fun x => c * planarPartial f e x := + funext (planarPartial_const_mul (hf.of_le (by norm_num)) c e) + simp only [planarLaplacian] + simp_rw [h] + simp_rw [planarPartial_const_mul (planarPartial_C1 hf _)] + exact (Finset.mul_sum _ _ _).symm + +theorem normalizedPlanarMode_eq_const_mul : normalizedPlanarMode = + fun r => (Real.sqrt (∫ s, planarResolventMode s ^ 2))⁻¹ * planarResolventMode r := by + funext r + simp only [normalizedPlanarMode, div_eq_mul_inv, mul_comm] + +theorem normalizedPlanarMode_square_integrable : + Integrable (fun r => normalizedPlanarMode r ^ 2) := by + simp_rw [normalizedPlanarMode, div_pow] + exact planarResolventMode_square_integrable.div_const _ + +theorem normalizedPlanarMode_memLp : MemLp normalizedPlanarMode 2 := + (memLp_two_iff_integrable_sq normalizedPlanarMode_C7.continuous.aestronglyMeasurable).mpr + normalizedPlanarMode_square_integrable + +theorem normalizedPlanarMode_eigen_equation (r : PlanarPosition) : + planarLaplacian normalizedPlanarMode r = + (2 * manufacturedPlanarWell r + 1) * normalizedPlanarMode r := by + rw [normalizedPlanarMode_eq_const_mul, + planarLaplacian_const_mul (planarResolventMode_C7.of_le (by norm_num)), + manufacturedPlanarWell_eigen_equation] + ring + +theorem planarPartial_translate (f : PlanarPosition → ℝ) (u e r : PlanarPosition) : + planarPartial (fun x => f (x - u)) e r = planarPartial f e (r - u) := by + simp only [planarPartial, fderiv_comp_sub] + +theorem planarLaplacian_translate (f : PlanarPosition → ℝ) (u r : PlanarPosition) : + planarLaplacian (fun x => f (x - u)) r = planarLaplacian f (r - u) := by + have h (e : PlanarPosition) : planarPartial (fun x => f (x - u)) e = + fun x => planarPartial f e (x - u) := funext (planarPartial_translate f u e) + simp only [planarLaplacian] + simp_rw [h, planarPartial_translate] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarOverlap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarOverlap.lean new file mode 100644 index 0000000000000000000000000000000000000000..010b3d2e2c22d69678f96c57697c617df1e09320 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarOverlap.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarExponentialEnvelope +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalized + +namespace OAI + +/-! Actual normalized planar orbitals have overlap bounded at rate 0.9, +uniformly over every pair of centers. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def normalizedPlanarExponentialConstant (a : ℝ) : ℝ := + planarExponentialConstant a / Real.sqrt (∫ r, planarResolventMode r ^ 2) + +theorem normalizedPlanarExponentialConstant_positive {a : ℝ} (ha : 0 ≤ a) (ha₁ : a < 1) : + 0 < normalizedPlanarExponentialConstant a := + div_pos (planarExponentialConstant_positive ha ha₁) + (Real.sqrt_pos.mpr planarResolventMode_square_integral_positive) + +theorem normalizedPlanarMode_exponential_envelope {a : ℝ} (ha : 0 ≤ a) (ha₁ : a < 1) + (r : PlanarPosition) : + normalizedPlanarMode r ≤ normalizedPlanarExponentialConstant a * Real.exp (-a * ‖r‖) := by + have h := div_le_div_of_nonneg_right (planarResolventMode_exponential_envelope ha ha₁ r) + (Real.sqrt_nonneg (∫ r, planarResolventMode r ^ 2)) + convert h using 1 + · rfl + · unfold normalizedPlanarExponentialConstant + ring + +def planarModeOverlap (u v : PlanarPosition) : ℝ := + ∫ r, normalizedPlanarMode (r - u) * normalizedPlanarMode (r - v) + +theorem planarModeOverlap_integrable (u v : PlanarPosition) : + Integrable (fun r => normalizedPlanarMode (r - u) * normalizedPlanarMode (r - v)) := + (normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u)).integrable_mul + (normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume v)) + +theorem planarModeOverlap_nonnegative (u v : PlanarPosition) : 0 ≤ planarModeOverlap u v := + integral_nonneg (fun _ => mul_nonneg (normalizedPlanarMode_positive _).le (normalizedPlanarMode_positive _).le) + +theorem planarModeOverlap_diagonal (u : PlanarPosition) : planarModeOverlap u u = 1 := by + unfold planarModeOverlap + simp_rw [← pow_two] + rw [integral_sub_right_eq_self (fun r => normalizedPlanarMode r ^ 2) u, + normalizedPlanarMode_normalized] + +theorem planarModeOverlap_envelope {a b : ℝ} (hb : 0 ≤ b) (hba : b < a) (ha₁ : a < 1) + (u v : PlanarPosition) : + planarModeOverlap u v ≤ + (normalizedPlanarExponentialConstant a ^ 2 * + (∫ r : PlanarPosition, Real.exp (-(a - b) * ‖r‖))) * Real.exp (-b * ‖u - v‖) := by + have ha : 0 ≤ a := le_trans hb hba.le + have hC := (normalizedPlanarExponentialConstant_positive ha ha₁).le + have hpt (r : PlanarPosition) : + normalizedPlanarMode (r - u) * normalizedPlanarMode (r - v) ≤ + (normalizedPlanarExponentialConstant a ^ 2 * Real.exp (-b * ‖u - v‖)) * + Real.exp (-(a - b) * ‖r - u‖) := by + have ht : ‖u - v‖ ≤ ‖r - u‖ + ‖r - v‖ := by + simpa only [dist_eq_norm, norm_sub_rev u r] using dist_triangle u r v + have hs := mul_le_mul_of_nonneg_left ht hb + have he : -a * (‖r - u‖ + ‖r - v‖) ≤ -b * ‖u - v‖ + -(a - b) * ‖r - u‖ := by + nlinarith [mul_nonneg (sub_pos.mpr hba).le (norm_nonneg (r - v))] + calc + _ ≤ (normalizedPlanarExponentialConstant a * Real.exp (-a * ‖r - u‖)) * + (normalizedPlanarExponentialConstant a * Real.exp (-a * ‖r - v‖)) := + mul_le_mul (normalizedPlanarMode_exponential_envelope ha ha₁ _) + (normalizedPlanarMode_exponential_envelope ha ha₁ _) + (normalizedPlanarMode_positive _).le (mul_nonneg hC (Real.exp_pos _).le) + _ = normalizedPlanarExponentialConstant a ^ 2 * Real.exp (-a * (‖r - u‖ + ‖r - v‖)) := by + rw [show -a * (‖r - u‖ + ‖r - v‖) = -a * ‖r - u‖ + -a * ‖r - v‖ by ring, + Real.exp_add] + ring + _ ≤ normalizedPlanarExponentialConstant a ^ 2 * + Real.exp (-b * ‖u - v‖ + -(a - b) * ‖r - u‖) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr he) (sq_nonneg _) + _ = _ := by rw [Real.exp_add]; ring + have hi := ((planar_exp_norm_integrable (sub_pos.mpr hba)).comp_sub_right u).const_mul + (normalizedPlanarExponentialConstant a ^ 2 * Real.exp (-b * ‖u - v‖)) + have h := integral_mono (planarModeOverlap_integrable u v) hi hpt + rw [integral_const_mul, integral_sub_right_eq_self + (fun r : PlanarPosition => Real.exp (-(a - b) * ‖r‖)) u] at h + exact h.trans_eq (by ring) + +def planarOverlapConstant : ℝ := normalizedPlanarExponentialConstant (19 / 20) ^ 2 * + (∫ r : PlanarPosition, Real.exp (-(1 / 20 : ℝ) * ‖r‖)) + +theorem planarOverlapConstant_nonnegative : 0 ≤ planarOverlapConstant := + mul_nonneg (sq_nonneg _) (integral_nonneg (fun _ => (Real.exp_pos _).le)) + +theorem planarModeOverlap_decay (u v : PlanarPosition) : + planarModeOverlap u v ≤ planarOverlapConstant * Real.exp (-(9 / 10 : ℝ) * ‖u - v‖) := by + have h := planarModeOverlap_envelope (a := 19 / 20) (b := 9 / 10) + (by norm_num) (by norm_num) (by norm_num) u v + norm_num only [show (19 / 20 : ℝ) - 9 / 10 = 1 / 20 by norm_num] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPartition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dae56794e39a16d2a1f2a36ed79997cab1f71ba --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPartition.lean @@ -0,0 +1,165 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarIMS +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv + +namespace OAI + +/-! A smooth square partition for finitely many disjoint planar cutoffs. +The exterior function is smooth even on the regions where all site cutoffs +vanish; no square root at a zero is used. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def planarTrigPartition {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) : Option ι → PlanarPosition → ℝ + | none => fun x => 1 + ∑ i, (Real.cos (χ i x) - 1) + | some i => fun x => Real.sin (χ i x) + +theorem planarTrigPartition_C1 {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) (hχ : ∀ i, ContDiff ℝ 1 (χ i)) + (i : Option ι) : ContDiff ℝ 1 (planarTrigPartition χ i) := by + cases i with + | none => exact contDiff_const.add (ContDiff.sum (fun i _ => (hχ i).cos.sub contDiff_const)) + | some i => exact (hχ i).sin + +theorem disjoint_cutoff_vanish {ι : Type*} + (χ : ι → PlanarPosition → ℝ) + (hdisj : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {i j : ι} {x : PlanarPosition} (hxi : x ∈ tsupport (χ i)) (hji : j ≠ i) + (e : PlanarPosition) : χ j x = 0 ∧ planarPartial (χ j) e x = 0 := by + have hxj : x ∉ tsupport (χ j) := + fun hxj => Set.disjoint_left.mp (hdisj i j hji.symm) hxi hxj + refine ⟨image_eq_zero_of_notMem_tsupport hxj, ?_⟩ + simp only [planarPartial, fderiv_of_notMem_tsupport ℝ hxj, zero_apply] + +theorem planarTrigPartition_exterior_at {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) + (hdisj : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {i : ι} {x : PlanarPosition} (hxi : x ∈ tsupport (χ i)) : + planarTrigPartition χ none x = Real.cos (χ i x) := by + classical + dsimp only [planarTrigPartition] + rw [Finset.sum_eq_single i] + · ring + · intro j _ hji + rw [(disjoint_cutoff_vanish χ hdisj hxi hji 0).1, Real.cos_zero, sub_self] + · simp + +/-- The exterior and all site members have square sum exactly one. -/ +theorem planarTrigPartition_square_sum {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) + (hdisj : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + (x : PlanarPosition) : ∑ i, planarTrigPartition χ i x ^ 2 = 1 := by + classical + rw [Fintype.sum_option] + by_cases hx : ∃ i, x ∈ tsupport (χ i) + · obtain ⟨i, hi⟩ := hx + rw [planarTrigPartition_exterior_at χ hdisj hi] + have hs : (∑ j, planarTrigPartition χ (some j) x ^ 2) = Real.sin (χ i x) ^ 2 := by + apply Finset.sum_eq_single i + · intro j _ hji + simp only [planarTrigPartition, (disjoint_cutoff_vanish χ hdisj hi hji 0).1, + Real.sin_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow] + · simp + rw [hs] + nlinarith [Real.sin_sq_add_cos_sq (χ i x)] + · have hz (i : ι) : χ i x = 0 := + image_eq_zero_of_notMem_tsupport (fun hi => hx ⟨i, hi⟩) + simp only [planarTrigPartition, hz, Real.cos_zero, Real.sin_zero, sub_self, + Finset.sum_const_zero, add_zero, one_pow, ne_eq, OfNat.ofNat_ne_zero, + not_false_eq_true, zero_pow] + +theorem planarTrigPartition_partial_site {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) (hχ : ∀ i, ContDiff ℝ 1 (χ i)) + (i : ι) (e x : PlanarPosition) : + planarPartial (planarTrigPartition χ (some i)) e x = + Real.cos (χ i x) * planarPartial (χ i) e x := by + dsimp only [planarTrigPartition, planarPartial] + rw [fderiv_sin ((hχ i).differentiable (by norm_num) x)] + rfl + +theorem planarTrigPartition_partial_exterior {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) (hχ : ∀ i, ContDiff ℝ 1 (χ i)) + (e x : PlanarPosition) : + planarPartial (planarTrigPartition χ none) e x = + -(∑ i, Real.sin (χ i x) * planarPartial (χ i) e x) := by + have hd (i : ι) : HasFDerivAt (fun y => Real.cos (χ i y) - 1) + (-Real.sin (χ i x) • fderiv ℝ (χ i) x) x := by + simpa only [sub_zero, Pi.sub_def] using + (((hχ i).differentiable (by norm_num) x).hasFDerivAt.cos.sub (hasFDerivAt_const 1 x)) + have hs := (hasFDerivAt_const (1 : ℝ) x).add + (HasFDerivAt.fun_sum (fun i (_ : i ∈ (Finset.univ : Finset ι)) => hd i)) + have he := congrArg (fun L : PlanarPosition →L[ℝ] ℝ => L e) hs.fderiv + simpa only [planarTrigPartition, planarPartial, zero_add, sum_apply, smul_apply, + smul_eq_mul, neg_mul, Finset.sum_neg_distrib, Pi.add_def, Pi.sub_def] using he + +/-- Disjoint supports prevent a factor equal to the number of wells in the +localization error: the square gradient equals that of the active angle. -/ +theorem planarTrigPartition_gradient_square {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) (hχ : ∀ i, ContDiff ℝ 1 (χ i)) + (hdisj : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + (e x : PlanarPosition) : + (∑ i, planarPartial (planarTrigPartition χ i) e x ^ 2) = + ∑ i, planarPartial (χ i) e x ^ 2 := by + classical + rw [Fintype.sum_option, planarTrigPartition_partial_exterior χ hχ] + simp_rw [planarTrigPartition_partial_site χ hχ] + by_cases hx : ∃ i, x ∈ tsupport (χ i) + · obtain ⟨i, hi⟩ := hx + have hz (j : ι) (hji : j ≠ i) : planarPartial (χ j) e x = 0 := + (disjoint_cutoff_vanish χ hdisj hi hji e).2 + have hs : (∑ j, Real.sin (χ j x) * planarPartial (χ j) e x) = + Real.sin (χ i x) * planarPartial (χ i) e x := by + apply Finset.sum_eq_single i + · intro j _ hji + rw [hz j hji, mul_zero] + · simp + have hc : (∑ j, (Real.cos (χ j x) * planarPartial (χ j) e x) ^ 2) = + (Real.cos (χ i x) * planarPartial (χ i) e x) ^ 2 := by + apply Finset.sum_eq_single i + · intro j _ hji + rw [hz j hji, mul_zero, zero_pow (by decide : 2 ≠ 0)] + · simp + have hg : (∑ j, planarPartial (χ j) e x ^ 2) = planarPartial (χ i) e x ^ 2 := by + apply Finset.sum_eq_single i + · intro j _ hji + rw [hz j hji, zero_pow (by decide : 2 ≠ 0)] + · simp + rw [hs, hc, hg] + calc + _ = (Real.sin (χ i x) ^ 2 + Real.cos (χ i x) ^ 2) * planarPartial (χ i) e x ^ 2 := by ring + _ = _ := by rw [Real.sin_sq_add_cos_sq, one_mul] + · have hz (i : ι) : planarPartial (χ i) e x = 0 := by + have hi : x ∉ tsupport (χ i) := fun hi => hx ⟨i, hi⟩ + simp only [planarPartial, fderiv_of_notMem_tsupport ℝ hi, zero_apply] + simp only [hz, mul_zero, Finset.sum_const_zero, neg_zero, ne_eq, + OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, add_zero] + +theorem planarTrigPartition_gradient_bound {ι : Type*} [Fintype ι] + (χ : ι → PlanarPosition → ℝ) (hχ : ∀ i, ContDiff ℝ 1 (χ i)) + (hdisj : ∀ i j, i ≠ j → Disjoint (tsupport (χ i)) (tsupport (χ j))) + {G : ℝ} (hG : 0 ≤ G) (e : PlanarPosition) + (hbound : ∀ i x, |planarPartial (χ i) e x| ≤ G) (x : PlanarPosition) : + (∑ i, planarPartial (planarTrigPartition χ i) e x ^ 2) ≤ G ^ 2 := by + classical + rw [planarTrigPartition_gradient_square χ hχ hdisj] + by_cases hx : ∃ i, x ∈ tsupport (χ i) + · obtain ⟨i, hi⟩ := hx + rw [Finset.sum_eq_single i] + · simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) hG).mpr (hbound i x) + · intro j _ hji + rw [(disjoint_cutoff_vanish χ hdisj hi hji e).2, zero_pow (by decide : 2 ≠ 0)] + · simp + · have hz (i : ι) : planarPartial (χ i) e x = 0 := by + have hi : x ∉ tsupport (χ i) := fun hi => hx ⟨i, hi⟩ + simp only [planarPartial, fderiv_of_notMem_tsupport ℝ hi, zero_apply] + simp only [hz, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, Finset.sum_const_zero] + exact sq_nonneg G + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPolynomialScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPolynomialScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dade13c61b8895d12f5e46f9b8fb13c701e8011 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarPolynomialScale.lean @@ -0,0 +1,85 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCalibration +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics + +namespace OAI + +/-! Uniform polynomial amplification of the actual hopping brackets. A fixed +large power of the input-size parameter suffices; the well constants and +contact tolerance remain fixed. -/ + +noncomputable section +open Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem planar_polynomial_brackets {A k : ℕ} {ε N : ℝ} + (hε : 0 ≤ ε) (_hε₁ : ε ≤ 1) (hN : 2 ≤ N) + (hd : 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N)) + (hγ : 0 ≤ (k : ℝ) * ε - ((A : ℝ) + 1)) + (hlo : (k : ℝ) + 3 ≤ planarHoppingLowerConstant * + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1))) + (hhi : planarHoppingUpperConstant * (2 * (k : ℝ) + 1) ≤ + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1))) : + N ^ A ≤ Real.exp ((k : ℝ) * Real.log N) * + planarHopping ((1 - ε) * ((k : ℝ) * Real.log N)) ∧ + Real.exp ((k : ℝ) * Real.log N) * + planarHopping ((1 + ε) * ((k : ℝ) * Real.log N)) ≤ (N ^ A)⁻¹ := by + have hNpos : 0 < N := by linarith + have hk : (0 : ℝ) ≤ k := Nat.cast_nonneg _ + have hlog : 0 ≤ Real.log N := Real.log_nonneg (by linarith) + have hlogN : Real.log N ≤ N := (Real.log_le_sub_one_of_pos hNpos).trans (by linarith) + let γ : ℝ := (k : ℝ) * ε - ((A : ℝ) + 1) + have hp : (2 : ℝ) ^ γ ≤ N ^ γ := Real.rpow_le_rpow (by norm_num) hN hγ + have hloN : (k : ℝ) + 3 ≤ planarHoppingLowerConstant * N ^ γ := + hlo.trans (mul_le_mul_of_nonneg_left hp planarHoppingLowerConstant_positive.le) + have hhiN : planarHoppingUpperConstant * (2 * (k : ℝ) + 1) ≤ N ^ γ := hhi.trans hp + have hexp : Real.exp (ε * ((k : ℝ) * Real.log N)) = N ^ A * N * N ^ γ := by + calc + _ = N ^ ((A : ℝ) + 1 + γ) := by + rw [Real.rpow_def_of_pos hNpos] + congr 1 + dsimp [γ] + ring + _ = (N ^ (A : ℝ) * N ^ (1 : ℝ)) * N ^ γ := by + rw [Real.rpow_add hNpos, Real.rpow_add hNpos] + _ = _ := by rw [Real.rpow_natCast, Real.rpow_one] + have hshort : (1 - ε) * ((k : ℝ) * Real.log N) + 3 ≤ ((k : ℝ) + 3) * N := by + have hD : (1 - ε) * ((k : ℝ) * Real.log N) ≤ (k : ℝ) * Real.log N := by + nlinarith [mul_nonneg hk hlog] + have hkn := mul_le_mul_of_nonneg_left hlogN hk + nlinarith + have hlong : (1 + ε) * ((k : ℝ) * Real.log N) + 1 ≤ (2 * (k : ℝ) + 1) * N := by + have hD : (1 + ε) * ((k : ℝ) * Real.log N) ≤ 2 * ((k : ℝ) * Real.log N) := by + nlinarith [mul_nonneg hk hlog] + have hkn := mul_le_mul_of_nonneg_left hlogN hk + nlinarith + have hD : 0 ≤ (k : ℝ) * Real.log N := mul_nonneg hk hlog + have horder : (1 - ε) * ((k : ℝ) * Real.log N) ≤ + (1 + ε) * ((k : ℝ) * Real.log N) := by nlinarith + constructor + · apply le_trans _ (planarHopping_short_scaled hd) + rw [div_mul_eq_mul_div, le_div_iff₀ (by linarith)] + calc + _ ≤ N ^ A * (((k : ℝ) + 3) * N) := + mul_le_mul_of_nonneg_left hshort (pow_nonneg hNpos.le _) + _ ≤ N ^ A * ((planarHoppingLowerConstant * N ^ γ) * N) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hloN hNpos.le) + (pow_nonneg hNpos.le _) + _ = _ := by rw [hexp]; ring + · apply le_trans (planarHopping_long_scaled (hd.trans horder)) + rw [show -ε * ((k : ℝ) * Real.log N) = -(ε * ((k : ℝ) * Real.log N)) by ring, + Real.exp_neg, ← div_eq_mul_inv, div_le_iff₀ (Real.exp_pos _), hexp] + have hpA : N ^ A ≠ 0 := pow_ne_zero _ hNpos.ne' + calc + _ ≤ planarHoppingUpperConstant * ((2 * (k : ℝ) + 1) * N) := + mul_le_mul_of_nonneg_left hlong planarHoppingUpperConstant_positive.le + _ ≤ N ^ γ * N := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right hhiN hNpos.le + _ = _ := by field_simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarProjectionGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarProjectionGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..63444f75799d70faad2e58757d91056995929ad1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarProjectionGap.lean @@ -0,0 +1,170 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSpectralInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarNormalized + +namespace OAI + +/-! The isolated-well orthogonal gap implies the actual rank-one projection +bound on every vector in the closed Sobolev graph. The ground cross term +vanishes by the proved variational minimum, without a further spectral input. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +def shiftedForm (u : Target) : ℝ := form u + (1/2 : ℝ) * ‖u.1‖ ^ 2 + +def shiftedCross (u g : Target) : ℝ := + inner ℝ u.2 g.2 + inner ℝ u.1 (wellMultiplier g.1) + + inner ℝ g.1 (wellMultiplier u.1) + inner ℝ u.1 g.1 + +theorem shiftedForm_add_smul (u g : Target) (t : ℝ) : + shiftedForm (u + t • g) = shiftedForm u + t * shiftedCross u g + t^2 * shiftedForm g := by + change (1/2 : ℝ) * ‖u.2 + t • g.2‖ ^ 2 + + inner ℝ (u.1 + t • g.1) (wellMultiplier (u.1 + t • g.1)) + + (1/2 : ℝ) * ‖u.1 + t • g.1‖ ^ 2 = _ + rw [norm_add_sq_real, norm_add_sq_real, map_add, map_smul] + simp only [inner_add_left, inner_add_right, real_inner_smul_left, real_inner_smul_right, + norm_smul, mul_pow, Real.norm_eq_abs, sq_abs] + unfold shiftedForm form shiftedCross + ring + +theorem shiftedForm_nonnegative (u : Sobolev) : 0 ≤ shiftedForm u.val := by + have h := form_lower u + unfold shiftedForm + linarith + +theorem shiftedForm_normalizedMode : shiftedForm normalizedMode.val = 0 := by + rw [shiftedForm, normalizedMode_energy, normalizedMode_mass] + norm_num + +private theorem affine_nonnegative_slope_zero (a b : ℝ) (h : ∀ t : ℝ, 0 ≤ a + t*b) : b = 0 := by + by_contra hb + have ht := h (-(a+1)/b) + have he : a + (-(a+1)/b)*b = -1 := by field_simp [hb]; ring + rw [he] at ht + linarith + +theorem shiftedCross_normalizedMode (u : Sobolev) : shiftedCross u.val normalizedMode.val = 0 := by + apply affine_nonnegative_slope_zero (shiftedForm u.val) + intro t + have h := shiftedForm_nonnegative (u + t • normalizedMode) + change 0 ≤ shiftedForm (u.val + t • normalizedMode.val) at h + rw [shiftedForm_add_smul, shiftedForm_normalizedMode, mul_zero, add_zero] at h + exact h + +theorem shiftedForm_remove_ground (u : Sobolev) (t : ℝ) : + shiftedForm (u - t • normalizedMode).val = shiftedForm u.val := by + change shiftedForm (u.val - t • normalizedMode.val) = _ + rw [sub_eq_add_neg, ← neg_smul, shiftedForm_add_smul, + shiftedCross_normalizedMode, shiftedForm_normalizedMode] + ring + +/-- The precise rank-one closed-form bound needed in the multiwell IMS +argument, derived from the already cited isolated spectral input. -/ +theorem manufacturedPlanarWell_projection_gap (hpublished : ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ u : Sobolev, + ((-1/2 : ℝ) + γ) * ‖u.val.1‖^2 - + γ * (inner ℝ u.val.1 normalizedMode.val.1)^2 ≤ form u.val := by + obtain ⟨γ₀, hγ₀, hgap₀⟩ := hpublished + let γ := min γ₀ (1/4 : ℝ) + have hγ : 0 < γ := lt_min hγ₀ (by norm_num) + have hgap (u : Sobolev) (hu : inner ℝ u.val.1 normalizedMode.val.1 = 0) : + ((-1/2 : ℝ) + γ) * ‖u.val.1‖^2 ≤ form u.val := by + have hcoef : (-1/2 : ℝ) + γ ≤ -1/2 + γ₀ := by + dsimp only [γ] + linarith [min_le_left γ₀ (1/4 : ℝ)] + exact (mul_le_mul_of_nonneg_right hcoef (sq_nonneg ‖u.val.1‖)).trans (hgap₀ u hu) + refine ⟨γ, hγ, min_le_right _ _, fun u => ?_⟩ + let c := inner ℝ u.val.1 normalizedMode.val.1 + let v : Sobolev := u - c • normalizedMode + have hv : inner ℝ v.val.1 normalizedMode.val.1 = 0 := by + change inner ℝ (u.val.1 - c • normalizedMode.val.1) normalizedMode.val.1 = 0 + rw [inner_sub_left, real_inner_smul_left, real_inner_self_eq_norm_sq, normalizedMode_mass] + dsimp only [c] + ring + have hn : ‖v.val.1‖^2 = ‖u.val.1‖^2 - c^2 := by + change ‖u.val.1 - c • normalizedMode.val.1‖^2 = _ + rw [norm_sub_sq_real, real_inner_smul_right, norm_smul, mul_pow, + Real.norm_eq_abs, sq_abs, normalizedMode_mass] + dsimp only [c] + ring + have hshift : shiftedForm v.val = shiftedForm u.val := shiftedForm_remove_ground u c + have hg := hgap v hv + unfold shiftedForm at hshift + rw [hn] at hg hshift + dsimp only [c] at hg hshift + linarith + +theorem normalizedMode_ae : normalizedMode.val.1 =ᵐ[volume] normalizedPlanarMode := by + have hs := Lp.coeFn_smul (Real.sqrt (‖mode.val.1‖^2))⁻¹ mode.val.1 + filter_upwards [hs, mode_memLp.coeFn_toLp] with x hx hm + change (((Real.sqrt (‖mode.val.1‖^2))⁻¹ • mode.val.1 : Lp ℝ 2 volume) x) = _ + rw [hx] + change (Real.sqrt (‖mode.val.1‖^2))⁻¹ * mode.val.1 x = _ + change mode.val.1 x = planarResolventMode x at hm + rw [hm, mode_mass, normalizedPlanarMode_eq_const_mul] + rfl + +theorem graph_normalizedMode_inner (u : Test) : + inner ℝ (graph (μ := volume) u).1 normalizedMode.val.1 = + ∫ x, u.val x * normalizedPlanarMode x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [(memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp, + normalizedMode_ae] with x hx hg + change toL2 (μ := volume) u x = u.val x at hx + change inner ℝ (toL2 (μ := volume) u x) (normalizedMode.val.1 x) = _ + rw [hx, hg, RCLike.inner_apply, conj_trivial] + ring + +/-- The rank-one inequality is attached to the actual normalized planar +function and actual test-function integrals used by localization. -/ +theorem manufacturedPlanarWell_test_projection_gap (hpublished : ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ u : Test, + ((-1/2 : ℝ) + γ) * (∫ x, u.val x ^ 2) - + γ * (∫ x, u.val x * normalizedPlanarMode x)^2 ≤ + planarTestForm manufacturedPlanarWell u.val := by + obtain ⟨γ, hγ, hsmall, hgap⟩ := manufacturedPlanarWell_projection_gap hpublished + refine ⟨γ, hγ, hsmall, fun u => ?_⟩ + let v : Sobolev := ⟨graph (μ := volume) u, subset_closure ⟨u, rfl⟩⟩ + have hg := hgap v + change ((-1/2 : ℝ) + γ) * ‖(graph (μ := volume) u).1‖^2 - + γ * (inner ℝ (graph (μ := volume) u).1 normalizedMode.val.1)^2 ≤ + form (graph (μ := volume) u) at hg + rw [graph_mass, graph_normalizedMode_inner, graph_form] at hg + exact hg + +end ContinuumCoulomb.PlanarSobolev + +namespace ContinuumCoulomb + +/-- Export the isolated projection inequality with the ambient Euclidean +measure used by the actual continuum construction. -/ +theorem manufacturedPlanarWell_actual_projection_gap + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ f : PlanarPosition → ℝ, + ContDiff ℝ 1 f → HasCompactSupport f → + ((-1/2 : ℝ) + γ) * (∫ x, f x ^ 2) - + γ * (∫ x, f x * normalizedPlanarMode x)^2 ≤ + planarTestForm manufacturedPlanarWell f := by + let : MeasurableSpace PlanarPosition := borel PlanarPosition + let : BorelSpace PlanarPosition := ⟨rfl⟩ + let : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + obtain ⟨γ, hγ, hsmall, hgap⟩ := PlanarSobolev.manufacturedPlanarWell_test_projection_gap hpublished + refine ⟨γ, hγ, hsmall, fun f hf hc => ?_⟩ + have h := hgap ⟨f, hf, hc⟩ + have he (g : PlanarPosition → ℝ) := PlanarSobolev.planar_integral_change_borel + (borel PlanarPosition) ⟨rfl⟩ g + rw [he (fun x => f x ^ 2), he (fun x => f x * normalizedPlanarMode x)] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarRadial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..10dbe255744270f3e19aa1fce11c91aef7675733 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarRadial.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHopping +import Mathlib.Analysis.InnerProductSpace.Projection.Reflection +import Mathlib.MeasureTheory.Measure.Haar.NormedSpace + +namespace OAI + +/-! Rotation/reflection invariance of the actual manufactured planar data. +The hopping between arbitrary translated centers depends only on distance. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarForcing_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) (r : PlanarPosition) : + planarForcing (L r) = planarForcing r := by + simp only [planarForcing, L.norm_map] + +theorem planarResolventKernel_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) + (r : PlanarPosition) : planarResolventKernel (L r) = planarResolventKernel r := by + simp only [planarResolventKernel, planarResolventIntegrand, planarHeatKernel, L.norm_map] + +theorem planarResolventMode_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) + (r : PlanarPosition) : planarResolventMode (L r) = planarResolventMode r := by + unfold planarResolventMode + rw [← MeasureTheory.integral_comp L + (fun b => planarResolventKernel b * planarForcing (L r - b))] + apply integral_congr_ae + filter_upwards [] with b + rw [planarResolventKernel_isometry, ← L.map_sub, planarForcing_isometry] + +theorem normalizedPlanarMode_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) + (r : PlanarPosition) : normalizedPlanarMode (L r) = normalizedPlanarMode r := by + simp only [normalizedPlanarMode, planarResolventMode_isometry] + +theorem manufacturedPlanarWell_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) + (r : PlanarPosition) : manufacturedPlanarWell (L r) = manufacturedPlanarWell r := by + simp only [manufacturedPlanarWell, planarResolventMode_isometry, planarForcing_isometry] + +theorem planarResolventMode_radial {r s : PlanarPosition} (h : ‖r‖ = ‖s‖) : + planarResolventMode r = planarResolventMode s := by + have hi := planarResolventMode_isometry ((ℝ ∙ (r - s))ᗮ.reflection) r + rw [Submodule.reflection_sub h] at hi + exact hi.symm + +theorem normalizedPlanarMode_radial {r s : PlanarPosition} (h : ‖r‖ = ‖s‖) : + normalizedPlanarMode r = normalizedPlanarMode s := by + simp only [normalizedPlanarMode, planarResolventMode_radial h] + +theorem manufacturedPlanarWell_radial {r s : PlanarPosition} (h : ‖r‖ = ‖s‖) : + manufacturedPlanarWell r = manufacturedPlanarWell s := by + simp only [manufacturedPlanarWell, planarResolventMode_radial h, planarForcing, h] + +def planarHoppingAt (u : PlanarPosition) : ℝ := + (∫ r, planarForcing r * planarResolventMode (r - u)) / + (2 * ∫ r, planarResolventMode r ^ 2) + +theorem planarHoppingAt_isometry (L : PlanarPosition ≃ₗᵢ[ℝ] PlanarPosition) + (u : PlanarPosition) : planarHoppingAt (L u) = planarHoppingAt u := by + unfold planarHoppingAt + congr 1 + rw [← MeasureTheory.integral_comp L + (fun r => planarForcing r * planarResolventMode (r - L u))] + apply integral_congr_ae + filter_upwards [] with r + rw [planarForcing_isometry, ← L.map_sub, planarResolventMode_isometry] + +theorem planarHoppingAt_norm (u : PlanarPosition) : planarHoppingAt u = planarHopping ‖u‖ := by + have hn : ‖‖u‖ • planarAxis 0‖ = ‖u‖ := by + rw [norm_smul, planarAxis_zero_norm, mul_one, Real.norm_of_nonneg (norm_nonneg u)] + have h := planarHoppingAt_isometry ((ℝ ∙ (‖u‖ • planarAxis 0 - u))ᗮ.reflection) + (‖u‖ • planarAxis 0) + rw [Submodule.reflection_sub hn] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolvent.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..178edf276e47c0854159dc7f49b7ad29fdebd408 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolvent.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatKernel +import Mathlib.Analysis.Calculus.ContDiff.Convolution +import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals +import Mathlib.MeasureTheory.Integral.ExpDecay + +namespace OAI + +/-! Construction of the actual positive finite-smooth planar resolvent mode. +Tonelli/Fubini give an L¹ resolvent kernel of mass one, so convolution with +the manuscript's compact forcing has C⁷ regularity. The resolvent differential +equation, quantitative tails and excitation gap are subsequent steps. -/ + +noncomputable section +open MeasureTheory Function +open scoped Convolution +namespace ContinuumCoulomb + +def planarResolventIntegrand (p : ℝ × PlanarPosition) : ℝ := + Real.exp (-p.1) * planarHeatKernel p.1 p.2 + +theorem planarResolventIntegrand_measurable : Measurable planarResolventIntegrand := by + unfold planarResolventIntegrand planarHeatKernel + fun_prop + +theorem planarResolventIntegrand_integrable : + Integrable planarResolventIntegrand + ((volume.restrict (Set.Ioi (0 : ℝ))).prod (volume : Measure PlanarPosition)) := by + apply (integrable_prod_iff planarResolventIntegrand_measurable.aestronglyMeasurable).mpr + have hE : IntegrableOn (fun t : ℝ => Real.exp (-t)) (Set.Ioi (0 : ℝ)) := by + simpa only [neg_mul, one_mul] using exp_neg_integrableOn_Ioi 0 (by norm_num : (0 : ℝ) < 1) + refine ⟨?_, hE.congr ?_⟩ + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact (planarHeatKernel_integrable ht).const_mul (Real.exp (-t)) + · filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + have hn (r : PlanarPosition) : ‖planarResolventIntegrand (t, r)‖ = + Real.exp (-t) * planarHeatKernel t r := by + rw [Real.norm_eq_abs, abs_of_nonneg] + · rfl + · exact mul_nonneg (Real.exp_pos _).le (planarHeatKernel_positive ht r).le + simp_rw [hn] + rw [integral_const_mul, planarHeatKernel_integral ht, mul_one] + +def planarResolventKernel (r : PlanarPosition) : ℝ := + ∫ t in Set.Ioi (0 : ℝ), planarResolventIntegrand (t, r) + +theorem planarResolventKernel_integrable : Integrable planarResolventKernel := + planarResolventIntegrand_integrable.integral_prod_right + +theorem planarResolvent_forcing_integrable (r : PlanarPosition) : + Integrable (fun p : ℝ × PlanarPosition => planarResolventIntegrand p * planarForcing (r - p.2)) + ((volume.restrict (Set.Ioi (0 : ℝ))).prod (volume : Measure PlanarPosition)) := by + apply planarResolventIntegrand_integrable.mul_bdd + ((planarForcing_C7.continuous.comp (continuous_const.sub continuous_snd)).aestronglyMeasurable) + exact Filter.Eventually.of_forall (fun p => by + change ‖planarForcing (r - p.2)‖ ≤ (1 : ℝ) + rw [Real.norm_eq_abs, abs_of_nonneg (planarForcing_nonnegative _)] + exact planarForcing_le_one _) + +def planarResolventMode (r : PlanarPosition) : ℝ := + ∫ b, planarResolventKernel b * planarForcing (r - b) + +theorem planarResolventMode_C7 : ContDiff ℝ 7 planarResolventMode := + planarForcing_hasCompactSupport.contDiff_convolution_right + (ContinuousLinearMap.mul ℝ ℝ) planarResolventKernel_integrable.locallyIntegrable planarForcing_C7 + +/-- This is exactly the Gaussian heat representation in the manuscript. -/ +theorem planarResolventMode_heat_representation (r : PlanarPosition) : + planarResolventMode r = ∫ t in Set.Ioi (0 : ℝ), Real.exp (-t) * planarHeatAverage t r := by + unfold planarResolventMode planarResolventKernel + simp_rw [← integral_mul_const] + rw [← integral_integral_swap (planarResolvent_forcing_integrable r)] + simp_rw [planarResolventIntegrand, mul_assoc, integral_const_mul] + rfl + +theorem planarResolventMode_heat_integrable (r : PlanarPosition) : + IntegrableOn (fun t => Real.exp (-t) * planarHeatAverage t r) (Set.Ioi (0 : ℝ)) := by + have h := (planarResolvent_forcing_integrable r).integral_prod_left + change Integrable _ _ + simpa only [planarResolventIntegrand, mul_assoc, integral_const_mul, planarHeatAverage] using h + +theorem planarResolventMode_positive (r : PlanarPosition) : 0 < planarResolventMode r := by + rw [planarResolventMode_heat_representation] + have hpos (t : ℝ) (ht : t ∈ Set.Ioi (0 : ℝ)) : + 0 < Real.exp (-t) * planarHeatAverage t r := + mul_pos (Real.exp_pos _) (planarHeatAverage_positive ht r) + have hae : 0 ≤ᵐ[volume.restrict (Set.Ioi (0 : ℝ))] + (fun t => Real.exp (-t) * planarHeatAverage t r) := by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht using (hpos t ht).le + apply (integral_pos_iff_support_of_nonneg_ae hae (planarResolventMode_heat_integrable r)).mpr + have hs : Set.Ioi (0 : ℝ) ⊆ support (fun t => Real.exp (-t) * planarHeatAverage t r) := + fun t ht => (hpos t ht).ne' + have hm : 0 < (volume.restrict (Set.Ioi (0 : ℝ))) (Set.Ioi (0 : ℝ)) := by simp + exact hm.trans_le (measure_mono hs) + +theorem planarResolventMode_le_one (r : PlanarPosition) : planarResolventMode r ≤ 1 := by + rw [planarResolventMode_heat_representation, ← integral_exp_neg_Ioi_zero] + apply integral_mono_ae (planarResolventMode_heat_integrable r) + (by simpa only [IntegrableOn, neg_mul, one_mul] using + exp_neg_integrableOn_Ioi 0 (by norm_num : (0 : ℝ) < 1)) + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + exact mul_le_of_le_one_right (Real.exp_pos _).le (planarHeatAverage_le_one ht r) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventEquation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..11f853096e154b70026122d9998397e9c8691ad8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventEquation.lean @@ -0,0 +1,153 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLaplaceIBP +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDerivatives + +namespace OAI + +/-! The differential eigen-equation of the constructed resolvent mode is +obtained from its heat representation and the fundamental theorem of calculus, +not supplied as an assumption. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +theorem planarResolvent_joint_integrable {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) (r : PlanarPosition) : + Integrable (fun p : ℝ × PlanarPosition => planarResolventIntegrand p * g (r - p.2)) + ((volume.restrict (Set.Ioi (0 : ℝ))).prod (volume : Measure PlanarPosition)) := by + obtain ⟨B, hB⟩ := hg.bounded_above_of_compact_support hc + apply planarResolventIntegrand_integrable.mul_bdd + ((hg.comp (continuous_const.sub continuous_snd)).aestronglyMeasurable) + exact Eventually.of_forall (fun p => by + change ‖g (r - p.2)‖ ≤ B + exact hB _) + +theorem planarResolventOf_heat_representation {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) (r : PlanarPosition) : + planarResolventOf g r = ∫ t in Set.Ioi (0 : ℝ), + Real.exp (-t) * ∫ b, planarHeatKernel t b * g (r - b) := by + unfold planarResolventOf planarResolventKernel + simp_rw [← integral_mul_const] + rw [← integral_integral_swap (planarResolvent_joint_integrable hg hc r)] + simp_rw [planarResolventIntegrand, mul_assoc, integral_const_mul] + +theorem planarResolventOf_heat_integrable {g : PlanarPosition → ℝ} + (hg : Continuous g) (hc : HasCompactSupport g) (r : PlanarPosition) : + IntegrableOn (fun t => Real.exp (-t) * ∫ b, planarHeatKernel t b * g (r - b)) + (Set.Ioi (0 : ℝ)) := by + have h := (planarResolvent_joint_integrable hg hc r).integral_prod_left + change Integrable _ _ + simpa only [planarResolventIntegrand, mul_assoc, integral_const_mul] using h + +theorem planarResolventMode_laplacian_integral (r : PlanarPosition) : + planarLaplacian planarResolventMode r = planarResolventOf (planarLaplacian planarForcing) r := by + have hi (a : Fin 2) : Integrable (fun b => planarResolventKernel b * + planarPartial (planarPartial planarForcing (planarAxis a)) (planarAxis a) (r - b)) := + ((planarForcing_hasCompactSupport.fderiv_apply ℝ (planarAxis a)).fderiv_apply ℝ + (planarAxis a)).convolutionExists_right (ContinuousLinearMap.mul ℝ ℝ) + planarResolventKernel_integrable.locallyIntegrable + (planarPartial_continuous (planarPartial_C1 (planarForcing_C7.of_le (by norm_num)) _) _) r + unfold planarLaplacian + simp_rw [planarResolventMode_partial_partial] + change (∑ a : Fin 2, ∫ b, planarResolventKernel b * + planarPartial (planarPartial planarForcing (planarAxis a)) (planarAxis a) (r - b)) = + ∫ b, planarResolventKernel b * ∑ a : Fin 2, + planarPartial (planarPartial planarForcing (planarAxis a)) (planarAxis a) (r - b) + rw [← integral_finsetSum _ (fun a _ => hi a)] + simp only [Finset.mul_sum] + +def planarHeatResolventPrimitive (r : PlanarPosition) (t : ℝ) : ℝ := + if t = 0 then planarForcing r else Real.exp (-t) * planarHeatAverage t r + +def planarHeatResolventDerivative (r : PlanarPosition) (t : ℝ) : ℝ := + Real.exp (-t) * (∫ b, planarHeatKernel t b * planarLaplacian planarForcing (r - b)) - + Real.exp (-t) * planarHeatAverage t r + +@[simp] theorem planarHeatResolventPrimitive_zero (r : PlanarPosition) : + planarHeatResolventPrimitive r 0 = planarForcing r := by + simp [planarHeatResolventPrimitive] + +theorem planarHeatResolventPrimitive_hasDerivAt (r : PlanarPosition) {t : ℝ} (ht : 0 < t) : + HasDerivAt (planarHeatResolventPrimitive r) (planarHeatResolventDerivative r t) t := by + have he : HasDerivAt (fun s : ℝ => Real.exp (-s)) (-Real.exp (-t)) t := by + simpa only [Pi.neg_apply, id_eq, mul_neg, mul_one] using (hasDerivAt_id t).neg.exp + have hd := he.mul (planarHeatAverage_hasDerivAt_laplacian ht r) + have hd' : HasDerivAt (fun s => Real.exp (-s) * planarHeatAverage s r) + (planarHeatResolventDerivative r t) t := by + convert hd using 1 + dsimp [planarHeatResolventDerivative] + ring + apply hd'.congr_of_eventuallyEq + filter_upwards [Ioi_mem_nhds ht] with s hs + simp only [planarHeatResolventPrimitive, ite_eq_right (show s ≠ 0 from (show 0 < s from hs).ne')] + +theorem planarHeatResolventPrimitive_continuousWithinAt (r : PlanarPosition) : + ContinuousWithinAt (planarHeatResolventPrimitive r) (Set.Ici (0 : ℝ)) 0 := by + have he : Tendsto (fun t : ℝ => Real.exp (-t)) (𝓝[>] 0) (𝓝 1) := by + have he0 : Tendsto (fun t : ℝ => Real.exp (-t)) (𝓝 (0 : ℝ)) (𝓝 (Real.exp (-0))) := + (Real.continuous_exp.comp continuous_neg).continuousAt.tendsto + simpa only [neg_zero, Real.exp_zero] using + he0.mono_left (nhdsWithin_le_nhds (s := Set.Ioi (0 : ℝ))) + have hlim := he.mul (planarHeatAverage_tendsto_zero r) + apply continuousWithinAt_Ioi_iff_Ici.mp + change Tendsto _ _ (𝓝 (planarHeatResolventPrimitive r 0)) + rw [planarHeatResolventPrimitive_zero] + have hlim' : Tendsto (fun t => Real.exp (-t) * planarHeatAverage t r) + (𝓝[>] (0 : ℝ)) (𝓝 (planarForcing r)) := by simpa only [one_mul] using hlim + apply hlim'.congr' + filter_upwards [self_mem_nhdsWithin] with t ht + simp only [planarHeatResolventPrimitive, ite_eq_right (show t ≠ 0 from (show 0 < t from ht).ne')] + +theorem planarHeatResolventDerivative_integrable (r : PlanarPosition) : + IntegrableOn (planarHeatResolventDerivative r) (Set.Ioi (0 : ℝ)) := + (planarResolventOf_heat_integrable + (planarLaplacian_continuous (planarForcing_C7.of_le (by norm_num))) + (planarLaplacian_hasCompactSupport planarForcing_hasCompactSupport) r).sub + (planarResolventMode_heat_integrable r) + +theorem planarHeatResolventPrimitive_integrable (r : PlanarPosition) : + IntegrableOn (planarHeatResolventPrimitive r) (Set.Ioi (0 : ℝ)) := by + apply (planarResolventMode_heat_integrable r).congr + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + simp only [planarHeatResolventPrimitive, ite_eq_right (show t ≠ 0 from (show 0 < t from ht).ne')] + +theorem planarResolventMode_equation (r : PlanarPosition) : + planarLaplacian planarResolventMode r = planarResolventMode r - planarForcing r := by + have hd := fun t (ht : t ∈ Set.Ioi (0 : ℝ)) => planarHeatResolventPrimitive_hasDerivAt r ht + have hzero := tendsto_zero_of_hasDerivAt_of_integrableOn_Ioi hd + (planarHeatResolventDerivative_integrable r) (planarHeatResolventPrimitive_integrable r) + have hFTC := integral_Ioi_of_hasDerivAt_of_tendsto + (planarHeatResolventPrimitive_continuousWithinAt r) hd + (planarHeatResolventDerivative_integrable r) hzero + have hL := planarResolventOf_heat_representation + (planarLaplacian_continuous (planarForcing_C7.of_le (by norm_num))) + (planarLaplacian_hasCompactSupport planarForcing_hasCompactSupport) r + have hLi := planarResolventOf_heat_integrable + (planarLaplacian_continuous (planarForcing_C7.of_le (by norm_num))) + (planarLaplacian_hasCompactSupport planarForcing_hasCompactSupport) r + simp only [planarHeatResolventDerivative, planarHeatResolventPrimitive_zero, zero_sub, + integral_sub hLi (planarResolventMode_heat_integrable r), ← hL, + ← planarResolventMode_heat_representation, ← planarResolventMode_laplacian_integral] at hFTC + linarith + +theorem manufacturedPlanarWell_eigen_equation (r : PlanarPosition) : + planarLaplacian planarResolventMode r = + (2 * manufacturedPlanarWell r + 1) * planarResolventMode r := by + rw [planarResolventMode_equation] + unfold manufacturedPlanarWell + field_simp [(planarResolventMode_positive r).ne'] + ring + +theorem manufacturedPlanarWell_test_lower (u : PlanarPosition → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + -(1 / 2 : ℝ) * (∫ x, u x ^ 2) ≤ planarTestForm manufacturedPlanarWell u := + planar_positive_mode_form_lower planarResolventMode manufacturedPlanarWell u + (planarResolventMode_C7.of_le (by norm_num)) planarResolventMode_positive + manufacturedPlanarWell_C7.continuous manufacturedPlanarWell_eigen_equation hu hc + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..cad44fc4cc83e163d94c15b74d6e5b9425a1c679 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventModulus.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcingModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHopping + +namespace OAI + +/-! Explicit moduli for numerical normalization and contact integrals. +The constants come from the actual compact forcing and mass-one kernel. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarResolventMode_norm_sub_explicit (x y : PlanarPosition) : + |planarResolventMode x - planarResolventMode y| ≤ 32 * ‖x - y‖ := by + unfold planarResolventMode + rw [← integral_sub (planarResolventMode_integrand_integrable x) + (planarResolventMode_integrand_integrable y)] + have h := norm_integral_le_of_norm_le + (f := fun b => planarResolventKernel b * planarForcing (x - b) - + planarResolventKernel b * planarForcing (y - b)) + (planarResolventKernel_integrable.mul_const (32 * ‖x - y‖)) + (Filter.Eventually.of_forall (fun b => by + rw [← mul_sub, norm_mul, Real.norm_of_nonneg (planarResolventKernel_nonnegative b), + Real.norm_eq_abs] + apply mul_le_mul_of_nonneg_left _ (planarResolventKernel_nonnegative b) + simpa only [show x - b - (y - b) = x - y by abel] using + planarForcing_norm_sub_explicit (x - b) (y - b))) + simpa only [integral_mul_const, planarResolventKernel_integral, one_mul, + Real.norm_eq_abs] using h + +theorem planarResolventMode_square_norm_sub (x y : PlanarPosition) : + |planarResolventMode x ^ 2 - planarResolventMode y ^ 2| ≤ 64 * ‖x - y‖ := by + have hx := (planarResolventMode_positive x).le + have hy := (planarResolventMode_positive y).le + have hsum : 0 ≤ planarResolventMode x + planarResolventMode y := add_nonneg hx hy + have hsum' : planarResolventMode x + planarResolventMode y ≤ 2 := + by linarith [planarResolventMode_le_one x, planarResolventMode_le_one y] + rw [show planarResolventMode x ^ 2 - planarResolventMode y ^ 2 = + (planarResolventMode x - planarResolventMode y) * + (planarResolventMode x + planarResolventMode y) by ring, + abs_mul, abs_of_nonneg hsum] + calc + _ ≤ (32 * ‖x - y‖) * 2 := + mul_le_mul (planarResolventMode_norm_sub_explicit x y) hsum' + hsum (by positivity) + _ = _ := by ring + +theorem planarHoppingIntegrand_norm_sub_explicit (d : ℝ) (x y : PlanarPosition) : + |planarHoppingIntegrand d x - planarHoppingIntegrand d y| ≤ 64 * ‖x - y‖ := by + have hx := planarForcing_nonnegative x + have hy := planarForcing_nonnegative y + have hz := (planarResolventMode_positive (y - d • planarAxis 0)).le + have ha := planarResolventMode_le_one (y - d • planarAxis 0) + have hb := planarForcing_le_one x + have heq : planarHoppingIntegrand d x - planarHoppingIntegrand d y = + planarForcing x * (planarResolventMode (x - d • planarAxis 0) - + planarResolventMode (y - d • planarAxis 0)) + + (planarForcing x - planarForcing y) * planarResolventMode (y - d • planarAxis 0) := by + unfold planarHoppingIntegrand + ring + rw [heq] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg hx, abs_of_nonneg hz] + have hr : |planarResolventMode (x - d • planarAxis 0) - + planarResolventMode (y - d • planarAxis 0)| ≤ 32 * ‖x - y‖ := by + simpa only [show x - d • planarAxis 0 - (y - d • planarAxis 0) = x - y by abel] using + planarResolventMode_norm_sub_explicit (x - d • planarAxis 0) (y - d • planarAxis 0) + have h₁ := mul_le_mul hb hr (abs_nonneg _) zero_le_one + have h₂ := mul_le_mul (planarForcing_norm_sub_explicit x y) ha hz (by positivity) + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventTails.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..151bb069abc402fa1c0ce13a778763bcc600e492 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarResolventTails.lean @@ -0,0 +1,140 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSharpDecay +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDerivatives + +namespace OAI + +/-! The same sharp exponential rate for compact forcing derivatives. The +heat-kernel proof is applied to the actual first/second derivative forcing, +without assuming differentiated resolvent asymptotics. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarResolventOf_product_integrable {g : PlanarPosition → ℝ} {B : ℝ} + (hg : Continuous g) (hB : ∀ x, ‖g x‖ ≤ B) (r : PlanarPosition) : + Integrable (fun p : ℝ × PlanarPosition => planarResolventIntegrand p * g (r - p.2)) + ((volume.restrict (Set.Ioi (0 : ℝ))).prod (volume : Measure PlanarPosition)) := by + apply planarResolventIntegrand_integrable.mul_bdd (c := B) + ((hg.comp (continuous_const.sub continuous_snd)).aestronglyMeasurable) + exact Filter.Eventually.of_forall (fun p => hB (r - p.2)) + +theorem planarResolventOf_bounded_heat_representation {g : PlanarPosition → ℝ} {B : ℝ} + (hg : Continuous g) (hB : ∀ x, ‖g x‖ ≤ B) (r : PlanarPosition) : + planarResolventOf g r = ∫ t in Set.Ioi (0 : ℝ), Real.exp (-t) * + (∫ b, planarHeatKernel t b * g (r - b)) := by + unfold planarResolventOf planarResolventKernel + simp_rw [← integral_mul_const] + rw [← integral_integral_swap (planarResolventOf_product_integrable hg hB r)] + simp_rw [planarResolventIntegrand, mul_assoc, integral_const_mul] + +theorem planar_supported_exponential_bound {g : PlanarPosition → ℝ} {B : ℝ} + (hs : tsupport g ⊆ Metric.closedBall 0 1) (hB : ∀ x, ‖g x‖ ≤ B) + (e s : PlanarPosition) : ‖g s‖ ≤ B * Real.exp (‖e‖ - inner ℝ e s) := by + have hB₀ : 0 ≤ B := (norm_nonneg (g 0)).trans (hB 0) + by_cases hg : g s = 0 + · rw [hg, norm_zero] + exact mul_nonneg hB₀ (Real.exp_pos _).le + have hsn : ‖s‖ ≤ 1 := by + have h := hs (subset_tsupport g hg) + simpa only [Metric.mem_closedBall, dist_zero_right] using h + have hi : inner ℝ e s ≤ ‖e‖ := (real_inner_le_norm e s).trans + (by simpa only [mul_one] using mul_le_mul_of_nonneg_left hsn (norm_nonneg e)) + exact (hB s).trans (le_mul_of_one_le_right hB₀ (Real.one_le_exp (by linarith))) + +theorem planarHeatOf_tilt_bound {g : PlanarPosition → ℝ} {B t : ℝ} + (hs : tsupport g ⊆ Metric.closedBall 0 1) (hB : ∀ x, ‖g x‖ ≤ B) + (ht : 0 < t) (e r : PlanarPosition) : + ‖∫ b, planarHeatKernel t b * g (r - b)‖ ≤ + (B * Real.exp (‖e‖ - inner ℝ e r)) * Real.exp (t * ‖e‖ ^ 2) := by + have hpt (b : PlanarPosition) : ‖planarHeatKernel t b * g (r - b)‖ ≤ + ((B * Real.exp (‖e‖ - inner ℝ e r)) * Real.exp (t * ‖e‖ ^ 2)) * + planarHeatKernel t (b - (2 * t) • e) := by + rw [norm_mul, Real.norm_of_nonneg (planarHeatKernel_positive ht b).le] + calc + _ ≤ planarHeatKernel t b * (B * Real.exp (‖e‖ - inner ℝ e (r - b))) := + mul_le_mul_of_nonneg_left (planar_supported_exponential_bound hs hB e (r - b)) + (planarHeatKernel_positive ht b).le + _ = (B * Real.exp (‖e‖ - inner ℝ e r)) * + (planarHeatKernel t b * Real.exp (inner ℝ e b)) := by + rw [inner_sub_right, show ‖e‖ - (inner ℝ e r - inner ℝ e b) = + (‖e‖ - inner ℝ e r) + inner ℝ e b by ring, Real.exp_add] + ring + _ = _ := by rw [planarHeatKernel_tilt ht]; ring + have h := norm_integral_le_of_norm_le + (((planarHeatKernel_integrable ht).comp_sub_right ((2 * t) • e)).const_mul + ((B * Real.exp (‖e‖ - inner ℝ e r)) * Real.exp (t * ‖e‖ ^ 2))) + (Filter.Eventually.of_forall hpt) + simpa only [integral_const_mul, integral_sub_right_eq_self, planarHeatKernel_integral ht, + mul_one] using h + +theorem planarResolventOf_tilt_bound {g : PlanarPosition → ℝ} {B : ℝ} + (hg : Continuous g) (hs : tsupport g ⊆ Metric.closedBall 0 1) (hB : ∀ x, ‖g x‖ ≤ B) + (e r : PlanarPosition) (he : ‖e‖ < 1) : + ‖planarResolventOf g r‖ ≤ B * Real.exp (‖e‖ - inner ℝ e r) / (1 - ‖e‖ ^ 2) := by + have hc : 0 < 1 - ‖e‖ ^ 2 := by nlinarith [norm_nonneg e] + have hi : IntegrableOn (fun t : ℝ => Real.exp (-(1 - ‖e‖ ^ 2) * t)) (Set.Ioi 0) := + exp_neg_integrableOn_Ioi 0 hc + rw [planarResolventOf_bounded_heat_representation hg hB r] + have h := norm_integral_le_of_norm_le + (f := fun t : ℝ => Real.exp (-t) * (∫ b, planarHeatKernel t b * g (r - b))) + (hi.const_mul (B * Real.exp (‖e‖ - inner ℝ e r))) (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + rw [norm_mul, Real.norm_of_nonneg (Real.exp_pos _).le] + calc + _ ≤ Real.exp (-t) * ((B * Real.exp (‖e‖ - inner ℝ e r)) * Real.exp (t * ‖e‖ ^ 2)) := + mul_le_mul_of_nonneg_left (planarHeatOf_tilt_bound hs hB ht e r) (Real.exp_pos _).le + _ = (B * Real.exp (‖e‖ - inner ℝ e r)) * Real.exp (-(1 - ‖e‖ ^ 2) * t) := by + rw [show -(1 - ‖e‖ ^ 2) * t = -t + t * ‖e‖ ^ 2 by ring, Real.exp_add] + ring) + have heval : (∫ t : ℝ in Set.Ioi 0, Real.exp (-(1 - ‖e‖ ^ 2) * t)) = + (1 - ‖e‖ ^ 2)⁻¹ := by + rw [integral_exp_mul_Ioi (by linarith : -(1 - ‖e‖ ^ 2) < 0)] + simp + rw [show ‖e‖ ^ 2 - 1 = -(1 - ‖e‖ ^ 2) by ring, div_neg] + simp only [neg_div, neg_neg, one_div] + simpa only [integral_const_mul, heval, div_eq_mul_inv] using h + +theorem planarResolventOf_sharp_upper {g : PlanarPosition → ℝ} {B : ℝ} + (hg : Continuous g) (hs : tsupport g ⊆ Metric.closedBall 0 1) (hB : ∀ x, ‖g x‖ ≤ B) + {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + ‖planarResolventOf g r‖ ≤ B * ‖r‖ * Real.exp (2 - ‖r‖) := by + have hB₀ : 0 ≤ B := (norm_nonneg (g 0)).trans (hB 0) + by_cases hBzero : B = 0 + · simpa only [hBzero, zero_mul] using planarResolventOf_bound hB r + have hBpos : 0 < B := lt_of_le_of_ne hB₀ (Ne.symm hBzero) + have h := planar_tilt_envelope_sharp_upper r (‖planarResolventOf g r‖ / B) + (fun e he => (div_le_iff₀ hBpos).2 + ((planarResolventOf_tilt_bound hg hs hB e r he).trans_eq (by ring))) hr + have hh := (div_le_iff₀ hBpos).mp h + convert hh using 1; ring + +theorem planarResolventMode_partial_sharp_tail (e : PlanarPosition) : + ∃ B : ℝ, 0 ≤ B ∧ ∀ r : PlanarPosition, 1 ≤ ‖r‖ → + ‖planarPartial planarResolventMode e r‖ ≤ B * ‖r‖ * Real.exp (2 - ‖r‖) := by + have hg := planarPartial_continuous (planarForcing_C7.of_le (by norm_num)) e + have hc := planarForcing_hasCompactSupport.fderiv_apply ℝ e + obtain ⟨B, hB⟩ := hg.bounded_above_of_compact_support hc + refine ⟨B, (norm_nonneg _).trans (hB 0), fun r hr => ?_⟩ + rw [planarResolventMode_partial] + exact planarResolventOf_sharp_upper hg + ((tsupport_fderiv_apply_subset ℝ e).trans planarForcing_support) hB hr + +theorem planarResolventMode_partial_partial_sharp_tail (e v : PlanarPosition) : + ∃ B : ℝ, 0 ≤ B ∧ ∀ r : PlanarPosition, 1 ≤ ‖r‖ → + ‖planarPartial (planarPartial planarResolventMode e) v r‖ ≤ + B * ‖r‖ * Real.exp (2 - ‖r‖) := by + have hg := planarPartial_continuous (planarPartial_C1 (planarForcing_C7.of_le (by norm_num)) e) v + have hc := (planarForcing_hasCompactSupport.fderiv_apply ℝ e).fderiv_apply ℝ v + obtain ⟨B, hB⟩ := hg.bounded_above_of_compact_support hc + refine ⟨B, (norm_nonneg _).trans (hB 0), fun r hr => ?_⟩ + rw [planarResolventMode_partial_partial] + exact planarResolventOf_sharp_upper hg + ((tsupport_fderiv_apply_subset ℝ v).trans + ((tsupport_fderiv_apply_subset ℝ e).trans planarForcing_support)) hB hr + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarScaleChoice.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarScaleChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcd55a4bbcc5442b06a899c94565cad916fea4f9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarScaleChoice.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarPolynomialScale + +namespace OAI + +/-! A single fixed polynomial exponent gives uniform hopping brackets for +every input size. Exponential domination selects that exponent once. -/ + +noncomputable section +open Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem exists_planar_scale_conditions_above (B : ℝ) (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ B ≤ (k : ℝ) ∧ 0 ≤ (k : ℝ) * ε - ((A : ℝ) + 1) ∧ + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log 2) ∧ + (k : ℝ) + 3 ≤ planarHoppingLowerConstant * + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) ∧ + planarHoppingUpperConstant * (2 * (k : ℝ) + 1) ≤ + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) := by + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hcast : Tendsto (fun k : ℕ => (k : ℝ)) atTop atTop := tendsto_natCast_atTop_atTop + have htbase : Tendsto (fun k : ℕ => Real.exp ((ε * Real.log 2) * (k : ℝ)) / (k : ℝ)) + atTop atTop := by + simpa only [Function.comp_def, Real.rpow_one] using + (tendsto_exp_mul_div_rpow_atTop 1 (ε * Real.log 2) (mul_pos hε hlog)).comp hcast + have ht : Tendsto (fun k : ℕ => (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) / (k : ℝ)) + atTop atTop := by + convert htbase.const_mul_atTop (Real.exp_pos (-((A : ℝ) + 1) * Real.log 2)) using 1 + funext k + rw [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2), ← mul_div_assoc, ← Real.exp_add] + congr 1 + congr 1 + ring + let bound : ℝ := max B (max 1 (max (((A : ℝ) + 1) / ε) (2 / ((1 - ε) * Real.log 2)))) + have hb : ∀ᶠ k : ℕ in atTop, bound ≤ (k : ℝ) := hcast.eventually (eventually_ge_atTop bound) + have hr : ∀ᶠ k : ℕ in atTop, + max (4 / planarHoppingLowerConstant) (3 * planarHoppingUpperConstant) ≤ + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) / (k : ℝ) := + ht.eventually (eventually_ge_atTop _) + obtain ⟨k, hkb, hkr⟩ := (hb.and hr).exists + have hkbB : B ≤ (k : ℝ) := (le_max_left _ _).trans hkb + have hkb0 : max 1 (max (((A : ℝ) + 1) / ε) (2 / ((1 - ε) * Real.log 2))) ≤ (k : ℝ) := + (le_max_right _ _).trans hkb + have hk₁ : (1 : ℝ) ≤ k := (le_max_left _ _).trans hkb0 + have hkp : (0 : ℝ) < k := by linarith + have hkA : ((A : ℝ) + 1) / ε ≤ k := + (le_max_left _ _).trans ((le_max_right _ _).trans hkb0) + have hkD : 2 / ((1 - ε) * Real.log 2) ≤ k := + (le_max_right _ _).trans ((le_max_right _ _).trans hkb0) + have hlo := (le_div_iff₀ hkp).mp ((le_max_left _ _).trans hkr) + have hhi := (le_div_iff₀ hkp).mp ((le_max_right _ _).trans hkr) + have hmul := mul_le_mul_of_nonneg_left hlo planarHoppingLowerConstant_positive.le + have heq : planarHoppingLowerConstant * ((4 / planarHoppingLowerConstant) * (k : ℝ)) = + 4 * (k : ℝ) := by field_simp [planarHoppingLowerConstant_positive.ne'] + rw [heq] at hmul + refine ⟨k, by exact_mod_cast hkp, hkbB, ?_, ?_, ?_, ?_⟩ + · exact sub_nonneg.mpr ((div_le_iff₀ hε).mp hkA) + · have h := (div_le_iff₀ (mul_pos (sub_pos.mpr hε₁) hlog)).mp hkD + nlinarith + · exact (by linarith : (k : ℝ) + 3 ≤ 4 * (k : ℝ)).trans hmul + · have hU := planarHoppingUpperConstant_positive + nlinarith + +theorem exists_planar_scale_conditions (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ 0 ≤ (k : ℝ) * ε - ((A : ℝ) + 1) ∧ + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log 2) ∧ + (k : ℝ) + 3 ≤ planarHoppingLowerConstant * + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) ∧ + planarHoppingUpperConstant * (2 * (k : ℝ) + 1) ≤ + (2 : ℝ) ^ ((k : ℝ) * ε - ((A : ℝ) + 1)) := by + obtain ⟨k, hk, _, hγ, hd, hlo, hhi⟩ := exists_planar_scale_conditions_above 0 A hε hε₁ + exact ⟨k, hk, hγ, hd, hlo, hhi⟩ + +/-- For every polynomial target range, a fixed power `λ=N^k` brackets that +range uniformly at the two allowed contact lengths, for all real `N≥2`. -/ +theorem exists_planar_polynomial_brackets_above (B : ℝ) (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ B ≤ (k : ℝ) ∧ ∀ N : ℝ, 2 ≤ N → + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ + N ^ A ≤ N ^ k * planarHopping ((1 - ε) * ((k : ℝ) * Real.log N)) ∧ + N ^ k * planarHopping ((1 + ε) * ((k : ℝ) * Real.log N)) ≤ (N ^ A)⁻¹ := by + obtain ⟨k, hk, hB, hγ, hd, hlo, hhi⟩ := exists_planar_scale_conditions_above B A hε hε₁ + refine ⟨k, hk, hB, fun N hN => ?_⟩ + have hNpos : 0 < N := by linarith + have hlog : Real.log 2 ≤ Real.log N := Real.log_le_log (by norm_num) hN + have hdN : 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N) := hd.trans + (mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg k)) (sub_pos.mpr hε₁).le) + have hb := planar_polynomial_brackets hε.le hε₁.le hN hdN hγ hlo hhi + have he : Real.exp ((k : ℝ) * Real.log N) = N ^ k := by + rw [Real.exp_nat_mul, Real.exp_log hNpos] + rw [he] at hb + exact ⟨hdN, hb⟩ + +theorem exists_planar_polynomial_brackets (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ + N ^ A ≤ N ^ k * planarHopping ((1 - ε) * ((k : ℝ) * Real.log N)) ∧ + N ^ k * planarHopping ((1 + ε) * ((k : ℝ) * Real.log N)) ≤ (N ^ A)⁻¹ := by + obtain ⟨k, hk, _, h⟩ := exists_planar_polynomial_brackets_above 0 A hε hε₁ + exact ⟨k, hk, h⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSharpDecay.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSharpDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bca2ac4088cec19d27bdc3cde7a1684fd014e70 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSharpDecay.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeDecay + +namespace OAI + +/-! A sharp exponential rate for the actual planar resolvent mode. Gaussian +exponential tilting gives a polynomial prefactor and decay `exp (-|r|)`, as +needed to bracket the contact hoppings at lengths `(1±ε)D`. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarHeatKernel_tilt {t : ℝ} (ht : 0 < t) (e b : PlanarPosition) : + planarHeatKernel t b * Real.exp (inner ℝ e b) = + Real.exp (t * ‖e‖ ^ 2) * planarHeatKernel t (b - (2 * t) • e) := by + have he : -‖b‖ ^ 2 / (4 * t) + inner ℝ e b = + t * ‖e‖ ^ 2 + -‖b - (2 * t) • e‖ ^ 2 / (4 * t) := by + rw [norm_sub_sq_real, real_inner_smul_right, norm_smul, mul_pow, + Real.norm_eq_abs, sq_abs, real_inner_comm b e] + field_simp + ring + unfold planarHeatKernel + rw [mul_assoc, ← Real.exp_add, he, Real.exp_add] + ring + +theorem planarForcing_exponential_bound (e s : PlanarPosition) : + planarForcing s ≤ Real.exp (‖e‖ - inner ℝ e s) := by + by_cases hf : planarForcing s = 0 + · rw [hf] + exact (Real.exp_pos _).le + have hs : ‖s‖ ≤ 1 := le_of_lt (lt_of_not_ge + (fun h => hf (planarForcing_zero_of_norm_ge_one h))) + have hi : inner ℝ e s ≤ ‖e‖ := (real_inner_le_norm e s).trans + (by simpa only [mul_one] using mul_le_mul_of_nonneg_left hs (norm_nonneg e)) + exact (planarForcing_le_one s).trans (Real.one_le_exp (by linarith)) + +theorem planarHeatForcing_tilt_bound {t : ℝ} (ht : 0 < t) (e r b : PlanarPosition) : + planarHeatKernel t b * planarForcing (r - b) ≤ + (Real.exp (‖e‖ - inner ℝ e r) * Real.exp (t * ‖e‖ ^ 2)) * + planarHeatKernel t (b - (2 * t) • e) := by + calc + _ ≤ planarHeatKernel t b * Real.exp (‖e‖ - inner ℝ e (r - b)) := + mul_le_mul_of_nonneg_left (planarForcing_exponential_bound e (r - b)) + (planarHeatKernel_positive ht b).le + _ = Real.exp (‖e‖ - inner ℝ e r) * + (planarHeatKernel t b * Real.exp (inner ℝ e b)) := by + rw [inner_sub_right, show ‖e‖ - (inner ℝ e r - inner ℝ e b) = + (‖e‖ - inner ℝ e r) + inner ℝ e b by ring, Real.exp_add] + ring + _ = _ := by rw [planarHeatKernel_tilt ht]; ring + +theorem planarHeatAverage_tilt_bound {t : ℝ} (ht : 0 < t) (e r : PlanarPosition) : + planarHeatAverage t r ≤ + Real.exp (‖e‖ - inner ℝ e r) * Real.exp (t * ‖e‖ ^ 2) := by + have hi := ((planarHeatKernel_integrable ht).comp_sub_right ((2 * t) • e)).const_mul + (Real.exp (‖e‖ - inner ℝ e r) * Real.exp (t * ‖e‖ ^ 2)) + have h := integral_mono (planarHeatAverage_integrand_integrable ht r) hi + (planarHeatForcing_tilt_bound ht e r) + simpa only [planarHeatAverage, integral_const_mul, integral_sub_right_eq_self, + planarHeatKernel_integral ht, mul_one] using h + +theorem planarResolventMode_tilt_bound (e r : PlanarPosition) (he : ‖e‖ < 1) : + planarResolventMode r ≤ Real.exp (‖e‖ - inner ℝ e r) / (1 - ‖e‖ ^ 2) := by + have hc : 0 < 1 - ‖e‖ ^ 2 := by nlinarith [norm_nonneg e] + have hi : IntegrableOn (fun t : ℝ => Real.exp (-(1 - ‖e‖ ^ 2) * t)) (Set.Ioi 0) := + exp_neg_integrableOn_Ioi 0 hc + rw [planarResolventMode_heat_representation] + have h := integral_mono_ae (planarResolventMode_heat_integrable r) + (hi.const_mul (Real.exp (‖e‖ - inner ℝ e r))) (by + filter_upwards [ae_restrict_mem measurableSet_Ioi] with t ht + calc + _ ≤ Real.exp (-t) * (Real.exp (‖e‖ - inner ℝ e r) * Real.exp (t * ‖e‖ ^ 2)) := + mul_le_mul_of_nonneg_left (planarHeatAverage_tilt_bound ht e r) (Real.exp_pos _).le + _ = Real.exp (‖e‖ - inner ℝ e r) * Real.exp (-(1 - ‖e‖ ^ 2) * t) := by + rw [show -(1 - ‖e‖ ^ 2) * t = -t + t * ‖e‖ ^ 2 by ring, Real.exp_add] + ring) + have heval : (∫ t : ℝ in Set.Ioi 0, Real.exp (-(1 - ‖e‖ ^ 2) * t)) = + (1 - ‖e‖ ^ 2)⁻¹ := by + rw [integral_exp_mul_Ioi (by linarith : -(1 - ‖e‖ ^ 2) < 0)] + simp + rw [show ‖e‖ ^ 2 - 1 = -(1 - ‖e‖ ^ 2) by ring, div_neg] + simp only [neg_div, neg_neg, one_div] + simpa only [integral_const_mul, heval, div_eq_mul_inv] using h + +theorem planar_tilt_envelope_sharp_upper (r : PlanarPosition) (v : ℝ) + (hv : ∀ e : PlanarPosition, ‖e‖ < 1 → + v ≤ Real.exp (‖e‖ - inner ℝ e r) / (1 - ‖e‖ ^ 2)) (hr : 1 ≤ ‖r‖) : + v ≤ ‖r‖ * Real.exp (2 - ‖r‖) := by + have hR : 0 < ‖r‖ := lt_of_lt_of_le (by norm_num : (0 : ℝ) < 1) hr + let c : ℝ := (‖r‖ - 1) / ‖r‖ ^ 2 + let e : PlanarPosition := c • r + have hc : 0 ≤ c := div_nonneg (by linarith) (sq_nonneg _) + have hn : ‖e‖ = (‖r‖ - 1) / ‖r‖ := by + rw [show e = c • r from rfl, norm_smul, Real.norm_of_nonneg hc] + dsimp [c] + field_simp + have hi : inner ℝ e r = ‖r‖ - 1 := by + rw [show e = c • r from rfl, real_inner_smul_left, real_inner_self_eq_norm_sq] + dsimp [c] + exact div_mul_cancel₀ _ (pow_ne_zero 2 hR.ne') + have he : ‖e‖ < 1 := by + rw [hn] + exact (div_lt_one hR).2 (by linarith) + have hdpos : 0 < 1 - ‖e‖ ^ 2 := by nlinarith [norm_nonneg e] + have hden : 1 / ‖r‖ ≤ 1 - ‖e‖ ^ 2 := by + have hsq : ‖e‖ ^ 2 ≤ ‖e‖ := by nlinarith [norm_nonneg e] + have hid : 1 - ‖e‖ = 1 / ‖r‖ := by rw [hn]; field_simp; ring + linarith + have hinv : (1 - ‖e‖ ^ 2)⁻¹ ≤ ‖r‖ := by + have h := div_le_div_of_nonneg_left (by norm_num : (0 : ℝ) ≤ 1) + (one_div_pos.mpr hR) hden + simpa only [one_div, inv_inv] using h + have hexp : Real.exp (‖e‖ - inner ℝ e r) ≤ Real.exp (2 - ‖r‖) := by + apply Real.exp_le_exp.mpr + rw [hi] + linarith + calc + _ ≤ Real.exp (‖e‖ - inner ℝ e r) / (1 - ‖e‖ ^ 2) := + hv e he + _ ≤ Real.exp (2 - ‖r‖) * ‖r‖ := by + rw [div_eq_mul_inv] + exact mul_le_mul hexp hinv (inv_nonneg.mpr hdpos.le) (Real.exp_pos _).le + _ = _ := mul_comm _ _ + +theorem planarResolventMode_sharp_upper {r : PlanarPosition} (hr : 1 ≤ ‖r‖) : + planarResolventMode r ≤ ‖r‖ * Real.exp (2 - ‖r‖) := + planar_tilt_envelope_sharp_upper r (planarResolventMode r) + (fun e he => planarResolventMode_tilt_bound e r he) hr + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSiteCutoffs.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSiteCutoffs.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8118e17b88ac2d097a627fb43b956976eede039 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSiteCutoffs.lean @@ -0,0 +1,136 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarPartition +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeH1 + +namespace OAI + +/-! Actual scaled cutoffs for separated planar sites. Their square +partition has a localization cost of order D⁻² independent of site count. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb +open PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +def planarSiteAngle (D : ℝ) (u x : PlanarPosition) : ℝ := + (Real.pi / 2) * cutoffBump ((6 / D) • (x - u)) + +theorem planarSiteAngle_C1 (D : ℝ) (u : PlanarPosition) : + ContDiff ℝ 1 (planarSiteAngle D u) := + contDiff_const.mul ((cutoffBump_smooth.of_le (by simp)).comp + ((contDiff_id.sub contDiff_const).const_smul (6 / D))) + +theorem planarSiteAngle_support {D : ℝ} (hD : 0 < D) (u : PlanarPosition) : + tsupport (planarSiteAngle D u) ⊆ Metric.closedBall u (D / 3) := by + apply closure_minimal ?_ Metric.isClosed_closedBall + intro x hx + change planarSiteAngle D u x ≠ 0 at hx + change dist x u ≤ D / 3 + by_contra! hn + have hb : cutoffBump ((6 / D) • (x - u)) = 0 := by + apply cutoffBump.zero_of_le_dist + change 2 ≤ dist ((6 / D) • (x - u)) 0 + rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_of_pos (div_pos (by norm_num) hD)] + rw [div_mul_eq_mul_div, le_div_iff₀ hD] + rw [dist_eq_norm] at hn + linarith + exact hx (by simp only [planarSiteAngle, hb, mul_zero]) + +theorem planarSiteAngle_disjoint {ι : Type*} {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i - u j‖) + (i j : ι) (hij : i ≠ j) : + Disjoint (tsupport (planarSiteAngle D (u i))) (tsupport (planarSiteAngle D (u j))) := by + apply Set.disjoint_left.mpr + intro x hi hj + have hi' := planarSiteAngle_support hD (u i) hi + have hj' := planarSiteAngle_support hD (u j) hj + simp only [Metric.mem_closedBall, dist_eq_norm] at hi' hj' + have ht : ‖u i - u j‖ ≤ ‖x - u i‖ + ‖x - u j‖ := by + simpa only [dist_eq_norm, norm_sub_rev (u i) x] using dist_triangle (u i) x (u j) + have hs := hsep i j hij + linarith + +theorem planarSiteAngle_inner {D : ℝ} (hD : 0 < D) (u x : PlanarPosition) + (hx : ‖x-u‖ ≤ D / 8) : planarSiteAngle D u x = Real.pi / 2 := by + have hb : cutoffBump ((6 / D) • (x - u)) = 1 := by + apply cutoffBump.one_of_mem_closedBall + change dist ((6 / D) • (x - u)) 0 ≤ 1 + rw [dist_zero_right, norm_smul, Real.norm_eq_abs, abs_of_pos (div_pos (by norm_num) hD)] + rw [div_mul_eq_mul_div, div_le_iff₀ hD] + linarith + simp only [planarSiteAngle, hb, mul_one] + +def planarSitePartition {ι : Type*} [Fintype ι] (D : ℝ) (u : ι → PlanarPosition) : + Option ι → PlanarPosition → ℝ := planarTrigPartition (fun i => planarSiteAngle D (u i)) + +theorem planarSitePartition_C1 {ι : Type*} [Fintype ι] (D : ℝ) + (u : ι → PlanarPosition) (i : Option ι) : ContDiff ℝ 1 (planarSitePartition D u i) := + planarTrigPartition_C1 _ (fun i => planarSiteAngle_C1 D (u i)) i + +theorem planarSitePartition_square_sum {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (x : PlanarPosition) : + ∑ i, planarSitePartition D u i x ^ 2 = 1 := + planarTrigPartition_square_sum _ (planarSiteAngle_disjoint hD u hsep) x + +theorem planarSitePartition_site_inner {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (i : ι) (x : PlanarPosition) (hx : ‖x-u i‖ ≤ D / 8) : + planarSitePartition D u (some i) x = 1 := by + dsimp only [planarSitePartition, planarTrigPartition] + rw [planarSiteAngle_inner hD _ _ hx, Real.sin_pi_div_two] + +theorem planarSiteAngle_partial (D : ℝ) (u e x : PlanarPosition) : + planarPartial (planarSiteAngle D u) e x = + (Real.pi / 2 * (6 / D)) * planarPartial cutoffBump e ((6 / D) • (x-u)) := by + change fderiv ℝ (fun y => Real.pi / 2 * cutoffBump ((6 / D) • (y-u))) x e = + (Real.pi / 2 * (6 / D)) * fderiv ℝ cutoffBump ((6 / D) • (x-u)) e + have hm := ((hasFDerivAt_id (𝕜 := ℝ) x).sub (hasFDerivAt_const u x)).const_smul (6 / D) + have hb := (cutoffBump_smooth.differentiable (by simp) ((6 / D) • (x-u))).hasFDerivAt.comp x hm + have ha := hb.const_mul (Real.pi / 2) + have he := congrArg (fun L : PlanarPosition →L[ℝ] ℝ => L e) ha.fderiv + simpa only [Pi.sub_def, Pi.mul_def, Pi.smul_def, + id_eq, Function.comp_def, + ContinuousLinearMap.comp_apply, smul_apply, smul_eq_mul, sub_zero, + ContinuousLinearMap.id_apply, zero_apply, map_smul, mul_assoc] using he + +def planarSiteDerivativeBound (D : ℝ) : ℝ := + (Real.pi / 2 * (6 / D)) * cutoffGradBound + +theorem planarSiteDerivativeBound_nonnegative {D : ℝ} (hD : 0 < D) : + 0 ≤ planarSiteDerivativeBound D := by + unfold planarSiteDerivativeBound + exact mul_nonneg (mul_nonneg (div_nonneg Real.pi_pos.le (by norm_num)) + (div_pos (by norm_num) hD).le) cutoffGradBound_nonnegative + +theorem planarSiteAngle_partial_bound {D : ℝ} (hD : 0 < D) + (u x : PlanarPosition) (a : Fin 2) : + |planarPartial (planarSiteAngle D u) (planarAxis a) x| ≤ planarSiteDerivativeBound D := by + have hc : 0 ≤ Real.pi / 2 * (6 / D) := + mul_nonneg (div_nonneg Real.pi_pos.le (by norm_num)) (div_pos (by norm_num) hD).le + rw [planarSiteAngle_partial, abs_mul, abs_of_nonneg hc] + apply mul_le_mul_of_nonneg_left ?_ hc + rw [← grad_coordinate] + exact (PiLp.norm_apply_le (grad cutoffBump ((6 / D) • (x-u))) a).trans (cutoffGradBound_spec _) + +theorem planarSitePartition_direction_bound {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (a : Fin 2) (x : PlanarPosition) : + (∑ i, planarPartial (planarSitePartition D u i) (planarAxis a) x ^ 2) ≤ + planarSiteDerivativeBound D ^ 2 := + planarTrigPartition_gradient_bound _ (fun i => planarSiteAngle_C1 D (u i)) + (planarSiteAngle_disjoint hD u hsep) (planarSiteDerivativeBound_nonnegative hD) + (planarAxis a) (fun i x => planarSiteAngle_partial_bound hD (u i) x a) x + +theorem planarSitePartition_gradient_bound {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) (x : PlanarPosition) : + (∑ a : Fin 2, ∑ i, planarPartial (planarSitePartition D u i) (planarAxis a) x ^ 2) ≤ + 2 * planarSiteDerivativeBound D ^ 2 := by + rw [Fin.sum_univ_two] + linarith [planarSitePartition_direction_bound hD u hsep 0 x, + planarSitePartition_direction_bound hD u hsep 1 x] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSliceProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSliceProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..5df878d5526756f64925d17c697c5fa87aa6b88c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSliceProjection.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalResidual +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarCutoffTail + +namespace OAI + +/-! Planar orbital coefficients on product L2, with exact contraction +and subtraction identities. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarCoefficient (u : PlanarPosition) (f : SplitPosition → ℝ) (z : ℝ) : ℝ := + ∫ r, f (r,z)*normalizedPlanarMode (r-u) + +theorem split_memLp_planar_slices (f : SplitPosition → ℝ) (hf : MemLp f 2) : + ∀ᵐ z : ℝ, MemLp (fun r : PlanarPosition => f (r,z)) 2 := by + have hp : MemLp f 2 ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + simpa only [Measure.volume_eq_prod] using hf + filter_upwards [hp.aestronglyMeasurable.prodMk_right,hp.integrable_sq.prod_left_ae] with z hz hi + exact (memLp_two_iff_integrable_sq hz).mpr hi + +theorem planarCoefficient_contraction (u : PlanarPosition) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + MemLp (planarCoefficient u f) 2 ∧ + (∫ z, (planarCoefficient u f z)^2) ≤ ∫ p, f p^2 := by + have hp : MemLp f 2 ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + simpa only [Measure.volume_eq_prod] using hf + have hphi : MemLp (fun r => normalizedPlanarMode (r-u)) 2 := + normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u) + have hm : AEStronglyMeasurable (planarCoefficient u f) volume := + (hp.aestronglyMeasurable.mul hphi.aestronglyMeasurable.comp_fst).prod_swap.integral_prod_right' + have hdom : ∀ᵐ z : ℝ, (planarCoefficient u f z)^2 ≤ ∫ r : PlanarPosition, f (r,z)^2 := by + filter_upwards [split_memLp_planar_slices f hf] with z hz + have h := planar_l2_pair_sq_le (fun r => f (r,z)) + (fun r => normalizedPlanarMode (r-u)) hz hphi + rw [integral_sub_right_eq_self (fun r => normalizedPlanarMode r^2) u, + normalizedPlanarMode_normalized,mul_one] at h + exact h + have hi : Integrable (fun z : ℝ => ∫ r : PlanarPosition, f (r,z)^2) := + hp.integrable_sq.integral_prod_right + have ha : Integrable (fun z => (planarCoefficient u f z)^2) := + hi.mono' (hm.pow 2) (hdom.mono (fun z hz => by + simpa only [Real.norm_eq_abs, + abs_of_nonneg (sq_nonneg (planarCoefficient u f z))] using hz)) + refine ⟨(memLp_two_iff_integrable_sq hm).mpr ha,?_⟩ + have h := integral_mono_ae ha hi hdom + rw [← integral_prod_symm _ hp.integrable_sq] at h + simpa only [Measure.volume_eq_prod] using h + +theorem planarCoefficient_sub_ae (u : PlanarPosition) + (f g : SplitPosition → ℝ) (hf : MemLp f 2) (hg : MemLp g 2) : + planarCoefficient u (fun p => f p-g p) =ᵐ[volume] + fun z => planarCoefficient u f z-planarCoefficient u g z := by + have hphi : MemLp (fun r => normalizedPlanarMode (r-u)) 2 := + normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u) + filter_upwards [split_memLp_planar_slices f hf,split_memLp_planar_slices g hg] with z hz hz' + unfold planarCoefficient + rw [show (fun r => (f (r,z)-g (r,z))*normalizedPlanarMode (r-u)) = + (fun r => f (r,z)*normalizedPlanarMode (r-u)-g (r,z)*normalizedPlanarMode (r-u)) from + funext (fun r => sub_mul _ _ _)] + simpa only [Pi.mul_apply] using integral_sub (hz.integrable_mul hphi) (hz'.integrable_mul hphi) + +theorem planarCoefficient_lift (u : PlanarPosition) (freq : ℝ) + (a : PlanarPosition → ℝ) (z : ℝ) : + planarCoefficient u (verticalLift freq a) z = + (∫ r, a r*normalizedPlanarMode (r-u))*verticalMode freq z := by + unfold planarCoefficient verticalLift + rw [show (fun r => a r*verticalMode freq z*normalizedPlanarMode (r-u)) = + (fun r => (a r*normalizedPlanarMode (r-u))*verticalMode freq z) from + funext (fun r => by ring),integral_mul_const] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolev.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolev.lean new file mode 100644 index 0000000000000000000000000000000000000000..032d51f71b1907bd63639d803b29f9786ca15320 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolev.lean @@ -0,0 +1,212 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventEquation +import RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean.H1 + +namespace OAI + +/-! Closure of the actual manufactured-well inequality on the planar +Sobolev graph. The bounded potential acts on actual L² classes, and the +form is continuous in the function-and-gradient norm. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +namespace PlanarSobolev + +def originalIntegral (f : PlanarPosition → ℝ) : ℝ := ∫ x, f x + +private abbrev originalMeasurable : MeasurableSpace PlanarPosition := inferInstance + +private abbrev originalBorel : @BorelSpace PlanarPosition _ originalMeasurable := inferInstance + +def originalIntegrable (f : PlanarPosition → ℝ) : Prop := Integrable f + +theorem planar_integrable_change_borel + (m : MeasurableSpace PlanarPosition) (hm : @BorelSpace PlanarPosition _ m) + (f : PlanarPosition → ℝ) : + (letI : MeasurableSpace PlanarPosition := m + letI : BorelSpace PlanarPosition := hm + letI : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + Integrable f) ↔ originalIntegrable f := by + have he : m = originalMeasurable := + hm.measurable_eq.trans originalBorel.measurable_eq.symm + cases he + rfl + +theorem planar_integral_change_borel + (m : MeasurableSpace PlanarPosition) (hm : @BorelSpace PlanarPosition _ m) + (f : PlanarPosition → ℝ) : + (letI : MeasurableSpace PlanarPosition := m + letI : BorelSpace PlanarPosition := hm + letI : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + ∫ x, f x) = originalIntegral f := by + have he : m = originalMeasurable := + hm.measurable_eq.trans originalBorel.measurable_eq.symm + cases he + rfl + +local instance : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +abbrev Sobolev := RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean.h1 + (μ := (volume : Measure PlanarPosition)) (E := PlanarPosition) + +abbrev Target := Lp ℝ 2 (volume : Measure PlanarPosition) × + Lp PlanarPosition 2 (volume : Measure PlanarPosition) + +abbrev Test := RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean.C1c + (E := PlanarPosition) + +private theorem well_bounded : ∃ B : ℝ, ∀ x, ‖manufacturedPlanarWell x‖ ≤ B := + manufacturedPlanarWell_C7.continuous.bounded_above_of_compact_support + manufacturedPlanarWell_hasCompactSupport + +def wellBound : ℝ := Classical.choose well_bounded + +theorem wellBound_spec (x : PlanarPosition) : + ‖manufacturedPlanarWell x‖ ≤ wellBound := Classical.choose_spec well_bounded x + +theorem wellBound_nonnegative : 0 ≤ wellBound := + (norm_nonneg (manufacturedPlanarWell 0)).trans (wellBound_spec 0) + +theorem well_mul_memLp (u : Lp ℝ 2 (volume : Measure PlanarPosition)) : + MemLp (fun x => manufacturedPlanarWell x * u x) 2 := by + apply (Lp.memLp u).of_le_mul (c := wellBound) + (manufacturedPlanarWell_C7.continuous.aestronglyMeasurable.mul (Lp.aestronglyMeasurable u)) + exact Filter.Eventually.of_forall (fun x => by + change ‖manufacturedPlanarWell x * u x‖ ≤ wellBound * ‖u x‖ + rw [norm_mul] + exact mul_le_mul_of_nonneg_right (wellBound_spec x) (norm_nonneg _)) + +def wellMultiply (u : Lp ℝ 2 (volume : Measure PlanarPosition)) : + Lp ℝ 2 (volume : Measure PlanarPosition) := + (well_mul_memLp u).toLp (fun x => manufacturedPlanarWell x * u x) + +theorem wellMultiply_ae (u : Lp ℝ 2 (volume : Measure PlanarPosition)) : + wellMultiply u =ᵐ[volume] fun x => manufacturedPlanarWell x * u x := + (well_mul_memLp u).coeFn_toLp + +private def wellMultiplyLinear : Lp ℝ 2 (volume : Measure PlanarPosition) →ₗ[ℝ] + Lp ℝ 2 (volume : Measure PlanarPosition) where + toFun := wellMultiply + map_add' u v := by + apply Lp.ext + filter_upwards [wellMultiply_ae (u + v), wellMultiply_ae u, wellMultiply_ae v, + Lp.coeFn_add u v, Lp.coeFn_add (wellMultiply u) (wellMultiply v)] with x h h₁ h₂ h₃ h₄ + simp only [h, h₄, h₃, Pi.add_apply, h₁, h₂] + exact mul_add _ _ _ + map_smul' c u := by + apply Lp.ext + change (wellMultiply (c • u) : PlanarPosition → ℝ) =ᵐ[volume] + (c • wellMultiply u : Lp ℝ 2 volume) + filter_upwards [wellMultiply_ae (c • u), wellMultiply_ae u, + Lp.coeFn_smul c u, Lp.coeFn_smul c (wellMultiply u)] with x h h₁ h₂ h₃ + simp only [h, h₃, h₁, h₂, Pi.smul_apply, smul_eq_mul] + ring + +def wellMultiplier : Lp ℝ 2 (volume : Measure PlanarPosition) →L[ℝ] + Lp ℝ 2 (volume : Measure PlanarPosition) := + wellMultiplyLinear.mkContinuous wellBound (fun u => + Lp.norm_le_mul_norm_of_ae_le_mul (by + filter_upwards [wellMultiply_ae u] with x hx + change ‖wellMultiply u x‖ ≤ wellBound * ‖u x‖ + rw [hx, norm_mul] + exact mul_le_mul_of_nonneg_right (wellBound_spec x) (norm_nonneg _))) + +def form (u : Target) : ℝ := + (1 / 2 : ℝ) * ‖u.2‖ ^ 2 + inner ℝ u.1 (wellMultiplier u.1) + +theorem form_continuous : Continuous form := + (continuous_const.mul (continuous_snd.norm.pow 2)).add + (continuous_fst.inner (wellMultiplier.continuous.comp continuous_fst)) + +private theorem l2_norm_sq (u : Lp PlanarPosition 2 (volume : Measure PlanarPosition)) : + ‖u‖ ^ 2 = ∫ x, ‖u x‖ ^ 2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + simp only [real_inner_self_eq_norm_sq] + +private theorem l2_real_norm_sq (u : Lp ℝ 2 (volume : Measure PlanarPosition)) : + ‖u‖ ^ 2 = ∫ x, u x ^ 2 := by + rw [← real_inner_self_eq_norm_sq, L2.inner_def] + simp only [RCLike.inner_apply, conj_trivial, sq] + +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean in +theorem grad_coordinate (u : PlanarPosition → ℝ) (x : PlanarPosition) (a : Fin 2) : + grad u x a = planarPartial u (planarAxis a) x := by + have h := InnerProductSpace.toDual_symm_apply (𝕜 := ℝ) + (x := planarAxis a) (y := fderiv ℝ u x) + simpa only [grad, planarPartial, planarAxis, EuclideanSpace.inner_single_right, + conj_trivial, one_mul] using h + +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean in +theorem graph_mass (u : Test) : + ‖(graph (μ := volume) u).1‖ ^ 2 = ∫ x, u.val x ^ 2 := by + rw [l2_real_norm_sq] + apply integral_congr_ae + filter_upwards [(memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp] with x hx + exact congrArg (fun t : ℝ => t ^ 2) hx + +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean in +theorem graph_kinetic (u : Test) : + ‖(graph (μ := volume) u).2‖ ^ 2 = + ∑ a : Fin 2, ∫ x, planarPartial u.val (planarAxis a) x ^ 2 := by + rw [l2_norm_sq] + have hi (a : Fin 2) : Integrable (fun x => planarPartial u.val (planarAxis a) x ^ 2) := by + have hc : HasCompactSupport (planarPartial u.val (planarAxis a)) := + u.property.2.fderiv_apply ℝ (planarAxis a) + have hs : HasCompactSupport (fun x => planarPartial u.val (planarAxis a) x ^ 2) := + hc.comp_left (g := fun t : ℝ => t ^ 2) (by norm_num) + exact ((planarPartial_continuous u.property.1 (planarAxis a)).pow 2).integrable_of_hasCompactSupport hs + rw [← integral_finsetSum Finset.univ (fun a _ => hi a)] + apply integral_congr_ae + filter_upwards [(memLp_grad_of_mem_C1c (μ := volume) u.property).coeFn_toLp] with x hx + change ‖toL2Grad (μ := volume) u x‖ ^ 2 = _ + change toL2Grad (μ := volume) u x = grad u.val x at hx + rw [hx, EuclideanSpace.real_norm_sq_eq] + exact Finset.sum_congr rfl (fun a _ => congrArg (fun t : ℝ => t ^ 2) (grad_coordinate _ _ _)) + +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean in +theorem graph_form (u : Test) : + form (graph (μ := volume) u) = planarTestForm manufacturedPlanarWell u.val := by + unfold form planarTestForm + rw [graph_kinetic, L2.inner_def] + have he (f : PlanarPosition → ℝ) := planar_integral_change_borel + (borel PlanarPosition) ⟨rfl⟩ f + apply congrArg₂ (· + ·) + · congr 1 + exact Finset.sum_congr rfl (fun a _ => he _) + · change (∫ x, inner ℝ ((graph (μ := volume) u).1 x) + (wellMultiplier (graph (μ := volume) u).1 x)) = + originalIntegral (fun x => manufacturedPlanarWell x * u.val x ^ 2) + rw [← he (fun x => manufacturedPlanarWell x * u.val x ^ 2)] + apply integral_congr_ae + filter_upwards [(memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp, + wellMultiply_ae (toL2 (μ := volume) u)] with x hx hw + change toL2 (μ := volume) u x = u.val x at hx + change inner ℝ (toL2 (μ := volume) u x) (wellMultiply (toL2 (μ := volume) u) x) = _ + rw [hw, hx, RCLike.inner_apply, conj_trivial] + ring + +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean in +/-- The proved inequality survives closure in the actual Sobolev norm. -/ +theorem form_lower (u : Sobolev) : + -(1 / 2 : ℝ) * ‖u.val.1‖ ^ 2 ≤ form u.val := by + have hclosed : IsClosed {v : Target | -(1 / 2 : ℝ) * ‖v.1‖ ^ 2 ≤ form v} := + isClosed_le (continuous_const.mul (continuous_fst.norm.pow 2)) form_continuous + have hdense : (LinearMap.range (graph (μ := volume) (E := PlanarPosition)) : Set Target) ⊆ + {v | -(1 / 2 : ℝ) * ‖v.1‖ ^ 2 ≤ form v} := by + rintro _ ⟨v, rfl⟩ + change -(1 / 2 : ℝ) * ‖(graph (μ := volume) v).1‖ ^ 2 ≤ form (graph (μ := volume) v) + rw [graph_mass, graph_form] + rw [planar_integral_change_borel (borel PlanarPosition) ⟨rfl⟩] + exact manufacturedPlanarWell_test_lower v.val v.property.1 v.property.2 + exact closure_minimal hdense hclosed u.property + +end PlanarSobolev +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolevDuality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolevDuality.lean new file mode 100644 index 0000000000000000000000000000000000000000..121669d2901d7ceb9bb0646fce89e37e567aa3f1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSobolevDuality.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundDuality +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarProjectionGap + +namespace OAI + +/-! Ground-state duality on the full closed planar Sobolev graph. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb.PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance instPlanarSobolevDualityMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarSobolevDualityBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarSobolevDualityMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +def groundDualWeight (ψ : Test) (a : Fin 2) (x : PlanarPosition) : ℝ := + planarPartial ψ.val (planarAxis a) x/planarResolventMode x + +theorem groundDualWeight_continuous (ψ : Test) (a : Fin 2) : + Continuous (groundDualWeight ψ a) := + (planarPartial_continuous ψ.property.1 _).div planarResolventMode_C7.continuous + (fun x => (planarResolventMode_positive x).ne') + +theorem groundDualWeight_compact (ψ : Test) (a : Fin 2) : + HasCompactSupport (groundDualWeight ψ a) := by + change HasCompactSupport (fun x => planarPartial ψ.val (planarAxis a) x * + (planarResolventMode x)⁻¹) + exact (ψ.property.2.fderiv_apply ℝ _).mul_right + +theorem groundDualWeight_memLp (ψ : Test) (a : Fin 2) : MemLp (groundDualWeight ψ a) 2 := + (groundDualWeight_continuous ψ a).memLp_of_hasCompactSupport (groundDualWeight_compact ψ a) + +def groundDualLp (ψ : Test) (a : Fin 2) : Lp ℝ 2 (volume : Measure PlanarPosition) := + (groundDualWeight_memLp ψ a).toLp (groundDualWeight ψ a) + +theorem groundDualLp_inner (u : Lp ℝ 2 (volume : Measure PlanarPosition)) + (ψ : Test) (a : Fin 2) : + inner ℝ u (groundDualLp ψ a) = + ∫ x, (u x/planarResolventMode x)*planarPartial ψ.val (planarAxis a) x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [(groundDualWeight_memLp ψ a).coeFn_toLp] with x hx + change inner ℝ (u x) ((groundDualWeight_memLp ψ a).toLp (groundDualWeight ψ a) x) = _ + rw [hx,RCLike.inner_apply,conj_trivial] + unfold groundDualWeight + ring + +theorem graph_groundDualLp_inner (u ψ : Test) (a : Fin 2) : + inner ℝ (graph (μ := volume) u).1 (groundDualLp ψ a) = + ∫ x, planarGroundQuotient u.val x*planarPartial ψ.val (planarAxis a) x := by + rw [groundDualLp_inner] + apply integral_congr_ae + filter_upwards [(memLp_of_mem_C1c (μ := volume) u.property).coeFn_toLp] with x hx + change (toL2 (μ := volume) u x/planarResolventMode x)*_ = _ + change toL2 (μ := volume) u x = u.val x at hx + rw [hx] + rfl + +theorem graph_ground_dual_bound (u ψ : Test) (a : Fin 2) : + (inner ℝ (graph (μ := volume) u).1 (groundDualLp ψ a))^2 ≤ + originalIntegral (fun x => (ψ.val x/planarResolventMode x)^2)* + (2*shiftedForm (graph (μ := volume) u)) := by + have h := planar_ground_dual_bound u.val ψ.val u.property.1 u.property.2 + ψ.property.1 ψ.property.2 a + change (originalIntegral (fun x => planarGroundQuotient u.val x* + planarPartial ψ.val (planarAxis a) x))^2 ≤ + originalIntegral (fun x => (ψ.val x/planarResolventMode x)^2)* + (2*planarTestForm manufacturedPlanarWell u.val+originalIntegral (fun x => u.val x^2)) at h + rw [graph_groundDualLp_inner,shiftedForm,graph_form,graph_mass] + simp_rw [planar_integral_change_borel (borel PlanarPosition) ⟨rfl⟩] + convert h using 1 + ring + +theorem sobolev_ground_dual_bound (u : Sobolev) (ψ : Test) (a : Fin 2) : + (inner ℝ u.val.1 (groundDualLp ψ a))^2 ≤ + originalIntegral (fun x => (ψ.val x/planarResolventMode x)^2)*(2*shiftedForm u.val) := by + have hS : Continuous (fun v : Target => shiftedForm v) := + form_continuous.add (continuous_const.mul (continuous_fst.norm.pow 2)) + have hc : IsClosed {v : Target | (inner ℝ v.1 (groundDualLp ψ a))^2 ≤ + originalIntegral (fun x => (ψ.val x/planarResolventMode x)^2)*(2*shiftedForm v)} := + isClosed_le ((continuous_fst.inner continuous_const).pow 2) + (continuous_const.mul (continuous_const.mul hS)) + apply closure_minimal (s := (LinearMap.range (graph (μ := volume) (E := PlanarPosition)) : Set Target)) + (t := {v : Target | (inner ℝ v.1 (groundDualLp ψ a))^2 ≤ + originalIntegral (fun x => (ψ.val x/planarResolventMode x)^2)*(2*shiftedForm v)}) ?_ hc u.property + rintro _ ⟨f,rfl⟩ + exact graph_ground_dual_bound f ψ a + +theorem zero_ground_form_axis_distribution (u : Sobolev) (hzero : shiftedForm u.val = 0) + (ψ : PlanarPosition → ℝ) (hψ : ContDiff ℝ 1 ψ) (hψc : HasCompactSupport ψ) (a : Fin 2) : + (∫ x, (u.val.1 x/planarResolventMode x)*planarPartial ψ (planarAxis a) x) = 0 := by + let p : Test := ⟨ψ,hψ,hψc⟩ + have hb := sobolev_ground_dual_bound u p a + rw [hzero,mul_zero,mul_zero] at hb + have he : inner ℝ u.val.1 (groundDualLp p a) = 0 := by nlinarith [sq_nonneg (inner ℝ u.val.1 (groundDualLp p a))] + rw [groundDualLp_inner] at he + exact he + +end ContinuumCoulomb.PlanarSobolev + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSpectralInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSpectralInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..290158b670af7b916d12143e0fff1e6f66631c8f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarSpectralInput.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarLocalization +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellBottom + +namespace OAI + +/-! The published negative-ground-energy gap consequence used conditionally. + +Gerald Teschl, *Mathematical Methods in Quantum Mechanics*, second edition, +AMS Graduate Studies in Mathematics 157 (2014), Theorems 10.2, 10.13 and +4.12 (including its quadratic-form-domain version). +Author's text: https://www.mat.univie.ac.at/~gerald/ftp/book-schroe/schroe2.pdf + +For a bounded compactly supported real potential in dimension two, Theorem +10.2 gives the self-adjoint Schrödinger operator, its smooth compact core and +essential spectrum `[0,∞)`. Theorem 10.13 makes an attained ground energy +simple. At a negative ground energy the next max-min value is strictly larger; +Theorem 4.12 states the corresponding inequality on the form domain. Below +we assume only that useful form consequence, then apply it to the actual +manufactured well and its attained bottom. The spectral consequence is +a premise of this conditional interface. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb +namespace PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance instSpectralInputMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instSpectralInputBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instSpectralInputMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +def compactPotentialForm (W : Test) (u : Sobolev) : ℝ := + (1 / 2 : ℝ) * ‖u.val.2‖ ^ 2 + + inner ℝ u.val.1 ((testScalarField W ℝ).operator u.val.1) + +/-- The negative-ground-energy specialization of Teschl's Theorems 10.2, +10.13 and 4.12. Its premises and conclusion concern the actual closed H¹ +graph and the actual multiplication operator for a compact C¹ potential. -/ +def PublishedNegativePlanarGroundGap : Prop := + ∀ (W : Test) (E : ℝ) (g : Sobolev), E < 0 → ‖g.val.1‖ ^ 2 = 1 → + (∀ u : Sobolev, E * ‖u.val.1‖ ^ 2 ≤ compactPotentialForm W u) → + compactPotentialForm W g = E → + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, + inner ℝ u.val.1 g.val.1 = 0 → + (E + γ) * ‖u.val.1‖ ^ 2 ≤ compactPotentialForm W u + +theorem compactPotentialForm_well (u : Sobolev) : + compactPotentialForm wellTest u = form u.val := by + simp only [compactPotentialForm, form, wellTest_operator] + +/-- The single well-specific consequence actually used by the construction. -/ +def ManufacturedPlanarGroundGap : Prop := + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, + inner ℝ u.val.1 normalizedMode.val.1 = 0 → + ((-1/2:ℝ)+γ)*‖u.val.1‖^2 ≤ form u.val + +/-- Conditional gap for the actual resolvent-generated well, using only the +published spectral consequence above. Membership, normalization and energy +of this specific mode and the all-domain lower bound are proved separately. -/ +theorem manufacturedPlanarWell_gap (hpublished : PublishedNegativePlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ ∀ u : Sobolev, + inner ℝ u.val.1 normalizedMode.val.1 = 0 → + ((-1 / 2 : ℝ) + γ) * ‖u.val.1‖ ^ 2 ≤ form u.val := by + obtain ⟨γ, hγ, hbound⟩ := hpublished wellTest (-1 / 2) normalizedMode (by norm_num) + normalizedMode_mass + (fun u => by simpa only [compactPotentialForm_well, neg_div] using form_lower u) + (by simpa only [compactPotentialForm_well, neg_div] using normalizedMode_energy) + exact ⟨γ, hγ, fun u hu => (hbound u hu).trans_eq (compactPotentialForm_well u)⟩ + +end PlanarSobolev +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTestCauchy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTestCauchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..9af66909f508509262683891d475bf86e0648a54 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTestCauchy.lean @@ -0,0 +1,41 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundIdentity + +namespace OAI + +/-! The integral Cauchy–Schwarz estimate used in the planar ground-state +duality argument, on actual compact real test functions. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem planar_toLp_inner (f g : PlanarPosition → ℝ) + (hf : MemLp f 2) (hg : MemLp g 2) : + inner ℝ (hf.toLp f) (hg.toLp g) = ∫ x, f x*g x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hf.coeFn_toLp,hg.coeFn_toLp] with x hx hy + rw [hx,hy,RCLike.inner_apply,conj_trivial] + ring + +private theorem planar_toLp_sq (f : PlanarPosition → ℝ) (hf : MemLp f 2) : + ‖hf.toLp f‖^2 = ∫ x, f x^2 := by + rw [← real_inner_self_eq_norm_sq,planar_toLp_inner f f hf hf] + simp only [pow_two] + +theorem planar_test_cauchy_square (f g : PlanarPosition → ℝ) + (hf : Continuous f) (hg : Continuous g) + (hfc : HasCompactSupport f) (hgc : HasCompactSupport g) : + (∫ x, f x*g x)^2 ≤ (∫ x, f x^2)*(∫ x, g x^2) := by + have hfi : MemLp f 2 := hf.memLp_of_hasCompactSupport hfc + have hgi : MemLp g 2 := hg.memLp_of_hasCompactSupport hgc + have h := (sq_le_sq₀ (abs_nonneg (inner ℝ (hfi.toLp f) (hgi.toLp g))) + (mul_nonneg (norm_nonneg _) (norm_nonneg _))).mpr + (abs_real_inner_le_norm (hfi.toLp f) (hgi.toLp g)) + simpa only [sq_abs,mul_pow,planar_toLp_inner,planar_toLp_sq] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTranslatedGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTranslatedGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..195351e0bbf911835f326cfe933d77ef20ebd18a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarTranslatedGap.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarProjectionGap + +namespace OAI + +/-! The same fixed isolated-well projection gap holds at every actual +planar site, by translation of test functions and Euclidean volume. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarPartial_add_right (f : PlanarPosition → ℝ) (u e x : PlanarPosition) : + planarPartial (fun y => f (y+u)) e x = planarPartial f e (x+u) := by + simp only [planarPartial, fderiv_comp_add_right] + +theorem planarTestForm_translate (W f : PlanarPosition → ℝ) (u : PlanarPosition) : + planarTestForm W (fun x => f (x+u)) = + planarTestForm (fun x => W (x-u)) f := by + unfold planarTestForm + apply congrArg₂ (· + ·) + · congr 1 + apply Finset.sum_congr rfl + intro a _ + simp_rw [planarPartial_add_right] + exact integral_add_right_eq_self (fun x => planarPartial f (planarAxis a) x ^ 2) u + · rw [← integral_add_right_eq_self (fun x => W (x-u) * f x ^ 2) u] + apply integral_congr_ae + filter_upwards [] with x + simp only [add_sub_cancel_right] + +theorem manufacturedPlanarWell_translated_projection_gap + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (u : PlanarPosition) (f : PlanarPosition → ℝ), + ContDiff ℝ 1 f → HasCompactSupport f → + ((-1/2 : ℝ) + γ) * (∫ x, f x ^ 2) - + γ * (∫ x, f x * normalizedPlanarMode (x-u))^2 ≤ + planarTestForm (fun x => manufacturedPlanarWell (x-u)) f := by + obtain ⟨γ, hγ, hsmall, hgap⟩ := manufacturedPlanarWell_actual_projection_gap hpublished + refine ⟨γ, hγ, hsmall, fun u f hf hc => ?_⟩ + have hF : ContDiff ℝ 1 (fun x => f (x+u)) := hf.comp (contDiff_id.add contDiff_const) + have hC : HasCompactSupport (fun x => f (x+u)) := hc.comp_homeomorph (Homeomorph.addRight u) + have h := hgap (fun x => f (x+u)) hF hC + have hm : (∫ x, f (x+u)^2) = ∫ x, f x^2 := + integral_add_right_eq_self (fun x => f x^2) u + have hp : (∫ x, f (x+u) * normalizedPlanarMode x) = + ∫ x, f x * normalizedPlanarMode (x-u) := by + rw [← integral_add_right_eq_self (fun x => f x * normalizedPlanarMode (x-u)) u] + apply integral_congr_ae + filter_upwards [] with x + simp only [add_sub_cancel_right] + rwa [hm, hp, planarTestForm_translate] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarUniformCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarUniformCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bb378116182ee2b5c063805a613d67357ae054a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarUniformCalibration.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarScaleChoice + +namespace OAI + +/-! Uniform contact calibration with a single fixed polynomial scale. -/ + +noncomputable section +namespace ContinuumCoulomb + +/-- Every continuous distance-dependent target in a polynomial range is +attained by the actual amplified contact hopping at a permitted length. The +same fixed polynomial exponent works for every input size and every target +in that range. -/ +theorem exists_uniform_planar_calibration_above (B : ℝ) (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ B ≤ (k : ℝ) ∧ ∀ N : ℝ, 2 ≤ N → + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ ∀ q : ℝ → ℝ, + ContinuousOn q (Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N))) → + (∀ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), (N ^ A)⁻¹ ≤ q d ∧ q d ≤ N ^ A) → + ∃ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), N ^ k * planarHopping d = q d := by + obtain ⟨k, hk, hB, hscale⟩ := exists_planar_polynomial_brackets_above B A hε hε₁ + refine ⟨k, hk, hB, fun N hN => ?_⟩ + obtain ⟨hd, hlo, hhi⟩ := hscale N hN + refine ⟨hd, fun q hq hbound => ?_⟩ + have hD : 0 ≤ (k : ℝ) * Real.log N := + mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by linarith)) + have hab : (1 - ε) * ((k : ℝ) * Real.log N) ≤ + (1 + ε) * ((k : ℝ) * Real.log N) := by nlinarith + let F : ℝ → ℝ := fun d => N ^ k * planarHopping d - q d + have hc : ContinuousOn F (Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N))) := + (continuous_const.mul planarHopping_lipschitz.continuous).continuousOn.sub hq + have h₀ : F ((1 + ε) * ((k : ℝ) * Real.log N)) ≤ 0 := by + have h := hhi.trans (hbound _ ⟨hab, le_rfl⟩).1 + dsimp [F] + linarith + have h₁ : 0 ≤ F ((1 - ε) * ((k : ℝ) * Real.log N)) := by + have h := (hbound _ ⟨le_rfl, hab⟩).2.trans hlo + dsimp [F] + linarith + obtain ⟨d, hdmem, heq⟩ := intermediate_value_Icc' hab hc ⟨h₀, h₁⟩ + exact ⟨d, hdmem, sub_eq_zero.mp heq⟩ + +theorem exists_uniform_planar_calibration (A : ℕ) {ε : ℝ} (hε : 0 < ε) (hε₁ : ε < 1) : + ∃ k : ℕ, 0 < k ∧ ∀ N : ℝ, 2 ≤ N → + 2 ≤ (1 - ε) * ((k : ℝ) * Real.log N) ∧ ∀ q : ℝ → ℝ, + ContinuousOn q (Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N))) → + (∀ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), (N ^ A)⁻¹ ≤ q d ∧ q d ≤ N ^ A) → + ∃ d ∈ Set.Icc ((1 - ε) * ((k : ℝ) * Real.log N)) + ((1 + ε) * ((k : ℝ) * Real.log N)), N ^ k * planarHopping d = q d := by + obtain ⟨k, hk, _, h⟩ := exists_uniform_planar_calibration_above 0 A hε hε₁ + exact ⟨k, hk, h⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWeakConstant.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWeakConstant.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b24dc798be0e963521e70d3d09171eded05c75b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWeakConstant.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarGroundTransform +import Mathlib.Analysis.Calculus.BumpFunction.Convolution +import Mathlib.Analysis.Calculus.ContDiff.Convolution +import Mathlib.Analysis.Calculus.MeanValue + +namespace OAI + +/-! A locally integrable planar function with zero distributional gradient +is constant almost everywhere. This is the uniqueness step needed after the +ground-state transform; it uses actual compact mollifiers. -/ + +noncomputable section +open MeasureTheory Filter ContinuousLinearMap +open scoped Topology Convolution ContDiff +namespace ContinuumCoulomb + +local instance instPlanarWeakConstantMeasurable : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance instPlanarWeakConstantBorel : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance instPlanarWeakConstantMeasure : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +def planarMollifier (k : ℕ) : ContDiffBump (0 : PlanarPosition) where + rIn := 1/((k:ℝ)+1) + rOut := 2/((k:ℝ)+1) + rIn_pos := one_div_pos.mpr (by positivity) + rIn_lt_rOut := div_lt_div_of_pos_right (by norm_num) (by positivity) + +theorem planarMollifier_tendsto : + Tendsto (fun k => (planarMollifier k).rOut) atTop (𝓝 0) := by + have h := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).const_mul 2 + simpa only [planarMollifier,mul_one_div,mul_zero] using h + +private theorem planar_real_convolution_comm (f g : PlanarPosition → ℝ) : + f ⋆ g = g ⋆ f := by + ext x + rw [convolution_eq_swap,convolution_def] + apply integral_congr_ae + exact Filter.Eventually.of_forall (fun _ => mul_comm _ _) + +private theorem planar_reflected_derivative (κ : PlanarPosition → ℝ) + (hκ : ContDiff ℝ ∞ κ) (x y e : PlanarPosition) : + fderiv ℝ (fun z => κ (x-z)) y e = -(fderiv ℝ κ (x-y) e) := by + have hd := ((hκ.differentiable (by simp) (x-y)).hasFDerivAt).comp y + ((hasFDerivAt_id y).const_sub x) + change HasFDerivAt (fun z => κ (x-z)) _ y at hd + rw [hd.fderiv] + simp + +theorem planar_mollification_weak_zero (f : PlanarPosition → ℝ) + (hf : LocallyIntegrable f) + (hw : ∀ (φ : PlanarPosition → ℝ), ContDiff ℝ ∞ φ → HasCompactSupport φ → + ∀ e, (∫ x, f x*fderiv ℝ φ x e) = 0) (k : ℕ) (x e : PlanarPosition) : + fderiv ℝ ((planarMollifier k).normed volume ⋆ f) x e = 0 := by + let κ := (planarMollifier k).normed volume + have hκ : ContDiff ℝ ∞ κ := (planarMollifier k).contDiff_normed + have hc : HasCompactSupport κ := (planarMollifier k).hasCompactSupport_normed + have ht := hw (fun y => κ (x-y)) (hκ.comp (contDiff_const.sub contDiff_id)) + (hc.comp_homeomorph (Homeomorph.subLeft x)) e + simp_rw [planar_reflected_derivative κ hκ x,mul_neg,integral_neg,neg_eq_zero] at ht + rw [planar_real_convolution_comm κ f, + (hc.hasFDerivAt_convolution_right (lsmul ℝ ℝ) hf (hκ.of_le (by simp)) x).fderiv, + convolution_precompR_apply (lsmul ℝ ℝ) hf (hc.fderiv ℝ) + (hκ.continuous_fderiv (by simp)) x e] + simpa only [convolution_def,lsmul_apply,smul_eq_mul] using ht + +theorem planar_weak_gradient_zero_constant (f : PlanarPosition → ℝ) + (hf : LocallyIntegrable f) + (hw : ∀ (φ : PlanarPosition → ℝ), ContDiff ℝ ∞ φ → HasCompactSupport φ → + ∀ e, (∫ x, f x*fderiv ℝ φ x e) = 0) : + ∃ c : ℝ, f =ᵐ[volume] fun _ => c := by + let F (k : ℕ) : PlanarPosition → ℝ := (planarMollifier k).normed volume ⋆ f + have hconst (k : ℕ) (x y : PlanarPosition) : F k x = F k y := by + have hs : ContDiff ℝ ∞ (F k) := + (planarMollifier k).hasCompactSupport_normed.contDiff_convolution_left + (lsmul ℝ ℝ) (planarMollifier k).contDiff_normed hf + apply is_const_of_fderiv_eq_zero (hs.differentiable (by simp)) + intro z + ext e + exact planar_mollification_weak_zero f hf hw k z e + have ht : ∀ᵐ x ∂volume, Tendsto (fun k => F k x) atTop (𝓝 (f x)) := by + apply ContDiffBump.ae_convolution_tendsto_right_of_locallyIntegrable + (φ := planarMollifier) (K := 2) planarMollifier_tendsto _ hf + exact Filter.Eventually.of_forall (fun k => by simp [planarMollifier,div_eq_mul_inv]) + obtain ⟨x,hx⟩ := ht.exists + refine ⟨f x,?_⟩ + filter_upwards [ht] with y hy + have he : (fun k => F k y) = (fun k => F k x) := funext (fun k => hconst k y x) + rw [he] at hy + exact tendsto_nhds_unique hy hx + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellBottom.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellBottom.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea6ee178e00ad1eff1208e2e7ded67122e308040 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellBottom.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarModeEnergy + +namespace OAI + +/-! Exact variational bottom of the manufactured planar well on its +closed Sobolev graph. This is an analytic component of the continuum +construction; it does not assert the hardness reduction. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb +namespace PlanarSobolev +open RellichKondrachov.Analysis.FunctionalSpaces.Sobolev.Euclidean + +local instance : MeasurableSpace PlanarPosition := borel PlanarPosition +local instance : BorelSpace PlanarPosition := ⟨rfl⟩ +local instance : MeasureSpace PlanarPosition := measureSpaceOfInnerProductSpace + +theorem mode_mass : ‖mode.val.1‖ ^ 2 = originalIntegral (fun x => planarResolventMode x ^ 2) := by + rw [← planar_integral_change_borel (borel PlanarPosition) ⟨rfl⟩, + ← real_inner_self_eq_norm_sq, L2.inner_def] + apply integral_congr_ae + filter_upwards [mode_memLp.coeFn_toLp] with x hx + change inner ℝ (mode_memLp.toLp planarResolventMode x) + (mode_memLp.toLp planarResolventMode x) = _ + rw [hx, RCLike.inner_apply, conj_trivial] + ring + +theorem mode_kinetic : ‖mode.val.2‖ ^ 2 = + ∑ a : Fin 2, originalIntegral (fun x => planarPartial planarResolventMode (planarAxis a) x ^ 2) := by + have hi (a : Fin 2) : Integrable (fun x => planarPartial planarResolventMode (planarAxis a) x ^ 2) := + (planar_integrable_change_borel (borel PlanarPosition) ⟨rfl⟩ _).mpr + (planarResolventMode_partial_square_integrable (planarAxis a)) + simp_rw [← planar_integral_change_borel (borel PlanarPosition) ⟨rfl⟩] + rw [← real_inner_self_eq_norm_sq, L2.inner_def, + ← integral_finsetSum Finset.univ (fun a _ => hi a)] + apply integral_congr_ae + filter_upwards [mode_grad_memLp.coeFn_toLp] with x hx + change inner ℝ (mode_grad_memLp.toLp (grad planarResolventMode) x) + (mode_grad_memLp.toLp (grad planarResolventMode) x) = _ + rw [hx, real_inner_self_eq_norm_sq, grad_norm_sq] + +theorem mode_form : form mode.val = planarTestForm manufacturedPlanarWell planarResolventMode := by + unfold form planarTestForm + rw [mode_kinetic] + apply congrArg₂ (· + ·) + · rfl + · change inner ℝ modeTarget.1 (wellMultiplier modeTarget.1) = + originalIntegral (fun x => manufacturedPlanarWell x * planarResolventMode x ^ 2) + rw [← planar_integral_change_borel (borel PlanarPosition) ⟨rfl⟩, L2.inner_def] + apply integral_congr_ae + filter_upwards [mode_memLp.coeFn_toLp, wellMultiply_ae modeTarget.1] with x hx hw + change inner ℝ (modeTarget.1 x) (wellMultiply modeTarget.1 x) = _ + change modeTarget.1 x = planarResolventMode x at hx + rw [hw, hx, RCLike.inner_apply, conj_trivial] + ring + +theorem form_smul (c : ℝ) (u : Target) : form (c • u) = c ^ 2 * form u := by + change (1 / 2 : ℝ) * ‖c • u.2‖ ^ 2 + inner ℝ (c • u.1) (wellMultiplier (c • u.1)) = _ + rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, map_smul, + real_inner_smul_left, real_inner_smul_right] + unfold form + ring + +theorem mode_energy : form mode.val = -(1 / 2 : ℝ) * ‖mode.val.1‖ ^ 2 := by + rw [mode_form, mode_mass] + exact planarResolventMode_energy + +theorem mode_mass_positive : 0 < ‖mode.val.1‖ ^ 2 := by + rw [mode_mass] + exact planarResolventMode_square_integral_positive + +def normalizedMode : Sobolev := (Real.sqrt (‖mode.val.1‖ ^ 2))⁻¹ • mode + +theorem normalizedMode_mass : ‖normalizedMode.val.1‖ ^ 2 = 1 := by + change ‖(Real.sqrt (‖mode.val.1‖ ^ 2))⁻¹ • mode.val.1‖ ^ 2 = 1 + rw [norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, inv_pow, + Real.sq_sqrt mode_mass_positive.le, inv_mul_cancel₀ mode_mass_positive.ne'] + +theorem normalizedMode_energy : form normalizedMode.val = -(1 / 2 : ℝ) := by + change form ((Real.sqrt (‖mode.val.1‖ ^ 2))⁻¹ • mode.val) = _ + rw [form_smul, mode_energy, inv_pow, Real.sq_sqrt mode_mass_positive.le] + calc + _ = -(1 / 2 : ℝ) * ((‖mode.val.1‖ ^ 2)⁻¹ * ‖mode.val.1‖ ^ 2) := by ring + _ = _ := by rw [inv_mul_cancel₀ mode_mass_positive.ne', mul_one] + +def groundEnergy : EReal := + sInf {e | ∃ u : Sobolev, ‖u.val.1‖ ^ 2 = 1 ∧ e = (form u.val : EReal)} + +/-- Exact manufactured-well bottom, proved without a published spectral input. -/ +theorem groundEnergy_eq : groundEnergy = ((-1 / 2 : ℝ) : EReal) := by + apply le_antisymm + · have h := sInf_le (show (form normalizedMode.val : EReal) ∈ + {e | ∃ u : Sobolev, ‖u.val.1‖ ^ 2 = 1 ∧ e = (form u.val : EReal)} from + ⟨normalizedMode, normalizedMode_mass, rfl⟩) + simpa only [groundEnergy, normalizedMode_energy, neg_div] using h + · apply le_sInf + rintro e ⟨u, hu, rfl⟩ + have h := form_lower u + rw [hu, mul_one] at h + simpa only [neg_div] using (EReal.coe_le_coe h) + +end PlanarSobolev +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellLocalization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellLocalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9e7204f1c20e594cd58400f62f963dab68b2aa0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellLocalization.lean @@ -0,0 +1,114 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarIMSBounds + +namespace OAI + +/-! Exact localization of the actual sum of manufactured wells. Site +pieces see exactly their own well; the exterior piece sees zero potential. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def planarWellSum {ι : Type*} [Fintype ι] (u : ι → PlanarPosition) (x : PlanarPosition) : ℝ := + ∑ i, manufacturedPlanarWell (x-u i) + +theorem planarWellSum_continuous {ι : Type*} [Fintype ι] (u : ι → PlanarPosition) : + Continuous (planarWellSum u) := + continuous_finsetSum _ (fun i _ => manufacturedPlanarWell_C7.continuous.comp + (continuous_id.sub (continuous_const : Continuous (fun _ : PlanarPosition => u i)))) + +theorem manufacturedPlanarWell_zero_of_norm_ge_one {x : PlanarPosition} (hx : 1 ≤ ‖x‖) : + manufacturedPlanarWell x = 0 := by + simp only [manufacturedPlanarWell, planarForcing_zero_of_norm_ge_one hx, neg_zero, zero_div] + +theorem planarSitePartition_exterior_inner {ι : Type*} [Fintype ι] {D : ℝ} (hD : 0 < D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (i : ι) (x : PlanarPosition) (hx : ‖x-u i‖ ≤ D/8) : + planarSitePartition D u none x = 0 := by + have ha := planarSiteAngle_inner hD (u i) x hx + have hs : x ∈ tsupport (planarSiteAngle D (u i)) := by + apply subset_tsupport + change planarSiteAngle D (u i) x ≠ 0 + rw [ha] + exact div_ne_zero Real.pi_ne_zero (by norm_num) + change planarTrigPartition (fun j => planarSiteAngle D (u j)) none x = 0 + rw [planarTrigPartition_exterior_at _ (planarSiteAngle_disjoint hD u hsep) hs, + ha, Real.cos_pi_div_two] + +theorem planarWellSum_site_product {ι : Type*} [Fintype ι] {D : ℝ} (hD : 8 ≤ D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (i : ι) (x : PlanarPosition) : + planarWellSum u x * planarSitePartition D u (some i) x = + manufacturedPlanarWell (x-u i) * planarSitePartition D u (some i) x := by + classical + by_cases hz : planarSitePartition D u (some i) x = 0 + · rw [hz, mul_zero, mul_zero] + have hangle : planarSiteAngle D (u i) x ≠ 0 := by + intro ha + exact hz (by simp only [planarSitePartition, planarTrigPartition, ha, Real.sin_zero]) + have hi := planarSiteAngle_support (by linarith : 0 < D) (u i) (subset_tsupport _ hangle) + simp only [Metric.mem_closedBall, dist_eq_norm] at hi + unfold planarWellSum + rw [Finset.sum_mul, Finset.sum_eq_single i] + · intro j _ hji + have ht : ‖u i-u j‖ ≤ ‖x-u i‖ + ‖x-u j‖ := by + simpa only [dist_eq_norm, norm_sub_rev (u i) x] using dist_triangle (u i) x (u j) + have hs := hsep i j hji.symm + rw [manufacturedPlanarWell_zero_of_norm_ge_one (by linarith : 1 ≤ ‖x-u j‖), zero_mul] + · simp + +theorem planarWellSum_exterior_product {ι : Type*} [Fintype ι] {D : ℝ} (hD : 8 ≤ D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (x : PlanarPosition) : planarWellSum u x * planarSitePartition D u none x = 0 := by + unfold planarWellSum + rw [Finset.sum_mul] + apply Finset.sum_eq_zero + intro i _ + by_cases hi : 1 ≤ ‖x-u i‖ + · rw [manufacturedPlanarWell_zero_of_norm_ge_one hi, zero_mul] + · have hx : ‖x-u i‖ ≤ D/8 := by push Not at hi; linarith + rw [planarSitePartition_exterior_inner (by linarith : 0 < D) u hsep i x hx, mul_zero] + +theorem planarTestForm_potential_product_congr (W V f : PlanarPosition → ℝ) + (h : ∀ x, W x * f x = V x * f x) : planarTestForm W f = planarTestForm V f := by + unfold planarTestForm + congr 1 + apply integral_congr_ae + filter_upwards [] with x + simpa only [pow_two, ← mul_assoc] using congrArg (fun t : ℝ => t * f x) (h x) + +theorem planarWellSum_localized_forms {ι : Type*} [Fintype ι] {D : ℝ} (hD : 8 ≤ D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : PlanarPosition → ℝ) : + (∑ i, planarTestForm (planarWellSum u) (fun x => planarSitePartition D u i x * f x)) = + planarTestForm (fun _ => 0) (fun x => planarSitePartition D u none x * f x) + + ∑ i, planarTestForm (fun x => manufacturedPlanarWell (x-u i)) + (fun x => planarSitePartition D u (some i) x * f x) := by + rw [Fintype.sum_option] + apply congrArg₂ (· + ·) + · apply planarTestForm_potential_product_congr + intro x + rw [← mul_assoc, planarWellSum_exterior_product hD u hsep, zero_mul, zero_mul] + · apply Finset.sum_congr rfl + intro i _ + apply planarTestForm_potential_product_congr + intro x + rw [← mul_assoc, ← mul_assoc, planarWellSum_site_product hD u hsep] + +theorem planarWellSum_localization_lower {ι : Type*} [Fintype ι] {D : ℝ} (hD : 8 ≤ D) + (u : ι → PlanarPosition) (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : PlanarPosition → ℝ) (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + planarTestForm (fun _ => 0) (fun x => planarSitePartition D u none x * f x) + + (∑ i, planarTestForm (fun x => manufacturedPlanarWell (x-u i)) + (fun x => planarSitePartition D u (some i) x * f x)) - + planarSiteDerivativeBound D ^ 2 * (∫ x, f x ^ 2) ≤ planarTestForm (planarWellSum u) f := by + have h := planarSitePartition_IMS_lower (by linarith : 0 < D) u hsep + (planarWellSum u) f (planarWellSum_continuous u) hf hc + rwa [planarWellSum_localized_forms hD u hsep f] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..39393babe14d78cd0f4eefb5b0e6c42c6fae8de9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellMatrix.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarOverlap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarRadial + +namespace OAI + +/-! Actual well matrix elements. The well at the first orbital center gives +exactly the distance-dependent hopping; a well far from both centers gives +an error decaying at rate 1.9. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def planarWellMatrix (u v w : PlanarPosition) : ℝ := + ∫ r, normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - w) * normalizedPlanarMode (r - v) + +theorem planarWellMatrix_integrable (u v w : PlanarPosition) : + Integrable (fun r => normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - w) * + normalizedPlanarMode (r - v)) := by + apply (((normalizedPlanarMode_C7.continuous.comp (continuous_id.sub continuous_const)).mul + (manufacturedPlanarWell_C7.continuous.comp (continuous_id.sub continuous_const))).mul + (normalizedPlanarMode_C7.continuous.comp (continuous_id.sub continuous_const))).integrable_of_hasCompactSupport + exact (manufacturedPlanarWell_hasCompactSupport.comp_homeomorph (Homeomorph.subRight w)).mul_left.mul_right + +theorem planarWellMatrix_hopping (u v : PlanarPosition) : + planarWellMatrix u v u = -planarHopping ‖u - v‖ := by + let S : ℝ := ∫ r, planarResolventMode r ^ 2 + have hS : 0 < S := planarResolventMode_square_integral_positive + have hsqrt : Real.sqrt S ≠ 0 := (Real.sqrt_pos.mpr hS).ne' + have hpt (r : PlanarPosition) : + normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - u) * normalizedPlanarMode (r - v) = + -(1 / (2 * S)) * (planarForcing (r - u) * planarResolventMode (r - v)) := by + unfold normalizedPlanarMode manufacturedPlanarWell + change (planarResolventMode (r - u) / Real.sqrt S) * + (-planarForcing (r - u) / (2 * planarResolventMode (r - u))) * + (planarResolventMode (r - v) / Real.sqrt S) = _ + field_simp [hsqrt, (planarResolventMode_positive (r - u)).ne', hS.ne'] + rw [Real.sq_sqrt hS.le] + ring + have hi : (∫ r, planarForcing (r - u) * planarResolventMode (r - v)) = + ∫ r, planarForcing r * planarResolventMode (r - (v - u)) := by + have h := integral_sub_right_eq_self (μ := volume) + (fun r => planarForcing r * planarResolventMode (r - (v - u))) u + convert h using 1 + congr 1 + funext r + rw [show r - u - (v - u) = r - v by abel] + unfold planarWellMatrix + simp_rw [hpt] + rw [integral_const_mul, hi, norm_sub_rev u v, ← planarHoppingAt_norm (v - u)] + simp only [planarHoppingAt] + change -(1 / (2 * S)) * _ = -(_ / (2 * S)) + ring + +def planarWellMatrixConstant : ℝ := + normalizedPlanarExponentialConstant (19 / 20) ^ 2 * Real.exp (19 / 10) * + (∫ r : PlanarPosition, |manufacturedPlanarWell r|) + +theorem planarWellMatrixConstant_nonnegative : 0 ≤ planarWellMatrixConstant := + mul_nonneg (mul_nonneg (sq_nonneg _) (Real.exp_pos _).le) + (integral_nonneg (fun _ => abs_nonneg _)) + +theorem planarWellMatrix_two_far {D : ℝ} (u v w : PlanarPosition) + (hu : D ≤ ‖u - w‖) (hv : D ≤ ‖v - w‖) : + |planarWellMatrix u v w| ≤ planarWellMatrixConstant * Real.exp (-(19 / 10 : ℝ) * D) := by + let C := normalizedPlanarExponentialConstant (19 / 20) + have hC : 0 ≤ C := (normalizedPlanarExponentialConstant_positive (by norm_num) (by norm_num)).le + let B := C ^ 2 * Real.exp ((19 / 10 : ℝ) - (19 / 10 : ℝ) * D) + have hpt (r : PlanarPosition) : + ‖normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - w) * normalizedPlanarMode (r - v)‖ ≤ + B * |manufacturedPlanarWell (r - w)| := by + by_cases hw : manufacturedPlanarWell (r - w) = 0 + · simp only [hw, mul_zero, zero_mul, norm_zero, abs_zero, le_refl] + have hs : ‖r - w‖ ≤ 1 := by + have hm := (manufacturedPlanarWell_support.trans planarForcing_support) + (subset_tsupport _ (show r - w ∈ Function.support manufacturedPlanarWell from hw)) + simpa only [Metric.mem_closedBall, dist_zero_right] using hm + have htu : ‖u - w‖ ≤ ‖r - u‖ + ‖r - w‖ := by + simpa only [dist_eq_norm, norm_sub_rev u r] using dist_triangle u r w + have htv : ‖v - w‖ ≤ ‖r - v‖ + ‖r - w‖ := by + simpa only [dist_eq_norm, norm_sub_rev v r] using dist_triangle v r w + have he : -(19 / 20 : ℝ) * (‖r - u‖ + ‖r - v‖) ≤ 19 / 10 - (19 / 10 : ℝ) * D := by + linarith + have hp : normalizedPlanarMode (r - u) * normalizedPlanarMode (r - v) ≤ B := by + calc + _ ≤ (C * Real.exp (-(19 / 20 : ℝ) * ‖r - u‖)) * + (C * Real.exp (-(19 / 20 : ℝ) * ‖r - v‖)) := + mul_le_mul (normalizedPlanarMode_exponential_envelope (by norm_num) (by norm_num) _) + (normalizedPlanarMode_exponential_envelope (by norm_num) (by norm_num) _) + (normalizedPlanarMode_positive _).le (mul_nonneg hC (Real.exp_pos _).le) + _ = C ^ 2 * Real.exp (-(19 / 20 : ℝ) * (‖r - u‖ + ‖r - v‖)) := by + rw [show -(19 / 20 : ℝ) * (‖r - u‖ + ‖r - v‖) = + -(19 / 20 : ℝ) * ‖r - u‖ + -(19 / 20 : ℝ) * ‖r - v‖ by ring, Real.exp_add] + ring + _ ≤ B := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr he) (sq_nonneg C) + rw [norm_mul, norm_mul, Real.norm_of_nonneg (normalizedPlanarMode_positive _).le, + Real.norm_of_nonneg (normalizedPlanarMode_positive _).le, Real.norm_eq_abs] + convert mul_le_mul_of_nonneg_right hp (abs_nonneg (manufacturedPlanarWell (r - w))) using 1 + ring + have hiW : Integrable manufacturedPlanarWell := + manufacturedPlanarWell_C7.continuous.integrable_of_hasCompactSupport manufacturedPlanarWell_hasCompactSupport + have hi := (hiW.abs.comp_sub_right w).const_mul B + have h := norm_integral_le_of_norm_le hi (Filter.Eventually.of_forall hpt) + rw [integral_const_mul, integral_sub_right_eq_self (fun r : PlanarPosition => |manufacturedPlanarWell r|) w] at h + rw [Real.norm_eq_abs] at h + apply h.trans_eq + dsimp [B, C, planarWellMatrixConstant] + rw [show (19 / 10 : ℝ) - (19 / 10 : ℝ) * D = + (19 / 10 : ℝ) + -(19 / 10 : ℝ) * D by ring, Real.exp_add] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellNumerics.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellNumerics.lean new file mode 100644 index 0000000000000000000000000000000000000000..165926c4c6177b1d32f6e5b8af1075b9f80a112c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellNumerics.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableResolvent +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactQuotientBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellLocalization + +namespace OAI + +/-! A fixed guard turns the actual heat-resolvent evaluator into an +evaluator of the compact manufactured planar well. The guard is chosen +once on the unit disk; no instance-dependent real parameter is encoded. -/ + +noncomputable section +namespace ContinuumCoulomb.PlanarWellNumerics + +private theorem guard_exists : ∃ C : ℕ, 0 < C ∧ + ∀ r : PlanarPosition, ‖r‖ ≤ 1 → 2 ≤ (C:ℝ)*planarResolventMode r := by + obtain ⟨r,hr,hmin⟩ := (isCompact_closedBall (0:PlanarPosition) 1).exists_isMinOn + (Metric.nonempty_closedBall.mpr (by norm_num)) planarResolventMode_C7.continuous.continuousOn + obtain ⟨C,hC⟩ := exists_nat_gt (2/planarResolventMode r + 1) + have hp := planarResolventMode_positive r + have hCp : 0 < C := by + have hh : (0:ℝ) < C := lt_trans (by positivity) hC + exact_mod_cast hh + refine ⟨C,hCp,fun s hs => ?_⟩ + have hs' : s ∈ Metric.closedBall (0:PlanarPosition) 1 := by + simpa only [Metric.mem_closedBall,dist_zero_right] using hs + have hbase : 2 ≤ (C:ℝ)*planarResolventMode r := by + have hc : 2/planarResolventMode r ≤ C := by linarith + exact (div_le_iff₀ hp).mp hc + exact hbase.trans (mul_le_mul_of_nonneg_left (hmin hs') (Nat.cast_nonneg C)) + +def guard : ℕ := Classical.choose guard_exists + +theorem guard_positive : 0 < guard := (Classical.choose_spec guard_exists).1 + +theorem guard_bound (r : PlanarPosition) (hr : ‖r‖ ≤ 1) : + 2 ≤ (guard:ℝ)*planarResolventMode r := (Classical.choose_spec guard_exists).2 r hr + +def precision (p : ℕ) : ℕ := 4*guard^2*(p+1) + +def outside (q : ℚ×ℚ) : Prop := 1 ≤ q.1^2+q.2^2 +instance (q : ℚ×ℚ) : Decidable (outside q) := inferInstanceAs (Decidable (1 ≤ q.1^2+q.2^2)) + +def approximate (p : ℕ) (q : ℚ×ℚ) : ℚ := + if outside q then 0 else + -PlanarForcingProgram.value q / + (2*ResolventSchedule.approximate ((2,precision p),q)) + +theorem outside_norm {q : ℚ×ℚ} (hq : outside q) : + 1 ≤ ‖PlanarForcingProgram.position q‖ := by + have hqR : (1:ℝ) ≤ (q.1:ℝ)^2+(q.2:ℝ)^2 := by exact_mod_cast hq + rw [← PlanarForcingProgram.position_norm_sq] at hqR + nlinarith [norm_nonneg (PlanarForcingProgram.position q)] + +theorem inside_norm {q : ℚ×ℚ} (hq : ¬ outside q) : + ‖PlanarForcingProgram.position q‖ ≤ 1 := by + have hqR : (q.1:ℝ)^2+(q.2:ℝ)^2 < 1 := by exact_mod_cast lt_of_not_ge hq + rw [← PlanarForcingProgram.position_norm_sq] at hqR + nlinarith [norm_nonneg (PlanarForcingProgram.position q)] + +theorem approximation_error (p : ℕ) (q : ℚ×ℚ) : + |(approximate p q:ℝ)-manufacturedPlanarWell (PlanarForcingProgram.position q)| ≤ + ((p:ℝ)+1)⁻¹ := by + by_cases hq : outside q + · rw [approximate,ite_eq_left hq,manufacturedPlanarWell_zero_of_norm_ge_one (outside_norm hq)] + simp only [Rat.cast_zero,sub_self,abs_zero] + positivity + · have hr := inside_norm hq + let r := PlanarForcingProgram.position q + let ε : ℝ := ((precision p:ℝ)+1)⁻¹ + have hC : (1:ℝ) ≤ guard := by exact_mod_cast guard_positive + have hCp : (0:ℝ) < guard := by linarith + have hp : (0:ℝ) < (p:ℝ)+1 := by positivity + have hprec : (precision p:ℝ) = 4*(guard:ℝ)^2*((p:ℝ)+1) := by + simp only [precision,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat,Nat.cast_add,Nat.cast_one] + have hsmall : (guard:ℝ)*ε ≤ 1 := by + dsimp [ε] + apply (mul_inv_le_iff₀ (by positivity)).mpr + rw [hprec] + nlinarith [sq_nonneg ((guard:ℝ)-1),Nat.cast_nonneg (α := ℝ) p] + have heval := ResolventSchedule.approximation_error ((2,precision p),q) + (by exact hr.trans (by norm_num)) + have hb : |-planarForcing r| ≤ 4 := by + rw [abs_neg,abs_of_nonneg (planarForcing_nonnegative r)] + linarith [planarForcing_le_one r] + have h := contact_quotient_error hC (planarResolventMode_positive r) + (guard_bound r hr) (by dsimp [ε]; positivity) hsmall hb heval + (show |-planarForcing r - -planarForcing r| ≤ ε by simp only [sub_self,abs_zero]; dsimp [ε]; positivity) + have hlast : 3*(guard:ℝ)^2*ε ≤ ((p:ℝ)+1)⁻¹ := by + dsimp [ε] + rw [hprec] + apply (mul_le_mul_iff_left₀ hp).mp + field_simp + nlinarith [sq_nonneg (guard:ℝ)] + apply (le_trans ?_ hlast) + simpa only [approximate,ite_eq_right hq,manufacturedPlanarWell,PlanarForcingProgram.value_cast, + Rat.cast_div,Rat.cast_mul,Rat.cast_ofNat,Rat.cast_neg,r] using h + +end ContinuumCoulomb.PlanarWellNumerics + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellOverlap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellOverlap.lean new file mode 100644 index 0000000000000000000000000000000000000000..44ed17044637d278dd953eaaf9ea1406bc94f9c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PlanarWellOverlap.lean @@ -0,0 +1,37 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSobolev + +namespace OAI + +/-! A well at any center has an off-diagonal matrix bound from the actual +orbital overlap. This also controls the small depth counterterms. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarWellMatrix_le_overlap (u v w : PlanarPosition) : + |planarWellMatrix u v w| ≤ PlanarSobolev.wellBound * planarModeOverlap u v := by + have hi := (planarModeOverlap_integrable u v).const_mul PlanarSobolev.wellBound + have h := norm_integral_le_of_norm_le (f := fun r => + normalizedPlanarMode (r - u) * manufacturedPlanarWell (r - w) * normalizedPlanarMode (r - v)) + hi (Filter.Eventually.of_forall (fun r => by + rw [norm_mul, norm_mul, Real.norm_of_nonneg (normalizedPlanarMode_positive _).le, + Real.norm_of_nonneg (normalizedPlanarMode_positive _).le] + have hp := mul_le_mul_of_nonneg_right (PlanarSobolev.wellBound_spec (r - w)) + (mul_nonneg (normalizedPlanarMode_positive (r - u)).le (normalizedPlanarMode_positive (r - v)).le) + convert hp using 1 + ring)) + simpa only [Real.norm_eq_abs, integral_const_mul, planarWellMatrix, planarModeOverlap] using h + +theorem planarWellMatrix_overlap_decay (u v w : PlanarPosition) : + |planarWellMatrix u v w| ≤ + (PlanarSobolev.wellBound * planarOverlapConstant) * Real.exp (-(9 / 10 : ℝ) * ‖u - v‖) := by + exact (planarWellMatrix_le_overlap u v w).trans ((mul_le_mul_of_nonneg_left + (planarModeOverlap_decay u v) PlanarSobolev.wellBound_nonnegative).trans_eq (mul_assoc _ _ _).symm) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..086eea00222d30323e5fdee6227a88429ccc9f88 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorCalibration.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.AutomaticCalibrationNormalization + +namespace OAI + +/-! A fixed positive rational prefactor in the physical amplification is +absorbed into the requested edge weight. This retains the proved evaluator +and bisection, including their polynomial running times. -/ + +noncomputable section +namespace ContinuumCoulomb.PrefactorCalibration + +def adjustedWeight (a K : ℚ) : ℚ := K / a^2 +def precision (C P : ℕ) : ℕ := C*(P+1) +def input (a : ℚ) (C : ℕ) (x : AutomaticCalibration.Input) : AutomaticCalibration.Input := + (x.1,(precision C x.2.1,adjustedWeight a x.2.2)) +def value (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) (k A B : ℕ) + (x : AutomaticCalibration.Input) : ℚ := + AutomaticCalibration.value rho ε c k A B (input a C x) +def normalizedValue (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) (k A B : ℕ) + (x : AutomaticCalibration.Input) : ℚ := + value rho a C ε c k A B x / AutomaticCalibration.spacing c k x.1 + +theorem normalizedValue_mem (rho : ℕ) (a : ℚ) (C : ℕ) {ε c : ℚ} + (hε : 0 ≤ ε) (hc : 0 < c) (k A B : ℕ) (x : AutomaticCalibration.Input) + (hN : 0 < x.1) : normalizedValue rho a C ε c k A B x ∈ + Set.Icc (1-ε/2) (1+ε/2) := + AutomaticCalibration.normalizedValue_mem rho hε hc k A B (input a C x) hN + +theorem target_scale {a : ℝ} (ha : 0 < a) (freq τ K d : ℝ) : + a*coulombHoppingTarget freq τ (K/a^2) d = coulombHoppingTarget freq τ K d := by + unfold coulombHoppingTarget + rw [show K/a^2*(localizedCoulombProfile freq 0-localizedCoulombProfile freq d) = + (K*(localizedCoulombProfile freq 0-localizedCoulombProfile freq d))/a^2 by ring, + Real.sqrt_div' _ (sq_nonneg a),Real.sqrt_sq ha.le] + field_simp [ha.ne'] + +theorem weight_polynomial_range {a : ℚ} (ha : 0 < a) (A : ℕ) : + ∃ L : ℕ, 0 < L ∧ ∀ (N : ℝ), 2 ≤ N → ∀ K : ℚ, + (N^A)⁻¹ ≤ (K:ℝ) → (K:ℝ) ≤ N^A → + (N^(A+L))⁻¹ ≤ (adjustedWeight a K:ℝ) ∧ + (adjustedWeight a K:ℝ) ≤ N^(A+L) := by + have haR : (0:ℝ) < a := by exact_mod_cast ha + have ha2 : 0 < ((a:ℝ)^2)⁻¹ := inv_pos.mpr (sq_pos_of_pos haR) + obtain ⟨L,hL,hbound⟩ := exists_polynomial_constant_bounds ha2 (((a:ℝ)^2)⁻¹) + refine ⟨L,hL,fun N hN K hlo hhi => ?_⟩ + have hNp : 0 < N := by linarith + have hK : (0:ℝ) ≤ K := (inv_nonneg.mpr (pow_nonneg hNp.le A)).trans hlo + obtain ⟨hcl,hcu⟩ := hbound N hN + have he : (adjustedWeight a K:ℝ) = (K:ℝ)*((a:ℝ)^2)⁻¹ := by + rw [adjustedWeight,Rat.cast_div,Rat.cast_pow,div_eq_mul_inv] + rw [he,pow_add,mul_inv_rev] + constructor + · have hm := mul_le_mul hlo hcl (inv_nonneg.mpr (pow_nonneg hNp.le L)) hK + simpa only [mul_comm] using hm + · exact mul_le_mul hhi hcu ha2.le (pow_nonneg hNp.le A) + +theorem precision_error {a : ℝ} {C : ℕ} (_ha : 0 ≤ a) (hC : a ≤ C) (P : ℕ) : + a*((precision C P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ := by + rw [← div_eq_mul_inv,inv_eq_one_div] + apply (div_le_div_iff₀ (by positivity) (by positivity)).mpr + have hm := mul_le_mul_of_nonneg_right hC (by positivity : (0:ℝ) ≤ (P:ℝ)+1) + simp only [precision,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + nlinarith + +theorem exists_calibration (rho : ℕ) (hrho : 0 < rho) + (a : ℚ) (ha : 0 < a) (ε : ℚ) (hε : 0 < ε) (hε1 : ε < 1) + (A B : ℕ) (kmin : ℝ) : + ∃ (C L : ℕ) (c : ℚ) (k : ℕ), 0 < C ∧ 0 < L ∧ 0 < c ∧ 0 < k ∧ kmin ≤ (k:ℝ) ∧ + ∀ (N P : ℕ) (K : ℚ), 2 ≤ N → ((N:ℝ)^A)⁻¹ ≤ K → (K:ℝ) ≤ (N:ℝ)^A → + let d := value rho a C ε c k (A+L) B (N,(P,K)) + let D := (k:ℝ)*Real.log (N:ℝ) + (1-(ε:ℝ))*D ≤ d ∧ (d:ℝ) ≤ (1+(ε:ℝ))*D ∧ + localizedGramConstant (GaussianFrequency.frequency rho) ≤ + localizedCoulombProfile (GaussianFrequency.frequency rho) 0- + localizedCoulombProfile (GaussianFrequency.frequency rho) d ∧ + |(a:ℝ)*(N:ℝ)^k*planarHopping d- + coulombHoppingTarget (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ K d| ≤ + ((P:ℝ)+1)⁻¹ := by + have haR : (0:ℝ) < a := by exact_mod_cast ha + obtain ⟨C,hC⟩ := exists_nat_gt (max 1 (a:ℝ)) + have hCp : 0 < C := by + have hp : (0:ℝ) < C := lt_trans zero_lt_one ((le_max_left _ _).trans_lt hC) + exact_mod_cast hp + have hCa : (a:ℝ) ≤ C := ((le_max_right _ _).trans_lt hC).le + obtain ⟨L,hL,hweights⟩ := weight_polynomial_range ha A + obtain ⟨c,k,hc,hk,hkmin,hcal⟩ := AutomaticCalibration.exists_automatic_calibration + rho hrho ε hε hε1 (A+L) B kmin + refine ⟨C,L,c,k,hCp,hL,hc,hk,hkmin,fun N P K hN hlo hhi => ?_⟩ + obtain ⟨hwl,hwu⟩ := hweights N (by exact_mod_cast hN) K hlo hhi + obtain ⟨hdl,hdu,hgap,herror⟩ := hcal N (precision C P) (adjustedWeight a K) hN hwl hwu + change (1-(ε:ℝ))*((k:ℝ)*Real.log (N:ℝ)) ≤ + AutomaticCalibration.value rho ε c k (A+L) B (N,(precision C P,adjustedWeight a K)) ∧ _ + refine ⟨hdl,hdu,hgap,?_⟩ + let d := AutomaticCalibration.value rho ε c k (A+L) B (N,(precision C P,adjustedWeight a K)) + have ht := target_scale haR (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ K d + have hweight : (adjustedWeight a K:ℝ) = (K:ℝ)/(a:ℝ)^2 := by + simp only [adjustedWeight,Rat.cast_div,Rat.cast_pow] + rw [hweight] at herror + change |(a:ℝ)*(N:ℝ)^k*planarHopping d- + coulombHoppingTarget (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ K d| ≤ ((P:ℝ)+1)⁻¹ + calc + _ = |(a:ℝ)*((N:ℝ)^k*planarHopping d- + coulombHoppingTarget (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ + ((K:ℝ)/(a:ℝ)^2) d)| := by rw [mul_sub,ht]; congr 1; ring + _ = (a:ℝ)*|(N:ℝ)^k*planarHopping d- + coulombHoppingTarget (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ + ((K:ℝ)/(a:ℝ)^2) d| := by rw [abs_mul,abs_of_pos haR] + _ ≤ (a:ℝ)*((precision C P:ℝ)+1)⁻¹ := mul_le_mul_of_nonneg_left herror haR.le + _ ≤ ((P:ℝ)+1)⁻¹ := precision_error haR.le hCa P + +end ContinuumCoulomb.PrefactorCalibration + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..7430a2409e795c6460b43c597c16c55f8d023b69 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceCalibration.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorSourceContactCorrectness + +namespace OAI + +/-! Uniform, executable nominal calibration for the actual positive +three-stage graph, with precisely the amplification of the nuclear mesh. -/ + +noncomputable section +namespace ContinuumCoulomb.PrefactorSourceContactProgram +open ContactMediator + +def nominalDistance (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) + (s p k A B : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) + (e : GlobalEdge (SourceMetadataProgram.geometricSource s d hd)) : ℚ := + PrefactorCalibration.value rho a C ε c k A B + (CalibrationMesh.base (SourceContactProgram.size d), + (SourceContactProgram.size d ^ p,SourceContactProgram.weights s d hd e)) + +theorem graphLengths_scale (rho : ℕ) (a : ℚ) (C : ℕ) (ε : ℚ) + {c : ℚ} (hc : 0 < c) (s p k A B : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) + (e : GlobalEdge (SourceMetadataProgram.geometricSource s d hd)) : + (AutomaticCalibration.spacing c k (CalibrationMesh.base (SourceContactProgram.size d)):ℝ) * + CalibratedContactProgram.graphLengths rho ε c k A B + (CalibrationMesh.base (SourceContactProgram.size d)) + (PrefactorCalibration.precision C (SourceContactProgram.size d ^ p)) + (SourceMetadataProgram.geometricSource s d hd) (weights a s d hd) e = + nominalDistance rho a C ε c s p k A B d hd e := by + exact CalibratedContactProgram.graphLengths_scale rho ε hc k A B + (CalibrationMesh.base (SourceContactProgram.size d)) + (PrefactorCalibration.precision C (SourceContactProgram.size d ^ p)) + (by have h := CalibrationMesh.base_ge_two (SourceContactProgram.size_ge_two d); omega) + (SourceMetadataProgram.geometricSource s d hd) (weights a s d hd) e + +theorem exists_nominal_calibration (rho : ℕ) (hrho : 0 < rho) + (ε : ℚ) (hε : 0 < ε) (hε1 : ε < 1) (s B : ℕ) (kmin : ℝ) : + ∃ (C A : ℕ) (c : ℚ) (k : ℕ), 0 < C ∧ 0 < c ∧ 0 < k ∧ kmin ≤ (k:ℝ) ∧ + ∀ (d : BinaryHeisenberg) (hd : d.Valid), d.PolynomialPromise s → ∀ p : ℕ, + ∀ e : GlobalEdge (SourceMetadataProgram.geometricSource s d hd), + let r := nominalDistance rho (CalibrationMesh.prefactor rho) C ε c s p k A B d hd e + let N := CalibrationMesh.base (SourceContactProgram.size d) + let D := (k:ℝ)*Real.log N + (1-(ε:ℝ))*D ≤ r ∧ (r:ℝ) ≤ (1+(ε:ℝ))*D ∧ + localizedGramConstant (GaussianFrequency.frequency rho) ≤ + localizedCoulombProfile (GaussianFrequency.frequency rho) 0- + localizedCoulombProfile (GaussianFrequency.frequency rho) r ∧ + |(CalibrationMesh.amplification rho (SourceContactProgram.size d) k:ℝ)*planarHopping r- + coulombHoppingTarget (GaussianFrequency.frequency rho) ((N:ℝ)^B)⁻¹ + (SourceContactProgram.weights s d hd e) r| ≤ + ((SourceContactProgram.size d:ℝ)^p+1)⁻¹ := by + obtain ⟨A,hA,hweights⟩ := source_weight_range s + obtain ⟨C,L,c,k,hC,hL,hc,hk,hkmin,hcal⟩ := PrefactorCalibration.exists_calibration + rho hrho (CalibrationMesh.prefactor rho) (CalibrationMesh.prefactor_positive hrho) + ε hε hε1 A B kmin + refine ⟨C,A+L,c,k,hC,hc,hk,hkmin,fun d hd hp p e => ?_⟩ + obtain ⟨hlo,hhi⟩ := hweights d hd hp e + have hm := hcal (CalibrationMesh.base (SourceContactProgram.size d)) + (SourceContactProgram.size d ^ p) (SourceContactProgram.weights s d hd e) + (CalibrationMesh.base_ge_two (SourceContactProgram.size_ge_two d)) hlo hhi + simpa only [nominalDistance,CalibrationMesh.amplification,Rat.cast_mul,Rat.cast_pow, + Rat.cast_natCast,Nat.cast_pow] using hm + +end ContinuumCoulomb.PrefactorSourceContactProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceContactCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceContactCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..3066587c07b435ca05ba9be1a5917abb77af349d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSourceContactCorrectness.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefactorSourceContactProgram + +namespace OAI + +/-! The prefactor-aware program retains the exact final graph enumeration, +and calibrates its original weights at the physical unit-charge scale. -/ + +noncomputable section +namespace ContinuumCoulomb.PrefactorSourceContactProgram +open ContactMediator + +def weights (a : ℚ) (s : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) : + GlobalEdge (SourceMetadataProgram.geometricSource s d hd) → ℚ := + fun e => PrefactorCalibration.adjustedWeight a (SourceContactProgram.weights s d hd e) + +theorem electron_count (s : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) : + (SourcePositiveProgram.output s d).vertices = + Fintype.card (GlobalSite (SourceMetadataProgram.geometricSource s d hd)) := by + rw [SourcePositiveProgram.vertices_eq s d hd] + simp only [GlobalSite,Fintype.card_fin] + rfl + +theorem electron_count_positive (s : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) : + 0 < (SourcePositiveProgram.output s d).vertices := by + rw [electron_count s d hd,globalSite_card] + have hp := (SourceMetadataProgram.geometricSource s d hd).vertices_pos + omega + +theorem input_eq_graphInput (a : ℚ) (C s p h : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) : + input a C s p h d = CalibratedContactProgram.graphInput + (SourceMetadataProgram.geometricSource s d hd) + (CalibrationMesh.base (SourceContactProgram.size d)) + (PrefactorCalibration.precision C (SourceContactProgram.size d ^ p)) + (SourceContactProgram.size d ^ h) (weights a s d hd) := by + unfold input CalibratedContactProgram.graphInput + rw [SourceContactProgram.coordinates_eq s d hd,SourceContactProgram.signedBonds_eq s d hd, + SourceContactProgram.weights_eq s d hd,List.map_ofFn] + rfl + +theorem value_eq_array (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) + (s p h k A B : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) : + value rho a C ε c s p h k A B d = List.ofFn (fun x => + ContactCalibratedGeometry.position (SourceMetadataProgram.geometricSource s d hd) + (SourceContactProgram.size d ^ h) + (AutomaticCalibration.spacing c k (CalibrationMesh.base (SourceContactProgram.size d))) + (CalibratedContactProgram.graphLengths rho ε c k A B + (CalibrationMesh.base (SourceContactProgram.size d)) + (PrefactorCalibration.precision C (SourceContactProgram.size d ^ p)) + (SourceMetadataProgram.geometricSource s d hd) (weights a s d hd)) x) := by + unfold value + rw [input_eq_graphInput] + exact CalibratedContactProgram.value_graphInput _ _ _ _ _ _ _ _ _ _ _ + +theorem source_weight_range (s : ℕ) : ∃ A : ℕ, 0 < A ∧ + ∀ (d : BinaryHeisenberg) (hd : d.Valid), d.PolynomialPromise s → + ∀ e : GlobalEdge (SourceMetadataProgram.geometricSource s d hd), + ((CalibrationMesh.base (SourceContactProgram.size d):ℝ)^A)⁻¹ ≤ + SourceContactProgram.weights s d hd e ∧ + (SourceContactProgram.weights s d hd e:ℝ) ≤ + (CalibrationMesh.base (SourceContactProgram.size d):ℝ)^A := by + obtain ⟨A,hA,hweight⟩ := SourceMetadataProgram.geometricSource_weight_range s + refine ⟨A,hA,fun d hd hp e => ?_⟩ + obtain ⟨hlo,hhi⟩ := hweight d hd hp e + have hn : (1:ℝ) ≤ SourceContactProgram.size d := by + exact_mod_cast (show 1 ≤ SourceContactProgram.size d from + le_trans (by decide : 1 ≤ 2) (SourceContactProgram.size_ge_two d)) + have hbase : (SourceContactProgram.size d:ℝ) ≤ + CalibrationMesh.base (SourceContactProgram.size d) := by + simp only [CalibrationMesh.base,Nat.cast_pow] + exact le_self_pow₀ hn (by decide) + have hpow := pow_le_pow_left₀ (by positivity : (0:ℝ) ≤ SourceContactProgram.size d) hbase A + have hsize : (SourceContactProgram.size d:ℝ) = + (binaryHeisenbergCodec.encode d).length + 2 := by + simp only [SourceContactProgram.size,SourceMetadataProgram.size,Nat.cast_add,Nat.cast_one] + ring + have hlo' : ((SourceContactProgram.size d:ℝ)^A)⁻¹ ≤ + (SourceContactProgram.weights s d hd e:ℝ) := by + simpa only [hsize,SourceContactProgram.weights,SourcePositiveProgram.sourceBound] using hlo + have hhi' : (SourceContactProgram.weights s d hd e:ℝ) ≤ + (SourceContactProgram.size d:ℝ)^A := by + simpa only [hsize,SourceContactProgram.weights,SourcePositiveProgram.sourceBound] using hhi + refine ⟨?_,hhi'.trans hpow⟩ + have hpos : (0:ℝ) < (SourceContactProgram.size d:ℝ)^A := by positivity + have hinv : ((CalibrationMesh.base (SourceContactProgram.size d):ℝ)^A)⁻¹ ≤ + ((SourceContactProgram.size d:ℝ)^A)⁻¹ := by + simpa only [one_div] using one_div_le_one_div_of_le hpos hpow + exact hinv.trans hlo' + +end ContinuumCoulomb.PrefactorSourceContactProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSpacing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSpacing.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5ea25dd390c1036a516d5eb89996be53595d249 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/PrefactorSpacing.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationMesh + +namespace OAI + +/-! A nominal test at unit weight bounds the shared rational spacing even +when the particular source has no edges. No approximation certificate for +logarithm evaluation needs to be added to the construction interface. -/ + +noncomputable section +namespace ContinuumCoulomb.PrefactorCalibration + +theorem spacing_bounds (rho : ℕ) (a : ℚ) (C : ℕ) {ε c : ℚ} + (hε : 0 ≤ ε) (hεsmall : ε ≤ 1/1000) (hc : 0 < c) + (k A B N P : ℕ) (hN : 2 ≤ N) + (hlen : + (1-(ε:ℝ))*((k:ℝ)*Real.log (CalibrationMesh.base N)) ≤ + value rho a C ε c k A B (CalibrationMesh.base N,(P,1)) ∧ + (value rho a C ε c k A B (CalibrationMesh.base N,(P,1)):ℝ) ≤ + (1+(ε:ℝ))*((k:ℝ)*Real.log (CalibrationMesh.base N))) : + (59/2:ℝ)*(k:ℝ)*Real.log N ≤ AutomaticCalibration.spacing c k (CalibrationMesh.base N) ∧ + (AutomaticCalibration.spacing c k (CalibrationMesh.base N):ℝ) ≤ 31*(k:ℝ)*Real.log N := by + let Q := AutomaticCalibration.spacing c k (CalibrationMesh.base N) + let x : AutomaticCalibration.Input := (CalibrationMesh.base N,(P,1)) + let t := (normalizedValue rho a C ε c k A B x:ℝ) + let r := (value rho a C ε c k A B x:ℝ) + have hbase : 0 < CalibrationMesh.base N := lt_of_lt_of_le (by decide : 0 < 2) + (CalibrationMesh.base_ge_two hN) + have hQ : (0:ℝ) < Q := by exact_mod_cast AutomaticCalibration.spacing_positive hc k _ hbase + have he : (Q:ℝ)*t=r := by + dsimp only [t,r,normalizedValue,x,Q] + push_cast + field_simp [show (AutomaticCalibration.spacing c k (CalibrationMesh.base N):ℝ) ≠ 0 from hQ.ne'] + obtain ⟨htl,htu⟩ := normalizedValue_mem rho a C hε hc k A B x hbase + have hεR : (0:ℝ) ≤ ε := by exact_mod_cast hε + have hεRsmall : (ε:ℝ) ≤ 1/1000 := by + have hh := (Rat.cast_le (K := ℝ)).mpr hεsmall + simpa only [Rat.cast_div,Rat.cast_one,Rat.cast_ofNat] using hh + have htlR : (1:ℝ)-(ε:ℝ)/2 ≤ t := by + have hh := (Rat.cast_le (K := ℝ)).mpr htl + simpa only [Rat.cast_sub,Rat.cast_one,Rat.cast_div,Rat.cast_ofNat,t] using hh + have htuR : t ≤ (1:ℝ)+(ε:ℝ)/2 := by + have hh := (Rat.cast_le (K := ℝ)).mpr htu + simpa only [Rat.cast_add,Rat.cast_one,Rat.cast_div,Rat.cast_ofNat,t] using hh + have ht0 : (999/1000:ℝ) ≤ t := by linarith + have ht1 : t ≤ (1001/1000:ℝ) := by linarith + have hmul0 := mul_le_mul_of_nonneg_left ht0 hQ.le + have hmul1 := mul_le_mul_of_nonneg_left ht1 hQ.le + rw [he] at hmul0 hmul1 + have hlog : Real.log (CalibrationMesh.base N:ℝ)=30*Real.log N := by + simp only [CalibrationMesh.base,Nat.cast_pow,Real.log_pow] + norm_num + have hx : 0 ≤ (k:ℝ)*Real.log N := mul_nonneg (Nat.cast_nonneg _) + (Real.log_nonneg (by exact_mod_cast (show 1 ≤ N by omega))) + change (1-(ε:ℝ))*((k:ℝ)*Real.log (CalibrationMesh.base N)) ≤ r ∧ + r ≤ (1+(ε:ℝ))*((k:ℝ)*Real.log (CalibrationMesh.base N)) at hlen + rw [hlog] at hlen + have hl := mul_le_mul_of_nonneg_right hεRsmall hx + constructor <;> nlinarith [hlen.1,hlen.2] + +end ContinuumCoulomb.PrefactorCalibration + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalBoxRound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalBoxRound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d8a6f5a72413926c211b452c4131bf88f45e4f1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalBoxRound.lean @@ -0,0 +1,121 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserVelocityNumerics +import OAI.Computability.QuantumFactoring.BitStackRationalFloor + +namespace OAI + +/-! Bounded integer numerator registers for rounded Euler iteration. +Clipping to a fixed box prevents malformed evaluator outputs from causing +unbounded register growth. On valid trajectories clipping never increases +the distance to the exact coordinate. -/ + +namespace ContinuumCoulomb.RationalBoxRound +open ExactQuantumFactoring.BitStackProgram + +def clip (B : ℕ) (z : ℤ) : ℤ := max (-(B:ℤ)) (min (B:ℤ) z) + +theorem clip_bounds (B : ℕ) (z : ℤ) : -(B:ℤ) ≤ clip B z ∧ clip B z ≤ B := by + constructor + · exact le_max_left _ _ + · exact max_le (by omega) (min_le_left _ _) + +theorem clip_natAbs (B : ℕ) (z : ℤ) : (clip B z).natAbs ≤ B := by + have h := clip_bounds B z + have ha : ((clip B z).natAbs:ℤ) ≤ (B:ℤ) := by + simpa only [Int.natCast_natAbs] using (abs_le.mpr h : |clip B z| ≤ (B:ℤ)) + exact_mod_cast ha + +def numerator (D B : ℕ) (q : ℚ) : ℤ := clip B ⌊(D:ℚ)*q⌋ +def value (D B : ℕ) (q : ℚ) : ℚ := (numerator D B q:ℚ)/(D:ℚ) + +theorem numerator_bits (D B : ℕ) (q : ℚ) : + (numerator D B q).natAbs.bits.length ≤ B.bits.length := + bits_length_mono (clip_natAbs _ _) + +theorem clip_real_error {B x q : ℝ} (hB : 0 ≤ B) (hx : |x| ≤ B) : + |max (-B) (min B q)-x| ≤ |q-x| := by + by_cases hlo : q ≤ -B + · rw [min_eq_right (by linarith),max_eq_left hlo] + have hxl := (abs_le.mp hx).1 + rw [abs_of_nonpos (by linarith),abs_of_nonpos (by linarith)] + linarith + · by_cases hhi : B ≤ q + · rw [min_eq_left hhi,max_eq_right (by linarith)] + have hxu := (abs_le.mp hx).2 + rw [abs_of_nonneg (by linarith),abs_of_nonneg (by linarith)] + linarith + · rw [min_eq_right (le_of_not_ge hhi),max_eq_right (le_of_not_ge hlo)] + +theorem value_error {D B : ℕ} (hD : 0 < D) (q : ℚ) (x : ℝ) + (hx : |x| ≤ (B:ℝ)/(D:ℝ)) : + |(value D B q:ℝ)-x| ≤ |(q:ℝ)-x|+1/(D:ℝ) := by + have hDp : (0:ℝ) < D := by exact_mod_cast hD + have hfloor : |(⌊(D:ℚ)*q⌋:ℝ)-(D:ℝ)*(q:ℝ)| ≤ 1 := by + have hl := Int.floor_le ((D:ℚ)*q) + have hu := Int.lt_floor_add_one ((D:ℚ)*q) + have hlR : (⌊(D:ℚ)*q⌋:ℝ) ≤ (D:ℝ)*(q:ℝ) := by exact_mod_cast hl + have huR : (D:ℝ)*(q:ℝ) < (⌊(D:ℚ)*q⌋:ℝ)+1 := by exact_mod_cast hu + exact abs_le.mpr ⟨by linarith,by linarith⟩ + have htarget : |(D:ℝ)*x| ≤ B := by + rw [abs_mul,abs_of_pos hDp] + exact (mul_le_mul_of_nonneg_left hx hDp.le).trans_eq (by field_simp) + have hc := clip_real_error (show (0:ℝ) ≤ B by positivity) htarget + (q := (⌊(D:ℚ)*q⌋:ℝ)) + have hcast : (numerator D B q:ℝ) = + max (-(B:ℝ)) (min (B:ℝ) (⌊(D:ℚ)*q⌋:ℝ)) := by + simp only [numerator,clip,Int.cast_max,Int.cast_min,Int.cast_neg,Int.cast_natCast] + rw [← hcast] at hc + have ht := abs_sub_le (⌊(D:ℚ)*q⌋:ℝ) ((D:ℝ)*(q:ℝ)) ((D:ℝ)*x) + have hscale : |(D:ℝ)*(q:ℝ)-(D:ℝ)*x| = (D:ℝ)*|(q:ℝ)-x| := by + rw [← mul_sub,abs_mul,abs_of_pos hDp] + rw [hscale] at ht + have heq : (value D B q:ℝ)-x = ((numerator D B q:ℝ)-(D:ℝ)*x)/(D:ℝ) := by + simp only [value,Rat.cast_div,Rat.cast_intCast,Rat.cast_natCast] + field_simp + rw [heq,abs_div,abs_of_pos hDp] + apply (div_le_iff₀ hDp).mpr + have hs : (|(q:ℝ)-x|+1/(D:ℝ))*(D:ℝ) = (D:ℝ)*|(q:ℝ)-x|+1 := by field_simp + rw [hs] + linarith + +abbrev Input := (ℕ×ℕ)×ℚ +def inputCode : Input → List Bool := prodCode (prodCode Nat.bits Nat.bits) ratCode + +noncomputable opaque clipProgram : Procedure (prodCode Nat.bits intCode) intCode + (fun x => clip x.1 x.2) := by + let B := Procedure.natToInt.comp (Procedure.first Nat.bits intCode) + let z := Procedure.second Nat.bits intCode + let low := Procedure.intNeg.comp B + let tooLow := Procedure.intSign.comp (Procedure.intSub.comp (z.pair low)) + let tooHigh := Procedure.intSign.comp (Procedure.intSub.comp (B.pair z)) + exact (Procedure.conditional tooLow low (Procedure.conditional tooHigh B z)).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq] + unfold clip + split_ifs with hlo hhi + · rw [min_eq_right (by linarith),max_eq_left (by linarith)] + · rw [min_eq_left (by linarith),max_eq_right (by omega)] + · rw [min_eq_right (by linarith),max_eq_right (by linarith)]) + +noncomputable opaque numeratorProgram : Procedure inputCode intCode + (fun x => numerator x.1.1 x.1.2 x.2) := by + let db := Procedure.first (prodCode Nat.bits Nat.bits) ratCode + let d := (Procedure.first Nat.bits Nat.bits).comp db + let b := (Procedure.second Nat.bits Nat.bits).comp db + let q := Procedure.second (prodCode Nat.bits Nat.bits) ratCode + let scaled := Procedure.ratMul.comp ((Procedure.natToRat.comp d).pair q) + exact (clipProgram.comp (b.pair (Procedure.ratFloor.comp scaled))).congrFun (by intro x; rfl) + +noncomputable opaque program : Procedure inputCode ratCode + (fun x => value x.1.1 x.1.2 x.2) := by + let db := Procedure.first (prodCode Nat.bits Nat.bits) ratCode + let d := (Procedure.first Nat.bits Nat.bits).comp db + exact (Procedure.ratDiv.comp ((Procedure.intToRat.comp numeratorProgram).pair + (Procedure.natToRat.comp d))).congrFun (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode intCode + (fun x => numerator x.1.1 x.1.2 x.2) := numeratorProgram.toTM2 + +end ContinuumCoulomb.RationalBoxRound + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalClamp.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalClamp.lean new file mode 100644 index 0000000000000000000000000000000000000000..82c3183a0bccc0e13bad6299aaf3f6e71c9dec10 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalClamp.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram + +namespace OAI + +/-! A literal rational clamp preserves approximation error to values in +[0,1]. It keeps numerical density samples nonnegative and bounded. -/ + +namespace ContinuumCoulomb +open ExactQuantumFactoring.BitStackProgram + +def rationalUnitClamp (q : ℚ) : ℚ := max 0 (min 1 q) + +theorem rationalUnitClamp_nonnegative (q : ℚ) : 0 ≤ rationalUnitClamp q := + le_max_left _ _ + +theorem rationalUnitClamp_le_one (q : ℚ) : rationalUnitClamp q ≤ 1 := + max_le (by norm_num) (min_le_left _ _) + +theorem rationalUnitClamp_error (q : ℚ) {r : ℝ} (hr0 : 0 ≤ r) (hr1 : r ≤ 1) : + |(rationalUnitClamp q : ℝ) - r| ≤ |(q : ℝ) - r| := by + by_cases hq0 : q < 0 + · have hq : (q : ℝ) < 0 := by exact_mod_cast hq0 + have he : rationalUnitClamp q = 0 := by + unfold rationalUnitClamp + rw [min_eq_right (by linarith), max_eq_left hq0.le] + rw [he, Rat.cast_zero, zero_sub, abs_neg, abs_of_nonneg hr0, + abs_of_nonpos (by linarith : (q : ℝ) - r ≤ 0)] + linarith + · by_cases hq1 : 1 < q + · have hq : (1 : ℝ) < q := by exact_mod_cast hq1 + have he : rationalUnitClamp q = 1 := by + unfold rationalUnitClamp + rw [min_eq_left hq1.le, max_eq_right (by norm_num)] + rw [he, Rat.cast_one, abs_of_nonneg (by linarith : 0 ≤ 1 - r), + abs_of_nonneg (by linarith : 0 ≤ (q : ℝ) - r)] + linarith + · have he : rationalUnitClamp q = q := by + unfold rationalUnitClamp + rw [min_eq_right (le_of_not_gt hq1), max_eq_right (le_of_not_gt hq0)] + rw [he] + +noncomputable opaque rationalUnitClampProgram : Procedure ratCode ratCode rationalUnitClamp := by + let q := Procedure.identity ratCode + let zero := Procedure.constant ratCode ratCode (0 : ℚ) + let one := Procedure.constant ratCode ratCode (1 : ℚ) + let below := BisectionProgram.rationalLess.comp (q.pair zero) + let above := BisectionProgram.rationalLess.comp (one.pair q) + exact (Procedure.conditional below zero (Procedure.conditional above one q)).congrFun (by + intro q + simp only [Function.comp_apply, id_eq, decide_eq_true_eq] + split_ifs with h0 h1 + · simp [rationalUnitClamp, min_eq_right (by linarith : q ≤ 1), max_eq_left h0.le] + · simp [rationalUnitClamp, min_eq_left h1.le] + · simp [rationalUnitClamp, min_eq_right (le_of_not_gt h1), max_eq_right (le_of_not_gt h0)]) + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a29edc0f7ff62a2dfc7ae94384d89f6eba1501b7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactBudget.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalContactMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceHoppingBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.HubbardTolerance + +namespace OAI + +/-! Polynomial precision suffices for the entire rational contact hopping +matrix. Both the coordinate error and the nonedge tail are paid explicitly. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactCalibratedGeometry +open ContactMediator MediatorIteration + +theorem exists_full_matrix_offsets {a freq : ℝ} (ha : 0 < a) (hfreq : 0 < freq) : + ∃ qN qC : ℕ, 1 ≤ qN ∧ 1 ≤ qC ∧ + ∀ (N k A S p pc h : ℕ), 2 ≤ N → + qN+S+p+1 ≤ 5*k → qC+30*k+A+S+p+2 ≤ h → p+2 ≤ pc → + ∀ (d : SquareLatticeHeisenberg) (W G m : ℕ) (σ : GlobalSite d ≃ Fin (m+1)) + (q : ℚ), 0 < q → (q:ℝ) ≤ (N:ℝ)^S → + ∀ (ℓ : GlobalEdge d → ℚ), 7200 ≤ N^h → + (∀ e, (ℓ e:ℝ) ∈ Set.Icc (1-contactLengthTolerance) (1+contactLengthTolerance)) → + ∀ (D Dfar τ : ℝ), 5 ≤ D → 2 ≤ Dfar → + 35*(k:ℝ)*Real.log N ≤ Dfar → D ≤ (9/10:ℝ)*q → Dfar ≤ (6/5:ℝ)*q → + 2*localLeakageBound freq D ≤ localDualMass freq/2 → 0 ≤ τ → τ ≤ 1 → + ∀ K : GlobalEdge d → ℝ, (∀ e, 0 ≤ K e) → (∀ e, K e ≤ (N:ℝ)^A) → + (∀ x y, ‖point d (N^h) q ℓ x-point d (N^h) q ℓ y‖ ≤ 2*(N:ℝ)^S) → + (∀ e, |(a*((N:ℝ)^k)^30)*planarHopping ((q:ℝ)*ℓ e)- + coulombHoppingTarget freq τ (K e) ((q:ℝ)*ℓ e)| ≤ 1/((N:ℝ)^pc+1)) → + ∀ i j : Fin (m+1), + let F := finalGraph d.bonds W G + let u := fun x => point d (N^h) q ℓ (σ.symm x) + ‖(((a*((N:ℝ)^k)^30)*planarHoppingMatrix u i j:ℝ):ℂ)- + HubbardGlobal.graphHoppingMatrix m (fun e => σ (F.left e)) (fun e => σ (F.right e)) + (fun e => (-(coulombHoppingTarget freq τ (K e) + ‖u (σ (F.left e))-u (σ (F.right e))‖):ℝ)) i j‖ ≤ ((N:ℝ)^p)⁻¹ := by + obtain ⟨qN,hqN,hnonedge⟩ := exists_nonedge_hopping_offset ha + obtain ⟨qC,hqC,hcoordinate⟩ := exists_contact_coordinate_offset ha freq + refine ⟨qN,qC,hqN,hqC,?_⟩ + intro N k A S p pc h hN hk hh hpc d W G m σ q hq hqS ℓ hP hℓ + D Dfar τ hD hDfar hfar hDq hfarq hleak hτ hτ1 K hK hKA hdiam hres i j + have hNR : (2:ℝ) ≤ N := by exact_mod_cast hN + have hqR : (0:ℝ) ≤ q := by exact_mod_cast hq.le + have hscale : 0 ≤ a*((N:ℝ)^k)^30 := mul_nonneg ha.le (pow_nonneg (pow_nonneg (Nat.cast_nonneg _) _) _) + have hbudget (e : GlobalEdge d) := hcoordinate k A S (p+1) h pc (by omega) (by omega) + N τ (K e) q hNR hτ hτ1 (hK e) (hKA e) hqR hqS + have hbudget' (e : GlobalEdge d) : 1/((N:ℝ)^pc+1)+ + ((a*((N:ℝ)^k)^30)*(planarHoppingLipschitzConstant:ℝ)+ + coulombTargetLipschitzConstant freq τ (K e))* + ((q:ℝ)*(72*(((N^h:ℕ):ℝ)+1)⁻¹)) ≤ ((N:ℝ)^(p+1))⁻¹ := by + simpa only [Nat.cast_pow] using hbudget e + have hm := full_matrix_error d W G (N^h) m σ hq ℓ hP hℓ hfreq hD hDfar hleak + hDq hfarq hscale hτ (inv_nonneg.mpr (pow_nonneg (Nat.cast_nonneg _) _)) K hK + hdiam hres hbudget' i j + have hn := hnonedge S (p+1) k (by omega) N Dfar hNR hfar + exact hm.trans ((add_le_add hn le_rfl).trans (by + simpa only [two_mul] using double_inverse_power_le hNR p)) + +end ContinuumCoulomb.ContactCalibratedGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..8854a2db7bc89f0804c59f9a303c11d3707f4bb0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalContactMatrix.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedMatrixError +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorSimple + +namespace OAI + +/-! The rational contact coordinates control the complete physical hopping +matrix in the electron index order, including every nonedge entry. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactCalibratedGeometry +open ContactMediator MediatorIteration + +theorem full_matrix_error (d : SquareLatticeHeisenberg) (W G P m : ℕ) + (σ : GlobalSite d ≃ Fin (m+1)) {q : ℚ} (hq : 0 < q) + (ℓ : GlobalEdge d → ℚ) (hP : 7200 ≤ P) + (hℓ : ∀ a, (ℓ a : ℝ) ∈ Set.Icc (1-contactLengthTolerance) (1+contactLengthTolerance)) + {freq D Dfar scale τ L ε₀ ε : ℝ} + (hfreq : 0 < freq) (hD : 5 ≤ D) (hDfar : 2 ≤ Dfar) + (hleak : 2*localLeakageBound freq D ≤ localDualMass freq/2) + (hDq : D ≤ (9/10:ℝ)*q) (hfarq : Dfar ≤ (6/5:ℝ)*q) + (hscale : 0 ≤ scale) (hτ : 0 ≤ τ) (hε : 0 ≤ ε) + (K : GlobalEdge d → ℝ) (hK : ∀ a, 0 ≤ K a) + (hL : ∀ x y, ‖point d P q ℓ x-point d P q ℓ y‖ ≤ L) + (hres : ∀ a, |scale*planarHopping ((q:ℝ)*ℓ a)- + coulombHoppingTarget freq τ (K a) ((q:ℝ)*ℓ a)| ≤ ε₀) + (hbudget : ∀ a, ε₀+(scale*(planarHoppingLipschitzConstant:ℝ)+ + coulombTargetLipschitzConstant freq τ (K a))*((q:ℝ)*(72*((P:ℝ)+1)⁻¹)) ≤ ε) + (i j : Fin (m+1)) : + let F := finalGraph d.bonds W G + let u := fun x => point d P q ℓ (σ.symm x) + ‖((scale*planarHoppingMatrix u i j:ℝ):ℂ)- + HubbardGlobal.graphHoppingMatrix m (fun a => σ (F.left a)) (fun a => σ (F.right a)) + (fun a => (-(coulombHoppingTarget freq τ (K a) + ‖u (σ (F.left a))-u (σ (F.right a))‖):ℝ)) i j‖ ≤ + scale*planarHoppingUpperConstant*(L+1)*Real.exp (-Dfar)+ε := by + intro F u + have hloop (a : GlobalEdge d) : σ (F.left a) ≠ σ (F.right a) := + fun he => finalGraph_noLoops d.bonds W G a (σ.injective he) + have hsimple : ∀ a b : GlobalEdge d, a ≠ b → + ¬(σ (F.left a)=σ (F.left b) ∧ σ (F.right a)=σ (F.right b)) ∧ + ¬(σ (F.left a)=σ (F.right b) ∧ σ (F.right a)=σ (F.left b)) := by + intro a b hab + have hs := (finalGraph_simple d.bonds W G).hypothesis a b hab + exact ⟨fun h => hs.1 ⟨σ.injective h.1,σ.injective h.2⟩, + fun h => hs.2 ⟨σ.injective h.1,σ.injective h.2⟩⟩ + apply HubbardGlobal.planarHoppingMatrix_calibrated_error m + (fun a => σ (F.left a)) (fun a => σ (F.right a)) u hloop hsimple hscale hDfar hε + (fun x y => hL _ _) ?_ _ ?_ i j + · intro x y hxy hn + have hraw : σ.symm x ≠ σ.symm y := fun h => hxy (σ.symm.injective h) + have hnon : Nonedge d W G (σ.symm x) (σ.symm y) := by + rintro ⟨a,ha⟩ + rcases ha with ⟨hax,hay⟩ | ⟨hay,hax⟩ + · exact (hn a).1 ⟨(σ.apply_symm_apply x).symm.trans (congrArg σ hax).symm, + (σ.apply_symm_apply y).symm.trans (congrArg σ hay).symm⟩ + · exact (hn a).2 ⟨(σ.apply_symm_apply x).symm.trans (congrArg σ hax).symm, + (σ.apply_symm_apply y).symm.trans (congrArg σ hay).symm⟩ + exact hfarq.trans (by simpa only [u,dist_eq_norm] using + (nonedge_separation d W G P hq ℓ hP hℓ _ _ hraw hnon).le) + · intro a + have hr := calibrated_edge_residual d W G P hq ℓ hP hℓ hfreq hD hleak hDq + hscale hτ K hK hres a (finalGraph_noLoops d.bonds W G a) + simpa only [u,Equiv.symm_apply_apply,dist_eq_norm] using hr.trans (hbudget a) + +end ContinuumCoulomb.ContactCalibratedGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalExponential.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalExponential.lean new file mode 100644 index 0000000000000000000000000000000000000000..c28e4f90d2b83ab8601c741f4f186bfd8ba0477c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalExponential.lean @@ -0,0 +1,77 @@ +import Mathlib.Analysis.Complex.Exponential +import Mathlib.Tactic + +namespace OAI + +/-! A rational Taylor approximation with an explicit magnitude and binary +precision parameter. This applies to the negative rational exponents in +the Gaussian heat kernel as well as to positive arguments. -/ + +open scoped BigOperators +namespace ContinuumCoulomb.RationalExponential + +def order (M p : ℕ) : ℕ := 2 * (2 * M ^ 2 + p + 2) + +def taylorSum (q : ℚ) (n : ℕ) : ℚ := + ∑ j ∈ Finset.range n, q ^ j / (j.factorial : ℚ) + +def approximate (M p : ℕ) (q : ℚ) : ℚ := taylorSum q (order M p) + +private theorem factorial_bound (M p : ℕ) : + 2 ^ (p + 2) * M ^ order M p ≤ (order M p).factorial := by + let N := 2 * M ^ 2 + p + 2 + have hprec : 2 ^ (p + 2) ≤ 2 ^ N := + Nat.pow_le_pow_right (by decide) (by dsimp [N]; omega) + have hpow : 2 ^ N * M ^ (2 * N) ≤ N ^ N := by + rw [pow_mul, ← mul_pow] + apply Nat.pow_le_pow_left + dsimp [N] + omega + have hfac : N ^ N ≤ (2 * N).factorial := by + have h1 : N ^ N ≤ (N + 1) ^ N := Nat.pow_le_pow_left (Nat.le_succ N) N + have h2 : (N + 1) ^ N ≤ N.factorial * (N + 1) ^ N := by + simpa only [one_mul] using Nat.mul_le_mul_right ((N + 1) ^ N) + (show 1 ≤ N.factorial from Nat.factorial_pos N) + have h3 := @Nat.factorial_mul_pow_le_factorial N N + rw [show N + N = 2 * N by omega] at h3 + exact h1.trans (h2.trans h3) + exact (Nat.mul_le_mul_right (M ^ (2 * N)) hprec).trans (hpow.trans hfac) + +theorem error (M p : ℕ) (q : ℚ) (hq : |(q : ℝ)| ≤ M) : + |Real.exp (q : ℝ) - (approximate M p q : ℝ)| ≤ (2 ^ p : ℝ)⁻¹ := by + let n := order M p + have hpnonneg : 0 ≤ (p : ℝ) := by positivity + have hx : ‖((q : ℝ) : ℂ)‖ / (n + 1 : ℕ) ≤ (1 / 2 : ℝ) := by + rw [Complex.norm_real, Real.norm_eq_abs] + apply (div_le_iff₀ (by positivity : (0 : ℝ) < (n + 1 : ℕ))).mpr + dsimp [n, order] + push_cast + nlinarith [sq_nonneg ((M : ℝ) - 1 / 4)] + have hc := Complex.exp_bound' (x := ((q : ℝ) : ℂ)) (n := n) hx + have hr : |Real.exp (q : ℝ) - (approximate M p q : ℝ)| ≤ + |(q : ℝ)| ^ n / (n.factorial : ℝ) * 2 := by + simpa only [Complex.norm_real, Real.norm_eq_abs, ← Complex.ofReal_exp, + ← Complex.ofReal_pow, ← Complex.ofReal_natCast, ← Complex.ofReal_div, + ← Complex.ofReal_sum, ← Complex.ofReal_sub, approximate, taylorSum, + Rat.cast_sum, Rat.cast_div, Rat.cast_pow, Rat.cast_natCast, n] using hc + have hpow : |(q : ℝ)| ^ n ≤ (M : ℝ) ^ n := pow_le_pow_left₀ (abs_nonneg _) hq n + have hfac : (2 ^ (p + 2) : ℝ) * (M : ℝ) ^ n ≤ (n.factorial : ℝ) := by + exact_mod_cast factorial_bound M p + have hratio : (M : ℝ) ^ n / (n.factorial : ℝ) ≤ (2 ^ (p + 2) : ℝ)⁻¹ := by + apply (div_le_iff₀ (by positivity : (0 : ℝ) < n.factorial)).mpr + have hm : (M : ℝ) ^ n * 2 ^ (p + 2) ≤ (n.factorial : ℝ) := by + simpa only [mul_comm] using hfac + have hr' : (M : ℝ) ^ n ≤ (n.factorial : ℝ) / 2 ^ (p + 2) := + (le_div_iff₀ (by positivity : (0 : ℝ) < 2 ^ (p + 2))).mpr hm + simpa only [div_eq_mul_inv, mul_comm] using hr' + have hprec : (2 ^ (p + 2) : ℝ)⁻¹ * 2 ≤ (2 ^ p : ℝ)⁻¹ := by + rw [pow_add] + norm_num + have hp : 0 ≤ (2 ^ p : ℝ)⁻¹ := by positivity + nlinarith + exact hr.trans ((mul_le_mul_of_nonneg_right + ((div_le_div_of_nonneg_right hpow (by positivity)).trans hratio) (by norm_num)).trans hprec) + +end ContinuumCoulomb.RationalExponential + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalFieldDifferences.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalFieldDifferences.lean new file mode 100644 index 0000000000000000000000000000000000000000..8718d62c58c2b17557d446672f12db4c495e86c2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalFieldDifferences.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserCoordinateDifferences +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CappedKernelProgram + +namespace OAI + +/-! Coordinate differences of a rational scalar sampler approximate the +actual gradient and Laplacian. The real extension below is only a proof +device; the numerical expressions evaluate the sampler at rational points. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb.RationalFieldDifferences +open CappedKernelProgram (Triple position) +open NeutralAtom (axis dirPartial coordinateLaplacian) + +theorem position_injective : Function.Injective position := by + rintro ⟨a,ay,az⟩ ⟨b,byCoord,bz⟩ h + have h0 := congrArg (fun x : Position => x 0) h + have h1 := congrArg (fun x : Position => x 1) h + have h2 := congrArg (fun x : Position => x 2) h + change (a:ℝ) = (b:ℝ) at h0 + change (ay:ℝ) = (byCoord:ℝ) at h1 + change (az:ℝ) = (bz:ℝ) at h2 + have h0' : a=b := by exact_mod_cast h0 + have h1' : ay=byCoord := by exact_mod_cast h1 + have h2' : az=bz := by exact_mod_cast h2 + simp only [h0',h1',h2'] + +def extend (V : Position → ℝ) (sample : Triple → ℚ) (x : Position) : ℝ := by + classical + exact if h : ∃ q, position q=x then (sample (Classical.choose h):ℝ) else V x + +theorem extend_at (V : Position → ℝ) (sample : Triple → ℚ) (q : Triple) : + extend V sample (position q) = (sample q:ℝ) := by + rw [extend,dite_eq_left (show ∃ r, position r=position q from ⟨q,rfl⟩)] + congr 1 + exact congrArg sample (position_injective + (Classical.choose_spec (show ∃ r, position r=position q from ⟨q,rfl⟩))) + +theorem extend_error (V : Position → ℝ) (sample : Triple → ℚ) {ε : ℝ} + (hε : 0 ≤ ε) (he : ∀ q, |(sample q:ℝ)-V (position q)| ≤ ε) (x : Position) : + |extend V sample x-V x| ≤ ε := by + unfold extend + split_ifs with h + · have hs := he (Classical.choose h) + simpa only [Classical.choose_spec h] using hs + · simpa only [sub_self,abs_zero] using hε + +def shift (q : Triple) (h : ℚ) (a : Fin 3) : Triple := + (q.1+(if a=0 then h else 0), + (q.2.1+(if a=1 then h else 0),q.2.2+(if a=2 then h else 0))) + +theorem shift_position (q : Triple) (h : ℚ) (a : Fin 3) : + position (shift q h a) = position q+(h:ℝ) • axis a := by + ext b + fin_cases a <;> fin_cases b <;> simp [position,shift,axis] + +def first (sample : Triple → ℚ) (h : ℚ) (q : Triple) (a : Fin 3) : ℚ := + (sample (shift q h a)-sample q)/h + +def second (sample : Triple → ℚ) (h : ℚ) (q : Triple) (a : Fin 3) : ℚ := + (sample (shift q h a)+sample (shift q (-h) a)-2*sample q)/h^2 + +def laplacian (sample : Triple → ℚ) (h : ℚ) (q : Triple) : ℚ := ∑ a, second sample h q a + +theorem first_error (V : Position → ℝ) (hV : ContDiff ℝ 6 V) (sample : Triple → ℚ) + {B ε : ℝ} (hB : 0 ≤ B) (hε : 0 ≤ ε) {h : ℚ} (hh : 0 < h) + (hb : ∀ k ≤ 6, ∀ x, ‖iteratedFDeriv ℝ k V x‖ ≤ B) + (he : ∀ q, |(sample q:ℝ)-V (position q)| ≤ ε) (q : Triple) (a : Fin 3) : + |(first sample h q a:ℝ)-dirPartial V (axis a) (position q)| ≤ B*(h:ℝ)+2*ε/(h:ℝ) := by + have hhR : (0:ℝ) < h := by exact_mod_cast hh + have hd := MoserCoordinateDifferences.first_error V (extend V sample) hV hB hε hhR hb + (extend_error V sample hε he) (position q) a + rw [← shift_position,extend_at,extend_at] at hd + simpa only [first,Rat.cast_div,Rat.cast_sub] using hd + +theorem second_error (V : Position → ℝ) (hV : ContDiff ℝ 6 V) (sample : Triple → ℚ) + {B ε : ℝ} (hB : 0 ≤ B) (hε : 0 ≤ ε) {h : ℚ} (hh : 0 < h) + (hb : ∀ k ≤ 6, ∀ x, ‖iteratedFDeriv ℝ k V x‖ ≤ B) + (he : ∀ q, |(sample q:ℝ)-V (position q)| ≤ ε) (q : Triple) (a : Fin 3) : + |(second sample h q a:ℝ)-dirPartial (dirPartial V (axis a)) (axis a) (position q)| ≤ + B*(h:ℝ)+4*ε/(h:ℝ)^2 := by + have hhR : (0:ℝ) < h := by exact_mod_cast hh + have hd := MoserCoordinateDifferences.second_error V (extend V sample) hV hB hhR hb + (extend_error V sample hε he) (position q) a + have hm : position q-(h:ℝ) • axis a = position (shift q (-h) a) := by + rw [shift_position,Rat.cast_neg,neg_smul,sub_eq_add_neg] + rw [← shift_position,hm,extend_at,extend_at,extend_at] at hd + simpa only [second,Rat.cast_div,Rat.cast_add,Rat.cast_mul,Rat.cast_pow,Rat.cast_sub,Rat.cast_ofNat] using hd + +theorem laplacian_error (V : Position → ℝ) (hV : ContDiff ℝ 6 V) (sample : Triple → ℚ) + {B ε : ℝ} (hB : 0 ≤ B) (hε : 0 ≤ ε) {h : ℚ} (hh : 0 < h) + (hb : ∀ k ≤ 6, ∀ x, ‖iteratedFDeriv ℝ k V x‖ ≤ B) + (he : ∀ q, |(sample q:ℝ)-V (position q)| ≤ ε) (q : Triple) : + |(laplacian sample h q:ℝ)-coordinateLaplacian V (position q)| ≤ + 3*(B*(h:ℝ)+4*ε/(h:ℝ)^2) := by + rw [laplacian,Rat.cast_sum,NeutralAtom.coordinateLaplacian_eq_partials + ((hV.of_le (by norm_num : (2:WithTop ℕ∞) ≤ 6)).contDiffAt),← Finset.sum_sub_distrib] + apply (Finset.abs_sum_le_sum_abs _ _).trans + calc + _ ≤ ∑ _a : Fin 3, (B*(h:ℝ)+4*ε/(h:ℝ)^2) := + Finset.sum_le_sum (fun a _ => second_error V hV sample hB hε hh hb he q a) + _ = _ := by simp; ring + +end ContinuumCoulomb.RationalFieldDifferences + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalGaussNodes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalGaussNodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb50c5e32f89307a87f48d312be306dd96c6ef96 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalGaussNodes.lean @@ -0,0 +1,105 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerGeometry +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ResolventNumericalBounds + +namespace OAI + +/-! Rational initial nodes for the tensor Gauss rule on mesh `1/N`. +The only irrational constant is evaluated by the existing dyadic square-root +program; the error bound is uniform over the entire integer lattice. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb.RationalGaussNodes +open CappedKernelProgram (Triple position) +open EulerRegisters (Registers) + +abbrev Signs := Bool×(Bool×Bool) + +def abscissa (P : ℕ) : ℚ := RationalSquareRoot.value (2*(P+1),(1/3:ℚ)) +def signed (P : ℕ) (b : Bool) : ℚ := if b then abscissa P else -abscissa P +def index (k : Registers) (b : Signs) : GaussLatticeIndex := + (![k.1,k.2.1,k.2.2],![if b.1 then 1 else 0,if b.2.1 then 1 else 0,if b.2.2 then 1 else 0]) +def value (P N : ℕ) (k : Registers) (b : Signs) : Triple := + (((k.1:ℚ)+signed P b.1/2)/N, + (((k.2.1:ℚ)+signed P b.2.1/2)/N,((k.2.2:ℚ)+signed P b.2.2/2)/N)) + +theorem abscissa_error (P : ℕ) : + |(abscissa P:ℝ)-gaussAbscissa| ≤ (2*((P:ℝ)+1))⁻¹ := by + have he := RationalSquareRoot.value_error (2*(P+1)) (q := (1/3:ℚ)) (by norm_num) + have hs : Real.sqrt ((1/3:ℚ):ℝ) = gaussAbscissa := by + norm_num [gaussAbscissa,Real.sqrt_inv] + rw [hs] at he + apply he.trans + have hn : 2*(P+1) ≤ 2^(2*(P+1)) := (ResolventSchedule.succ_le_two_pow _).trans' (by omega) + have hr : 2*((P:ℝ)+1) ≤ (2:ℝ)^(2*(P+1)) := by exact_mod_cast hn + rw [inv_pow] + exact inv_anti₀ (by positivity) hr + +theorem signed_error (P : ℕ) (b : Bool) : + |(signed P b:ℝ)-gaussNode (if b then 1 else 0)| ≤ (2*((P:ℝ)+1))⁻¹ := by + cases b + · change |((-abscissa P:ℚ):ℝ)-(-gaussAbscissa)| ≤ _ + rw [Rat.cast_neg,neg_sub_neg,abs_sub_comm] + exact abscissa_error P + · change |(abscissa P:ℝ)-gaussAbscissa| ≤ _ + exact abscissa_error P + +private theorem coordinate_error (P : ℕ) {N : ℕ} (hN : 0 < N) (k : ℤ) (b : Bool) : + |((((k:ℚ)+signed P b/2)/N:ℚ):ℝ)- + (N:ℝ)⁻¹*((k:ℝ)+gaussNode (if b then 1 else 0)/2)| ≤ + (1/(2*(N:ℝ)))*(2*((P:ℝ)+1))⁻¹ := by + have hn : (0:ℝ) < N := by exact_mod_cast hN + have hid : ((((k:ℚ)+signed P b/2)/N:ℚ):ℝ)- + (N:ℝ)⁻¹*((k:ℝ)+gaussNode (if b then 1 else 0)/2) = + (1/(2*(N:ℝ)))*((signed P b:ℝ)-gaussNode (if b then 1 else 0)) := by + push_cast + ring + rw [hid,abs_mul,abs_of_nonneg (by positivity : (0:ℝ) ≤ 1/(2*(N:ℝ)))] + exact mul_le_mul_of_nonneg_left (signed_error P b) (by positivity) + +theorem approximation_error (P : ℕ) {N : ℕ} (hN : 0 < N) (k : Registers) (b : Signs) : + ‖position (value P N k b)-gaussLatticePoint (N:ℝ)⁻¹ (index k b)‖ ≤ ((P:ℝ)+1)⁻¹ := by + let d : ℝ := (1/(2*(N:ℝ)))*(2*((P:ℝ)+1))⁻¹ + have hd : 0 ≤ d := by dsimp [d]; positivity + have hc (a : Fin 3) : + |(position (value P N k b)-gaussLatticePoint (N:ℝ)⁻¹ (index k b)) a| ≤ |(0:Position) a|+d := by + fin_cases a + · simpa [value,position,gaussLatticePoint,index,d] using coordinate_error P hN k.1 b.1 + · simpa [value,position,gaussLatticePoint,index,d] using coordinate_error P hN k.2.1 b.2.1 + · simpa [value,position,gaussLatticePoint,index,d] using coordinate_error P hN k.2.2 b.2.2 + have he := EulerRegisters.norm_of_coordinate_error hd hc + simp only [norm_zero,zero_add] at he + apply he.trans + have hn : (1:ℝ) ≤ N := by exact_mod_cast (Nat.succ_le_of_lt hN) + have hp : 0 < (P:ℝ)+1 := by positivity + have hNp : (0:ℝ) < N := by exact_mod_cast hN + have hid : 3*d = (3/(4*(N:ℝ)))/((P:ℝ)+1) := by + dsimp [d] + field_simp [hNp.ne',hp.ne'] + ring + rw [hid,← one_div] + apply div_le_div_of_nonneg_right _ hp.le + apply (div_le_one (by positivity : (0:ℝ) < 4*(N:ℝ))).mpr + nlinarith + +/-- The initial-node error and the rational ODE solver error add after +transport by the actual common Lipschitz map. -/ +theorem transported_error (G : Position → Position) {K : ℝ≥0} (hG : LipschitzWith K G) + (P : ℕ) {N : ℕ} (hN : 0 < N) (k : Registers) (b : Signs) + (out : Triple) {δ : ℝ} + (he : ‖position out-G (position (value P N k b))‖ ≤ δ) : + ‖position out-G (gaussLatticePoint (N:ℝ)⁻¹ (index k b))‖ ≤ + δ+(K:ℝ)*((P:ℝ)+1)⁻¹ := by + have ht := hG.dist_le_mul (position (value P N k b)) + (gaussLatticePoint (N:ℝ)⁻¹ (index k b)) + rw [dist_eq_norm,dist_eq_norm] at ht + have hh := ht.trans (mul_le_mul_of_nonneg_left (approximation_error P hN k b) K.coe_nonneg) + exact (norm_sub_le_norm_sub_add_norm_sub _ (G (position (value P N k b))) _).trans (add_le_add he hh) + +end ContinuumCoulomb.RationalGaussNodes + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatBox.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatBox.lean new file mode 100644 index 0000000000000000000000000000000000000000..38b4be79566b3a9920e1bf7f9f3aba30717af58d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatBox.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatSample + +namespace OAI + +/-! Three literal nested quadratures for the heat representation of the +planar resolvent. The two spatial integrals run over `[-1,1]`, which +contains the support of the forcing. All sample counts are unary. -/ + +namespace ContinuumCoulomb.RationalHeatBox +open ExactQuantumFactoring.BitStackProgram +open RationalHeatSample + +abbrev Settings := RationalHeatSample.Settings × (Point × ℕ) +abbrev PlaneEnvironment := Settings × ℚ +abbrev LineEnvironment := PlaneEnvironment × ℚ + +def settingsCode : Settings → List Bool := + prodCode RationalHeatSample.settingsCode (prodCode pointCode unaryCode) + +def planeCode : PlaneEnvironment → List Bool := prodCode settingsCode ratCode +def lineCode : LineEnvironment → List Bool := prodCode planeCode ratCode + +def sample (e : LineEnvironment) (y₂ : ℚ) : ℚ := + RationalHeatSample.value (e.1.1.1, e.1.2, e.1.1.2.1, e.2, y₂) + +def lineInput (e : PlaneEnvironment) (y₁ : ℚ) : RationalQuadratureProgram.Input LineEnvironment := + (e.1.2.2, (e, y₁), -1, 2 / (e.1.2.2 : ℚ)) + +def line (e : PlaneEnvironment) (y₁ : ℚ) : ℚ := + RationalQuadratureProgram.value sample (lineInput e y₁) + +def planeInput (e : Settings) (t : ℚ) : RationalQuadratureProgram.Input PlaneEnvironment := + (e.2.2, (e, t), -1, 2 / (e.2.2 : ℚ)) + +def plane (e : Settings) (t : ℚ) : ℚ := + RationalQuadratureProgram.value line (planeInput e t) + +abbrev Input := RationalQuadratureProgram.Input Settings + +def inputCode : Input → List Bool := RationalQuadratureProgram.inputCode settingsCode + +def value (x : Input) : ℚ := RationalQuadratureProgram.value plane x + +noncomputable def sampleProgram : + Procedure (prodCode lineCode ratCode) ratCode (fun x => sample x.1 x.2) := by + let lineEnv := Procedure.first lineCode ratCode + let y₂ := Procedure.second lineCode ratCode + let planeEnv := (Procedure.first planeCode ratCode).comp lineEnv + let y₁ := (Procedure.second planeCode ratCode).comp lineEnv + let setting := (Procedure.first settingsCode ratCode).comp planeEnv + let t := (Procedure.second settingsCode ratCode).comp planeEnv + let constants := (Procedure.first RationalHeatSample.settingsCode + (prodCode pointCode unaryCode)).comp setting + let pointAndCount := (Procedure.second RationalHeatSample.settingsCode + (prodCode pointCode unaryCode)).comp setting + let point := (Procedure.first pointCode unaryCode).comp pointAndCount + let args := constants.pair (t.pair (point.pair (y₁.pair y₂))) + exact (RationalHeatSample.program.comp args).congrFun (by intro x; rfl) + +noncomputable def lineInputProgram : + Procedure (prodCode planeCode ratCode) (RationalQuadratureProgram.inputCode lineCode) + (fun x => lineInput x.1 x.2) := by + let e := Procedure.first planeCode ratCode + let y := Procedure.second planeCode ratCode + let setting := (Procedure.first settingsCode ratCode).comp e + let pointAndCount := (Procedure.second RationalHeatSample.settingsCode + (prodCode pointCode unaryCode)).comp setting + let N := (Procedure.second pointCode unaryCode).comp pointAndCount + let count := Procedure.natToRat.comp (Procedure.unaryToBits.comp N) + let two := Procedure.constant (prodCode planeCode ratCode) ratCode (2 : ℚ) + let h := Procedure.ratDiv.comp (two.pair count) + let a := Procedure.constant (prodCode planeCode ratCode) ratCode (-1 : ℚ) + exact (N.pair ((e.pair y).pair (a.pair h))).congrFun (by intro x; rfl) + +noncomputable def lineProgram : + Procedure (prodCode planeCode ratCode) ratCode (fun x => line x.1 x.2) := + ((RationalQuadratureProgram.program lineCode sample sampleProgram).comp lineInputProgram).congrFun + (by intro x; rfl) + +noncomputable def planeInputProgram : + Procedure (prodCode settingsCode ratCode) (RationalQuadratureProgram.inputCode planeCode) + (fun x => planeInput x.1 x.2) := by + let e := Procedure.first settingsCode ratCode + let t := Procedure.second settingsCode ratCode + let pointAndCount := (Procedure.second RationalHeatSample.settingsCode + (prodCode pointCode unaryCode)).comp e + let N := (Procedure.second pointCode unaryCode).comp pointAndCount + let count := Procedure.natToRat.comp (Procedure.unaryToBits.comp N) + let two := Procedure.constant (prodCode settingsCode ratCode) ratCode (2 : ℚ) + let h := Procedure.ratDiv.comp (two.pair count) + let a := Procedure.constant (prodCode settingsCode ratCode) ratCode (-1 : ℚ) + exact (N.pair ((e.pair t).pair (a.pair h))).congrFun (by intro x; rfl) + +noncomputable def planeProgram : + Procedure (prodCode settingsCode ratCode) ratCode (fun x => plane x.1 x.2) := + ((RationalQuadratureProgram.program planeCode line lineProgram).comp planeInputProgram).congrFun + (by intro x; rfl) + +noncomputable def program : Procedure inputCode ratCode value := + (RationalQuadratureProgram.program settingsCode plane planeProgram).congrFun + (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode value := program.toTM2 + +end ContinuumCoulomb.RationalHeatBox + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatPlaneError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatPlaneError.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8a339f001d88606ef8f7ba8cc193523c5477059 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatPlaneError.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatBox +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RectangleQuadrature +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatSampleError + +namespace OAI + +/-! Error of the actual rational two-coordinate heat quadrature. +The sample evaluator is the concrete Taylor/π/forcing program. -/ + +namespace ContinuumCoulomb.RationalHeatBox + +def spatialStep (N : ℕ) : ℚ := 2 / (N : ℚ) +def spatialNode (N i : ℕ) : ℚ := RationalQuadratureProgram.node (-1) (spatialStep N) i + +theorem spatialEndpoint (N : ℕ) (hN : 0 < N) : spatialNode N N = 1 := by + have hn : (N : ℚ) ≠ 0 := by exact_mod_cast hN.ne' + unfold spatialNode RationalQuadratureProgram.node spatialStep + field_simp + ring + +theorem spatialNode_mem (N i : ℕ) (hN : 0 < N) (hi : i ≤ N) : + (spatialNode N i : ℝ) ∈ Set.Icc (-1 : ℝ) 1 := by + have hh : 0 ≤ (spatialStep N : ℝ) := by unfold spatialStep; positivity + have h := UniformQuadrature.node_mem (a := (-1 : ℝ)) hh hi + have hend : UniformQuadrature.node (-1 : ℝ) (spatialStep N : ℝ) N = 1 := by + have hc := RationalQuadratureProgram.node_cast (-1) (spatialStep N) N + norm_num only [Rat.cast_neg, Rat.cast_one] at hc + rw [← hc] + exact_mod_cast spatialEndpoint N hN + simpa only [spatialNode, RationalQuadratureProgram.node_cast, Rat.cast_neg, Rat.cast_one, + hend] using h + +theorem plane_cast (e : Settings) (t : ℚ) : + (plane e t : ℝ) = + UniformQuadrature.rectangleSum (spatialStep e.2.2 : ℝ) (spatialStep e.2.2 : ℝ) e.2.2 e.2.2 + (fun i j => (RationalHeatSample.value + (e.1, t, e.2.1, spatialNode e.2.2 i, spatialNode e.2.2 j) : ℝ)) := by + simp [plane, planeInput, line, lineInput, sample, RationalQuadratureProgram.value, + RationalQuadratureProgram.sample, spatialNode, spatialStep, + UniformQuadrature.rectangleSum, UniformQuadrature.sampleSum] + +theorem plane_error (e : Settings) (t : ℚ) {η : ℝ} + (hη : 0 < η) (ht : η ≤ (t : ℝ)) (hN : 0 < e.2.2) (hpi : 0 < e.1.2.2) + (hM : ∀ i < e.2.2, ∀ j < e.2.2, + |(RationalHeatSample.exponent (t, e.2.1, spatialNode e.2.2 i, spatialNode e.2.2 j) : ℝ)| + ≤ e.1.1) : + |(plane e t : ℝ) - Real.exp (-(t : ℝ)) * planarHeatAverage t + (PlanarForcingProgram.position e.2.1)| ≤ + 4 * (2 * planarBoxSpatialConstant (PlanarForcingProgram.position e.2.1) η * + (spatialStep e.2.2 : ℝ) + + ((2 ^ e.1.2.1 : ℝ)⁻¹ + 8 / (e.1.2.2 : ℝ)) / (4 * η)) := by + let r := PlanarForcingProgram.position e.2.1 + let L := planarBoxSpatialConstant r η + let δ := ((2 ^ e.1.2.1 : ℝ)⁻¹ + 8 / (e.1.2.2 : ℝ)) / (4 * η) + let f := fun x y => HeatKernelModulus.density r t (planarPairEquiv.symm (x, y)) + let v := fun i j => (RationalHeatSample.value + (e.1, t, e.2.1, spatialNode e.2.2 i, spatialNode e.2.2 j) : ℝ) + have hh : 0 ≤ (spatialStep e.2.2 : ℝ) := by unfold spatialStep; positivity + have hL : 0 ≤ L := by dsimp [L, planarBoxSpatialConstant]; positivity + have hend : UniformQuadrature.node (-1 : ℝ) (spatialStep e.2.2 : ℝ) e.2.2 = 1 := by + have hc := RationalQuadratureProgram.node_cast (-1) (spatialStep e.2.2) e.2.2 + norm_num only [Rat.cast_neg, Rat.cast_one] at hc + rw [← hc] + exact_mod_cast spatialEndpoint e.2.2 hN + have hLipX : ∀ x ∈ Set.Icc (-1 : ℝ) 1, ∀ x' ∈ Set.Icc (-1 : ℝ) 1, + ∀ y ∈ Set.Icc (-1 : ℝ) 1, |f x y - f x' y| ≤ L * |x - x'| := by + intro x hx x' hx' y hy + exact planarBox_spatial_first r hη ht hx hx' hy + have hLipY : ∀ x ∈ Set.Icc (-1 : ℝ) 1, ∀ y ∈ Set.Icc (-1 : ℝ) 1, + ∀ y' ∈ Set.Icc (-1 : ℝ) 1, |f x y - f x y'| ≤ L * |y - y'| := by + intro x hx y hy y' hy' + exact planarBox_spatial_second r hη ht hx hy hy' + have hsample : ∀ i < e.2.2, ∀ j < e.2.2, + |v i j - f (UniformQuadrature.node (-1) (spatialStep e.2.2 : ℝ) i) + (UniformQuadrature.node (-1) (spatialStep e.2.2 : ℝ) j)| ≤ δ := by + intro i hi j hj + have h := RationalHeatSample.error_density_uniform + (e.1, t, e.2.1, spatialNode e.2.2 i, spatialNode e.2.2 j) hη ht hpi (hM i hi j hj) + dsimp only [v, f, r, δ] + simpa only [rationalPosition_eq_pair, spatialNode, RationalQuadratureProgram.node_cast, + Rat.cast_neg, Rat.cast_one] using h + have h := UniformQuadrature.rectangle_error f v (-1) (spatialStep e.2.2 : ℝ) e.2.2 + (-1) (spatialStep e.2.2 : ℝ) e.2.2 hh hh hL hL + (by simpa only [hend] using hLipX) (by simpa only [hend] using hLipY) hsample + have hlen : (e.2.2 : ℝ) * (spatialStep e.2.2 : ℝ) = 2 := by + have hn : (e.2.2 : ℝ) ≠ 0 := by exact_mod_cast hN.ne' + simp only [spatialStep, Rat.cast_div, Rat.cast_ofNat, Rat.cast_natCast] + field_simp + rw [hend, hlen] at h + rw [plane_cast, planarHeatResolvent_box] + change |UniformQuadrature.rectangleSum _ _ _ _ v - ∫ x in (-1 : ℝ)..1, + ∫ y in (-1 : ℝ)..1, f x y| ≤ _ + convert h using 1 + ring + +theorem plane_error_of_magnitude (e : Settings) (t : ℚ) {η : ℝ} + (hη : 0 < η) (ht : η ≤ (t : ℝ)) (hN : 0 < e.2.2) (hpi : 0 < e.1.2.2) + (hM : (t : ℝ) + (‖PlanarForcingProgram.position e.2.1‖ + 2) ^ 2 / (4 * η) ≤ e.1.1) : + |(plane e t : ℝ) - Real.exp (-(t : ℝ)) * planarHeatAverage t + (PlanarForcingProgram.position e.2.1)| ≤ + 4 * (2 * planarBoxSpatialConstant (PlanarForcingProgram.position e.2.1) η * + (spatialStep e.2.2 : ℝ) + + ((2 ^ e.1.2.1 : ℝ)⁻¹ + 8 / (e.1.2.2 : ℝ)) / (4 * η)) := by + apply plane_error e t hη ht hN hpi + intro i hi j hj + exact (RationalHeatSample.exponent_abs_le _ hη ht le_rfl + (spatialNode_mem _ _ hN hi.le) (spatialNode_mem _ _ hN hj.le)).trans hM + +end ContinuumCoulomb.RationalHeatBox + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cd3dd4286379f4205311f5aa31bbe43593eae9d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalHeatSample.lean @@ -0,0 +1,192 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalExponentialProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PiProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PlanarForcingProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatKernel + +namespace OAI + +/-! Actual rational evaluation of the heat-resolvent integrand. Both π and +the exponential are computed by rational approximation programs. +Clamping the computed π below by one keeps every denominator quantitative. -/ + +namespace ContinuumCoulomb.RationalHeatSample +open ExactQuantumFactoring.BitStackProgram + +def safePi (N : ℕ) : ℚ := max 1 (PiProgram.approximate N) + +theorem safePi_ge_one (N : ℕ) : (1 : ℝ) ≤ (safePi N : ℝ) := by + exact_mod_cast le_max_left (1 : ℚ) (PiProgram.approximate N) + +theorem safePi_error (N : ℕ) (hN : 0 < N) : + |(safePi N : ℝ) - Real.pi| ≤ 8 / (N : ℝ) := by + have h := PiProgram.error N hN + have hp : (1 : ℝ) ≤ Real.pi := by linarith [Real.two_le_pi] + by_cases hq : (1 : ℚ) ≤ PiProgram.approximate N + · simpa only [safePi, max_eq_right hq] using h + · have hq' : (PiProgram.approximate N : ℝ) ≤ 1 := by exact_mod_cast le_of_not_ge hq + rw [safePi, max_eq_left (le_of_not_ge hq), Rat.cast_one, + abs_of_nonpos (by linarith)] + rw [abs_of_nonpos (by linarith)] at h + linarith + +noncomputable def safePiProgram : Procedure unaryCode ratCode safePi := by + let q := PiProgram.program + let one := Procedure.constant unaryCode ratCode (1 : ℚ) + let difference := Procedure.ratSub.comp (q.pair one) + let negative := Procedure.intSign.comp (Procedure.ratNum.comp difference) + exact (Procedure.conditional negative one q).congrFun (by + intro N + simp only [Function.comp_apply, Rat.num_neg, decide_eq_true_eq] + unfold safePi + split_ifs with h + · rw [max_eq_left (by linarith)] + · rw [max_eq_right (by linarith)]) + +abbrev Point := ℚ × ℚ +abbrev Arguments := ℚ × (Point × Point) +abbrev Settings := ℕ × (ℕ × ℕ) +abbrev Input := Settings × Arguments + +def pointCode : Point → List Bool := prodCode ratCode ratCode +def argumentsCode : Arguments → List Bool := prodCode ratCode (prodCode pointCode pointCode) +def settingsCode : Settings → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) +def inputCode : Input → List Bool := prodCode settingsCode argumentsCode + +def exponent (a : Arguments) : ℚ := + -a.1 - ((a.2.1.1 - a.2.2.1) ^ 2 + (a.2.1.2 - a.2.2.2) ^ 2) / (4 * a.1) + +def value (x : Input) : ℚ := + RationalExponential.approximate x.1.1 x.1.2.1 (exponent x.2) * + PlanarForcingProgram.value x.2.2.2 / (4 * safePi x.1.2.2 * x.2.1) + +noncomputable def exponentProgram : Procedure argumentsCode ratCode exponent := by + let t := Procedure.first ratCode (prodCode pointCode pointCode) + let xy := Procedure.second ratCode (prodCode pointCode pointCode) + let x := (Procedure.first pointCode pointCode).comp xy + let y := (Procedure.second pointCode pointCode).comp xy + let dx := Procedure.ratSub.comp + (((Procedure.first ratCode ratCode).comp x).pair ((Procedure.first ratCode ratCode).comp y)) + let dy := Procedure.ratSub.comp + (((Procedure.second ratCode ratCode).comp x).pair ((Procedure.second ratCode ratCode).comp y)) + let normSq := Procedure.ratAdd.comp + ((Procedure.ratMul.comp (dx.pair dx)).pair (Procedure.ratMul.comp (dy.pair dy))) + let four := Procedure.constant argumentsCode ratCode (4 : ℚ) + let denom := Procedure.ratMul.comp (four.pair t) + let gaussian := Procedure.ratDiv.comp (normSq.pair denom) + exact (Procedure.ratSub.comp ((Procedure.ratNeg.comp t).pair gaussian)).congrFun + (by intro a; simp only [exponent, pow_two]; rfl) + +noncomputable def program : Procedure inputCode ratCode value := by + let settings := Procedure.first settingsCode argumentsCode + let args := Procedure.second settingsCode argumentsCode + let M := (Procedure.first unaryCode (prodCode unaryCode unaryCode)).comp settings + let pn := (Procedure.second unaryCode (prodCode unaryCode unaryCode)).comp settings + let p := (Procedure.first unaryCode unaryCode).comp pn + let N := (Procedure.second unaryCode unaryCode).comp pn + let expArg := M.pair (p.pair (exponentProgram.comp args)) + let exponential := RationalExponentialProgram.program.comp expArg + let xy := (Procedure.second ratCode (prodCode pointCode pointCode)).comp args + let y := (Procedure.second pointCode pointCode).comp xy + let forcing := PlanarForcingProgram.program.comp y + let numerator := Procedure.ratMul.comp (exponential.pair forcing) + let t := (Procedure.first ratCode (prodCode pointCode pointCode)).comp args + let pi := safePiProgram.comp N + let four := Procedure.constant inputCode ratCode (4 : ℚ) + let denominator := Procedure.ratMul.comp ((Procedure.ratMul.comp (four.pair pi)).pair t) + exact (Procedure.ratDiv.comp (numerator.pair denominator)).congrFun (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode value := program.toTM2 + +theorem ratio_error {E e P Q dE dP : ℝ} + (hP : 1 ≤ P) (hQ : 1 ≤ Q) (he : 0 ≤ e) (he1 : e ≤ 1) + (hE : |E - e| ≤ dE) (hPQ : |P - Q| ≤ dP) : + |E / P - e / Q| ≤ dE + dP := by + have hP0 : 0 < P := by linarith + have hQ0 : 0 < Q := by linarith + have hdE : 0 ≤ dE := (abs_nonneg _).trans hE + have hdP : 0 ≤ dP := (abs_nonneg _).trans hPQ + have hid : E / P - e / Q = (E - e) / P + e * (Q - P) / (P * Q) := by + field_simp + ring + rw [hid] + calc + _ ≤ |(E - e) / P| + |e * (Q - P) / (P * Q)| := abs_add_le _ _ + _ ≤ dE + dP := by + apply add_le_add + · rw [abs_div, abs_of_pos hP0] + apply (div_le_iff₀ hP0).mpr + exact hE.trans (by nlinarith) + · rw [abs_div, abs_mul, abs_of_nonneg he, abs_of_pos (mul_pos hP0 hQ0), abs_sub_comm Q P] + apply (div_le_iff₀ (mul_pos hP0 hQ0)).mpr + have hmul : 1 ≤ P * Q := by nlinarith + have hnum := mul_le_mul_of_nonneg_left hPQ he + nlinarith + +theorem exponent_nonpos (a : Arguments) (ht : 0 < (a.1 : ℝ)) : + (exponent a : ℝ) ≤ 0 := by + simp only [exponent, Rat.cast_sub, Rat.cast_neg, Rat.cast_div, Rat.cast_add, Rat.cast_pow, + Rat.cast_mul, Rat.cast_ofNat] + have hpos : 0 ≤ (((a.2.1.1 : ℝ) - a.2.2.1) ^ 2 + + ((a.2.1.2 : ℝ) - a.2.2.2) ^ 2) / (4 * (a.1 : ℝ)) := by positivity + linarith + +theorem position_sub_norm_sq (x y : Point) : + ‖PlanarForcingProgram.position x - PlanarForcingProgram.position y‖ ^ 2 = + ((x.1 : ℝ) - y.1) ^ 2 + ((x.2 : ℝ) - y.2) ^ 2 := by + rw [EuclideanSpace.norm_sq_eq] + simp only [Fin.sum_univ_two, PlanarForcingProgram.position, PiLp.sub_apply, + Matrix.cons_val_zero, Matrix.cons_val_one, + Matrix.cons_val_fin_one, Real.norm_eq_abs, sq_abs] + +theorem exact_density (a : Arguments) : + Real.exp (exponent a : ℝ) * planarForcing (PlanarForcingProgram.position a.2.2) / + (4 * Real.pi * (a.1 : ℝ)) = + Real.exp (-(a.1 : ℝ)) * planarHeatKernel a.1 + (PlanarForcingProgram.position a.2.1 - PlanarForcingProgram.position a.2.2) * + planarForcing (PlanarForcingProgram.position a.2.2) := by + simp only [exponent, Rat.cast_sub, Rat.cast_neg, Rat.cast_div, Rat.cast_add, + Rat.cast_pow, Rat.cast_mul, Rat.cast_ofNat, planarHeatKernel, position_sub_norm_sq] + rw [show -(a.1 : ℝ) - (((a.2.1.1 : ℝ) - a.2.2.1) ^ 2 + + ((a.2.1.2 : ℝ) - a.2.2.2) ^ 2) / (4 * (a.1 : ℝ)) = + -(a.1 : ℝ) + (-((((a.2.1.1 : ℝ) - a.2.2.1) ^ 2 + + ((a.2.1.2 : ℝ) - a.2.2.2) ^ 2) / (4 * (a.1 : ℝ)))) by ring, + Real.exp_add] + simp only [neg_div] + ring + +theorem error (x : Input) (ht : 0 < (x.2.1 : ℝ)) (hN : 0 < x.1.2.2) + (hM : |(exponent x.2 : ℝ)| ≤ x.1.1) : + |(value x : ℝ) - Real.exp (exponent x.2 : ℝ) * + planarForcing (PlanarForcingProgram.position x.2.2.2) / + (4 * Real.pi * (x.2.1 : ℝ))| ≤ + ((2 ^ x.1.2.1 : ℝ)⁻¹ + 8 / (x.1.2.2 : ℝ)) / (4 * (x.2.1 : ℝ)) := by + let F := planarForcing (PlanarForcingProgram.position x.2.2.2) + have hF : 0 ≤ F := planarForcing_nonnegative _ + have hF1 : F ≤ 1 := planarForcing_le_one _ + have he := RationalExponential.error x.1.1 x.1.2.1 (exponent x.2) hM + have hr := ratio_error + (E := (RationalExponential.approximate x.1.1 x.1.2.1 (exponent x.2) : ℝ)) + (e := Real.exp (exponent x.2 : ℝ)) (dE := (2 ^ x.1.2.1 : ℝ)⁻¹) + (dP := 8 / (x.1.2.2 : ℝ)) + (safePi_ge_one x.1.2.2) (by linarith [Real.two_le_pi]) + (Real.exp_pos _).le ((Real.exp_le_one_iff).mpr (exponent_nonpos x.2 ht)) + (by simpa only [abs_sub_comm] using he) (safePi_error x.1.2.2 hN) + have hd : 0 < 4 * (x.2.1 : ℝ) := by positivity + have hv : (value x : ℝ) - Real.exp (exponent x.2 : ℝ) * F / + (4 * Real.pi * (x.2.1 : ℝ)) = + (((RationalExponential.approximate x.1.1 x.1.2.1 (exponent x.2) : ℝ) / + (safePi x.1.2.2 : ℝ) - Real.exp (exponent x.2 : ℝ) / Real.pi) * F) / + (4 * (x.2.1 : ℝ)) := by + simp only [value, Rat.cast_div, Rat.cast_mul, Rat.cast_ofNat, PlanarForcingProgram.value_cast] + dsimp only [F] + ring + rw [hv, abs_div, abs_mul, abs_of_nonneg hF, abs_of_pos hd] + apply div_le_div_of_nonneg_right _ hd.le + have hn := mul_le_mul_of_nonneg_right hr hF + have hb : 0 ≤ (2 ^ x.1.2.1 : ℝ)⁻¹ + 8 / (x.1.2.2 : ℝ) := by positivity + exact hn.trans (by nlinarith) + +end ContinuumCoulomb.RationalHeatSample + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalLogScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalLogScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..92c4fdd0012f91e420ee9d1634eccbc40b74eba1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalLogScale.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionSchedule + +namespace OAI + +/-! A rational approximation to the logarithmic contact scale. Only a fixed +rational approximation to `log 2` is used. The input-dependent operation is +the bit length of a natural power, so no real logarithm is queried at runtime. -/ + +noncomputable section +namespace ContinuumCoulomb.RationalLogScale + +def value (c : ℚ) (k N : ℕ) : ℚ := c * ((N ^ k).bits.length : ℚ) + +theorem bitLength_log_error (m : ℕ) (hm : 0 < m) : + 0 ≤ ((m.bits.length : ℝ) * Real.log 2 - Real.log (m : ℝ)) ∧ + (m.bits.length : ℝ) * Real.log 2 - Real.log (m : ℝ) ≤ Real.log 2 := by + have hmR : (0 : ℝ) < m := by exact_mod_cast hm + have hs : 0 < m.size := Nat.size_pos.mpr hm + obtain ⟨s, hs⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hs) + have hlo : 2 ^ s ≤ m := Nat.lt_size.mp (by omega) + have hhi : m < 2 ^ (s + 1) := by simpa only [hs] using Nat.lt_size_self m + have hloR : (2 : ℝ) ^ s ≤ m := by exact_mod_cast hlo + have hhiR : (m : ℝ) < 2 ^ (s + 1) := by exact_mod_cast hhi + have hl := Real.log_le_log (by positivity : (0 : ℝ) < 2 ^ s) hloR + have hh := Real.log_lt_log hmR hhiR + rw [Real.log_pow] at hl hh + simp only [Nat.size_eq_bits_len, hs, Nat.cast_succ] at * + constructor <;> nlinarith + +theorem exists_logTwo_approximation {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) : + ∃ c : ℚ, 0 < c ∧ |(c : ℝ) - Real.log 2| ≤ ε / 4 * Real.log 2 := by + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨c, hc0, hc1⟩ := exists_rat_btwn + (show (1 - ε / 4) * Real.log 2 < (1 + ε / 4) * Real.log 2 by + nlinarith [mul_pos hε hlog]) + refine ⟨c, ?_, abs_le.mpr ⟨?_, ?_⟩⟩ + · have : (0 : ℝ) < c := (mul_pos (by linarith : 0 < 1 - ε / 4) hlog).trans hc0 + exact_mod_cast this + · nlinarith + · nlinarith + +theorem relative_error (c : ℚ) {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) + (hc : |(c : ℝ) - Real.log 2| ≤ ε / 4 * Real.log 2) + (k N : ℕ) (hN : 2 ≤ N) (hk : 8 ≤ ε * (k : ℝ)) : + |(value c k N : ℝ) - (k : ℝ) * Real.log (N : ℝ)| ≤ + ε * ((k : ℝ) * Real.log (N : ℝ)) := by + have hNp : 0 < N := by omega + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hlogN : Real.log 2 ≤ Real.log (N : ℝ) := + Real.log_le_log (by norm_num) (by exact_mod_cast hN) + have hE0 : 0 ≤ (k : ℝ) * Real.log (N : ℝ) := mul_nonneg (Nat.cast_nonneg _) (hlog.le.trans hlogN) + obtain ⟨hb0, hb1⟩ := bitLength_log_error (N ^ k) (pow_pos hNp k) + rw [Nat.cast_pow, Real.log_pow] at hb0 hb1 + have htriangle := abs_add_le + (((N ^ k).bits.length : ℝ) * ((c : ℝ) - Real.log 2)) + (((N ^ k).bits.length : ℝ) * Real.log 2 - (k : ℝ) * Real.log (N : ℝ)) + have hchange : |(value c k N : ℝ) - (k : ℝ) * Real.log (N : ℝ)| ≤ + (((N ^ k).bits.length : ℝ) * (ε / 4 * Real.log 2)) + Real.log 2 := by + have hmul := mul_le_mul_of_nonneg_left hc (Nat.cast_nonneg (N ^ k).bits.length : + (0 : ℝ) ≤ (N ^ k).bits.length) + have habs : |((N ^ k).bits.length : ℝ) * ((c : ℝ) - Real.log 2)| ≤ + ((N ^ k).bits.length : ℝ) * (ε / 4 * Real.log 2) := by + rw [abs_mul, abs_of_nonneg (Nat.cast_nonneg _)] + exact hmul + rw [show |((N ^ k).bits.length : ℝ) * Real.log 2 - + (k : ℝ) * Real.log (N : ℝ)| = + ((N ^ k).bits.length : ℝ) * Real.log 2 - (k : ℝ) * Real.log (N : ℝ) + from abs_of_nonneg hb0] at htriangle + have heq : (value c k N : ℝ) - (k : ℝ) * Real.log (N : ℝ) = + ((N ^ k).bits.length : ℝ) * ((c : ℝ) - Real.log 2) + + (((N ^ k).bits.length : ℝ) * Real.log 2 - (k : ℝ) * Real.log (N : ℝ)) := by + simp only [value, Rat.cast_mul, Rat.cast_natCast] + ring + rw [heq] + exact htriangle.trans (add_le_add habs hb1) + have hround : 2 * Real.log 2 ≤ ε / 4 * ((k : ℝ) * Real.log (N : ℝ)) := by + have hcount : (2 : ℝ) ≤ ε / 4 * (k : ℝ) := by nlinarith + have h₁ := mul_le_mul_of_nonneg_right hcount hlog.le + have h₂ := mul_le_mul_of_nonneg_left hlogN + (show 0 ≤ ε / 4 * (k : ℝ) by positivity) + nlinarith only [h₁, h₂] + have hbit := mul_le_mul_of_nonneg_left hb1 (show 0 ≤ ε / 4 by positivity) + have hsmall : ε / 4 * Real.log 2 ≤ Real.log 2 := + (mul_le_mul_of_nonneg_right (by linarith : ε / 4 ≤ 1) hlog.le).trans_eq (one_mul _) + have hscaled := mul_nonneg hε.le hE0 + nlinarith only [hchange, hbit, hsmall, hround, hscaled] + +theorem relative_bounds (c : ℚ) {ε : ℝ} (hε : 0 < ε) (hε1 : ε ≤ 1) + (hc : |(c : ℝ) - Real.log 2| ≤ ε / 4 * Real.log 2) + (k N : ℕ) (hN : 2 ≤ N) (hk : 8 ≤ ε * (k : ℝ)) : + (1 - ε) * ((k : ℝ) * Real.log (N : ℝ)) ≤ (value c k N : ℝ) ∧ + (value c k N : ℝ) ≤ (1 + ε) * ((k : ℝ) * Real.log (N : ℝ)) := by + have h := abs_le.mp (relative_error c hε hε1 hc k N hN hk) + constructor <;> nlinarith [h.1, h.2] + +end ContinuumCoulomb.RationalLogScale + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalResolventError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalResolventError.lean new file mode 100644 index 0000000000000000000000000000000000000000..fceb751c9f61e18a8d37da766b75609eb143e681 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalResolventError.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatPlaneError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatTimeModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarHeatTruncation + +namespace OAI + +/-! The actual computed three-dimensional heat quadrature approximates +the constructed planar resolvent. The bound includes both numerical +quadrature and the explicitly proved short/long-time tails. -/ + +noncomputable section +namespace ContinuumCoulomb.RationalHeatBox + +def timeEndpoint (x : Input) : ℚ := + RationalQuadratureProgram.node x.2.2.1 x.2.2.2 x.1 + +def planeErrorBound (e : Settings) (η : ℝ) : ℝ := + 4 * (2 * planarBoxSpatialConstant (PlanarForcingProgram.position e.2.1) η * + (spatialStep e.2.2 : ℝ) + + ((2 ^ e.1.2.1 : ℝ)⁻¹ + 8 / (e.1.2.2 : ℝ)) / (4 * η)) + +def resolventErrorBound (x : Input) : ℝ := + (x.1 : ℝ) * (4 * planarBoxTimeConstant (PlanarForcingProgram.position x.2.1.2.1) + (x.2.2.1 : ℝ) * (x.2.2.2 : ℝ) ^ 2 + + (x.2.2.2 : ℝ) * planeErrorBound x.2.1 (x.2.2.1 : ℝ)) + + (x.2.2.1 : ℝ) + Real.exp (-(timeEndpoint x : ℝ)) + +theorem resolvent_error (x : Input) + (hη : 0 < (x.2.2.1 : ℝ)) (hh : 0 ≤ (x.2.2.2 : ℝ)) + (hN : 0 < x.2.1.2.2) (hpi : 0 < x.2.1.1.2.2) + (hM : (timeEndpoint x : ℝ) + + (‖PlanarForcingProgram.position x.2.1.2.1‖ + 2) ^ 2 / (4 * (x.2.2.1 : ℝ)) ≤ x.2.1.1.1) : + |(value x : ℝ) - planarResolventMode (PlanarForcingProgram.position x.2.1.2.1)| ≤ + resolventErrorBound x := by + let r := PlanarForcingProgram.position x.2.1.2.1 + let η := (x.2.2.1 : ℝ) + let h := (x.2.2.2 : ℝ) + let T := (timeEndpoint x : ℝ) + let f := fun t => Real.exp (-t) * planarHeatAverage t r + have hT : T = UniformQuadrature.node η h x.1 := + RationalQuadratureProgram.node_cast _ _ _ + have hηT : η ≤ T := by rw [hT]; exact (UniformQuadrature.node_mem hh (Nat.le_refl x.1)).1 + have hL : 0 ≤ 4 * planarBoxTimeConstant r η := by + dsimp [planarBoxTimeConstant, η] + positivity + have hLip : ∀ t ∈ Set.Icc η (UniformQuadrature.node η h x.1), + ∀ s ∈ Set.Icc η (UniformQuadrature.node η h x.1), + |f t - f s| ≤ (4 * planarBoxTimeConstant r η) * |t - s| := by + intro t ht s hs + exact planarHeatTime_lipschitz r hη ht.1 hs.1 + have hSample : ∀ i < x.1, + |(plane x.2.1 (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) : ℝ) - + f (UniformQuadrature.node η h i)| ≤ planeErrorBound x.2.1 η := by + intro i hi + have htmem := UniformQuadrature.node_mem (a := η) hh hi.le + have htmem' : (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i : ℝ) ∈ Set.Icc η T := by + rw [RationalQuadratureProgram.node_cast, hT] + exact htmem + have hm : (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i : ℝ) + + (‖r‖ + 2) ^ 2 / (4 * η) ≤ x.2.1.1.1 := by + linarith [htmem'.2, hM] + have hp := plane_error_of_magnitude x.2.1 + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) hη htmem'.1 hN hpi hm + dsimp only [f, r, η, h, planeErrorBound] + simpa only [RationalQuadratureProgram.node_cast] using hp + have hQuad := UniformQuadrature.samples_error_lipschitz f + (fun i => (plane x.2.1 (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) : ℝ)) + η h x.1 hh hL hLip hSample + have hQuad' : |(value x : ℝ) - planarTruncatedHeat r η T| ≤ + (x.1 : ℝ) * (4 * planarBoxTimeConstant r η * h ^ 2 + h * planeErrorBound x.2.1 η) := by + rw [value, RationalQuadratureProgram.value_cast] + rw [← hT] at hQuad + exact hQuad + have hTail : |planarTruncatedHeat r η T - planarResolventMode r| ≤ η + Real.exp (-T) := by + rw [abs_sub_comm] + exact planarTruncatedHeat_error r hη.le hηT + calc + _ = |((value x : ℝ) - planarTruncatedHeat r η T) + + (planarTruncatedHeat r η T - planarResolventMode r)| := by congr 1; ring + _ ≤ |(value x : ℝ) - planarTruncatedHeat r η T| + + |planarTruncatedHeat r η T - planarResolventMode r| := abs_add_le _ _ + _ ≤ (x.1 : ℝ) * (4 * planarBoxTimeConstant r η * h ^ 2 + h * planeErrorBound x.2.1 η) + + (η + Real.exp (-T)) := add_le_add hQuad' hTail + _ = _ := by dsimp [resolventErrorBound, r, η, h, T]; ring + +end ContinuumCoulomb.RationalHeatBox + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSixQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSixQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c87038ad1a6dc898a9ae6432b0b6a1ff12a5009 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSixQuadrature.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalRectangleProgram + +namespace OAI + +/-! Six-coordinate rational cubature, as three literal rectangle programs. +The same finite mesh is retained in each register environment. -/ + +namespace ContinuumCoulomb.RationalSixQuadrature +open ExactQuantumFactoring.BitStackProgram + +variable {E : Type} +abbrev Pair := ℚ × ℚ +abbrev Input (E : Type) := RationalRectangleProgram.Input E +abbrev Evaluator (E : Type) := E → ℚ → ℚ → ℚ → ℚ → ℚ → ℚ → ℚ + +def pairCode : Pair → List Bool := prodCode ratCode ratCode + +def augment (x : Input E) (a b : ℚ) : Input (E × Pair) := + (x.1, ((x.2.1, (a, b)), x.2.2)) + +def remember (x : Input E) : Input (Input E) := (x.1, (x, x.2.2)) + +def inner (f : Evaluator E) (e : (E × Pair) × Pair) (a b : ℚ) : ℚ := + f e.1.1 e.1.2.1 e.1.2.2 e.2.1 e.2.2 a b + +def middle (f : Evaluator E) (x : Input (E × Pair)) (a b : ℚ) : ℚ := + RationalRectangleProgram.value (inner f) (augment x a b) + +def outer (f : Evaluator E) (x : Input E) (a b : ℚ) : ℚ := + RationalRectangleProgram.value (middle f) (remember (augment x a b)) + +def value (f : Evaluator E) (x : Input E) : ℚ := + RationalRectangleProgram.value (outer f) (remember x) + +noncomputable opaque augmentProgram (ce : E → List Bool) : + Procedure (prodCode (prodCode (RationalRectangleProgram.inputCode ce) ratCode) ratCode) + (RationalRectangleProgram.inputCode (prodCode ce pairCode)) + (fun x => augment x.1.1 x.1.2 x.2) := by + let xa := Procedure.first (prodCode (RationalRectangleProgram.inputCode ce) ratCode) ratCode + let x := (Procedure.first (RationalRectangleProgram.inputCode ce) ratCode).comp xa + let a := (Procedure.second (RationalRectangleProgram.inputCode ce) ratCode).comp xa + let b := Procedure.second (prodCode (RationalRectangleProgram.inputCode ce) ratCode) ratCode + let n := (Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce)).comp x + let env := (Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce)).comp x + let data := (Procedure.first ce pairCode).comp env + let mesh := (Procedure.second ce pairCode).comp env + exact (n.pair ((data.pair (a.pair b)).pair mesh)).congrFun (by intro q; rfl) + +noncomputable opaque rememberProgram (ce : E → List Bool) : + Procedure (RationalRectangleProgram.inputCode ce) + (RationalRectangleProgram.inputCode (RationalRectangleProgram.inputCode ce)) remember := by + let n := Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce) + let env := Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce) + let mesh := (Procedure.second ce pairCode).comp env + exact (n.pair ((Procedure.identity (RationalRectangleProgram.inputCode ce)).pair mesh)).congrFun + (by intro q; rfl) + +noncomputable opaque middleProgram (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode (prodCode ce pairCode) pairCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Procedure (prodCode (prodCode (RationalRectangleProgram.inputCode (prodCode ce pairCode)) ratCode) ratCode) + ratCode (fun x => middle f x.1.1 x.1.2 x.2) := + ((RationalRectangleProgram.program (prodCode (prodCode ce pairCode) pairCode) (inner f) p).comp + (augmentProgram (prodCode ce pairCode))).congrFun (by intro q; rfl) + +noncomputable opaque outerProgram (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode (prodCode ce pairCode) pairCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Procedure (prodCode (prodCode (RationalRectangleProgram.inputCode ce) ratCode) ratCode) + ratCode (fun x => outer f x.1.1 x.1.2 x.2) := by + let rectangle := RationalRectangleProgram.program + (RationalRectangleProgram.inputCode (prodCode ce pairCode)) (middle f) (middleProgram ce f p) + exact (rectangle.comp ((rememberProgram (prodCode ce pairCode)).comp (augmentProgram ce))).congrFun + (by intro q; rfl) + +noncomputable opaque program (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode (prodCode ce pairCode) pairCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Procedure (RationalRectangleProgram.inputCode ce) ratCode (value f) := + ((RationalRectangleProgram.program (RationalRectangleProgram.inputCode ce) (outer f) + (outerProgram ce f p)).comp (rememberProgram ce)).congrFun (by intro q; rfl) + +noncomputable def certificate (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode (prodCode ce pairCode) pairCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Turing.TM2ComputableInPolyTime (RationalRectangleProgram.inputCode ce) ratCode (value f) := + (program ce f p).toTM2 + + +theorem value_cast (f : Evaluator E) (x : Input E) : + (value f x : ℝ) = + UniformQuadrature.rectangleSum (x.2.2.2 : ℝ) (x.2.2.2 : ℝ) x.1 x.1 (fun i j => + UniformQuadrature.rectangleSum (x.2.2.2 : ℝ) (x.2.2.2 : ℝ) x.1 x.1 (fun k l => + UniformQuadrature.rectangleSum (x.2.2.2 : ℝ) (x.2.2.2 : ℝ) x.1 x.1 (fun m n => + (f x.2.1 + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 k) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 l) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 m) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 n) : ℝ)))) := by + simp only [value, outer, middle, inner, remember, augment, + RationalRectangleProgram.value_cast] + +end ContinuumCoulomb.RationalSixQuadrature + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSmoothTransition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSmoothTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..88d4b2c85cd37b6bafe5c0e212f0a095cf197e9d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSmoothTransition.lean @@ -0,0 +1,190 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalExponential +import Mathlib.Analysis.SpecialFunctions.SmoothTransition +import Mathlib.Analysis.Complex.ExponentialBounds + +namespace OAI + +/-! Rational approximation of the explicit smooth transition. Exponents +near the flat junction are truncated before Taylor evaluation, keeping +both the magnitude parameter and the error polynomial in the precision. -/ + +namespace ContinuumCoulomb.RationalSmoothTransition + +def clip (q : ℚ) : ℚ := max 0 (min 1 q) + +theorem clip_bounds (q : ℚ) : 0 ≤ clip q ∧ clip q ≤ 1 := by + constructor + · exact le_max_left _ _ + · exact max_le (by norm_num) (min_le_left _ _) + +theorem clip_error (q : ℚ) {a ε : ℝ} (ha0 : 0 ≤ a) (ha1 : a ≤ 1) + (hq : |(q:ℝ)-a| ≤ ε) : |(clip q:ℝ)-a| ≤ ε := by + have he := abs_le.mp hq + by_cases hq0 : q ≤ 0 + · have hqR : (q:ℝ) ≤ 0 := by exact_mod_cast hq0 + simp only [clip, min_eq_right (hq0.trans (by norm_num : (0:ℚ) ≤ 1)), + max_eq_left hq0, Rat.cast_zero, zero_sub, abs_neg, abs_of_nonneg ha0] + linarith + · by_cases hq1 : 1 ≤ q + · have hqR : (1:ℝ) ≤ q := by exact_mod_cast hq1 + simp only [clip, min_eq_left hq1, max_eq_right (by norm_num : (0:ℚ) ≤ 1), + Rat.cast_one, abs_of_nonneg (sub_nonneg.mpr ha1)] + linarith + · simpa only [clip, min_eq_right (le_of_not_ge hq1), + max_eq_right (le_of_not_ge hq0)] using hq + +def flat (p : ℕ) (q : ℚ) : ℚ := + if (p+1 : ℚ)⁻¹ < q then + clip (RationalExponential.approximate (p+1) (p+1) (-q⁻¹)) + else 0 + +theorem flat_bounds (p : ℕ) (q : ℚ) : 0 ≤ flat p q ∧ flat p q ≤ 1 := by + unfold flat + split_ifs + · exact clip_bounds _ + · constructor <;> norm_num + +private theorem two_pow_bound (p : ℕ) : p+1 ≤ 2^(p+1) := by + induction p with + | zero => norm_num + | succ p ih => + rw [pow_succ] + omega + +theorem flat_error (p : ℕ) (q : ℚ) : + |(flat p q:ℝ)-expNegInvGlue (q:ℝ)| ≤ ((p:ℝ)+1)⁻¹ := by + have hp : (0:ℝ) < (p:ℝ)+1 := by positivity + have hpQ : (0:ℚ) < (p+1:ℚ) := by positivity + have hg0 : 0 ≤ expNegInvGlue (q:ℝ) := expNegInvGlue.nonneg _ + have hg1 : expNegInvGlue (q:ℝ) ≤ 1 := by + by_cases hq : (q:ℝ) ≤ 0 + · rw [expNegInvGlue.zero_of_nonpos hq]; norm_num + · rw [expNegInvGlue, ite_eq_right hq] + exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (inv_nonneg.mpr (le_of_not_ge hq))) + unfold flat + split_ifs with hq + · have hqR : ((p:ℝ)+1)⁻¹ < (q:ℝ) := by + have hh := (Rat.cast_lt (K := ℝ)).mpr hq + simpa only [Rat.cast_inv, Rat.cast_add, Rat.cast_natCast, Rat.cast_one] using hh + have hqp : (0:ℝ) < (q:ℝ) := (inv_pos.mpr hp).trans hqR + have hinv : (q:ℝ)⁻¹ ≤ (p:ℝ)+1 := by + exact (inv_le_comm₀ hqp hp).mpr hqR.le + have he := RationalExponential.error (p+1) (p+1) (-q⁻¹) (by + push_cast + rw [abs_neg, abs_of_pos (inv_pos.mpr hqp)] + simpa only [Nat.cast_add, Nat.cast_one] using hinv) + have hprec : (2^(p+1):ℝ)⁻¹ ≤ ((p:ℝ)+1)⁻¹ := by + apply (inv_le_inv₀ (by positivity) hp).mpr + exact_mod_cast two_pow_bound p + have he' : |(RationalExponential.approximate (p+1) (p+1) (-q⁻¹):ℝ) - + expNegInvGlue (q:ℝ)| ≤ ((p:ℝ)+1)⁻¹ := by + rw [expNegInvGlue, ite_eq_right (not_le.mpr hqp)] + simpa only [Rat.cast_neg, Rat.cast_inv, abs_sub_comm] using he.trans hprec + exact clip_error _ hg0 hg1 he' + · have hqR : (q:ℝ) ≤ ((p:ℝ)+1)⁻¹ := by + have hh := (Rat.cast_le (K := ℝ)).mpr (le_of_not_gt hq) + simpa only [Rat.cast_inv, Rat.cast_add, Rat.cast_natCast, Rat.cast_one] using hh + by_cases hqp : (q:ℝ) ≤ 0 + · rw [expNegInvGlue.zero_of_nonpos hqp] + simpa using (inv_nonneg.mpr hp.le) + · have hqp' : (0:ℝ) < (q:ℝ) := lt_of_not_ge hqp + have hexp : (q:ℝ)⁻¹ ≤ Real.exp (q:ℝ)⁻¹ := by + linarith [Real.add_one_le_exp ((q:ℝ)⁻¹)] + have hinv : (Real.exp (q:ℝ)⁻¹)⁻¹ ≤ (q:ℝ) := by + simpa only [inv_inv] using + (inv_le_inv₀ (Real.exp_pos _) (inv_pos.mpr hqp')).mpr hexp + rw [Rat.cast_zero, zero_sub, abs_neg, abs_of_nonneg hg0, expNegInvGlue, ite_eq_right hqp, + Real.exp_neg] + exact hinv.trans hqR + +theorem transition_denominator_lower (x : ℝ) : + (1/9:ℝ) ≤ expNegInvGlue x + expNegInvGlue (1-x) := by + have he : Real.exp 2 ≤ 9 := by + rw [show (2:ℝ) = 1+1 by norm_num, Real.exp_add] + nlinarith [Real.exp_one_lt_three, Real.exp_pos 1] + have hinv : (1/9:ℝ) ≤ expNegInvGlue (1/2) := by + norm_num only [expNegInvGlue, show ¬ ((1/2:ℝ) ≤ 0) by norm_num, ite_false, + one_div, inv_inv, inv_div, mul_one] + rw [Real.exp_neg] + exact (le_inv_comm₀ (by norm_num) (Real.exp_pos _)).mpr (by simpa using he) + by_cases hx : (1/2:ℝ) ≤ x + · exact hinv.trans ((expNegInvGlue.monotone hx).trans + (le_add_of_nonneg_right (expNegInvGlue.nonneg _))) + · have hy : (1/2:ℝ) ≤ 1-x := by linarith + exact hinv.trans ((expNegInvGlue.monotone hy).trans + (le_add_of_nonneg_left (expNegInvGlue.nonneg _))) + +def precision (p : ℕ) : ℕ := 1000*(p+1) + +def approximate (p : ℕ) (q : ℚ) : ℚ := + flat (precision p) q / (flat (precision p) q + flat (precision p) (1-q)) + +theorem quotient_error {a b a' b' ε : ℝ} + (ha : 0 ≤ a) (ha1 : a ≤ 1) (hb : 1/9 ≤ a+b) + (hε : 0 ≤ ε) (hsmall : ε ≤ 1/1000) + (hea : |a'-a| ≤ ε) (heb : |b'-b| ≤ ε) : + |a'/(a'+b')-a/(a+b)| ≤ 342*ε := by + have hden : |(a'+b')-(a+b)| ≤ 2*ε := by + have h := (abs_add_le (a'-a) (b'-b)).trans (add_le_add hea heb) + convert h using 1 <;> ring_nf + have hd : 0 < a+b := by linarith + have hd' : 1/18 ≤ a'+b' := by linarith [(abs_le.mp hden).1] + have hd'p : 0 < a'+b' := by linarith + have hi : (a+b)⁻¹ ≤ 9 := (inv_le_iff_one_le_mul₀ hd).mpr (by linarith) + have hi' : (a'+b')⁻¹ ≤ 18 := (inv_le_iff_one_le_mul₀ hd'p).mpr (by linarith) + have hnum : |a'/(a'+b')-a/(a+b)| ≤ + ε*(a'+b')⁻¹ + 2*ε*(a'+b')⁻¹*(a+b)⁻¹ := by + have heq : a'/(a'+b')-a/(a+b) = + (a'-a)*(a'+b')⁻¹ + a*((a+b)-(a'+b'))*(a'+b')⁻¹*(a+b)⁻¹ := by + field_simp [hd.ne',hd'p.ne'] + ring + rw [heq] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_mul, abs_mul, abs_of_nonneg ha, + abs_of_pos (inv_pos.mpr hd), abs_of_pos (inv_pos.mpr hd'p), + abs_sub_comm (a+b) (a'+b')] + apply add_le_add + · exact mul_le_mul_of_nonneg_right hea (inv_nonneg.mpr hd'p.le) + · apply mul_le_mul_of_nonneg_right _ (inv_nonneg.mpr hd.le) + apply mul_le_mul_of_nonneg_right _ (inv_nonneg.mpr hd'p.le) + calc + _ ≤ 1*(2*ε) := mul_le_mul ha1 hden (abs_nonneg _) (by norm_num) + _ = 2*ε := one_mul _ + apply hnum.trans + calc + _ ≤ ε*18 + 2*ε*18*9 := by gcongr + _ = 342*ε := by ring + +theorem approximation_error (p : ℕ) (q : ℚ) : + |(approximate p q:ℝ)-Real.smoothTransition (q:ℝ)| ≤ ((p:ℝ)+1)⁻¹ := by + let ε : ℝ := ((precision p:ℝ)+1)⁻¹ + have hp : (0:ℝ) < (p:ℝ)+1 := by positivity + have he : 0 ≤ ε := by dsimp [ε]; positivity + have hesmall : ε ≤ 1/1000 := by + dsimp [ε,precision] + push_cast + apply (inv_le_iff_one_le_mul₀ (by positivity)).mpr + nlinarith [Nat.cast_nonneg (α := ℝ) p] + have ha1 : expNegInvGlue (q:ℝ) ≤ 1 := by + by_cases hq : (q:ℝ) ≤ 0 + · rw [expNegInvGlue.zero_of_nonpos hq]; norm_num + · rw [expNegInvGlue, ite_eq_right hq] + exact Real.exp_le_one_iff.mpr (neg_nonpos.mpr (inv_nonneg.mpr (le_of_not_ge hq))) + have heb : |(flat (precision p) (1-q):ℝ)-expNegInvGlue (1-(q:ℝ))| ≤ ε := by + simpa only [Rat.cast_sub, Rat.cast_one] using flat_error (precision p) (1-q) + have h := quotient_error (expNegInvGlue.nonneg _) ha1 + (transition_denominator_lower (q:ℝ)) he hesmall + (flat_error (precision p) q) heb + have hbound : 342*ε ≤ ((p:ℝ)+1)⁻¹ := by + dsimp [ε,precision] + push_cast + apply (mul_le_mul_iff_left₀ hp).mp + field_simp + nlinarith [Nat.cast_nonneg (α := ℝ) p] + apply (le_trans ?_ hbound) + simpa only [approximate, Real.smoothTransition, Rat.cast_div, Rat.cast_add, + Rat.cast_sub, Rat.cast_one] using h + +end ContinuumCoulomb.RationalSmoothTransition + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSquareRoot.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSquareRoot.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d57cf84e975e646171c4cd81a52e884dfde74d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalSquareRoot.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.DyadicRootProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ChargePrograms + +namespace OAI + +/-! Certified evaluation of square roots of nonnegative rational samples. +The same finite dyadic procedure serves the fixed Gaussian constants and +softened Coulomb distances. -/ + +namespace ContinuumCoulomb.RationalSquareRoot +open ExactQuantumFactoring.BitStackProgram + +def value (x : ℕ × ℚ) : ℚ := + DyadicRootProgram.value x.1 x.2.num.toNat x.2.den + +def inputCode : (ℕ × ℚ) → List Bool := prodCode unaryCode ratCode + +noncomputable opaque argumentProgram : Procedure inputCode DyadicRootProgram.rawCode + (fun x => (x.1, x.2.num.toNat, x.2.den)) := by + let p := Procedure.first unaryCode ratCode + let q := Procedure.second unaryCode ratCode + let num := ChargePrograms.intToNatProgram.comp (Procedure.ratNum.comp q) + let den := Procedure.ratDen.comp q + exact p.pair (num.pair den) + +noncomputable opaque program : Procedure inputCode ratCode value := + (DyadicRootProgram.rawProgram.comp argumentProgram).congrFun (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode value := + program.toTM2 + +theorem value_error (b : ℕ) {q : ℚ} (hq : 0 ≤ q) : + |(value (b, q) : ℝ) - Real.sqrt (q : ℝ)| ≤ (2 : ℝ)⁻¹ ^ b := by + have hnum : (q.num.toNat : ℤ) = q.num := Int.toNat_of_nonneg (Rat.num_nonneg.mpr hq) + have hnumq : (q.num.toNat : ℚ) = (q.num : ℚ) := by exact_mod_cast hnum + have hrepr : (q.num.toNat : ℚ) / q.den = q := by rw [hnumq, Rat.num_div_den] + have hre : (q.num.toNat : ℝ) / q.den = (q : ℝ) := by + simpa only [Rat.cast_div, Rat.cast_natCast] using congrArg (fun x : ℚ => (x : ℝ)) hrepr + have h := DyadicRootProgram.value_error b q.num.toNat q.den q.pos + rw [hre] at h + change |(DyadicRootProgram.value b q.num.toNat q.den : ℝ) - Real.sqrt (q : ℝ)| ≤ _ + rw [abs_sub_comm, abs_of_nonneg h.1] + exact h.2.le.trans_eq (by simp only [one_div, inv_pow]) + +theorem sqrt_perturbation {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) : + |Real.sqrt a - Real.sqrt b| ≤ Real.sqrt |a - b| := by + apply Real.abs_le_sqrt + have hsa := Real.sq_sqrt ha + have hsb := Real.sq_sqrt hb + by_cases hab : a ≤ b + · have hs := Real.sqrt_le_sqrt hab + have hm := mul_nonneg (Real.sqrt_nonneg a) (sub_nonneg.mpr hs) + rw [abs_of_nonpos (sub_nonpos.mpr hab)] + nlinarith + · have hs := Real.sqrt_le_sqrt (le_of_not_ge hab) + have hm := mul_nonneg (Real.sqrt_nonneg b) (sub_nonneg.mpr hs) + rw [abs_of_nonneg (sub_nonneg.mpr (le_of_not_ge hab))] + nlinarith + +end ContinuumCoulomb.RationalSquareRoot + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTaylorRegisters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTaylorRegisters.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd5e9d66fa63055f44c0f2ddeb7ea40a8cd2b5d7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTaylorRegisters.lean @@ -0,0 +1,162 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalExponential +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AmplificationProgram +import OAI.Computability.QuantumFactoring.BitStackRationals + +namespace OAI + +/-! A shared-denominator Taylor recurrence for arbitrary rational inputs. +The numerator may be signed. Register size grows polynomially in the +iteration count and the encoded numerator and denominator lengths. -/ + +namespace ContinuumCoulomb.RationalTaylorRegisters +open ExactQuantumFactoring.BitStackProgram +open scoped BigOperators + +abbrev State := ℤ × (ℕ × (ℕ × (ℤ × (ℕ × ℤ)))) + +def code : State → List Bool := prodCode intCode + (prodCode Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))) + +def step (s : State) : State := + let factor := (s.2.2.1 + 1) * s.2.1 + (s.1, s.2.1, s.2.2.1 + 1, (factor : ℤ) * (s.2.2.2.1 + s.2.2.2.2.2), + factor * s.2.2.2.2.1, s.1 * s.2.2.2.2.2) + +def initial (q : ℚ) : State := (q.num, q.den, 0, 0, 1, 1) + +theorem iterate_initial (q : ℚ) (n : ℕ) : + ((step^[n]) (initial q)).1 = q.num ∧ + ((step^[n]) (initial q)).2.1 = q.den ∧ + ((step^[n]) (initial q)).2.2.1 = n ∧ + (((step^[n]) (initial q)).2.2.2.1 : ℚ) = + (n.factorial * q.den ^ n : ℕ) * RationalExponential.taylorSum q n ∧ + ((step^[n]) (initial q)).2.2.2.2.1 = n.factorial * q.den ^ n ∧ + ((step^[n]) (initial q)).2.2.2.2.2 = q.num ^ n := by + induction n with + | zero => simp [initial, RationalExponential.taylorSum] + | succ n ih => + rcases ih with ⟨ha, hb, hj, hA, hF, hP⟩ + rw [Function.iterate_succ_apply'] + refine ⟨ha, hb, ?_, ?_, ?_, ?_⟩ + · change ((step^[n]) (initial q)).2.2.1 + 1 = n + 1 + rw [hj] + · change (((((((step^[n]) (initial q)).2.2.1 + 1) * + ((step^[n]) (initial q)).2.1 : ℕ) : ℤ) * + (((step^[n]) (initial q)).2.2.2.1 + + ((step^[n]) (initial q)).2.2.2.2.2) : ℤ) : ℚ) = _ + push_cast + rw [hj, hb, hA, hP] + have hden : (q.den : ℚ) ≠ 0 := by exact_mod_cast q.den_nz + have hnum : (q.num : ℚ) = q * q.den := by + calc + (q.num : ℚ) = ((q.num : ℚ) / q.den) * q.den := by field_simp + _ = q * q.den := by rw [Rat.num_div_den] + simp only [Nat.cast_mul, Nat.cast_pow, RationalExponential.taylorSum, + Finset.sum_range_succ, Nat.factorial_succ, Nat.cast_add, Nat.cast_one, + hnum, mul_pow, Int.cast_pow, pow_succ] + have hfac : (n.factorial : ℚ) ≠ 0 := by positivity + field_simp + · change (((step^[n]) (initial q)).2.2.1 + 1) * + ((step^[n]) (initial q)).2.1 * ((step^[n]) (initial q)).2.2.2.2.1 = _ + rw [hj, hb, hF, Nat.factorial_succ, pow_succ] + ring + · change ((step^[n]) (initial q)).1 * ((step^[n]) (initial q)).2.2.2.2.2 = _ + rw [ha, hP, pow_succ, mul_comm] + +def result (s : State) : ℚ := mkRat s.2.2.2.1 s.2.2.2.2.1 + +theorem result_correct (q : ℚ) (n : ℕ) : + result ((step^[n]) (initial q)) = RationalExponential.taylorSum q n := by + obtain ⟨_, _, _, hA, hF, _⟩ := iterate_initial q n + have hpos : 0 < q.den := q.pos + have hden : (n.factorial * q.den ^ n : ℚ) ≠ 0 := by positivity + unfold result + rw [Rat.mkRat_eq_div, hA, hF] + push_cast + field_simp + +def measure (s : State) : ℕ := s.1.natAbs.bits.length + s.2.1.bits.length + + s.2.2.1.bits.length + max s.2.2.2.1.natAbs.bits.length s.2.2.2.2.2.natAbs.bits.length + + s.2.2.2.2.1.bits.length + +theorem code_length (s : State) : (code s).length = + 2 * s.1.natAbs.bits.length + 2 * s.2.1.bits.length + 2 * s.2.2.1.bits.length + + 2 * s.2.2.2.1.natAbs.bits.length + 2 * s.2.2.2.2.1.bits.length + + s.2.2.2.2.2.natAbs.bits.length + 20 := by + simp only [code, prodCode, intCode, intData, pairBits_length, + Procedure.boolCode, List.length_singleton] + omega + +theorem measure_le_code (s : State) : measure s ≤ (code s).length := by + rw [code_length] + unfold measure + omega + +theorem code_le_measure (s : State) : (code s).length ≤ 3 * measure s + 20 := by + rw [code_length] + unfold measure + omega + +private theorem int_add_bits (a b : ℤ) : + (a + b).natAbs.bits.length ≤ max a.natAbs.bits.length b.natAbs.bits.length + 1 := + (bits_length_mono (Int.natAbs_add_le a b)).trans (AmplificationProgram.bits_add_max _ _) + +theorem step_measure (s : State) : measure (step s) ≤ + measure s + s.1.natAbs.bits.length + 2 * s.2.1.bits.length + 2 * s.2.2.1.bits.length + 4 := by + have hj := AmplificationProgram.bits_succ s.2.2.1 + have hf := bits_length_mul (s.2.2.1 + 1) s.2.1 + have hA := bits_length_mul ((s.2.2.1 + 1) * s.2.1) + (s.2.2.2.1 + s.2.2.2.2.2).natAbs + have ha := int_add_bits s.2.2.2.1 s.2.2.2.2.2 + have hF := bits_length_mul ((s.2.2.1 + 1) * s.2.1) s.2.2.2.2.1 + have hP := bits_length_mul s.1.natAbs s.2.2.2.2.2.natAbs + have hm : max + (((((s.2.2.1 + 1) * s.2.1 : ℕ) : ℤ) * + (s.2.2.2.1 + s.2.2.2.2.2)).natAbs.bits.length) + ((s.1 * s.2.2.2.2.2).natAbs.bits.length) ≤ + max s.2.2.2.1.natAbs.bits.length s.2.2.2.2.2.natAbs.bits.length + + s.1.natAbs.bits.length + s.2.1.bits.length + s.2.2.1.bits.length + 2 := by + simp only [Int.natAbs_mul, Int.natAbs_natCast] + apply max_le <;> omega + dsimp only [measure, step] + omega + +theorem iterate_parameters (s : State) (n : ℕ) : + ((step^[n]) s).1 = s.1 ∧ ((step^[n]) s).2.1 = s.2.1 ∧ + ((step^[n]) s).2.2.1.bits.length ≤ s.2.2.1.bits.length + n := by + induction n with + | zero => exact ⟨rfl, rfl, le_rfl⟩ + | succ n ih => + rw [Function.iterate_succ_apply'] + refine ⟨ih.1, ih.2.1, ?_⟩ + exact (AmplificationProgram.bits_succ _).trans (by omega) + +theorem iterate_measure (s : State) (n : ℕ) : + measure ((step^[n]) s) ≤ measure s + n * (5 * measure s + 2 * n + 4) := by + induction n with + | zero => simp + | succ n ih => + rw [Function.iterate_succ_apply'] + have hstep := step_measure ((step^[n]) s) + obtain ⟨ha, hb, hj⟩ := iterate_parameters s n + rw [ha, hb] at hstep + have h1 : s.1.natAbs.bits.length ≤ measure s := by unfold measure; omega + have h2 : s.2.1.bits.length ≤ measure s := by unfold measure; omega + have h3 : s.2.2.1.bits.length ≤ measure s := by unfold measure; omega + nlinarith + +theorem iterate_code_bound (n : ℕ) (s : State) (i : ℕ) (hi : i ≤ n) : + (code ((step^[i]) s)).length ≤ + (64 * (Polynomial.X + 1) ^ 2 + 100 : Polynomial ℕ).eval (n + (code s).length) := by + have hc := code_le_measure ((step^[i]) s) + have hm := iterate_measure s i + have hs := measure_le_code s + have hp := Nat.pow_le_pow_left hi 2 + have hmul := Nat.mul_le_mul hi hs + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one] + nlinarith + +end ContinuumCoulomb.RationalTaylorRegisters + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTripleQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTripleQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..766949f3996a93d32a380ee47e6b5af238e5706e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RationalTripleQuadrature.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalRectangleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteCubeQuadrature + +namespace OAI + +/-! Three-coordinate rational cubature, using the already proved literal +one- and two-coordinate summation programs. -/ + +namespace ContinuumCoulomb.RationalTripleQuadrature +open ExactQuantumFactoring.BitStackProgram + +variable {E : Type} +abbrev Input (E : Type) := RationalQuadratureProgram.Input E +abbrev Evaluator (E : Type) := E → ℚ → ℚ → ℚ → ℚ + +def augment (x : Input E) (a : ℚ) : Input (E×ℚ) := + (x.1,((x.2.1,a),x.2.2)) + +def remember (x : Input E) : Input (Input E) := (x.1,(x,x.2.2)) + +def inner (f : Evaluator E) (e : E×ℚ) (b c : ℚ) : ℚ := f e.1 e.2 b c + +def outer (f : Evaluator E) (x : Input E) (a : ℚ) : ℚ := + RationalRectangleProgram.value (inner f) (augment x a) + +def value (f : Evaluator E) (x : Input E) : ℚ := + RationalQuadratureProgram.value (outer f) (remember x) + +noncomputable opaque augmentProgram (ce : E → List Bool) : + Procedure (prodCode (RationalQuadratureProgram.inputCode ce) ratCode) + (RationalQuadratureProgram.inputCode (prodCode ce ratCode)) + (fun x => augment x.1 x.2) := by + let x := Procedure.first (RationalQuadratureProgram.inputCode ce) ratCode + let a := Procedure.second (RationalQuadratureProgram.inputCode ce) ratCode + let n := (Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce)).comp x + let env := (Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce)).comp x + let e := (Procedure.first ce (prodCode ratCode ratCode)).comp env + let mesh := (Procedure.second ce (prodCode ratCode ratCode)).comp env + exact n.pair ((e.pair a).pair mesh) + +noncomputable opaque rememberProgram (ce : E → List Bool) : + Procedure (RationalQuadratureProgram.inputCode ce) + (RationalQuadratureProgram.inputCode (RationalQuadratureProgram.inputCode ce)) remember := by + let n := Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce) + let env := Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce) + let mesh := (Procedure.second ce (prodCode ratCode ratCode)).comp env + exact n.pair ((Procedure.identity (RationalQuadratureProgram.inputCode ce)).pair mesh) + +noncomputable opaque outerProgram (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode ce ratCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Procedure (prodCode (RationalQuadratureProgram.inputCode ce) ratCode) ratCode + (fun x => outer f x.1 x.2) := + (RationalRectangleProgram.program (prodCode ce ratCode) (inner f) p).comp (augmentProgram ce) + +noncomputable opaque program (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode ce ratCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Procedure (RationalQuadratureProgram.inputCode ce) ratCode (value f) := + (RationalQuadratureProgram.program (RationalQuadratureProgram.inputCode ce) (outer f) + (outerProgram ce f p)).comp (rememberProgram ce) + +noncomputable def certificate (ce : E → List Bool) (f : Evaluator E) + (p : Procedure (prodCode (prodCode (prodCode ce ratCode) ratCode) ratCode) + ratCode (fun x => inner f x.1.1 x.1.2 x.2)) : + Turing.TM2ComputableInPolyTime (RationalQuadratureProgram.inputCode ce) ratCode (value f) := + (program ce f p).toTM2 + +theorem value_cast (f : Evaluator E) (x : Input E) : + (value f x:ℝ) = UniformQuadrature.cubeSample (x.2.2.2:ℝ) x.1 3 (fun v => + (f x.2.1 (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 (v 0)) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 (v 1)) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 (v 2)):ℝ)) := by + simp only [value,RationalQuadratureProgram.value_cast,RationalQuadratureProgram.sample, + outer,inner,remember,augment,RationalRectangleProgram.value_cast, + UniformQuadrature.cubeSample,UniformQuadrature.rectangleSum, + Fin.cons_zero,Fin.cons_one] + rfl + +end ContinuumCoulomb.RationalTripleQuadrature + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RayleighGround.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RayleighGround.lean new file mode 100644 index 0000000000000000000000000000000000000000..691a5a6e393eccd3d313dcb9a5a095fadfaec272 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RayleighGround.lean @@ -0,0 +1,31 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.FormStability +import OAI.Analysis.CoulombRadii.FormDomain.CoreKinetic + +namespace OAI + +/-! Positive-mass trial vectors give upper bounds for the exact full-domain +Coulomb infimum after normalization. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem formGroundEnergy_le_rayleigh {M n : ℕ} (S : Coulomb.Nuclei M) + (w : Coulomb.H1Vector n) (hw : Coulomb.Antisymmetric w) (hm : 0 < Coulomb.mass w) : + formGroundEnergy S n ≤ ((Coulomb.form S w/Coulomb.mass w : ℝ):EReal) := by + have h := formGroundEnergy_le_trial S ⟨w.normalized,hw.normalized⟩ + (Coulomb.mass_normalized w hm) + have he : Coulomb.form S w.normalized = Coulomb.form S w/Coulomb.mass w := by + apply (eq_div_iff (ne_of_gt hm)).mpr + simpa only [mul_comm] using Coulomb.form_normalized_weight S w + simpa only [he] using h + +theorem formGroundEnergy_finite_of_positive_mass {M n : ℕ} (S : Coulomb.Nuclei M) + (w : Coulomb.H1Vector n) (hw : Coulomb.Antisymmetric w) (hm : 0 < Coulomb.mass w) : + formGroundEnergy S n ≠ ⊤ ∧ formGroundEnergy S n ≠ ⊥ := + formGroundEnergy_finite S ⟨w.normalized,hw.normalized⟩ (Coulomb.mass_normalized w hm) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealMollification.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealMollification.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab871a0bdac9ace11ca8578bc7ca38f95df59d97 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealMollification.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SobolevDensityInput +import OAI.Analysis.CoulombRadii.FormDomain.HardyMollifier + +namespace OAI + +/-! Smooth approximation of real L² functions on the actual configuration +space. Fatou and the contraction estimate suffice; no Sobolev density input +is used. This is the scalar approximation needed for the H=W discharge. -/ + +noncomputable section +open MeasureTheory Filter ContinuousLinearMap +open scoped Topology Convolution +namespace ContinuumCoulomb + +private theorem l2_error_eventually_lt {n : ℕ} + (u : Configuration n → ℝ) (v : ℕ → Configuration n → ℝ) + (hu : MemLp u 2) (hv : ∀ k, MemLp (v k) 2) + (ht : ∀ᵐ x, Tendsto (fun k => v k x) atTop (𝓝 (u x))) + (hb : ∀ k, (∫ x, v k x ^ 2) ≤ ∫ x, u x ^ 2) + {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ k in atTop, (∫ x, (v k x-u x)^2) < ε := by + by_contra h + have hfreq : ∃ᶠ k in atTop, ε ≤ ∫ x, (v k x-u x)^2 := by + simpa only [Filter.Frequently,not_le,not_not] using h + obtain ⟨ns,hns,hbad⟩ := exists_seq_forall_of_frequently hfreq + have hsum (k : ℕ) : + (∫ x, (v k x+u x)^2)+(∫ x, (v k x-u x)^2) = + 2*(∫ x, v k x^2)+2*(∫ x, u x^2) := by + calc + _ = ∫ x, (v k x+u x)^2+(v k x-u x)^2 := + (integral_add ((hv k).add hu).integrable_sq ((hv k).sub hu).integrable_sq).symm + _ = ∫ x, 2*v k x^2+2*u x^2 := by + apply integral_congr_ae + exact Eventually.of_forall (fun _ => by ring) + _ = _ := by + rw [integral_add ((hv k).integrable_sq.const_mul 2) (hu.integrable_sq.const_mul 2), + integral_const_mul,integral_const_mul] + have hlim : ∀ᵐ x, Tendsto (fun k => (v (ns k) x+u x)^2) + atTop (𝓝 (4*u x^2)) := by + filter_upwards [ht] with x hx + have he : (u x+u x)^2 = 4*u x^2 := by ring + simpa only [Function.comp_apply,he] using ((hx.comp hns).add_const (u x)).pow 2 + have hbound (k : ℕ) : (∫ x, (v (ns k) x+u x)^2) ≤ + 4*(∫ x, u x^2)-ε := by + have hs := hsum (ns k) + have hb' := hb (ns k) + have he := hbad k + linarith + have hf := Coulomb.ae_nonneg_fatou_integrable volume (fun x => 4*u x^2) + (fun k x => (v (ns k) x+u x)^2) (4*(∫ x, u x^2)-ε) + (fun k => ((hv (ns k)).add hu).integrable_sq) + (fun k x => sq_nonneg (v (ns k) x+u x)) + (fun x => mul_nonneg (by norm_num) (sq_nonneg (u x))) + hlim hbound + rw [integral_const_mul] at hf + linarith [hf.2] + +def realMollification {n : ℕ} (u : Configuration n → ℝ) (k : ℕ) : + Configuration n → ℝ := (Coulomb.hardyMollifier k).normed volume ⋆ u + +theorem realMollification_smooth {n : ℕ} {u : Configuration n → ℝ} + (hu : MemLp u 2) (k : ℕ) : ContDiff ℝ (⊤ : ℕ∞) (realMollification u k) := + (Coulomb.hardyMollifier k).hasCompactSupport_normed.contDiff_convolution_left + (lsmul ℝ ℝ) (Coulomb.hardyMollifier k).contDiff_normed + (hu.locallyIntegrable (by norm_num)) + +theorem realMollification_contraction {n : ℕ} {u : Configuration n → ℝ} + (hu : MemLp u 2) (k : ℕ) : + MemLp (realMollification u k) 2 ∧ + (∫ x, realMollification u k x ^ 2) ≤ ∫ x, u x ^ 2 := by + have h := Coulomb.convolution_sq_integral_le + ((Coulomb.hardyMollifier k).normed volume) u + ((Coulomb.hardyMollifier k).contDiff_normed (n := (⊤ : ℕ∞))).continuous + (Coulomb.hardyMollifier k).hasCompactSupport_normed + (Coulomb.hardyMollifier k).nonneg_normed + (Coulomb.hardyMollifier k).integral_normed + (hu.locallyIntegrable (by norm_num)) hu.integrable_sq + exact ⟨(memLp_two_iff_integrable_sq + (realMollification_smooth hu k).continuous.aestronglyMeasurable).mpr h.1,h.2⟩ + +theorem realMollification_error {n : ℕ} {u : Configuration n → ℝ} + (hu : MemLp u 2) {ε : ℝ} (hε : 0 < ε) : + ∀ᶠ k in atTop, (∫ x, (realMollification u k x-u x)^2) < ε := by + apply l2_error_eventually_lt u (realMollification u) hu + (fun k => (realMollification_contraction hu k).1) ?_ + (fun k => (realMollification_contraction hu k).2) hε + apply ContDiffBump.ae_convolution_tendsto_right_of_locallyIntegrable + (φ := fun k => Coulomb.hardyMollifier k) (K := 2) + Coulomb.hardyMollifier_tendsto _ (hu.locallyIntegrable (by norm_num)) + apply Eventually.of_forall + intro k + simp only [Coulomb.hardyMollifier] + simp only [mul_one_div,le_refl] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOneElectronState.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOneElectronState.lean new file mode 100644 index 0000000000000000000000000000000000000000..383c2da3f4cb79dee8638d3998a6c40e48e37163 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOneElectronState.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronCoordinates + +namespace OAI + +/-! Real spatial functions embedded into the full spinful one-electron +weak-H1 space. This transfers nuclear form estimates to orbital products. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem real_one_electron_partial {f : Position → ℝ} (hf : ContDiff ℝ 1 f) + (a : Fin 1 × Fin 3) (x : Configuration 1) : + fderiv ℝ (fun y : Configuration 1 => (f (oneElectronCoordinates y) : ℂ)) x + (EuclideanSpace.single a 1) = + (fderiv ℝ f (oneElectronCoordinates x) (EuclideanSpace.single a.2 1) : ℂ) := by + have hd := Complex.ofRealCLM.hasFDerivAt.comp x + ((hf.differentiable (by norm_num) _).hasFDerivAt.comp x oneElectronCoordinates.toContinuousLinearEquiv.hasFDerivAt) + have hn : oneElectronCoordinates (EuclideanSpace.single a 1) = EuclideanSpace.single a.2 1 := by + rcases a with ⟨a,b⟩ + have ha : a = 0 := Subsingleton.elim _ _ + subst a + exact oneElectronCoordinates_single b + have h := congrArg (fun L : Configuration 1 →L[ℝ] ℂ => L (EuclideanSpace.single a 1)) hd.fderiv + simpa only [Function.comp_def,ContinuousLinearMap.comp_apply,Complex.ofRealCLM_apply, + ContinuousLinearEquiv.coe_coe,LinearIsometryEquiv.coe_toContinuousLinearEquiv,hn] using h + +def realOneElectronState (f : Position → ℝ) (hf : ContDiff ℝ 1 f) (hL2 : MemLp f 2) + (hd : ∀ e : Position, MemLp (fun x => fderiv ℝ f x e) 2) : Coulomb.H1Vector 1 := + classicalH1State (fun _ x => (f (oneElectronCoordinates x) : ℂ)) + (fun _ => Complex.ofRealCLM.contDiff.comp (hf.comp oneElectronCoordinates.contDiff)) + (fun _ => (hL2.comp_measurePreserving oneElectronCoordinates.measurePreserving).ofReal) + (fun _ a => by + have hm : MemLp (fun x : Configuration 1 => + (fderiv ℝ f (oneElectronCoordinates x) (EuclideanSpace.single a.2 1) : ℂ)) 2 := + ((hd (EuclideanSpace.single a.2 1)).comp_measurePreserving + oneElectronCoordinates.measurePreserving).ofReal + simpa only [real_one_electron_partial hf] using hm) + +theorem realOneElectronState_value (f : Position → ℝ) (hf : ContDiff ℝ 1 f) + (hL2 : MemLp f 2) (hd : ∀ e : Position, MemLp (fun x => fderiv ℝ f x e) 2) + (s : SpinConfiguration 1) (x : Configuration 1) : + (realOneElectronState f hf hL2 hd).value s x = (f (oneElectronCoordinates x) : ℂ) := rfl + +theorem realOneElectronState_gradient (f : Position → ℝ) (hf : ContDiff ℝ 1 f) + (hL2 : MemLp f 2) (hd : ∀ e : Position, MemLp (fun x => fderiv ℝ f x e) 2) + (s : SpinConfiguration 1) (a : Fin 1 × Fin 3) (x : Configuration 1) : + (realOneElectronState f hf hL2 hd).gradient s a x = + (fderiv ℝ f (oneElectronCoordinates x) (EuclideanSpace.single a.2 1) : ℂ) := + real_one_electron_partial hf a x + +theorem real_nuclear_integrable_transfer (F : Position → ℝ) + (hI : ∀ w : Coulomb.H1Vector 1, ∀ s : SpinConfiguration 1, + Integrable (fun x => |F (Coulomb.position x 0)| * ‖w.value s x‖^2)) + (f : Position → ℝ) (hf : ContDiff ℝ 1 f) (hL2 : MemLp f 2) + (hd : ∀ e : Position, MemLp (fun x => fderiv ℝ f x e) 2) : + Integrable (fun y => |F y| * f y^2) := by + have h := hI (realOneElectronState f hf hL2 hd) (fun _ => 0) + simp only [realOneElectronState_value,Complex.norm_real,Real.norm_eq_abs,sq_abs, + ← oneElectronCoordinates_apply] at h + exact (oneElectronCoordinates.measurePreserving.integrable_comp_emb + oneElectronCoordinates.toHomeomorph.measurableEmbedding).mp h + +theorem real_nuclear_form_transfer (F : Position → ℝ) (B : ℝ) + (hbound : ∀ w : Coulomb.H1Vector 1, ∀ s : SpinConfiguration 1, + (∫ x, |F (Coulomb.position x 0)| * ‖w.value s x‖^2) ≤ + B*((∫ x, ‖w.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖w.gradient s (0,k) x‖^2)) + (f : Position → ℝ) (hf : ContDiff ℝ 1 f) (hL2 : MemLp f 2) + (hd : ∀ e : Position, MemLp (fun x => fderiv ℝ f x e) 2) : + (∫ y, |F y| *f y^2) ≤ B*((∫ y, f y^2)+ + ∑ k : Fin 3, ∫ y, (fderiv ℝ f y (EuclideanSpace.single k 1))^2) := by + have h := hbound (realOneElectronState f hf hL2 hd) (fun _ => 0) + simp only [realOneElectronState_value,realOneElectronState_gradient,Complex.norm_real, + Real.norm_eq_abs,sq_abs] at h + have hp (x : Configuration 1) : Coulomb.position x 0 = oneElectronCoordinates x := rfl + simp_rw [hp] at h + have hF : (∫ x : Configuration 1, |F (oneElectronCoordinates x)| * f (oneElectronCoordinates x)^2) = + ∫ y, |F y| * f y^2 := oneElectronCoordinates_integral (fun y => |F y| * f y^2) + have hM : (∫ x : Configuration 1, f (oneElectronCoordinates x)^2) = ∫ y, f y^2 := + oneElectronCoordinates_integral (fun y => f y^2) + have hD (k : Fin 3) : (∫ x : Configuration 1, + (fderiv ℝ f (oneElectronCoordinates x) (EuclideanSpace.single k 1))^2) = + ∫ y, (fderiv ℝ f y (EuclideanSpace.single k 1))^2 := + oneElectronCoordinates_integral (fun y => (fderiv ℝ f y (EuclideanSpace.single k 1))^2) + rw [hF,hM] at h + simp_rw [hD] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOrbitalResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOrbitalResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..465f5c54a6cc27d302c4e4562ff13d97c023492c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealOrbitalResidual.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Laplacian +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.H1PairingBound + +namespace OAI + +/-! Weak form of a real one-electron orbital's differential residual. +This is used for finite corrected combinations of the manufactured modes. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def realOrbitalPairing (V : Configuration 1 → ℝ) (E : ℝ) + (φ : Configuration 1 → ℝ) (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : ℂ := + (1/2:ℂ)*(∑ a, ∫ x, v.gradient s a x*(configurationRealPartial φ a x : ℂ))+ + (∫ x, v.value s x*(V x*φ x : ℝ))-(E:ℂ)*(∫ x, v.value s x*(φ x : ℂ)) + +theorem realOrbitalPairing_eq_residual (hdensity : PublishedSobolevSmoothDensity) + (V : Configuration 1 → ℝ) (E : ℝ) (φ R : Configuration 1 → ℝ) + (hφ : ContDiff ℝ 2 φ) (hm : MemLp φ 2) + (hp : ∀ a, MemLp (configurationRealPartial φ a) 2) + (hV : MemLp (fun x => V x*φ x) 2) (hR : MemLp R 2) + (heq : ∀ x, R x = -(1/2:ℝ)*configurationRealLaplacian φ x+V x*φ x-E*φ x) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + realOrbitalPairing V E φ v s = ∫ x, v.value s x*(R x : ℂ) := by + have hL : MemLp (configurationRealLaplacian φ) 2 := by + have he : configurationRealLaplacian φ = (fun x => 2*(V x*φ x-E*φ x-R x)) := by + funext x + linarith [heq x] + rw [he] + exact ((hV.sub (hm.const_mul E)).sub hR).const_mul 2 + have hi := weakH1_laplacian_pairing hdensity φ hφ hp hL v s + have hLI := (v.value_L2 s).integrable_mul hL.ofReal + have hVI := (v.value_L2 s).integrable_mul hV.ofReal + have hPI := (v.value_L2 s).integrable_mul hm.ofReal + have he (x : Configuration 1) : v.value s x*(R x : ℂ) = + (-1/2:ℂ)*(v.value s x*(configurationRealLaplacian φ x : ℂ))+ + v.value s x*(V x*φ x : ℝ)-(E:ℂ)*(v.value s x*(φ x : ℂ)) := by + rw [heq x] + push_cast + ring + unfold realOrbitalPairing + simp_rw [he] + have hsub := integral_sub ((hLI.const_mul (-1/2:ℂ)).add hVI) (hPI.const_mul (E:ℂ)) + have hadd := integral_add (hLI.const_mul (-1/2:ℂ)) hVI + simp only [Pi.add_apply,Pi.mul_apply] at hsub hadd + rw [hadd,integral_const_mul,integral_const_mul] at hsub + rw [hi] + let A : ℂ := ∫ x, v.value s x*(configurationRealLaplacian φ x : ℂ) + let B : ℂ := ∫ x, v.value s x*(V x*φ x : ℝ) + let C : ℂ := ∫ x, v.value s x*(φ x : ℂ) + change _ = (-1/2:ℂ)*A+B-(E:ℂ)*C at hsub + change (1/2:ℂ)*(-A)+B-(E:ℂ)*C = _ + calc + _ = (-1/2:ℂ)*A+B-(E:ℂ)*C := by ring + _ = _ := hsub.symm + +theorem realOrbitalPairing_square_bound (hdensity : PublishedSobolevSmoothDensity) + (V : Configuration 1 → ℝ) (E : ℝ) (φ R : Configuration 1 → ℝ) + (hφ : ContDiff ℝ 2 φ) (hm : MemLp φ 2) + (hp : ∀ a, MemLp (configurationRealPartial φ a) 2) + (hV : MemLp (fun x => V x*φ x) 2) (hR : MemLp R 2) + (heq : ∀ x, R x = -(1/2:ℝ)*configurationRealLaplacian φ x+V x*φ x-E*φ x) + (v : Coulomb.H1Vector 1) (s : SpinConfiguration 1) : + ‖realOrbitalPairing V E φ v s‖^2 ≤ (∫ x, R x^2)*(∫ x, ‖v.value s x‖^2) := by + rw [realOrbitalPairing_eq_residual hdensity V E φ R hφ hm hp hV hR heq] + exact h1_real_pairing_sq_le v s R hR + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealSpinOrbitals.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealSpinOrbitals.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a2d27986a7b7d2931eda8f6b53d72aa44073416 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RealSpinOrbitals.lean @@ -0,0 +1,118 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalSlaterKinetic + +namespace OAI + +/-! Spin lifting of real C1 orbitals into the actual fermionic weak-H1 +domain. Any injective list of occupied orthonormal spatial/spin modes +gives a normalized antisymmetric state on the full configuration space. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +def realSpinOrbital (f : Position → ℝ) (σ : Fin 2) (x : Position) (s : Fin 2) : ℂ := + if s = σ then (f x : ℂ) else 0 + +theorem realSpinOrbital_C1 (f : Position → ℝ) (hf : ContDiff ℝ 1 f) (σ s : Fin 2) : + ContDiff ℝ 1 (fun x => realSpinOrbital f σ x s) := by + by_cases h : s = σ + · simpa only [realSpinOrbital, h, ite_true, Function.comp_def, Complex.ofRealCLM_apply] using Complex.ofRealCLM.contDiff.comp hf + · simpa only [realSpinOrbital, h, ite_false] using (contDiff_const : ContDiff ℝ 1 (fun _ : Position => (0 : ℂ))) + +theorem realSpinOrbital_memLp (f : Position → ℝ) (hf : MemLp f 2) (σ s : Fin 2) : + MemLp (fun x => realSpinOrbital f σ x s) 2 := by + by_cases h : s = σ + · simp only [realSpinOrbital, h, ite_true] + exact hf.ofReal + · simp only [realSpinOrbital, h, ite_false] + exact MemLp.zero + +theorem realSpinOrbital_fderiv (f : Position → ℝ) (hf : ContDiff ℝ 1 f) + (σ s : Fin 2) (x e : Position) : + fderiv ℝ (fun y => realSpinOrbital f σ y s) x e = + if s = σ then (fderiv ℝ f x e : ℂ) else 0 := by + by_cases h : s = σ + · simp only [realSpinOrbital, h, ite_true] + exact congrArg (fun L : Position →L[ℝ] ℂ => L e) + (Complex.ofRealCLM.hasFDerivAt.comp x (hf.differentiable (by norm_num) x).hasFDerivAt).fderiv + · simp [realSpinOrbital, h] + +theorem realSpinOrbital_partial_memLp (f : Position → ℝ) (hf : ContDiff ℝ 1 f) + (hd : ∀ b : Fin 3, MemLp (fun x => fderiv ℝ f x (EuclideanSpace.single b 1)) 2) + (σ s : Fin 2) (b : Fin 3) : + MemLp (fun x => fderiv ℝ (fun y => realSpinOrbital f σ y s) x (EuclideanSpace.single b 1)) 2 := by + simp_rw [realSpinOrbital_fderiv f hf] + by_cases h : s = σ + · simp only [h, ite_true] + exact (hd b).ofReal + · simp only [h, ite_false] + exact MemLp.zero + +theorem realSpinOrbital_inner (f g : Position → ℝ) (σ τ : Fin 2) : + (∑ s : Fin 2, ∫ x, star (realSpinOrbital f σ x s) * realSpinOrbital g τ x s) = + if σ = τ then (↑(∫ x, f x * g x) : ℂ) else 0 := by + by_cases h : σ = τ + · subst τ + have hp (s : Fin 2) : + (∫ x, star (realSpinOrbital f σ x s) * realSpinOrbital g σ x s) = + if s=σ then (↑(∫ x, f x*g x) : ℂ) else 0 := by + by_cases hs : s=σ + · subst s + simp only [realSpinOrbital, ite_true, Complex.star_def, Complex.conj_ofReal, + ← Complex.ofReal_mul, integral_complex_ofReal] + · simp [realSpinOrbital, hs] + simp only [hp, Finset.sum_ite_eq', Finset.mem_univ, ite_true] + · have hz (s : Fin 2) (x : Position) : star (realSpinOrbital f σ x s) * realSpinOrbital g τ x s = 0 := by + by_cases hs : s = σ + · subst s + simp [realSpinOrbital, h] + · simp [realSpinOrbital, hs] + simp only [hz, integral_zero, Finset.sum_const_zero, h, ite_false] + +theorem selectedRealSpinOrbitals_orthonormal {α : Type*} {n : ℕ} + (f : α → Position → ℝ) + (ho : ∀ i j, (∫ x, f i x * f j x) = if i = j then (1 : ℝ) else 0) + (p : Fin n → α × Fin 2) (hp : Function.Injective p) (i j : Fin n) : + (∑ s : Fin 2, ∫ x, star (realSpinOrbital (f (p i).1) (p i).2 x s) * + realSpinOrbital (f (p j).1) (p j).2 x s) = if i = j then (1 : ℂ) else 0 := by + classical + rw [realSpinOrbital_inner, ho] + by_cases hij : i = j + · subst j + simp + · by_cases hs : (p i).2 = (p j).2 + · have hf : (p i).1 ≠ (p j).1 := by + intro hf + exact hij (hp (Prod.ext hf hs)) + simp only [hs, hf, hij, ite_true, ite_false, Complex.ofReal_zero] + · simp only [hs, hij, ite_false] + +def selectedRealSlaterState {α : Type*} {n : ℕ} (f : α → Position → ℝ) + (hf : ∀ i, ContDiff ℝ 1 (f i)) (hL2 : ∀ i, MemLp (f i) 2) + (hd : ∀ i b, MemLp (fun x => fderiv ℝ (f i) x (EuclideanSpace.single b 1)) 2) + (p : Fin n → α × Fin 2) : Coulomb.H1Vector n := + classicalSlaterState (fun i => realSpinOrbital (f (p i).1) (p i).2) + (fun i s => realSpinOrbital_C1 _ (hf (p i).1) _ s) + (fun i s => realSpinOrbital_memLp _ (hL2 (p i).1) _ s) + (fun i s b => realSpinOrbital_partial_memLp _ (hf (p i).1) (hd (p i).1) _ s b) + +theorem selectedRealSlaterState_antisymmetric {α : Type*} {n : ℕ} + (f : α → Position → ℝ) (hf : ∀ i, ContDiff ℝ 1 (f i)) (hL2 : ∀ i, MemLp (f i) 2) + (hd : ∀ i b, MemLp (fun x => fderiv ℝ (f i) x (EuclideanSpace.single b 1)) 2) + (p : Fin n → α × Fin 2) : Coulomb.Antisymmetric (selectedRealSlaterState f hf hL2 hd p) := + classicalSlaterState_antisymmetric _ _ _ _ + +theorem selectedRealSlaterState_normalized {α : Type*} {n : ℕ} + (f : α → Position → ℝ) (hf : ∀ i, ContDiff ℝ 1 (f i)) (hL2 : ∀ i, MemLp (f i) 2) + (hd : ∀ i b, MemLp (fun x => fderiv ℝ (f i) x (EuclideanSpace.single b 1)) 2) + (ho : ∀ i j, (∫ x, f i x * f j x) = if i = j then (1 : ℝ) else 0) + (p : Fin n → α × Fin 2) (hp : Function.Injective p) : + Coulomb.mass (selectedRealSlaterState f hf hL2 hd p) = 1 := + classicalSlaterState_normalized _ _ _ _ (selectedRealSpinOrbitals_orthonormal f ho p hp) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RectangleQuadrature.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RectangleQuadrature.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0475f0054b14894f18017fb6907ab0a7fde2b13 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/RectangleQuadrature.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.UniformSamplesOn + +namespace OAI + +/-! Quantitative tensor quadrature in two coordinates, with independent +coordinate moduli and errors in each computed sample. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb.UniformQuadrature + +theorem node_mem {a h : ℝ} {N i : ℕ} (hh : 0 ≤ h) (hi : i ≤ N) : + node a h i ∈ Set.Icc a (node a h N) := by + constructor + · dsimp only [node] + linarith [mul_nonneg (Nat.cast_nonneg i) hh] + · dsimp only [node] + exact add_le_add_right (mul_le_mul_of_nonneg_right (by exact_mod_cast hi) hh) a + +def rectangleSum (hx hy : ℝ) (Nx Ny : ℕ) (v : ℕ → ℕ → ℝ) : ℝ := + sampleSum hx Nx (fun i => sampleSum hy Ny (v i)) + +theorem rectangle_error (f : ℝ → ℝ → ℝ) (v : ℕ → ℕ → ℝ) + (a hx : ℝ) (Nx : ℕ) (b hy : ℝ) (Ny : ℕ) {Lx Ly ε : ℝ} + (hhx : 0 ≤ hx) (hhy : 0 ≤ hy) (hLx : 0 ≤ Lx) (hLy : 0 ≤ Ly) + (hLipX : ∀ x ∈ Set.Icc a (node a hx Nx), ∀ x' ∈ Set.Icc a (node a hx Nx), + ∀ y ∈ Set.Icc b (node b hy Ny), |f x y - f x' y| ≤ Lx * |x - x'|) + (hLipY : ∀ x ∈ Set.Icc a (node a hx Nx), ∀ y ∈ Set.Icc b (node b hy Ny), + ∀ y' ∈ Set.Icc b (node b hy Ny), |f x y - f x y'| ≤ Ly * |y - y'|) + (heval : ∀ i < Nx, ∀ j < Ny, + |v i j - f (node a hx i) (node b hy j)| ≤ ε) : + |rectangleSum hx hy Nx Ny v - + ∫ x in a..node a hx Nx, ∫ y in b..node b hy Ny, f x y| ≤ + ((Nx : ℝ) * hx) * ((Ny : ℝ) * hy) * (Lx * hx + Ly * hy + ε) := by + have hylen : node b hy Ny - b = (Ny : ℝ) * hy := by dsimp [node]; ring + have hys : b ≤ node b hy Ny := (node_mem hhy (Nat.le_refl Ny)).1 + have hL : 0 ≤ ((Ny : ℝ) * hy) * Lx := by positivity + have hsection : ∀ x ∈ Set.Icc a (node a hx Nx), + ContinuousOn (f x) (Set.Icc b (node b hy Ny)) := by + intro x hx' + exact continuousOn_of_abs_sub_le (hLipY x hx') + have houterLip : ∀ x ∈ Set.Icc a (node a hx Nx), + ∀ x' ∈ Set.Icc a (node a hx Nx), + |(∫ y in b..node b hy Ny, f x y) - ∫ y in b..node b hy Ny, f x' y| ≤ + (((Ny : ℝ) * hy) * Lx) * |x - x'| := by + intro x hx' x' hx'' + have h := integral_parameter_lipschitz f hys hsection hLipX hx' hx'' + simpa only [hylen] using h + have hinner : ∀ i < Nx, + |sampleSum hy Ny (v i) - ∫ y in b..node b hy Ny, f (node a hx i) y| ≤ + ((Ny : ℝ) * hy) * (Ly * hy + ε) := by + intro i hi + have h := samples_error_lipschitz (f (node a hx i)) (v i) b hy Ny hhy hLy + (hLipY (node a hx i) (node_mem hhx hi.le)) (heval i hi) + convert h using 1 + ring + have h := samples_error_lipschitz (fun x => ∫ y in b..node b hy Ny, f x y) + (fun i => sampleSum hy Ny (v i)) a hx Nx hhx hL houterLip hinner + change |rectangleSum hx hy Nx Ny v - _| ≤ _ at h + convert h using 1 + ring + +end ContinuumCoulomb.UniformQuadrature + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventNumericalBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventNumericalBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..967b5fff5545497f4280cdc76f282b11ca4831c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventNumericalBounds.lean @@ -0,0 +1,173 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalResolventError +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ResolventSchedule + +namespace OAI + +/-! Elementary quantitative bounds for the fixed polynomial schedule. +These estimates keep all mesh choices explicit. -/ + +noncomputable section +namespace ContinuumCoulomb.ResolventSchedule + +theorem succ_le_two_pow (n : ℕ) : n + 1 ≤ 2 ^ n := by + induction n with + | zero => norm_num + | succ n ih => + rw [pow_succ] + omega + +theorem taylor_precision_bound (Q : ℕ) (hQ : 1 ≤ Q) : + (Q : ℝ) ^ 2 * (2 ^ (4 * Q) : ℝ)⁻¹ ≤ (Q : ℝ)⁻¹ := by + have hn : Q ^ 3 ≤ 2 ^ (4 * Q) := by + calc + Q ^ 3 ≤ Q ^ 4 := pow_le_pow_right₀ hQ (by norm_num) + _ ≤ (Q + 1) ^ 4 := Nat.pow_le_pow_left (by omega) 4 + _ ≤ (2 ^ Q) ^ 4 := Nat.pow_le_pow_left (succ_le_two_pow Q) 4 + _ = 2 ^ (4 * Q) := by rw [← pow_mul]; congr 1; omega + have hQr : (0 : ℝ) < Q := by exact_mod_cast (lt_of_lt_of_le Nat.zero_lt_one hQ) + have hnr : (Q : ℝ) ^ 3 ≤ 2 ^ (4 * Q) := by exact_mod_cast hn + have hp : (0 : ℝ) < 2 ^ (4 * Q) := by positivity + apply (mul_le_mul_iff_left₀ hQr).mp + rw [inv_mul_cancel₀ hQr.ne'] + calc + (Q : ℝ) ^ 2 * (2 ^ (4 * Q) : ℝ)⁻¹ * Q = Q ^ 3 / (2 ^ (4 * Q) : ℝ) := by ring + _ ≤ 1 := (div_le_one hp).mpr hnr + +theorem exp_tail_le_inverse {Q : ℝ} (hQ : 0 < Q) : Real.exp (-Q) ≤ Q⁻¹ := by + rw [Real.exp_neg] + exact inv_anti₀ hQ (by linarith [Real.add_one_le_exp Q]) + +theorem mesh_fraction_bound {A Q : ℝ} (hA : 1 ≤ A) (hQ : 1 ≤ Q) : + (4 * A ^ 2 * Q ^ 5 + 192 * A * Q ^ 3 + 8 * Q ^ 2) / + (4096 * A ^ 4 * Q ^ 8) ≤ Q⁻¹ := by + have hA0 : 0 < A := by linarith + have hQ0 : 0 < Q := by linarith + have hN : 0 < 4096 * A ^ 4 * Q ^ 8 := by positivity + have h₂ : A ^ 2 * Q ^ 6 ≤ A ^ 4 * Q ^ 8 := + mul_le_mul (pow_le_pow_right₀ hA (by norm_num)) (pow_le_pow_right₀ hQ (by norm_num)) + (by positivity) (by positivity) + have h₁ : A * Q ^ 4 ≤ A ^ 4 * Q ^ 8 := by + have ha : A ≤ A ^ 4 := by simpa using pow_le_pow_right₀ hA (show 1 ≤ 4 by norm_num) + exact mul_le_mul ha (pow_le_pow_right₀ hQ (by norm_num)) (by positivity) (by positivity) + have h₀ : Q ^ 3 ≤ A ^ 4 * Q ^ 8 := by + calc + Q ^ 3 ≤ Q ^ 8 := pow_le_pow_right₀ hQ (by norm_num) + _ ≤ A ^ 4 * Q ^ 8 := le_mul_of_one_le_left (by positivity) (one_le_pow₀ hA) + have hn : (4 * A ^ 2 * Q ^ 5 + 192 * A * Q ^ 3 + 8 * Q ^ 2) * Q ≤ + 4096 * A ^ 4 * Q ^ 8 := by + calc + _ = 4 * (A ^ 2 * Q ^ 6) + 192 * (A * Q ^ 4) + 8 * Q ^ 3 := by ring + _ ≤ 204 * (A ^ 4 * Q ^ 8) := by linarith + _ ≤ _ := by nlinarith [show 0 ≤ A ^ 4 * Q ^ 8 by positivity] + calc + _ ≤ ((4096 * A ^ 4 * Q ^ 8) / Q) / (4096 * A ^ 4 * Q ^ 8) := + div_le_div_of_nonneg_right ((le_div_iff₀ hQ0).mpr hn) hN.le + _ = Q⁻¹ := by field_simp + +theorem spatial_constant_bound (r : PlanarPosition) {R Q : ℝ} + (hR : ‖r‖ ≤ R) (hQ : 1 ≤ Q) : + planarBoxSpatialConstant r Q⁻¹ ≤ 12 * (R + 3) * Q ^ 2 := by + have hR0 : 0 ≤ R := (norm_nonneg r).trans hR + have hQsq : Q ≤ Q ^ 2 := by nlinarith + have hmain := mul_le_mul_of_nonneg_right (show 2 * (‖r‖ + 2) ≤ 2 * (R + 2) by linarith) + (sq_nonneg Q) + have hnonneg := mul_nonneg hR0 (sq_nonneg Q) + simp only [planarBoxSpatialConstant, inv_inv, inv_pow, div_inv_eq_mul] + nlinarith + +theorem time_constant_bound (r : PlanarPosition) {R Q : ℝ} + (hR : ‖r‖ ≤ R) (hQ : 1 ≤ Q) : + planarBoxTimeConstant r Q⁻¹ ≤ (R + 3) ^ 2 * Q ^ 3 := by + have hR0 : 0 ≤ R := (norm_nonneg r).trans hR + have hQ0 : 0 ≤ Q := by linarith + have hQ2 : Q ^ 2 ≤ Q ^ 3 := by nlinarith + have hQ1 : Q ≤ Q ^ 3 := by nlinarith + have hsquare : (‖r‖ + 2) ^ 2 ≤ (R + 2) ^ 2 := + (sq_le_sq₀ (by positivity) (by positivity)).mpr (by linarith) + have hc : 2 + (‖r‖ + 2) ^ 2 / 4 ≤ (R + 3) ^ 2 := by nlinarith + have hm := mul_le_mul_of_nonneg_right hc (show 0 ≤ Q ^ 3 by positivity) + have hQne : Q ≠ 0 := by linarith + have heq : planarBoxTimeConstant r Q⁻¹ = + Q ^ 2 + Q + (‖r‖ + 2) ^ 2 * Q ^ 3 / 4 := by + unfold planarBoxTimeConstant + field_simp [hQne] + ring + rw [heq] + nlinarith + +theorem scalar_error_bound {A Q N w Lt Ls e : ℝ} + (hA : 1 ≤ A) (hQ : 1 ≤ Q) (hN : N = 4096 * A ^ 4 * Q ^ 8) + (hw0 : 0 ≤ w) (hw : w ≤ Q) + (hLt : Lt ≤ A ^ 2 * Q ^ 3) (hLs : Ls ≤ 12 * A * Q ^ 2) + (he0 : 0 ≤ e) (he : Q ^ 2 * e ≤ Q⁻¹) : + N * (4 * Lt * (w / N) ^ 2 + (w / N) * + (4 * (2 * Ls * (2 / N) + (e + 8 / N) / (4 * Q⁻¹)))) + + Q⁻¹ + Real.exp (-Q) ≤ 4 * Q⁻¹ := by + have hQ0 : 0 < Q := by linarith + have hA0 : 0 < A := by linarith + have hN0 : 0 < N := by rw [hN]; positivity + have hw2 : w ^ 2 ≤ Q ^ 2 := (sq_le_sq₀ hw0 hQ0.le).mpr hw + have h₁ := mul_le_mul hLt hw2 (sq_nonneg w) (show 0 ≤ A ^ 2 * Q ^ 3 by positivity) + have h₂ := mul_le_mul hLs hw hw0 (show 0 ≤ 12 * A * Q ^ 2 by positivity) + have h₃ := mul_le_mul_of_nonneg_left hw hQ0.le + have hnum : 4 * Lt * w ^ 2 + 16 * Ls * w + 8 * Q * w ≤ + 4 * A ^ 2 * Q ^ 5 + 192 * A * Q ^ 3 + 8 * Q ^ 2 := by + nlinarith + have hmesh : (4 * Lt * w ^ 2 + 16 * Ls * w + 8 * Q * w) / N ≤ Q⁻¹ := by + apply (div_le_div_of_nonneg_right hnum hN0.le).trans + rw [hN] + exact mesh_fraction_bound hA hQ + have hsample : Q * w * e ≤ Q⁻¹ := + (mul_le_mul_of_nonneg_right (show Q * w ≤ Q ^ 2 by nlinarith [h₃]) he0).trans he + have hid : N * (4 * Lt * (w / N) ^ 2 + (w / N) * + (4 * (2 * Ls * (2 / N) + (e + 8 / N) / (4 * Q⁻¹)))) = + (4 * Lt * w ^ 2 + 16 * Ls * w + 8 * Q * w) / N + Q * w * e := by + field_simp [hN0.ne', hQ0.ne'] + ring + rw [hid] + linarith [exp_tail_le_inverse hQ0] + +theorem argument_endpoint (x : Input) : + RationalHeatBox.timeEndpoint (argument x) = (scale x.1.2 : ℚ) := by + have hN : (count x.1.1 x.1.2 : ℚ) ≠ 0 := by + exact_mod_cast (count_positive x.1.1 x.1.2).ne' + have hQ : (scale x.1.2 : ℚ) ≠ 0 := by + exact_mod_cast (scale_positive x.1.2).ne' + change (scale x.1.2 : ℚ)⁻¹ + (count x.1.1 x.1.2 : ℚ) * + (((scale x.1.2 : ℚ) - (scale x.1.2 : ℚ)⁻¹) / count x.1.1 x.1.2) = _ + field_simp [hN, hQ] + ring + +theorem argument_start_positive (x : Input) : 0 < ((argument x).2.2.1 : ℝ) := by + have hQ := scale_positive x.1.2 + change 0 < (((scale x.1.2 : ℚ)⁻¹ : ℚ) : ℝ) + rw [Rat.cast_inv, Rat.cast_natCast] + positivity + +theorem argument_step_nonnegative (x : Input) : 0 ≤ ((argument x).2.2.2 : ℝ) := by + have hQ : (1 : ℚ) ≤ scale x.1.2 := by + exact_mod_cast (Nat.succ_le_iff.mpr (scale_positive x.1.2)) + have hN : (0 : ℚ) < count x.1.1 x.1.2 := by exact_mod_cast count_positive x.1.1 x.1.2 + have hi : (scale x.1.2 : ℚ)⁻¹ ≤ 1 := (inv_le_one₀ (by linarith)).mpr hQ + have hh : 0 ≤ ((scale x.1.2 : ℚ) - (scale x.1.2 : ℚ)⁻¹) / count x.1.1 x.1.2 := + div_nonneg (by linarith) hN.le + exact_mod_cast hh + +theorem magnitude_bound (r : PlanarPosition) {R Q : ℝ} + (hR : ‖r‖ ≤ R) (hQ : 0 < Q) : + Q + (‖r‖ + 2) ^ 2 / (4 * Q⁻¹) ≤ (R + 3) ^ 2 * Q := by + have hR0 : 0 ≤ R := (norm_nonneg r).trans hR + have hsquare : (‖r‖ + 2) ^ 2 ≤ (R + 2) ^ 2 := + (sq_le_sq₀ (by positivity) (by positivity)).mpr (by linarith) + have hc : 1 + (‖r‖ + 2) ^ 2 / 4 ≤ (R + 3) ^ 2 := by nlinarith + have hm := mul_le_mul_of_nonneg_right hc hQ.le + have hid : Q + (‖r‖ + 2) ^ 2 / (4 * Q⁻¹) = + (1 + (‖r‖ + 2) ^ 2 / 4) * Q := by field_simp [hQ.ne'] + rw [hid] + exact hm + +end ContinuumCoulomb.ResolventSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..11a296c985cb064f56b2d1ef7b3a6e45018041b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ResolventSchedule.lean @@ -0,0 +1,138 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalHeatBox + +namespace OAI + +/-! Literal polynomial-sized mesh and precision choices for the resolvent +quadrature. The radius and requested inverse accuracy are unary inputs. -/ + +namespace ContinuumCoulomb.ResolventSchedule +open ExactQuantumFactoring.BitStackProgram + +def scale (P : ℕ) : ℕ := 16 * (P + 1) +def countPrefix (R : ℕ) : ℕ := 4096 * (R + 3) ^ 4 +def count (R P : ℕ) : ℕ := countPrefix R * scale P ^ 8 +def magnitude (R P : ℕ) : ℕ := (R + 3) ^ 2 * scale P +def precision (P : ℕ) : ℕ := 4 * scale P + +abbrev Input := (ℕ × ℕ) × RationalHeatSample.Point +def inputCode : Input → List Bool := + prodCode (prodCode unaryCode unaryCode) RationalHeatSample.pointCode + +def argument (x : Input) : RationalHeatBox.Input := + let R := x.1.1 + let P := x.1.2 + let N := count R P + let Q := (scale P : ℚ) + (N, (((magnitude R P, (precision P, N)), (x.2, N)), (Q⁻¹, (Q - Q⁻¹) / N))) + +def approximate (x : Input) : ℚ := RationalHeatBox.value (argument x) + +noncomputable opaque mulProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => x.1 * x.2) := Procedure.unaryMul + +noncomputable opaque addProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => x.1 + x.2) := Procedure.unaryAdd + +noncomputable opaque scaleProgram : Procedure unaryCode unaryCode scale := by + let sixteen := Procedure.constant unaryCode unaryCode 16 + exact (mulProgram.comp (sixteen.pair Procedure.unarySuccessor)).congrFun + (by intro P; rfl) + +noncomputable opaque squareProgram : Procedure unaryCode unaryCode (fun n => n ^ 2) := + (mulProgram.comp ((Procedure.identity unaryCode).pair (Procedure.identity unaryCode))).congrFun + (by intro n; exact (pow_two n).symm) + +noncomputable opaque fourthProgram : Procedure unaryCode unaryCode (fun n => n ^ 4) := + (squareProgram.comp squareProgram).congrFun (by intro n; dsimp; ring) + +noncomputable opaque eighthProgram : Procedure unaryCode unaryCode (fun n => n ^ 8) := + (squareProgram.comp fourthProgram).congrFun (by intro n; dsimp; ring) + +noncomputable opaque constant4096Program : + Procedure (prodCode unaryCode unaryCode) unaryCode (fun _ => 4096) := + (fourthProgram.comp (Procedure.constant (prodCode unaryCode unaryCode) unaryCode 8)).congrFun + (by intro x; norm_num) + +noncomputable opaque radiusOffsetProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x : ℕ × ℕ => x.1 + 3) := + (addProgram.comp ((Procedure.first unaryCode unaryCode).pair + (Procedure.constant (prodCode unaryCode unaryCode) unaryCode 3))).congrFun + (by intro x; rfl) + +noncomputable opaque radiusFourthProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x : ℕ × ℕ => (x.1 + 3) ^ 4) := + fourthProgram.comp radiusOffsetProgram + +noncomputable opaque scaleEighthProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x : ℕ × ℕ => scale x.2 ^ 8) := + eighthProgram.comp (scaleProgram.comp (Procedure.second unaryCode unaryCode)) + +noncomputable opaque countPrefixProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x : ℕ × ℕ => countPrefix x.1) := + (mulProgram.comp (constant4096Program.pair radiusFourthProgram)).congrFun + (by intro x; rfl) + +noncomputable opaque countFactorsProgram : + Procedure (prodCode unaryCode unaryCode) (prodCode unaryCode unaryCode) + (fun x : ℕ × ℕ => (countPrefix x.1, scale x.2 ^ 8)) := + countPrefixProgram.pair scaleEighthProgram + +noncomputable opaque countRawProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x : ℕ × ℕ => countPrefix x.1 * scale x.2 ^ 8) := + mulProgram.comp countFactorsProgram + +theorem count_value (x : ℕ × ℕ) : countPrefix x.1 * scale x.2 ^ 8 = count x.1 x.2 := by + unfold count + rfl + +noncomputable opaque countProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => count x.1 x.2) := countRawProgram.congrFun count_value + +noncomputable opaque magnitudeProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => magnitude x.1 x.2) := by + let R := Procedure.first unaryCode unaryCode + let Q := scaleProgram.comp (Procedure.second unaryCode unaryCode) + let three := Procedure.constant (prodCode unaryCode unaryCode) unaryCode 3 + let R3 := addProgram.comp (R.pair three) + let square := squareProgram.comp R3 + exact (mulProgram.comp (square.pair Q)).congrFun (by + intro x + rfl) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode precision := by + let four := Procedure.constant unaryCode unaryCode 4 + exact (mulProgram.comp (four.pair scaleProgram)).congrFun (by intro P; rfl) + +noncomputable opaque argumentProgram : + Procedure inputCode RationalHeatBox.inputCode argument := by + let rp := Procedure.first (prodCode unaryCode unaryCode) RationalHeatSample.pointCode + let point := Procedure.second (prodCode unaryCode unaryCode) RationalHeatSample.pointCode + let P := (Procedure.second unaryCode unaryCode).comp rp + let Q := scaleProgram.comp P + let N := countProgram.comp rp + let M := magnitudeProgram.comp rp + let p := precisionProgram.comp P + let Qrat := Procedure.natToRat.comp (Procedure.unaryToBits.comp Q) + let Nrat := Procedure.natToRat.comp (Procedure.unaryToBits.comp N) + let eta := Procedure.ratInv.comp Qrat + let width := Procedure.ratSub.comp (Qrat.pair eta) + let step := Procedure.ratDiv.comp (width.pair Nrat) + let settings := (M.pair (p.pair N)).pair (point.pair N) + exact (N.pair (settings.pair (eta.pair step))).congrFun (by intro x; rfl) + +noncomputable opaque program : Procedure inputCode ExactQuantumFactoring.BitStackProgram.ratCode approximate := + (RationalHeatBox.program.comp argumentProgram).congrFun (by intro x; rfl) + +noncomputable opaque certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode approximate := program.toTM2 + +theorem scale_positive (P : ℕ) : 0 < scale P := by unfold scale; omega + +theorem count_positive (R P : ℕ) : 0 < count R P := by + have hscale := scale_positive P + unfold count countPrefix + positivity + +end ContinuumCoulomb.ResolventSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarMollification.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarMollification.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c4d8047d99ab299ca5f88bc85286fc8259fe90b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarMollification.lean @@ -0,0 +1,71 @@ +import Mathlib.Analysis.Calculus.BumpFunction.Convolution +import Mathlib.Analysis.Calculus.ContDiff.Convolution +import Mathlib.Analysis.Calculus.Deriv.Support + +namespace OAI + +/-! Compact smooth approximation on the real line, including its derivative. +Only the one-dimensional approximation needed by the oscillator is built. -/ + +noncomputable section +open MeasureTheory Filter ContinuousLinearMap +open scoped Topology Convolution ContDiff +namespace ContinuumCoulomb + +def scalarMollifier (k : ℕ) : ContDiffBump (0 : ℝ) where + rIn := 1/((k:ℝ)+1) + rOut := 2/((k:ℝ)+1) + rIn_pos := one_div_pos.mpr (by positivity) + rIn_lt_rOut := div_lt_div_of_pos_right (by norm_num) (by positivity) + +theorem scalarMollifier_tendsto : + Tendsto (fun k => (scalarMollifier k).rOut) atTop (𝓝 0) := by + have h := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).const_mul 2 + simpa only [scalarMollifier,mul_one_div,mul_zero] using h + +def scalarMollification (f : ℝ → ℝ) (k : ℕ) : ℝ → ℝ := + (scalarMollifier k).normed volume ⋆ f + +theorem scalarMollification_smooth {f : ℝ → ℝ} (hf : Continuous f) (k : ℕ) : + ContDiff ℝ ∞ (scalarMollification f k) := + (scalarMollifier k).hasCompactSupport_normed.contDiff_convolution_left + (lsmul ℝ ℝ) (scalarMollifier k).contDiff_normed hf.locallyIntegrable + +theorem scalarMollification_compact {f : ℝ → ℝ} (hf : HasCompactSupport f) (k : ℕ) : + HasCompactSupport (scalarMollification f k) := + (scalarMollifier k).hasCompactSupport_normed.convolution (lsmul ℝ ℝ) hf + +theorem scalarMollification_tendsto {f : ℝ → ℝ} (hf : Continuous f) (z : ℝ) : + Tendsto (fun k => scalarMollification f k z) atTop (𝓝 (f z)) := + ContDiffBump.convolution_tendsto_right_of_continuous scalarMollifier_tendsto hf z + +theorem scalarMollification_deriv {f : ℝ → ℝ} + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) (k : ℕ) : + deriv (scalarMollification f k) = scalarMollification (deriv f) k := by + funext z + have hs : ContDiff ℝ ∞ ((scalarMollifier k).normed volume) := + (scalarMollifier k).contDiff_normed + exact (hc.hasDerivAt_convolution_right (lsmul ℝ ℝ) + hs.continuous.locallyIntegrable hf z).deriv + +theorem scalarMollification_bound {f : ℝ → ℝ} {C : ℝ} + (hC : ∀ z, ‖f z‖ ≤ C) (k : ℕ) (z : ℝ) : + ‖scalarMollification f k z‖ ≤ C := by + have hs : ContDiff ℝ ∞ ((scalarMollifier k).normed volume) := + (scalarMollifier k).contDiff_normed + have hi : Integrable ((scalarMollifier k).normed volume) := + hs.continuous.integrable_of_hasCompactSupport (scalarMollifier k).hasCompactSupport_normed + have h := norm_integral_le_of_norm_le (hi.mul_const C) + (Filter.Eventually.of_forall fun y => show + ‖(scalarMollifier k).normed volume y * f (z-y)‖ ≤ + (scalarMollifier k).normed volume y*C by + rw [norm_mul,Real.norm_eq_abs,abs_of_nonneg ((scalarMollifier k).nonneg_normed y)] + exact mul_le_mul_of_nonneg_left (hC (z-y)) ((scalarMollifier k).nonneg_normed y)) + simpa only [scalarMollification,convolution,lsmul_apply,smul_eq_mul, + integral_mul_const,(scalarMollifier k).integral_normed,one_mul] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarScaleBudgets.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarScaleBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c7069aa5a3d53b27bd92eba3041e99b43d47911 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScalarScaleBudgets.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds +import Mathlib.Analysis.SpecialFunctions.Log.Basic + +namespace OAI + +/-! Fixed size-independent thresholds for the scalar conditions in the +manufactured continuum comparison. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem exists_inverse_power_offset {ε : ℝ} (hε : 0 < ε) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ r k : ℕ, q+r ≤ k → ∀ N : ℝ, 2 ≤ N → + N^r/N^k ≤ ε := by + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds hε 1 + refine ⟨q,by omega,fun r k hk N hN => ?_⟩ + have hN0 : 0 < N := by linarith + calc + _ ≤ N^r/N^(q+r) := div_le_div_of_nonneg_left (by positivity) (by positivity) + (pow_le_pow_right₀ (by linarith : 1 ≤ N) hk) + _ = (N^q)⁻¹ := by rw [pow_add]; field_simp + _ ≤ ε := (hbound N hN).1 + +theorem exists_polynomial_ratio_offset (C : ℝ) {ε : ℝ} (hε : 0 < ε) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ r p k : ℕ, q+r+p ≤ k → ∀ N : ℝ, 2 ≤ N → + C*N^r/(N^k)^2 ≤ ε/N^p := by + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds hε C + refine ⟨q,by omega,fun r p k hk N hN => ?_⟩ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + calc + _ ≤ N^q*N^r/(N^k)^2 := by + gcongr + exact (hbound N hN).2 + _ ≤ 1/N^(q+p) := by + rw [div_le_div_iff₀ (by positivity : 0 < (N^k)^2) (pow_pos hN0 _), + one_mul,← pow_add,← pow_add,← pow_mul] + exact pow_le_pow_right₀ hN1 (by omega) + _ = (N^q)⁻¹/N^p := by rw [pow_add]; field_simp + _ ≤ ε/N^p := div_le_div_of_nonneg_right (hbound N hN).1 (by positivity) + +theorem exists_logarithmic_scale_threshold (D : ℝ) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ k : ℕ, k₀ ≤ k → ∀ N : ℝ, 2 ≤ N → + D ≤ 25*(k:ℝ)*Real.log N := by + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + obtain ⟨k₀,hk₀⟩ := exists_nat_ge (max 1 (D/(25*Real.log 2))) + refine ⟨k₀,by exact_mod_cast (le_max_left _ _).trans hk₀,fun k hk N hN => ?_⟩ + have hquot : D/(25*Real.log 2) ≤ (k:ℝ) := + ((le_max_right _ _).trans hk₀).trans (by exact_mod_cast hk) + have hD := (div_le_iff₀ (by positivity : 0 < 25*Real.log 2)).mp hquot + have hlogs : Real.log 2 ≤ Real.log N := Real.log_le_log (by norm_num) hN + calc + D ≤ 25*(k:ℝ)*Real.log 2 := by nlinarith only [hD] + _ ≤ _ := mul_le_mul_of_nonneg_left hlogs (by positivity) + +theorem exists_centered_slab_threshold (C S₀ : ℝ) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ k : ℕ, k₀ ≤ k → ∀ N : ℝ, 2 ≤ N → + ∀ H S : ℝ, (N^k)^50 ≤ H → (N^k)^5 ≤ S → S ≤ 2*(N^k)^5 → + S₀ ≤ S ∧ 1 ≤ H ∧ C*S^3 ≤ H ∧ (N^k)^5 ≤ H/2 := by + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds + (show (0:ℝ)<1 by norm_num) (max S₀ (8*max C 0)) + refine ⟨q,by omega,fun k hk N hN H S hH hS hShi => ?_⟩ + have hN1 : 1 ≤ N := by linarith + have hR1 : 1 ≤ N^k := one_le_pow₀ hN1 + have hS0 : 0 ≤ S := (pow_nonneg (by positivity : 0 ≤ N^k) 5).trans hS + have hR2 : 2 ≤ N^k := hN.trans (le_self_pow₀ hN1 (by omega)) + have hmax : max S₀ (8*max C 0) ≤ N^k := + (hbound N hN).2.trans (pow_le_pow_right₀ hN1 hk) + have hC : 8*max C 0 ≤ (N^k)^35 := + ((le_max_right _ _).trans hmax).trans (le_self_pow₀ hR1 (by decide)) + have hCH : C*S^3 ≤ (N^k)^50 := by + calc + _ ≤ max C 0*(2*(N^k)^5)^3 := + mul_le_mul (le_max_left _ _) (pow_le_pow_left₀ hS0 hShi 3) + (pow_nonneg hS0 3) (le_max_right _ _) + _ = (8*max C 0)*(N^k)^15 := by ring + _ ≤ (N^k)^35*(N^k)^15 := mul_le_mul_of_nonneg_right hC (by positivity) + _ = _ := by ring + have htwo : 2*(N^k)^5 ≤ (N^k)^50 := by + calc + _ ≤ (N^k)*(N^k)^5 := mul_le_mul_of_nonneg_right hR2 (by positivity) + _ = (N^k)^6 := by ring + _ ≤ _ := pow_le_pow_right₀ hR1 (by decide) + exact ⟨(le_max_left _ _).trans (hmax.trans ((le_self_pow₀ hR1 (by decide)).trans hS)), + (one_le_pow₀ hR1).trans hH,hCH.trans hH,by linarith [htwo.trans hH]⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScaledNuclearNear.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScaledNuclearNear.lean new file mode 100644 index 0000000000000000000000000000000000000000..c70abde8c9c1434b7531b0003350f9111bccefa1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ScaledNuclearNear.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SeparatedNuclearNear + +namespace OAI + +/-! Equal-mass near-node errors have the required square-mesh scaling. +The constant depends on the separation and near-ball ratios, not on the +number of nuclei or the size of the box. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem scaled_nuclear_near_bound {κ σ : ℝ} (hκ : 0 < κ) (hσ : 0 < σ) : + ∃ A : ℝ, 1 ≤ A ∧ ∀ (m n : ℕ) (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (R : Fin m → Position) (h ρ : ℝ), + 0 < h → h ≤ 1 → 0 ≤ ρ → + (∀ a b, a ≠ b → σ*h ≤ ‖R a-R b‖) → + (ρ*h^3/8)*(∑ a, ∫ x in electronBall i (R a) (κ*h), + Coulomb.coulombKernel (Coulomb.position x i-R a)*‖u.value s x‖^2) ≤ + ρ*A*h^2*((∫ x, ‖u.value s x‖^2)+ + ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) := by + obtain ⟨C,hC,hbound⟩ := separated_nuclear_near_bound + let M : ℝ := (4*κ+σ)^3/σ^3 + let B : ℝ := max (24*C^2/κ) (8*κ) + let A : ℝ := max 1 (M/8*B) + refine ⟨A,le_max_left _ _,fun m n u s i R h ρ hh hh1 hρ hsep => ?_⟩ + have hM : 0 ≤ M := by dsimp [M]; positivity + have hB : 0 ≤ B := (by positivity : 0 ≤ 24*C^2/κ).trans (le_max_left _ _) + have hmass : 0 ≤ ∫ x, ‖u.value s x‖^2 := integral_nonneg (fun _ => sq_nonneg _) + have hgrad : 0 ≤ ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2 := + Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _)) + have hh2 : h^2 ≤ 1 := by nlinarith + have he := hbound m n u s i R (κ*h) (σ*h) (mul_pos hκ hh) (mul_pos hσ hh) hsep + have hr : (4*(κ*h)+σ*h)^3/(σ*h)^3 = M := by + dsimp [M] + field_simp [hσ.ne',hh.ne'] + rw [hr] at he + have hb : (24*C^2/κ)*(∫ x, ‖u.value s x‖^2)+ + 8*κ*h^2*(∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) ≤ + B*((∫ x, ‖u.value s x‖^2)+∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) := by + rw [mul_add] + apply add_le_add + · exact mul_le_mul_of_nonneg_right (le_max_left _ _) hmass + · apply mul_le_mul_of_nonneg_right _ hgrad + exact (mul_le_mul_of_nonneg_left hh2 (by positivity : 0 ≤ 8*κ)).trans + (by simpa only [mul_one] using (le_max_right (24*C^2/κ) (8*κ))) + calc + _ ≤ (ρ*h^3/8)*(M*((24*C^2/(κ*h))*(∫ x, ‖u.value s x‖^2)+ + 8*(κ*h)*(∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2))) := + mul_le_mul_of_nonneg_left he (by positivity) + _ = (ρ*h^2)*(M/8)*((24*C^2/κ)*(∫ x, ‖u.value s x‖^2)+ + 8*κ*h^2*(∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2)) := by + field_simp [hκ.ne',hh.ne'] + _ ≤ (ρ*h^2)*(M/8)*(B*((∫ x, ‖u.value s x‖^2)+ + ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2)) := + mul_le_mul_of_nonneg_left hb (by positivity) + _ ≤ ρ*A*h^2*((∫ x, ‖u.value s x‖^2)+ + ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) := by + have ha : M/8*B ≤ A := le_max_right _ _ + nlinarith [mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right ha (add_nonneg hmass hgrad)) + (show 0 ≤ ρ*h^2 by positivity)] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SeparatedNuclearNear.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SeparatedNuclearNear.lean new file mode 100644 index 0000000000000000000000000000000000000000..a81eca9b4fa59f374c34d566580dbd29963804b5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SeparatedNuclearNear.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPacking +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearNearEstimate + +namespace OAI + +/-! Separation of the actual point nuclei supplies the bounded-overlap +hypothesis in the weak-H1 near-node estimate. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem separated_electron_ball_overlap {m n : ℕ} (R : Fin m → Position) (i : Fin n) + {d L : ℝ} (hd : 0 < d) (hL : 0 ≤ L) + (hsep : ∀ a b, a ≠ b → d ≤ ‖R a-R b‖) (x : Configuration n) : + (∑ a, if x ∈ electronBall i (R a) L then (1:ℝ) else 0) ≤ (2*L+d)^3/d^3 := by + have h := separated_ball_overlap R (Coulomb.position x i) hd hL hsep + apply (le_div_iff₀ (pow_pos hd 3)).mpr + convert h using 1 + congr 1 + simp only [electronBall,Set.mem_ofPred_eq,norm_sub_rev,← Finset.sum_filter, + Finset.sum_const,nsmul_eq_mul,mul_one] + +theorem separated_nuclear_near_bound : + ∃ C : ℝ, 1 ≤ C ∧ ∀ (m n : ℕ) (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (R : Fin m → Position) (r d : ℝ), + 0 < r → 0 < d → (∀ a b, a ≠ b → d ≤ ‖R a-R b‖) → + (∑ a, ∫ x in electronBall i (R a) r, + Coulomb.coulombKernel (Coulomb.position x i-R a)*‖u.value s x‖^2) ≤ + ((4*r+d)^3/d^3)*((24*C^2/r)*(∫ x, ‖u.value s x‖^2)+ + 8*r*(∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2)) := by + obtain ⟨C,hC,hbound⟩ := nuclear_near_sum_bound + refine ⟨C,hC,fun m n u s i R r d hr hd hsep => ?_⟩ + have hb := hbound m n u s i R r ((2*(2*r)+d)^3/d^3) hr + (separated_electron_ball_overlap R i hd (by positivity) hsep) + convert hb using 1 + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SharpBlockPerturbation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SharpBlockPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..774f598ab62a9b4f8362c1e579c4dba57cbd50ed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SharpBlockPerturbation.lean @@ -0,0 +1,114 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Perturbation +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.ClockWeightedBound + +namespace OAI + +/-! A block estimate retaining the cancellation in the effective energy. +It is needed when the third-order gadget's coupling exceeds its low block. -/ + +noncomputable section +namespace ContinuumCoulomb.Perturbation +open scoped InnerProductSpace + +variable {L H : Type*} [NormedAddCommGroup L] [InnerProductSpace ℝ L] + [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +theorem sharp_lowBlockEnergy_lower (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} + (hd : 0 ≤ d) (hm : 0 ≤ m) (_hη : 0 ≤ η) (hsmall : 2*(d+m) ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) + (hD : ∀ q, |⟪q,D q⟫_ℝ| ≤ d*‖q‖^2) + (hμ : μ ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ effectiveForm C T B p) + (p : L) (q : H) : + -2*(d+m)*η^2*‖p‖^2 ≤ lowBlockEnergy C A D B p q-μ*(‖p‖^2+‖q‖^2) := by + have hi := penalty_square_identity A T B hAT hAsymm p q (by norm_num : (1:ℝ) ≠ 0) + simp only [one_mul,inv_one,one_smul] at hi + have hnorm := norm_add_sq_two (q+T (B p)) (-(T (B p))) + simp only [add_neg_cancel_right,norm_neg] at hnorm + have ht := pow_le_pow_left₀ (norm_nonneg _) (hTB p) 2 + rw [mul_pow] at ht + have hq : ‖q‖^2 ≤ 2*‖q+T (B p)‖^2+2*η^2*‖p‖^2 := by linarith + have hqp := mul_le_mul_of_nonneg_left hq (add_nonneg hd hm) + have hg := mul_le_mul_of_nonneg_right hsmall (sq_nonneg ‖q+T (B p)‖) + have hmup := mul_le_mul_of_nonneg_right hμ (sq_nonneg ‖q‖) + have hminp := hmin p + have hdq := (abs_le.mp (hD q)).1 + have hgapq := hgap (q+T (B p)) + unfold effectiveForm at hminp + unfold lowBlockEnergy blockEnergy + nlinarith + +theorem sharp_lowBlockRayleigh_lower (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} + (hd : 0 ≤ d) (hm : 0 ≤ m) (hη : 0 ≤ η) (hsmall : 2*(d+m) ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) + (hD : ∀ q, |⟪q,D q⟫_ℝ| ≤ d*‖q‖^2) + (hμ : μ ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ effectiveForm C T B p) + (p : L) (q : H) (hpq : 0 < ‖p‖^2+‖q‖^2) : + μ-2*(d+m)*η^2 ≤ lowBlockRayleigh C A D B p q := by + have h := sharp_lowBlockEnergy_lower C A T D B hd hm hη hsmall hAT hAsymm hgap hTB hD hμ hmin p q + unfold lowBlockRayleigh + apply (le_div_iff₀ hpq).mpr + have hnonneg : 0 ≤ 2*(d+m)*η^2*‖q‖^2 := by positivity + nlinarith + +theorem sharp_lowBlockRayleigh_trial_upper (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {d m η μ : ℝ} (hd : 0 ≤ d) (hm : 0 ≤ m) (_hη : 0 ≤ η) + (hAT : ∀ x, A (T x) = x) (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) + (hD : ∀ q, |⟪q,D q⟫_ℝ| ≤ d*‖q‖^2) + (hμ : -m ≤ μ) (p : L) (hp : ‖p‖ = 1) (he : effectiveForm C T B p = μ) : + lowBlockRayleigh C A D B p (-(T (B p))) ≤ μ+(d+m)*η^2 := by + have ht := pow_le_pow_left₀ (norm_nonneg _) (hTB p) 2 + rw [hp,mul_one] at ht + have hi := blockEnergy_trial_identity A T D B hAT p + have hdq := (abs_le.mp (hD (-(T (B p))))).2 + simp only [norm_neg] at hdq + have hmup := mul_le_mul_of_nonneg_right hμ (sq_nonneg ‖T (B p)‖) + have herr := mul_le_mul_of_nonneg_left ht (add_nonneg hd hm) + have hextra : 0 ≤ (d+m)*η^2*‖T (B p)‖^2 := by positivity + unfold lowBlockRayleigh lowBlockEnergy + rw [hp,norm_neg] + apply (div_le_iff₀ (by positivity : (0:ℝ) < 1^2+‖T (B p)‖^2)).mpr + unfold effectiveForm at he + nlinarith + +theorem sharp_lowBlockBottom (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} + (hd : 0 ≤ d) (hm : 0 ≤ m) (hη : 0 ≤ η) (hsmall : 2*(d+m) ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) + (hD : ∀ q, |⟪q,D q⟫_ℝ| ≤ d*‖q‖^2) + (hμ : |μ| ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ effectiveForm C T B p) + (p₀ : L) (hp₀ : ‖p₀‖ = 1) (he : effectiveForm C T B p₀ = μ) : + |lowBlockBottom C A D B-μ| ≤ 2*(d+m)*η^2 := by + have hμb := abs_le.mp hμ + have hnon : 0 < ‖p₀‖^2+‖-(T (B p₀))‖^2 := by rw [hp₀]; positivity + have hn : {e | ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q}.Nonempty := + ⟨_,p₀,-(T (B p₀)),hnon,rfl⟩ + have hl (e : ℝ) (he : ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q) : μ-2*(d+m)*η^2 ≤ e := by + obtain ⟨p,q,hpq,rfl⟩ := he + exact sharp_lowBlockRayleigh_lower C A T D B hd hm hη hsmall hAT hAsymm hgap hTB hD hμb.2 hmin p q hpq + have hb : BddBelow {e | ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q} := ⟨_,hl⟩ + have hlow : μ-2*(d+m)*η^2 ≤ lowBlockBottom C A D B := le_csInf hn hl + have hu : lowBlockBottom C A D B ≤ μ+(d+m)*η^2 := + (csInf_le hb ⟨p₀,-(T (B p₀)),hnon,rfl⟩).trans + (sharp_lowBlockRayleigh_trial_upper C A T D B hd hm hη hAT hTB hD hμb.1 p₀ hp₀ he) + have herr : 0 ≤ (d+m)*η^2 := by positivity + exact abs_le.mpr ⟨by linarith,by linarith⟩ + +end ContinuumCoulomb.Perturbation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedHubbardBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedHubbardBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..15207f0d506caeb1e45ee4dbc964205e9e17472b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedHubbardBounds.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.HubbardBottomBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedHubbardForm + +namespace OAI + +/-! The actual finite Hubbard energy, including its off-site shift and +form error, has polynomial size. No occupation-space dimension enters. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb +open HubbardGlobal + +theorem localizedOffsiteCoulomb_nonnegative {m : ℕ} (freq : ℝ) + (u : Fin m → PlanarPosition) (i j : Fin m) : 0 ≤ localizedOffsiteCoulomb freq u i j := by + unfold localizedOffsiteCoulomb + split_ifs + · exact le_rfl + · exact localizedCoulombCoeff_nonnegative _ _ _ + +theorem localizedOffsiteCoulomb_le {m : ℕ} {freq : ℝ} (hf : 0 < freq) + (u : Fin m → PlanarPosition) (i j : Fin m) : + localizedOffsiteCoulomb freq u i j ≤ localizedPotentialBound freq := by + unfold localizedOffsiteCoulomb + split_ifs + · exact localizedPotentialBound_nonnegative _ + · exact localizedCoulombCoeff_le hf _ _ + +theorem localizedOffsiteCoulomb_sum_le {m : ℕ} {freq : ℝ} (hf : 0 < freq) + (u : Fin m → PlanarPosition) : + (∑ i, ∑ j, localizedOffsiteCoulomb freq u i j) ≤ (m:ℝ)^2*localizedPotentialBound freq := by + have h := Finset.sum_le_sum (s := Finset.univ) (fun i _ => + Finset.sum_le_sum (s := Finset.univ) (fun j _ => localizedOffsiteCoulomb_le hf u i j)) + simpa only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,pow_two,mul_assoc] using h + +theorem localizedHubbardFormError_nonnegative (m : ℕ) (freq D : ℝ) {ε : ℝ} (hε : 0 ≤ ε) : + 0 ≤ localizedHubbardFormError m freq D ε := by + have hO := localizedOverlapBound_nonnegative D + have hP := localizedPotentialBound_nonnegative freq + have hC := localizedFourIndexConstant_nonnegative freq + unfold localizedHubbardFormError + positivity + +theorem shifted_hubbard_abs_bound {Edge : Type*} [Fintype Edge] + {freq D ε : ℝ} (hf : 0 < freq) (hε : 0 ≤ ε) (m : ℕ) + (u : Fin (m+1) → PlanarPosition) (left right : Edge → Fin (m+1)) (t : Edge → ℝ) + (he : localizedHubbardFormError m freq D ε ≤ 1) : + |hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)-localizedHubbardFormError m freq D ε| ≤ + ((m+1:ℝ)/2+(m+1:ℝ)^2)*localizedPotentialBound freq+4*(∑ e, |t e|)+1 := by + have hP := localizedPotentialBound_nonnegative freq + have hU0 := localizedCoulombProfile_nonnegative freq 0 + have hU : localizedCoulombProfile freq 0 ≤ localizedPotentialBound freq := by + simpa only [localizedCoulombCoeff_distance,sub_self,norm_zero] using + localizedCoulombCoeff_le hf (0 : PlanarPosition) 0 + have hsum0 : 0 ≤ ∑ i, ∑ j, localizedOffsiteCoulomb freq u i j := + Finset.sum_nonneg (fun i _ => Finset.sum_nonneg (fun j _ => localizedOffsiteCoulomb_nonnegative freq u i j)) + have hsum := localizedOffsiteCoulomb_sum_le hf u + have he0 := localizedHubbardFormError_nonnegative m freq D hε + have hh := hubbardFermionBottom_abs_bound m (localizedCoulombProfile freq 0) + (localizedOffsiteCoulomb freq u) left right t + simp_rw [abs_of_nonneg hU0,abs_of_nonneg (localizedOffsiteCoulomb_nonnegative freq u _ _)] at hh + have hu := mul_le_mul_of_nonneg_left hU (show 0 ≤ (m+1:ℝ)/2 by positivity) + have ht := (abs_sub + (hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)) (localizedHubbardFormError m freq D ε)).trans + (add_le_add (abs_sub _ _) (le_refl |localizedHubbardFormError m freq D ε|)) + rw [abs_of_nonneg he0,abs_of_nonneg (mul_nonneg (by norm_num) hsum0)] at ht + simp only [Nat.cast_add,Nat.cast_one] at hsum + nlinarith only [ht,hh,hu,hsum,he] + +theorem exists_shifted_hubbard_polynomial_bound {freq : ℝ} (hf : 0 < freq) : + ∃ q : ℕ, 1 ≤ q ∧ ∀ (r v : ℕ) (N : ℝ), 2 ≤ N → + ∀ {Edge : Type} [Fintype Edge] (m : ℕ) (u : Fin (m+1) → PlanarPosition) + (left right : Edge → Fin (m+1)) (t : Edge → ℝ) (D ε : ℝ), + (m+1:ℝ) ≤ N^r → (∑ e, |t e|) ≤ N^v → 0 ≤ ε → + localizedHubbardFormError m freq D ε ≤ 1 → + |hubbardFermionBottom m (localizedCoulombProfile freq 0) (localizedOffsiteCoulomb freq u) left right t- + (1/2:ℝ)*(∑ i, ∑ j, localizedOffsiteCoulomb freq u i j)-localizedHubbardFormError m freq D ε| ≤ + N^(q+2*r+v) := by + let C := (3/2:ℝ)*localizedPotentialBound freq+5 + have hP := localizedPotentialBound_nonnegative freq + obtain ⟨q,hq,hbound⟩ := exists_polynomial_constant_bounds (by norm_num : (0:ℝ)<1) C + refine ⟨q,by omega,fun r v N hN Edge _ m u left right t D ε hm ht hε he => ?_⟩ + have hN1 : 1 ≤ N := by linarith + have hM : 1 ≤ (m+1:ℝ) := by have := Nat.cast_nonneg (α := ℝ) m; linarith + have hM2 : (m+1:ℝ) ≤ (m+1:ℝ)^2 := by nlinarith [sq_nonneg ((m+1:ℝ)-1)] + have hpow : (m+1:ℝ)^2 ≤ N^(2*r+v) := by + calc + _ ≤ (N^r)^2 := pow_le_pow_left₀ (by positivity) hm 2 + _ ≤ N^(2*r+v) := by + rw [← pow_mul] + exact pow_le_pow_right₀ hN1 (by omega) + have hfirst : ((m+1:ℝ)/2+(m+1:ℝ)^2)*localizedPotentialBound freq ≤ + ((3/2:ℝ)*localizedPotentialBound freq)*N^(2*r+v) := by + calc + _ ≤ ((3/2:ℝ)*(m+1:ℝ)^2)*localizedPotentialBound freq := + mul_le_mul_of_nonneg_right (by linarith only [hM2]) hP + _ ≤ ((3/2:ℝ)*localizedPotentialBound freq)*N^(2*r+v) := by + have h := mul_le_mul_of_nonneg_left hpow (show 0 ≤ (3/2:ℝ)*localizedPotentialBound freq by positivity) + convert h using 1 + ring + have ht' : (∑ e, |t e|) ≤ N^(2*r+v) := ht.trans (pow_le_pow_right₀ hN1 (by omega)) + have hone : 1 ≤ N^(2*r+v) := one_le_pow₀ hN1 + calc + _ ≤ ((m+1:ℝ)/2+(m+1:ℝ)^2)*localizedPotentialBound freq+4*(∑ e, |t e|)+1 := + shifted_hubbard_abs_bound hf hε m u left right t he + _ ≤ C*N^(2*r+v) := by dsimp [C]; nlinarith only [hfirst,ht',hone] + _ ≤ N^q*N^(2*r+v) := mul_le_mul_of_nonneg_right (hbound N hN).2 (by positivity) + _ = N^(q+2*r+v) := by rw [← pow_add]; congr 1; omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedPhysicalForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedPhysicalForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..f57bc6d7986e735e15f18a7c037f7fa3338181fb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ShiftedPhysicalForm.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FiniteTensorFormError +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.Dilation + +namespace OAI + +/-! Exact energy offset between the manufactured form and the physical +Coulomb Hamiltonian. All identities hold on the full weak-H1 domain. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem nuclearPerturbedForm_physical_identity {M n : ℕ} + (nuc : Coulomb.Nuclei M) (W F : Position → ℝ) (scale offset : ℝ) + (hsplit : ∀ y, W y+F y = -scale⁻¹*Coulomb.attraction nuc y-offset) + (w : Coulomb.H1Vector n) (hI : nuclearFormIntegrable F w) : + nuclearPerturbedForm (fun x => ∑ i, W (Coulomb.position x i)) F w = + Coulomb.kinetic w-scale⁻¹*Coulomb.nuclearEnergy nuc w- + (n:ℝ)*offset*Coulomb.mass w := by + have hpoint (s : SpinConfiguration n) (x : Configuration n) : + (∑ i, W (Coulomb.position x i))*‖w.value s x‖^2 = + -scale⁻¹*((∑ i, Coulomb.attraction nuc (Coulomb.position x i))*‖w.value s x‖^2)- + (n:ℝ)*offset*‖w.value s x‖^2- + ∑ i, F (Coulomb.position x i)*‖w.value s x‖^2 := by + have he (i : Fin n) : W (Coulomb.position x i) = + -scale⁻¹*Coulomb.attraction nuc (Coulomb.position x i)-offset-F (Coulomb.position x i) := by + linarith only [hsplit (Coulomb.position x i)] + simp_rw [he] + simp only [Finset.sum_sub_distrib,← Finset.mul_sum,← Finset.sum_mul,Finset.sum_const, + Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + have hi (s : SpinConfiguration n) : + (∫ x, (∑ i, W (Coulomb.position x i))*‖w.value s x‖^2)+ + ∑ i, ∫ x, F (Coulomb.position x i)*‖w.value s x‖^2 = + -scale⁻¹*(∫ x, (∑ i, Coulomb.attraction nuc (Coulomb.position x i))*‖w.value s x‖^2)- + (n:ℝ)*offset*(∫ x, ‖w.value s x‖^2) := by + simp_rw [hpoint] + have ha : Integrable (fun x => -scale⁻¹* + ((∑ i, Coulomb.attraction nuc (Coulomb.position x i))*‖w.value s x‖^2)) := + (w.nuclear_integrable nuc s).const_mul _ + have hb : Integrable (fun x => (n:ℝ)*offset*‖w.value s x‖^2) := + (w.value_L2 s).norm.integrable_sq.const_mul _ + have hc : Integrable (fun x => ∑ i, F (Coulomb.position x i)*‖w.value s x‖^2) := + integrable_finsetSum _ (fun i _ => hI s i) + have hsub := integral_sub (ha.sub hb) hc + have hsub' := integral_sub ha hb + simp only [Pi.sub_apply] at hsub hsub' + rw [hsub,hsub', + integral_const_mul,integral_const_mul, + integral_finsetSum _ (fun i _ => hI s i)] + ring + unfold nuclearPerturbedForm boundedPotentialForm nuclearErrorEnergy Coulomb.nuclearEnergy Coulomb.mass + rw [add_assoc,← Finset.sum_add_distrib] + simp_rw [hi] + simp only [Finset.sum_sub_distrib,← Finset.mul_sum] + ring + +theorem dilated_physicalForm_shift {M n : ℕ} + (nuc : Coulomb.Nuclei M) (W F : Position → ℝ) {scale : ℝ} (hscale : 0 < scale) + (offset : ℝ) (hsplit : ∀ y, W y+F y = -scale⁻¹*Coulomb.attraction nuc y-offset) + (w : Coulomb.H1Vector n) (hI : nuclearFormIntegrable F w) : + Coulomb.form (dilatedNuclei nuc scale (ne_of_gt hscale)) + (normalizedDilation w scale (ne_of_gt hscale)) = + scale^2*(nuclearPerturbedForm (fun x => ∑ i, W (Coulomb.position x i)) F w+ + scale⁻¹*Coulomb.pairEnergy w)+(scale^2*(n:ℝ)*offset)*Coulomb.mass w := by + rw [form_normalizedDilation nuc w hscale, + nuclearPerturbedForm_physical_identity nuc W F scale offset hsplit w hI] + field_simp [ne_of_gt hscale] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SingleSpinSource.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SingleSpinSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec4a8785764fd7bcfffc884b92f4675dd07786c1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SingleSpinSource.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AtomicOutputs +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceMetadataProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram + +namespace OAI + +/-! A literal, constant-size decision branch covers the original one-spin +source. This prevents the many-electron construction from excluding it. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem source_one_vertex_edges (d : SquareLatticeHeisenberg) (hv : d.vertices ≤ 1) : d.edges=0 := by + apply Nat.eq_zero_of_not_pos + intro he + let e : Fin d.edges := ⟨0,he⟩ + have hn := d.edge_ne e + have hl := (d.left e).isLt + have hr := (d.right e).isLt + exact hn (Fin.ext (by omega)) + +theorem source_one_vertex_energy (d : SquareLatticeHeisenberg) (hv : d.vertices ≤ 1) : + realSourceGroundEnergy d=0 := by + have he := source_one_vertex_edges d hv + let : IsEmpty (Fin d.edges) := Fin.isEmpty_iff.mpr he + have hf (w : SourceSpinVector d.vertices) : sourceHamiltonianForm d w=0 := by + simp [sourceHamiltonianForm] + apply le_antisymm + · simpa only [hf] using realSourceGroundEnergy_le_trial d (allUpSourceVector d.vertices) + (allUpSourceVector_mass d.vertices) + · exact realSourceGroundEnergy_lower_of_forall d 0 (fun w _ => (hf w).ge) + +namespace SingleSpinSource +open ExactQuantumFactoring.BitStackProgram + +def value (d : BinaryHeisenberg) : UnitCoulomb := + if d.lower.value < 0 then atomicOutput false else atomicOutput true + +noncomputable opaque program : Procedure binaryHeisenbergCodec.encode unitCoulombCodec.encode value := by + let test := BisectionProgram.rationalLess.comp + (SourcePrograms.lower.pair (Procedure.constant binaryHeisenbergCodec.encode ratCode 0)) + exact (Procedure.conditional test + (Procedure.constant binaryHeisenbergCodec.encode unitCoulombCodec.encode (atomicOutput false)) + (Procedure.constant binaryHeisenbergCodec.encode unitCoulombCodec.encode (atomicOutput true))).congrFun + (by intro d; simp only [Function.comp_apply,value,decide_eq_true_eq]) + +theorem yes (hh : PublishedHydrogenBottom) (d : BinaryHeisenberg) (hd : d.Valid) + (hv : d.coordinate.length ≤ 1) + (hy : realSourceGroundEnergy (d.toSource hd) ≤ d.lower.value) : value d ∈ unitCoulombPromise.yes := by + have he := source_one_vertex_energy (d.toSource hd) hv + have hl : ¬d.lower.value < 0 := not_lt.mpr (by exact_mod_cast (by linarith [he] : (0:ℝ) ≤ d.lower.value)) + simp only [value,hl,ite_false] + exact atomicOutput_yes hh + +theorem no (hh : PublishedHydrogenBottom) (d : BinaryHeisenberg) (hd : d.Valid) + (hv : d.coordinate.length ≤ 1) + (hn : (d.upper.value:ℝ) ≤ realSourceGroundEnergy (d.toSource hd)) : value d ∈ unitCoulombPromise.no := by + have he := source_one_vertex_energy (d.toSource hd) hv + have hu : d.upper.value ≤ 0 := by exact_mod_cast (by linarith [he] : (d.upper.value:ℝ) ≤ 0) + have hl : d.lower.value < 0 := lt_of_lt_of_le hd.gap hu + simp only [value,hl,ite_true] + exact atomicOutput_no hh + +end SingleSpinSource +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SlowLogarithmicExtent.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SlowLogarithmicExtent.lean new file mode 100644 index 0000000000000000000000000000000000000000..9af648edebc2425ab3b50978b6de7f7c2428c8e2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SlowLogarithmicExtent.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactExtent + +namespace OAI + +/-! The logarithmic spacing contributes only a hundredth of the adjustable +exponent. This closes the final analytic parameter inequalities without a +circular dependence on the spatial extent. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactMediator + +theorem hundred_mul_le_two_pow (q : ℕ) (hq : 11 ≤ q) : 100*(q+1) ≤ 2^q := by + obtain ⟨r,rfl⟩ := Nat.exists_eq_add_of_le hq + induction r with + | zero => norm_num + | succ r ih => + calc + 100*(11+(r+1)+1) ≤ 2*(100*(11+r+1)) := by omega + _ ≤ 2*2^(11+r) := Nat.mul_le_mul_left 2 (ih (by omega)) + _ = 2^(11+(r+1)) := by rw [show 11+(r+1)=11+r+1 by omega,pow_succ]; omega + +theorem exponent_le_slow_power (k : ℕ) (hk : 1100 ≤ k) {N : ℝ} (hN : 2 ≤ N) : + (k : ℝ) ≤ N^(k/100) := by + have hq : 11 ≤ k/100 := by omega + have hkn : k ≤ 100*(k/100+1) := by omega + have hpow : (k : ℝ) ≤ (2:ℝ)^(k/100) := by + exact_mod_cast hkn.trans (hundred_mul_le_two_pow _ hq) + exact hpow.trans (pow_le_pow_left₀ (by norm_num) hN _) + +theorem slow_logarithmic_extent (k s : ℕ) (hk : 1100 ≤ k) + {N : ℝ} (hN : 2 ≤ N) : + 2*(31*(k:ℝ)*Real.log N)*(17*N^s+17) ≤ N^(k/100+s+13) := by + have hNp : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hlog := (Real.log_le_sub_one_of_pos hNp).trans (show N-1 ≤ N by linarith) + have hlog0 := Real.log_nonneg hN1 + have hsize : 17*N^s+17 ≤ 34*N^s := by nlinarith [one_le_pow₀ hN1 (n := s)] + have hkpow := exponent_le_slow_power k hk hN + have hC : (2108:ℝ) ≤ N^12 := + (by norm_num : (2108:ℝ) ≤ 2^12).trans (pow_le_pow_left₀ (by norm_num) hN 12) + calc + _ ≤ 2*(31*N^(k/100)*N)*(34*N^s) := by gcongr + _ = 2108*(N^(k/100)*N^s*N) := by ring + _ ≤ N^12*(N^(k/100)*N^s*N) := mul_le_mul_of_nonneg_right hC (by positivity) + _ = N^(k/100+s+13) := by + rw [show k/100+s+13=12+(k/100+s+1) by omega] + simp only [pow_add,pow_one] + +theorem slow_extent_parameter_closure (C k : ℕ) (hC : 4*C ≤ k) : + C+72*(k/100) ≤ k := by omega + +end ContinuumCoulomb.ContactMediator + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SmoothCutoffApproximation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SmoothCutoffApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d94b31f645bdc4c7301291fce6aede359650f07 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SmoothCutoffApproximation.lean @@ -0,0 +1,178 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SobolevDensityInput + +namespace OAI + +/-! Compact cutoffs of actual smooth weak-H1 vectors. This is the cutoff +step needed after the published smooth-density theorem. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +private theorem cutoff_complex_C1 {n : ℕ} (χ : Configuration n → ℝ) + (hχ : ContDiff ℝ 1 χ) : ContDiff ℝ 1 (fun x => (χ x : ℂ)) := + Complex.ofRealCLM.contDiff.comp hχ + +def smoothCutoffState {n : ℕ} (u : Coulomb.H1Vector n) + (hu : ∀ s, ContDiff ℝ 1 (u.value s)) (χ : Configuration n → ℝ) + (hχ : ContDiff ℝ 1 χ) (hc : HasCompactSupport χ) : Coulomb.H1Vector n := + classicalH1State (fun s x => (χ x : ℂ) * u.value s x) + (fun s => (cutoff_complex_C1 χ hχ).mul (hu s)) + (fun s => ((cutoff_complex_C1 χ hχ).mul (hu s)).continuous.memLp_of_hasCompactSupport + ((hc.comp_left Complex.ofReal_zero).mul_right)) + (fun s a => + (show Continuous (fun x => fderiv ℝ (fun y => (χ y : ℂ) * u.value s y) x + (EuclideanSpace.single a 1)) from + (((cutoff_complex_C1 χ hχ).mul (hu s)).continuous_fderiv (by norm_num)).clm_apply + continuous_const).memLp_of_hasCompactSupport + (((hc.comp_left Complex.ofReal_zero).mul_right).fderiv_apply ℝ _)) + +theorem smoothCutoffState_gradient {n : ℕ} (u : Coulomb.H1Vector n) + (hu : ∀ s, ContDiff ℝ 1 (u.value s)) + (hd : ∀ s a x, fderiv ℝ (u.value s) x (EuclideanSpace.single a 1) = u.gradient s a x) + (χ : Configuration n → ℝ) (hχ : ContDiff ℝ 1 χ) (hc : HasCompactSupport χ) + (s : SpinConfiguration n) (a : Fin n × Fin 3) (x : Configuration n) : + (smoothCutoffState u hu χ hχ hc).gradient s a x = + (fderiv ℝ χ x (EuclideanSpace.single a 1) : ℂ) * u.value s x + + (χ x : ℂ) * u.gradient s a x := by + change fderiv ℝ (fun y => (χ y : ℂ) * u.value s y) x (EuclideanSpace.single a 1) = _ + have hfχ := Complex.ofRealCLM.hasFDerivAt.comp x + (hχ.differentiable (by norm_num) x).hasFDerivAt + have hf := hfχ.mul (hu s |>.differentiable (by norm_num) x).hasFDerivAt + have he := congrArg (fun L : Configuration n →L[ℝ] ℂ => L (EuclideanSpace.single a 1)) hf.fderiv + calc + _ = (χ x : ℂ) * u.gradient s a x + + u.value s x * (fderiv ℝ χ x (EuclideanSpace.single a 1) : ℂ) := by + simpa only [Pi.mul_def, Function.comp_def, add_apply, smul_apply, + ContinuousLinearMap.comp_apply, Complex.ofRealCLM_apply, smul_eq_mul, hd] using he + _ = _ := by ring + +/-- Dominated convergence for the two terms in the cutoff product rule. -/ +theorem cutoff_product_error_tendsto {n : ℕ} + (f g : Configuration n → ℂ) (hf : MemLp f 2) (hg : MemLp g 2) + (a b : ℕ → Configuration n → ℝ) + (ha : ∀ k, Continuous (a k)) (hb : ∀ k, Continuous (b k)) + (A B : ℝ) (hA : 0 ≤ A) (hB : 0 ≤ B) + (hab : ∀ k x, |a k x| ≤ A ∧ |b k x| ≤ B) + (hat : ∀ x, Tendsto (fun k => a k x) atTop (𝓝 0)) + (hbt : ∀ x, Tendsto (fun k => b k x) atTop (𝓝 0)) : + Tendsto (fun k => ∫ x, ‖(a k x : ℂ) * f x + (b k x : ℂ) * g x‖^2) + atTop (𝓝 0) := by + have hfi : Integrable (fun x => ‖f x‖^2) := + (memLp_two_iff_integrable_sq_norm hf.aestronglyMeasurable).mp hf + have hgi : Integrable (fun x => ‖g x‖^2) := + (memLp_two_iff_integrable_sq_norm hg.aestronglyMeasurable).mp hg + suffices hlim : Tendsto + (fun k => ∫ x, ‖(a k x : ℂ)*f x + (b k x : ℂ)*g x‖^2) + atTop (𝓝 (∫ _ : Configuration n, (0 : ℝ))) by + simpa only [integral_zero] using hlim + apply tendsto_integral_of_dominated_convergence + (fun x => 2*A^2*‖f x‖^2 + 2*B^2*‖g x‖^2) + · intro k + exact ((((Complex.continuous_ofReal.comp (ha k)).aestronglyMeasurable.mul + hf.aestronglyMeasurable).add + ((Complex.continuous_ofReal.comp (hb k)).aestronglyMeasurable.mul + hg.aestronglyMeasurable)).norm.pow 2) + · exact (hfi.const_mul (2*A^2)).add (hgi.const_mul (2*B^2)) + · intro k + filter_upwards [] with x + rw [Real.norm_eq_abs, abs_of_nonneg (sq_nonneg _)] + have he : ‖(a k x : ℂ)*f x + (b k x : ℂ)*g x‖ ≤ A*‖f x‖ + B*‖g x‖ := by + apply (norm_add_le _ _).trans + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact add_le_add + (mul_le_mul_of_nonneg_right (hab k x).1 (norm_nonneg _)) + (mul_le_mul_of_nonneg_right (hab k x).2 (norm_nonneg _)) + have hs := (sq_le_sq₀ (norm_nonneg _) + (add_nonneg (mul_nonneg hA (norm_nonneg _)) (mul_nonneg hB (norm_nonneg _)))).mpr he + nlinarith [sq_nonneg (A*‖f x‖ - B*‖g x‖)] + · filter_upwards [] with x + have ht := (((Complex.continuous_ofReal.tendsto 0).comp (hat x)).mul_const (f x)).add + (((Complex.continuous_ofReal.tendsto 0).comp (hbt x)).mul_const (g x)) + simpa using ht.norm.pow 2 + +theorem smoothCutoffState_error_tendsto {n : ℕ} (u : Coulomb.H1Vector n) + (hu : ∀ s, ContDiff ℝ 1 (u.value s)) + (hd : ∀ s a x, fderiv ℝ (u.value s) x (EuclideanSpace.single a 1) = u.gradient s a x) + (χ : ℕ → Configuration n → ℝ) (hχ : ∀ k, ContDiff ℝ 1 (χ k)) + (hc : ∀ k, HasCompactSupport (χ k)) + (D : ℝ) (hb : ∀ k x, |χ k x| ≤ 1) + (hdb : ∀ k a x, |fderiv ℝ (χ k) x (EuclideanSpace.single a 1)| ≤ D) + (ht : ∀ x, Tendsto (fun k => χ k x) atTop (𝓝 1)) + (hdt : ∀ a x, Tendsto (fun k => fderiv ℝ (χ k) x (EuclideanSpace.single a 1)) + atTop (𝓝 0)) : + Tendsto (fun k => h1GraphError u (smoothCutoffState u hu (χ k) (hχ k) (hc k))) + atTop (𝓝 0) := by + have hχb (k : ℕ) (x : Configuration n) : |χ k x - 1| ≤ 2 := by + calc + _ ≤ |χ k x| + |(1 : ℝ)| := abs_sub _ _ + _ ≤ 2 := by simpa only [abs_one] using (show |χ k x| + 1 ≤ 2 by linarith [hb k x]) + have hv (s : SpinConfiguration n) : + Tendsto (fun k => ∫ x, ‖u.value s x - + (smoothCutoffState u hu (χ k) (hχ k) (hc k)).value s x‖^2) atTop (𝓝 0) := by + have h := cutoff_product_error_tendsto (u.value s) (u.value s) + (u.value_L2 s) (u.value_L2 s) + (fun k x => χ k x - 1) (fun _ _ => 0) + (fun k => (hχ k).continuous.sub continuous_const) (fun _ => continuous_const) + 2 0 (by norm_num) le_rfl (fun k x => ⟨hχb k x, by simp⟩) + (fun x => by simpa using (ht x).sub_const 1) (fun _ => tendsto_const_nhds) + convert h using 1 + funext k + apply integral_congr_ae + filter_upwards [] with x + change ‖u.value s x - (χ k x : ℂ)*u.value s x‖^2 = _ + rw [norm_sub_rev] + congr 2 + push_cast + ring + have hg (s : SpinConfiguration n) (a : Fin n × Fin 3) : + Tendsto (fun k => ∫ x, ‖u.gradient s a x - + (smoothCutoffState u hu (χ k) (hχ k) (hc k)).gradient s a x‖^2) atTop (𝓝 0) := by + have h := cutoff_product_error_tendsto (u.value s) (u.gradient s a) + (u.value_L2 s) (u.partial_L2 s a) + (fun k x => fderiv ℝ (χ k) x (EuclideanSpace.single a 1)) (fun k x => χ k x - 1) + (fun k => ((hχ k).continuous_fderiv (by norm_num)).clm_apply continuous_const) + (fun k => (hχ k).continuous.sub continuous_const) + |D| 2 (abs_nonneg D) (by norm_num) + (fun k x => ⟨(hdb k a x).trans (le_abs_self D), hχb k x⟩) + (hdt a) (fun x => by simpa using (ht x).sub_const 1) + convert h using 1 + funext k + apply integral_congr_ae + filter_upwards [] with x + rw [smoothCutoffState_gradient u hu hd, norm_sub_rev] + congr 2 + push_cast + ring + simpa only [h1GraphError, Finset.sum_const_zero, zero_add] using + (tendsto_finsetSum _ (fun s _ => hv s)).add + (tendsto_finsetSum _ (fun s _ => tendsto_finsetSum _ (fun a _ => hg s a))) + +/-- Every smooth actual H1 vector is the graph-norm limit of compactly +supported C1 vectors, using the existing full-space cutoff construction. -/ +theorem exists_compact_approximation_of_smooth {n : ℕ} (u : Coulomb.H1Vector n) + (hu : ∀ s, ContDiff ℝ (⊤ : ℕ∞) (u.value s)) + (hd : ∀ s a x, u.gradient s a x = fderiv ℝ (u.value s) x (EuclideanSpace.single a 1)) + {ε : ℝ} (hε : 0 < ε) : + ∃ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ 1 (v.value s) ∧ HasCompactSupport (v.value s)) ∧ + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) ∧ + h1GraphError u v < ε := by + obtain ⟨χ, D, hχ, hc, hb, hdb, ht, hdt⟩ := Coulomb.exists_hardyCutoffs n + have hu₁ : ∀ s, ContDiff ℝ 1 (u.value s) := fun s => (hu s).of_le (by simp) + have hχ₁ : ∀ k, ContDiff ℝ 1 (χ k) := fun k => (hχ k).of_le (by simp) + have he := smoothCutoffState_error_tendsto u hu₁ (fun s a x => (hd s a x).symm) + χ hχ₁ hc D hb hdb ht hdt + obtain ⟨k, hk⟩ := (he.eventually (gt_mem_nhds hε)).exists + refine ⟨smoothCutoffState u hu₁ (χ k) (hχ₁ k) (hc k), fun s => ?_, + fun _ _ _ => rfl, hk⟩ + exact ⟨(cutoff_complex_C1 _ (hχ₁ k)).mul (hu₁ s), + ((hc k).comp_left Complex.ofReal_zero).mul_right⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..40c2f5e31b41397edd03c2a4c9626cee57a5723e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensity.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ComplexMollification + +namespace OAI + +/-! The whole-space H=W specialization required by the two continuum +reductions. The approximation is constructed by normalized smooth convolution, +with no published density hypothesis remaining. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +theorem complexMollification_error_tendsto {n : ℕ} {u : Configuration n → ℂ} + (hu : MemLp u 2) : + Tendsto (fun k => ∫ x, ‖u x-complexMollification u k x‖^2) atTop (𝓝 0) := by + apply tendsto_order.mpr + constructor + · intro a ha + exact Eventually.of_forall (fun k => ha.trans_le (integral_nonneg (fun x => sq_nonneg _))) + · intro a ha + exact complexMollification_error hu ha + +def mollifiedH1 {n : ℕ} (u : Coulomb.H1Vector n) (k : ℕ) : Coulomb.H1Vector n := + classicalH1State (fun s => complexMollification (u.value s) k) + (fun s => (complexMollification_smooth (u.value_L2 s) k).of_le (by simp)) + (fun s => complexMollification_memLp (u.value_L2 s) k) + (fun s a => by + have he := complexMollification_partial (u.value_L2 s) (u.partial_L2 s a) + (EuclideanSpace.single a 1) (u.weak_partial s a) k + simp_rw [he] + exact complexMollification_memLp (u.partial_L2 s a) k) + +theorem mollifiedH1_gradient {n : ℕ} (u : Coulomb.H1Vector n) (k : ℕ) + (s : SpinConfiguration n) (a : Fin n × Fin 3) (x : Configuration n) : + (mollifiedH1 u k).gradient s a x = complexMollification (u.gradient s a) k x := + complexMollification_partial (u.value_L2 s) (u.partial_L2 s a) + (EuclideanSpace.single a 1) (u.weak_partial s a) k x + +theorem mollifiedH1_error_tendsto {n : ℕ} (u : Coulomb.H1Vector n) : + Tendsto (fun k => h1GraphError u (mollifiedH1 u k)) atTop (𝓝 0) := by + have hv := tendsto_finsetSum Finset.univ (fun s _ => + complexMollification_error_tendsto (u.value_L2 s)) + have hg := tendsto_finsetSum Finset.univ (fun s _ => + tendsto_finsetSum Finset.univ (fun a _ => + complexMollification_error_tendsto (u.partial_L2 s a))) + unfold h1GraphError + simp_rw [mollifiedH1_gradient] + simpa only [mollifiedH1,classicalH1State,Finset.sum_const_zero,add_zero] using hv.add hg + +/-- Meyers–Serrin, H=W, specialized to the full Euclidean weak-H1 space, +proved here by the explicit convolution sequence. -/ +theorem publishedSobolevSmoothDensity : PublishedSobolevSmoothDensity := by + intro n u ε hε + have he := (tendsto_order.mp (mollifiedH1_error_tendsto u)).2 ε hε + obtain ⟨k,hk⟩ := he.exists + refine ⟨fun s => complexMollification (u.value s) k, + fun s => complexMollification_smooth (u.value_L2 s) k, + fun s => complexMollification_memLp (u.value_L2 s) k,?_,hk⟩ + intro s a + have heq := complexMollification_partial (u.value_L2 s) (u.partial_L2 s a) + (EuclideanSpace.single a 1) (u.weak_partial s a) k + simp_rw [heq] + exact complexMollification_memLp (u.partial_L2 s a) k + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensityInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensityInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..2653e6bfd4424706f1f1c3afa38c0c5431056c5a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SobolevDensityInput.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 + +namespace OAI + +/-! +# The Sobolev density input for conditional estimates + +N. G. Meyers and J. Serrin, *H = W*, Proc. Natl. Acad. Sci. USA 51 (1964), +1055–1056, DOI 10.1073/pnas.51.6.1055, Theorem and the Lemma on p.1056. +We use only m=1, p=2 on the full Euclidean configuration space. The finite +spin index is handled componentwise. This is smooth approximation in the +value-and-weak-gradient norm; no compact support or Coulomb-form comparison +is included in the assumption. +-/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +/-- Squared error in the actual value-and-gradient graph. -/ +def h1GraphError {n : ℕ} (u v : Coulomb.H1Vector n) : ℝ := + (∑ s, ∫ x, ‖u.value s x - v.value s x‖ ^ 2) + + ∑ s, ∑ a, ∫ x, ‖u.gradient s a x - v.gradient s a x‖ ^ 2 + +theorem h1GraphError_nonnegative {n : ℕ} (u v : Coulomb.H1Vector n) : + 0 ≤ h1GraphError u v := by + unfold h1GraphError + apply add_nonneg + · exact Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _)) + · exact Finset.sum_nonneg (fun _ _ => + Finset.sum_nonneg (fun _ _ => integral_nonneg (fun _ => sq_nonneg _))) + +/-- The precise specialization of the published H=W theorem. -/ +def PublishedSobolevSmoothDensity : Prop := + ∀ (n : ℕ) (u : Coulomb.H1Vector n) (ε : ℝ), 0 < ε → + ∃ (f : SpinConfiguration n → Configuration n → ℂ) + (hf : ∀ s, ContDiff ℝ (⊤ : ℕ∞) (f s)) + (hL2 : ∀ s, MemLp (f s) 2) + (hpartial : ∀ s a, MemLp + (fun x => fderiv ℝ (f s) x (EuclideanSpace.single a 1)) 2), + h1GraphError u (classicalH1State f (fun s => (hf s).of_le (by simp)) hL2 hpartial) < ε + +/-- A convenient actual-H1 version, preserving the published input explicitly. -/ +theorem exists_smooth_h1_approximation (hpublished : PublishedSobolevSmoothDensity) + {n : ℕ} (u : Coulomb.H1Vector n) {ε : ℝ} (hε : 0 < ε) : + ∃ v : Coulomb.H1Vector n, + (∀ s, ContDiff ℝ (⊤ : ℕ∞) (v.value s)) ∧ + (∀ s a x, v.gradient s a x = + fderiv ℝ (v.value s) x (EuclideanSpace.single a 1)) ∧ + h1GraphError u v < ε := by + obtain ⟨f, hf, hL2, hpartial, he⟩ := hpublished n u ε hε + exact ⟨classicalH1State f (fun s => (hf s).of_le (by simp)) hL2 hpartial, + hf, fun _ _ _ => rfl, he⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..260c71350161397132786a4ec468b9953333c4d7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitCoordinates.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedModes +import Mathlib.MeasureTheory.Measure.Haar.InnerProductSpace + +namespace OAI + +/-! Volume-preserving planar/transverse coordinates for the actual +three-dimensional Coulomb space. The intermediate product has its Euclidean +L² norm; the final ordinary product carries the same product volume. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def verticalCoordinateEquiv : EuclideanSpace ℝ (Fin 1) ≃ₗᵢ[ℝ] ℝ where + __ := (PiLp.equivOfUnique 2 ℝ (fun _ : Fin 1 => ℝ)).toLinearEquiv + norm_map' := by + intro x + change ‖x 0‖ = ‖x‖ + simp [PiLp.norm_eq_of_L2, Real.sqrt_sq_eq_abs] + +def positionSplitIsometry : Position ≃ₗᵢ[ℝ] WithLp 2 SplitPosition := + (LinearIsometryEquiv.piLpCongrLeft 2 ℝ ℝ + ((finSumFinEquiv (m := 2) (n := 1)).symm)).trans + ((PiLp.sumPiLpEquivProdLpPiLp (𝕜 := ℝ) 2 (fun _ => ℝ)).trans + (LinearIsometryEquiv.withLpProdCongr 2 + (LinearIsometryEquiv.refl ℝ PlanarPosition) verticalCoordinateEquiv)) + +def positionSplitCoordinates : Position ≃L[ℝ] SplitPosition := + positionSplitIsometry.toContinuousLinearEquiv.trans + (WithLp.prodContinuousLinearEquiv 2 ℝ PlanarPosition ℝ) + +theorem positionSplitCoordinates_measurePreserving : + MeasurePreserving positionSplitCoordinates := by + change MeasurePreserving (fun x => WithLp.ofLp (positionSplitIsometry x)) + exact (WithLp.volume_preserving_ofLp PlanarPosition ℝ).comp + positionSplitIsometry.measurePreserving + +theorem positionSplitCoordinates_integral (f : SplitPosition → ℝ) : + (∫ x : Position, f (positionSplitCoordinates x)) = ∫ p, f p := + positionSplitCoordinates_measurePreserving.integral_comp + positionSplitCoordinates.toHomeomorph.measurableEmbedding f + +theorem positionSplitCoordinates_norm_sq (x : Position) : + ‖x‖ ^ 2 = ‖(positionSplitCoordinates x).1‖ ^ 2 + + (positionSplitCoordinates x).2 ^ 2 := by + change ‖x‖ ^ 2 = ‖(positionSplitIsometry x).fst‖ ^ 2 + (positionSplitIsometry x).snd ^ 2 + have h := WithLp.prod_norm_sq_eq_of_L2 (positionSplitIsometry x) + rw [positionSplitIsometry.norm_map] at h + simpa only [Real.norm_eq_abs, sq_abs] using h + +theorem positionSplitCoordinates_distance (x y : Position) : + ‖x - y‖ = Real.sqrt (‖(positionSplitCoordinates x).1 - (positionSplitCoordinates y).1‖ ^ 2 + + ((positionSplitCoordinates x).2 - (positionSplitCoordinates y).2) ^ 2) := by + have h := positionSplitCoordinates_norm_sq (x - y) + rw [map_sub] at h + simp only [Prod.fst_sub, Prod.snd_sub] at h + rw [← h, Real.sqrt_sq (norm_nonneg _)] + +def continuumLocalizedMode (freq : ℝ) (u : PlanarPosition) (x : Position) : ℝ := + localizedMode freq u (positionSplitCoordinates x) + +theorem continuumLocalizedMode_C7 (freq : ℝ) (u : PlanarPosition) : + ContDiff ℝ 7 (continuumLocalizedMode freq u) := + (localizedMode_C7 freq u).comp positionSplitCoordinates.contDiff + +theorem continuumLocalizedMode_positive {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (x : Position) : 0 < continuumLocalizedMode freq u x := + localizedMode_positive hfreq u _ + +theorem continuumLocalizedMode_normalized {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) : (∫ x : Position, continuumLocalizedMode freq u x ^ 2) = 1 := by + change (∫ x : Position, (localizedMode freq u (positionSplitCoordinates x)) ^ 2) = 1 + rw [positionSplitCoordinates_integral (fun p => localizedMode freq u p ^ 2), + localizedMode_normalized hfreq] + +theorem continuumLocalizedMode_memLp {freq : ℝ} (hfreq : 0 < freq) (u : PlanarPosition) : + MemLp (continuumLocalizedMode freq u) 2 := + (localizedMode_memLp hfreq u).comp_measurePreserving positionSplitCoordinates_measurePreserving + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIdentity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..12393087a5e31e434693f9bbfcbc3e3836a2df2e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIdentity.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFormIntegrals + +namespace OAI + +/-! Fubini identities for the full split-coordinate kinetic and potential +forms. No domain restriction beyond compact C1 test functions is introduced. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem split_integral_planar (g : SplitPosition → ℝ) (hg : Integrable g) : + (∫ z : ℝ, ∫ r : PlanarPosition, g (r,z)) = ∫ p, g p := by + have hi : Integrable g (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hg + simpa only [Measure.volume_eq_prod] using (integral_prod_symm _ hi).symm + +theorem split_integral_vertical (g : SplitPosition → ℝ) (hg : Integrable g) : + (∫ r : PlanarPosition, ∫ z : ℝ, g (r,z)) = ∫ p, g p := by + have hi : Integrable g (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hg + simpa only [Measure.volume_eq_prod] using (integral_prod _ hi).symm + +def splitRealKinetic (f : SplitPosition → ℝ) : ℝ := + (1/2:ℝ)*((∑ a : Fin 2, ∫ p, (splitPlanarPartial f a p)^2) + + ∫ p, (splitVerticalPartial f p)^2) + +def splitRealForm (V : SplitPosition → ℝ) (f : SplitPosition → ℝ) : ℝ := + splitRealKinetic f+∫ p, V p*f p^2 + +def splitSeparablePotential {m : ℕ} (u : Fin m → PlanarPosition) + (freq S : ℝ) (p : SplitPosition) : ℝ := + planarWellSum u p.1+verticalCapPotential freq S p.2 + +theorem splitPlanarForm_eq {m : ℕ} (u : Fin m → PlanarPosition) + {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + splitPlanarForm u f = + (1/2:ℝ)*(∑ a : Fin 2, ∫ p, (splitPlanarPartial f a p)^2) + + ∫ p, planarWellSum u p.1*f p^2 := by + have hk (a : Fin 2) : Integrable (fun z : ℝ => ∫ r : PlanarPosition, + (splitPlanarPartial f a (r,z))^2) := by + have hi : Integrable (fun p => (splitPlanarPartial f a p)^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact splitPlanarPartial_square_integrable hf hc a + exact hi.integral_prod_right + have hp : Integrable (fun p : SplitPosition => planarWellSum u p.1*f p^2) := + split_potential_integrable hf.continuous hc ((planarWellSum_continuous u).comp continuous_fst) + have hp' : Integrable (fun z : ℝ => ∫ r : PlanarPosition, planarWellSum u r*f (r,z)^2) := by + have hi : Integrable (fun p : SplitPosition => planarWellSum u p.1*f p^2) + (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hp + exact hi.integral_prod_right + unfold splitPlanarForm + simp_rw [planarTestForm, splitPlanarPartial_eq hf] + rw [integral_add ((integrable_finsetSum _ (fun a _ => hk a)).const_mul _) hp', + integral_const_mul, integral_finsetSum _ (fun a _ => hk a)] + simp_rw [split_integral_planar _ (splitPlanarPartial_square_integrable hf hc _)] + rw [split_integral_planar _ hp] + +theorem splitVerticalForm_eq (freq S : ℝ) + {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + splitVerticalForm freq S f = + (1/2:ℝ)*(∫ p, (splitVerticalPartial f p)^2) + + ∫ p, verticalCapPotential freq S p.2*f p^2 := by + have hk := splitVerticalPartial_square_integrable hf hc + have hk' : Integrable (fun r : PlanarPosition => ∫ z : ℝ, + (splitVerticalPartial f (r,z))^2) := by + have hi : Integrable (fun p => (splitVerticalPartial f p)^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hk + exact hi.integral_prod_left + have hp : Integrable (fun p : SplitPosition => verticalCapPotential freq S p.2*f p^2) := by + apply split_potential_integrable hf.continuous hc + unfold verticalCapPotential + fun_prop + have hp' : Integrable (fun r : PlanarPosition => ∫ z : ℝ, verticalCapPotential freq S z*f (r,z)^2) := by + have hi : Integrable (fun p : SplitPosition => verticalCapPotential freq S p.2*f p^2) + (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hp + exact hi.integral_prod_left + unfold splitVerticalForm + simp_rw [verticalCappedForm, splitVerticalPartial_eq hf] + rw [integral_add (hk'.const_mul _) hp', integral_const_mul, + split_integral_vertical _ hk, split_integral_vertical _ hp] + +theorem splitSeparableForm_eq {m : ℕ} (u : Fin m → PlanarPosition) (freq S : ℝ) + {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + splitRealForm (splitSeparablePotential u freq S) f = + splitPlanarForm u f+splitVerticalForm freq S f := by + have hp : Integrable (fun p : SplitPosition => planarWellSum u p.1*f p^2) := + split_potential_integrable hf.continuous hc ((planarWellSum_continuous u).comp continuous_fst) + have hv : Integrable (fun p : SplitPosition => verticalCapPotential freq S p.2*f p^2) := by + apply split_potential_integrable hf.continuous hc + unfold verticalCapPotential + fun_prop + rw [splitPlanarForm_eq u hf hc, splitVerticalForm_eq freq S hf hc] + unfold splitRealForm splitRealKinetic splitSeparablePotential + simp_rw [add_mul] + rw [integral_add hp hv] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIntegrals.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIntegrals.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b14ff419adc79703a2ab88dfaf529a47ecc6dcb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFormIntegrals.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitTestFunctions + +namespace OAI + +/-! Integrability of the actual sliced forms. These lemmas justify applying +Fubini and integrating the published one-dimensional and planar estimates. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem split_square_integrable {f : SplitPosition → ℝ} + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + Integrable (fun p => f p^2) := + (hf.continuous.memLp_of_hasCompactSupport hc (p := 2)).integrable_sq + +theorem split_potential_integrable {f V : SplitPosition → ℝ} + (hf : Continuous f) (hc : HasCompactSupport f) (hV : Continuous V) : + Integrable (fun p => V p*f p^2) := by + have hs : HasCompactSupport (fun p => f p^2) := + hc.comp_left (g := fun t : ℝ => t^2) (by norm_num) + have hp : HasCompactSupport (fun p => V p*f p^2) := hs.mul_left + exact (hV.mul (hf.pow 2)).integrable_of_hasCompactSupport hp + +theorem split_planar_slice_contDiff {f : SplitPosition → ℝ} + (hf : ContDiff ℝ 1 f) (z : ℝ) : ContDiff ℝ 1 (fun r => f (r,z)) := + hf.comp (contDiff_id.prodMk contDiff_const) + +theorem split_vertical_slice_contDiff {f : SplitPosition → ℝ} + (hf : ContDiff ℝ 1 f) (r : PlanarPosition) : ContDiff ℝ 1 (fun z => f (r,z)) := + hf.comp (contDiff_const.prodMk contDiff_id) + +theorem split_planar_mass_integral {f : SplitPosition → ℝ} + (hf : MemLp f 2) : + (∫ z : ℝ, ∫ r : PlanarPosition, f (r,z)^2) = ∫ p, f p^2 := by + have hi : Integrable (fun p : SplitPosition => f p^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hf.integrable_sq + simpa only [Measure.volume_eq_prod] using (integral_prod_symm _ hi).symm + +theorem split_vertical_mass_integral {f : SplitPosition → ℝ} + (hf : MemLp f 2) : + (∫ r : PlanarPosition, ∫ z : ℝ, f (r,z)^2) = ∫ p, f p^2 := by + have hi : Integrable (fun p : SplitPosition => f p^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hf.integrable_sq + simpa only [Measure.volume_eq_prod] using (integral_prod _ hi).symm + +theorem split_planar_form_integrable {m : ℕ} (u : Fin m → PlanarPosition) + {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + Integrable (fun z => planarTestForm (planarWellSum u) (fun r => f (r,z))) := by + have hk : ∀ a : Fin 2, Integrable (fun z : ℝ => + ∫ r : PlanarPosition, (splitPlanarPartial f a (r,z))^2) := by + intro a + have hi : Integrable (fun p => (splitPlanarPartial f a p)^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact splitPlanarPartial_square_integrable hf hc a + exact hi.integral_prod_right + have hi : Integrable (fun p : SplitPosition => planarWellSum u p.1*f p^2) + (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact split_potential_integrable hf.continuous hc + ((planarWellSum_continuous u).comp continuous_fst) + have he : (fun z => planarTestForm (planarWellSum u) (fun r => f (r,z))) = + (fun z => (1/2:ℝ)*(∑ a : Fin 2, ∫ r : PlanarPosition, + (splitPlanarPartial f a (r,z))^2) + ∫ r, planarWellSum u r*f (r,z)^2) := by + funext z + simp only [planarTestForm, splitPlanarPartial_eq hf] + rw [he] + exact ((integrable_finsetSum _ (fun a _ => hk a)).const_mul (1/2)).add + hi.integral_prod_right + +theorem split_vertical_form_integrable (freq S : ℝ) + {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + Integrable (fun r : PlanarPosition => verticalCappedForm freq S (fun z => f (r,z))) := by + have hk : Integrable (fun p : SplitPosition => (splitVerticalPartial f p)^2) + (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact splitVerticalPartial_square_integrable hf hc + have hi : Integrable (fun p : SplitPosition => verticalCapPotential freq S p.2*f p^2) + (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + apply split_potential_integrable hf.continuous hc + unfold verticalCapPotential + fun_prop + have he : (fun r : PlanarPosition => verticalCappedForm freq S (fun z => f (r,z))) = + (fun r => (1/2:ℝ)*(∫ z : ℝ, (splitVerticalPartial f (r,z))^2) + + ∫ z, verticalCapPotential freq S z*f (r,z)^2) := by + funext r + simp only [verticalCappedForm, splitVerticalPartial_eq hf] + rw [he] + exact (hk.integral_prod_left.const_mul (1/2)).add hi.integral_prod_left + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFrameBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFrameBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3d593b9c667e65d8363883ca7cd8aed69f309e6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitFrameBound.lean @@ -0,0 +1,34 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarSliceProjection + +namespace OAI + +/-! The planar frame estimate on arbitrary full L2 slices. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem split_planar_frame_bound {D : ℝ} {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ z, ∑ i, (planarCoefficient (u i) f z)^2) ≤ + (1+m*localizedOverlapBound D)*(∫ p, f p^2) := by + have hp : MemLp f 2 ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + simpa only [Measure.volume_eq_prod] using hf + have hi : Integrable (fun z : ℝ => ∑ i, (planarCoefficient (u i) f z)^2) := + integrable_finsetSum _ (fun i _ => (planarCoefficient_contraction (u i) f hf).1.integrable_sq) + have hraw := hp.integrable_sq.integral_prod_right + have hbound : ∀ᵐ z : ℝ, (∑ i, (planarCoefficient (u i) f z)^2) ≤ + (1+m*localizedOverlapBound D)*(∫ r : PlanarPosition, f (r,z)^2) := by + filter_upwards [split_memLp_planar_slices f hf] with z hz + exact planar_modes_frame_bound u hsep (fun r => f (r,z)) hz + have h := integral_mono_ae hi (hraw.const_mul (1+m*localizedOverlapBound D)) hbound + rw [integral_const_mul,← integral_prod_symm _ hp.integrable_sq] at h + simpa only [Measure.volume_eq_prod] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitIntegratedBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitIntegratedBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4521ee8910378ee6f3b3218d18c4b5062a7eccb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitIntegratedBounds.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFormIntegrals + +namespace OAI + +/-! Actual integrated form bounds. The premises name only the published +isolated-well and harmonic-oscillator spectral results. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem splitPlanarForm_projection_lower + (hpublished : PlanarSobolev.ManufacturedPlanarGroundGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η : ℝ), 8 ≤ D → 0 < η → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + ∀ f : SplitPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + ((-1/2:ℝ)+γ-planarSiteDerivativeBound D^2- + γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8)))*(∫ p, f p^2) - + γ*(1+η)*(∫ z, ∑ i, (planarCoefficient (u i) f z)^2) ≤ splitPlanarForm u f := by + obtain ⟨γ,hγ,hsmall,hbound⟩ := planarWellSum_test_projection_bound hpublished + refine ⟨γ,hγ,hsmall,fun m D η hD hη u hsep f hf hc => ?_⟩ + have hL2 : MemLp f 2 := hf.continuous.memLp_of_hasCompactSupport hc + have hmass : Integrable (fun z : ℝ => ∫ r : PlanarPosition, f (r,z)^2) := by + have hi : Integrable (fun p : SplitPosition => f p^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hL2.integrable_sq + exact hi.integral_prod_right + have hcoeff : Integrable (fun z : ℝ => ∑ i, (planarCoefficient (u i) f z)^2) := + integrable_finsetSum _ (fun i _ => (planarCoefficient_contraction (u i) f hL2).1.integrable_sq) + have hb := integral_mono + ((hmass.const_mul _).sub (hcoeff.const_mul _)) + (split_planar_form_integrable u hf hc) + (fun z => hbound m D η hD hη u hsep (fun r => f (r,z)) + (split_planar_slice_contDiff hf z) (compact_planar_slice hc z)) + simp only [Pi.sub_apply] at hb + rw [integral_sub (hmass.const_mul _) (hcoeff.const_mul _), + integral_const_mul, integral_const_mul, split_planar_mass_integral hL2] at hb + exact hb + +theorem splitVerticalForm_projection_lower + (hpublished : PublishedVerticalOscillatorGap) + {freq S η : ℝ} (hfreq : 0 < freq) (hS : 0 < S) (hη : 0 < η) + (hbarrier : 3*freq/2 ≤ freq^2*S^2/8) + (f : SplitPosition → ℝ) (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + (3*freq/2-verticalCutoffDerivativeBound S^2/2- + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8))*(∫ p, f p^2) - + freq*(1+η)*(∫ r, (verticalCoefficient freq f r)^2) ≤ splitVerticalForm freq S f := by + have hL2 : MemLp f 2 := hf.continuous.memLp_of_hasCompactSupport hc + have hmass : Integrable (fun r : PlanarPosition => ∫ z : ℝ, f (r,z)^2) := by + have hi : Integrable (fun p : SplitPosition => f p^2) (volume.prod volume) := by + rw [← Measure.volume_eq_prod] + exact hL2.integrable_sq + exact hi.integral_prod_left + have hcoeff := (verticalCoefficient_contraction hfreq f hL2).1.integrable_sq + have hb := integral_mono + ((hmass.const_mul _).sub (hcoeff.const_mul _)) + (split_vertical_form_integrable freq S hf hc) + (fun r => verticalCappedForm_global_projection_lower hpublished hfreq hS hη hbarrier + (fun z => f (r,z)) (split_vertical_slice_contDiff hf r) (compact_vertical_slice hc r)) + simp only [Pi.sub_apply] at hb + rw [integral_sub (hmass.const_mul _) (hcoeff.const_mul _), + integral_const_mul, integral_const_mul, split_vertical_mass_integral hL2] at hb + exact hb + +/-- Conditional on the two precisely stated published spectral inputs, this +is a finite-rank lower bound for the actual split-coordinate Schrödinger form. -/ +theorem split_test_spectral_lower + (hp : PlanarSobolev.ManufacturedPlanarGroundGap) + (hv : PublishedVerticalOscillatorGap) : + ∃ γ : ℝ, 0 < γ ∧ γ ≤ 1/4 ∧ ∀ (m : ℕ) (D η freq S : ℝ), + 8 ≤ D → 0 < η → 0 < freq → 0 < S → 3*freq/2 ≤ freq^2*S^2/8 → + ∀ u : Fin m → PlanarPosition, (∀ i j, i ≠ j → D ≤ ‖u i-u j‖) → + γ*(1+η)*(1+m*localizedOverlapBound D) ≤ freq*(1+η) → + ∀ f : SplitPosition → ℝ, ContDiff ℝ 1 f → HasCompactSupport f → + (((-1/2:ℝ)+γ-planarSiteDerivativeBound D^2- + γ*(1+η⁻¹)*m*planarSiteTailConstant*Real.exp (-(19/20:ℝ)*(D/8))) + + (3*freq/2-verticalCutoffDerivativeBound S^2/2- + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) - + freq*(1+η))*(∫ p, f p^2) - + γ*(1+η)*(∑ i, (∫ p, f p*localizedMode freq (u i) p)^2) ≤ + splitPlanarForm u f+splitVerticalForm freq S f := by + obtain ⟨γ,hγ,hsmall,hplanar⟩ := splitPlanarForm_projection_lower hp + refine ⟨γ,hγ,hsmall,fun m D η freq S hD hη hfreq hS hbarrier u hsep hdom f hf hc => ?_⟩ + exact split_form_projection_lower hfreq (mul_nonneg hγ.le (by positivity)) u hsep hdom f + (hf.continuous.memLp_of_hasCompactSupport hc) + (hplanar m D η hD hη u hsep f hf hc) + (splitVerticalForm_projection_lower hv hfreq hS hη hbarrier f hf hc) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ab9b6799f9a6ad5d0658656e0533f2b1a74745b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionBudget.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitProjectionPairing + +namespace OAI + +/-! The full planar slice penalty is controlled by transverse mass and +the finite family of actual tensor-orbital coefficients. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarCoefficient_mass_split {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ z, (planarCoefficient u f z)^2) = + (∫ z, (planarCoefficient u (verticalResidual freq f) z)^2) + + (∫ p, f p*localizedMode freq u p)^2 := by + let a := verticalCoefficient freq f + let c := ∫ r, a r*normalizedPlanarMode (r-u) + let b := planarCoefficient u f + let r := planarCoefficient u (verticalResidual freq f) + have ha : MemLp a 2 := (verticalCoefficient_contraction hfreq f hf).1 + have hl := verticalLift_memLp hfreq a ha + have hr := (planarCoefficient_contraction u (verticalResidual freq f) + (verticalResidual_mass hfreq f hf).1).1 + have hbeq : b =ᵐ[volume] fun z => r z+c*verticalMode freq z := by + have hs := planarCoefficient_sub_ae u f (verticalLift freq a) hf hl + filter_upwards [hs] with z hz + have he := planarCoefficient_lift u freq a z + change r z = b z-planarCoefficient u (verticalLift freq a) z at hz + rw [he] at hz + change b z = r z+c*verticalMode freq z + dsimp [c] + linarith + rw [verticalCoefficient_pair_tensor hfreq u f hf] + change (∫ z, (b z)^2) = (∫ z, (r z)^2)+c^2 + calc + _ = ∫ z, (r z+c*verticalMode freq z)^2 := + integral_congr_ae (hbeq.mono (fun z hz => by rw [hz])) + _ = (∫ z, (r z)^2)+(2*c)*(∫ z, r z*verticalMode freq z)+ + c^2*(∫ z, (verticalMode freq z)^2) := by + have he : (fun z => (r z+c*verticalMode freq z)^2) = + (fun z => (r z)^2+((2*c)*(r z*verticalMode freq z)+c^2*(verticalMode freq z)^2)) := by + funext z + ring + have hc := hr.integrable_mul (verticalMode_memLp hfreq) + rw [he,integral_add (f := fun z => (r z)^2) + (g := fun z => (2*c)*(r z*verticalMode freq z)+c^2*(verticalMode freq z)^2) + hr.integrable_sq + ((hc.const_mul (2*c)).add ((verticalMode_square_integrable hfreq).const_mul (c^2))), + integral_add (f := fun z => (2*c)*(r z*verticalMode freq z)) + (g := fun z => c^2*(verticalMode freq z)^2) + (hc.const_mul (2*c)) ((verticalMode_square_integrable hfreq).const_mul (c^2)), + integral_const_mul,integral_const_mul] + ring + _ = _ := by + rw [residual_planarCoefficient_orthogonal hfreq u f hf,verticalMode_normalized hfreq] + ring + +/-- The estimate removes the spurious infinite-dimensional planar penalty +in the excited transverse sector, retaining only actual tensor coefficients. -/ +theorem split_projection_budget {freq D : ℝ} (hfreq : 0 < freq) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ z, ∑ i, (planarCoefficient (u i) f z)^2) ≤ + (1+m*localizedOverlapBound D)* + ((∫ p, f p^2)-(∫ r, (verticalCoefficient freq f r)^2)) + + ∑ i, (∫ p, f p*localizedMode freq (u i) p)^2 := by + have hR := verticalResidual_mass hfreq f hf + have hb := split_planar_frame_bound u hsep (verticalResidual freq f) hR.1 + rw [hR.2] at hb + have he : (∫ z, ∑ i, (planarCoefficient (u i) f z)^2) = + (∫ z, ∑ i, (planarCoefficient (u i) (verticalResidual freq f) z)^2) + + ∑ i, (∫ p, f p*localizedMode freq (u i) p)^2 := by + rw [integral_finsetSum _ (fun i _ => (planarCoefficient_contraction (u i) f hf).1.integrable_sq), + integral_finsetSum _ (fun i _ => + (planarCoefficient_contraction (u i) (verticalResidual freq f) hR.1).1.integrable_sq)] + simp_rw [planarCoefficient_mass_split hfreq _ f hf] + rw [Finset.sum_add_distrib] + rw [he] + exact add_le_add hb le_rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionPairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..b095954d30e2e97f72a076e30fbe78e3df07a2e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitProjectionPairing.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFrameBound + +namespace OAI + +/-! Fubini identities for the actual localized tensor orbitals and the +transverse residual. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem planarCoefficient_pair_tensor {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ z, planarCoefficient u f z*verticalMode freq z) = + ∫ p, f p*localizedMode freq u p := by + have hi : Integrable (fun p => f p*localizedMode freq u p) + ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + rw [← Measure.volume_eq_prod] + exact hf.integrable_mul (localizedMode_memLp hfreq u) + rw [Measure.volume_eq_prod,integral_prod_symm _ hi] + apply integral_congr_ae + filter_upwards [] with z + unfold planarCoefficient + rw [← integral_mul_const] + apply integral_congr_ae + filter_upwards [] with r + unfold localizedMode + ring + +theorem verticalCoefficient_pair_tensor {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ p, f p*localizedMode freq u p) = + ∫ r, verticalCoefficient freq f r*normalizedPlanarMode (r-u) := by + have hi : Integrable (fun p => f p*localizedMode freq u p) + ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + rw [← Measure.volume_eq_prod] + exact hf.integrable_mul (localizedMode_memLp hfreq u) + rw [Measure.volume_eq_prod,integral_prod _ hi] + apply integral_congr_ae + filter_upwards [] with r + unfold verticalCoefficient + rw [← integral_mul_const] + apply integral_congr_ae + filter_upwards [] with z + unfold localizedMode + ring + +theorem residual_planarCoefficient_orthogonal {freq : ℝ} (hfreq : 0 < freq) + (u : PlanarPosition) (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ z, planarCoefficient u (verticalResidual freq f) z*verticalMode freq z) = 0 := by + rw [planarCoefficient_pair_tensor hfreq u _ (verticalResidual_mass hfreq f hf).1] + exact verticalResidual_orthogonal hfreq f hf (fun r => normalizedPlanarMode (r-u)) + (normalizedPlanarMode_memLp.comp_measurePreserving (measurePreserving_sub_right volume u)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitPullback.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitPullback.lean new file mode 100644 index 0000000000000000000000000000000000000000..f10a14514df74d881b4c48009ed3368ef6972803 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitPullback.lean @@ -0,0 +1,105 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitFormIdentity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField + +namespace OAI + +/-! Exact kinetic-energy pullback between physical Euclidean space and +planar/transverse product coordinates. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def splitPullback (f : Position → ℝ) (p : SplitPosition) : ℝ := + f (positionSplitCoordinates.symm p) + +theorem splitPullback_contDiff {f : Position → ℝ} (hf : ContDiff ℝ 1 f) : + ContDiff ℝ 1 (splitPullback f) := + hf.comp positionSplitCoordinates.symm.contDiff + +theorem splitPullback_compact {f : Position → ℝ} (hc : HasCompactSupport f) : + HasCompactSupport (splitPullback f) := + hc.comp_homeomorph positionSplitCoordinates.symm.toHomeomorph + +theorem splitPullback_integral (f : Position → ℝ) : + (∫ p, splitPullback f p) = ∫ x, f x := by + rw [← positionSplitCoordinates_integral (splitPullback f)] + simp only [splitPullback, ContinuousLinearEquiv.symm_apply_apply] + +theorem splitCoordinate_planar_axis (a : Fin 2) : + positionSplitCoordinates.symm (planarAxis a,0) = + EuclideanSpace.single (Fin.castSucc a) (1:ℝ) := by + apply positionSplitCoordinates.injective + rw [ContinuousLinearEquiv.apply_symm_apply] + apply Prod.ext + · ext i + fin_cases i <;> fin_cases a <;> + simp [planarAxis, positionSplitCoordinates_fst_zero, positionSplitCoordinates_fst_one] + · rw [positionSplitCoordinates_snd] + fin_cases a <;> simp + +theorem splitCoordinate_vertical_axis : + positionSplitCoordinates.symm (0,1) = EuclideanSpace.single (2:Fin 3) (1:ℝ) := by + apply positionSplitCoordinates.injective + rw [ContinuousLinearEquiv.apply_symm_apply] + apply Prod.ext + · ext i + fin_cases i <;> simp [positionSplitCoordinates_fst_zero, positionSplitCoordinates_fst_one] + · rw [positionSplitCoordinates_snd] + simp + +theorem splitPullback_planar_partial {f : Position → ℝ} (hf : ContDiff ℝ 1 f) + (a : Fin 2) (p : SplitPosition) : + splitPlanarPartial (splitPullback f) a p = + fderiv ℝ f (positionSplitCoordinates.symm p) (EuclideanSpace.single (Fin.castSucc a) 1) := by + have h := ((hf.differentiable (by norm_num)) (positionSplitCoordinates.symm p)).hasFDerivAt.comp p + positionSplitCoordinates.symm.hasFDerivAt + have he := congrArg (fun L => L (planarAxis a,0)) h.fderiv + unfold splitPlanarPartial splitPullback + simpa only [Function.comp_def, + ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, + splitCoordinate_planar_axis] using he + +theorem splitPullback_vertical_partial {f : Position → ℝ} (hf : ContDiff ℝ 1 f) + (p : SplitPosition) : + splitVerticalPartial (splitPullback f) p = + fderiv ℝ f (positionSplitCoordinates.symm p) (EuclideanSpace.single (2:Fin 3) 1) := by + have h := ((hf.differentiable (by norm_num)) (positionSplitCoordinates.symm p)).hasFDerivAt.comp p + positionSplitCoordinates.symm.hasFDerivAt + have he := congrArg (fun L => L ((0:PlanarPosition),(1:ℝ))) h.fderiv + unfold splitVerticalPartial splitPullback + simpa only [Function.comp_def, + ContinuousLinearMap.comp_apply, ContinuousLinearEquiv.coe_coe, + splitCoordinate_vertical_axis] using he + +def positionRealKinetic (f : Position → ℝ) : ℝ := + (1/2:ℝ)*∑ a : Fin 3, ∫ x, (fderiv ℝ f x (EuclideanSpace.single a 1))^2 + +def positionRealForm (V f : Position → ℝ) : ℝ := + positionRealKinetic f+∫ x, V x*f x^2 + +theorem splitPullback_kinetic {f : Position → ℝ} (hf : ContDiff ℝ 1 f) : + splitRealKinetic (splitPullback f) = positionRealKinetic f := by + unfold splitRealKinetic positionRealKinetic + simp_rw [splitPullback_planar_partial hf, splitPullback_vertical_partial hf] + have hi (a : Fin 3) : (∫ p, (fderiv ℝ f (positionSplitCoordinates.symm p) + (EuclideanSpace.single a 1))^2) = ∫ x, (fderiv ℝ f x (EuclideanSpace.single a 1))^2 := + splitPullback_integral (fun x => (fderiv ℝ f x (EuclideanSpace.single a 1))^2) + simp_rw [hi] + rw [Fin.sum_univ_castSucc (n := 2)] + rfl + +theorem splitPullback_form (V : Position → ℝ) {f : Position → ℝ} (hf : ContDiff ℝ 1 f) : + splitRealForm (fun p => V (positionSplitCoordinates.symm p)) (splitPullback f) = + positionRealForm V f := by + unfold splitRealForm positionRealForm + rw [splitPullback_kinetic hf] + congr 1 + exact splitPullback_integral (fun x => V x*f x^2) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitSpectralBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitSpectralBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..edcbd30d55758508be24f32a5fb697ffd2e1e252 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitSpectralBudget.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitProjectionBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedGap +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellLocalization + +namespace OAI + +/-! Combining the actual planar and transverse form estimates. The +projection budget removes the planar penalty from transverse excitations. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def splitPlanarForm {m : ℕ} (u : Fin m → PlanarPosition) (f : SplitPosition → ℝ) : ℝ := + ∫ z, planarTestForm (planarWellSum u) (fun r => f (r,z)) + +def splitVerticalForm (freq S : ℝ) (f : SplitPosition → ℝ) : ℝ := + ∫ r : PlanarPosition, verticalCappedForm freq S (fun z => f (r,z)) + +theorem split_form_projection_lower {freq D S Ep Ev a b : ℝ} + (hfreq : 0 < freq) (ha : 0 ≤ a) + {m : ℕ} (u : Fin m → PlanarPosition) + (hsep : ∀ i j, i ≠ j → D ≤ ‖u i-u j‖) + (hdominate : a*(1+m*localizedOverlapBound D) ≤ b) + (f : SplitPosition → ℝ) (hf : MemLp f 2) + (hp : Ep*(∫ p, f p^2)-a*(∫ z, ∑ i, (planarCoefficient (u i) f z)^2) ≤ + splitPlanarForm u f) + (hv : Ev*(∫ p, f p^2)-b*(∫ r, (verticalCoefficient freq f r)^2) ≤ + splitVerticalForm freq S f) : + (Ep+Ev-b)*(∫ p, f p^2)-a*(∑ i, (∫ p, f p*localizedMode freq (u i) p)^2) ≤ + splitPlanarForm u f+splitVerticalForm freq S f := by + let M := ∫ p, f p^2 + let Z := ∫ r, (verticalCoefficient freq f r)^2 + let P := ∫ z, ∑ i, (planarCoefficient (u i) f z)^2 + let T := ∑ i, (∫ p, f p*localizedMode freq (u i) p)^2 + let C := 1+m*localizedOverlapBound D + have hZ : Z ≤ M := (verticalCoefficient_contraction hfreq f hf).2 + have hP : P ≤ C*(M-Z)+T := split_projection_budget hfreq u hsep f hf + have hpen : a*P+b*Z ≤ b*M+a*T := by + calc + a*P+b*Z ≤ a*(C*(M-Z)+T)+b*Z := + add_le_add (mul_le_mul_of_nonneg_left hP ha) le_rfl + _ = a*C*M+(b-a*C)*Z+a*T := by ring + _ ≤ a*C*M+(b-a*C)*M+a*T := + add_le_add (add_le_add le_rfl + (mul_le_mul_of_nonneg_left hZ (sub_nonneg.mpr hdominate))) le_rfl + _ = b*M+a*T := by ring + change (Ep+Ev-b)*M-a*T ≤ _ + change Ep*M-a*P ≤ _ at hp + change Ev*M-b*Z ≤ _ at hv + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitTestFunctions.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitTestFunctions.lean new file mode 100644 index 0000000000000000000000000000000000000000..964b49b61d1ef68991445a7999cc3e33aa8e025c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/SplitTestFunctions.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SplitSpectralBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarMultiwellProjection + +namespace OAI + +/-! Classical test functions in split coordinates: compact slices and +their exact directional derivatives. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem compact_planar_slice {f : SplitPosition → ℝ} (hc : HasCompactSupport f) (z : ℝ) : + HasCompactSupport (fun r => f (r,z)) := by + have hK := hc.image (continuous_fst : Continuous (Prod.fst : SplitPosition → PlanarPosition)) + apply hK.of_isClosed_subset (isClosed_tsupport _) + apply closure_minimal _ hK.isClosed + intro r hr + exact ⟨(r,z),subset_tsupport f hr,rfl⟩ + +theorem compact_vertical_slice {f : SplitPosition → ℝ} (hc : HasCompactSupport f) (r : PlanarPosition) : + HasCompactSupport (fun z => f (r,z)) := by + have hK := hc.image (continuous_snd : Continuous (Prod.snd : SplitPosition → ℝ)) + apply hK.of_isClosed_subset (isClosed_tsupport _) + apply closure_minimal _ hK.isClosed + intro z hz + exact ⟨(r,z),subset_tsupport f hz,rfl⟩ + +def splitPlanarPartial (f : SplitPosition → ℝ) (a : Fin 2) (p : SplitPosition) : ℝ := + fderiv ℝ f p (planarAxis a,0) + +def splitVerticalPartial (f : SplitPosition → ℝ) (p : SplitPosition) : ℝ := + fderiv ℝ f p (0,1) + +theorem splitPlanarPartial_eq {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) + (a : Fin 2) (r : PlanarPosition) (z : ℝ) : + planarPartial (fun s => f (s,z)) (planarAxis a) r = splitPlanarPartial f a (r,z) := by + have h := ((hf.differentiable (by norm_num)) (r,z)).hasFDerivAt.comp r + ((hasFDerivAt_id (𝕜 := ℝ) r).prodMk (hasFDerivAt_const z r)) + unfold planarPartial splitPlanarPartial + have he := congrArg (fun L => L (planarAxis a)) h.fderiv + exact he + +theorem splitVerticalPartial_eq {f : SplitPosition → ℝ} (hf : ContDiff ℝ 1 f) + (r : PlanarPosition) (z : ℝ) : + deriv (fun s => f (r,s)) z = splitVerticalPartial f (r,z) := by + have h := ((hf.differentiable (by norm_num)) (r,z)).hasFDerivAt.comp_hasDerivAt z + ((hasDerivAt_const z r).prodMk (hasDerivAt_id z)) + exact h.deriv + +theorem compact_directional_square_integrable + {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + [MeasurableSpace E] [BorelSpace E] + (μ : Measure E) [IsLocallyFiniteMeasure μ] + {f : E → ℝ} (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) (e : E) : + Integrable (fun x => (fderiv ℝ f x e)^2) μ := by + have hd : Continuous (fderiv ℝ f) := hf.continuous_fderiv one_ne_zero + have he : Continuous (fun x => fderiv ℝ f x e) := hd.clm_apply continuous_const + have hs : HasCompactSupport (fun x => fderiv ℝ f x e) := hc.fderiv_apply ℝ e + exact (he.memLp_of_hasCompactSupport hs (p := 2) (μ := μ)).integrable_sq + +theorem splitPlanarPartial_square_integrable {f : SplitPosition → ℝ} + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) (a : Fin 2) : + Integrable (fun p => (splitPlanarPartial f a p)^2) := + compact_directional_square_integrable volume hf hc (planarAxis a,0) + +theorem splitVerticalPartial_square_integrable {f : SplitPosition → ℝ} + (hf : ContDiff ℝ 1 f) (hc : HasCompactSupport f) : + Integrable (fun p => (splitVerticalPartial f p)^2) := + compact_directional_square_integrable volume hf hc (0,1) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TM2Composition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TM2Composition.lean new file mode 100644 index 0000000000000000000000000000000000000000..bee7d84f8ee2b4131550a6f43951054194d7174e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TM2Composition.lean @@ -0,0 +1,24 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialTimeSize +import OAI.Computability.MinUncut.Machines.MachineSubstitution + +namespace OAI + +/-! Polynomial-time composition uses concrete finite TM2 +compiler. It lifts the heterogeneous machine programs and performs a two-pass +stack transfer with a proved linear intermediate-word cost. -/ + +namespace ContinuumCoulomb.TM2Composition +open Turing + +/-- Actual polynomial-time composition, with the intermediate length bound +proved from the first machine's execution rather than postulated. -/ +noncomputable def computable {α β γ : Type} + {ea : α → List Bool} {eb : β → List Bool} {ec : γ → List Bool} + {f : α → β} {g : β → γ} + (hf : TM2ComputableInPolyTime ea eb f) (hg : TM2ComputableInPolyTime eb ec g) : + TM2ComputableInPolyTime ea ec (g ∘ f) := + MinUncutGames.Foundations.Complexity.MachineSequential.composeBits (f := f) (g := g) hf hg + +end ContinuumCoulomb.TM2Composition + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderBottom.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderBottom.lean new file mode 100644 index 0000000000000000000000000000000000000000..a16a08c01c9adae36f08ae80a689e018e520129b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderBottom.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ThirdOrderPerturbation + +namespace OAI + +/-! Third-order comparison of actual finite-dimensional ground energies. -/ + +noncomputable section +namespace ContinuumCoulomb.Perturbation +open scoped InnerProductSpace +variable {L H : Type*} [NormedAddCommGroup L] [InnerProductSpace ℝ L] + [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +theorem thirdOrderForm_smul (C : L →L[ℝ] L) (T D : H →L[ℝ] H) + (B : L →L[ℝ] H) (r : ℝ) (p : L) : + thirdOrderForm C T D B (r • p) = r^2*thirdOrderForm C T D B p := by + simp only [thirdOrderForm,effectiveForm_smul,map_smul, + real_inner_smul_left,real_inner_smul_right] + ring + +def thirdOrderBottom (C : L →L[ℝ] L) (T D : H →L[ℝ] H) (B : L →L[ℝ] H) : ℝ := + sInf {e | ∃ p : L, ‖p‖ = 1 ∧ e = thirdOrderForm C T D B p} + +theorem thirdOrderForm_minimizer [FiniteDimensional ℝ L] + (C : L →L[ℝ] L) (T D : H →L[ℝ] H) (B : L →L[ℝ] H) + (u : L) (hu : ‖u‖ = 1) : + ∃ p : L, ‖p‖ = 1 ∧ ∀ x : L, + thirdOrderForm C T D B p*‖x‖^2 ≤ thirdOrderForm C T D B x := by + have := FiniteDimensional.proper_rclike ℝ L + have hTB : Continuous (fun p => T (B p)) := T.continuous.comp B.continuous + have hc : Continuous (thirdOrderForm C T D B) := + ((continuous_id.inner C.continuous).sub + (B.continuous.inner hTB)).add (hTB.inner (D.continuous.comp hTB)) + have hn : (Metric.sphere (0 : L) 1).Nonempty := ⟨u,by simpa using hu⟩ + obtain ⟨p,hp,hmin⟩ := (isCompact_sphere (0 : L) 1).exists_isMinOn hn hc.continuousOn + refine ⟨p,by simpa using hp,?_⟩ + intro x + by_cases hx : x = 0 + · simp [hx,thirdOrderForm,effectiveForm,inverseForm] + have hxn : ‖x‖ ≠ 0 := norm_ne_zero_iff.mpr hx + have hunit : ‖(‖x‖⁻¹ : ℝ) • x‖ = 1 := norm_smul_inv_norm hx + have h := hmin (show (‖x‖⁻¹ : ℝ) • x ∈ Metric.sphere (0 : L) 1 by simpa using hunit) + change thirdOrderForm C T D B p ≤ thirdOrderForm C T D B ((‖x‖⁻¹ : ℝ) • x) at h + rw [thirdOrderForm_smul] at h + calc + _ ≤ (‖x‖⁻¹^2*thirdOrderForm C T D B x)*‖x‖^2 := + mul_le_mul_of_nonneg_right h (sq_nonneg _) + _ = _ := by field_simp + +theorem thirdOrderBottom_eq (C : L →L[ℝ] L) (T D : H →L[ℝ] H) + (B : L →L[ℝ] H) (p : L) (hp : ‖p‖ = 1) + (hmin : ∀ x, thirdOrderForm C T D B p*‖x‖^2 ≤ thirdOrderForm C T D B x) : + thirdOrderBottom C T D B = thirdOrderForm C T D B p := by + have hl (e : ℝ) (he : ∃ x : L, ‖x‖ = 1 ∧ e = thirdOrderForm C T D B x) : + thirdOrderForm C T D B p ≤ e := by + obtain ⟨x,hx,rfl⟩ := he + simpa only [hx,one_pow,mul_one] using hmin x + exact le_antisymm (csInf_le ⟨_,hl⟩ ⟨p,hp,rfl⟩) (le_csInf ⟨_,p,hp,rfl⟩ hl) + +theorem thirdOrder_bottom_error (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} (hg : 0 < g) + (hd : 0 ≤ d) (hm : 0 ≤ m) (hsmall : 2*d+4*m ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hDsymm : ∀ x y, ⟪x,D y⟫_ℝ = ⟪D x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) (hD : ‖D‖ ≤ d) + (hμ : |μ| ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ thirdOrderForm C T D B p) + (p₀ : L) (hp₀ : ‖p₀‖ = 1) (he : thirdOrderForm C T D B p₀ = μ) : + |lowBlockBottom C A D B-μ| ≤ (2*d^2/g+2*m)*η^2 := by + have hμb := abs_le.mp hμ + have hnon : 0 < ‖p₀‖^2+‖-(T (B p₀))‖^2 := by rw [hp₀]; positivity + have hn : {e | ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q}.Nonempty := ⟨_,p₀,-(T (B p₀)),hnon,rfl⟩ + have hl (e : ℝ) (he : ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q) : μ-(2*d^2/g+2*m)*η^2 ≤ e := by + obtain ⟨p,q,hpq,rfl⟩ := he + exact thirdOrder_rayleigh_lower C A T D B hg hd hm hsmall hAT hAsymm + hDsymm hgap hTB hD hμb.2 hmin p q hpq + have hb : BddBelow {e | ∃ (p : L) (q : H), 0 < ‖p‖^2+‖q‖^2 ∧ + e = lowBlockRayleigh C A D B p q} := ⟨_,hl⟩ + have hlow : μ-(2*d^2/g+2*m)*η^2 ≤ lowBlockBottom C A D B := le_csInf hn hl + have hu : lowBlockBottom C A D B ≤ μ+m*η^2 := + (csInf_le hb ⟨p₀,-(T (B p₀)),hnon,rfl⟩).trans + (thirdOrder_trial_upper C A T D B hm hAT hTB hμb.1 p₀ hp₀ he) + have herr : m*η^2 ≤ (2*d^2/g+2*m)*η^2 := by + have hz : 0 ≤ 2*d^2/g := by positivity + exact mul_le_mul_of_nonneg_right (by linarith) (sq_nonneg η) + exact abs_le.mpr ⟨by linarith,by linarith⟩ + +theorem finite_thirdOrder_bottom_error [FiniteDimensional ℝ L] + (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) (B : L →L[ℝ] H) + {g d m η : ℝ} (hg : 0 < g) (hd : 0 ≤ d) (hm : 0 ≤ m) (hsmall : 2*d+4*m ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hDsymm : ∀ x y, ⟪x,D y⟫_ℝ = ⟪D x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) (hD : ‖D‖ ≤ d) + (hbound : ∀ p, ‖p‖ = 1 → |thirdOrderForm C T D B p| ≤ m) + (u : L) (hu : ‖u‖ = 1) : + |lowBlockBottom C A D B-thirdOrderBottom C T D B| ≤ (2*d^2/g+2*m)*η^2 := by + obtain ⟨p,hp,hmin⟩ := thirdOrderForm_minimizer C T D B u hu + rw [thirdOrderBottom_eq C T D B p hp hmin] + exact thirdOrder_bottom_error C A T D B hg hd hm hsmall hAT hAsymm hDsymm hgap + hTB hD (hbound p hp) hmin p hp rfl + +end ContinuumCoulomb.Perturbation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderPerturbation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderPerturbation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6392e85cc32935fc319dda0b9a53eea616fc26c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderPerturbation.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SharpBlockPerturbation + +namespace OAI + +/-! A third-order block estimate. Keeping the high-block correction in the +effective form makes simultaneous three-body gadgets have a decreasing error. -/ + +noncomputable section +namespace ContinuumCoulomb.Perturbation +open scoped InnerProductSpace + +variable {L H : Type*} [NormedAddCommGroup L] [InnerProductSpace ℝ L] + [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +def thirdOrderForm (C : L →L[ℝ] L) (T D : H →L[ℝ] H) (B : L →L[ℝ] H) + (p : L) : ℝ := effectiveForm C T B p + ⟪T (B p),D (T (B p))⟫_ℝ + +theorem thirdOrder_square_identity (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hDsymm : ∀ x y, ⟪x,D y⟫_ℝ = ⟪D x,y⟫_ℝ) (p : L) (q : H) : + lowBlockEnergy C A D B p q = thirdOrderForm C T D B p + + penaltyForm A (q+T (B p)) + ⟪q+T (B p),D (q+T (B p))⟫_ℝ - + 2*⟪q+T (B p),D (T (B p))⟫_ℝ := by + have hi := penalty_square_identity A T B hAT hAsymm p q (by norm_num : (1:ℝ) ≠ 0) + simp only [one_mul,inv_one,one_smul] at hi + have hc : ⟪T (B p),D q⟫_ℝ = ⟪q,D (T (B p))⟫_ℝ := by + rw [hDsymm,real_inner_comm] + simp only [map_add,inner_add_left,inner_add_right,hc] + unfold lowBlockEnergy blockEnergy thirdOrderForm effectiveForm + linarith + +private theorem quadratic_cross_bound {g d x z : ℝ} (hg : 0 < g) : + -(2*d^2/g)*z^2 ≤ g/2*x^2-2*d*x*z := by + apply (mul_le_mul_iff_right₀ hg).mp + field_simp + nlinarith [sq_nonneg (g*x-2*d*z)] + +theorem thirdOrder_energy_lower (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} (hg : 0 < g) + (_hd : 0 ≤ d) (hm : 0 ≤ m) (hsmall : 2*d+4*m ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hDsymm : ∀ x y, ⟪x,D y⟫_ℝ = ⟪D x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) (hD : ‖D‖ ≤ d) + (hμ : μ ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ thirdOrderForm C T D B p) + (p : L) (q : H) : + -(2*d^2/g+2*m)*η^2*‖p‖^2 ≤ + lowBlockEnergy C A D B p q-μ*(‖p‖^2+‖q‖^2) := by + let z := T (B p) + let y := q+z + have hi := thirdOrder_square_identity C A T D B hAT hAsymm hDsymm p q + have hnorm := norm_add_sq_two y (-z) + have hyz : y+(-z) = q := by dsimp [y]; abel + rw [hyz,norm_neg] at hnorm + have hz : ‖z‖^2 ≤ η^2*‖p‖^2 := by + simpa only [mul_pow] using pow_le_pow_left₀ (norm_nonneg _) (hTB p) 2 + have hdq : -(d*‖y‖^2) ≤ ⟪y,D y⟫_ℝ := by + have h := highPerturbation_abs_le D (g := 1) (ε := d) (by simpa using hD) y + simpa using (abs_le.mp h).1 + have hDz : ‖D z‖ ≤ d*‖z‖ := + (D.le_opNorm z).trans (mul_le_mul_of_nonneg_right hD (norm_nonneg _)) + have hcross : ⟪y,D z⟫_ℝ ≤ ‖y‖*d*‖z‖ := by + calc + _ ≤ ‖y‖*‖D z‖ := real_inner_le_norm _ _ + _ ≤ ‖y‖*(d*‖z‖) := mul_le_mul_of_nonneg_left hDz (norm_nonneg _) + _ = _ := by ring + have hquad := quadratic_cross_bound (d := d) (x := ‖y‖) (z := ‖z‖) hg + have hscale := mul_le_mul_of_nonneg_right hsmall (sq_nonneg ‖y‖) + have hμq := mul_le_mul_of_nonneg_right hμ (sq_nonneg ‖q‖) + have hmnorm := mul_le_mul_of_nonneg_left hnorm hm + have hK : 0 ≤ 2*d^2/g+2*m := by positivity + have hKz := mul_le_mul_of_nonneg_left hz hK + have hgp := hgap y + have hmp := hmin p + change lowBlockEnergy C A D B p q = thirdOrderForm C T D B p + + penaltyForm A y + ⟪y,D y⟫_ℝ - 2*⟪y,D z⟫_ℝ at hi + nlinarith + +theorem thirdOrder_rayleigh_lower (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {g d m η μ : ℝ} (hg : 0 < g) + (hd : 0 ≤ d) (hm : 0 ≤ m) (hsmall : 2*d+4*m ≤ g) + (hAT : ∀ x, A (T x) = x) + (hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) + (hDsymm : ∀ x y, ⟪x,D y⟫_ℝ = ⟪D x,y⟫_ℝ) + (hgap : ∀ q, g*‖q‖^2 ≤ penaltyForm A q) + (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) (hD : ‖D‖ ≤ d) + (hμ : μ ≤ m) (hmin : ∀ p, μ*‖p‖^2 ≤ thirdOrderForm C T D B p) + (p : L) (q : H) (hpq : 0 < ‖p‖^2+‖q‖^2) : + μ-(2*d^2/g+2*m)*η^2 ≤ lowBlockRayleigh C A D B p q := by + have he := thirdOrder_energy_lower C A T D B hg hd hm hsmall hAT hAsymm + hDsymm hgap hTB hD hμ hmin p q + unfold lowBlockRayleigh + apply (le_div_iff₀ hpq).mpr + have hKq : 0 ≤ (2*d^2/g+2*m)*η^2*‖q‖^2 := by positivity + nlinarith + +theorem thirdOrder_trial_identity (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) (hAT : ∀ x, A (T x) = x) (p : L) : + lowBlockEnergy C A D B p (-(T (B p))) = thirdOrderForm C T D B p := by + unfold lowBlockEnergy thirdOrderForm effectiveForm + rw [blockEnergy_trial_identity A T D B hAT] + simp only [map_neg,inner_neg_left,inner_neg_right] + ring + +theorem thirdOrder_trial_upper (C : L →L[ℝ] L) (A T D : H →L[ℝ] H) + (B : L →L[ℝ] H) {m η μ : ℝ} (hm : 0 ≤ m) + (hAT : ∀ x, A (T x) = x) (hTB : ∀ p, ‖T (B p)‖ ≤ η*‖p‖) + (hμ : -m ≤ μ) (p : L) (hp : ‖p‖ = 1) (he : thirdOrderForm C T D B p = μ) : + lowBlockRayleigh C A D B p (-(T (B p))) ≤ μ+m*η^2 := by + have hz := pow_le_pow_left₀ (norm_nonneg _) (hTB p) 2 + rw [hp,mul_one] at hz + unfold lowBlockRayleigh + rw [thirdOrder_trial_identity C A T D B hAT,he,hp,norm_neg] + apply (div_le_iff₀ (by positivity : (0:ℝ) < 1^2+‖T (B p)‖^2)).mpr + have hmz := mul_le_mul_of_nonneg_right hμ (sq_nonneg ‖T (B p)‖) + have hη := mul_le_mul_of_nonneg_left hz hm + have hx : 0 ≤ m*η^2*‖T (B p)‖^2 := by positivity + nlinarith + +end ContinuumCoulomb.Perturbation + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..05a935ffd8b5efde49b3e28225cd2d35fd581334 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/ThirdOrderScale.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ThirdOrderBottom + +namespace OAI + +/-! Polynomial scales for the simultaneous third-order estimate. -/ + +namespace ContinuumCoulomb.Perturbation + +theorem thirdOrder_scale_small {K R : ℝ} (hK : 1 ≤ K) (hR : 4*K ≤ R) : + 2*(K*R^2)+4*(2*K) ≤ R^3 := by + have hR4 : 4 ≤ R := by linarith + have hr2 : 4 ≤ R^2 := by nlinarith + have hfirst := mul_le_mul_of_nonneg_right hR (sq_nonneg R) + have hsecond := mul_le_mul_of_nonneg_left hr2 (show 0 ≤ R by linarith) + nlinarith + +theorem thirdOrder_scale_error {K R : ℝ} (hK : 1 ≤ K) (hR : 4*K ≤ R) : + (2*(K*R^2)^2/R^3+2*(2*K))*(K/R)^2 ≤ 4*K^4/R := by + have hRp : 0 < R := by linarith + have hKp : 0 < K := by linarith + apply (le_div_iff₀ hRp).mpr + have he : ((2*(K*R^2)^2/R^3+2*(2*K))*(K/R)^2)*R = + 2*K^4+4*K^3/R := by field_simp; ring + rw [he] + have hKR : 2 ≤ K*R := by nlinarith + have hk3 : 0 ≤ K^3 := by positivity + have h : 4*K^3/R ≤ 2*K^4 := by + apply (div_le_iff₀ hRp).mpr + nlinarith [mul_le_mul_of_nonneg_left hKR (show 0 ≤ 2*K^3 by positivity)] + linarith + +theorem thirdOrder_polynomial_schedule {K N : ℝ} (hK : 1 ≤ K) (hN : 1 ≤ N) : + let R := 8*K^4*N + 4*K ≤ R ∧ + 2*(K*R^2)+4*(2*K) ≤ R^3 ∧ + (2*(K*R^2)^2/R^3+2*(2*K))*(K/R)^2 ≤ 1/N := by + let R := 8*K^4*N + have hk4 : K ≤ K^4 := le_self_pow₀ hK (by norm_num : (4:ℕ) ≠ 0) + have hk4p : 0 < K^4 := by positivity + have hR : 4*K ≤ R := by + dsimp [R] + have h := mul_le_mul_of_nonneg_left hN (show 0 ≤ 8*K^4 by positivity) + nlinarith + refine ⟨hR,thirdOrder_scale_small hK hR,(thirdOrder_scale_error hK hR).trans ?_⟩ + have hNp : 0 < N := by linarith + change 4*K^4/(8*K^4*N) ≤ 1/N + calc + _ = 1/(2*N) := by field_simp; ring + _ ≤ 1/N := one_div_le_one_div_of_le hNp (by linarith) + +end ContinuumCoulomb.Perturbation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGauss.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGauss.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2f6c423c3dc9d031b82c5e47b0f3d30e2d59f84 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGauss.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MoserCoordinateProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussNodeProgram + +namespace OAI + +/-! Actual rational transport of Gauss nodes. A common polynomial precision +absorbs both the initial square-root error and the numerical flow error. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb.TransformedGauss +open CappedKernelProgram (Triple position) +open EulerRegisters (Registers) +open RationalGaussNodes (Signs) + +def precision (K P : ℕ) : ℕ := 2*(K+1)*(P+1) + +def value (rho U C K P N : ℕ) (scale S : ℚ) (sites : List (ℚ×ℚ)) + (k : Registers) (b : Signs) : Triple := + let T := precision K P + ManufacturedEuler.approximate rho U C T scale S sites (RationalGaussNodes.value T N k b) + +theorem error_budget (K P : ℕ) : + (1+(K:ℝ))*((precision K P:ℝ)+1)⁻¹ ≤ ((P:ℝ)+1)⁻¹ := by + have hP : 0 < (P:ℝ)+1 := by positivity + have hK : 0 < (K:ℝ)+1 := by positivity + have hT : (precision K P:ℝ) = 2*((K:ℝ)+1)*((P:ℝ)+1) := by + simp only [precision,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_add,Nat.cast_one] + apply (mul_inv_le_iff₀ (add_pos_of_nonneg_of_pos (Nat.cast_nonneg _) zero_lt_one)).mpr + rw [hT] + have he : ((P:ℝ)+1)⁻¹*(2*((K:ℝ)+1)*((P:ℝ)+1)+1) = + 2*((K:ℝ)+1)+((P:ℝ)+1)⁻¹ := by field_simp + rw [he] + linarith [inv_nonneg.mpr hP.le] + +/-- This is an error-composition lemma. Its numerical-flow premise is +supplied below by the proved actual manufactured Euler construction. -/ +theorem error_of_endpoint_error (rho U C K P : ℕ) {N : ℕ} (hN : 0 < N) + (scale S : ℚ) (sites : List (ℚ×ℚ)) (k : Registers) (b : Signs) + (G : Position → Position) {L : ℝ≥0} (hG : LipschitzWith L G) (hL : (L:ℝ) ≤ K) + (hendpoint : ∀ q : Triple, + ‖position (ManufacturedEuler.approximate rho U C (precision K P) scale S sites q)-G (position q)‖ ≤ + ((precision K P:ℝ)+1)⁻¹) : + ‖position (value rho U C K P N scale S sites k b)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index k b))‖ ≤ ((P:ℝ)+1)⁻¹ := by + have he := RationalGaussNodes.transported_error G hG (precision K P) hN k b + (ManufacturedEuler.approximate rho U C (precision K P) scale S sites + (RationalGaussNodes.value (precision K P) N k b)) + (hendpoint (RationalGaussNodes.value (precision K P) N k b)) + apply he.trans + have hm := mul_le_mul_of_nonneg_right hL + (inv_nonneg.mpr (add_nonneg (Nat.cast_nonneg (precision K P)) zero_le_one)) + calc + _ ≤ ((precision K P:ℝ)+1)⁻¹+(K:ℝ)*((precision K P:ℝ)+1)⁻¹ := add_le_add le_rfl hm + _ = (1+(K:ℝ))*((precision K P:ℝ)+1)⁻¹ := by ring + _ ≤ _ := error_budget K P + +/-- The transformed-node approximation is uniform over all manufactured +fields and all their actual time-one maps. U and C are fixed beforehand. -/ +theorem exists_uniform_constants (rho : ℕ) (hrho : 0 < rho) : + ∃ U C : ℕ, 0 < U ∧ 0 < C ∧ ∀ (K P N : ℕ), 0 < N → ∀ (scale S : ℚ), + (1:ℝ) ≤ scale → (1:ℝ) ≤ S → ∀ (m : ℕ) (u : Fin m → ℚ×ℚ), + Function.Injective u → + (∀ i j, i ≠ j → 3 ≤ ‖PlanarForcingProgram.position (u i)-PlanarForcingProgram.position (u j)‖) → + (∀ i, localizedCounterterm (GaussianFrequency.frequency rho) + (fun j => PlanarForcingProgram.position (u j)) i ≤ scale) → + (∀ x, |manufacturedCharge (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i))) x| ≤ (rho:ℝ)/2) → + ∀ G : Position → ℝ → Position, + IsUnitTimeFlow (moserVelocity (rho:ℝ) (manufacturedWellField (GaussianFrequency.frequency rho) + scale S (fun i => PlanarForcingProgram.position (u i)))) G → + ∀ L : ℝ≥0, LipschitzWith L (fun x => G x 1) → (L:ℝ) ≤ K → + ∀ (k : Registers) (b : Signs), + ‖position (value rho U C K P N scale S (List.ofFn u) k b)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index k b)) 1‖ ≤ ((P:ℝ)+1)⁻¹ := by + obtain ⟨U,C,hU,hC,herror⟩ := ManufacturedEuler.exists_uniform_constants rho hrho + refine ⟨U,C,hU,hC,?_⟩ + intro K P N hN scale S hs hS m u hu hsep hc hcharge G hG L hLip hL k b + exact error_of_endpoint_error rho U C K P hN scale S (List.ofFn u) k b + (fun x => G x 1) hLip hL + (herror (precision K P) scale S hs hS m u hu hsep hc hcharge G hG) + +end ContinuumCoulomb.TransformedGauss + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussList.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussList.lean new file mode 100644 index 0000000000000000000000000000000000000000..4504e44962aefb6e27a817cc5c5eda640ab95d89 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussList.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.TransformedGaussProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussSeparation + +namespace OAI + +/-! The same certified node program is applied to the whole finite list of +Gauss labels. It preserves the nucleus count and, at the proved precision, +pairwise distinctness. -/ + +open scoped NNReal +namespace ContinuumCoulomb.TransformedGauss +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode position) +open EulerRegisters (Registers registersCode) +open RationalGaussNodes (Signs signsCode) + +abbrev Environment := (ℕ×ℕ)×((ℚ×ℚ)×List (ℚ×ℚ)) +abbrev Label := Registers×Signs +def labelCode : Label → List Bool := prodCode registersCode signsCode +def environmentCode : Environment → List Bool := + prodCode (prodCode unaryCode Nat.bits) + (prodCode (prodCode ratCode ratCode) ManufacturedFieldEvaluation.sitesCode) +def listInputCode : (Environment×List Label) → List Bool := + prodCode environmentCode (listCode labelCode) + +noncomputable def nodes (rho U C K : ℕ) (x : Environment×List Label) : List Triple := + x.2.map (fun l => value rho U C K x.1.1.1 x.1.1.2 x.1.2.1.1 x.1.2.1.2 x.1.2.2 l.1 l.2) + +private noncomputable opaque nodeEnvironmentProgram : + Procedure (prodCode environmentCode labelCode) environmentCode Prod.fst := + Procedure.first _ _ +private noncomputable opaque nodeLabelProgram : + Procedure (prodCode environmentCode labelCode) labelCode Prod.snd := Procedure.second _ _ +private noncomputable opaque nodeParametersProgram : + Procedure (prodCode environmentCode labelCode) (prodCode unaryCode Nat.bits) + (fun x => x.1.1) := (Procedure.first _ _).comp nodeEnvironmentProgram +private noncomputable opaque nodeFieldProgram : + Procedure (prodCode environmentCode labelCode) + (prodCode (prodCode ratCode ratCode) ManufacturedFieldEvaluation.sitesCode) + (fun x => x.1.2) := (Procedure.second _ _).comp nodeEnvironmentProgram +private noncomputable opaque nodeArgumentProgram : + Procedure (prodCode environmentCode labelCode) inputCode + (fun x => (x.1.1,(x.1.2.1,(x.1.2.2,x.2)))) := + nodeParametersProgram.pair + (((Procedure.first _ _).comp nodeFieldProgram).pair + (((Procedure.second _ _).comp nodeFieldProgram).pair nodeLabelProgram)) + +noncomputable opaque listProgram (rho U C K : ℕ) : + Procedure listInputCode (listCode tripleCode) (nodes rho U C K) := by + let sample := (program rho U C K).comp nodeArgumentProgram + exact (Procedure.listMapWith (ea := environmentCode) (eb := labelCode) (ec := tripleCode) + (f := fun e l => value rho U C K e.1.1 e.1.2 e.2.1.1 e.2.1.2 e.2.2 l.1 l.2) + ((0,(0,0)),(false,(false,false))) (0,(0,0)) sample).congrFun (by intro x; rfl) + +noncomputable def listCertificate (rho U C K : ℕ) : + Turing.TM2ComputableInPolyTime listInputCode (listCode tripleCode) (nodes rho U C K) := + (listProgram rho U C K).toTM2 + +theorem nodes_length (rho U C K : ℕ) (x : Environment×List Label) : + (nodes rho U C K x).length = x.2.length := by simp only [nodes,List.length_map] + +theorem nodes_nodup (rho U C K : ℕ) (P : ℕ) {N : ℕ} (hN : 0 < N) + (scale S : ℚ) (sites : List (ℚ×ℚ)) (labels : List Label) (hnodup : labels.Nodup) + (G : Position → Position) {J : ℝ≥0} (hG : AntilipschitzWith J G) + (herror : ∀ l : Label, + ‖position (value rho U C K P N scale S sites l.1 l.2)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index l.1 l.2))‖ ≤ ((P:ℝ)+1)⁻¹) + (hprecision : 2*(J:ℝ)*((P:ℝ)+1)⁻¹ < (N:ℝ)⁻¹/3) : + (nodes rho U C K (((P,N),((scale,S),sites)),labels)).Nodup := by + exact hnodup.map (value_injective id Function.injective_id rho U C K P hN scale S sites G + hG herror hprecision) + +end ContinuumCoulomb.TransformedGauss + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..42b5874dd640ef1c32fd4d291fe2adc09238f586 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TransformedGaussSeparation.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGauss + +namespace OAI + +/-! Distinctness of the numerical transported nodes. The input labels use +the same integer cells and eight sign choices as the exact Gauss grid. -/ + +noncomputable section +open scoped NNReal +namespace ContinuumCoulomb.TransformedGauss +open CappedKernelProgram (Triple position) +open EulerRegisters (Registers) +open RationalGaussNodes (Signs) + +private theorem sign_injective {a b : Bool} + (h : (if a then (1:Fin 2) else 0) = (if b then (1:Fin 2) else 0)) : a = b := by + cases a <;> cases b <;> simp_all + +theorem index_injective : Function.Injective (fun x : Registers×Signs => + RationalGaussNodes.index x.1 x.2) := by + rintro ⟨k,b⟩ ⟨l,c⟩ h + have h0 : k.1 = l.1 := by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.1 0) h + have h1 : k.2.1 = l.2.1 := by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.1 1) h + have h2 : k.2.2 = l.2.2 := by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.1 2) h + have hb0 : b.1 = c.1 := sign_injective (by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.2 0) h) + have hb1 : b.2.1 = c.2.1 := sign_injective (by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.2 1) h) + have hb2 : b.2.2 = c.2.2 := sign_injective (by + simpa [RationalGaussNodes.index] using congrArg (fun x : GaussLatticeIndex => x.2 2) h) + exact Prod.ext (Prod.ext h0 (Prod.ext h1 h2)) (Prod.ext hb0 (Prod.ext hb1 hb2)) + +theorem value_injective {I : Type*} (labels : I → Registers×Signs) + (hlabels : Function.Injective labels) (rho U C K P : ℕ) {N : ℕ} (hN : 0 < N) + (scale S : ℚ) (sites : List (ℚ×ℚ)) (G : Position → Position) + {J : ℝ≥0} (hG : AntilipschitzWith J G) + (herror : ∀ i, + ‖position (value rho U C K P N scale S sites (labels i).1 (labels i).2)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels i).1 (labels i).2))‖ ≤ + ((P:ℝ)+1)⁻¹) + (hprecision : 2*(J:ℝ)*((P:ℝ)+1)⁻¹ < (N:ℝ)⁻¹/3) : + Function.Injective (fun i => value rho U C K P N scale S sites (labels i).1 (labels i).2) := by + intro i j hij + by_contra hne + have hindices : RationalGaussNodes.index (labels i).1 (labels i).2 ≠ + RationalGaussNodes.index (labels j).1 (labels j).2 := by + intro he + exact hne (hlabels (index_injective he)) + have hbase := gaussLatticePoint_separation + (show 0 < (N:ℝ)⁻¹ by positivity) _ _ hindices + have htrans := hG.le_mul_dist + (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels i).1 (labels i).2)) + (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels j).1 (labels j).2)) + simp only [dist_eq_norm] at htrans + have hi := herror i + have hj := herror j + have he := congrArg position hij + rw [he] at hi + have ht : ‖G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels i).1 (labels i).2))- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels j).1 (labels j).2))‖ ≤ + 2*((P:ℝ)+1)⁻¹ := by + calc + _ ≤ ‖G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels i).1 (labels i).2))- + position (value rho U C K P N scale S sites (labels i).1 (labels i).2)‖+ + ‖position (value rho U C K P N scale S sites (labels i).1 (labels i).2)- + G (gaussLatticePoint (N:ℝ)⁻¹ (RationalGaussNodes.index (labels j).1 (labels j).2))‖ := + norm_sub_le_norm_sub_add_norm_sub _ _ _ + _ ≤ _ := by rw [norm_sub_rev _ (position _),he]; linarith + have hmul := mul_le_mul_of_nonneg_left ht J.coe_nonneg + nlinarith + +end ContinuumCoulomb.TransformedGauss + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TruncatedNuclearForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TruncatedNuclearForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..941e6f9b0ecc6dceb594769bd87d3310bf9f3260 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/TruncatedNuclearForm.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.TransportedNearForm + +namespace OAI + +/-! The truncated point kernels in the mesh error are controlled on the +entire weak-H1 domain by the separated-nucleus near-field estimate. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators NNReal +namespace ContinuumCoulomb + +theorem truncated_nuclear_integrable_bound {n : ℕ} (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (a : Position) (r : ℝ) : + Integrable (fun x => Coulomb.truncatedCoulomb r (Coulomb.position x i-a)*‖u.value s x‖^2) ∧ + (∫ x, Coulomb.truncatedCoulomb r (Coulomb.position x i-a)*‖u.value s x‖^2) ≤ + ∫ x in electronBall i a r, Coulomb.coulombKernel (Coulomb.position x i-a)*‖u.value s x‖^2 := by + have hi := (u.nuclear_coulomb_integrable_bound s i a (by norm_num : (0:ℝ) < 1)).1 + have hk (z : Position) : Coulomb.truncatedCoulomb r z ≤ Coulomb.coulombKernel z := by + by_cases hz : z ∈ Metric.ball (0:Position) r + · simp only [Coulomb.truncatedCoulomb,Set.indicator_of_mem hz,le_refl] + · simpa only [Coulomb.truncatedCoulomb,Set.indicator_of_notMem hz] using + Coulomb.coulombKernel_nonneg z + have hm : AEStronglyMeasurable + (fun x : Configuration n => Coulomb.truncatedCoulomb r (Coulomb.position x i-a)) volume := + ((Coulomb.coulombKernel_measurable.indicator measurableSet_ball).comp + ((Coulomb.positionCLM i).continuous.sub continuous_const).measurable).aestronglyMeasurable + have ht : Integrable (fun x => + Coulomb.truncatedCoulomb r (Coulomb.position x i-a)*‖u.value s x‖^2) := by + apply hi.mono' (hm.mul ((u.value_L2 s).aestronglyMeasurable.norm.pow 2)) + exact Filter.Eventually.of_forall (fun x => by + change ‖Coulomb.truncatedCoulomb r (Coulomb.position x i-a)*‖u.value s x‖^2‖ ≤ _ + rw [Real.norm_of_nonneg (mul_nonneg (Coulomb.truncatedCoulomb_nonneg _ _) (sq_nonneg _))] + exact mul_le_mul_of_nonneg_right (hk _) (sq_nonneg _)) + refine ⟨ht,?_⟩ + rw [← integral_indicator (electronBall_measurable i a r)] + apply integral_mono ht (hi.indicator (electronBall_measurable i a r)) + intro x + by_cases hx : x ∈ electronBall i a r + · rw [Set.indicator_of_mem hx] + exact mul_le_mul_of_nonneg_right (hk _) (sq_nonneg _) + · rw [Set.indicator_of_notMem hx] + have hn : Coulomb.position x i-a ∉ Metric.ball (0:Position) r := by + simp only [Metric.mem_ball,dist_zero_right] + exact not_lt.mpr (le_of_lt (lt_of_not_ge hx)) + simp only [Coulomb.truncatedCoulomb,Set.indicator_of_notMem hn,zero_mul,le_refl] + +theorem transportedGauss_truncated_form {κ : ℝ} (hκ : 0 < κ) + (K : ℝ≥0) (hK : 0 < K) : + ∃ A : ℝ, 1 ≤ A ∧ ∀ {ι : Type} [Fintype ι] (n : ℕ) (u : Coulomb.H1Vector n) + (s : SpinConfiguration n) (i : Fin n) (h ρ : ℝ), + 0 < h → h ≤ 1 → 0 ≤ ρ → + ∀ (index : ι → GaussLatticeIndex), Function.Injective index → + ∀ (G : Position → Position), AntilipschitzWith K G → + (ρ*h^3/8)*(∑ a, ∫ x, + Coulomb.truncatedCoulomb (κ*h) (Coulomb.position x i-G (gaussLatticePoint h (index a)))* + ‖u.value s x‖^2) ≤ + ρ*A*h^2*((∫ x, ‖u.value s x‖^2)+ + ∑ k : Fin 3, ∫ x, ‖u.gradient s (i,k) x‖^2) := by + obtain ⟨A,hA,hbound⟩ := transportedGauss_near_form hκ K hK + refine ⟨A,hA,?_⟩ + intro ι _ n u s i h ρ hh hh1 hρ index hindex G hG + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + have he := hbound (Fintype.card ι) n u s i h ρ hh hh1 hρ (index ∘ e) + (hindex.comp e.injective) G hG + have hs : (∑ a : ι, ∫ x in electronBall i (G (gaussLatticePoint h (index a))) (κ*h), + Coulomb.coulombKernel (Coulomb.position x i-G (gaussLatticePoint h (index a)))*‖u.value s x‖^2) = + ∑ a : Fin (Fintype.card ι), ∫ x in electronBall i (G (gaussLatticePoint h (index (e a)))) (κ*h), + Coulomb.coulombKernel (Coulomb.position x i-G (gaussLatticePoint h (index (e a))))*‖u.value s x‖^2 := + (Fintype.sum_equiv e _ _ (fun _ => rfl)).symm + apply le_trans _ (by simpa only [Function.comp_apply,← hs] using he) + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Finset.sum_le_sum (fun a _ => + (truncated_nuclear_integrable_bound u s i (G (gaussLatticePoint h (index a))) (κ*h)).2) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitBinaryInclusion.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitBinaryInclusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd66d91cd9e0f78f131d4c50f5ea603de54511ba --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitBinaryInclusion.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearPromise + +namespace OAI + +/-! The unit-charge target is a special case of the binary-charge target. +The inclusion preserves the actual full fermionic continuum energy and +both promise thresholds. -/ + +namespace ContinuumCoulomb + +def UnitCoulomb.toBinary (d : UnitCoulomb) : BinaryCoulomb where + nuclei := d.nuclei.map (fun r => (r, 1)) + electrons := d.electrons + lower := d.lower + upper := d.upper + +theorem UnitCoulomb.toBinary_valid (d : UnitCoulomb) (h : d.Valid) : d.toBinary.Valid := by + dsimp only [UnitCoulomb.toBinary] + refine { + nuclei_pos := by simpa only [UnitCoulomb.toBinary, List.length_map] using h.nuclei_pos + electrons_pos := h.electrons_pos + positions := ?_ + distinct := ?_ + charge_pos := ?_ + lower_denominator := h.lower_denominator + upper_denominator := h.upper_denominator + gap := h.gap } + · intro a + change ((d.nuclei.map (fun r => (r, (1 : ℕ)))).get a).1.Valid + simp only [List.get_eq_getElem, List.getElem_map] + exact h.positions ⟨a.val, by simpa only [List.length_map] using a.isLt⟩ + · intro a b hab + change ((d.nuclei.map (fun r => (r, (1 : ℕ)))).get a).1.value = + ((d.nuclei.map (fun r => (r, (1 : ℕ)))).get b).1.value at hab + simp only [List.get_eq_getElem, List.getElem_map] at hab + have h' := h.distinct (a₁ := ⟨a.val, by simpa only [List.length_map] using a.isLt⟩) + (a₂ := ⟨b.val, by simpa only [List.length_map] using b.isLt⟩) hab + exact Fin.ext (congrArg (fun x : Fin d.nuclei.length => x.val) h') + · intro a + change 0 < ((d.nuclei.map (fun r => (r, (1 : ℕ)))).get a).2 + simp only [List.get_eq_getElem, List.getElem_map] + exact Nat.zero_lt_one + +private theorem nuclearData_ext (d e : NuclearData) (hn : d.nuclei=e.nuclei) + (hp : ∀ i, d.position i=e.position (Fin.cast hn i)) + (hz : ∀ i, d.charge i=e.charge (Fin.cast hn i)) (he : d.electrons=e.electrons) : d=e := by + rcases d with ⟨nd,hnd,pd,hd,zd,hzd,ed,hed⟩ + rcases e with ⟨ne,hne,pe,he',ze,hze,ee,hee⟩ + dsimp only at hn hp hz he + subst ne + simp only [Fin.cast_refl, id_eq] at hp hz + have hp' := funext hp + have hz' := funext hz + subst pe + subst ze + subst ee + rfl + +theorem UnitCoulomb.toBinary_toData (d : UnitCoulomb) (h : d.Valid) : + d.toBinary.toData (d.toBinary_valid h) = (d.toData h).toNuclearData := by + apply nuclearData_ext _ _ (by exact List.length_map (fun r => (r, (1 : ℕ)))) + · intro i + dsimp only [UnitCoulomb.toBinary, BinaryCoulomb.toData, UnitCoulomb.toData, + UnitNuclearData.toNuclearData] at i ⊢ + simp only [List.get_eq_getElem, List.getElem_map, Fin.val_cast] + · intro i + dsimp only [UnitCoulomb.toBinary, BinaryCoulomb.toData, UnitCoulomb.toData, + UnitNuclearData.toNuclearData] at i ⊢ + simp only [List.get_eq_getElem, List.getElem_map] + · rfl + +noncomputable section + +theorem UnitCoulomb.toBinary_energy (d : UnitCoulomb) (h : d.Valid) : + groundEnergy (d.toBinary.toData (d.toBinary_valid h)) = unitGroundEnergy (d.toData h) := by + rw [d.toBinary_toData h, unit_groundEnergy_eq] + +theorem unitBinary_yes {d : UnitCoulomb} (h : d ∈ unitCoulombPromise.yes) : + d.toBinary ∈ binaryCoulombPromise.yes := by + obtain ⟨hv, he⟩ := h + refine ⟨d.toBinary_valid hv, ?_⟩ + rw [d.toBinary_energy hv] + exact he + +theorem unitBinary_no {d : UnitCoulomb} (h : d ∈ unitCoulombPromise.no) : + d.toBinary ∈ binaryCoulombPromise.no := by + obtain ⟨hv, he⟩ := h + refine ⟨d.toBinary_valid hv, ?_⟩ + rw [d.toBinary_energy hv] + exact he + +end +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitProgramGroundInterval.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitProgramGroundInterval.lean new file mode 100644 index 0000000000000000000000000000000000000000..f295c1fb7edcd417653e5ee7bad95e7e2c749efc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/UnitProgramGroundInterval.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ProgramGroundIdentity + +namespace OAI + +/-! The literal binary-encoded unit-charge output inherits the full +ground-energy interval and validity from the computed node estimates. -/ + +noncomputable section +open scoped BigOperators Classical NNReal +namespace ContinuumCoulomb.UnitCoulombProgram +open CappedKernelProgram (position) + +theorem ground_interval (rho U C K : ℕ) (hrho : 0 < rho) (x : Input) + (hN : 0 < x.1.1.1.2) (hn : 0 < x.2.1) (hgap : (1:ℚ) ≤ x.2.2.2-x.2.2.1) + (G : Position → Position) (hG : Function.Injective G) {J : ℝ≥0} + (hAnti : AntilipschitzWith J G) + (herror : ∀ l : TransformedGauss.Label, + ‖position (TransformedGauss.value rho U C K x.1.1.1.1 x.1.1.1.2 + x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 l.1 l.2)- + G (gaussLatticePoint (x.1.1.1.2:ℝ)⁻¹ (RationalGaussNodes.index l.1 l.2))‖ ≤ + ((x.1.1.1.1:ℝ)+1)⁻¹) + (hprecision : 2*(J:ℝ)*((x.1.1.1.1:ℝ)+1)⁻¹ < (x.1.1.1.2:ℝ)⁻¹/3) + {scale center error roundError : ℝ} (hs : 0 < scale) + (hfactor : (PhysicalNuclearProgram.factor rho x.1.1.1.2:ℝ)=scale⁻¹) + (hlo : ((center-error:ℝ):EReal) ≤ formGroundEnergy + (dilatedNuclei (CenteredGaussLabels.nuclei x.1.2 G hG (by positivity : 0 < (x.1.1.1.2:ℝ)⁻¹)) + scale hs.ne') x.2.1) + (hhi : formGroundEnergy + (dilatedNuclei (CenteredGaussLabels.nuclei x.1.2 G hG (by positivity : 0 < (x.1.1.1.2:ℝ)⁻¹)) + scale hs.ne') x.2.1 ≤ ((center+error:ℝ):EReal)) + (hsmall : 32*(scale⁻¹*((x.1.1.1.1:ℝ)+1)⁻¹)*(CenteredGaussLabels.labels x.1.2).length ≤ 1) + (hbudget : 32*(scale⁻¹*((x.1.1.1.1:ℝ)+1)⁻¹)*(CenteredGaussLabels.labels x.1.2).length* + (center+error+4*(x.2.1:ℝ)*((CenteredGaussLabels.labels x.1.2).length:ℝ)^2) ≤ roundError) : + ∃ hx : (value rho U C K x).Valid, + ((center-error-roundError:ℝ):EReal) ≤ unitGroundEnergy ((value rho U C K x).toData hx) ∧ + unitGroundEnergy ((value rho U C K x).toData hx) ≤ ((center+error+roundError:ℝ):EReal) := by + have hnodes := TransformedGauss.nodes_nodup rho U C K x.1.1.1.1 hN + x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 (CenteredGaussLabels.labels x.1.2) + (CenteredGaussLabels.labels_nodup x.1.2) G hAnti herror hprecision + let hx := valid_of_nodes rho U C K x hrho hN hn hnodes hgap + obtain ⟨hq,hl,hu⟩ := CenteredGaussLabels.numerical_ground_interval x.1.2 rho U C K x.1.1.1.1 hN + x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 G hG hAnti herror hprecision hs x.2.1 hlo hhi hsmall hbudget + refine ⟨hx,?_,?_⟩ + · rw [program_ground_identity rho U C K x hx hs hfactor hq] + exact hl + · rw [program_ground_identity rho U C K x hx hs hfactor hq] + exact hu + +end ContinuumCoulomb.UnitCoulombProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..0031e49b98675f2fa6150fe76e10f68281e04e88 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedForm.lean @@ -0,0 +1,180 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalSpectralInput +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ExplicitVerticalCutoff +import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension +import Mathlib.Analysis.Calculus.Deriv.Support + +namespace OAI + +/-! The actual capped transverse oscillator and its two-part IMS formula. +The cutoff is one on the inner half-slab and zero beyond the slab. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +def verticalCapPotential (freq S z : ℝ) : ℝ := + (freq^2/2) * min (z^2) (S^2) + +def verticalCappedForm (freq S : ℝ) (u : ℝ → ℝ) : ℝ := + (1/2 : ℝ) * (∫ z, deriv u z^2) + ∫ z, verticalCapPotential freq S z * u z^2 + +def verticalCutoffAngle (S z : ℝ) : ℝ := + (Real.pi/2) * verticalCutoffBump ((2/S)*z) + +def verticalInnerCutoff (S z : ℝ) : ℝ := Real.sin (verticalCutoffAngle S z) +def verticalOuterCutoff (S z : ℝ) : ℝ := Real.cos (verticalCutoffAngle S z) + +theorem verticalCutoffAngle_smooth (S : ℝ) : ContDiff ℝ ∞ (verticalCutoffAngle S) := + contDiff_const.mul (verticalCutoffBump.contDiff.comp (contDiff_const.mul contDiff_id)) + +theorem verticalInnerCutoff_smooth (S : ℝ) : ContDiff ℝ ∞ (verticalInnerCutoff S) := + (verticalCutoffAngle_smooth S).sin + +theorem verticalOuterCutoff_smooth (S : ℝ) : ContDiff ℝ ∞ (verticalOuterCutoff S) := + (verticalCutoffAngle_smooth S).cos + +theorem verticalCutoff_partition (S z : ℝ) : + verticalInnerCutoff S z^2 + verticalOuterCutoff S z^2 = 1 := Real.sin_sq_add_cos_sq _ + +theorem verticalCutoff_inner {S : ℝ} (hS : 0 < S) {z : ℝ} (hz : |z| ≤ S/2) : + verticalInnerCutoff S z = 1 ∧ verticalOuterCutoff S z = 0 := by + have hb : verticalCutoffBump ((2/S)*z) = 1 := by + apply verticalCutoffBump.one_of_mem_closedBall + change dist ((2/S)*z) 0 ≤ 1 + rw [dist_zero_right, Real.norm_eq_abs, abs_mul, abs_of_pos (div_pos (by norm_num) hS)] + have hm := mul_le_mul_of_nonneg_left hz (div_pos (by norm_num : (0:ℝ)<2) hS).le + have he : (2/S)*(S/2) = (1:ℝ) := by field_simp + exact hm.trans_eq he + simp [verticalInnerCutoff, verticalOuterCutoff, verticalCutoffAngle, hb] + +theorem verticalCutoff_outer {S : ℝ} (hS : 0 < S) {z : ℝ} (hz : S ≤ |z|) : + verticalInnerCutoff S z = 0 ∧ verticalOuterCutoff S z = 1 := by + have hb : verticalCutoffBump ((2/S)*z) = 0 := by + apply verticalCutoffBump.zero_of_le_dist + rw [dist_zero_right, Real.norm_eq_abs, abs_mul, abs_of_pos (div_pos (by norm_num) hS)] + have hm := mul_le_mul_of_nonneg_left hz (div_pos (by norm_num : (0:ℝ)<2) hS).le + have he : (2/S)*S = (2:ℝ) := by field_simp + exact he.symm.le.trans hm + simp [verticalInnerCutoff, verticalOuterCutoff, verticalCutoffAngle, hb] + +theorem vertical_deriv_square_integrable (u : ℝ → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : Integrable (fun z => deriv u z^2) := by + have hd : Continuous (deriv u) := hu.continuous_deriv (by norm_num) + have hdc : HasCompactSupport (deriv u) := hc.deriv + have hsq : HasCompactSupport (fun z => deriv u z^2) := + hdc.comp_left (g := fun t : ℝ => t^2) (by norm_num) + exact (hd.pow 2).integrable_of_hasCompactSupport hsq + +theorem vertical_product_integrable (V u : ℝ → ℝ) (hV : Continuous V) + (hu : Continuous u) (hc : HasCompactSupport u) : Integrable (fun z => V z*u z^2) := by + have huc : HasCompactSupport (fun z => u z^2) := + hc.comp_left (g := fun t : ℝ => t^2) (by norm_num) + have hprod : HasCompactSupport (fun z => V z * u z^2) := huc.mul_left + exact (hV.mul (hu.pow 2)).integrable_of_hasCompactSupport hprod + +private theorem verticalCutoffBump_deriv_bounded : + ∃ C : ℝ, ∀ z, ‖deriv (verticalCutoffBump : ℝ → ℝ) z‖ ≤ C := by + have hs : ContDiff ℝ 2 (verticalCutoffBump : ℝ → ℝ) := verticalCutoffBump.contDiff + exact (hs.continuous_deriv (by norm_num)).bounded_above_of_compact_support + verticalCutoffBump.hasCompactSupport.deriv + +def verticalCutoffDerivativeConstant : ℝ := Classical.choose verticalCutoffBump_deriv_bounded + +theorem verticalCutoffDerivativeConstant_nonnegative : 0 ≤ verticalCutoffDerivativeConstant := + (norm_nonneg _).trans (Classical.choose_spec verticalCutoffBump_deriv_bounded 0) + +def verticalCutoffDerivativeBound (S : ℝ) : ℝ := + (Real.pi/2 * (2/S)) * verticalCutoffDerivativeConstant + +theorem verticalCutoffAngle_deriv (S z : ℝ) : + deriv (verticalCutoffAngle S) z = + (Real.pi/2 * (2/S)) * deriv (verticalCutoffBump : ℝ → ℝ) ((2/S)*z) := by + have hs : ContDiff ℝ 1 (verticalCutoffBump : ℝ → ℝ) := verticalCutoffBump.contDiff + have hb := (hs.differentiable (by norm_num) ((2/S)*z)).hasDerivAt + have h := (hb.comp z ((hasDerivAt_id z).const_mul (2/S))).const_mul (Real.pi/2) + change HasDerivAt (verticalCutoffAngle S) _ z at h + rw [h.deriv] + ring + +theorem verticalCutoffAngle_deriv_bound {S : ℝ} (hS : 0 < S) (z : ℝ) : + |deriv (verticalCutoffAngle S) z| ≤ verticalCutoffDerivativeBound S := by + have hc : 0 ≤ Real.pi/2 * (2/S) := by positivity + rw [verticalCutoffAngle_deriv, abs_mul, abs_of_nonneg hc] + exact mul_le_mul_of_nonneg_left + (Classical.choose_spec verticalCutoffBump_deriv_bounded ((2/S)*z)) hc + +theorem verticalCutoff_deriv_identity (S : ℝ) (u : ℝ → ℝ) + (hu : ContDiff ℝ 1 u) (z : ℝ) : + deriv (fun x => verticalInnerCutoff S x*u x) z^2 + + deriv (fun x => verticalOuterCutoff S x*u x) z^2 = + deriv u z^2 + deriv (verticalCutoffAngle S) z^2*u z^2 := by + have ha := (verticalCutoffAngle_smooth S).differentiable (by simp) z + have hi := ha.hasDerivAt.sin + have ho := ha.hasDerivAt.cos + have hu' := (hu.differentiable (by norm_num) z).hasDerivAt + have hdi : deriv (fun x => verticalInnerCutoff S x*u x) z = + Real.cos (verticalCutoffAngle S z) * deriv (verticalCutoffAngle S) z * u z + + Real.sin (verticalCutoffAngle S z) * deriv u z := by + simpa only [verticalInnerCutoff] using (hi.fun_mul hu').deriv + have hdo : deriv (fun x => verticalOuterCutoff S x*u x) z = + -(Real.sin (verticalCutoffAngle S z) * deriv (verticalCutoffAngle S) z) * u z + + Real.cos (verticalCutoffAngle S z) * deriv u z := by + simpa only [verticalOuterCutoff, neg_mul] using (ho.fun_mul hu').deriv + rw [hdi, hdo] + linear_combination (deriv u z^2 + deriv (verticalCutoffAngle S) z^2*u z^2) * + Real.sin_sq_add_cos_sq (verticalCutoffAngle S z) + +/-- Exact IMS identity on the actual one-dimensional capped form. -/ +theorem verticalCappedForm_IMS (freq S : ℝ) (u : ℝ → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + verticalCappedForm freq S (fun z => verticalInnerCutoff S z*u z) + + verticalCappedForm freq S (fun z => verticalOuterCutoff S z*u z) = + verticalCappedForm freq S u + (1/2:ℝ)*∫ z, deriv (verticalCutoffAngle S) z^2*u z^2 := by + have hi : ContDiff ℝ 1 (verticalInnerCutoff S) := (verticalInnerCutoff_smooth S).of_le (by simp) + have ho : ContDiff ℝ 1 (verticalOuterCutoff S) := (verticalOuterCutoff_smooth S).of_le (by simp) + have ha : Continuous (fun z => deriv (verticalCutoffAngle S) z^2) := + ((verticalCutoffAngle_smooth S).continuous_deriv (by simp)).pow 2 + have hV : Continuous (verticalCapPotential freq S) := by unfold verticalCapPotential; fun_prop + have hd : (∫ z, deriv (fun x => verticalInnerCutoff S x*u x) z^2) + + (∫ z, deriv (fun x => verticalOuterCutoff S x*u x) z^2) = + (∫ z, deriv u z^2) + ∫ z, deriv (verticalCutoffAngle S) z^2*u z^2 := by + rw [← integral_add (vertical_deriv_square_integrable _ (hi.mul hu) hc.mul_left) + (vertical_deriv_square_integrable _ (ho.mul hu) hc.mul_left), + ← integral_add (vertical_deriv_square_integrable u hu hc) + (vertical_product_integrable _ u ha hu.continuous hc)] + exact integral_congr_ae (Filter.Eventually.of_forall (verticalCutoff_deriv_identity S u hu)) + have hp : (∫ z, verticalCapPotential freq S z*(verticalInnerCutoff S z*u z)^2) + + (∫ z, verticalCapPotential freq S z*(verticalOuterCutoff S z*u z)^2) = + ∫ z, verticalCapPotential freq S z*u z^2 := by + rw [← integral_add + (vertical_product_integrable _ _ hV (hi.mul hu).continuous hc.mul_left) + (vertical_product_integrable _ _ hV (ho.mul hu).continuous hc.mul_left)] + apply integral_congr_ae + filter_upwards [] with z + linear_combination (verticalCapPotential freq S z*u z^2) * verticalCutoff_partition S z + unfold verticalCappedForm + linarith + +/-- On the supported inner piece the capped potential is exactly harmonic. -/ +theorem verticalCappedForm_inner {S : ℝ} (hS : 0 < S) (freq : ℝ) (u : ℝ → ℝ) : + verticalCappedForm freq S (fun z => verticalInnerCutoff S z*u z) = + verticalForm freq (fun z => verticalInnerCutoff S z*u z) := by + unfold verticalCappedForm verticalForm + congr 1 + rw [← integral_const_mul] + apply integral_congr_ae + filter_upwards [] with z + by_cases hz : |z| ≤ S + · have hs : z^2 ≤ S^2 := by + nlinarith [sq_abs z, (sq_le_sq₀ (abs_nonneg z) hS.le).mpr hz] + simp only [verticalCapPotential, min_eq_left hs] + ring + · rw [(verticalCutoff_outer hS (le_of_not_ge hz)).1] + simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..4178c86203d6a60e73312d6d4805e65ce62e1e63 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedGap.lean @@ -0,0 +1,161 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCutoffTail + +namespace OAI + +/-! The capped transverse oscillator inherits the published oscillator +projection bound, with a proved IMS cost and a proved Gaussian cutoff error. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem verticalCutoff_mass (S : ℝ) (u : ℝ → ℝ) + (hu : Continuous u) (hc : HasCompactSupport u) : + (∫ z, (verticalInnerCutoff S z*u z)^2) + + (∫ z, (verticalOuterCutoff S z*u z)^2) = ∫ z, u z^2 := by + have hci : HasCompactSupport (fun z => verticalInnerCutoff S z*u z) := hc.mul_left + have hco : HasCompactSupport (fun z => verticalOuterCutoff S z*u z) := hc.mul_left + have hsi : HasCompactSupport (fun z => (verticalInnerCutoff S z*u z)^2) := + hci.comp_left (g := fun t : ℝ => t^2) (by norm_num) + have hso : HasCompactSupport (fun z => (verticalOuterCutoff S z*u z)^2) := + hco.comp_left (g := fun t : ℝ => t^2) (by norm_num) + have hi : Integrable (fun z => (verticalInnerCutoff S z*u z)^2) := + (((verticalInnerCutoff_smooth S).continuous.mul hu).pow 2).integrable_of_hasCompactSupport hsi + have ho : Integrable (fun z => (verticalOuterCutoff S z*u z)^2) := + (((verticalOuterCutoff_smooth S).continuous.mul hu).pow 2).integrable_of_hasCompactSupport hso + rw [← integral_add hi ho] + apply integral_congr_ae + filter_upwards [] with z + linear_combination u z^2 * verticalCutoff_partition S z + +theorem verticalCappedForm_outer_lower {S : ℝ} (hS : 0 < S) + (freq : ℝ) (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (freq^2*S^2/8) * (∫ z, (verticalOuterCutoff S z*u z)^2) ≤ + verticalCappedForm freq S (fun z => verticalOuterCutoff S z*u z) := by + have ho : ContDiff ℝ 1 (fun z => verticalOuterCutoff S z*u z) := + ((verticalOuterCutoff_smooth S).of_le (by simp)).mul hu + have hi := vertical_product_integrable (verticalCapPotential freq S) _ + (by unfold verticalCapPotential; fun_prop) ho.continuous hc.mul_left + have hlo := vertical_product_integrable (fun _ => freq^2*S^2/8) _ + continuous_const ho.continuous hc.mul_left + have hp : (∫ z, (freq^2*S^2/8)*(verticalOuterCutoff S z*u z)^2) ≤ + ∫ z, verticalCapPotential freq S z*(verticalOuterCutoff S z*u z)^2 := by + apply integral_mono hlo hi + intro z + change (freq^2*S^2/8)*(verticalOuterCutoff S z*u z)^2 ≤ + verticalCapPotential freq S z*(verticalOuterCutoff S z*u z)^2 + by_cases hz : |z| ≤ S/2 + · rw [(verticalCutoff_inner hS hz).2] + simp + · have hs : S^2/4 ≤ z^2 := by + have h := (sq_le_sq₀ (by positivity : 0 ≤ S/2) (abs_nonneg z)).mpr + (le_of_not_ge hz) + nlinarith [sq_abs z] + have hm : S^2/4 ≤ min (z^2) (S^2) := le_min hs (by nlinarith [sq_nonneg S]) + have hv : freq^2*S^2/8 ≤ verticalCapPotential freq S z := by + unfold verticalCapPotential + nlinarith [mul_le_mul_of_nonneg_left hm (sq_nonneg freq)] + exact mul_le_mul_of_nonneg_right hv (sq_nonneg _) + rw [integral_const_mul] at hp + unfold verticalCappedForm + exact hp.trans (le_add_of_nonneg_left + (mul_nonneg (by norm_num) (integral_nonneg (fun z => sq_nonneg _)))) + +/-- The only input is the published harmonic-oscillator gap. The slab +cutoff, exterior barrier and localization cost are explicit actual functions. -/ +theorem verticalCappedForm_projection_lower (hpublished : PublishedVerticalOscillatorGap) + {freq S : ℝ} (hfreq : 0 < freq) (hS : 0 < S) + (hbarrier : 3*freq/2 ≤ freq^2*S^2/8) + (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (3*freq/2) * (∫ z, u z^2) - + freq * (∫ z, (verticalInnerCutoff S z*u z)*verticalMode freq z)^2 - + (verticalCutoffDerivativeBound S^2/2) * (∫ z, u z^2) ≤ + verticalCappedForm freq S u := by + have hi : ContDiff ℝ 1 (fun z => verticalInnerCutoff S z*u z) := + ((verticalInnerCutoff_smooth S).of_le (by simp)).mul hu + have hin := hpublished freq hfreq _ hi hc.mul_left + rw [← verticalCappedForm_inner hS freq u] at hin + have hout := (mul_le_mul_of_nonneg_right hbarrier + (integral_nonneg (fun z => sq_nonneg (verticalOuterCutoff S z*u z)))).trans + (verticalCappedForm_outer_lower hS freq u hu hc) + have hm := verticalCutoff_mass S u hu.continuous hc + have hims := verticalCappedForm_IMS freq S u hu hc + have hcost : (∫ z, deriv (verticalCutoffAngle S) z^2*u z^2) ≤ + verticalCutoffDerivativeBound S^2 * (∫ z, u z^2) := by + rw [← integral_const_mul] + apply integral_mono + (vertical_product_integrable _ u + (((verticalCutoffAngle_smooth S).continuous_deriv (by simp)).pow 2) hu.continuous hc) + (vertical_product_integrable _ u continuous_const hu.continuous hc) + intro z + change deriv (verticalCutoffAngle S) z^2*u z^2 ≤ verticalCutoffDerivativeBound S^2*u z^2 + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + have hb := verticalCutoffAngle_deriv_bound hS z + have hB : 0 ≤ verticalCutoffDerivativeBound S := by + exact (abs_nonneg _).trans hb + simpa only [sq_abs] using (sq_le_sq₀ (abs_nonneg _) hB).mpr hb + nlinarith + +private theorem vertical_add_sq_le {η : ℝ} (hη : 0 < η) (a b : ℝ) : + (a+b)^2 ≤ (1+η)*a^2 + (1+η⁻¹)*b^2 := by + have he : (((1+η)*a^2 + (1+η⁻¹)*b^2) - (a+b)^2)*η = (η*a-b)^2 := by + field_simp [hη.ne'] + ring + have hn : 0 ≤ (((1+η)*a^2 + (1+η⁻¹)*b^2) - (a+b)^2)*η := by + rw [he] + exact sq_nonneg _ + exact sub_nonneg.mp (nonneg_of_mul_nonneg_left hn hη) + +theorem verticalCutoff_pair_bound {freq S η : ℝ} + (hfreq : 0 < freq) (hS : 0 < S) (hη : 0 < η) + (u : ℝ → ℝ) (hu : MemLp u 2) : + (∫ z, (verticalInnerCutoff S z*u z)*verticalMode freq z)^2 ≤ + (1+η)*(∫ z, u z*verticalMode freq z)^2 + + (1+η⁻¹)*(∫ z, u z^2)* + (verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) := by + have hy := vertical_add_sq_le hη (∫ z, u z*verticalMode freq z) + ((∫ z, (verticalInnerCutoff S z*u z)*verticalMode freq z) - + (∫ z, u z*verticalMode freq z)) + have he := mul_le_mul_of_nonneg_left (verticalCutoff_pair_error hfreq hS u hu) + (show 0 ≤ 1+η⁻¹ by positivity) + nlinarith + +/-- The capped form has a global finite-rank lower bound. Unlike the +orthogonality corollary, this bound passes directly through approximation. -/ +theorem verticalCappedForm_global_projection_lower + (hpublished : PublishedVerticalOscillatorGap) + {freq S η : ℝ} (hfreq : 0 < freq) (hS : 0 < S) (hη : 0 < η) + (hbarrier : 3*freq/2 ≤ freq^2*S^2/8) + (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (3*freq/2 - verticalCutoffDerivativeBound S^2/2 - + freq*(1+η⁻¹)*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) * + (∫ z, u z^2) - freq*(1+η)*(∫ z, u z*verticalMode freq z)^2 ≤ + verticalCappedForm freq S u := by + have h := verticalCappedForm_projection_lower hpublished hfreq hS hbarrier u hu hc + have hp := verticalCutoff_pair_bound hfreq hS hη u + (hu.continuous.memLp_of_hasCompactSupport hc) + have hm := mul_le_mul_of_nonneg_left hp hfreq.le + nlinarith + +/-- Orthogonality is to the actual uncut Gaussian; its cutoff error is +accounted for quantitatively rather than inserted as a spectral premise. -/ +theorem verticalCappedForm_complement_lower (hpublished : PublishedVerticalOscillatorGap) + {freq S : ℝ} (hfreq : 0 < freq) (hS : 0 < S) + (hbarrier : 3*freq/2 ≤ freq^2*S^2/8) + (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) + (ho : (∫ z, u z*verticalMode freq z) = 0) : + (3*freq/2 - verticalCutoffDerivativeBound S^2/2 - + freq*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) * (∫ z, u z^2) ≤ + verticalCappedForm freq S u := by + have h := verticalCappedForm_projection_lower hpublished hfreq hS hbarrier u hu hc + have hp := verticalCutoff_pair_error hfreq hS u + (hu.continuous.memLp_of_hasCompactSupport hc) + rw [ho, sub_zero] at hp + have hm := mul_le_mul_of_nonneg_left hp hfreq.le + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..60686eede12460a905e7bf60e22be5120df34e3a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCappedScale.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedGap + +namespace OAI + +/-! A fixed slab width threshold makes both actual transverse cutoff +losses smaller than half the oscillator gap. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem verticalCutoffDerivativeBound_tendsto : + Tendsto verticalCutoffDerivativeBound atTop (𝓝 0) := by + have h := (tendsto_inv_atTop_zero.const_mul (2:ℝ)).const_mul (Real.pi/2) + have h' := h.mul_const verticalCutoffDerivativeConstant + change Tendsto (fun S : ℝ => (Real.pi/2*(2/S))*verticalCutoffDerivativeConstant) atTop (𝓝 0) + simpa only [div_eq_mul_inv, zero_mul, mul_zero] using h' + +theorem verticalCutoffLoss_tendsto {freq : ℝ} (hfreq : 0 < freq) : + Tendsto (fun S : ℝ => verticalCutoffDerivativeBound S^2/2 + + freq*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8)) atTop (𝓝 0) := by + have harg : Tendsto (fun S : ℝ => (freq/8)*S^2) atTop atTop := + (tendsto_pow_atTop (by norm_num : 2 ≠ 0)).const_mul_atTop (by positivity : 0 < freq/8) + have he : Tendsto (fun S : ℝ => Real.exp (-freq*S^2/8)) atTop (𝓝 0) := by + convert Real.tendsto_exp_neg_atTop_nhds_zero.comp harg using 1 + ext S + congr 1 + ring + simpa using ((verticalCutoffDerivativeBound_tendsto.pow 2).div_const 2).add + (he.const_mul (freq*verticalCutoffTailConstant freq)) + +/-- The actual capped oscillator keeps a fixed positive excitation gap +for every sufficiently wide slab, uniformly over compact C1 tests. -/ +theorem verticalCappedForm_uniform_complement_gap + (hpublished : PublishedVerticalOscillatorGap) {freq : ℝ} (hfreq : 0 < freq) : + ∃ R : ℝ, 1 ≤ R ∧ ∀ S : ℝ, R ≤ S → ∀ u : ℝ → ℝ, + ContDiff ℝ 1 u → HasCompactSupport u → + (∫ z, u z*verticalMode freq z) = 0 → + freq*(∫ z, u z^2) ≤ verticalCappedForm freq S u := by + have hbar : Tendsto (fun S : ℝ => (freq^2/8)*S^2) atTop atTop := + (tendsto_pow_atTop (by norm_num : 2 ≠ 0)).const_mul_atTop (by positivity : 0 < freq^2/8) + have hb : ∀ᶠ S : ℝ in atTop, 3*freq/2 ≤ freq^2*S^2/8 := by + filter_upwards [hbar.eventually (eventually_ge_atTop (3*freq/2))] with S hS + convert hS using 1; ring + have hl : ∀ᶠ S : ℝ in atTop, verticalCutoffDerivativeBound S^2/2 + + freq*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8) < freq/2 := + (verticalCutoffLoss_tendsto hfreq).eventually (gt_mem_nhds (by linarith)) + obtain ⟨R, hR⟩ := Filter.eventually_atTop.1 (hb.and hl) + refine ⟨max 1 R, le_max_left _ _, fun S hS u hu hc ho => ?_⟩ + have hs : 0 < S := lt_of_lt_of_le (by norm_num : (0:ℝ)<1) ((le_max_left _ _).trans hS) + obtain ⟨hbarrier, hloss⟩ := hR S ((le_max_right _ _).trans hS) + have h := verticalCappedForm_complement_lower hpublished hfreq hs hbarrier u hu hc ho + have hm : 0 ≤ ∫ z, u z^2 := integral_nonneg (fun z => sq_nonneg _) + have hcoef : freq ≤ 3*freq/2 - verticalCutoffDerivativeBound S^2/2 - + freq*verticalCutoffTailConstant freq*Real.exp (-freq*S^2/8) := by linarith + exact (mul_le_mul_of_nonneg_right hcoef hm).trans h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCutoffTail.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCutoffTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..a15b1eb7e138135878a06d7fcbecdc123e00a724 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalCutoffTail.lean @@ -0,0 +1,127 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedForm + +namespace OAI + +/-! Gaussian control of the inner-slab projection error for the actual +transverse cutoff. The loss decays exponentially in the square of the slab +width, with the oscillator frequency fixed by the construction. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def verticalCutoffError (freq S z : ℝ) : ℝ := + (verticalInnerCutoff S z-1)*verticalMode freq z + +theorem verticalCutoffError_memLp {freq : ℝ} (hfreq : 0 < freq) (S : ℝ) : + MemLp (verticalCutoffError freq S) 2 := by + apply (verticalMode_memLp hfreq).of_le_mul (c := 2) + ((((verticalInnerCutoff_smooth S).continuous.sub continuous_const).mul + (verticalMode_smooth freq).continuous).aestronglyMeasurable) + filter_upwards [] with z + change ‖(verticalInnerCutoff S z-1)*verticalMode freq z‖ ≤ _ + rw [norm_mul, Real.norm_eq_abs] + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + have h := abs_sub (verticalInnerCutoff S z) (1:ℝ) + have hs := Real.abs_sin_le_one (verticalCutoffAngle S z) + simp only [abs_one] at h + change |verticalInnerCutoff S z| ≤ 1 at hs + linarith + +def verticalCutoffTailConstant (freq : ℝ) : ℝ := + (4 / Real.sqrt (Real.pi/freq)) * ∫ z : ℝ, Real.exp (-(freq/2)*z^2) + +theorem verticalCutoffTailConstant_nonnegative (freq : ℝ) : + 0 ≤ verticalCutoffTailConstant freq := by + unfold verticalCutoffTailConstant + exact mul_nonneg (div_nonneg (by norm_num) (Real.sqrt_nonneg _)) + (integral_nonneg (fun z => (Real.exp_pos _).le)) + +theorem verticalCutoffError_square_bound {freq S : ℝ} + (hfreq : 0 < freq) (hS : 0 < S) (z : ℝ) : + verticalCutoffError freq S z^2 ≤ + ((4 / Real.sqrt (Real.pi/freq)) * Real.exp (-freq*S^2/8)) * + Real.exp (-(freq/2)*z^2) := by + by_cases hz : |z| ≤ S/2 + · rw [verticalCutoffError, (verticalCutoff_inner hS hz).1, sub_self, zero_mul, zero_pow (by decide : 2 ≠ 0)] + positivity + · have hz' : S/2 ≤ |z| := (le_of_not_ge hz) + have hsq : S^2/4 ≤ z^2 := by + have h := (sq_le_sq₀ (by positivity : 0 ≤ S/2) (abs_nonneg z)).mpr hz' + nlinarith [sq_abs z] + have hd : (verticalInnerCutoff S z-1)^2 ≤ (4:ℝ) := by + have h := abs_sub (verticalInnerCutoff S z) (1:ℝ) + have hs := Real.abs_sin_le_one (verticalCutoffAngle S z) + simp only [abs_one] at h + change |verticalInnerCutoff S z| ≤ 1 at hs + have ha : |verticalInnerCutoff S z-1| ≤ 2 := by linarith + nlinarith [sq_abs (verticalInnerCutoff S z-1), abs_nonneg (verticalInnerCutoff S z-1)] + have he : Real.exp (-freq*z^2) ≤ + Real.exp (-freq*S^2/8)*Real.exp (-(freq/2)*z^2) := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_left hsq hfreq.le] + unfold verticalCutoffError + rw [mul_pow, verticalMode_square hfreq] + calc + _ ≤ 4 * (Real.exp (-freq*z^2) / Real.sqrt (Real.pi/freq)) := + mul_le_mul_of_nonneg_right hd (by positivity) + _ ≤ 4 * ((Real.exp (-freq*S^2/8)*Real.exp (-(freq/2)*z^2)) / + Real.sqrt (Real.pi/freq)) := + mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_right he (Real.sqrt_nonneg _)) (by norm_num) + _ = _ := by ring + +theorem verticalCutoffError_integral_bound {freq S : ℝ} + (hfreq : 0 < freq) (hS : 0 < S) : + (∫ z, verticalCutoffError freq S z^2) ≤ + verticalCutoffTailConstant freq * Real.exp (-freq*S^2/8) := by + have hi : Integrable (fun z => verticalCutoffError freq S z^2) := + (memLp_two_iff_integrable_sq (verticalCutoffError_memLp hfreq S).aestronglyMeasurable).mp + (verticalCutoffError_memLp hfreq S) + have he := (integrable_exp_neg_mul_sq (show 0 < freq/2 by linarith)).const_mul + ((4 / Real.sqrt (Real.pi/freq)) * Real.exp (-freq*S^2/8)) + have h := integral_mono hi he (verticalCutoffError_square_bound hfreq hS) + rw [integral_const_mul] at h + convert h using 1 + unfold verticalCutoffTailConstant + ring + +/-- The projection error is bounded for every actual L2 test function. -/ +theorem verticalCutoff_pair_error {freq S : ℝ} (hfreq : 0 < freq) (hS : 0 < S) + (u : ℝ → ℝ) (hu : MemLp u 2) : + ((∫ z, (verticalInnerCutoff S z*u z)*verticalMode freq z) - + (∫ z, u z*verticalMode freq z))^2 ≤ + (∫ z, u z^2)*(verticalCutoffTailConstant freq * Real.exp (-freq*S^2/8)) := by + have hi₀ : Integrable (fun z => u z*verticalMode freq z) := hu.integrable_mul (verticalMode_memLp hfreq) + have hi₁ : Integrable (fun z => u z*verticalCutoffError freq S z) := + hu.integrable_mul (verticalCutoffError_memLp hfreq S) + have hp : (∫ z, (verticalInnerCutoff S z*u z)*verticalMode freq z) - + (∫ z, u z*verticalMode freq z) = ∫ z, u z*verticalCutoffError freq S z := by + have he : (fun z => (verticalInnerCutoff S z*u z)*verticalMode freq z) = + (fun z => u z*verticalMode freq z + u z*verticalCutoffError freq S z) := by + funext z + unfold verticalCutoffError + ring + rw [he, integral_add hi₀ hi₁] + ring + rw [hp] + have hpair (f g : ℝ → ℝ) (hf : MemLp f 2) (hg : MemLp g 2) : + inner ℝ (hf.toLp f) (hg.toLp g) = ∫ z, f z*g z := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hf.coeFn_toLp, hg.coeFn_toLp] with z hz hf' + rw [hz, hf', RCLike.inner_apply, conj_trivial] + ring + have h := real_inner_mul_inner_self_le (hu.toLp u) + ((verticalCutoffError_memLp hfreq S).toLp (verticalCutoffError freq S)) + rw [hpair _ _ hu (verticalCutoffError_memLp hfreq S), hpair _ _ hu hu, + hpair _ _ (verticalCutoffError_memLp hfreq S) (verticalCutoffError_memLp hfreq S)] at h + have hc := verticalCutoffError_integral_bound hfreq hS + simp only [← pow_two] at h + exact h.trans (mul_le_mul_of_nonneg_left hc (integral_nonneg (fun z => sq_nonneg _))) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f09f3076274c4e13b8288c2c8cd8cc5d18dbe502 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalEnergy.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalMode + +namespace OAI + +/-! The normalized Gaussian actually attains transverse oscillator energy +`freq/2`, by the differential equation and integrable integration by parts. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def verticalForm (freq : ℝ) (u : ℝ → ℝ) : ℝ := + (1 / 2 : ℝ) * (∫ z, deriv u z ^ 2) + + (freq ^ 2 / 2) * (∫ z, z ^ 2 * u z ^ 2) + +theorem verticalMode_second_product_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun z => verticalMode freq z * deriv (deriv (verticalMode freq)) z) := by + have h := ((verticalMode_moment_integrable hfreq 2).const_mul (freq ^ 2)).sub + ((verticalMode_square_integrable hfreq).const_mul freq) + convert h using 1 + funext z + rw [verticalMode_second_deriv] + simp only [Pi.sub_apply] + ring + +theorem verticalMode_energy_ibp {freq : ℝ} (hfreq : 0 < freq) : + (∫ z, verticalMode freq z * deriv (deriv (verticalMode freq)) z) = + -(∫ z, deriv (verticalMode freq) z ^ 2) := by + have h := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + (f := verticalMode freq) (g := deriv (verticalMode freq)) (v := (1 : ℝ)) + (by simpa only [fderiv_apply_one_eq_deriv, ← pow_two] using + verticalMode_deriv_square_integrable hfreq) + (by simpa only [fderiv_apply_one_eq_deriv] using verticalMode_second_product_integrable hfreq) + ((verticalMode_memLp hfreq).integrable_mul (verticalMode_deriv_memLp hfreq)) + (fun z _ => (verticalMode_hasDerivAt freq z).differentiableAt) + (fun z _ => (verticalMode_second_hasDerivAt freq z).differentiableAt) + simpa only [fderiv_apply_one_eq_deriv, ← pow_two] using h + +theorem verticalMode_energy {freq : ℝ} (hfreq : 0 < freq) : + verticalForm freq (verticalMode freq) = freq / 2 := by + have h := verticalMode_energy_ibp hfreq + have heq : (∫ z, verticalMode freq z * deriv (deriv (verticalMode freq)) z) = + freq ^ 2 * (∫ z, z ^ 2 * verticalMode freq z ^ 2) - freq := by + simp_rw [verticalMode_second_deriv] + rw [show (fun z => verticalMode freq z * ((freq ^ 2 * z ^ 2 - freq) * verticalMode freq z)) = + (fun z => freq ^ 2 * (z ^ 2 * verticalMode freq z ^ 2) - freq * verticalMode freq z ^ 2) + from by funext z; ring] + rw [integral_sub ((verticalMode_moment_integrable hfreq 2).const_mul _) + ((verticalMode_square_integrable hfreq).const_mul _), integral_const_mul, + integral_const_mul, verticalMode_normalized hfreq, mul_one] + unfold verticalForm + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalFactorization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..27929a78219642d05f9b13bf57d1e9e39724ac29 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalFactorization.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalCappedForm + +namespace OAI + +/-! The oscillator ground-state transform on compact C¹ functions, with all +boundary terms discharged by compact support. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +theorem vertical_cross_integrable (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) + (hc : HasCompactSupport u) : Integrable (fun z => 2*z*u z*deriv u z) := by + have hd := hu.continuous_deriv (by norm_num) + exact (((continuous_const.mul continuous_id).mul hu.continuous).mul hd).integrable_of_hasCompactSupport + hc.deriv.mul_left + +theorem vertical_cross_identity (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) + (hc : HasCompactSupport u) : + (∫ z : ℝ, 2*z*u z*deriv u z) = -(∫ z : ℝ, u z^2) := by + have hd (z : ℝ) : deriv (fun x => u x^2) z = 2*u z*deriv u z := by + have h := (hu.differentiable (by norm_num) z).hasDerivAt + have hh := h.fun_mul h + have he : (fun x => u x*u x) = (fun x => u x^2) := by funext x; ring + rw [he] at hh + rw [hh.deriv] + ring + have hc2 : HasCompactSupport (fun z => u z^2) := + hc.comp_left (g := fun x : ℝ => x^2) (by norm_num) + have hA : Integrable (fun z => fderiv ℝ (fun x => u x^2) z 1*z) := by + have he : (fun z => fderiv ℝ (fun x => u x^2) z 1*z) = + (fun z => 2*z*u z*deriv u z) := by + funext z + rw [fderiv_apply_one_eq_deriv,hd] + ring + rw [he] + exact vertical_cross_integrable u hu hc + have hB : Integrable (fun z => u z^2*fderiv ℝ (fun x : ℝ => x) z 1) := by + have hcont : Continuous (fun z => u z^2) := by fun_prop + have hi : Integrable (fun z => u z^2) := hcont.integrable_of_hasCompactSupport hc2 + simpa only [fderiv_apply_one_eq_deriv,deriv_id'',mul_one] using hi + have hfg : Integrable (fun z => u z^2*z) := + ((hu.continuous.pow 2).mul continuous_id).integrable_of_hasCompactSupport hc2.mul_right + have h := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable hA hB hfg + (fun z _ => ((hu.pow 2).differentiable (by norm_num) z)) + (fun z _ => differentiableAt_id) + simp only [fderiv_apply_one_eq_deriv,deriv_id'',mul_one,hd] at h + have he : (∫ z : ℝ, 2*u z*deriv u z*z) = ∫ z : ℝ, 2*z*u z*deriv u z := by + apply integral_congr_ae + exact Filter.Eventually.of_forall fun z => by ring + rw [he] at h + linarith + +theorem vertical_factorized_energy (freq : ℝ) (u : ℝ → ℝ) + (hu : ContDiff ℝ 1 u) (hc : HasCompactSupport u) : + (1/2:ℝ)*(∫ z : ℝ, (deriv u z+freq*z*u z)^2) = + verticalForm freq u - (freq/2)*(∫ z : ℝ, u z^2) := by + have hiD := vertical_deriv_square_integrable u hu hc + have hiP := vertical_product_integrable (fun z => z^2) u + (continuous_id.pow 2) hu.continuous hc + have hiC := vertical_cross_integrable u hu hc + have he : (fun z => (deriv u z+freq*z*u z)^2) = + (fun z => (deriv u z)^2+freq^2*(z^2*u z^2)+freq*(2*z*u z*deriv u z)) := by + funext z + ring + rw [he,integral_add (f := fun z => (deriv u z)^2+freq^2*(z^2*u z^2)) + (g := fun z => freq*(2*z*u z*deriv u z)) (hiD.add (hiP.const_mul _)) (hiC.const_mul _), + integral_add (f := fun z => (deriv u z)^2) (g := fun z => freq^2*(z^2*u z^2)) + hiD (hiP.const_mul _),integral_const_mul,integral_const_mul, + vertical_cross_identity u hu hc] + unfold verticalForm + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalMode.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalMode.lean new file mode 100644 index 0000000000000000000000000000000000000000..09592ae116a62e6391a541950d1613570e1cfbaa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalMode.lean @@ -0,0 +1,100 @@ +import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral +import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts +import Mathlib.Analysis.Calculus.ContDiff.Deriv +import Mathlib.MeasureTheory.Function.L2Space + +namespace OAI + +/-! The actual normalized Gaussian in the transverse direction. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +def verticalMode (freq z : ℝ) : ℝ := + Real.exp (-freq * z ^ 2 / 2) / Real.sqrt (Real.sqrt (Real.pi / freq)) + +theorem verticalMode_positive {freq : ℝ} (hfreq : 0 < freq) (z : ℝ) : + 0 < verticalMode freq z := + div_pos (Real.exp_pos _) (Real.sqrt_pos.mpr (Real.sqrt_pos.mpr (div_pos Real.pi_pos hfreq))) + +theorem verticalMode_smooth (freq : ℝ) : ContDiff ℝ ∞ (verticalMode freq) := by + unfold verticalMode + fun_prop + +theorem verticalMode_hasDerivAt (freq z : ℝ) : + HasDerivAt (verticalMode freq) (-freq * z * verticalMode freq z) z := by + have h := ((((hasDerivAt_id z).pow 2).const_mul (-freq)).div_const 2).exp + convert h.div_const (Real.sqrt (Real.sqrt (Real.pi / freq))) using 1 + · rfl + · simp only [verticalMode, id_eq, Pi.pow_apply, Nat.cast_ofNat, Nat.reduceSub, + pow_one, mul_one] + ring + +theorem verticalMode_deriv (freq z : ℝ) : + deriv (verticalMode freq) z = -freq * z * verticalMode freq z := + (verticalMode_hasDerivAt freq z).deriv + +theorem verticalMode_second_hasDerivAt (freq z : ℝ) : + HasDerivAt (deriv (verticalMode freq)) + ((freq ^ 2 * z ^ 2 - freq) * verticalMode freq z) z := by + rw [show deriv (verticalMode freq) = (fun x => -freq * x * verticalMode freq x) + from funext (verticalMode_deriv freq)] + convert (((hasDerivAt_id z).const_mul (-freq)).mul (verticalMode_hasDerivAt freq z)) using 1 + · rfl + · simp only [id_eq] + ring + +theorem verticalMode_second_deriv (freq z : ℝ) : + deriv (deriv (verticalMode freq)) z = (freq ^ 2 * z ^ 2 - freq) * verticalMode freq z := + (verticalMode_second_hasDerivAt freq z).deriv + +theorem verticalMode_square {freq : ℝ} (_hfreq : 0 < freq) (z : ℝ) : + verticalMode freq z ^ 2 = Real.exp (-freq * z ^ 2) / Real.sqrt (Real.pi / freq) := by + unfold verticalMode + rw [div_pow, Real.sq_sqrt (Real.sqrt_nonneg _), ← Real.exp_nat_mul] + congr 2 + ring + +theorem verticalMode_moment_integrable {freq : ℝ} (hfreq : 0 < freq) (n : ℕ) : + Integrable (fun z : ℝ => z ^ n * verticalMode freq z ^ 2) := by + have h : Integrable (fun z : ℝ => z ^ n * Real.exp (-freq * z ^ 2)) := by + simpa only [Real.rpow_natCast] using + (integrable_rpow_mul_exp_neg_mul_sq hfreq (s := (n : ℝ)) + (lt_of_lt_of_le (by norm_num : (-1 : ℝ) < 0) (Nat.cast_nonneg n))) + simp_rw [verticalMode_square hfreq, ← mul_div_assoc] + exact h.div_const _ + +theorem verticalMode_square_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun z : ℝ => verticalMode freq z ^ 2) := by + simpa only [pow_zero, one_mul] using verticalMode_moment_integrable hfreq 0 + +theorem verticalMode_normalized {freq : ℝ} (hfreq : 0 < freq) : + (∫ z : ℝ, verticalMode freq z ^ 2) = 1 := by + simp_rw [verticalMode_square hfreq] + rw [integral_div, integral_gaussian, div_self] + exact (Real.sqrt_pos.mpr (div_pos Real.pi_pos hfreq)).ne' + +theorem verticalMode_memLp {freq : ℝ} (hfreq : 0 < freq) : MemLp (verticalMode freq) 2 := + (memLp_two_iff_integrable_sq (verticalMode_smooth freq).continuous.aestronglyMeasurable).mpr + (verticalMode_square_integrable hfreq) + +theorem verticalMode_deriv_square_integrable {freq : ℝ} (hfreq : 0 < freq) : + Integrable (fun z : ℝ => deriv (verticalMode freq) z ^ 2) := by + have h := (verticalMode_moment_integrable hfreq 2).const_mul (freq ^ 2) + convert h using 1 + funext z + rw [verticalMode_deriv] + ring + +theorem verticalMode_deriv_memLp {freq : ℝ} (hfreq : 0 < freq) : + MemLp (deriv (verticalMode freq)) 2 := by + apply (memLp_two_iff_integrable_sq ?_).mpr (verticalMode_deriv_square_integrable hfreq) + exact ((verticalMode_smooth freq).continuous_deriv (by simp)).aestronglyMeasurable + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalOscillatorGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalOscillatorGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..948f28be054138375f6e2cce8a2fa19b2907deef --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalOscillatorGap.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianMollification +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalFactorization + +namespace OAI + +/-! Discharge of the published transverse-oscillator input. The normalized +Gaussian Poincare inequality and an exact compact-support integration by parts +give precisely the projection inequality used by the continuum reduction. -/ + +noncomputable section +open MeasureTheory +open scoped ContDiff +namespace ContinuumCoulomb + +theorem vertical_quotient_deriv {freq : ℝ} (hf : 0 < freq) + (u : ℝ → ℝ) (hu : ContDiff ℝ 1 u) (z : ℝ) : + deriv (fun x => u x/verticalMode freq x) z = + (deriv u z+freq*z*u z)/verticalMode freq z := by + have hn := (verticalMode_positive hf z).ne' + rw [((hu.differentiable (by norm_num) z).hasDerivAt.fun_div + (verticalMode_hasDerivAt freq z) hn).deriv] + field_simp [hn] + ring + +/-- The exact harmonic-oscillator projection inequality. -/ +theorem publishedVerticalOscillatorGap : PublishedVerticalOscillatorGap := by + intro freq hf u hu hc + let v : ℝ → ℝ := fun z => u z/verticalMode freq z + have hv : ContDiff ℝ 1 v := hu.div ((verticalMode_smooth freq).of_le (by simp)) + (fun z => (verticalMode_positive hf z).ne') + have hvc : HasCompactSupport v := by + change HasCompactSupport (fun z => u z*(verticalMode freq z)⁻¹) + exact hc.mul_right + have hm (z : ℝ) : verticalMode freq z^2*v z^2 = u z^2 := by + dsimp [v] + field_simp [(verticalMode_positive hf z).ne'] + have ha (z : ℝ) : verticalMode freq z^2*v z = u z*verticalMode freq z := by + dsimp [v] + field_simp [(verticalMode_positive hf z).ne'] + have hd (z : ℝ) : verticalMode freq z^2*(deriv v z)^2 = + (deriv u z+freq*z*u z)^2 := by + rw [show deriv v z = _ from vertical_quotient_deriv hf u hu z] + field_simp [(verticalMode_positive hf z).ne'] + have h := gaussian_scalar_poincare hf v hv hvc + simp_rw [hm,ha,hd] at h + have he := vertical_factorized_energy freq u hu hc + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..72a27d324835dcd79eca1b21735d83ea9229cf39 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalResidual.lean @@ -0,0 +1,128 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalSliceProjection + +namespace OAI + +/-! Exact L2 mass splitting into the Gaussian transverse mode and its +orthogonal residual, for arbitrary product-space wavefunctions. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def verticalLift (freq : ℝ) (a : PlanarPosition → ℝ) (p : SplitPosition) : ℝ := + a p.1*verticalMode freq p.2 + +def verticalResidual (freq : ℝ) (f : SplitPosition → ℝ) (p : SplitPosition) : ℝ := + f p-verticalLift freq (verticalCoefficient freq f) p + +theorem verticalLift_memLp {freq : ℝ} (hfreq : 0 < freq) + (a : PlanarPosition → ℝ) (ha : MemLp a 2) : MemLp (verticalLift freq a) 2 := by + have hm : AEStronglyMeasurable (verticalLift freq a) + ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := + ha.aestronglyMeasurable.comp_fst.mul (verticalMode_memLp hfreq).aestronglyMeasurable.comp_snd + have hi := ha.integrable_sq.mul_prod (verticalMode_square_integrable hfreq) + have he : (fun p : SplitPosition => verticalLift freq a p^2) = + fun p => (a p.1)^2*(verticalMode freq p.2)^2 := by + funext p + exact mul_pow _ _ _ + rw [← he] at hi + apply (memLp_two_iff_integrable_sq (by simpa only [Measure.volume_eq_prod] using hm)).mpr + simpa only [Measure.volume_eq_prod] using hi + +theorem verticalLift_mass {freq : ℝ} (hfreq : 0 < freq) (a : PlanarPosition → ℝ) : + (∫ p, (verticalLift freq a p)^2) = ∫ r, a r^2 := by + simp_rw [verticalLift, mul_pow] + rw [Measure.volume_eq_prod, + integral_prod_mul (fun r => a r^2) (fun z => verticalMode freq z^2), + verticalMode_normalized hfreq,mul_one] + +theorem verticalCoefficient_lift {freq : ℝ} (hfreq : 0 < freq) + (a : PlanarPosition → ℝ) (r : PlanarPosition) : + verticalCoefficient freq (verticalLift freq a) r = a r := by + unfold verticalCoefficient verticalLift + rw [show (fun z => a r*verticalMode freq z*verticalMode freq z) = + (fun z => a r*(verticalMode freq z)^2) from funext (fun z => by ring)] + rw [integral_const_mul,verticalMode_normalized hfreq,mul_one] + +theorem verticalCoefficient_pair_identity {freq : ℝ} (hfreq : 0 < freq) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + (∫ p, f p*verticalLift freq (verticalCoefficient freq f) p) = + ∫ r, (verticalCoefficient freq f r)^2 := by + have ha := (verticalCoefficient_contraction hfreq f hf).1 + have hi := hf.integrable_mul (verticalLift_memLp hfreq _ ha) + have hiprod : Integrable (fun p => f p*verticalLift freq (verticalCoefficient freq f) p) + ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + rw [← Measure.volume_eq_prod] + exact hi + rw [Measure.volume_eq_prod,integral_prod _ hiprod] + apply integral_congr_ae + filter_upwards [] with r + change (∫ z, f (r,z)*(verticalCoefficient freq f r*verticalMode freq z)) = _ + rw [show (fun z => f (r,z)*(verticalCoefficient freq f r*verticalMode freq z)) = + (fun z => verticalCoefficient freq f r*(f (r,z)*verticalMode freq z)) from + funext (fun z => by ring),integral_const_mul] + change verticalCoefficient freq f r*verticalCoefficient freq f r = _ + ring + +/-- Exact Pythagoras identity for the actual transverse projection. -/ +theorem verticalResidual_mass {freq : ℝ} (hfreq : 0 < freq) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + MemLp (verticalResidual freq f) 2 ∧ + (∫ p, (verticalResidual freq f p)^2) = + (∫ p, f p^2)-(∫ r, (verticalCoefficient freq f r)^2) := by + let a := verticalCoefficient freq f + let g := verticalLift freq a + have ha : MemLp a 2 := (verticalCoefficient_contraction hfreq f hf).1 + have hg : MemLp g 2 := verticalLift_memLp hfreq a ha + refine ⟨hf.sub hg,?_⟩ + have he : (fun p => (verticalResidual freq f p)^2) = + (fun p => f p^2+(g p^2-2*(f p*g p))) := by + funext p + change (f p-g p)^2 = _ + ring + rw [he,integral_add (f := fun p => f p^2) (g := fun p => g p^2-2*(f p*g p)) + hf.integrable_sq (hg.integrable_sq.sub ((hf.integrable_mul hg).const_mul 2)), + integral_sub (f := fun p => g p^2) (g := fun p => 2*(f p*g p)) + hg.integrable_sq ((hf.integrable_mul hg).const_mul 2),integral_const_mul] + have hm : (∫ p, g p^2) = ∫ r, a r^2 := verticalLift_mass hfreq a + have hp : (∫ p, f p*g p) = ∫ r, a r^2 := verticalCoefficient_pair_identity hfreq f hf + rw [hm,hp] + dsimp [a] + ring + +theorem verticalResidual_coefficient_zero {freq : ℝ} (hfreq : 0 < freq) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + verticalCoefficient freq (verticalResidual freq f) =ᵐ[volume] 0 := by + have ha := (verticalCoefficient_contraction hfreq f hf).1 + have h := verticalCoefficient_sub_ae hfreq f + (verticalLift freq (verticalCoefficient freq f)) hf (verticalLift_memLp hfreq _ ha) + filter_upwards [h] with r hr + change verticalCoefficient freq (fun p => f p-verticalLift freq (verticalCoefficient freq f) p) r = 0 + simpa only [verticalCoefficient_lift hfreq,sub_self] using hr + +/-- The residual is orthogonal to every product with the transverse mode. -/ +theorem verticalResidual_orthogonal {freq : ℝ} (hfreq : 0 < freq) + (f : SplitPosition → ℝ) (hf : MemLp f 2) + (a : PlanarPosition → ℝ) (ha : MemLp a 2) : + (∫ p, verticalResidual freq f p*verticalLift freq a p) = 0 := by + have hr := (verticalResidual_mass hfreq f hf).1 + have hi := hr.integrable_mul (verticalLift_memLp hfreq a ha) + have hiprod : Integrable (fun p => verticalResidual freq f p*verticalLift freq a p) + ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + rw [← Measure.volume_eq_prod] + exact hi + rw [Measure.volume_eq_prod,integral_prod _ hiprod] + apply integral_eq_zero_of_ae + filter_upwards [verticalResidual_coefficient_zero hfreq f hf] with r hz + change (∫ z, verticalResidual freq f (r,z)*(a r*verticalMode freq z)) = 0 + rw [show (fun z => verticalResidual freq f (r,z)*(a r*verticalMode freq z)) = + (fun z => a r*(verticalResidual freq f (r,z)*verticalMode freq z)) from + funext (fun z => by ring),integral_const_mul] + change a r*verticalCoefficient freq (verticalResidual freq f) r = 0 + simp only [hz,Pi.zero_apply,mul_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSliceProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSliceProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab859ba7c55f61fdbfb43eeb5198bc1383f0352f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSliceProjection.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarFrameBound + +namespace OAI + +/-! The actual transverse Gaussian defines a contraction on the full L2 +product space. No compact-support or smoothness hypothesis is imposed here. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +private theorem line_pair_sq_le (f g : ℝ → ℝ) (hf : MemLp f 2) (hg : MemLp g 2) : + (∫ z, f z*g z)^2 ≤ (∫ z, f z^2)*(∫ z, g z^2) := by + have hp (a b : ℝ → ℝ) (ha : MemLp a 2) (hb : MemLp b 2) : + inner ℝ (ha.toLp a) (hb.toLp b) = ∫ z, a z*b z := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [ha.coeFn_toLp,hb.coeFn_toLp] with z hz hz' + rw [hz,hz',RCLike.inner_apply,conj_trivial] + ring + have h := real_inner_mul_inner_self_le (hf.toLp f) (hg.toLp g) + rw [hp f g hf hg,hp f f hf hf,hp g g hg hg] at h + simpa only [pow_two] using h + +def verticalCoefficient (freq : ℝ) (f : SplitPosition → ℝ) (r : PlanarPosition) : ℝ := + ∫ z, f (r,z)*verticalMode freq z + +theorem split_memLp_vertical_slices (f : SplitPosition → ℝ) (hf : MemLp f 2) : + ∀ᵐ r : PlanarPosition, MemLp (fun z : ℝ => f (r,z)) 2 := by + have hp : MemLp f 2 ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + simpa only [Measure.volume_eq_prod] using hf + filter_upwards [hp.aestronglyMeasurable.prodMk_left,hp.integrable_sq.prod_right_ae] with r hr hi + exact (memLp_two_iff_integrable_sq hr).mpr hi + +/-- The normalized Gaussian coefficient is an L2 contraction on arbitrary +real wavefunctions, including the closure needed for the continuum form. -/ +theorem verticalCoefficient_contraction {freq : ℝ} (hfreq : 0 < freq) + (f : SplitPosition → ℝ) (hf : MemLp f 2) : + MemLp (verticalCoefficient freq f) 2 ∧ + (∫ r, (verticalCoefficient freq f r)^2) ≤ ∫ p, f p^2 := by + have hfprod : MemLp f 2 ((volume : Measure PlanarPosition).prod (volume : Measure ℝ)) := by + simpa only [Measure.volume_eq_prod] using hf + have hfsq := hfprod.integrable_sq + have hm : AEStronglyMeasurable (verticalCoefficient freq f) volume := + (hfprod.aestronglyMeasurable.mul (verticalMode_memLp hfreq).aestronglyMeasurable.comp_snd).integral_prod_right' + have hs := split_memLp_vertical_slices f hf + have hdom : ∀ᵐ r : PlanarPosition, + (verticalCoefficient freq f r)^2 ≤ ∫ z : ℝ, f (r,z)^2 := by + filter_upwards [hs] with r hr + simpa only [verticalCoefficient,verticalMode_normalized hfreq,mul_one] using + line_pair_sq_le (fun z => f (r,z)) (verticalMode freq) hr (verticalMode_memLp hfreq) + have hi : Integrable (fun r : PlanarPosition => ∫ z : ℝ, f (r,z)^2) := hfsq.integral_prod_left + have ha : Integrable (fun r => (verticalCoefficient freq f r)^2) := + hi.mono' (hm.pow 2) (hdom.mono (fun r hr => by + simpa only [Real.norm_eq_abs, + abs_of_nonneg (sq_nonneg (verticalCoefficient freq f r))] using hr)) + refine ⟨(memLp_two_iff_integrable_sq hm).mpr ha, ?_⟩ + have h := integral_mono_ae ha hi hdom + rw [← integral_prod _ hfsq] at h + simpa only [Measure.volume_eq_prod] using h + +theorem verticalCoefficient_sub_ae {freq : ℝ} (hfreq : 0 < freq) + (f g : SplitPosition → ℝ) (hf : MemLp f 2) (hg : MemLp g 2) : + verticalCoefficient freq (fun p => f p-g p) =ᵐ[volume] + fun r => verticalCoefficient freq f r-verticalCoefficient freq g r := by + filter_upwards [split_memLp_vertical_slices f hf,split_memLp_vertical_slices g hg] with r hr hr' + unfold verticalCoefficient + rw [show (fun z => (f (r,z)-g (r,z))*verticalMode freq z) = + (fun z => f (r,z)*verticalMode freq z-g (r,z)*verticalMode freq z) from + funext (fun z => sub_mul _ _ _)] + simpa only [Pi.mul_apply] using + integral_sub (hr.integrable_mul (verticalMode_memLp hfreq)) + (hr'.integrable_mul (verticalMode_memLp hfreq)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSpectralInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSpectralInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbf0cd32002d939986b88882cc48c264877e1cae --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/VerticalSpectralInput.lean @@ -0,0 +1,38 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.VerticalEnergy + +namespace OAI + +/-! The published oscillator gap, specialized to the one-dimensional form. + +Gerald Teschl, *Mathematical Methods in Quantum Mechanics*, second edition, +AMS Graduate Studies in Mathematics 157 (2014), Section 8.3, equations +(8.39)--(8.43) and Theorem 8.5; form-domain max-min in Theorem 4.12. +https://www.mat.univie.ac.at/~gerald/ftp/book-schroe/schroe2.pdf + +The one-dimensional Hermite calculation gives eigenvalues `(2n+1)freq` +for `-∂²+freq²z²` and the Gaussian (8.41). Dividing by two gives bottom +`freq/2` and gap `freq`. We assume just the resulting projection-form inequality +on compact C¹ tests. The Gaussian and its normalization and attained energy +are actual definitions and proved facts, not extra premises. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +def PublishedVerticalOscillatorGap : Prop := + ∀ (freq : ℝ), 0 < freq → ∀ (u : ℝ → ℝ), ContDiff ℝ 1 u → HasCompactSupport u → + (3 * freq / 2) * (∫ z, u z ^ 2) - freq * (∫ z, u z * verticalMode freq z) ^ 2 ≤ + verticalForm freq u + +theorem verticalForm_gap_on_orthogonal (hpublished : PublishedVerticalOscillatorGap) + {freq : ℝ} (hfreq : 0 < freq) {u : ℝ → ℝ} (hu : ContDiff ℝ 1 u) + (hc : HasCompactSupport u) (ho : (∫ z, u z * verticalMode freq z) = 0) : + (3 * freq / 2) * (∫ z, u z ^ 2) ≤ verticalForm freq u := by + simpa only [ho, zero_pow (by norm_num : 2 ≠ 0), mul_zero, sub_zero] using + hpublished freq hfreq u hu hc + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakComplexLaplacian.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakComplexLaplacian.lean new file mode 100644 index 0000000000000000000000000000000000000000..be17ac402b58f380dbe050f4dc5ee2b6e85d4032 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakComplexLaplacian.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Laplacian + +namespace OAI + +/-! Integration by parts for a complex C2 orbital against the full weak-H1 +space. Only the sum of its second derivatives is required to lie in L2. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +def configurationComplexPartial {n : ℕ} (φ : Configuration n → ℂ) + (a : Fin n × Fin 3) (x : Configuration n) : ℂ := + fderiv ℝ φ x (EuclideanSpace.single a 1) + +def configurationComplexLaplacian {n : ℕ} (φ : Configuration n → ℂ) + (x : Configuration n) : ℂ := + ∑ a, configurationComplexPartial (configurationComplexPartial φ a) a x + +theorem configurationComplexPartial_C1 {n : ℕ} {φ : Configuration n → ℂ} + (hφ : ContDiff ℝ 2 φ) (a : Fin n × Fin 3) : + ContDiff ℝ 1 (configurationComplexPartial φ a) := + (hφ.fderiv_right (show (1 : WithTop ℕ∞)+1 ≤ 2 by norm_num)).clm_apply contDiff_const + +theorem h1_inner_complex_coordinate {n : ℕ} (u : Coulomb.H1Vector n) + (a : H1Index n) (φ : Configuration n → ℂ) (hφ : MemLp φ 2) : + inner ℂ (hφ.toLp φ) (h1Coordinates u a) = + ∫ x, star (φ x)*h1CoordinateFunction u a x := by + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hφ.coeFn_toLp,(h1Coordinate_memLp u a).coeFn_toLp] with x hp hu + change h1Coordinates u a x = h1CoordinateFunction u a x at hu + rw [hp,hu,RCLike.inner_apply] + exact mul_comm _ _ + +theorem weakH1_complex_laplacian_pairing (hdensity : PublishedSobolevSmoothDensity) + {n : ℕ} (φ : Configuration n → ℂ) (hφ : ContDiff ℝ 2 φ) + (hpartial : ∀ a, MemLp (configurationComplexPartial φ a) 2) + (hlap : MemLp (configurationComplexLaplacian φ) 2) + (v : Coulomb.H1Vector n) (s : SpinConfiguration n) : + (∑ a, ∫ x, star (configurationComplexPartial φ a x)*v.gradient s a x) = + -(∫ x, star (configurationComplexLaplacian φ x)*v.value s x) := by + let G (a : Fin n × Fin 3) : Lp ℂ 2 (volume : Measure (Configuration n)) := + (hpartial a).toLp (configurationComplexPartial φ a) + let L : Lp ℂ 2 (volume : Measure (Configuration n)) := + hlap.toLp (configurationComplexLaplacian φ) + have hpair (w : Coulomb.H1Vector n) (a : Fin n × Fin 3) : + inner ℂ (G a) (h1Coordinates w (Sum.inr (s,a))) = + ∫ x, star (configurationComplexPartial φ a x)*w.gradient s a x := + h1_inner_complex_coordinate w (Sum.inr (s,a)) _ (hpartial a) + have hlpair (w : Coulomb.H1Vector n) : + inner ℂ L (h1Coordinates w (Sum.inl s)) = + ∫ x, star (configurationComplexLaplacian φ x)*w.value s x := + h1_inner_complex_coordinate w (Sum.inl s) _ hlap + have hcompact (w : Coulomb.H1Vector n) + (hw : ∀ t, ContDiff ℝ 1 (w.value t) ∧ HasCompactSupport (w.value t)) + (hd : ∀ t a x, w.gradient t a x = + fderiv ℝ (w.value t) x (EuclideanSpace.single a 1)) : + (∑ a, inner ℂ (G a) (h1Coordinates w (Sum.inr (s,a)))) = + -inner ℂ L (h1Coordinates w (Sum.inl s)) := by + have hi (a : Fin n × Fin 3) : Integrable (fun x => + star (configurationComplexPartial (configurationComplexPartial φ a) a x)*w.value s x) := + (((configurationComplexPartial_C1 hφ a).continuous_fderiv (by norm_num)).clm_apply + continuous_const).star.mul (hw s).1.continuous |>.integrable_of_hasCompactSupport (hw s).2.mul_left + have he (a : Fin n × Fin 3) : + (∫ x, star (configurationComplexPartial φ a x)*w.gradient s a x) = + -(∫ x, star (configurationComplexPartial (configurationComplexPartial φ a) a x)*w.value s x) := by + have hc := configurationComplexPartial_C1 hφ a + have hstar (x : Configuration n) : + fderiv ℝ (fun y => star (configurationComplexPartial φ a y)) x + (EuclideanSpace.single a 1) = + star (configurationComplexPartial (configurationComplexPartial φ a) a x) := by + exact congrArg (fun B : Configuration n →L[ℝ] ℂ => B (EuclideanSpace.single a 1)) + (Complex.conjCLE.hasFDerivAt.comp x (hc.differentiable (by norm_num) x).hasFDerivAt).fderiv + have hh := complex_C1_compact_test_ibp (fun x => star (configurationComplexPartial φ a x)) + (w.value s) (Complex.conjCLE.contDiff.comp hc) (hw s).1 (hw s).2 + (EuclideanSpace.single a 1) + simpa only [hd,hstar] using hh + simp only [hpair,hlpair] + simp_rw [he] + rw [Finset.sum_neg_distrib] + congr 1 + rw [← integral_finsetSum Finset.univ (fun a _ => hi a)] + apply integral_congr_ae + filter_upwards [] with x + simp only [configurationComplexLaplacian,star_sum,Finset.sum_mul] + obtain ⟨w,hw,hd,ht⟩ := exists_compact_h1_graph_sequence hdensity v + have hcG : Continuous (fun f : H1Coordinates n => + ∑ a, inner ℂ (G a) (f (Sum.inr (s,a)))) := + continuous_finsetSum _ (fun a _ => continuous_const.inner (continuous_apply _)) + have hcL : Continuous (fun f : H1Coordinates n => -inner ℂ L (f (Sum.inl s))) := + (continuous_const.inner (continuous_apply _)).neg + have heq := tendsto_nhds_unique (hcG.continuousAt.tendsto.comp ht) + ((hcL.continuousAt.tendsto.comp ht).congr' (Filter.Eventually.of_forall + (fun k => (hcompact (w k) (hw k) (hd k)).symm))) + simpa only [hpair,hlpair] using heq + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Laplacian.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Laplacian.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a771e0ba80a6ee43378e2ed977d86ce2cade2f0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Laplacian.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WeakH1Pairing + +namespace OAI + +/-! The weak kinetic pairing with a C2 orbital only requires its Laplacian, +not each second partial separately, to belong to L2. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology BigOperators +namespace ContinuumCoulomb + +def configurationRealPartial {n : ℕ} (φ : Configuration n → ℝ) + (a : Fin n × Fin 3) (x : Configuration n) : ℝ := + fderiv ℝ φ x (EuclideanSpace.single a 1) + +def configurationRealLaplacian {n : ℕ} (φ : Configuration n → ℝ) + (x : Configuration n) : ℝ := + ∑ a, configurationRealPartial (configurationRealPartial φ a) a x + +theorem configurationRealPartial_C1 {n : ℕ} {φ : Configuration n → ℝ} + (hφ : ContDiff ℝ 2 φ) (a : Fin n × Fin 3) : + ContDiff ℝ 1 (configurationRealPartial φ a) := + (hφ.fderiv_right (show (1 : WithTop ℕ∞)+1 ≤ 2 by norm_num)).clm_apply contDiff_const + +theorem weakH1_laplacian_pairing (hdensity : PublishedSobolevSmoothDensity) + {n : ℕ} (φ : Configuration n → ℝ) (hφ : ContDiff ℝ 2 φ) + (hpartial : ∀ a, MemLp (configurationRealPartial φ a) 2) + (hlap : MemLp (configurationRealLaplacian φ) 2) + (v : Coulomb.H1Vector n) (s : SpinConfiguration n) : + (∑ a, ∫ x, v.gradient s a x*(configurationRealPartial φ a x : ℂ)) = + -(∫ x, v.value s x*(configurationRealLaplacian φ x : ℂ)) := by + let G (a : Fin n × Fin 3) : Lp ℂ 2 (volume : Measure (Configuration n)) := + (hpartial a).ofReal.toLp (fun x => (configurationRealPartial φ a x : ℂ)) + let L : Lp ℂ 2 (volume : Measure (Configuration n)) := + hlap.ofReal.toLp (fun x => (configurationRealLaplacian φ x : ℂ)) + have hpair (w : Coulomb.H1Vector n) (a : Fin n × Fin 3) : + inner ℂ (G a) (h1Coordinates w (Sum.inr (s,a))) = + ∫ x, w.gradient s a x*(configurationRealPartial φ a x : ℂ) := + h1_inner_real_coordinate w (Sum.inr (s,a)) _ (hpartial a) + have hlpair (w : Coulomb.H1Vector n) : + inner ℂ L (h1Coordinates w (Sum.inl s)) = + ∫ x, w.value s x*(configurationRealLaplacian φ x : ℂ) := + h1_inner_real_coordinate w (Sum.inl s) _ hlap + have hcompact (w : Coulomb.H1Vector n) + (hw : ∀ t, ContDiff ℝ 1 (w.value t) ∧ HasCompactSupport (w.value t)) + (hd : ∀ t a x, w.gradient t a x = + fderiv ℝ (w.value t) x (EuclideanSpace.single a 1)) : + (∑ a, inner ℂ (G a) (h1Coordinates w (Sum.inr (s,a)))) = + -inner ℂ L (h1Coordinates w (Sum.inl s)) := by + have hi (a : Fin n × Fin 3) : Integrable (fun x => w.value s x* + (configurationRealPartial (configurationRealPartial φ a) a x : ℂ)) := + ((hw s).1.continuous.mul (Complex.continuous_ofReal.comp + (((configurationRealPartial_C1 hφ a).continuous_fderiv (by norm_num)).clm_apply + continuous_const))).integrable_of_hasCompactSupport (hw s).2.mul_right + have he (a : Fin n × Fin 3) : + (∫ x, w.gradient s a x*(configurationRealPartial φ a x : ℂ)) = + -(∫ x, w.value s x* + (configurationRealPartial (configurationRealPartial φ a) a x : ℂ)) := by + have hc := configurationRealPartial_C1 hφ a + have hdcast (x : Configuration n) : + fderiv ℝ (fun y => (configurationRealPartial φ a y : ℂ)) x + (EuclideanSpace.single a 1) = + (configurationRealPartial (configurationRealPartial φ a) a x : ℂ) := by + exact congrArg (fun B : Configuration n →L[ℝ] ℂ => B (EuclideanSpace.single a 1)) + (Complex.ofRealCLM.hasFDerivAt.comp x (hc.differentiable (by norm_num) x).hasFDerivAt).fderiv + have hh := complex_C1_compact_test_ibp (fun x => (configurationRealPartial φ a x : ℂ)) + (w.value s) (Complex.ofRealCLM.contDiff.comp hc) (hw s).1 (hw s).2 + (EuclideanSpace.single a 1) + simpa only [hd,hdcast,mul_comm] using hh + simp only [hpair,hlpair] + simp_rw [he] + rw [Finset.sum_neg_distrib] + congr 1 + rw [← integral_finsetSum Finset.univ (fun a _ => hi a)] + apply integral_congr_ae + filter_upwards [] with x + simp only [configurationRealLaplacian,Complex.ofReal_sum,Finset.mul_sum] + obtain ⟨w,hw,hd,ht⟩ := exists_compact_h1_graph_sequence hdensity v + have hcG : Continuous (fun f : H1Coordinates n => + ∑ a, inner ℂ (G a) (f (Sum.inr (s,a)))) := + continuous_finsetSum _ (fun a _ => continuous_const.inner (continuous_apply _)) + have hcL : Continuous (fun f : H1Coordinates n => -inner ℂ L (f (Sum.inl s))) := + (continuous_const.inner (continuous_apply _)).neg + have heq := tendsto_nhds_unique (hcG.continuousAt.tendsto.comp ht) + ((hcL.continuousAt.tendsto.comp ht).congr' (Filter.Eventually.of_forall + (fun k => (hcompact (w k) (hw k) (hd k)).symm))) + simpa only [hpair,hlpair] using heq + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Pairing.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Pairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8ff03207a6e71f88dd3343223dcc9adc8fd0547 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WeakH1Pairing.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.OneElectronClosure +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ClassicalH1 + +namespace OAI + +/-! Integration by parts against a noncompact square-integrable C1 function +on the actual weak-H1 graph. Compact approximation is used only through the +explicit published Sobolev density input. -/ + +noncomputable section +open MeasureTheory Filter +open scoped Topology +namespace ContinuumCoulomb + +theorem complex_C1_compact_test_ibp {n : ℕ} (f g : Configuration n → ℂ) + (hf : ContDiff ℝ 1 f) (hg : ContDiff ℝ 1 g) (hc : HasCompactSupport g) + (a : Configuration n) : + (∫ x, f x*fderiv ℝ g x a) = -(∫ x, fderiv ℝ f x a*g x) := by + have hf' : Continuous (fun x => fderiv ℝ f x a) := + (hf.continuous_fderiv (by norm_num)).clm_apply continuous_const + have hg' : Continuous (fun x => fderiv ℝ g x a) := + (hg.continuous_fderiv (by norm_num)).clm_apply continuous_const + exact integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable + ((hf'.mul hg.continuous).integrable_of_hasCompactSupport hc.mul_left) + ((hf.continuous.mul hg').integrable_of_hasCompactSupport (hc.fderiv_apply ℝ a).mul_left) + ((hf.continuous.mul hg.continuous).integrable_of_hasCompactSupport hc.mul_left) + (fun x _ => hf.differentiable (by norm_num) x) + (fun x _ => hg.differentiable (by norm_num) x) + +theorem h1_inner_real_coordinate {n : ℕ} (u : Coulomb.H1Vector n) + (a : H1Index n) (φ : Configuration n → ℝ) (hφ : MemLp φ 2) : + inner ℂ (hφ.ofReal.toLp (fun x => (φ x : ℂ))) (h1Coordinates u a) = + ∫ x, h1CoordinateFunction u a x*(φ x : ℂ) := by + have hmem : MemLp (fun x => (φ x : ℂ)) 2 := hφ.ofReal + rw [L2.inner_def] + apply integral_congr_ae + filter_upwards [hmem.coeFn_toLp,(h1Coordinate_memLp u a).coeFn_toLp] with x hp hu + change h1Coordinates u a x = h1CoordinateFunction u a x at hu + change inner ℂ (hmem.toLp _ x) (h1Coordinates u a x) = _ + rw [hp,hu,RCLike.inner_apply] + simp only [Complex.conj_ofReal] + +theorem weakH1_real_test_ibp (hdensity : PublishedSobolevSmoothDensity) + {n : ℕ} (g : Configuration n → ℝ) (hg : ContDiff ℝ 1 g) (hL2 : MemLp g 2) + (a : Fin n × Fin 3) + (hpartial : MemLp (fun x => fderiv ℝ g x (EuclideanSpace.single a 1)) 2) + (v : Coulomb.H1Vector n) (s : SpinConfiguration n) : + (∫ x, v.gradient s a x*(g x : ℂ)) = + -(∫ x, v.value s x*(fderiv ℝ g x (EuclideanSpace.single a 1) : ℂ)) := by + let d : Configuration n → ℝ := fun x => fderiv ℝ g x (EuclideanSpace.single a 1) + let G : Lp ℂ 2 (volume : Measure (Configuration n)) := hL2.ofReal.toLp (fun x => (g x : ℂ)) + let D : Lp ℂ 2 (volume : Measure (Configuration n)) := hpartial.ofReal.toLp (fun x => (d x : ℂ)) + have hcompact (w : Coulomb.H1Vector n) + (hw : ∀ t, ContDiff ℝ 1 (w.value t) ∧ HasCompactSupport (w.value t)) + (hd : ∀ t b x, w.gradient t b x = + fderiv ℝ (w.value t) x (EuclideanSpace.single b 1)) : + inner ℂ G (h1Coordinates w (Sum.inr (s,a))) = + -inner ℂ D (h1Coordinates w (Sum.inl s)) := by + rw [h1_inner_real_coordinate w (Sum.inr (s,a)) g hL2, + h1_inner_real_coordinate w (Sum.inl s) d hpartial] + have he (x : Configuration n) : fderiv ℝ (fun y => (g y : ℂ)) x + (EuclideanSpace.single a 1) = (d x : ℂ) := by + exact congrArg (fun L : Configuration n →L[ℝ] ℂ => L (EuclideanSpace.single a 1)) + (Complex.ofRealCLM.hasFDerivAt.comp x (hg.differentiable (by norm_num) x).hasFDerivAt).fderiv + have hi := complex_C1_compact_test_ibp (fun x => (g x : ℂ)) (w.value s) + (Complex.ofRealCLM.contDiff.comp hg) (hw s).1 (hw s).2 (EuclideanSpace.single a 1) + simpa only [h1CoordinateFunction, hd, he, mul_comm] using hi + obtain ⟨w,hw,hd,ht⟩ := exists_compact_h1_graph_sequence hdensity v + have hcG : Continuous (fun f : H1Coordinates n => inner ℂ G (f (Sum.inr (s,a)))) := + continuous_const.inner (continuous_apply _) + have hcD : Continuous (fun f : H1Coordinates n => -inner ℂ D (f (Sum.inl s))) := + (continuous_const.inner (continuous_apply _)).neg + have hl := hcG.continuousAt.tendsto.comp ht + have hr := hcD.continuousAt.tendsto.comp ht + have heq : inner ℂ G (h1Coordinates v (Sum.inr (s,a))) = + -inner ℂ D (h1Coordinates v (Sum.inl s)) := + tendsto_nhds_unique hl (hr.congr' (Filter.Eventually.of_forall (fun k => + (hcompact (w k) (hw k) (hd k)).symm))) + change inner ℂ (hL2.ofReal.toLp (fun x => (g x : ℂ))) + (h1Coordinates v (Sum.inr (s,a))) = + -inner ℂ (hpartial.ofReal.toLp (fun x => (d x : ℂ))) + (h1Coordinates v (Sum.inl s)) at heq + rw [h1_inner_real_coordinate v (Sum.inr (s,a)) g hL2, + h1_inner_real_coordinate v (Sum.inl s) d hpartial] at heq + exact heq + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapDerivatives.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapDerivatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e7ca9990bb297c7c7f5a4ee6fbc4f16cc9259c0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapDerivatives.lean @@ -0,0 +1,181 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.WellCapRegularity + +namespace OAI + +/-! Uniform quantitative bounds on the two derivatives of the rational cap. -/ + +noncomputable section +open Set Filter +open scoped Topology +namespace ContinuumCoulomb + +private theorem cap_local_zero {t : ℝ} (ht : t < 1 / 16) : + wellCap =ᶠ[𝓝 t] fun _ => 0 := by + filter_upwards [Iio_mem_nhds ht] with s hs + exact wellCap_eq_zero hs.le + +private theorem cap_local_one {t : ℝ} (ht : 1 / 8 < t) : + wellCap =ᶠ[𝓝 t] fun _ => 1 := by + filter_upwards [Ioi_mem_nhds ht] with s hs + exact wellCap_eq_one hs.le + +private theorem cap_local_middle {t : ℝ} (ht0 : 1 / 16 < t) (ht1 : t < 1 / 8) : + wellCap =ᶠ[𝓝 t] fun s => wellTransition (16 * s - 1) := by + filter_upwards [Ioi_mem_nhds ht0, Iio_mem_nhds ht1] with s hs0 hs1 + change 1 / 16 < s at hs0 + change s < 1 / 8 at hs1 + simp only [wellCap, ite_eq_right (not_le.mpr hs0), ite_eq_right (not_le.mpr hs1)] + +theorem wellCap_deriv_zero_left {t : ℝ} (ht : t ≤ 1 / 16) : deriv wellCap t = 0 := by + rcases lt_or_eq_of_le ht with hlt | heq + · rw [(cap_local_zero hlt).deriv_eq] + simp + · subst t + have hmin : IsLocalMin wellCap (1 / 16) := by + apply Filter.Eventually.of_forall + intro s + rw [wellCap_eq_zero (le_refl _)] + exact (wellCap_bounds s).1 + exact hmin.deriv_eq_zero + +theorem wellCap_deriv_zero_right {t : ℝ} (ht : 1 / 8 ≤ t) : deriv wellCap t = 0 := by + rcases lt_or_eq_of_le ht with hlt | heq + · rw [(cap_local_one hlt).deriv_eq] + simp + · subst t + have hmax : IsLocalMax wellCap (1 / 8) := by + apply Filter.Eventually.of_forall + intro s + rw [wellCap_eq_one (le_refl _)] + exact (wellCap_bounds s).2 + exact hmax.deriv_eq_zero + +private theorem middle_hasDerivAt (t : ℝ) : + HasDerivAt (fun s => wellTransition (16 * s - 1)) + (480 * (16 * t - 1) ^ 2 * (16 * t - 2) ^ 2) t := by + have hlin := ((hasDerivAt_id t).const_mul 16).sub_const 1 + convert (((hlin.pow 5).const_mul 6).sub ((hlin.pow 4).const_mul 15)).add + ((hlin.pow 3).const_mul 10) using 1 <;> (try funext y) <;> + (dsimp [wellTransition]; all_goals ring) + +private theorem middlePrime_hasDerivAt (t : ℝ) : + HasDerivAt (fun s => 480 * (16 * s - 1) ^ 2 * (16 * s - 2) ^ 2) + (15360 * (16 * t - 1) * (16 * t - 2) * (32 * t - 3)) t := by + have hlin := ((hasDerivAt_id t).const_mul 16).sub_const 1 + have hlin' := ((hasDerivAt_id t).const_mul 16).sub_const 2 + convert ((hlin.pow 2).const_mul 480).mul (hlin'.pow 2) using 1 <;> + (try funext y) <;> (dsimp; all_goals ring) + +theorem wellCap_deriv_inside {t : ℝ} (ht0 : 1 / 16 < t) (ht1 : t < 1 / 8) : + deriv wellCap t = 480 * (16 * t - 1) ^ 2 * (16 * t - 2) ^ 2 := by + rw [(cap_local_middle ht0 ht1).deriv_eq] + exact (middle_hasDerivAt t).deriv + +theorem wellCap_deriv_bounds (t : ℝ) : 0 ≤ deriv wellCap t ∧ deriv wellCap t ≤ 480 := by + by_cases h0 : t ≤ 1 / 16 + · rw [wellCap_deriv_zero_left h0] + norm_num + by_cases h1 : 1 / 8 ≤ t + · rw [wellCap_deriv_zero_right h1] + norm_num + rw [wellCap_deriv_inside (lt_of_not_ge h0) (lt_of_not_ge h1)] + have hs0 : 0 ≤ 16 * t - 1 := by linarith + have hs1 : 16 * t - 1 ≤ 1 := by linarith + have ha : (16 * t - 1) ^ 2 ≤ 1 := by nlinarith + have hb : (16 * t - 2) ^ 2 ≤ 1 := by nlinarith + have hab := mul_le_mul ha hb (sq_nonneg (16 * t - 2)) (by norm_num : (0 : ℝ) ≤ 1) + constructor + · positivity + · nlinarith + +theorem wellCap_deriv2_zero_left {t : ℝ} (ht : t ≤ 1 / 16) : + deriv (deriv wellCap) t = 0 := by + rcases lt_or_eq_of_le ht with hlt | heq + · rw [(cap_local_zero hlt).deriv.deriv_eq] + simp + · subst t + have hmin : IsLocalMin (deriv wellCap) (1 / 16) := by + apply Filter.Eventually.of_forall + intro s + rw [wellCap_deriv_zero_left (le_refl _)] + exact (wellCap_deriv_bounds s).1 + exact hmin.deriv_eq_zero + +theorem wellCap_deriv2_zero_right {t : ℝ} (ht : 1 / 8 ≤ t) : + deriv (deriv wellCap) t = 0 := by + rcases lt_or_eq_of_le ht with hlt | heq + · rw [(cap_local_one hlt).deriv.deriv_eq] + simp + · subst t + have hmin : IsLocalMin (deriv wellCap) (1 / 8) := by + apply Filter.Eventually.of_forall + intro s + rw [wellCap_deriv_zero_right (le_refl _)] + exact (wellCap_deriv_bounds s).1 + exact hmin.deriv_eq_zero + +theorem wellCap_deriv2_inside {t : ℝ} (ht0 : 1 / 16 < t) (ht1 : t < 1 / 8) : + deriv (deriv wellCap) t = + 15360 * (16 * t - 1) * (16 * t - 2) * (32 * t - 3) := by + rw [(cap_local_middle ht0 ht1).deriv.deriv_eq] + have heq : deriv (fun s => wellTransition (16 * s - 1)) = + fun s => 480 * (16 * s - 1) ^ 2 * (16 * s - 2) ^ 2 := by + funext s + exact (middle_hasDerivAt s).deriv + rw [heq] + exact (middlePrime_hasDerivAt t).deriv + +theorem wellCap_deriv2_bound (t : ℝ) : |deriv (deriv wellCap) t| ≤ 15360 := by + by_cases h0 : t ≤ 1 / 16 + · rw [wellCap_deriv2_zero_left h0] + norm_num + by_cases h1 : 1 / 8 ≤ t + · rw [wellCap_deriv2_zero_right h1] + norm_num + rw [wellCap_deriv2_inside (lt_of_not_ge h0) (lt_of_not_ge h1)] + have ha : |16 * t - 1| ≤ 1 := abs_le.mpr ⟨by linarith, by linarith⟩ + have hb : |16 * t - 2| ≤ 1 := abs_le.mpr ⟨by linarith, by linarith⟩ + have hc : |32 * t - 3| ≤ 1 := abs_le.mpr ⟨by linarith, by linarith⟩ + have hab := mul_le_mul ha hb (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have habc := mul_le_mul hab hc (abs_nonneg _) (by norm_num : (0 : ℝ) ≤ 1 * 1) + simp only [abs_mul, abs_of_nonneg (by norm_num : (0 : ℝ) ≤ 15360)] + nlinarith + +theorem wellCap_lipschitz : LipschitzWith 480 wellCap := by + apply lipschitzWith_of_nnnorm_deriv_le + (wellCap_contDiff_two.differentiable (by norm_num)) + intro t + change ‖deriv wellCap t‖ ≤ (480 : ℝ) + rw [Real.norm_eq_abs, abs_of_nonneg (wellCap_deriv_bounds t).1] + exact (wellCap_deriv_bounds t).2 + +theorem wellCap_deriv_lipschitz : LipschitzWith 15360 (deriv wellCap) := by + have h : ContDiff ℝ 1 (deriv wellCap) := wellCap_contDiff_two.deriv' + apply lipschitzWith_of_nnnorm_deriv_le (h.differentiable (by norm_num)) + intro t + change ‖deriv (deriv wellCap) t‖ ≤ (15360 : ℝ) + simpa only [Real.norm_eq_abs] using wellCap_deriv2_bound t + +theorem radial_wellCap_difference {D : ℝ} (hD : 0 < D) (center x y : Position) : + |wellCap (‖x - center‖ / D) - wellCap (‖y - center‖ / D)| ≤ + (480 / D) * ‖x - y‖ := by + have hcap := wellCap_lipschitz.dist_le_mul (‖x - center‖ / D) (‖y - center‖ / D) + have hrad : |‖x - center‖ / D - ‖y - center‖ / D| ≤ ‖x - y‖ / D := by + rw [← sub_div, abs_div, abs_of_pos hD] + apply div_le_div_of_nonneg_right _ hD.le + have h := abs_norm_sub_norm_le (x - center) (y - center) + have he : (x - center) - (y - center) = x - y := by abel + simpa only [he] using h + have hc : |wellCap (‖x - center‖ / D) - wellCap (‖y - center‖ / D)| ≤ + 480 * |‖x - center‖ / D - ‖y - center‖ / D| := by + simpa only [Real.dist_eq, NNReal.coe_ofNat] using hcap + apply hc.trans + calc + _ ≤ 480 * (‖x - y‖ / D) := mul_le_mul_of_nonneg_left hrad (by norm_num) + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapRegularity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fc1af8b9f46e9e7c0aa130561338f581fd0060c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCapRegularity.lean @@ -0,0 +1,197 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedWells + +namespace OAI + +/-! C² regularity of the manuscript's rational quintic nuclear cap. -/ + +noncomputable section +open Set Filter +open scoped Topology ContDiff +namespace ContinuumCoulomb + +private theorem hasDerivAt_wellSplice (f g df dg : ℝ → ℝ) (a : ℝ) + (hf : ∀ x, HasDerivAt f (df x) x) (hg : ∀ x, HasDerivAt g (dg x) x) + (hvalue : f a = g a) (hderiv : df a = dg a) (x : ℝ) : + HasDerivAt (fun t => if t ≤ a then f t else g t) + (if x ≤ a then df x else dg x) x := by + rcases lt_trichotomy x a with hx | he | hx + · rw [ite_eq_left hx.le] + apply (hf x).congr_of_eventuallyEq + filter_upwards [Iio_mem_nhds hx] with t ht + exact ite_eq_left ht.le + · subst x + rw [ite_eq_left (le_refl a)] + have hl : HasDerivWithinAt (fun t => if t ≤ a then f t else g t) + (df a) (Iic a) a := + (hf a).hasDerivWithinAt.congr_of_mem + (fun t ht => ite_eq_left ht) (le_refl a) + have hr : HasDerivWithinAt (fun t => if t ≤ a then f t else g t) + (df a) (Ici a) a := by + rw [hderiv] + apply (hg a).hasDerivWithinAt.congr_of_mem _ (le_refl a) + intro t ht + by_cases hta : t ≤ a + · have he : t = a := le_antisymm hta ht + subst t + simpa only [ite_eq_left (le_refl a)] using hvalue + · exact ite_eq_right hta + have h := hl.union hr + simpa only [Iic_union_Ici, hasDerivWithinAt_univ] using h + · rw [ite_eq_right (not_le.mpr hx)] + apply (hg x).congr_of_eventuallyEq + filter_upwards [Ioi_mem_nhds hx] with t ht + exact ite_eq_right (not_le.mpr ht) + +private theorem contDiff_two_wellSplice (f g : ℝ → ℝ) (a : ℝ) + (hf : ContDiff ℝ 2 f) (hg : ContDiff ℝ 2 g) + (hvalue : f a = g a) (hfirst : deriv f a = deriv g a) + (hsecond : deriv (deriv f) a = deriv (deriv g) a) : + ContDiff ℝ 2 (fun t => if t ≤ a then f t else g t) := by + have hdf : ContDiff ℝ 1 (deriv f) := hf.deriv' + have hdg : ContDiff ℝ 1 (deriv g) := hg.deriv' + have hd := hasDerivAt_wellSplice f g (deriv f) (deriv g) a + (fun x => (hf.differentiable (by norm_num) x).hasDerivAt) + (fun x => (hg.differentiable (by norm_num) x).hasDerivAt) hvalue hfirst + have hd' := hasDerivAt_wellSplice (deriv f) (deriv g) + (deriv (deriv f)) (deriv (deriv g)) a + (fun x => (hdf.differentiable (by norm_num) x).hasDerivAt) + (fun x => (hdg.differentiable (by norm_num) x).hasDerivAt) hfirst hsecond + have heq : deriv (fun t => if t ≤ a then f t else g t) = + fun t => if t ≤ a then deriv f t else deriv g t := by + funext t + exact (hd t).deriv + have heq' : deriv (fun t => if t ≤ a then deriv f t else deriv g t) = + fun t => if t ≤ a then deriv (deriv f) t else deriv (deriv g) t := by + funext t + exact (hd' t).deriv + rw [show (2 : ℕ∞ω) = 1 + 1 from rfl, contDiff_succ_iff_deriv] + refine ⟨fun x => (hd x).differentiableAt, by simp, ?_⟩ + rw [heq, contDiff_one_iff_deriv, heq'] + refine ⟨fun x => (hd' x).differentiableAt, ?_⟩ + exact (hdf.continuous_deriv (by norm_num)).if_le + (hdg.continuous_deriv (by norm_num)) continuous_id continuous_const + (fun x hx => by simpa only [hx] using hsecond) + +private def wellMiddle (t : ℝ) := wellTransition (16 * t - 1) +private def wellMiddlePrime (t : ℝ) := 480 * (16 * t - 1) ^ 2 * (16 * t - 2) ^ 2 +private def wellMiddleSecond (t : ℝ) := + 15360 * (16 * t - 1) * (16 * t - 2) * (32 * t - 3) + +private theorem wellMiddle_hasDerivAt (t : ℝ) : + HasDerivAt wellMiddle (wellMiddlePrime t) t := by + have hlin := ((hasDerivAt_id t).const_mul 16).sub_const 1 + convert (((hlin.pow 5).const_mul 6).sub ((hlin.pow 4).const_mul 15)).add + ((hlin.pow 3).const_mul 10) using 1 <;> (try funext y) <;> + (dsimp [wellMiddle, wellTransition, wellMiddlePrime]; all_goals ring) + +private theorem wellMiddlePrime_hasDerivAt (t : ℝ) : + HasDerivAt wellMiddlePrime (wellMiddleSecond t) t := by + have hlin := ((hasDerivAt_id t).const_mul 16).sub_const 1 + have hlin' := ((hasDerivAt_id t).const_mul 16).sub_const 2 + convert ((hlin.pow 2).const_mul 480).mul (hlin'.pow 2) using 1 <;> (try funext y) <;> + (dsimp [wellMiddlePrime, wellMiddleSecond]; all_goals ring) + +private theorem deriv_wellMiddle : deriv wellMiddle = wellMiddlePrime := by + funext t + exact (wellMiddle_hasDerivAt t).deriv + +private theorem deriv2_wellMiddle : deriv (deriv wellMiddle) = wellMiddleSecond := by + rw [deriv_wellMiddle] + funext t + exact (wellMiddlePrime_hasDerivAt t).deriv + +/-- All cap data are rational polynomials; both derivatives match the constant +pieces at the endpoints of the transition interval. -/ +theorem wellCap_contDiff_two : ContDiff ℝ 2 wellCap := by + have hmiddle : ContDiff ℝ 2 wellMiddle := by + unfold wellMiddle wellTransition + fun_prop + let upper : ℝ → ℝ := fun t => if t ≤ 1 / 8 then wellMiddle t else 1 + have hupper : ContDiff ℝ 2 upper := by + apply contDiff_two_wellSplice wellMiddle (fun _ => 1) (1 / 8) hmiddle contDiff_const + · norm_num [wellMiddle, wellTransition] + · rw [deriv_wellMiddle] + norm_num [wellMiddlePrime] + · rw [deriv2_wellMiddle] + norm_num [wellMiddleSecond] + have hlocal : upper =ᶠ[𝓝 (1 / 16 : ℝ)] wellMiddle := by + filter_upwards [Iio_mem_nhds (by norm_num : (1 / 16 : ℝ) < 1 / 8)] with t ht + exact ite_eq_left ht.le + have hcap : ContDiff ℝ 2 (fun t => if t ≤ 1 / 16 then 0 else upper t) := by + apply contDiff_two_wellSplice (fun _ => 0) upper (1 / 16) contDiff_const hupper + · norm_num [upper, wellMiddle, wellTransition] + · rw [hlocal.deriv_eq, deriv_wellMiddle] + norm_num [wellMiddlePrime] + · rw [hlocal.deriv.deriv_eq, deriv2_wellMiddle] + norm_num [wellMiddleSecond] + convert hcap using 1 + funext t + unfold wellCap upper + by_cases h0 : t ≤ 1 / 16 + · simp only [ite_eq_left h0] + · simp only [ite_eq_right h0] + by_cases h1 : 1 / 8 ≤ t + · rw [ite_eq_left h1] + by_cases ht : t ≤ 1 / 8 + · have he : t = 1 / 8 := le_antisymm ht h1 + subst t + norm_num [wellMiddle, wellTransition] + · exact (ite_eq_right ht).symm + · have ht : t ≤ 1 / 8 := (lt_of_not_ge h1).le + simp only [ite_eq_right h1, ite_eq_left ht, wellMiddle] + +/-- Despite the two Coulomb poles, the capped field is globally C². The proof +uses actual vanishing neighbourhoods at the poles and ordinary differentiation +away from them. -/ +theorem cappedSitePotential_contDiff_two {D q q' : ℝ} (hD : 128 ≤ D) + (center displacement : Position) (hdisp : ‖displacement‖ ≤ 4) : + ContDiff ℝ 2 (cappedSitePotential D q q' center displacement) := by + have hD0 : 0 < D := by linarith + apply contDiff_iff_contDiffAt.mpr + intro x + by_cases hprimary : x = center + · subst x + apply contDiffAt_const.congr_of_eventuallyEq + filter_upwards [Metric.ball_mem_nhds center (by positivity : 0 < D / 16)] with y hy + exact cappedSitePotential_zero_near_primary hD0 center displacement y + (by simpa only [dist_eq_norm] using (Metric.mem_ball.mp hy).le) + by_cases hsecondary : x = center + displacement + · subst x + apply contDiffAt_const.congr_of_eventuallyEq + filter_upwards [Metric.ball_mem_nhds (center + displacement) + (by positivity : 0 < D / 32)] with y hy + apply cappedSitePotential_zero_near_secondary hD center displacement y hdisp + have he : y - center - displacement = y - (center + displacement) := by abel + rw [he] + exact (Metric.mem_ball.mp hy).le + have hp : x - center ≠ 0 := sub_ne_zero.mpr hprimary + have hs : x - center - displacement ≠ 0 := by + intro h + apply hsecondary + have he : x - center - displacement = x - (center + displacement) := by abel + exact sub_eq_zero.mp (he.symm.trans h) + have hnorm : ContDiffAt ℝ 2 (fun y : Position => ‖y - center‖) x := + (contDiffAt_id.sub contDiffAt_const).norm ℝ hp + have hnorm' : ContDiffAt ℝ 2 (fun y : Position => ‖y - center - displacement‖) x := + ((contDiffAt_id.sub contDiffAt_const).sub contDiffAt_const).norm ℝ hs + have hcap : ContDiffAt ℝ 2 (fun y : Position => wellCap (‖y - center‖ / D)) x := + wellCap_contDiff_two.contDiffAt.comp x (hnorm.div_const D) + exact hcap.mul ((contDiffAt_const.mul (hnorm.inv (norm_ne_zero_iff.mpr hp))).add + (contDiffAt_const.mul (hnorm'.inv (norm_ne_zero_iff.mpr hs)))) + +theorem backgroundPotential_contDiff_two {m : ℕ} {D q q' : ℝ} (hD : 128 ≤ D) + (center displacement : Fin m → Position) (hdisp : ∀ j, ‖displacement j‖ ≤ 4) + (site : Fin m) : ContDiff ℝ 2 (backgroundPotential D q q' center displacement site) := by + apply ContDiff.sum + intro j _ + by_cases hj : j = site + · simp only [ite_eq_left hj] + exact contDiff_const + · simp only [ite_eq_right hj] + exact cappedSitePotential_contDiff_two hD _ _ (hdisp j) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCover.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..962d0811d2e7cbc55d79404fe0f39db3529de05c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellCover.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CubeGeometry + +namespace OAI + +/-! A cover of the actual well support by boxes whose total volume is +linear in the number of wells and the vertical cutoff radius. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +def wellCoverBox (u : PlanarPosition) (r S : ℝ) : Set Position := + WithLp.ofLp ⁻¹' Set.Icc ![u 0-r,u 1-r,-S] ![u 0+r,u 1+r,S] + +theorem mem_wellCoverBox {u : PlanarPosition} {r S : ℝ} {x : Position} : + x ∈ wellCoverBox u r S ↔ |x 0-u 0| ≤ r ∧ |x 1-u 1| ≤ r ∧ |x 2| ≤ S := by + constructor + · rintro ⟨hl,hu⟩ + have h0l := hl 0; have h0u := hu 0 + have h1l := hl 1; have h1u := hu 1 + have h2l := hl 2; have h2u := hu 2 + simp only [Matrix.cons_val_zero,Matrix.cons_val_one,Matrix.cons_val] at * + exact ⟨abs_le.mpr ⟨by linarith,by linarith⟩, + abs_le.mpr ⟨by linarith,by linarith⟩,abs_le.mpr ⟨h2l,h2u⟩⟩ + · rintro ⟨h0,h1,h2⟩ + obtain ⟨h0l,h0u⟩ := abs_le.mp h0 + obtain ⟨h1l,h1u⟩ := abs_le.mp h1 + obtain ⟨h2l,h2u⟩ := abs_le.mp h2 + constructor <;> intro i <;> fin_cases i <;> simp <;> linarith + +theorem wellCoverBox_isClosed (u : PlanarPosition) (r S : ℝ) : + IsClosed (wellCoverBox u r S) := + isClosed_Icc.preimage (PiLp.continuous_ofLp 2 (fun _ : Fin 3 => ℝ)) + +theorem wellCoverBox_measure_ne_top (u : PlanarPosition) (r S : ℝ) : + volume (wellCoverBox u r S) ≠ ⊤ := by + unfold wellCoverBox + rw [(PiLp.volume_preserving_ofLp (Fin 3)).measure_preimage measurableSet_Icc.nullMeasurableSet] + exact isCompact_Icc.measure_ne_top + +theorem wellCoverBox_volume (u : PlanarPosition) {r S : ℝ} (hr : 0 ≤ r) (hS : 0 ≤ S) : + volume.real (wellCoverBox u r S) = 8*r^2*S := by + unfold wellCoverBox Measure.real + rw [(PiLp.volume_preserving_ofLp (Fin 3)).measure_preimage measurableSet_Icc.nullMeasurableSet] + rw [Real.volume_Icc_pi_toReal (by intro i; fin_cases i <;> simp <;> linarith)] + simp [Fin.prod_univ_succ] + ring + +theorem manufacturedWellField_support_cover (freq scale : ℝ) {S : ℝ} (hS : 0 < S) + {m : ℕ} (u : Fin m → PlanarPosition) : + tsupport (manufacturedWellField freq scale S u) ⊆ ⋃ i, wellCoverBox (u i) 1 S := by + apply closure_minimal _ (isClosed_iUnion_of_finite (fun i => wellCoverBox_isClosed (u i) 1 S)) + intro x hx + have hz : |(positionSplitCoordinates x).2| < S := by + by_contra hn + exact hx (manufacturedWellField_outer freq scale hS u x (le_of_not_gt hn)) + have hnear : ∃ i, ‖(positionSplitCoordinates x).1-u i‖ < 1 := by + by_contra hn + apply hx + unfold manufacturedWellField + rw [countertermWellSum_zero_far freq scale u _ (fun i => + le_of_not_gt (fun hi => hn ⟨i,hi⟩)),mul_zero] + obtain ⟨i,hi⟩ := hnear + apply Set.mem_iUnion.mpr + refine ⟨i,mem_wellCoverBox.mpr ⟨?_,?_,?_⟩⟩ + · simpa only [Real.norm_eq_abs,PiLp.sub_apply,positionSplitCoordinates_fst_zero] using + (PiLp.norm_apply_le ((positionSplitCoordinates x).1-u i) 0).trans hi.le + · simpa only [Real.norm_eq_abs,PiLp.sub_apply,positionSplitCoordinates_fst_one] using + (PiLp.norm_apply_le ((positionSplitCoordinates x).1-u i) 1).trans hi.le + · simpa only [positionSplitCoordinates_snd] using hz.le + +theorem wellCover_volume_bound {m : ℕ} (u : Fin m → PlanarPosition) + {r S : ℝ} (hr : 0 ≤ r) (hS : 0 ≤ S) : + volume.real (⋃ i, wellCoverBox (u i) r S) ≤ 8*m*r^2*S := by + apply (measureReal_iUnion_fintype_le (fun i => wellCoverBox (u i) r S)).trans + simp only [wellCoverBox_volume _ hr hS,Finset.sum_const,Finset.card_univ, + Fintype.card_fin,nsmul_eq_mul] + apply le_of_eq + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellFieldOrbitalResidual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellFieldOrbitalResidual.lean new file mode 100644 index 0000000000000000000000000000000000000000..edc8236ecac928795efb95f7c1bccdb5102c723b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/OneParticle/WellFieldOrbitalResidual.lean @@ -0,0 +1,154 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedMomentTail +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField + +namespace OAI + +/-! The cutoff and depth-counterterm contribution to the actual localized +one-particle residual. The estimate uses polynomially many spatial modes. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators +namespace ContinuumCoulomb + +theorem planarWellSum_abs_bound {m : ℕ} (u : Fin m → PlanarPosition) (r : PlanarPosition) : + |planarWellSum u r| ≤ (m : ℝ)*PlanarSobolev.wellBound := by + unfold planarWellSum + calc + _ ≤ ∑ i, |manufacturedPlanarWell (r-u i)| := Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : Fin m, PlanarSobolev.wellBound := Finset.sum_le_sum (fun i _ => by + simpa only [Real.norm_eq_abs] using PlanarSobolev.wellBound_spec (r-u i)) + _ = _ := by simp + +theorem countertermWellSum_sub_eq (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (r : PlanarPosition) : + countertermWellSum freq scale u r-planarWellSum u r = + ∑ i, (localizedCounterterm freq u i/scale)*manufacturedPlanarWell (r-u i) := by + unfold countertermWellSum planarWellSum + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro i _ + ring + +theorem countertermWellSum_sub_abs_bound (freq scale : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) {δ : ℝ} + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (r : PlanarPosition) : + |countertermWellSum freq scale u r-planarWellSum u r| ≤ + (m : ℝ)*δ*PlanarSobolev.wellBound := by + rw [countertermWellSum_sub_eq] + calc + _ ≤ ∑ i, |(localizedCounterterm freq u i/scale)*manufacturedPlanarWell (r-u i)| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : Fin m, δ*PlanarSobolev.wellBound := by + apply Finset.sum_le_sum + intro i _ + rw [abs_mul, abs_of_nonneg (hcoeff i).1] + exact mul_le_mul (hcoeff i).2 (by + simpa only [Real.norm_eq_abs] using PlanarSobolev.wellBound_spec (r-u i)) + (abs_nonneg _) ((hcoeff i).1.trans (hcoeff i).2) + _ = _ := by simp [mul_assoc] + +theorem manufacturedWellField_sub_abs_bound (freq scale S : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) {δ : ℝ} (_hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (x : Position) : + |manufacturedWellField freq scale S u x-planarWellSum u (positionSplitCoordinates x).1| ≤ + (m : ℝ)*(δ+1)*PlanarSobolev.wellBound := by + let t := slabWellCutoff S (positionSplitCoordinates x).2 + let a := countertermWellSum freq scale u (positionSplitCoordinates x).1 + let b := planarWellSum u (positionSplitCoordinates x).1 + have ht : 0 ≤ t ∧ t ≤ 1 := slabWellCutoff_bounds _ _ + have hdiff := countertermWellSum_sub_abs_bound freq scale u hcoeff (positionSplitCoordinates x).1 + have hb := planarWellSum_abs_bound u (positionSplitCoordinates x).1 + have h1 : |t-1| ≤ 1 := by rw [abs_of_nonpos (by linarith : t-1 ≤ 0)]; linarith + have he : t*a-b = t*(a-b)+(t-1)*b := by ring + change |t*a-b| ≤ _ + rw [he] + calc + _ ≤ |t*(a-b)|+|(t-1)*b| := abs_add_le _ _ + _ ≤ (m : ℝ)*δ*PlanarSobolev.wellBound+(m : ℝ)*PlanarSobolev.wellBound := by + rw [abs_mul, abs_mul, abs_of_nonneg ht.1] + exact add_le_add + ((mul_le_mul_of_nonneg_right ht.2 (abs_nonneg _)).trans (by simpa only [one_mul] using hdiff)) + ((mul_le_mul_of_nonneg_right h1 (abs_nonneg _)).trans (by simpa only [one_mul] using hb)) + _ = _ := by ring + +def wellFieldOrbitalResidual (freq scale S : ℝ) {m : ℕ} + (u : Fin m → PlanarPosition) (j : Fin m) (x : Position) : ℝ := + (manufacturedWellField freq scale S u x-planarWellSum u (positionSplitCoordinates x).1)* + continuumLocalizedMode freq (u j) x + +theorem wellFieldOrbitalResidual_square_integrable {freq : ℝ} (hfreq : 0 < freq) + (scale S : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + Integrable (fun x => wellFieldOrbitalResidual freq scale S u j x^2) := by + have hm : MemLp (wellFieldOrbitalResidual freq scale S u j) 2 := by + apply (continuumLocalizedMode_memLp hfreq (u j)).of_le_mul + (c := (m : ℝ)*(δ+1)*PlanarSobolev.wellBound) + ((((manufacturedWellField_C7 freq scale S u).continuous.sub + ((planarWellSum_continuous u).comp positionSplitCoordinates.continuous.fst)).mul + (continuumLocalizedMode_C7 freq (u j)).continuous).aestronglyMeasurable) + filter_upwards [] with x + change ‖(manufacturedWellField freq scale S u x-planarWellSum u (positionSplitCoordinates x).1)* + continuumLocalizedMode freq (u j) x‖ ≤ _ + rw [norm_mul, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (manufacturedWellField_sub_abs_bound freq scale S u hδ hcoeff x) + (norm_nonneg _) + exact hm.integrable_sq + +theorem wellFieldOrbitalResidual_square_bound {freq S : ℝ} (hfreq : 0 < freq) + (hS : 0 < S) (scale : ℝ) {m : ℕ} (u : Fin m → PlanarPosition) + {δ : ℝ} (hδ : 0 ≤ δ) + (hcoeff : ∀ i, 0 ≤ localizedCounterterm freq u i/scale ∧ + localizedCounterterm freq u i/scale ≤ δ) (j : Fin m) : + (∫ x, wellFieldOrbitalResidual freq scale S u j x^2) ≤ + ((m : ℝ)*δ*PlanarSobolev.wellBound)^2+ + ((m : ℝ)*(δ+1)*PlanarSobolev.wellBound)^2* + (localizedDensityMoment freq (u j) 8/(S/2)^8) := by + let K := Metric.closedBall (0 : Position) (S/2) + let A := (m : ℝ)*δ*PlanarSobolev.wellBound + let B := (m : ℝ)*(δ+1)*PlanarSobolev.wellBound + have hK : MeasurableSet K := Metric.isClosed_closedBall.measurableSet + have hA : 0 ≤ A := mul_nonneg (mul_nonneg (Nat.cast_nonneg m) hδ) PlanarSobolev.wellBound_nonnegative + have hB : 0 ≤ B := mul_nonneg (mul_nonneg (Nat.cast_nonneg m) (by linarith)) PlanarSobolev.wellBound_nonnegative + have hi := wellFieldOrbitalResidual_square_integrable hfreq scale S u hδ hcoeff j + have hd := localizedDensity_integrable hfreq (u j) + have hp (x : Position) (hx : x ∈ K) : wellFieldOrbitalResidual freq scale S u j x^2 ≤ + A^2*localizedDensity freq (u j) x := by + have hxnorm : ‖x‖ ≤ S/2 := by simpa only [K, Metric.mem_closedBall, dist_zero_right] using hx + have hz : |(positionSplitCoordinates x).2| ≤ S/2 := by + simpa only [positionSplitCoordinates_snd, Real.norm_eq_abs] using + (PiLp.norm_apply_le x 2).trans hxnorm + have hb := countertermWellSum_sub_abs_bound freq scale u hcoeff (positionSplitCoordinates x).1 + rw [← manufacturedWellField_inner freq scale hS u x hz] at hb + have h := mul_le_mul_of_nonneg_right ((sq_le_sq₀ (abs_nonneg _) hA).mpr hb) + (localizedDensity_nonnegative freq (u j) x) + simpa only [wellFieldOrbitalResidual, localizedDensity, mul_pow, sq_abs] using h + have hq (x : Position) : wellFieldOrbitalResidual freq scale S u j x^2 ≤ + B^2*localizedDensity freq (u j) x := by + have hb := manufacturedWellField_sub_abs_bound freq scale S u hδ hcoeff x + have h := mul_le_mul_of_nonneg_right ((sq_le_sq₀ (abs_nonneg _) hB).mpr hb) + (localizedDensity_nonnegative freq (u j) x) + simpa only [wellFieldOrbitalResidual, localizedDensity, mul_pow, sq_abs] using h + have hin := setIntegral_mono_on hi.integrableOn (hd.const_mul (A^2)).integrableOn hK hp + have hout := setIntegral_mono_on hi.integrableOn (hd.const_mul (B^2)).integrableOn hK.compl + (fun x _ => hq x) + rw [integral_const_mul] at hin hout + have hmass : (∫ x in K, localizedDensity freq (u j) x) ≤ 1 := by + rw [← localizedDensity_mass hfreq (u j)] + exact integral_mono_measure Measure.restrict_le_self + (Filter.Eventually.of_forall (localizedDensity_nonnegative freq (u j))) hd + have htail := localizedDensity_mass_tail_eighth hfreq (half_pos hS) (u j) hK + (fun x hx => (lt_of_not_ge (by simpa only [K, Metric.mem_closedBall, dist_zero_right] using hx)).le) + have h := add_le_add (hin.trans (mul_le_mul_of_nonneg_left hmass (sq_nonneg A))) + (hout.trans (mul_le_mul_of_nonneg_left htail (sq_nonneg B))) + rw [integral_add_compl hK hi] at h + simpa only [mul_one, A, B] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs.lean new file mode 100644 index 0000000000000000000000000000000000000000..52e8135b59e2e96e611cba42860bf7e99420ff9e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AffinePhysicalThresholdProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AmplificationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AutomaticCalibrationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionRegisters +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedBisectionProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedContactProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedEvaluationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibrationRationalBracketProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CappedKernelProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredGaussProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredNuclearProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredPhysicalThresholdProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ChargePrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactCanonicalEdgeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactEdgeNumberProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactGeometryBlockProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactHeightProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactHeightScheduleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactLocalInputProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactPlacedGadgetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactRationalGadgetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactRationalPlaceProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactSourceInputProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactVertexProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombEvaluationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombNormalizationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombPairProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombPairSumProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CountertermProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.DyadicRootProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EncodingPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EnumeratedGridNuclei +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EulerProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EulerVectorPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.FiniteDifferenceProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussNodeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianFrequencyProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianPacketProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.HoppingProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ManufacturedFieldProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ManufacturedVelocityProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorListProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorOffsetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorThreeStageProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorUnaryProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MoserCoordinateProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MoserDifferenceProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.NormalizationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PhysicalNuclearProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PhysicalThresholdProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PiProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PlanarForcingProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PlanarWellProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialHoppingSmallness +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialResidualBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialTimeSize +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialUnaryBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefactorCalibrationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefactorSourceContactProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefixListPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefixPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ProgramGroundIdentity +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalExponentialProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalLogScaleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalQuadratureProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalRectangleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombMassBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombSample +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombSampleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensityModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensitySample +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensitySampleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SlabBoxProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SlabOriginProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SmoothTransitionProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceBranchProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceContactProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceMetadataProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceNormalizationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceNuclearProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePositiveProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SquareRootProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.TransformedGaussProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.UnitBinaryProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.UnitCoulombProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.VerticalCutoffProgram diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AffinePhysicalThresholdProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AffinePhysicalThresholdProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..9115cd6fa93ede54bd7e23e5d61af827cd4b8553 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AffinePhysicalThresholdProgram.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.AffinePhysicalThreshold + +namespace OAI + +/-! Literal polynomial-time evaluation of the complete affine threshold shift. +Every precision and loop bound is computed in unary from polynomial metadata. -/ + +namespace ContinuumCoulomb.AffinePhysicalThreshold +open ExactQuantumFactoring.BitStackProgram + +def dataCode : (ℚ×(List CoulombPairSum.Point×List ℚ)) → List Bool := + prodCode ratCode (prodCode (listCode CoulombPairSum.pointCode) (listCode ratCode)) +def inputCode : Input → List Bool := prodCode CenteredPhysicalThreshold.inputCode dataCode + +noncomputable opaque numbersProgram : Procedure inputCode CenteredPhysicalThreshold.inputCode Prod.fst := + Procedure.first _ _ +noncomputable opaque dataProgram : Procedure inputCode dataCode Prod.snd := Procedure.second _ _ +noncomputable opaque tauProgram : Procedure inputCode ratCode (fun x => x.2.1) := + (Procedure.first _ _).comp dataProgram +noncomputable opaque listsProgram : Procedure inputCode + (prodCode (listCode CoulombPairSum.pointCode) (listCode ratCode)) (fun x => x.2.2) := + (Procedure.second _ _).comp dataProgram +noncomputable opaque sitesProgram : Procedure inputCode (listCode CoulombPairSum.pointCode) + (fun x => x.2.2.1) := (Procedure.first _ _).comp listsProgram +noncomputable opaque weightsProgram : Procedure inputCode (listCode ratCode) + (fun x => x.2.2.2) := (Procedure.second _ _).comp listsProgram +noncomputable opaque errorProgram : Procedure inputCode unaryCode (fun x => x.1.2.2.1) := + CenteredPhysicalThreshold.errorProgram.comp numbersProgram +noncomputable opaque geometryProgram : Procedure inputCode CenteredPhysicalThreshold.geometryCode + (fun x => x.1.1) := CenteredPhysicalThreshold.geometryProgram.comp numbersProgram +noncomputable opaque electronsProgram : Procedure inputCode unaryCode (fun x => x.1.2.1) := + CenteredPhysicalThreshold.electronsProgram.comp numbersProgram +noncomputable opaque precisionProgram : Procedure inputCode unaryCode + (fun x => 2*(x.1.2.2.1+1)) := + ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 2).pair + (Procedure.unarySuccessor.comp errorProgram)) + +noncomputable opaque pairPrecisionProgram : Procedure inputCode unaryCode pairPrecision := by + let cube := CenteredPhysicalThreshold.meshCubeProgram.comp numbersProgram + let base := Procedure.unarySuccessor.comp (ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 8).pair cube)) + exact (ResolventSchedule.mulProgram.comp (base.pair precisionProgram)).congrFun + (by intro x; rfl) + +noncomputable opaque pairProgram (rho : ℕ) : Procedure inputCode ratCode (pairValue rho) := + (CoulombPairSum.program rho).comp (pairPrecisionProgram.pair sitesProgram) + +noncomputable opaque finiteProgram (rho : ℕ) : Procedure inputCode (prodCode ratCode ratCode) + (finiteValue rho) := by + let bounds := CenteredPhysicalThreshold.endpointsProgram.comp numbersProgram + let lower := (Procedure.first ratCode ratCode).comp bounds + let upper := (Procedure.second ratCode ratCode).comp bounds + let sum := RationalSumProgram.sumProgram.comp weightsProgram + let tauSquared := Procedure.ratMul.comp (tauProgram.pair tauProgram) + let lowerShift := Procedure.ratSub.comp (lower.pair sum) + let upperShift := Procedure.ratSub.comp (upper.pair sum) + let lowerScale := Procedure.ratMul.comp (tauSquared.pair lowerShift) + let upperScale := Procedure.ratMul.comp (tauSquared.pair upperShift) + exact ((Procedure.ratSub.comp (lowerScale.pair (pairProgram rho))).pair + (Procedure.ratSub.comp (upperScale.pair (pairProgram rho)))).congrFun + (by intro x; simp only [finiteValue,pow_two,Function.comp_apply]) + +noncomputable opaque argumentProgram (rho : ℕ) : + Procedure inputCode CenteredPhysicalThreshold.inputCode (argument rho) := + geometryProgram.pair (electronsProgram.pair (precisionProgram.pair (finiteProgram rho))) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode (prodCode ratCode ratCode) (value rho) := + (CenteredPhysicalThreshold.program rho).comp (argumentProgram rho) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime inputCode (prodCode ratCode ratCode) (value rho) := + (program rho).toTM2 + +end ContinuumCoulomb.AffinePhysicalThreshold + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AmplificationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AmplificationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d1b8c26cb0fd9081040874d22324c53bee35ec2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AmplificationProgram.lean @@ -0,0 +1,278 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableAmplification +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.BinaryEncoding +import OAI.Computability.QuantumFactoring.BitStackUnary +import OAI.Computability.QuantumFactoring.BitStackDivision + +namespace OAI + +/-! A binary stack-machine implementation of the exact rational Taylor +amplification used for the binary nuclear charges. The input parameter D is +unary; the large output and every arithmetic register are binary. -/ + +namespace ContinuumCoulomb.AmplificationProgram +open ExactQuantumFactoring.BitStackProgram +open scoped BigOperators + +abbrev State := ℕ × (ℕ × (ℕ × (ℕ × ℕ))) + +def stateCode : State → List Bool := prodCode Nat.bits + (prodCode Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))) + +def step (s : State) : State := + (s.1, s.2.1 + 1, (s.2.1 + 1) * (s.2.2.1 + s.2.2.2.2), + (s.2.1 + 1) * s.2.2.2.1, s.1 * s.2.2.2.2) + +def start (D : ℕ) : State := (D, 0, 0, 1, 1) + +def partialTaylor (D n : ℕ) : ℚ := ∑ j ∈ Finset.range n, (D : ℚ) ^ j / (j.factorial : ℚ) + +/-- Scaled numerator, factorial denominator and power are maintained by +literal natural-number additions and multiplications. -/ +theorem iterate_start (D n : ℕ) : + ((step^[n]) (start D)).1 = D ∧ + ((step^[n]) (start D)).2.1 = n ∧ + (((step^[n]) (start D)).2.2.1 : ℚ) = (n.factorial : ℚ) * partialTaylor D n ∧ + ((step^[n]) (start D)).2.2.2.1 = n.factorial ∧ + ((step^[n]) (start D)).2.2.2.2 = D ^ n := by + induction n with + | zero => simp [start, partialTaylor] + | succ n ih => + rw [Function.iterate_succ_apply'] + rcases ih with ⟨hD, hk, hA, hF, hP⟩ + refine ⟨hD, ?_, ?_, ?_, ?_⟩ + · change ((step^[n]) (start D)).2.1 + 1 = n + 1 + rw [hk] + · change (((((step^[n]) (start D)).2.1 + 1) * + (((step^[n]) (start D)).2.2.1 + ((step^[n]) (start D)).2.2.2.2) : ℕ) : ℚ) = _ + rw [hk, hP] + simp only [Nat.cast_mul, Nat.cast_add, Nat.cast_one, hA, partialTaylor, + Finset.sum_range_succ, Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, + Nat.cast_pow] + have hfac : (n.factorial : ℚ) ≠ 0 := by positivity + field_simp + · change (((step^[n]) (start D)).2.1 + 1) * ((step^[n]) (start D)).2.2.2.1 = + (n + 1).factorial + rw [hk, hF, Nat.factorial_succ] + · change ((step^[n]) (start D)).1 * ((step^[n]) (start D)).2.2.2.2 = D ^ (n + 1) + rw [hD, hP, pow_succ, Nat.mul_comm] + +/-- Natural ceiling of a nonnegative rational quotient is computed with +addition, subtraction by one, and ordinary natural division. -/ +theorem ceil_nat_ratio (A F : ℕ) (hF : 0 < F) : + Nat.ceil ((A : ℚ) / F) = (A + F - 1) / F := by + change Nat.ceil ((A : ℚ) / F) = A ⌈/⌉ F + have hFq : (0 : ℚ) < F := by exact_mod_cast hF + apply le_antisymm + · apply Nat.ceil_le.mpr + apply (div_le_iff₀ hFq).mpr + have hmul : A ≤ (A ⌈/⌉ F) * F := by + exact Nat.mul_comm F (A ⌈/⌉ F) ▸ + ((ceilDiv_le_iff_le_mul hF).mp (le_refl (A ⌈/⌉ F))) + exact_mod_cast hmul + · apply (ceilDiv_le_iff_le_mul hF).mpr + have h := (div_le_iff₀ hFq).mp (Nat.le_ceil ((A : ℚ) / F)) + have hmul : A ≤ Nat.ceil ((A : ℚ) / F) * F := by exact_mod_cast h + simpa only [Nat.mul_comm] using hmul + +def result (s : State) : ℕ := (s.2.2.1 + s.2.2.2.1 - 1) / s.2.2.2.1 + +theorem result_correct (D : ℕ) : + result ((step^[amplificationOrder D]) (start D)) = taylorAmplification D := by + let n := amplificationOrder D + rcases iterate_start D n with ⟨_, _, hA, hF, _⟩ + have hFq : (n.factorial : ℚ) ≠ 0 := by positivity + have hratio : (((step^[n]) (start D)).2.2.1 : ℚ) / ((step^[n]) (start D)).2.2.2.1 = + amplificationTaylor D := by + rw [hF, hA, mul_div_cancel_left₀ _ hFq] + rfl + change result ((step^[n]) (start D)) = Nat.ceil (amplificationTaylor D) + rw [← hratio] + exact (ceil_nat_ratio _ _ (by rw [hF]; exact Nat.factorial_pos n)).symm + +/-- Addition costs at most one more bit than the larger input. -/ +theorem bits_add_max (a b : ℕ) : + (a + b).bits.length ≤ max a.bits.length b.bits.length + 1 := by + simp only [Nat.size_eq_bits_len] + rw [Nat.size_le, pow_succ] + have ha := Nat.lt_size_self a + have hb := Nat.lt_size_self b + have hap : 2 ^ a.size ≤ 2 ^ max a.size b.size := by + apply Nat.pow_le_pow_right (by decide) + exact le_max_left a.size b.size + have hbp : 2 ^ b.size ≤ 2 ^ max a.size b.size := by + apply Nat.pow_le_pow_right (by decide) + exact le_max_right a.size b.size + omega + +theorem bits_succ (a : ℕ) : (a + 1).bits.length ≤ a.bits.length + 1 := by + simp only [Nat.size_eq_bits_len] + rw [Nat.size_le, pow_succ] + have ha := Nat.lt_size_self a + have hp : 0 < 2 ^ a.size := by positivity + omega + +def measure (s : State) : ℕ := s.1.bits.length + s.2.1.bits.length + + max s.2.2.1.bits.length s.2.2.2.2.bits.length + s.2.2.2.1.bits.length + +theorem stateCode_length (s : State) : (stateCode s).length = + 2 * s.1.bits.length + 2 * s.2.1.bits.length + 2 * s.2.2.1.bits.length + + 2 * s.2.2.2.1.bits.length + s.2.2.2.2.bits.length + 4 := by + simp only [stateCode, prodCode, pairBits_length] + omega + +theorem measure_le_code (s : State) : measure s ≤ (stateCode s).length := by + rw [stateCode_length] + unfold measure + have hm : max s.2.2.1.bits.length s.2.2.2.2.bits.length ≤ + s.2.2.1.bits.length + s.2.2.2.2.bits.length := by omega + omega + +theorem code_le_measure (s : State) : (stateCode s).length ≤ 3 * measure s + 4 := by + rw [stateCode_length] + unfold measure + have ha := le_max_left s.2.2.1.bits.length s.2.2.2.2.bits.length + have hp := le_max_right s.2.2.1.bits.length s.2.2.2.2.bits.length + omega + +theorem step_measure (s : State) : + measure (step s) ≤ measure s + s.1.bits.length + 2 * s.2.1.bits.length + 4 := by + have hk := bits_succ s.2.1 + have ha := bits_length_mul (s.2.1 + 1) (s.2.2.1 + s.2.2.2.2) + have has := bits_add_max s.2.2.1 s.2.2.2.2 + have hf := bits_length_mul (s.2.1 + 1) s.2.2.2.1 + have hp := bits_length_mul s.1 s.2.2.2.2 + have hp0 := le_max_right s.2.2.1.bits.length s.2.2.2.2.bits.length + dsimp only [measure, step] + have hm : max ((s.2.1 + 1) * (s.2.2.1 + s.2.2.2.2)).bits.length + (s.1 * s.2.2.2.2).bits.length ≤ + max s.2.2.1.bits.length s.2.2.2.2.bits.length + s.1.bits.length + s.2.1.bits.length + 2 := by + apply max_le <;> omega + omega + +theorem iterate_D (s : State) (i : ℕ) : ((step^[i]) s).1 = s.1 := by + induction i with + | zero => rfl + | succ i ih => rw [Function.iterate_succ_apply']; exact ih + +theorem iterate_index_bits (s : State) (i : ℕ) : + ((step^[i]) s).2.1.bits.length ≤ s.2.1.bits.length + i := by + induction i with + | zero => exact le_rfl + | succ i ih => + rw [Function.iterate_succ_apply'] + change (((step^[i]) s).2.1 + 1).bits.length ≤ _ + have h := bits_succ ((step^[i]) s).2.1 + omega + +theorem iterate_measure (s : State) (i : ℕ) : + measure ((step^[i]) s) ≤ measure s + i * (3 * measure s + i + 4) := by + induction i with + | zero => simp + | succ i ih => + rw [Function.iterate_succ_apply'] + have hstep := step_measure ((step^[i]) s) + rw [iterate_D] at hstep + have hk := iterate_index_bits s i + have hD : s.1.bits.length ≤ measure s := by unfold measure; omega + have hk0 : s.2.1.bits.length ≤ measure s := by unfold measure; omega + nlinarith + +/-- The entire arithmetic state stays polynomial in iteration count and +initial binary input size, including arbitrary initial register contents. -/ +theorem iterate_code_bound (n : ℕ) (s : State) (i : ℕ) (hi : i ≤ n) : + (stateCode ((step^[i]) s)).length ≤ + (16 * (Polynomial.X + 1) ^ 2 + 16 : Polynomial ℕ).eval (n + (stateCode s).length) := by + have hc := code_le_measure ((step^[i]) s) + have hm := iterate_measure s i + have hs := measure_le_code s + have hi2 := Nat.pow_le_pow_left hi 2 + have him := Nat.mul_le_mul hi hs + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one] + nlinarith + +noncomputable def stepProgram : Procedure stateCode stateCode step := by + let d := Procedure.first Nat.bits (prodCode Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))) + let t := Procedure.second Nat.bits (prodCode Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))) + let k := (Procedure.first Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))).comp t + let u := (Procedure.second Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))).comp t + let a := (Procedure.first Nat.bits (prodCode Nat.bits Nat.bits)).comp u + let v := (Procedure.second Nat.bits (prodCode Nat.bits Nat.bits)).comp u + let f := (Procedure.first Nat.bits Nat.bits).comp v + let p := (Procedure.second Nat.bits Nat.bits).comp v + let next := Procedure.successor.comp k + let numerator := Procedure.binaryMul.comp (next.pair (Procedure.binaryAdd.comp (a.pair p))) + let factorial := Procedure.binaryMul.comp (next.pair f) + let power := Procedure.binaryMul.comp (d.pair p) + exact (d.pair (next.pair (numerator.pair (factorial.pair power)))).congrFun (by intro s; rfl) + +noncomputable def repeatProgram : Procedure (prodCode unaryCode stateCode) stateCode + (fun x => (step^[x.1]) x.2) := + stepProgram.iterate (16 * (Polynomial.X + 1) ^ 2 + 16) iterate_code_bound + +noncomputable def orderProgram : Procedure unaryCode unaryCode amplificationOrder := by + let d := Procedure.identity unaryCode + let square := Procedure.unaryMul.comp (d.pair d) + let four := Procedure.constant unaryCode unaryCode 4 + let fourSquare := Procedure.unaryMul.comp (four.pair square) + exact (Procedure.unaryAdd.comp (fourSquare.pair four)).congrFun (by + intro D + change 4 * (D * D) + 4 = amplificationOrder D + unfold amplificationOrder + ring) + +noncomputable def startProgram : Procedure unaryCode stateCode start := by + let d := Procedure.unaryToBits + let zero := Procedure.constant unaryCode Nat.bits 0 + let one := Procedure.constant unaryCode Nat.bits 1 + exact (d.pair (zero.pair (zero.pair (one.pair one)))).congrFun (by intro D; rfl) + +noncomputable def resultProgram : Procedure stateCode Nat.bits result := by + let t := Procedure.second Nat.bits (prodCode Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))) + let u := (Procedure.second Nat.bits (prodCode Nat.bits (prodCode Nat.bits Nat.bits))).comp t + let a := (Procedure.first Nat.bits (prodCode Nat.bits Nat.bits)).comp u + let v := (Procedure.second Nat.bits (prodCode Nat.bits Nat.bits)).comp u + let f := (Procedure.first Nat.bits Nat.bits).comp v + let pred := Procedure.binarySub.comp ((Procedure.binaryAdd.comp (a.pair f)).pair + (Procedure.constant stateCode Nat.bits 1)) + exact (Procedure.binaryDiv.comp (pred.pair f)).congrFun (by intro s; rfl) + +/-- Every step is compiled from actual binary add/multiply/divide routines; +the repetition count is polynomial in the unary input size. -/ +noncomputable def rawProgram : Procedure unaryCode Nat.bits taylorAmplification := + (resultProgram.comp (repeatProgram.comp (orderProgram.pair startProgram))).congrFun result_correct + +theorem encodeUnary_replicate (D : ℕ) : + BinaryEncoding.encodeUnary D = List.replicate D true ++ [false] := by + induction D with + | zero => rfl + | succ D ih => simp only [BinaryEncoding.encodeUnary, List.replicate_succ, List.cons_append, ih] + +theorem encodeDigits_quote (bits : List Bool) : BinaryEncoding.encodeDigits bits = quoteBits bits := by + induction bits with + | nil => rfl + | cons b bs ih => simp only [BinaryEncoding.encodeDigits, quoteBits_cons, ih] + +/-- Strip the false unary terminator with two actual reversals and one pop. -/ +noncomputable def inputProgram : Procedure BinaryEncoding.unary.encode unaryCode id := by + let strip := (Procedure.reverse.comp (Procedure.tail.comp Procedure.reverse)).precompose + BinaryEncoding.unary.encode + exact strip.result (by + intro D + change ((BinaryEncoding.encodeUnary D).reverse.tail).reverse = List.replicate D true + rw [encodeUnary_replicate] + simp) + +/-- Exact amplification with explicit prefix encodings and a finite polynomial-time +machine. -/ +noncomputable def certificate : + Turing.TM2ComputableInPolyTime BinaryEncoding.unary.encode BinaryEncoding.natural.encode + taylorAmplification := by + let quoted := (Procedure.quote Nat.bits).comp rawProgram + let encoded : Procedure unaryCode BinaryEncoding.natural.encode taylorAmplification := + quoted.result (by intro D; exact (encodeDigits_quote (taylorAmplification D).bits).symm) + exact (encoded.comp inputProgram).toTM2 + +end ContinuumCoulomb.AmplificationProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AutomaticCalibrationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AutomaticCalibrationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d18024972a1c0e67f86374324347d25c714bfcd0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/AutomaticCalibrationProgram.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.AutomaticCalibrationParameters + +namespace OAI + +/-! The automatic distance program computes its polynomial query bounds, +scale and inverse-power target from unary source size, then runs the +certified rational-interval calibrated bisection. -/ + +namespace ContinuumCoulomb.AutomaticCalibration +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := prodCode unaryCode (prodCode unaryCode ratCode) + +noncomputable def unaryPowerProgram : (k : ℕ) → Procedure unaryCode unaryCode (fun n => n ^ k) + | 0 => Procedure.constant unaryCode unaryCode 1 + | k + 1 => (ResolventSchedule.mulProgram.comp + ((unaryPowerProgram k).pair (Procedure.identity unaryCode))).congrFun + (by intro n; simp only [Function.comp_apply, id_eq, pow_succ]) + +noncomputable opaque baseProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first unaryCode (prodCode unaryCode ratCode) + +noncomputable opaque tailProgram : Procedure inputCode (prodCode unaryCode ratCode) Prod.snd := + Procedure.second unaryCode (prodCode unaryCode ratCode) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first unaryCode ratCode).comp tailProgram + +noncomputable opaque coefficientProgram : Procedure inputCode ratCode (fun x => x.2.2) := + (Procedure.second unaryCode ratCode).comp tailProgram + +noncomputable opaque scaledSizeProgram (k : ℕ) : Procedure inputCode unaryCode + (fun x => 2 * k * x.1) := (CoulombEvaluation.scaleProgram (2 * k)).comp baseProgram + +noncomputable opaque queryProgram (k A : ℕ) : Procedure inputCode unaryCode + (fun x => queryBound k A x.1) := + Procedure.unarySuccessor.comp (ResolventSchedule.addProgram.comp + ((scaledSizeProgram k).pair ((unaryPowerProgram A).comp baseProgram))) + +noncomputable opaque scaleProgram (k : ℕ) : Procedure inputCode unaryCode + (fun x => x.1 ^ k) := (unaryPowerProgram k).comp baseProgram + +noncomputable opaque targetScaleProgram (B : ℕ) : Procedure inputCode ratCode + (fun x => ((x.1 ^ B : ℕ) : ℚ)⁻¹) := + Procedure.ratInv.comp (Procedure.natToRat.comp + (Procedure.unaryToBits.comp ((unaryPowerProgram B).comp baseProgram))) + +noncomputable opaque environmentProgram (k A B : ℕ) : Procedure inputCode + CalibratedEvaluation.environmentCode (environment k A B) := + ((queryProgram k A).pair precisionProgram).pair + ((scaleProgram k).pair ((targetScaleProgram B).pair coefficientProgram)) + +noncomputable opaque intervalProgram (ε c : ℚ) (k : ℕ) : Procedure inputCode + (prodCode ratCode ratCode) (fun x => interval ε c k x.1) := + (CalibrationRationalBracket.program ε c k).comp baseProgram + +noncomputable opaque argumentProgram (ε c : ℚ) (k A B : ℕ) : Procedure inputCode + CalibratedEvaluation.scheduledInputCode + (fun x => (environment k A B x, interval ε c k x.1)) := + (environmentProgram k A B).pair (intervalProgram ε c k) + +noncomputable opaque program (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : Procedure inputCode ratCode + (value rho ε c k A B) := + ((CalibratedEvaluation.scheduledProgram rho).comp (argumentProgram ε c k A B)).congrFun + (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : + Turing.TM2ComputableInPolyTime inputCode ratCode (value rho ε c k A B) := + (program rho ε c k A B).toTM2 + +end ContinuumCoulomb.AutomaticCalibration + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3b9aa6df18ca72f3866078f3a32b07556e8d5cc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionProgram.lean @@ -0,0 +1,172 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionRegisters +import OAI.Computability.QuantumFactoring.BitStackProcedures + +namespace OAI + +/-! Literal polynomial-time bisection with a supplied polynomial-time +rational evaluator. The evaluator environment and tolerance remain in +the input registers; they are not fixed nonuniform advice. -/ + +namespace ContinuumCoulomb.BisectionProgram +open ExactQuantumFactoring.BitStackProgram +open BisectionRegisters + +abbrev Config (E : Type) := E × (ℚ × Registers) + +def configCode {E : Type} (ce : E → List Bool) : Config E → List Bool := + prodCode ce (prodCode ratCode code) + +def advance {E : Type} (evaluate : E → ℚ → ℚ) (s : Config E) : Config E := + (s.1, (s.2.1, step s.2.1 (evaluate s.1) s.2.2)) + +theorem iterate_config {E : Type} (evaluate : E → ℚ → ℚ) (s : Config E) (n : ℕ) : + (advance evaluate)^[n] s = + (s.1, (s.2.1, (step s.2.1 (evaluate s.1))^[n] s.2.2)) := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply', ih, Function.iterate_succ_apply'] + rfl + +theorem config_length {E : Type} (ce : E → List Bool) (s : Config E) : + (configCode ce s).length = + 2 * (ce s.1).length + 2 * (ratCode s.2.1).length + (code s.2.2).length + 2 := by + simp only [configCode, prodCode, pairBits_length] + omega + +theorem iterate_code_bound {E : Type} (ce : E → List Bool) (evaluate : E → ℚ → ℚ) + (n : ℕ) (s : Config E) (i : ℕ) (hi : i ≤ n) : + (configCode ce ((advance evaluate)^[i] s)).length ≤ + (8 * (Polynomial.X + 1) ^ 2 + 20 : Polynomial ℕ).eval + (n + (configCode ce s).length) := by + rw [iterate_config, config_length] + have hb := iterate_bits s.2.1 (evaluate s.1) s.2.2 i + have hc := code_le_bits ((step s.2.1 (evaluate s.1))^[i] s.2.2) + have hs := bits_le_code s.2.2 + have hlen := config_length ce s + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one] + nlinarith + +noncomputable def rationalLess : Procedure (prodCode ratCode ratCode) + Procedure.boolCode (fun q => decide (q.1 < q.2)) := by + -- `q₁ < q₂` is the negative sign of `q₁-q₂`. + let sub' := Procedure.ratSub + exact (Procedure.intSign.comp (Procedure.ratNum.comp sub')).congrFun (by + intro q + simp only [Function.comp_apply, Rat.num_neg, sub_neg]) + +noncomputable def middleProgram : Procedure code ratCode middle := by + let lo := Procedure.first intCode (prodCode intCode (prodCode Nat.bits Procedure.boolCode)) + let tail := Procedure.second intCode (prodCode intCode (prodCode Nat.bits Procedure.boolCode)) + let hi := (Procedure.first intCode (prodCode Nat.bits Procedure.boolCode)).comp tail + let db := (Procedure.second intCode (prodCode Nat.bits Procedure.boolCode)).comp tail + let den := (Procedure.first Nat.bits Procedure.boolCode).comp db + exact (Procedure.makeRat.comp ((Procedure.intAdd.comp (lo.pair hi)).pair + (Procedure.double.comp den))).congrFun (by intro s; rfl) + +noncomputable def advanceProgram {E : Type} {ce : E → List Bool} + {evaluate : E → ℚ → ℚ} + (evalProgram : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Procedure (configCode ce) (configCode ce) (advance evaluate) := by + let env := Procedure.first ce (prodCode ratCode code) + let tail := Procedure.second ce (prodCode ratCode code) + let tolerance := (Procedure.first ratCode code).comp tail + let regs := (Procedure.second ratCode code).comp tail + let lo := (Procedure.first intCode (prodCode intCode (prodCode Nat.bits Procedure.boolCode))).comp regs + let rest := (Procedure.second intCode (prodCode intCode (prodCode Nat.bits Procedure.boolCode))).comp regs + let hi := (Procedure.first intCode (prodCode Nat.bits Procedure.boolCode)).comp rest + let db := (Procedure.second intCode (prodCode Nat.bits Procedure.boolCode)).comp rest + let den := (Procedure.first Nat.bits Procedure.boolCode).comp db + let settled := (Procedure.second Nat.bits Procedure.boolCode).comp db + let sum := Procedure.intAdd.comp (lo.pair hi) + let two := Procedure.constant (configCode ce) intCode (2 : ℤ) + let twiceLo := Procedure.intMul.comp (two.pair lo) + let twiceHi := Procedure.intMul.comp (two.pair hi) + let twiceDen := Procedure.double.comp den + let no := Procedure.constant (configCode ce) Procedure.boolCode false + let yes := Procedure.constant (configCode ce) Procedure.boolCode true + let leftRegs := sum.pair (twiceHi.pair (twiceDen.pair no)) + let rightRegs := twiceLo.pair (sum.pair (twiceDen.pair no)) + let stoppedRegs := sum.pair (sum.pair (twiceDen.pair yes)) + let middle := middleProgram.comp regs + let value := evalProgram.comp (env.pair middle) + let positive := rationalLess.comp (tolerance.pair value) + let negative := rationalLess.comp (value.pair (Procedure.ratNeg.comp tolerance)) + let moved := Procedure.conditional positive leftRegs + (Procedure.conditional negative rightRegs stoppedRegs) + let result := Procedure.conditional settled regs moved + exact (env.pair (tolerance.pair result)).congrFun (by + intro s + simp only [advance, step, Function.comp_apply, decide_eq_true_eq]) + +noncomputable def repeatProgram {E : Type} {ce : E → List Bool} + {evaluate : E → ℚ → ℚ} + (evalProgram : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Procedure (prodCode (fun n => List.replicate n true) (configCode ce)) (configCode ce) + (fun x => (advance evaluate)^[x.1] x.2) := + (advanceProgram evalProgram).iterate (8 * (Polynomial.X + 1) ^ 2 + 20) + (iterate_code_bound ce evaluate) + +noncomputable def initialProgram : Procedure (prodCode ratCode ratCode) code + (fun p => initial p.1 p.2) := by + let a := Procedure.first ratCode ratCode + let b := Procedure.second ratCode ratCode + let an := Procedure.ratNum.comp a + let bn := Procedure.ratNum.comp b + let ad := Procedure.ratDen.comp a + let bd := Procedure.ratDen.comp b + let lo := Procedure.intMul.comp (an.pair (Procedure.natToInt.comp bd)) + let hi := Procedure.intMul.comp (bn.pair (Procedure.natToInt.comp ad)) + let den := Procedure.binaryMul.comp (ad.pair bd) + exact (lo.pair (hi.pair (den.pair + (Procedure.constant (prodCode ratCode ratCode) Procedure.boolCode false)))).congrFun + (by intro p; rfl) + +abbrev Input (E : Type) := ℕ × (E × (ℚ × (ℚ × ℚ))) + +def inputCode {E : Type} (ce : E → List Bool) : Input E → List Bool := + prodCode (fun n => List.replicate n true) + (prodCode ce (prodCode ratCode (prodCode ratCode ratCode))) + +def approximate {E : Type} (evaluate : E → ℚ → ℚ) (x : Input E) : ℚ := + middle ((step x.2.2.1 (evaluate x.2.1))^[x.1] (initial x.2.2.2.1 x.2.2.2.2)) + +noncomputable def program {E : Type} {ce : E → List Bool} + {evaluate : E → ℚ → ℚ} + (evalProgram : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Procedure (inputCode ce) ratCode (approximate evaluate) := by + let n := Procedure.first (fun n => List.replicate n true) + (prodCode ce (prodCode ratCode (prodCode ratCode ratCode))) + let tail := Procedure.second (fun n => List.replicate n true) + (prodCode ce (prodCode ratCode (prodCode ratCode ratCode))) + let env := (Procedure.first ce (prodCode ratCode (prodCode ratCode ratCode))).comp tail + let rest := (Procedure.second ce (prodCode ratCode (prodCode ratCode ratCode))).comp tail + let tolerance := (Procedure.first ratCode (prodCode ratCode ratCode)).comp rest + let endpoints := (Procedure.second ratCode (prodCode ratCode ratCode)).comp rest + let config := env.pair (tolerance.pair (initialProgram.comp endpoints)) + let run := (repeatProgram evalProgram).comp (n.pair config) + let extract := (Procedure.second ratCode code).comp (Procedure.second ce (prodCode ratCode code)) + exact (middleProgram.comp (extract.comp run)).congrFun (by + intro x + simp only [Function.comp_apply, iterate_config, approximate]) + +noncomputable def certificate {E : Type} {ce : E → List Bool} + {evaluate : E → ℚ → ℚ} + (evalProgram : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Turing.TM2ComputableInPolyTime (inputCode ce) ratCode (approximate evaluate) := + (program evalProgram).toTM2 + +theorem residual {E : Type} (evaluate : E → ℚ → ℚ) (e : E) + {a b δ : ℚ} {f : ℝ → ℝ} {L : ℝ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) (hL : 0 ≤ L) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate e q : ℝ) - f q| ≤ (δ : ℝ)) + (hLip : ∀ x ∈ Set.Icc (a : ℝ) b, ∀ y ∈ Set.Icc (a : ℝ) b, + |f x - f y| ≤ L * |x - y|) (n : ℕ) : + |f (approximate evaluate (n, (e, (δ, (a, b)))))| ≤ + 2 * (δ : ℝ) + L * (((b : ℝ) - a) / 2 ^ n) := + BisectionRegisters.residual hδ hab ha hb hL heval hLip n + +end ContinuumCoulomb.BisectionProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionRegisters.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionRegisters.lean new file mode 100644 index 0000000000000000000000000000000000000000..187d102fd86b2c4ec452dea2c1960b85cac3779f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/BisectionRegisters.lean @@ -0,0 +1,165 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ApproximateBisection +import OAI.Computability.QuantumFactoring.BitStackRationals + +namespace OAI + +/-! Common-denominator registers for approximate bisection. Each update +doubles the denominator and uses only addition and doubling of numerators; +therefore every register gains at most one bit per iteration. -/ + +namespace ContinuumCoulomb.BisectionRegisters +open ExactQuantumFactoring.BitStackProgram + +abbrev Registers := ℤ × (ℤ × (ℕ × Bool)) + +def code : Registers → List Bool := + prodCode intCode (prodCode intCode (prodCode Nat.bits Procedure.boolCode)) + +def left (r : Registers) : ℚ := mkRat r.1 r.2.2.1 +def right (r : Registers) : ℚ := mkRat r.2.1 r.2.2.1 +def middle (r : Registers) : ℚ := mkRat (r.1 + r.2.1) (2 * r.2.2.1) + +def interval (r : Registers) : ApproximateBisection.Interval := + ⟨left r, right r, r.2.2.2⟩ + +def step (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) : Registers := + if r.2.2.2 then r + else if δ < evaluate (middle r) then + (r.1 + r.2.1, (2 * r.2.1, (2 * r.2.2.1, false))) + else if evaluate (middle r) < -δ then + (2 * r.1, (r.1 + r.2.1, (2 * r.2.2.1, false))) + else (r.1 + r.2.1, (r.1 + r.2.1, (2 * r.2.2.1, true))) + +def initial (a b : ℚ) : Registers := + (a.num * b.den, (b.num * a.den, (a.den * b.den, false))) + +theorem initial_den_pos (a b : ℚ) : 0 < (initial a b).2.2.1 := + Nat.mul_pos a.pos b.pos + +theorem middle_eq (r : Registers) (hr : 0 < r.2.2.1) : + middle r = ApproximateBisection.midpoint (interval r) := by + have hd : (r.2.2.1 : ℚ) ≠ 0 := by exact_mod_cast hr.ne' + simp only [middle, ApproximateBisection.midpoint, interval, left, right, + Rat.mkRat_eq_div, Int.cast_add, Nat.cast_mul, Nat.cast_ofNat] + field_simp + +theorem initial_interval (a b : ℚ) : + interval (initial a b) = ApproximateBisection.initial a b := by + have ha : (a.den : ℚ) ≠ 0 := by exact_mod_cast a.den_nz + have hb : (b.den : ℚ) ≠ 0 := by exact_mod_cast b.den_nz + have hl : left (initial a b) = a := by + change mkRat (a.num * b.den) (a.den * b.den) = a + rw [Rat.mkRat_eq_div] + push_cast + conv_rhs => rw [← Rat.num_div_den a] + field_simp + have hh : right (initial a b) = b := by + change mkRat (b.num * a.den) (a.den * b.den) = b + rw [Rat.mkRat_eq_div] + push_cast + conv_rhs => rw [← Rat.num_div_den b] + field_simp + change (⟨left (initial a b), right (initial a b), false⟩ : + ApproximateBisection.Interval) = ⟨a, b, false⟩ + rw [hl, hh] + +theorem step_den_pos (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) + (hr : 0 < r.2.2.1) : 0 < (step δ evaluate r).2.2.1 := by + unfold step + split_ifs <;> first | exact hr | exact Nat.mul_pos (by decide) hr + +private theorem double_quotient (z : ℤ) (d : ℕ) (hd : 0 < d) : + mkRat (2 * z) (2 * d) = mkRat z d := by + have h : (d : ℚ) ≠ 0 := by exact_mod_cast hd.ne' + simp only [Rat.mkRat_eq_div, Int.cast_mul, Int.cast_ofNat, Nat.cast_mul, Nat.cast_ofNat] + field_simp + +theorem step_interval (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) + (hr : 0 < r.2.2.1) : interval (step δ evaluate r) = + ApproximateBisection.step δ evaluate (interval r) := by + have hm : middle r = (left r + right r) / 2 := middle_eq r hr + unfold step ApproximateBisection.step + simp only [interval, ApproximateBisection.midpoint, ← hm] + split_ifs <;> simp [left, right, middle, double_quotient, hr] + +theorem iterate_interval (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) + (hr : 0 < r.2.2.1) (n : ℕ) : + 0 < ((step δ evaluate)^[n] r).2.2.1 ∧ + interval ((step δ evaluate)^[n] r) = + (ApproximateBisection.step δ evaluate)^[n] (interval r) := by + induction n with + | zero => exact ⟨hr, rfl⟩ + | succ n ih => + rw [Function.iterate_succ_apply', Function.iterate_succ_apply'] + exact ⟨step_den_pos δ evaluate _ ih.1, (step_interval δ evaluate _ ih.1).trans + (congrArg (ApproximateBisection.step δ evaluate) ih.2)⟩ + +def bits (r : Registers) : ℕ := + max (max r.1.natAbs.bits.length r.2.1.natAbs.bits.length) r.2.2.1.bits.length + +theorem code_length (r : Registers) : (code r).length = + 2 * r.1.natAbs.bits.length + 2 * r.2.1.natAbs.bits.length + + 2 * r.2.2.1.bits.length + 16 := by + simp only [code, prodCode, intCode, intData, pairBits_length, + Procedure.boolCode, List.length_singleton] + omega + +theorem bits_le_code (r : Registers) : bits r ≤ (code r).length := by + rw [code_length] + unfold bits + omega + +theorem code_le_bits (r : Registers) : (code r).length ≤ 6 * bits r + 16 := by + rw [code_length] + unfold bits + omega + +private theorem add_bits_le_max (a b : ℤ) : + (a + b).natAbs.bits.length ≤ max a.natAbs.bits.length b.natAbs.bits.length + 1 := by + have hab : (a + b).natAbs ≤ 2 * max a.natAbs b.natAbs := + (Int.natAbs_add_le a b).trans (by omega) + have h := (bits_length_mono hab).trans (double_bits_length (max a.natAbs b.natAbs)) + by_cases hm : a.natAbs ≤ b.natAbs + · rw [max_eq_right hm] at h + exact h.trans (Nat.add_le_add_right (le_max_right _ _) _) + · rw [max_eq_left (le_of_not_ge hm)] at h + exact h.trans (Nat.add_le_add_right (le_max_left _ _) _) + +private theorem double_int_bits (a : ℤ) : + (2 * a).natAbs.bits.length ≤ a.natAbs.bits.length + 1 := by + rw [Int.natAbs_mul] + exact double_bits_length a.natAbs + +theorem step_bits (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) : + bits (step δ evaluate r) ≤ bits r + 1 := by + have ha := add_bits_le_max r.1 r.2.1 + have hl := double_int_bits r.1 + have hh := double_int_bits r.2.1 + have hd := double_bits_length r.2.2.1 + unfold step + split_ifs <;> dsimp only [bits] <;> omega + +theorem iterate_bits (δ : ℚ) (evaluate : ℚ → ℚ) (r : Registers) (n : ℕ) : + bits ((step δ evaluate)^[n] r) ≤ bits r + n := by + induction n with + | zero => simp + | succ n ih => + rw [Function.iterate_succ_apply'] + exact (step_bits δ evaluate _).trans (by omega) + +/-- The actual unreduced register execution satisfies the analytic residual +bound; all evaluation calls remain inside the initial rational interval. -/ +theorem residual {a b δ : ℚ} {f : ℝ → ℝ} {evaluate : ℚ → ℚ} {L : ℝ} + (hδ : 0 ≤ δ) (hab : a ≤ b) (ha : 0 ≤ f a) (hb : f b ≤ 0) (hL : 0 ≤ L) + (heval : ∀ q ∈ Set.Icc a b, |(evaluate q : ℝ) - f q| ≤ (δ : ℝ)) + (hLip : ∀ x ∈ Set.Icc (a : ℝ) b, ∀ y ∈ Set.Icc (a : ℝ) b, + |f x - f y| ≤ L * |x - y|) (n : ℕ) : + |f (middle ((step δ evaluate)^[n] (initial a b)))| ≤ + 2 * (δ : ℝ) + L * (((b : ℝ) - a) / 2 ^ n) := by + obtain ⟨hp, hi⟩ := iterate_interval δ evaluate (initial a b) (initial_den_pos a b) n + rw [middle_eq _ hp, hi, initial_interval] + exact ApproximateBisection.run_residual hδ hab ha hb hL heval hLip n + +end ContinuumCoulomb.BisectionRegisters + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedBisectionProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedBisectionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc9b94b71af3300029f27ae90b1f1ec2a456c563 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedBisectionProgram.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedBisectionMachine + +namespace OAI + +/-! One polynomial TM2 program selects both the internal precision and +the iteration count and runs the actual calibrated bisection. -/ + +namespace ContinuumCoulomb.CalibratedEvaluation +open ExactQuantumFactoring.BitStackProgram + +abbrev ScheduledInput := Environment × (ℚ × ℚ) +def scheduledInputCode : ScheduledInput → List Bool := + prodCode environmentCode (prodCode ratCode ratCode) + +noncomputable opaque envMetadataProgram : Procedure environmentCode + (prodCode unaryCode unaryCode) Prod.fst := + Procedure.first (prodCode unaryCode unaryCode) (prodCode unaryCode (prodCode ratCode ratCode)) +noncomputable opaque envParametersProgram : Procedure environmentCode + (prodCode unaryCode (prodCode ratCode ratCode)) Prod.snd := + Procedure.second (prodCode unaryCode unaryCode) (prodCode unaryCode (prodCode ratCode ratCode)) +noncomputable opaque envBoundProgram : Procedure environmentCode unaryCode (fun e => e.1.1) := + (Procedure.first unaryCode unaryCode).comp envMetadataProgram +noncomputable opaque envPrecisionProgram : Procedure environmentCode unaryCode (fun e => e.1.2) := + (Procedure.second unaryCode unaryCode).comp envMetadataProgram +noncomputable opaque envScaleProgram : Procedure environmentCode unaryCode (fun e => e.2.1) := + (Procedure.first unaryCode (prodCode ratCode ratCode)).comp envParametersProgram + +noncomputable opaque refinedEnvironmentProgram : Procedure environmentCode environmentCode + refinedEnvironment := + (envBoundProgram.pair + (((CoulombEvaluation.scaleProgram 8).comp Procedure.unarySuccessor).comp envPrecisionProgram)).pair + envParametersProgram + +noncomputable opaque firstIterationFactorProgram (rho : ℕ) : Procedure environmentCode unaryCode + (fun e => 16 * lipschitzGuard rho * (e.2.1 + e.1.1 + 1)) := by + let sum := ResolventSchedule.addProgram.comp (envScaleProgram.pair envBoundProgram) + let suc := Procedure.unarySuccessor.comp sum + exact ((CoulombEvaluation.scaleProgram (16 * lipschitzGuard rho)).comp suc).congrFun + (by intro e; rfl) + +noncomputable opaque secondIterationFactorProgram (rho : ℕ) : Procedure environmentCode unaryCode + (fun e => 16 * lipschitzGuard rho * (e.2.1 + e.1.1 + 1) * (e.1.1 + 1)) := + (ResolventSchedule.mulProgram.comp ((firstIterationFactorProgram rho).pair + (Procedure.unarySuccessor.comp envBoundProgram))).congrFun (by intro e; rfl) + +noncomputable opaque iterationsProgram (rho : ℕ) : Procedure environmentCode unaryCode + (iterations rho) := + (ResolventSchedule.mulProgram.comp ((secondIterationFactorProgram rho).pair + (Procedure.unarySuccessor.comp envPrecisionProgram))).congrFun (by intro e; rfl) + +noncomputable opaque scheduledArgumentProgram (rho : ℕ) : Procedure scheduledInputCode + bisectionInputCode (fun x => (iterations rho x.1, (refinedEnvironment x.1, x.2))) := by + let e := Procedure.first environmentCode (prodCode ratCode ratCode) + let ends := Procedure.second environmentCode (prodCode ratCode ratCode) + exact ((iterationsProgram rho).comp e).pair + ((refinedEnvironmentProgram.comp e).pair ends) + +noncomputable opaque scheduledProgram (rho : ℕ) : Procedure scheduledInputCode ratCode + (fun x => scheduledValue rho x.1 x.2.1 x.2.2) := + ((bisectionProgram rho).comp (scheduledArgumentProgram rho)).congrFun (by intro x; rfl) + +noncomputable def scheduledCertificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime scheduledInputCode ratCode + (fun x => scheduledValue rho x.1 x.2.1 x.2.2) := + (scheduledProgram rho).toTM2 + +end ContinuumCoulomb.CalibratedEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedContactProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedContactProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7c24650c002fb7cd240a69f93af152110425f63 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedContactProgram.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.AutomaticCalibrationList +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactSourceInputProgram + +namespace OAI + +/-! One literal polynomial-time map from source arrays and target edge +coefficients to the physically scaled rational contact coordinates. -/ + +noncomputable section +namespace ContinuumCoulomb.CalibratedContactProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Data := List (ℤ × ℤ) × (List MediatorListProgram.Bond × List ℚ) +abbrev Input := ℕ × (AutomaticCalibrationList.Environment × Data) + +def dataCode : Data → List Bool := + prodCode (listCode ContactCanonicalEdgeProgram.latticeCode) + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode)) + +def inputCode : Input → List Bool := + prodCode unaryCode (prodCode AutomaticCalibrationList.environmentCode dataCode) + +def rawInput (rho : ℕ) (ε c : ℚ) (k A B : ℕ) (x : Input) : ContactSourceInputProgram.Input := + (x.1, (x.2.2.1, (x.2.2.2.1, + AutomaticCalibrationList.value rho ε c k A B (x.2.1, x.2.2.2.2)))) + +def value (rho : ℕ) (ε c : ℚ) (k A B : ℕ) (x : Input) : List (ℚ × ℚ) := + ContactSourceInputProgram.scaledPositions + (AutomaticCalibration.spacing c k x.2.1.1, rawInput rho ε c k A B x) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first unaryCode _ + +noncomputable opaque restProgram : Procedure inputCode + (prodCode AutomaticCalibrationList.environmentCode dataCode) Prod.snd := Procedure.second unaryCode _ + +noncomputable opaque environmentProgram : Procedure inputCode + AutomaticCalibrationList.environmentCode (fun x => x.2.1) := + (Procedure.first AutomaticCalibrationList.environmentCode dataCode).comp restProgram + +noncomputable opaque dataProgram : Procedure inputCode dataCode (fun x => x.2.2) := + (Procedure.second AutomaticCalibrationList.environmentCode dataCode).comp restProgram + +noncomputable opaque coordinatesProgram : Procedure inputCode + (listCode ContactCanonicalEdgeProgram.latticeCode) (fun x => x.2.2.1) := + (Procedure.first _ _).comp dataProgram + +noncomputable opaque listsProgram : Procedure inputCode + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode)) (fun x => x.2.2.2) := + (Procedure.second _ _).comp dataProgram + +noncomputable opaque bondsProgram : Procedure inputCode + (listCode MediatorListProgram.bondCode) (fun x => x.2.2.2.1) := + (Procedure.first _ _).comp listsProgram + +noncomputable opaque coefficientsProgram : Procedure inputCode (listCode ratCode) + (fun x => x.2.2.2.2) := (Procedure.second _ _).comp listsProgram + +noncomputable opaque lengthsProgram (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : + Procedure inputCode (listCode ratCode) + (fun x => AutomaticCalibrationList.value rho ε c k A B (x.2.1, x.2.2.2.2)) := + (AutomaticCalibrationList.program rho ε c k A B).comp + (environmentProgram.pair coefficientsProgram) + +noncomputable opaque rawProgram (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : + Procedure inputCode ContactSourceInputProgram.inputCode (rawInput rho ε c k A B) := + precisionProgram.pair (coordinatesProgram.pair + (bondsProgram.pair (lengthsProgram rho ε c k A B))) + +noncomputable opaque spacingProgram (c : ℚ) (k : ℕ) : Procedure inputCode ratCode + (fun x => AutomaticCalibration.spacing c k x.2.1.1) := + (RationalLogScale.program c k).comp + ((Procedure.first unaryCode unaryCode).comp environmentProgram) + +noncomputable opaque program (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : + Procedure inputCode (listCode ContactRationalGadget.pointCode) (value rho ε c k A B) := + ContactSourceInputProgram.scaledProgram.comp + ((spacingProgram c k).pair (rawProgram rho ε c k A B)) + +noncomputable def certificate (rho : ℕ) (ε c : ℚ) (k A B : ℕ) : + Turing.TM2ComputableInPolyTime inputCode (listCode ContactRationalGadget.pointCode) + (value rho ε c k A B) := (program rho ε c k A B).toTM2 + +end ContinuumCoulomb.CalibratedContactProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedEvaluationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedEvaluationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c23ca0d71f15417bf81b4e9c512e538d60300d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibratedEvaluationProgram.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationComponents + +namespace OAI + +/-! The final polynomial TM2 composition for the actual calibrated residual. -/ + +namespace ContinuumCoulomb.CalibratedEvaluation +open ExactQuantumFactoring.BitStackProgram + +attribute [local irreducible] CoulombEvaluation.approximate + +noncomputable def evaluatedExpression (rho : ℕ) (x : Environment × ℚ) : ℚ := + (x.1.2.1 : ℚ) * + ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2) - + x.1.2.2.1 * root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2 + +theorem evaluatedExpression_eq (rho : ℕ) (x : Environment × ℚ) : + evaluatedExpression rho x = value rho x.1 x.2 := rfl + +noncomputable opaque valuesProgram (rho : ℕ) : Procedure inputCode (prodCode ratCode ratCode) + (fun x => ((x.1.2.1 : ℚ) * + ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2), + x.1.2.2.1 * root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2)) := + scaledHoppingProgram.pair (targetProgram rho) + +noncomputable opaque subtractValuesProgram (rho : ℕ) : Procedure inputCode ratCode + ((fun q : ℚ × ℚ => q.1 - q.2) ∘ (fun x : Environment × ℚ => ((x.1.2.1 : ℚ) * + ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2), + x.1.2.2.1 * root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2))) := + Procedure.ratSub.comp (valuesProgram rho) + +private theorem subtract_pair_function {X : Type*} (f g : X → ℚ) : + ((fun q : ℚ × ℚ => q.1 - q.2) ∘ (fun x => (f x, g x))) = + (fun x => f x - g x) := rfl + +theorem subtractValues_function (rho : ℕ) : + ((fun q : ℚ × ℚ => q.1 - q.2) ∘ (fun x : Environment × ℚ => ((x.1.2.1 : ℚ) * + ComputableHopping.approximate ((x.1.1.1, hoppingPrecision x.1.2.1 x.1.1.2), x.2), + x.1.2.2.1 * root rho x.1.1.1 x.1.1.2 x.1.2.2.2 x.2))) = evaluatedExpression rho := by + exact subtract_pair_function _ _ + +noncomputable opaque rawProgram (rho : ℕ) : Procedure inputCode ratCode (evaluatedExpression rho) := + cast (congrArg (fun f : Environment × ℚ → ℚ => Procedure inputCode ratCode f) + (subtractValues_function rho)) (subtractValuesProgram rho) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode + (fun x => value rho x.1 x.2) := + cast (congrArg (fun f : Environment × ℚ → ℚ => Procedure inputCode ratCode f) + (funext (evaluatedExpression_eq rho))) (rawProgram rho) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime inputCode ratCode (fun x => value rho x.1 x.2) := + (program rho).toTM2 + +end ContinuumCoulomb.CalibratedEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibrationRationalBracketProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibrationRationalBracketProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..03091f024f92d462f1bac565c286301de7ae2b66 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CalibrationRationalBracketProgram.lean @@ -0,0 +1,33 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalLogScaleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationRationalBracket + +namespace OAI + +/-! A literal polynomial-time program returns both rational contact-search +endpoints from the unary instance-size parameter. -/ + +namespace ContinuumCoulomb.CalibrationRationalBracket +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque leftProgram (ε c : ℚ) (k : ℕ) : Procedure unaryCode ratCode + (fun N => (endpoints ε (RationalLogScale.value c k N)).1) := + Procedure.ratMul.comp + ((Procedure.constant unaryCode ratCode (1 - ε / 2)).pair (RationalLogScale.program c k)) + +noncomputable opaque rightProgram (ε c : ℚ) (k : ℕ) : Procedure unaryCode ratCode + (fun N => (endpoints ε (RationalLogScale.value c k N)).2) := + Procedure.ratMul.comp + ((Procedure.constant unaryCode ratCode (1 + ε / 2)).pair (RationalLogScale.program c k)) + +noncomputable opaque program (ε c : ℚ) (k : ℕ) : Procedure unaryCode + (prodCode ratCode ratCode) (fun N => endpoints ε (RationalLogScale.value c k N)) := + (leftProgram ε c k).pair (rightProgram ε c k) + +noncomputable def certificate (ε c : ℚ) (k : ℕ) : + Turing.TM2ComputableInPolyTime unaryCode (prodCode ratCode ratCode) + (fun N => endpoints ε (RationalLogScale.value c k N)) := + (program ε c k).toTM2 + +end ContinuumCoulomb.CalibrationRationalBracket + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CappedKernelProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CappedKernelProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..57fb949e3e57d5494225a41e981944c2f9570f65 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CappedKernelProgram.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedCoulombKernel +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram + +namespace OAI + +/-! A literal rational approximation of the bounded three-dimensional +Coulomb kernel. Only a dyadic square root and rational arithmetic occur. -/ + +noncomputable section +namespace ContinuumCoulomb.CappedKernelProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Triple := ℚ × (ℚ × ℚ) +abbrev Input := (ℕ × ℚ) × Triple + +def position (q : Triple) : Position := WithLp.toLp 2 ![(q.1 : ℝ), (q.2.1 : ℝ), (q.2.2 : ℝ)] +def normSquare (q : Triple) : ℚ := q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2 + +def approximate (x : Input) : ℚ := + (max x.1.2 (RationalSquareRoot.value (x.1.1, normSquare x.2)))⁻¹ + +theorem normSquare_nonnegative (q : Triple) : 0 ≤ normSquare q := by + unfold normSquare + positivity + +theorem position_norm_sq (q : Triple) : ‖position q‖ ^ 2 = (normSquare q : ℝ) := by + rw [EuclideanSpace.norm_sq_eq] + simp [position, normSquare, Fin.sum_univ_succ] + ring + +theorem position_norm (q : Triple) : ‖position q‖ = Real.sqrt (normSquare q : ℝ) := by + rw [← position_norm_sq, Real.sqrt_sq (norm_nonneg _)] + +theorem approximation_error (x : Input) (hε : 0 < x.1.2) : + |(approximate x : ℝ) - cappedCoulombKernel (x.1.2 : ℝ) (position x.2)| ≤ + ((x.1.2 : ℝ)⁻¹ ^ 2) * (2 : ℝ)⁻¹ ^ x.1.1 := by + let a : ℝ := max (x.1.2 : ℝ) (RationalSquareRoot.value (x.1.1, normSquare x.2) : ℝ) + let b : ℝ := max (x.1.2 : ℝ) ‖position x.2‖ + have hεr : (0 : ℝ) < x.1.2 := by exact_mod_cast hε + have ha : 0 < a := hεr.trans_le (le_max_left _ _) + have hb : 0 < b := hεr.trans_le (le_max_left _ _) + have hroot := RationalSquareRoot.value_error x.1.1 (normSquare_nonnegative x.2) + rw [← position_norm] at hroot + have hdiff : |a - b| ≤ (2 : ℝ)⁻¹ ^ x.1.1 := by + have h := abs_max_sub_max_le_abs + (RationalSquareRoot.value (x.1.1, normSquare x.2) : ℝ) ‖position x.2‖ (x.1.2 : ℝ) + rw [max_comm _ (x.1.2 : ℝ), max_comm _ (x.1.2 : ℝ)] at h + exact h.trans hroot + have hai : a⁻¹ ≤ (x.1.2 : ℝ)⁻¹ := inv_anti₀ hεr (le_max_left _ _) + have hbi : b⁻¹ ≤ (x.1.2 : ℝ)⁻¹ := inv_anti₀ hεr (le_max_left _ _) + have he : (approximate x : ℝ) - cappedCoulombKernel (x.1.2 : ℝ) (position x.2) = + (b - a) * a⁻¹ * b⁻¹ := by + have hcast : (approximate x : ℝ) = a⁻¹ := by + simp only [approximate, Rat.cast_inv, Rat.cast_max, a] + rw [hcast] + change a⁻¹ - b⁻¹ = _ + field_simp [ha.ne', hb.ne'] + rw [he, abs_mul, abs_mul, abs_of_pos (inv_pos.mpr ha), + abs_of_pos (inv_pos.mpr hb), abs_sub_comm b a] + calc + _ ≤ ((2 : ℝ)⁻¹ ^ x.1.1) * (x.1.2 : ℝ)⁻¹ * (x.1.2 : ℝ)⁻¹ := by gcongr + _ = _ := by ring + +def tripleCode : Triple → List Bool := prodCode ratCode (prodCode ratCode ratCode) +def inputCode : Input → List Bool := prodCode (prodCode unaryCode ratCode) tripleCode + +noncomputable opaque maximumProgram : Procedure (prodCode ratCode ratCode) ratCode + (fun q => max q.1 q.2) := by + exact (Procedure.conditional BisectionProgram.rationalLess + (Procedure.second ratCode ratCode) (Procedure.first ratCode ratCode)).congrFun (by + intro q + simp only [decide_eq_true_eq] + split_ifs with h + · exact (max_eq_right h.le).symm + · exact (max_eq_left (le_of_not_gt h)).symm) + +noncomputable opaque normSquareProgram : Procedure tripleCode ratCode normSquare := by + let x := Procedure.first ratCode (prodCode ratCode ratCode) + let yz := Procedure.second ratCode (prodCode ratCode ratCode) + let y := (Procedure.first ratCode ratCode).comp yz + let z := (Procedure.second ratCode ratCode).comp yz + let sx := Procedure.ratMul.comp (x.pair x) + let sy := Procedure.ratMul.comp (y.pair y) + let sz := Procedure.ratMul.comp (z.pair z) + exact (Procedure.ratAdd.comp ((Procedure.ratAdd.comp (sx.pair sy)).pair sz)).congrFun + (by intro q; simp only [normSquare, Function.comp_apply, pow_two]) + +noncomputable opaque program : Procedure inputCode ratCode approximate := by + let params := Procedure.first (prodCode unaryCode ratCode) tripleCode + let precision := (Procedure.first unaryCode ratCode).comp params + let epsilon := (Procedure.second unaryCode ratCode).comp params + let coords := Procedure.second (prodCode unaryCode ratCode) tripleCode + let square := normSquareProgram.comp coords + let root := RationalSquareRoot.program.comp (precision.pair square) + let den := maximumProgram.comp (epsilon.pair root) + exact (Procedure.ratDiv.comp ((Procedure.constant inputCode ratCode (1 : ℚ)).pair den)).congrFun + (by intro x; simp only [approximate, Function.comp_apply, one_div]) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode approximate := + program.toTM2 + +end ContinuumCoulomb.CappedKernelProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredGaussProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredGaussProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6f73a01de4bd6e9c9f0a5c22c137d8f3138e811 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredGaussProgram.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGaussLabels +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGaussList + +namespace OAI + +/-! Literal polynomial generation of the complete rectangular Gauss-label +list. The three integer radii are unary, so the cubic number of output cells +is polynomial in the encoded input size. -/ + +namespace ContinuumCoulomb.CenteredGaussLabels +open ExactQuantumFactoring.BitStackProgram + +private theorem flatten_code_bound {α : Type} (ea : α → List Bool) (xs : List (List α)) : + (listCode ea xs.flatten).length ≤ (listCode (listCode ea) xs).length := by + induction xs with + | nil => exact le_rfl + | cons x xs ih => + have h := listCode_length_append ea x xs.flatten + simp only [List.flatten_cons,listCode_length_cons] + omega + +private theorem fold_append {α : Type} (xs : List (List α)) (ys : List α) : + xs.foldl (fun ys x => ys++x) ys = ys++xs.flatten := by + induction xs generalizing ys with + | nil => simp + | cons x xs ih => simp only [List.foldl_cons,ih,List.flatten_cons,List.append_assoc] + +private noncomputable def flattenProgram {α : Type} (ea : α → List Bool) (d : α) : + Procedure (listCode (listCode ea)) (listCode ea) List.flatten := by + let step := (Procedure.listAppend ea d).comp (Procedure.swap (listCode ea) (listCode ea)) + let p := Procedure.foldList [] step Polynomial.X (by + intro xs ys i + change (listCode ea ((xs.take i).foldl (fun ys x => ys++x) ys)).length ≤ _ + rw [fold_append] + have h := listCode_length_append ea ys (xs.take i).flatten + have hf := flatten_code_bound ea (xs.take i) + have ht := listCode_length_take_le (listCode ea) i xs + simp only [Polynomial.eval_X] + omega) + exact (p.comp ((Procedure.identity (listCode (listCode ea))).pair + (Procedure.constant (listCode (listCode ea)) (listCode ea) []))).congrFun (by + intro xs + change xs.foldl (fun ys x => ys++x) [] = xs.flatten + simpa only [List.nil_append] using fold_append xs []) + +private noncomputable def productProgram {α β : Type} (ea : α → List Bool) (eb : β → List Bool) + (a : α) (b : β) : Procedure (prodCode (listCode ea) (listCode eb)) + (listCode (prodCode ea eb)) (fun x => x.1 ×ˢ x.2) := by + let row := (Procedure.listMapWith (ea := ea) (eb := eb) (ec := prodCode ea eb) + (f := fun a b => (a,b)) b (a,b) (Procedure.identity (prodCode ea eb))).comp + (Procedure.swap (listCode eb) ea) + let rows := (Procedure.listMapWith (ea := listCode eb) (eb := ea) + (ec := listCode (prodCode ea eb)) (f := fun ys a => ys.map (fun b => (a,b))) a [] row).comp + (Procedure.swap (listCode ea) (listCode eb)) + exact ((flattenProgram (prodCode ea eb) (a,b)).comp rows).congrFun (by intro x; rfl) + +def radiiCode : Radii → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) + +private noncomputable opaque integerStep : Procedure (prodCode unaryCode unaryCode) intCode + (fun x => (x.1:ℤ)-(x.2:ℤ)) := by + let cast := Procedure.natToInt.comp Procedure.unaryToBits + exact Procedure.intSub.comp + ((cast.comp (Procedure.first unaryCode unaryCode)).pair + (cast.comp (Procedure.second unaryCode unaryCode))) + +noncomputable opaque integersProgram : Procedure unaryCode (listCode intCode) integers := by + let count := Procedure.unarySuccessor.comp (Procedure.unaryMul.comp + ((Procedure.constant unaryCode unaryCode 2).pair (Procedure.identity unaryCode))) + exact ((Procedure.tabulate (ea := unaryCode) (eb := intCode) + (f := fun R i => (i:ℤ)-(R:ℤ)) 0 integerStep).comp + (count.pair (Procedure.identity unaryCode))).congrFun (by intro R; rfl) + +private noncomputable opaque firstRadiusProgram : Procedure radiiCode unaryCode Prod.fst := + Procedure.first _ _ +private noncomputable opaque tailRadiiProgram : Procedure radiiCode (prodCode unaryCode unaryCode) Prod.snd := + Procedure.second _ _ +private noncomputable opaque secondRadiusProgram : Procedure radiiCode unaryCode (fun r => r.2.1) := + (Procedure.first _ _).comp tailRadiiProgram +private noncomputable opaque thirdRadiusProgram : Procedure radiiCode unaryCode (fun r => r.2.2) := + (Procedure.second _ _).comp tailRadiiProgram + +noncomputable opaque cellsProgram : Procedure radiiCode (listCode EulerRegisters.registersCode) cells := by + let yz := (productProgram intCode intCode (0:ℤ) (0:ℤ)).comp + ((integersProgram.comp secondRadiusProgram).pair (integersProgram.comp thirdRadiusProgram)) + exact (productProgram intCode (prodCode intCode intCode) (0:ℤ) (0,0)).comp + ((integersProgram.comp firstRadiusProgram).pair yz) + +noncomputable opaque labelsProgram : Procedure radiiCode (listCode TransformedGauss.labelCode) labels := + (productProgram EulerRegisters.registersCode RationalGaussNodes.signsCode (0,(0,0)) + (false,(false,false))).comp + (cellsProgram.pair (Procedure.constant radiiCode (listCode RationalGaussNodes.signsCode) signs)) + +noncomputable def labelsCertificate : Turing.TM2ComputableInPolyTime radiiCode + (listCode TransformedGauss.labelCode) labels := labelsProgram.toTM2 + +end ContinuumCoulomb.CenteredGaussLabels + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredNuclearProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredNuclearProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a42d1f80002a039e2654def161929697424743b8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredNuclearProgram.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredGaussProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.NuclearCoordinateOutput + +namespace OAI + +/-! The complete finite rational nucleus list, generated from the actual +rectangular cell bounds, numerically transported, and serialized using the +continuum promise's own position codec. -/ + +open scoped NNReal +namespace ContinuumCoulomb.CenteredNuclearProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := TransformedGauss.Environment×CenteredGaussLabels.Radii +def inputCode : Input → List Bool := + prodCode TransformedGauss.environmentCode CenteredGaussLabels.radiiCode + +noncomputable def nuclei (rho U C K : ℕ) (x : Input) : List BinaryPosition := + NuclearCoordinateOutput.positions + (TransformedGauss.nodes rho U C K (x.1,CenteredGaussLabels.labels x.2)) + +noncomputable opaque argumentsProgram : Procedure inputCode TransformedGauss.listInputCode + (fun x => (x.1,CenteredGaussLabels.labels x.2)) := + (Procedure.first _ _).pair (CenteredGaussLabels.labelsProgram.comp (Procedure.second _ _)) + +noncomputable opaque program (rho U C K : ℕ) : Procedure inputCode + (BinaryEncoding.list binaryPositionCodec).encode (nuclei rho U C K) := + NuclearCoordinateOutput.positionsProgram.comp + ((TransformedGauss.listProgram rho U C K).comp argumentsProgram) + +noncomputable def certificate (rho U C K : ℕ) : Turing.TM2ComputableInPolyTime inputCode + (BinaryEncoding.list binaryPositionCodec).encode (nuclei rho U C K) := + (program rho U C K).toTM2 + +theorem nuclei_length (rho U C K : ℕ) (x : Input) : + (nuclei rho U C K x).length = + 8*((2*x.2.1+1)*(2*x.2.2.1+1)*(2*x.2.2.2+1)) := by + rw [nuclei,NuclearCoordinateOutput.positions_length,TransformedGauss.nodes_length, + CenteredGaussLabels.labels_length] + +theorem nuclei_valid (rho U C K : ℕ) (x : Input) {p : BinaryPosition} + (hp : p ∈ nuclei rho U C K x) : p.Valid := + NuclearCoordinateOutput.positions_valid _ hp + +theorem nuclei_nonempty (rho U C K : ℕ) (x : Input) : 0 < (nuclei rho U C K x).length := by + rw [nuclei_length] + positivity + +theorem nuclei_values_nodup (rho U C K : ℕ) (x : Input) (hN : 0 < x.1.1.2) + (G : Position → Position) {J : ℝ≥0} (hG : AntilipschitzWith J G) + (herror : ∀ l : TransformedGauss.Label, + ‖CappedKernelProgram.position (TransformedGauss.value rho U C K x.1.1.1 x.1.1.2 + x.1.2.1.1 x.1.2.1.2 x.1.2.2 l.1 l.2)- + G (gaussLatticePoint (x.1.1.2:ℝ)⁻¹ (RationalGaussNodes.index l.1 l.2))‖ ≤ + ((x.1.1.1:ℝ)+1)⁻¹) + (hprecision : 2*(J:ℝ)*((x.1.1.1:ℝ)+1)⁻¹ < (x.1.1.2:ℝ)⁻¹/3) : + ((nuclei rho U C K x).map BinaryPosition.value).Nodup := by + have hn := TransformedGauss.nodes_nodup rho U C K x.1.1.1 hN x.1.2.1.1 x.1.2.1.2 + x.1.2.2 (CenteredGaussLabels.labels x.2) (CenteredGaussLabels.labels_nodup x.2) + G hG herror hprecision + have hm := hn.map NuclearCoordinateOutput.position_value_injective + simpa only [nuclei,NuclearCoordinateOutput.positions,List.map_map,Function.comp_def] using hm + +end ContinuumCoulomb.CenteredNuclearProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredPhysicalThresholdProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredPhysicalThresholdProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ac2b6fc0c127a92fcabd1e32c064ac2b3035d39 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CenteredPhysicalThresholdProgram.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredPhysicalThreshold + +namespace OAI + +/-! Polynomial-time arithmetic for the complete physical threshold pair. -/ + +namespace ContinuumCoulomb.CenteredPhysicalThreshold +open ExactQuantumFactoring.BitStackProgram + +def geometryCode : Geometry → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) +def metadataCode : (ℕ×(ℕ×(ℚ×ℚ))) → List Bool := + prodCode unaryCode (prodCode unaryCode (prodCode ratCode ratCode)) +def inputCode : Input → List Bool := prodCode geometryCode metadataCode + +noncomputable opaque geometryProgram : Procedure inputCode geometryCode Prod.fst := Procedure.first _ _ +noncomputable opaque metadataProgram : Procedure inputCode metadataCode Prod.snd := Procedure.second _ _ +noncomputable opaque meshProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first _ _).comp geometryProgram +noncomputable opaque boxProgram : Procedure inputCode (prodCode unaryCode unaryCode) + (fun x => x.1.2) := (Procedure.second _ _).comp geometryProgram +noncomputable opaque electronsProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp metadataProgram +noncomputable opaque restProgram : Procedure inputCode (prodCode unaryCode (prodCode ratCode ratCode)) + (fun x => x.2.2) := (Procedure.second _ _).comp metadataProgram +noncomputable opaque errorProgram : Procedure inputCode unaryCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp restProgram +noncomputable opaque endpointsProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.2.2) := (Procedure.second _ _).comp restProgram + +noncomputable opaque meshCubeProgram : Procedure inputCode unaryCode (fun x => x.1.1^3) := + (ResolventSchedule.mulProgram.comp + ((ResolventSchedule.squareProgram.comp meshProgram).pair meshProgram)).congrFun + (by intro x; dsimp; ring) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode precision := by + let c8 := Procedure.constant inputCode unaryCode 8 + let scale := ResolventSchedule.mulProgram.comp (c8.pair meshCubeProgram) + let sq := ResolventSchedule.squareProgram.comp (Procedure.unarySuccessor.comp scale) + let first := ResolventSchedule.mulProgram.comp (c8.pair sq) + let second := ResolventSchedule.mulProgram.comp + (first.pair (Procedure.unarySuccessor.comp electronsProgram)) + exact (ResolventSchedule.mulProgram.comp + (second.pair (Procedure.unarySuccessor.comp errorProgram))).congrFun (by intro x; rfl) + +noncomputable opaque amplificationProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => amplification rho x.1.1) := by + let cube := Procedure.natToRat.comp (Procedure.unaryToBits.comp meshCubeProgram) + let num := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 8).pair cube) + exact (Procedure.ratDiv.comp + (num.pair (Procedure.constant inputCode ratCode (rho:ℚ)))).congrFun + (by intro x; simp [amplification]) + +noncomputable opaque referenceProgram (rho : ℕ) : Procedure inputCode ratCode (reference rho) := by + let slab := (SlabBoxSchedule.centeredProgram rho).comp (precisionProgram.pair geometryProgram) + let freq := (GaussianFrequency.program rho).comp precisionProgram + let sub := Procedure.ratSub.comp (freq.pair (Procedure.constant inputCode ratCode 1)) + let e0 := Procedure.ratDiv.comp (sub.pair (Procedure.constant inputCode ratCode 2)) + exact (Procedure.ratAdd.comp (slab.pair e0)).congrFun (by intro x; rfl) + +noncomputable opaque offsetProgram (rho : ℕ) : Procedure inputCode ratCode (offset rho) := by + let lambda := amplificationProgram rho + let square := Procedure.ratMul.comp (lambda.pair lambda) + let n := Procedure.natToRat.comp (Procedure.unaryToBits.comp electronsProgram) + let factor := Procedure.ratMul.comp (square.pair n) + exact (Procedure.ratMul.comp (factor.pair (referenceProgram rho))).congrFun + (by intro x; simp only [offset,pow_two,Function.comp_apply,id_eq]) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode (prodCode ratCode ratCode) (value rho) := by + let endpoints := endpointsProgram + let a := (Procedure.first ratCode ratCode).comp endpoints + let b := (Procedure.second ratCode ratCode).comp endpoints + let lower := Procedure.ratAdd.comp + ((offsetProgram rho).pair (Procedure.ratMul.comp ((amplificationProgram rho).pair a))) + let upper := Procedure.ratAdd.comp + ((offsetProgram rho).pair (Procedure.ratMul.comp ((amplificationProgram rho).pair b))) + exact lower.pair upper + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode + (prodCode ratCode ratCode) (value rho) := (program rho).toTM2 + +end ContinuumCoulomb.CenteredPhysicalThreshold + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ChargePrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ChargePrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d8ea217624e8877a553d3d5baf191a6d171657a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ChargePrograms.lean @@ -0,0 +1,148 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EncodingPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.BinaryWellCharges +import OAI.Computability.QuantumFactoring.BitStackRationalDivision +import OAI.Computability.QuantumFactoring.BitStackRationalFloor + +namespace OAI + +/-! Actual polynomial-time stack programs for the two rounded binary-well +charges. The geometric scale is unary and the number of sites is binary. +The output is the pair of binary natural-number codes. -/ + +namespace ContinuumCoulomb +namespace ChargePrograms +open ExactQuantumFactoring.BitStackProgram + +def parameters : BinaryEncoding.Codec (ℕ × ℕ) := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.unary) BinaryEncoding.natural + +theorem parameters_encoding (x : ℕ × ℕ) : parameters.encode x = + prodCode BinaryEncoding.unary.encode BinaryEncoding.natural.encode x := by + change BinaryEncoding.encodeDigits (BinaryEncoding.unary.encode x.1) ++ _ = _ + rw [AmplificationProgram.encodeDigits_quote] + rfl + +theorem parameters_length (D m : ℕ) : + (parameters.encode (D, m)).length = 2 * D + 2 * m.size + 4 := by + unfold parameters + rw [BinaryEncoding.pair_length, BinaryEncoding.quoted_length, + BinaryEncoding.unary_length, BinaryEncoding.natural_length] + dsimp only [Prod.fst, Prod.snd] + omega + +/-- Clamp a signed binary integer to a natural number. -/ +noncomputable def intToNatProgram : Procedure intCode Nat.bits Int.toNat := + (Procedure.conditional Procedure.intSign + (Procedure.constant intCode Nat.bits 0) Procedure.intAbs).congrFun (by + intro z + cases z <;> simp) + +/-- Ties round upward, exactly as the manuscript's rational charge function. -/ +noncomputable def rationalRoundProgram : Procedure ratCode intCode (fun q => round q) := + (Procedure.ratFloor.comp (Procedure.ratAdd.comp + ((Procedure.identity ratCode).pair (Procedure.constant ratCode ratCode (1 / 2))))).congrFun + (by intro q; exact (round_eq q).symm) + +noncomputable def scaledRoundProgram : Procedure (prodCode Nat.bits ratCode) Nat.bits + (fun x => rationalRoundedScaledCharge x.1 x.2) := by + let z := Procedure.natToRat.comp (Procedure.first Nat.bits ratCode) + let q := Procedure.second Nat.bits ratCode + exact (intToNatProgram.comp (rationalRoundProgram.comp + (Procedure.ratMul.comp (z.pair q)))).congrFun (by intro x; rfl) + +def rawParameters : (ℕ × ℕ) → List Bool := prodCode unaryCode Nat.bits + +noncomputable def dProgram : Procedure rawParameters unaryCode Prod.fst := + Procedure.first unaryCode Nat.bits + +noncomputable def mProgram : Procedure rawParameters Nat.bits Prod.snd := + Procedure.second unaryCode Nat.bits + +noncomputable def amplificationProgram : Procedure rawParameters Nat.bits + (fun x => binaryAmplification x.1) := + (AmplificationProgram.rawProgram.comp dProgram).congrFun (by intro x; rfl) + +noncomputable def dRationalProgram : Procedure rawParameters ratCode (fun x => (x.1 : ℚ)) := + (Procedure.natToRat.comp (Procedure.unaryToBits.comp dProgram)).congrFun (by intro x; rfl) + +noncomputable def mRationalProgram : Procedure rawParameters ratCode (fun x => (x.2 : ℚ)) := + (Procedure.natToRat.comp mProgram).congrFun (by intro x; rfl) + +noncomputable def fractionProgram (c : ℕ) : Procedure rawParameters ratCode + (fun x => (c : ℚ) * x.2 / x.1) := by + let multiple := Procedure.ratMul.comp + ((Procedure.constant rawParameters ratCode (c : ℚ)).pair mRationalProgram) + exact (Procedure.ratDiv.comp (multiple.pair dRationalProgram)).congrFun (by intro x; rfl) + +noncomputable def primaryRatioProgram : Procedure rawParameters ratCode + (fun x => 1 - 500 * x.2 / (x.1 : ℚ)) := + (Procedure.ratSub.comp ((Procedure.constant rawParameters ratCode 1).pair + (fractionProgram 500))).congrFun (by intro x; rfl) + +noncomputable def primaryRawProgram : Procedure rawParameters Nat.bits + (fun x => binaryPrimaryCharge x.1 x.2) := + (scaledRoundProgram.comp (amplificationProgram.pair primaryRatioProgram)).congrFun (by intro x; rfl) + +noncomputable def secondaryRawProgram : Procedure rawParameters Nat.bits + (fun x => binarySecondaryCharge x.1 x.2) := + (scaledRoundProgram.comp (amplificationProgram.pair (fractionProgram 1000))).congrFun (by intro x; rfl) + +/-- Parse the actual marker bits of a binary natural number. -/ +noncomputable def naturalInputProgram : Procedure BinaryEncoding.natural.encode Nat.bits id := + EncodingPrograms.naturalInput + +noncomputable def inputProgram : Procedure parameters.encode rawParameters id := by + let d := AmplificationProgram.inputProgram.comp + (Procedure.first BinaryEncoding.unary.encode BinaryEncoding.natural.encode) + let m := naturalInputProgram.comp + (Procedure.second BinaryEncoding.unary.encode BinaryEncoding.natural.encode) + exact (d.pair m).congrEncoding (fun x => (parameters_encoding x).symm) (by intro x; rfl) + +noncomputable def naturalOutputProgram : Procedure Nat.bits BinaryEncoding.natural.encode id := + EncodingPrograms.naturalOutput + +def output : BinaryEncoding.Codec (ℕ × ℕ) := + BinaryEncoding.pair BinaryEncoding.natural BinaryEncoding.natural + +noncomputable def primaryProgram : Procedure parameters.encode BinaryEncoding.natural.encode + (fun x => binaryPrimaryCharge x.1 x.2) := + (naturalOutputProgram.comp (primaryRawProgram.comp inputProgram)).congrFun (by intro x; rfl) + +noncomputable def secondaryProgram : Procedure parameters.encode BinaryEncoding.natural.encode + (fun x => binarySecondaryCharge x.1 x.2) := + (naturalOutputProgram.comp (secondaryRawProgram.comp inputProgram)).congrFun (by intro x; rfl) + +noncomputable def pairProgram : Procedure parameters.encode + (prodCode BinaryEncoding.natural.encode BinaryEncoding.natural.encode) + (fun x => (binaryPrimaryCharge x.1 x.2, binarySecondaryCharge x.1 x.2)) := + primaryProgram.pair secondaryProgram + +/-- Both physical charges, including rational scaling and integer rounding, +are computed by a finite Boolean-stack program with a polynomial runtime. -/ +noncomputable def program : Procedure parameters.encode output.encode + (fun x => (binaryPrimaryCharge x.1 x.2, binarySecondaryCharge x.1 x.2)) := + ((EncodingPrograms.appendPair BinaryEncoding.natural BinaryEncoding.natural).comp + pairProgram).congrFun (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime parameters.encode output.encode + (fun x => (binaryPrimaryCharge x.1 x.2, binarySecondaryCharge x.1 x.2)) := program.toTM2 + +theorem output_length (D m : ℕ) : + (output.encode (binaryPrimaryCharge D m, binarySecondaryCharge D m)).length = + 2 * (binaryPrimaryCharge D m).size + 2 * (binarySecondaryCharge D m).size + 2 := by + unfold output + rw [BinaryEncoding.pair_length, BinaryEncoding.natural_length, BinaryEncoding.natural_length] + dsimp only [Prod.fst, Prod.snd] + omega + +theorem output_length_le {D m : ℕ} (hm : 0 < m) (hscale : 2002 * m ≤ D) : + (output.encode (binaryPrimaryCharge D m, binarySecondaryCharge D m)).length ≤ 8 * D + 10 := by + rw [output_length] + obtain ⟨hp, hs⟩ := binaryWellCharges_bit_length hm hscale + omega + +end ChargePrograms +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactCanonicalEdgeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactCanonicalEdgeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8baf3cd8c464cc1aff8695278075cb9f065b084b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactCanonicalEdgeProgram.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactCanonicalEdge +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactHeightProgram + +namespace OAI + +/-! The canonical lattice strip is computed by integer comparisons. -/ + +namespace ContinuumCoulomb.ContactCanonicalEdgeProgram +open ExactQuantumFactoring.BitStackProgram + +def latticeCode : (ℤ × ℤ) → List Bool := prodCode intCode intCode +def inputCode : ((ℤ × ℤ) × (ℤ × ℤ)) → List Bool := prodCode latticeCode latticeCode +def edgeCode (e : ContactGridEdge) : List Bool := + prodCode Procedure.boolCode (prodCode latticeCode Procedure.boolCode) + (e.vertical, (e.anchor, e.reversed)) + +noncomputable opaque integerEqual : Procedure (prodCode intCode intCode) + Procedure.boolCode (fun x => decide (x.1 = x.2)) := + (Procedure.binaryZero.comp (Procedure.intAbs.comp Procedure.intSub)).congrFun (by + intro x + simp only [Function.comp_apply, Int.natAbs_eq_zero, sub_eq_zero]) + +noncomputable opaque integerLess : Procedure (prodCode intCode intCode) + Procedure.boolCode (fun x => decide (x.1 < x.2)) := + (Procedure.intSign.comp Procedure.intSub).congrFun (by + intro x + simp only [Function.comp_apply, sub_neg]) + +noncomputable opaque leftProgram : Procedure inputCode latticeCode Prod.fst := + Procedure.first latticeCode latticeCode +noncomputable opaque rightProgram : Procedure inputCode latticeCode Prod.snd := + Procedure.second latticeCode latticeCode +noncomputable opaque leftXProgram : Procedure inputCode intCode (fun x => x.1.1) := + (Procedure.first intCode intCode).comp leftProgram +noncomputable opaque leftYProgram : Procedure inputCode intCode (fun x => x.1.2) := + (Procedure.second intCode intCode).comp leftProgram +noncomputable opaque rightXProgram : Procedure inputCode intCode (fun x => x.2.1) := + (Procedure.first intCode intCode).comp rightProgram +noncomputable opaque rightYProgram : Procedure inputCode intCode (fun x => x.2.2) := + (Procedure.second intCode intCode).comp rightProgram + +noncomputable opaque verticalProgram : Procedure inputCode Procedure.boolCode + (fun x => decide (x.1.1 = x.2.1)) := integerEqual.comp (leftXProgram.pair rightXProgram) + +noncomputable opaque forwardProgram : Procedure inputCode Procedure.boolCode + (fun x => if decide (x.1.1 = x.2.1) then decide (x.1.2 < x.2.2) else decide (x.1.1 < x.2.1)) := + Procedure.conditional verticalProgram (integerLess.comp (leftYProgram.pair rightYProgram)) + (integerLess.comp (leftXProgram.pair rightXProgram)) + +noncomputable opaque anchorProgram : Procedure inputCode latticeCode + (fun x => if (if decide (x.1.1 = x.2.1) then decide (x.1.2 < x.2.2) + else decide (x.1.1 < x.2.1)) then x.1 else x.2) := + Procedure.conditional forwardProgram leftProgram rightProgram + +noncomputable opaque reverseProgram : Procedure inputCode Procedure.boolCode + (fun x => !(if decide (x.1.1 = x.2.1) then decide (x.1.2 < x.2.2) + else decide (x.1.1 < x.2.1))) := Procedure.boolNot.comp forwardProgram + +noncomputable opaque program : Procedure inputCode edgeCode + (fun x => canonicalContactEdge x.1 x.2) := + (verticalProgram.pair (anchorProgram.pair reverseProgram)).result (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode edgeCode + (fun x => canonicalContactEdge x.1 x.2) := program.toTM2 + +end ContinuumCoulomb.ContactCanonicalEdgeProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactEdgeNumberProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactEdgeNumberProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c22d8addd8249b6f8f868bf9a8971433c0edae6e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactEdgeNumberProgram.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactEdgeNumber +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactPlacedGadgetProgram + +namespace OAI + +/-! Each fixed local edge has an explicit polynomial-time global lookup +index, with the original source edge index retained. -/ + +namespace ContinuumCoulomb.ContactEdgeNumberProgram +open ExactQuantumFactoring.BitStackProgram ContactMediator + +abbrev Input := ℕ × ℕ + +def inputCode : Input → List Bool := prodCode unaryCode unaryCode + +noncomputable opaque rProgram : Procedure inputCode Nat.bits Prod.fst := + Procedure.unaryToBits.comp (Procedure.first unaryCode unaryCode) + +noncomputable opaque eProgram : Procedure inputCode Nat.bits Prod.snd := + Procedure.unaryToBits.comp (Procedure.second unaryCode unaryCode) + +noncomputable opaque twiceRProgram : Procedure inputCode Nat.bits (fun x => x.1 * 2) := + Procedure.binaryMul.comp (rProgram.pair (Procedure.constant inputCode Nat.bits 2)) + +noncomputable opaque twiceEProgram : Procedure inputCode Nat.bits (fun x => x.2 * 2) := + Procedure.binaryMul.comp (eProgram.pair (Procedure.constant inputCode Nat.bits 2)) + +noncomputable def pathProgram : (p : LocalPath) → + Procedure inputCode Nat.bits (fun x => pathNumber x.1 x.2 p) + | Sum.inl s => Procedure.binaryAdd.comp + (twiceEProgram.pair (Procedure.constant inputCode Nat.bits s.val)) + | Sum.inr (s, t) => + let a := Procedure.binaryAdd.comp + (twiceEProgram.pair (Procedure.constant inputCode Nat.bits s.val)) + let b := Procedure.binaryMul.comp (a.pair (Procedure.constant inputCode Nat.bits 2)) + let c := Procedure.binaryAdd.comp (twiceRProgram.pair b) + Procedure.binaryAdd.comp (c.pair (Procedure.constant inputCode Nat.bits t.val)) + +noncomputable opaque pathCountProgram : Procedure inputCode Nat.bits + (fun x => x.1 * 2 + x.1 * 2 * 2) := + Procedure.binaryAdd.comp (twiceRProgram.pair + (Procedure.binaryMul.comp (twiceRProgram.pair (Procedure.constant inputCode Nat.bits 2)))) + +noncomputable def edgeProgram : (a : LocalEdge) → + Procedure inputCode Nat.bits (fun x => edgeNumber x.1 x.2 a) + | Sum.inl _ => eProgram + | Sum.inr (Sum.inl p) => Procedure.binaryAdd.comp (rProgram.pair (pathProgram p)) + | Sum.inr (Sum.inr (p, t)) => + let base := Procedure.binaryAdd.comp (rProgram.pair pathCountProgram) + let twice := Procedure.binaryMul.comp + ((pathProgram p).pair (Procedure.constant inputCode Nat.bits 2)) + let b := Procedure.binaryAdd.comp (base.pair twice) + Procedure.binaryAdd.comp (b.pair (Procedure.constant inputCode Nat.bits t.val)) + +noncomputable def certificate (a : LocalEdge) : Turing.TM2ComputableInPolyTime inputCode + Nat.bits (fun x => edgeNumber x.1 x.2 a) := (edgeProgram a).toTM2 + +end ContinuumCoulomb.ContactEdgeNumberProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactGeometryBlockProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactGeometryBlockProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed8c1893b7352a4e7b02f8c9212b8c437bedfbe1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactGeometryBlockProgram.lean @@ -0,0 +1,143 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactPlacedGadgetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactMediator + +namespace OAI + +/-! Uniform polynomial-time serialization of the actual mediator vertex +blocks: old vertices, first sites, second sites, and the two third-site +blocks. The static local labels agree with `ContactMediator.encodeSite`. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactGeometryBlockProgram +open ExactQuantumFactoring.BitStackProgram ContactMediator + +abbrev EdgeInput := ContactPlacedGadgetProgram.Input + +def defaultEdge : EdgeInput := (((0, 0), (1, 0)), (0, (false, (1, ([], []))))) + +def pointCode : (ℚ × ℚ) → List Bool := ContactRationalGadget.pointCode + +def block (ss : List ContactGadgetSite) (xs : List EdgeInput) : List (ℚ × ℚ) := + (List.range (ss.length * xs.length)).map fun i => + ((ss.map (ContactPlacedGadgetProgram.position + ((xs.drop (i / ss.length)).headD defaultEdge))).drop (i % ss.length)).headD (0, 0) + +abbrev LoopInput := ℕ × List EdgeInput + +def loopCode : LoopInput → List Bool := + prodCode unaryCode (listCode ContactPlacedGadgetProgram.inputCode) + +noncomputable opaque indexProgram : Procedure loopCode Nat.bits (fun x => x.1) := + Procedure.unaryToBits.comp (Procedure.first unaryCode _) + +noncomputable opaque edgesProgram : Procedure loopCode + (listCode ContactPlacedGadgetProgram.inputCode) Prod.snd := Procedure.second unaryCode _ + +noncomputable opaque quotientProgram (n : ℕ) : Procedure loopCode Nat.bits + (fun x => x.1 / n) := Procedure.binaryDiv.comp + (indexProgram.pair (Procedure.constant loopCode Nat.bits n)) + +noncomputable opaque remainderProgram (n : ℕ) : Procedure loopCode Nat.bits + (fun x => x.1 % n) := Procedure.binaryMod.comp + (indexProgram.pair (Procedure.constant loopCode Nat.bits n)) + +noncomputable opaque edgeProgram (n : ℕ) : Procedure loopCode ContactPlacedGadgetProgram.inputCode + (fun x => (x.2.drop (x.1 / n)).headD defaultEdge) := + (Procedure.listGet ContactPlacedGadgetProgram.inputCode defaultEdge).comp + ((quotientProgram n).pair edgesProgram) + +noncomputable opaque pointListProgram (ss : List ContactGadgetSite) : Procedure loopCode + (listCode pointCode) (fun x => ss.map (ContactPlacedGadgetProgram.position + ((x.2.drop (x.1 / ss.length)).headD defaultEdge))) := + (ContactPlacedGadgetProgram.pointListProgram ss).comp (edgeProgram ss.length) + +noncomputable opaque stepProgram (ss : List ContactGadgetSite) : Procedure loopCode pointCode + (fun x => ((ss.map (ContactPlacedGadgetProgram.position + ((x.2.drop (x.1 / ss.length)).headD defaultEdge))).drop (x.1 % ss.length)).headD (0, 0)) := + (Procedure.listGet pointCode (0, 0)).comp + ((remainderProgram ss.length).pair (pointListProgram ss)) + +noncomputable opaque blockProgram (ss : List ContactGadgetSite) : + Procedure (listCode ContactPlacedGadgetProgram.inputCode) (listCode pointCode) (block ss) := by + let len := ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength + ContactPlacedGadgetProgram.inputCode defaultEdge + let count := (CoulombEvaluation.scaleProgram ss.length).comp len + exact ((Procedure.tabulate (ea := listCode ContactPlacedGadgetProgram.inputCode) + (eb := pointCode) (f := fun xs i => + ((ss.map (ContactPlacedGadgetProgram.position + ((xs.drop (i / ss.length)).headD defaultEdge))).drop (i % ss.length)).headD (0, 0)) + (0, 0) (stepProgram ss)).comp + (count.pair (Procedure.identity (listCode ContactPlacedGadgetProgram.inputCode)))).congrFun + (by intro xs; rfl) + +def firstSites : List ContactGadgetSite := + List.ofFn (fun s : Fin 2 => localToContact (localFirst s)) + +def secondSites : List ContactGadgetSite := + List.ofFn (fun i : Fin 4 => + let st : Fin 2 × Fin 2 := finProdFinEquiv.symm i + localToContact (localSecond st.1 st.2)) + +def thirdFirstSites : List ContactGadgetSite := + List.ofFn (fun i : Fin 4 => + let st : Fin 2 × Fin 2 := finProdFinEquiv.symm i + localToContact (localThird (Sum.inl st.1) st.2)) + +def thirdSecondSites : List ContactGadgetSite := + List.ofFn (fun sut : Fin 8 => + let st : Fin 4 × Fin 2 := finProdFinEquiv.symm sut + let su : Fin 2 × Fin 2 := finProdFinEquiv.symm st.1 + localToContact (localThird (Sum.inr su) st.2)) + +def oldPoint (p : ℤ × ℤ) : ℚ × ℚ := (17 * (p.1 : ℚ), 17 * (p.2 : ℚ)) + +noncomputable opaque oldPointProgram : Procedure ContactCanonicalEdgeProgram.latticeCode + pointCode oldPoint := by + let x := Procedure.intToRat.comp (Procedure.first intCode intCode) + let y := Procedure.intToRat.comp (Procedure.second intCode intCode) + exact (Procedure.ratMul.comp + ((Procedure.constant ContactCanonicalEdgeProgram.latticeCode ratCode 17).pair x)).pair + (Procedure.ratMul.comp + ((Procedure.constant ContactCanonicalEdgeProgram.latticeCode ratCode 17).pair y)) + +abbrev Input := List (ℤ × ℤ) × List EdgeInput + +def inputCode : Input → List Bool := + prodCode (listCode ContactCanonicalEdgeProgram.latticeCode) + (listCode ContactPlacedGadgetProgram.inputCode) + +def positions (x : Input) : List (ℚ × ℚ) := + x.1.map oldPoint ++ block firstSites x.2 ++ block secondSites x.2 ++ + block thirdFirstSites x.2 ++ block thirdSecondSites x.2 + +noncomputable opaque oldProgram : Procedure inputCode (listCode pointCode) + (fun x => x.1.map oldPoint) := + (Procedure.listMap (0, 0) (0, 0) oldPointProgram).comp (Procedure.first _ _) + +noncomputable opaque listProgram (ss : List ContactGadgetSite) : + Procedure inputCode (listCode pointCode) (fun x => block ss x.2) := + (blockProgram ss).comp (Procedure.second _ _) + +noncomputable opaque program : Procedure inputCode (listCode pointCode) positions := by + let append := Procedure.listAppend pointCode (0, 0) + let a := append.comp (oldProgram.pair (listProgram firstSites)) + let b := append.comp (a.pair (listProgram secondSites)) + let c := append.comp (b.pair (listProgram thirdFirstSites)) + exact (append.comp (c.pair (listProgram thirdSecondSites))).congrFun + (by intro x; simp only [positions, Function.comp_apply, List.append_assoc]) + +theorem positions_length (x : Input) : + (positions x).length = x.1.length + 18 * x.2.length := by + simp only [positions, List.length_append, List.length_map, block, + List.length_range, firstSites, secondSites, thirdFirstSites, thirdSecondSites, + List.length_ofFn] + omega + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + (listCode pointCode) positions := program.toTM2 + +end ContinuumCoulomb.ContactGeometryBlockProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..7782156739489815d441520bf1b994ccca11b9e3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightProgram.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedEvaluationComponents +import OAI.Computability.QuantumFactoring.BitStackListIndex + +namespace OAI + +/-! A literal rational height-residual program. It reads nine input lengths +and executes four already-certified rational square-root subprograms. -/ + +namespace ContinuumCoulomb.ContactHeightEvaluation +open ExactQuantumFactoring.BitStackProgram + +def environmentCode : Environment → List Bool := + prodCode unaryCode (prodCode (listCode ratCode) ratCode) + +def inputCode : (Environment × ℚ) → List Bool := prodCode environmentCode ratCode + +noncomputable opaque environmentProgram : Procedure inputCode environmentCode Prod.fst := + Procedure.first environmentCode ratCode + +noncomputable opaque heightProgram : Procedure inputCode ratCode Prod.snd := + Procedure.second environmentCode ratCode + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode (prodCode (listCode ratCode) ratCode)).comp environmentProgram + +noncomputable opaque dataProgram : Procedure inputCode (prodCode (listCode ratCode) ratCode) + (fun x => x.1.2) := + (Procedure.second unaryCode (prodCode (listCode ratCode) ratCode)).comp environmentProgram + +noncomputable opaque lengthsProgram : Procedure inputCode (listCode ratCode) + (fun x => x.1.2.1) := + (Procedure.first (listCode ratCode) ratCode).comp dataProgram + +noncomputable opaque targetProgram : Procedure inputCode ratCode (fun x => x.1.2.2) := + (Procedure.second (listCode ratCode) ratCode).comp dataProgram + +noncomputable opaque lengthProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => lengthAt x.1 k) := + (Procedure.listGet ratCode 1).comp + ((Procedure.constant inputCode Nat.bits k).pair lengthsProgram) + +noncomputable opaque squareLengthProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => (lengthAt x.1 k) ^ 2) := + (Procedure.ratMul.comp ((lengthProgram k).pair (lengthProgram k))).congrFun + (by intro x; simp only [Function.comp_apply, pow_two]) + +noncomputable opaque squareHeightProgram : Procedure inputCode ratCode + (fun x => x.2 ^ 2) := + (Procedure.ratMul.comp (heightProgram.pair heightProgram)).congrFun + (by intro x; simp only [Function.comp_apply, pow_two]) + +noncomputable opaque radicandProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => (lengthAt x.1 k) ^ 2 - x.2 ^ 2) := + Procedure.ratSub.comp ((squareLengthProgram k).pair squareHeightProgram) + +noncomputable opaque rootPrecisionProgram : Procedure inputCode unaryCode + (fun x => CalibratedEvaluation.rootPrecision x.1.1) := + CalibratedEvaluation.rootPrecisionProgram.comp precisionProgram + +noncomputable opaque rootProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => rootSample x.1 x.2 k) := + RationalSquareRoot.program.comp (rootPrecisionProgram.pair (radicandProgram k)) + +noncomputable opaque axial01Program : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1) := + Procedure.ratAdd.comp ((lengthProgram 0).pair (lengthProgram 1)) + +noncomputable opaque axial014Program : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4) := + Procedure.ratAdd.comp (axial01Program.pair (lengthProgram 4)) + +noncomputable opaque axial0147Program : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7) := + Procedure.ratAdd.comp (axial014Program.pair (lengthProgram 7)) + +noncomputable opaque axialProgram : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7 + lengthAt x.1 8) := + Procedure.ratAdd.comp (axial0147Program.pair (lengthProgram 8)) + +noncomputable opaque firstRootProgram : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7 + lengthAt x.1 8 + + rootSample x.1 x.2 2) := Procedure.ratAdd.comp (axialProgram.pair (rootProgram 2)) + +noncomputable opaque secondRootProgram : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7 + lengthAt x.1 8 + + rootSample x.1 x.2 2 + rootSample x.1 x.2 3) := + Procedure.ratAdd.comp (firstRootProgram.pair (rootProgram 3)) + +noncomputable opaque thirdRootProgram : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7 + lengthAt x.1 8 + + rootSample x.1 x.2 2 + rootSample x.1 x.2 3 + rootSample x.1 x.2 5) := + Procedure.ratAdd.comp (secondRootProgram.pair (rootProgram 5)) + +noncomputable opaque spanProgram : Procedure inputCode ratCode + (fun x => lengthAt x.1 0 + lengthAt x.1 1 + lengthAt x.1 4 + lengthAt x.1 7 + lengthAt x.1 8 + + rootSample x.1 x.2 2 + rootSample x.1 x.2 3 + rootSample x.1 x.2 5 + rootSample x.1 x.2 6) := + Procedure.ratAdd.comp (thirdRootProgram.pair (rootProgram 6)) + +noncomputable opaque program : Procedure inputCode ratCode (fun x => value x.1 x.2) := + Procedure.ratSub.comp (spanProgram.pair targetProgram) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => value x.1 x.2) := program.toTM2 + +end ContinuumCoulomb.ContactHeightEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightScheduleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightScheduleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e58e31046c8253a124129bf0dcc6370baed2a63b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactHeightScheduleProgram.lean @@ -0,0 +1,54 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactHeightBisection +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactHeightProgram + +namespace OAI + +/-! Polynomial-time execution of the concrete contact-height search. All +precision and iteration counts are unary linear functions of the request. -/ + +namespace ContinuumCoulomb.ContactHeightEvaluation +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque envPrecisionProgram : Procedure environmentCode unaryCode Prod.fst := + Procedure.first unaryCode (prodCode (listCode ratCode) ratCode) + +noncomputable opaque envDataProgram : Procedure environmentCode + (prodCode (listCode ratCode) ratCode) Prod.snd := + Procedure.second unaryCode (prodCode (listCode ratCode) ratCode) + +noncomputable opaque refinedPrecisionProgram : Procedure environmentCode unaryCode + (fun e => 16 * (e.1 + 1)) := + ((CoulombEvaluation.scaleProgram 16).comp Procedure.unarySuccessor).comp envPrecisionProgram + +noncomputable opaque refinedProgram : Procedure environmentCode environmentCode + refinedEnvironment := refinedPrecisionProgram.pair envDataProgram + +noncomputable opaque iterationProgram : Procedure environmentCode unaryCode iterations := + ((CoulombEvaluation.scaleProgram 64).comp Procedure.unarySuccessor).comp envPrecisionProgram + +noncomputable opaque toleranceProgram : Procedure environmentCode ratCode + (fun e => tolerance (refinedEnvironment e)) := by + let successor := Procedure.unarySuccessor.comp refinedPrecisionProgram + let rational := Procedure.natToRat.comp (Procedure.unaryToBits.comp successor) + exact (Procedure.ratInv.comp rational).congrFun (by + intro e + simp only [Function.comp_apply, id_eq, tolerance, refinedEnvironment, + Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, one_div]) + +noncomputable opaque scheduledArgumentProgram : Procedure environmentCode + (BisectionProgram.inputCode environmentCode) + (fun e => argument (refinedEnvironment e) (iterations e)) := + iterationProgram.pair (refinedProgram.pair + (toleranceProgram.pair (Procedure.constant environmentCode + (prodCode ratCode ratCode) ((2 / 5 : ℚ), (3 / 4 : ℚ))))) + +noncomputable opaque scheduledProgram : Procedure environmentCode ratCode scheduledValue := + ((BisectionProgram.program program).comp scheduledArgumentProgram).congrFun + (by intro e; rfl) + +noncomputable def scheduledCertificate : Turing.TM2ComputableInPolyTime + environmentCode ratCode scheduledValue := scheduledProgram.toTM2 + +end ContinuumCoulomb.ContactHeightEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactLocalInputProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactLocalInputProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..736d23106c0532fafb1fd98ea27040828aae9d91 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactLocalInputProgram.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactEdgeNumberProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalLocal + +namespace OAI + +/-! Extract the exact nineteen local lengths from the calibrated final-edge +array. Runtime indices are the proved natural formulas for `encodeEdge`. -/ + +namespace ContinuumCoulomb.ContactLocalInputProgram +open ExactQuantumFactoring.BitStackProgram ContactMediator + +abbrev Input := ℕ × (ℕ × (ℕ × (Bool × List ℚ))) + +def inputCode : Input → List Bool := prodCode unaryCode + (prodCode unaryCode (prodCode unaryCode (prodCode Procedure.boolCode (listCode ratCode)))) + +def lookup (x : Input) (a : LocalEdge) : ℚ := + (x.2.2.2.2.drop (edgeNumber x.2.1 x.2.2.1 a)).headD 1 + +def record (x : Input) : ContactRationalGadget.Input := + (x.1, (x.2.2.2.1, (lookup x (Sum.inl ()), + (List.ofFn (fun k : Fin 9 => lookup x (leftEdge k)), + List.ofFn (fun k : Fin 9 => lookup x (rightEdge k)))))) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first unaryCode _ + +noncomputable opaque tailProgram : Procedure inputCode + (prodCode unaryCode (prodCode unaryCode (prodCode Procedure.boolCode (listCode ratCode)))) + Prod.snd := Procedure.second unaryCode _ + +noncomputable opaque countProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first unaryCode _).comp tailProgram + +noncomputable opaque restProgram : Procedure inputCode + (prodCode unaryCode (prodCode Procedure.boolCode (listCode ratCode))) (fun x => x.2.2) := + (Procedure.second unaryCode _).comp tailProgram + +noncomputable opaque indexProgram : Procedure inputCode unaryCode (fun x => x.2.2.1) := + (Procedure.first unaryCode _).comp restProgram + +noncomputable opaque lastProgram : Procedure inputCode + (prodCode Procedure.boolCode (listCode ratCode)) (fun x => x.2.2.2) := + (Procedure.second unaryCode _).comp restProgram + +noncomputable opaque signProgram : Procedure inputCode Procedure.boolCode (fun x => x.2.2.2.1) := + (Procedure.first Procedure.boolCode (listCode ratCode)).comp lastProgram + +noncomputable opaque valuesProgram : Procedure inputCode (listCode ratCode) (fun x => x.2.2.2.2) := + (Procedure.second Procedure.boolCode (listCode ratCode)).comp lastProgram + +noncomputable opaque lookupProgram (a : LocalEdge) : Procedure inputCode ratCode (fun x => lookup x a) := + (Procedure.listGet ratCode 1).comp + (((ContactEdgeNumberProgram.edgeProgram a).comp (countProgram.pair indexProgram)).pair valuesProgram) + +noncomputable def valuesListProgram : (as : List LocalEdge) → + Procedure inputCode (listCode ratCode) (fun x => as.map (lookup x)) + | [] => (Procedure.constant inputCode (listCode ratCode) []).congrFun (by intro x; rfl) + | a :: as => ((Procedure.listCons ratCode).comp + ((lookupProgram a).pair (valuesListProgram as))).congrFun (by intro x; rfl) + +noncomputable opaque leftProgram : Procedure inputCode (listCode ratCode) + (fun x => List.ofFn (fun k : Fin 9 => lookup x (leftEdge k))) := + (valuesListProgram (List.ofFn leftEdge)).congrFun (by + intro x + simp only [List.map_ofFn, Function.comp_def]) + +noncomputable opaque rightProgram : Procedure inputCode (listCode ratCode) + (fun x => List.ofFn (fun k : Fin 9 => lookup x (rightEdge k))) := + (valuesListProgram (List.ofFn rightEdge)).congrFun (by + intro x + simp only [List.map_ofFn, Function.comp_def]) + +noncomputable opaque program : Procedure inputCode ContactRationalGadget.inputCode record := + precisionProgram.pair (signProgram.pair + ((lookupProgram (Sum.inl ())).pair (leftProgram.pair rightProgram))) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + ContactRationalGadget.inputCode record := program.toTM2 + +end ContinuumCoulomb.ContactLocalInputProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactPlacedGadgetProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactPlacedGadgetProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..83921062123a8939e8c244f8b9560f567552d028 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactPlacedGadgetProgram.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactRationalPlaceProgram +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! A source-edge record contains the original integer endpoints and the +nineteen calibrated lengths. The whole local coordinate list is computed +by the same orientation and height routines used in the geometric proof. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactPlacedGadgetProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ((ℤ × ℤ) × (ℤ × ℤ)) × ContactRationalGadget.Input + +def inputCode : Input → List Bool := + prodCode ContactCanonicalEdgeProgram.inputCode ContactRationalGadget.inputCode + +def placement (x : Input) : ContactGridEdge := canonicalContactEdge x.1.1 x.1.2 + +def position (x : Input) (s : ContactGadgetSite) : ℚ × ℚ := + ContactRationalGlobal.rationalPlace (placement x) (ContactRationalGadget.position x.2 s) + +noncomputable opaque placementProgram : Procedure inputCode ContactCanonicalEdgeProgram.edgeCode + placement := ContactCanonicalEdgeProgram.program.comp + (Procedure.first ContactCanonicalEdgeProgram.inputCode ContactRationalGadget.inputCode) + +noncomputable opaque gadgetProgram : Procedure inputCode ContactRationalGadget.inputCode Prod.snd := + Procedure.second ContactCanonicalEdgeProgram.inputCode ContactRationalGadget.inputCode + +noncomputable opaque positionProgram (s : ContactGadgetSite) : + Procedure inputCode ContactRationalGadget.pointCode (fun x => position x s) := + ContactRationalPlaceProgram.program.comp + (placementProgram.pair ((ContactRationalGadget.positionProgram s).comp gadgetProgram)) + +noncomputable def pointListProgram : (ss : List ContactGadgetSite) → + Procedure inputCode (listCode ContactRationalGadget.pointCode) + (fun x => ss.map (position x)) + | [] => (Procedure.constant inputCode (listCode ContactRationalGadget.pointCode) []).congrFun + (by intro x; rfl) + | s :: ss => ((Procedure.listCons ContactRationalGadget.pointCode).comp + ((positionProgram s).pair (pointListProgram ss))).congrFun (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + (listCode ContactRationalGadget.pointCode) + (fun x => ContactRationalGadget.sites.map (position x)) := + (pointListProgram ContactRationalGadget.sites).toTM2 + +end ContinuumCoulomb.ContactPlacedGadgetProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalGadgetProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalGadgetProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca222d71ab556a84423200a84d28e01ec812ea43 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalGadgetProgram.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGadget + +namespace OAI + +/-! Literal polynomial-time computation of the twenty rational gadget +positions, including the two exact outer endpoints. -/ + +namespace ContinuumCoulomb.ContactRationalGadget +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := + prodCode unaryCode (prodCode Procedure.boolCode + (prodCode ratCode (prodCode (listCode ratCode) (listCode ratCode)))) + +def pointCode : (ℚ × ℚ) → List Bool := prodCode ratCode ratCode + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first unaryCode _ + +noncomputable opaque restProgram : Procedure inputCode + (prodCode Procedure.boolCode (prodCode ratCode (prodCode (listCode ratCode) (listCode ratCode)))) + Prod.snd := Procedure.second unaryCode _ + +noncomputable opaque signProgram : Procedure inputCode Procedure.boolCode (fun x => x.2.1) := + (Procedure.first Procedure.boolCode _).comp restProgram + +noncomputable opaque dataProgram : Procedure inputCode + (prodCode ratCode (prodCode (listCode ratCode) (listCode ratCode))) (fun x => x.2.2) := + (Procedure.second Procedure.boolCode _).comp restProgram + +noncomputable opaque centralProgram : Procedure inputCode ratCode (fun x => x.2.2.1) := + (Procedure.first ratCode _).comp dataProgram + +noncomputable opaque listsProgram : Procedure inputCode + (prodCode (listCode ratCode) (listCode ratCode)) (fun x => x.2.2.2) := + (Procedure.second ratCode _).comp dataProgram + +noncomputable opaque leftListProgram : Procedure inputCode (listCode ratCode) + (fun x => x.2.2.2.1) := (Procedure.first (listCode ratCode) (listCode ratCode)).comp listsProgram + +noncomputable opaque rightListProgram : Procedure inputCode (listCode ratCode) + (fun x => x.2.2.2.2) := (Procedure.second (listCode ratCode) (listCode ratCode)).comp listsProgram + +noncomputable opaque positiveSpanProgram : Procedure inputCode ratCode + (fun x => (17 - x.2.2.1) / 2) := + (Procedure.ratMul.comp + ((Procedure.constant inputCode ratCode (1 / 2)).pair + (Procedure.ratSub.comp ((Procedure.constant inputCode ratCode 17).pair centralProgram)))).congrFun + (by intro x; simp only [Function.comp_apply]; ring) + +noncomputable opaque positiveOriginProgram : Procedure inputCode ratCode + (fun x => (17 + x.2.2.1) / 2) := + (Procedure.ratMul.comp + ((Procedure.constant inputCode ratCode (1 / 2)).pair + (Procedure.ratAdd.comp ((Procedure.constant inputCode ratCode 17).pair centralProgram)))).congrFun + (by intro x; simp only [Function.comp_apply]; ring) + +noncomputable opaque spanProgram : Procedure inputCode ratCode + (fun x => span x.2.1 x.2.2.1) := + Procedure.conditional signProgram (Procedure.constant inputCode ratCode (17 / 2)) positiveSpanProgram + +noncomputable opaque originProgram : Procedure inputCode ratCode + (fun x => origin x.2.1 x.2.2.1) := + Procedure.conditional signProgram (Procedure.constant inputCode ratCode (17 / 2)) positiveOriginProgram + +noncomputable opaque leftEnvironmentProgram : Procedure inputCode ContactHeightEvaluation.environmentCode + leftEnvironment := precisionProgram.pair (leftListProgram.pair spanProgram) + +noncomputable opaque rightEnvironmentProgram : Procedure inputCode ContactHeightEvaluation.environmentCode + rightEnvironment := precisionProgram.pair (rightListProgram.pair spanProgram) + +noncomputable opaque leftVertexProgram (k : ℕ) : Procedure inputCode pointCode + (fun x => ContactHeightEvaluation.closedVertex (leftEnvironment x) k) := + (ContactHeightEvaluation.closedVertexProgram k).comp leftEnvironmentProgram + +noncomputable opaque rightVertexProgram (k : ℕ) : Procedure inputCode pointCode + (fun x => ContactHeightEvaluation.closedVertex (rightEnvironment x) k) := + (ContactHeightEvaluation.closedVertexProgram k).comp rightEnvironmentProgram + +noncomputable opaque rightShiftProgram (k : ℕ) : Procedure inputCode pointCode + (fun x => (origin x.2.1 x.2.2.1 + + (ContactHeightEvaluation.closedVertex (rightEnvironment x) k).1, + (ContactHeightEvaluation.closedVertex (rightEnvironment x) k).2)) := by + let qx := (Procedure.first ratCode ratCode).comp (rightVertexProgram k) + let qy := (Procedure.second ratCode ratCode).comp (rightVertexProgram k) + exact (Procedure.ratAdd.comp (originProgram.pair qx)).pair qy + +noncomputable opaque sideProgram : Procedure inputCode pointCode + (fun x => if x.2.1 then (17 / 2, x.2.2.1) else (origin x.2.1 x.2.2.1, 0)) := + Procedure.conditional signProgram + ((Procedure.constant inputCode ratCode (17 / 2)).pair centralProgram) + (originProgram.pair (Procedure.constant inputCode ratCode 0)) + +noncomputable def positionProgram : (s : ContactGadgetSite) → + Procedure inputCode pointCode (fun x => position x s) + | Sum.inl k => leftVertexProgram k.val + | Sum.inr (Sum.inl k) => rightShiftProgram (k.val + 1) + | Sum.inr (Sum.inr _) => sideProgram + +noncomputable def pointListProgram : (ss : List ContactGadgetSite) → + Procedure inputCode (listCode pointCode) (fun x => ss.map (position x)) + | [] => (Procedure.constant inputCode (listCode pointCode) []).congrFun (by intro x; rfl) + | s :: ss => ((Procedure.listCons pointCode).comp + ((positionProgram s).pair (pointListProgram ss))).congrFun (by intro x; rfl) + +def sites : List ContactGadgetSite := + (List.ofFn (fun k : Fin 10 => Sum.inl k)) ++ + (List.ofFn (fun k : Fin 9 => Sum.inr (Sum.inl k))) ++ [contactGadgetSide] + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode (listCode pointCode) + (fun x => sites.map (position x)) := (pointListProgram sites).toTM2 + +end ContinuumCoulomb.ContactRationalGadget + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalPlaceProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalPlaceProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a05acc7f1be8c3ac63744bdf42efa0a99e9a3e93 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactRationalPlaceProgram.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactCanonicalEdgeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactRationalGadgetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalGlobal + +namespace OAI + +/-! Exact strip placement uses only rational arithmetic and the two +computed orientation bits. It preserves the original lattice endpoints. -/ + +namespace ContinuumCoulomb.ContactRationalPlaceProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ContactGridEdge × (ℚ × ℚ) + +def inputCode : Input → List Bool := + prodCode ContactCanonicalEdgeProgram.edgeCode ContactRationalGadget.pointCode + +noncomputable opaque edgeProgram : Procedure inputCode ContactCanonicalEdgeProgram.edgeCode + Prod.fst := Procedure.first _ _ + +noncomputable opaque pointProgram : Procedure inputCode ContactRationalGadget.pointCode + Prod.snd := Procedure.second _ _ + +noncomputable opaque verticalProgram : Procedure inputCode Procedure.boolCode + (fun x => x.1.vertical) := + ((Procedure.first Procedure.boolCode + (prodCode ContactCanonicalEdgeProgram.latticeCode Procedure.boolCode)).precompose + (fun e : ContactGridEdge => (e.vertical, (e.anchor, e.reversed)))).comp edgeProgram + +noncomputable opaque edgeTailProgram : Procedure inputCode + (prodCode ContactCanonicalEdgeProgram.latticeCode Procedure.boolCode) + (fun x => (x.1.anchor, x.1.reversed)) := + ((Procedure.second Procedure.boolCode + (prodCode ContactCanonicalEdgeProgram.latticeCode Procedure.boolCode)).precompose + (fun e : ContactGridEdge => (e.vertical, (e.anchor, e.reversed)))).comp edgeProgram + +noncomputable opaque reverseProgram : Procedure inputCode Procedure.boolCode + (fun x => x.1.reversed) := + (Procedure.second ContactCanonicalEdgeProgram.latticeCode Procedure.boolCode).comp edgeTailProgram + +noncomputable opaque anchorProgram : Procedure inputCode ContactCanonicalEdgeProgram.latticeCode + (fun x => x.1.anchor) := + (Procedure.first ContactCanonicalEdgeProgram.latticeCode Procedure.boolCode).comp edgeTailProgram + +noncomputable opaque anchorXProgram : Procedure inputCode ratCode + (fun x => (x.1.anchor.1 : ℚ)) := + Procedure.intToRat.comp ((Procedure.first intCode intCode).comp anchorProgram) + +noncomputable opaque anchorYProgram : Procedure inputCode ratCode + (fun x => (x.1.anchor.2 : ℚ)) := + Procedure.intToRat.comp ((Procedure.second intCode intCode).comp anchorProgram) + +noncomputable opaque rawXProgram : Procedure inputCode ratCode (fun x => x.2.1) := + (Procedure.first ratCode ratCode).comp pointProgram + +noncomputable opaque rawYProgram : Procedure inputCode ratCode (fun x => x.2.2) := + (Procedure.second ratCode ratCode).comp pointProgram + +noncomputable opaque reflectedXProgram : Procedure inputCode ratCode + (fun x => if x.1.reversed then 17 - x.2.1 else x.2.1) := + Procedure.conditional reverseProgram + (Procedure.ratSub.comp ((Procedure.constant inputCode ratCode 17).pair rawXProgram)) rawXProgram + +noncomputable opaque baseXProgram : Procedure inputCode ratCode + (fun x => 17 * (x.1.anchor.1 : ℚ)) := + Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 17).pair anchorXProgram) + +noncomputable opaque baseYProgram : Procedure inputCode ratCode + (fun x => 17 * (x.1.anchor.2 : ℚ)) := + Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 17).pair anchorYProgram) + +noncomputable opaque xProgram : Procedure inputCode ratCode + (fun x => if x.1.vertical then 17 * (x.1.anchor.1 : ℚ) - x.2.2 + else 17 * (x.1.anchor.1 : ℚ) + (if x.1.reversed then 17 - x.2.1 else x.2.1)) := + Procedure.conditional verticalProgram + (Procedure.ratSub.comp (baseXProgram.pair rawYProgram)) + (Procedure.ratAdd.comp (baseXProgram.pair reflectedXProgram)) + +noncomputable opaque yProgram : Procedure inputCode ratCode + (fun x => if x.1.vertical then 17 * (x.1.anchor.2 : ℚ) + + (if x.1.reversed then 17 - x.2.1 else x.2.1) + else 17 * (x.1.anchor.2 : ℚ) + x.2.2) := + Procedure.conditional verticalProgram + (Procedure.ratAdd.comp (baseYProgram.pair reflectedXProgram)) + (Procedure.ratAdd.comp (baseYProgram.pair rawYProgram)) + +noncomputable opaque program : Procedure inputCode ContactRationalGadget.pointCode + (fun x => ContactRationalGlobal.rationalPlace x.1 x.2) := + (xProgram.pair yProgram).congrFun (by + intro x + cases hv : x.1.vertical <;> cases hr : x.1.reversed <;> + simp [ContactRationalGlobal.rationalPlace, hv, hr]) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + ContactRationalGadget.pointCode (fun x => ContactRationalGlobal.rationalPlace x.1 x.2) := + program.toTM2 + +end ContinuumCoulomb.ContactRationalPlaceProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactSourceInputProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactSourceInputProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fb99c7423d045c815bbf91850a21b9fef653485 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactSourceInputProgram.lean @@ -0,0 +1,163 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactLocalInputProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactGeometryBlockProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorListProgram + +namespace OAI + +/-! A literal polynomial-time program turns the source coordinate/bond +lists and calibrated final-edge lengths into all rational contact sites. -/ + +noncomputable section +namespace ContinuumCoulomb.ContactSourceInputProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × (List (ℤ × ℤ) × (List MediatorListProgram.Bond × List ℚ)) + +def inputCode : Input → List Bool := prodCode unaryCode + (prodCode (listCode ContactCanonicalEdgeProgram.latticeCode) + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode))) + +abbrev LoopInput := ℕ × Input + +def loopCode : LoopInput → List Bool := prodCode unaryCode inputCode + +def bond (x : LoopInput) : MediatorListProgram.Bond := + (x.2.2.2.1.drop x.1).headD MediatorListProgram.zeroBond + +def edge (x : LoopInput) : ContactPlacedGadgetProgram.Input := + (((x.2.2.1.drop (bond x).1).headD (0, 0), + (x.2.2.1.drop (bond x).2.1).headD (0, 0)), + ContactLocalInputProgram.record (x.2.1, (x.2.2.2.1.length, + (x.1, (decide ((bond x).2.2 < 0), x.2.2.2.2))))) + +def edges (x : Input) : List ContactPlacedGadgetProgram.Input := + (List.range x.2.2.1.length).map (fun i => edge (i, x)) + +def positions (x : Input) : List (ℚ × ℚ) := + ContactGeometryBlockProgram.positions (x.2.1, edges x) + +noncomputable opaque indexProgram : Procedure loopCode unaryCode Prod.fst := + Procedure.first unaryCode inputCode + +noncomputable opaque inputProgram : Procedure loopCode inputCode Prod.snd := + Procedure.second unaryCode inputCode + +noncomputable opaque precisionProgram : Procedure loopCode unaryCode (fun x => x.2.1) := + (Procedure.first unaryCode _).comp inputProgram + +noncomputable opaque dataProgram : Procedure loopCode + (prodCode (listCode ContactCanonicalEdgeProgram.latticeCode) + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode))) (fun x => x.2.2) := + (Procedure.second unaryCode _).comp inputProgram + +noncomputable opaque coordinatesProgram : Procedure loopCode + (listCode ContactCanonicalEdgeProgram.latticeCode) (fun x => x.2.2.1) := + (Procedure.first _ _).comp dataProgram + +noncomputable opaque listsProgram : Procedure loopCode + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode)) (fun x => x.2.2.2) := + (Procedure.second _ _).comp dataProgram + +noncomputable opaque bondsProgram : Procedure loopCode + (listCode MediatorListProgram.bondCode) (fun x => x.2.2.2.1) := + (Procedure.first _ _).comp listsProgram + +noncomputable opaque lengthsProgram : Procedure loopCode (listCode ratCode) (fun x => x.2.2.2.2) := + (Procedure.second _ _).comp listsProgram + +noncomputable opaque countProgram : Procedure loopCode unaryCode (fun x => x.2.2.2.1.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength + MediatorListProgram.bondCode MediatorListProgram.zeroBond).comp bondsProgram + +noncomputable opaque bondProgram : Procedure loopCode MediatorListProgram.bondCode bond := + (Procedure.listGet MediatorListProgram.bondCode MediatorListProgram.zeroBond).comp + ((Procedure.unaryToBits.comp indexProgram).pair bondsProgram) + +noncomputable opaque leftIndexProgram : Procedure loopCode Nat.bits (fun x => (bond x).1) := + (Procedure.first Nat.bits (prodCode Nat.bits ratCode)).comp bondProgram + +noncomputable opaque bondTailProgram : Procedure loopCode (prodCode Nat.bits ratCode) + (fun x => (bond x).2) := (Procedure.second Nat.bits _).comp bondProgram + +noncomputable opaque rightIndexProgram : Procedure loopCode Nat.bits (fun x => (bond x).2.1) := + (Procedure.first Nat.bits ratCode).comp bondTailProgram + +noncomputable opaque weightProgram : Procedure loopCode ratCode (fun x => (bond x).2.2) := + (Procedure.second Nat.bits ratCode).comp bondTailProgram + +noncomputable opaque signProgram : Procedure loopCode Procedure.boolCode + (fun x => decide ((bond x).2.2 < 0)) := + (Procedure.intSign.comp (Procedure.ratNum.comp weightProgram)).congrFun (by + intro x + simp only [Function.comp_apply, Rat.num_neg]) + +noncomputable opaque leftProgram : Procedure loopCode ContactCanonicalEdgeProgram.latticeCode + (fun x => (x.2.2.1.drop (bond x).1).headD (0, 0)) := + (Procedure.listGet ContactCanonicalEdgeProgram.latticeCode (0, 0)).comp + (leftIndexProgram.pair coordinatesProgram) + +noncomputable opaque rightProgram : Procedure loopCode ContactCanonicalEdgeProgram.latticeCode + (fun x => (x.2.2.1.drop (bond x).2.1).headD (0, 0)) := + (Procedure.listGet ContactCanonicalEdgeProgram.latticeCode (0, 0)).comp + (rightIndexProgram.pair coordinatesProgram) + +noncomputable opaque localProgram : Procedure loopCode ContactRationalGadget.inputCode + (fun x => ContactLocalInputProgram.record (x.2.1, (x.2.2.2.1.length, + (x.1, (decide ((bond x).2.2 < 0), x.2.2.2.2))))) := + ContactLocalInputProgram.program.comp (precisionProgram.pair + (countProgram.pair (indexProgram.pair (signProgram.pair lengthsProgram)))) + +noncomputable opaque edgeProgram : Procedure loopCode ContactPlacedGadgetProgram.inputCode edge := + (leftProgram.pair rightProgram).pair localProgram + +noncomputable opaque edgesProgram : Procedure inputCode + (listCode ContactPlacedGadgetProgram.inputCode) edges := by + let lists : Procedure inputCode + (prodCode (listCode MediatorListProgram.bondCode) (listCode ratCode)) + (fun x => x.2.2) := (Procedure.second _ _).comp (Procedure.second unaryCode _) + let bonds := (Procedure.first (listCode MediatorListProgram.bondCode) (listCode ratCode)).comp lists + let count := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength + MediatorListProgram.bondCode MediatorListProgram.zeroBond).comp bonds + exact ((Procedure.tabulate (ea := inputCode) (eb := ContactPlacedGadgetProgram.inputCode) + (f := fun x i => edge (i, x)) ContactGeometryBlockProgram.defaultEdge edgeProgram).comp + (count.pair (Procedure.identity inputCode))).congrFun (by intro x; rfl) + +noncomputable opaque program : Procedure inputCode + (listCode ContactRationalGadget.pointCode) positions := + ContactGeometryBlockProgram.program.comp + (((Procedure.first _ _).comp (Procedure.second unaryCode _)).pair edgesProgram) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + (listCode ContactRationalGadget.pointCode) positions := program.toTM2 + +def scaledInputCode : (ℚ × Input) → List Bool := prodCode ratCode inputCode + +def scalePoint (x : ℚ × (ℚ × ℚ)) : ℚ × ℚ := (x.1 * x.2.1, x.1 * x.2.2) + +noncomputable opaque scalePointProgram : Procedure + (prodCode ratCode ContactRationalGadget.pointCode) ContactRationalGadget.pointCode scalePoint := by + let q := Procedure.first ratCode ContactRationalGadget.pointCode + let p := Procedure.second ratCode ContactRationalGadget.pointCode + let a := (Procedure.first ratCode ratCode).comp p + let b := (Procedure.second ratCode ratCode).comp p + exact (Procedure.ratMul.comp (q.pair a)).pair (Procedure.ratMul.comp (q.pair b)) + +def scaledPositions (x : ℚ × Input) : List (ℚ × ℚ) := + (positions x.2).map (fun p => (x.1 * p.1, x.1 * p.2)) + +noncomputable opaque scaledProgram : Procedure scaledInputCode + (listCode ContactRationalGadget.pointCode) scaledPositions := + (Procedure.listMapWith (ea := ratCode) (eb := ContactRationalGadget.pointCode) + (ec := ContactRationalGadget.pointCode) (f := fun q p => (q * p.1, q * p.2)) + (0, 0) (0, 0) scalePointProgram).comp + ((Procedure.first ratCode inputCode).pair + (program.comp (Procedure.second ratCode inputCode))) + +noncomputable def scaledCertificate : Turing.TM2ComputableInPolyTime scaledInputCode + (listCode ContactRationalGadget.pointCode) scaledPositions := scaledProgram.toTM2 + +end ContinuumCoulomb.ContactSourceInputProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactVertexProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactVertexProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e827011ebf45e792dacaffb08f414d1de88150ec --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ContactVertexProgram.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ContactRationalCoordinates +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ContactHeightScheduleProgram +import OAI.Computability.QuantumFactoring.BitStackListOps + +namespace OAI + +/-! Literal polynomial-time rational coordinates for a fixed nine-link +contact path. The height program is followed by four dyadic root evaluations +and the fixed finite prefix sums. -/ + +namespace ContinuumCoulomb.ContactHeightEvaluation +open scoped BigOperators +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque stepXProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => stepX x.1 x.2 k) := by + by_cases hs : k = 2 ∨ k = 3 ∨ k = 5 ∨ k = 6 + · exact (rootProgram k).congrFun (by intro x; simp only [stepX, ite_eq_left hs]) + · exact (lengthProgram k).congrFun (by intro x; simp only [stepX, ite_eq_right hs]) + +noncomputable opaque stepYProgram (k : ℕ) : Procedure inputCode ratCode + (fun x => stepY x.2 k) := by + by_cases hs : k = 2 ∨ k = 3 + · exact heightProgram.congrFun (by intro x; simp only [stepY, ite_eq_left hs]) + · by_cases hs' : k = 5 ∨ k = 6 + · exact (Procedure.ratNeg.comp heightProgram).congrFun (by + intro x + simp only [Function.comp_apply, stepY, ite_eq_right hs, ite_eq_left hs']) + · exact (Procedure.constant inputCode ratCode 0).congrFun (by + intro x + simp only [stepY, ite_eq_right hs, ite_eq_right hs']) + +noncomputable def prefixXProgram : (k : ℕ) → Procedure inputCode ratCode + (fun x => ∑ j ∈ Finset.range k, stepX x.1 x.2 j) + | 0 => (Procedure.constant inputCode ratCode 0).congrFun (by intro x; simp) + | k + 1 => (Procedure.ratAdd.comp ((prefixXProgram k).pair (stepXProgram k))).congrFun + (by intro x; simp only [Function.comp_apply, Finset.sum_range_succ]) + +noncomputable def prefixYProgram : (k : ℕ) → Procedure inputCode ratCode + (fun x => ∑ j ∈ Finset.range k, stepY x.2 j) + | 0 => (Procedure.constant inputCode ratCode 0).congrFun (by intro x; simp) + | k + 1 => (Procedure.ratAdd.comp ((prefixYProgram k).pair (stepYProgram k))).congrFun + (by intro x; simp only [Function.comp_apply, Finset.sum_range_succ]) + +noncomputable opaque coordinateInputProgram : Procedure environmentCode inputCode + (fun e => (e, scheduledValue e)) := + (Procedure.identity environmentCode).pair scheduledProgram + +noncomputable opaque vertexProgram (k : ℕ) : Procedure environmentCode + (prodCode ratCode ratCode) (fun e => vertex e k) := + (((prefixXProgram k).pair (prefixYProgram k)).comp coordinateInputProgram).congrFun + (by intro e; rfl) + +noncomputable def vertexListProgram : (k : ℕ) → Procedure environmentCode + (listCode (prodCode ratCode ratCode)) (fun e => (List.range k).map (vertex e)) + | 0 => (Procedure.constant environmentCode (listCode (prodCode ratCode ratCode)) []).congrFun + (by intro e; rfl) + | k + 1 => by + let singleton := (Procedure.listCons (prodCode ratCode ratCode)).comp + ((vertexProgram k).pair + (Procedure.constant environmentCode (listCode (prodCode ratCode ratCode)) [])) + exact ((Procedure.listAppend (prodCode ratCode ratCode) (0, 0)).comp + ((vertexListProgram k).pair singleton)).congrFun (by + intro e + simp only [Function.comp_apply, List.range_succ, List.map_append, + List.map_cons, List.map_nil]) + +noncomputable def vertexListCertificate : Turing.TM2ComputableInPolyTime + environmentCode (listCode (prodCode ratCode ratCode)) + (fun e => (List.range 10).map (vertex e)) := (vertexListProgram 10).toTM2 + +end ContinuumCoulomb.ContactHeightEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombEvaluationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombEvaluationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e1d88afb3cd2e22c814139e5bbdd4324f4cfb17 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombEvaluationProgram.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombEvaluationError + +namespace OAI + +/-! A single polynomial-time TM2 program for the actual localized +Coulomb coefficient at every rational separation and unary precision. -/ + +namespace ContinuumCoulomb.CoulombEvaluation +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × ℚ +def inputCode : Input → List Bool := prodCode unaryCode ratCode + +noncomputable opaque scaleProgram (k : ℕ) : Procedure unaryCode unaryCode (fun P => k * P) := + ResolventSchedule.mulProgram.comp + ((Procedure.constant unaryCode unaryCode k).pair (Procedure.identity unaryCode)) + +noncomputable opaque sixthProgram : Procedure unaryCode unaryCode (fun P => P ^ 6) := + (ResolventSchedule.squareProgram.comp NormalizationSchedule.cubeProgram).congrFun + (by intro P; simp only [Function.comp_apply]; ring) + +noncomputable opaque truncationPrecisionProgram : Procedure unaryCode unaryCode truncationPrecision := + (scaleProgram 4).comp Procedure.unarySuccessor + +noncomputable opaque capScaleProgram : Procedure unaryCode unaryCode + (fun P => CoulombTruncationSchedule.scale (truncationPrecision P)) := + ((scaleProgram 8).comp (Procedure.unarySuccessor.comp truncationPrecisionProgram)).congrFun + (by intro P; rfl) + +noncomputable opaque denominatorProgram (rho : ℕ) : Procedure unaryCode unaryCode (denominator rho) := + (scaleProgram (CoulombTruncationSchedule.guard (GaussianFrequency.frequency rho))).comp capScaleProgram + +noncomputable opaque radiusProgram (rho : ℕ) : Procedure unaryCode unaryCode (radius rho) := + ((scaleProgram (CoulombTruncationSchedule.guard (GaussianFrequency.frequency rho))).comp + (ResolventSchedule.squareProgram.comp capScaleProgram)).congrFun (by intro P; rfl) + +noncomputable opaque rawPrecisionProgram (rho : ℕ) : Procedure unaryCode unaryCode (rawPrecision rho) := + ((scaleProgram (4 * normalizationBound rho)).comp Procedure.unarySuccessor).congrFun + (by intro P; rfl) + +noncomputable opaque volumeProgram (rho : ℕ) : Procedure unaryCode unaryCode + (fun P => CoulombQuadratureSchedule.volume (radius rho P)) := + (sixthProgram.comp ((scaleProgram 2).comp (radiusProgram rho))).congrFun (by intro P; rfl) + +noncomputable opaque lipschitzProgram (rho : ℕ) : Procedure unaryCode unaryCode + (fun P => CoulombQuadratureSchedule.lipschitz (frequencyBound rho) (radius rho P) (denominator rho P)) := by + let r := radiusProgram rho + let d := denominatorProgram rho + let t := (scaleProgram (2 * frequencyBound rho)).comp r + let k := ResolventSchedule.addProgram.comp ((Procedure.constant unaryCode unaryCode 64).pair t) + let kd := ResolventSchedule.mulProgram.comp (k.pair d) + let dsq := ResolventSchedule.squareProgram.comp d + exact (ResolventSchedule.addProgram.comp (kd.pair dsq)).congrFun (by intro P; rfl) + +noncomputable opaque meshProgram (rho : ℕ) : Procedure unaryCode unaryCode (mesh rho) := by + let r := (scaleProgram 48).comp (radiusProgram rho) + let rl := ResolventSchedule.mulProgram.comp (r.pair (lipschitzProgram rho)) + let rlv := ResolventSchedule.mulProgram.comp (rl.pair (volumeProgram rho)) + exact (ResolventSchedule.mulProgram.comp (rlv.pair (rawPrecisionProgram rho))).congrFun + (by intro P; rfl) + +noncomputable opaque samplePrecisionProgram (rho : ℕ) : + Procedure unaryCode unaryCode (samplePrecision rho) := by + let d := (scaleProgram 32).comp (denominatorProgram rho) + let dv := ResolventSchedule.mulProgram.comp (d.pair (volumeProgram rho)) + exact (ResolventSchedule.mulProgram.comp (dv.pair (rawPrecisionProgram rho))).congrFun + (by intro P; rfl) + +noncomputable opaque kernelPrecisionProgram (rho : ℕ) : + Procedure unaryCode unaryCode (kernelPrecision rho) := by + let d := (scaleProgram 4).comp (ResolventSchedule.squareProgram.comp (denominatorProgram rho)) + let dv := ResolventSchedule.mulProgram.comp (d.pair (volumeProgram rho)) + exact (ResolventSchedule.mulProgram.comp (dv.pair (rawPrecisionProgram rho))).congrFun + (by intro P; rfl) + +noncomputable opaque normalizationPrecisionProgram (rho : ℕ) : + Procedure unaryCode unaryCode (normalizationPrecision rho) := by + let d := (scaleProgram (8 * rawMassBound rho)).comp (denominatorProgram rho) + exact (ResolventSchedule.mulProgram.comp (d.pair Procedure.unarySuccessor)).congrFun + (by intro P; rfl) + +noncomputable opaque radiusRationalProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => (radius rho x.1 : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp + ((radiusProgram rho).comp (Procedure.first unaryCode ratCode))) + +noncomputable opaque meshRationalProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => (mesh rho x.1 : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp + ((meshProgram rho).comp (Procedure.first unaryCode ratCode))) + +noncomputable opaque epsilonProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => 1 / (denominator rho x.1 : ℚ)) := + (Procedure.ratInv.comp (Procedure.natToRat.comp (Procedure.unaryToBits.comp + ((denominatorProgram rho).comp (Procedure.first unaryCode ratCode))))).congrFun + (by intro x; simp only [one_div]; rfl) + +noncomputable opaque inputProgram (rho : ℕ) : + Procedure inputCode (RationalRectangleProgram.inputCode RawCoulombSample.settingsCode) + (fun x => input rho x.1 x.2) := by + let p := Procedure.first unaryCode ratCode + let r := (radiusProgram rho).comp p + let q := (samplePrecisionProgram rho).comp p + let b := (kernelPrecisionProgram rho).comp p + let eps := epsilonProgram rho + let z := Procedure.constant inputCode ratCode (0 : ℚ) + let s := (Procedure.second unaryCode ratCode).pair (z.pair z) + let settings := (r.pair q).pair ((b.pair eps).pair s) + let nr := meshRationalProgram rho + let rr := radiusRationalProgram rho + let low := Procedure.ratNeg.comp rr + let width := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode (2 : ℚ)).pair rr) + let step := Procedure.ratDiv.comp (width.pair nr) + exact (((meshProgram rho).comp p).pair (settings.pair (low.pair step))).congrFun + (by intro x; rfl) + +noncomputable opaque rawProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => rawApproximate rho x.1 x.2) := + ((RawCoulombSample.quadratureProgram rho).comp (inputProgram rho)).congrFun (by intro x; rfl) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode + (fun x => approximate rho x.1 x.2) := by + let p := Procedure.first unaryCode ratCode + let n := (normalizationPrecisionProgram rho).comp p + let c := (CoulombNormalization.program rho).comp n + exact (Procedure.ratMul.comp (c.pair (rawProgram rho))).congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime inputCode ratCode (fun x => approximate rho x.1 x.2) := + (program rho).toTM2 + +end ContinuumCoulomb.CoulombEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombNormalizationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombNormalizationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..664f84726d712a718320f102e64338733786bf97 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombNormalizationProgram.lean @@ -0,0 +1,122 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombNormalizationError + +namespace OAI + +/-! A certified rational evaluator for the fixed Coulomb normalization +factor. The natural guard depends only on the fixed one-well model. -/ + +noncomputable section +namespace ContinuumCoulomb.CoulombNormalization +open ExactQuantumFactoring.BitStackProgram + +def guard (freq : ℝ) : ℕ := Nat.ceil (max 1 (max |freq| + (max (2 / (∫ r, planarResolventMode r ^ 2)) (2 / Real.pi)))) + 1 + +def coefficient (freq : ℝ) : ℝ := freq / ((∫ r, planarResolventMode r ^ 2) ^ 2 * Real.pi) +def factorBound (C : ℕ) : ℕ := C ^ 3 + 3 * C ^ 5 +def precision (rho P : ℕ) : ℕ := + (guard (GaussianFrequency.frequency rho) + factorBound (guard (GaussianFrequency.frequency rho))) * (P + 1) + +def approximate (rho P : ℕ) : ℚ := + GaussianFrequency.approximate rho (precision rho P) / + (NormalizationSchedule.approximate (precision rho P) ^ 2 * + PiProgram.approximate (8 * (precision rho P + 1))) + +theorem guard_bounds (freq : ℝ) : + 1 ≤ (guard freq : ℝ) ∧ |freq| ≤ (guard freq : ℝ) ∧ + 2 ≤ (guard freq : ℝ) * (∫ r, planarResolventMode r ^ 2) ∧ + 2 ≤ (guard freq : ℝ) * Real.pi := by + let M := max 1 (max |freq| (max (2 / (∫ r, planarResolventMode r ^ 2)) (2 / Real.pi))) + have hm : M ≤ (guard freq : ℝ) := by + have hh := Nat.le_ceil M + simp only [guard, Nat.cast_add, Nat.cast_one] + linarith + have h1 : (1 : ℝ) ≤ M := le_max_left _ _ + have hf : |freq| ≤ M := (le_max_left _ _).trans (le_max_right _ _) + have ha : 2 / (∫ r, planarResolventMode r ^ 2) ≤ M := + (le_max_left _ _).trans ((le_max_right _ _).trans (le_max_right _ _)) + have hp : 2 / Real.pi ≤ M := + (le_max_right _ _).trans ((le_max_right _ _).trans (le_max_right _ _)) + exact ⟨h1.trans hm, hf.trans hm, + (div_le_iff₀ planarResolventMode_square_integral_positive).mp (ha.trans hm), + (div_le_iff₀ Real.pi_pos).mp (hp.trans hm)⟩ + +theorem precision_bounds (rho P : ℕ) : + (guard (GaussianFrequency.frequency rho) : ℝ) * ((precision rho P : ℝ) + 1)⁻¹ ≤ 1 ∧ + (factorBound (guard (GaussianFrequency.frequency rho)) : ℝ) * + ((precision rho P : ℝ) + 1)⁻¹ ≤ ((P : ℝ) + 1)⁻¹ := by + let C := (guard (GaussianFrequency.frequency rho) : ℝ) + let K := (factorBound (guard (GaussianFrequency.frequency rho)) : ℝ) + let S := (P : ℝ) + 1 + have hC : 0 ≤ C := Nat.cast_nonneg _ + have hK : 0 ≤ K := Nat.cast_nonneg _ + have hS : 1 ≤ S := by + dsimp [S] + linarith [show (0 : ℝ) ≤ P from Nat.cast_nonneg _] + have hN : (precision rho P : ℝ) = (C + K) * S := by + simp only [precision, Nat.cast_mul, Nat.cast_add, Nat.cast_one, C, K, S] + have hn : (0 : ℝ) < precision rho P + 1 := by positivity + have hCa : C ≤ (precision rho P : ℝ) + 1 := by + rw [hN] + nlinarith [mul_nonneg hK (show 0 ≤ S by linarith)] + have hKa : K * S ≤ (precision rho P : ℝ) + 1 := by + rw [hN] + nlinarith [mul_nonneg hC (show 0 ≤ S by linarith)] + constructor + · change C * ((precision rho P : ℝ) + 1)⁻¹ ≤ 1 + rw [← div_eq_mul_inv] + exact (div_le_one hn).mpr hCa + · change K * ((precision rho P : ℝ) + 1)⁻¹ ≤ S⁻¹ + rw [← div_eq_mul_inv, ← one_div] + exact (div_le_div_iff₀ hn (by linarith : 0 < S)).mpr (by simpa using hKa) + +theorem approximation_error (rho P : ℕ) : + |(approximate rho P : ℝ) - coefficient (GaussianFrequency.frequency rho)| ≤ + ((P : ℝ) + 1)⁻¹ := by + let N := precision rho P + have hc := guard_bounds (GaussianFrequency.frequency rho) + have hπ := PiProgram.error (8 * (N + 1)) (by omega) + have hπ' : |(PiProgram.approximate (8 * (N + 1)) : ℝ) - Real.pi| ≤ ((N : ℝ) + 1)⁻¹ := by + convert hπ using 1 + push_cast + field_simp + have h := coulomb_normalization_error hc.1 planarResolventMode_square_integral_positive + Real.pi_pos hc.2.2.1 hc.2.2.2 hc.2.1 (by positivity) (precision_bounds rho P).1 + (NormalizationSchedule.approximation_error N) hπ' (GaussianFrequency.approximation_error rho N) + have he : (factorBound (guard (GaussianFrequency.frequency rho)) : ℝ) = + (guard (GaussianFrequency.frequency rho) : ℝ) ^ 3 + + 3 * (guard (GaussianFrequency.frequency rho) : ℝ) ^ 5 := by + simp only [factorBound, Nat.cast_add, Nat.cast_pow, Nat.cast_mul, Nat.cast_ofNat] + rw [← he] at h + have h' : |(approximate rho P : ℝ) - coefficient (GaussianFrequency.frequency rho)| ≤ + (factorBound (guard (GaussianFrequency.frequency rho)) : ℝ) * ((N : ℝ) + 1)⁻¹ := by + simpa only [approximate, coefficient, Rat.cast_div, Rat.cast_mul, Rat.cast_pow, N] using h + exact h'.trans (precision_bounds rho P).2 + +noncomputable opaque precisionProgram (rho : ℕ) : Procedure unaryCode unaryCode (precision rho) := by + let c := Procedure.constant unaryCode unaryCode + (guard (GaussianFrequency.frequency rho) + factorBound (guard (GaussianFrequency.frequency rho))) + exact (ResolventSchedule.mulProgram.comp (c.pair Procedure.unarySuccessor)).congrFun (by intro P; rfl) + +noncomputable opaque piCountProgram (rho : ℕ) : Procedure unaryCode unaryCode + (fun P => 8 * (precision rho P + 1)) := + (ResolventSchedule.mulProgram.comp ((Procedure.constant unaryCode unaryCode 8).pair + (Procedure.unarySuccessor.comp (precisionProgram rho)))).congrFun (by intro P; rfl) + +noncomputable opaque program (rho : ℕ) : Procedure unaryCode ratCode (approximate rho) := by + let n := precisionProgram rho + let f := (GaussianFrequency.program rho).comp n + let a := NormalizationSchedule.program.comp n + let p := PiProgram.program.comp (piCountProgram rho) + let a2 := Procedure.ratMul.comp (a.pair a) + exact (Procedure.ratDiv.comp (f.pair (Procedure.ratMul.comp (a2.pair p)))).congrFun + (by intro P; simp only [approximate, pow_two]; rfl) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime unaryCode ratCode (approximate rho) := (program rho).toTM2 + +end ContinuumCoulomb.CoulombNormalization + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a1a49ec1115d11a6692b04c9f4ebb511915b3e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairProgram.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPairEvaluation + +namespace OAI + +/-! Polynomial-time rational evaluation of direct Coulomb matrix entries +from their two rational planar coordinates. -/ + +namespace ContinuumCoulomb.CoulombPairEvaluation +open ExactQuantumFactoring.BitStackProgram + +def pointCode : (ℚ×ℚ) → List Bool := prodCode ratCode ratCode +def pairCode : ((ℚ×ℚ)×(ℚ×ℚ)) → List Bool := prodCode pointCode pointCode +abbrev Input := ℕ×((ℚ×ℚ)×(ℚ×ℚ)) +def inputCode : Input → List Bool := prodCode unaryCode pairCode + +noncomputable opaque squaredDistanceProgram : Procedure pairCode ratCode + (fun x => squaredDistance x.1 x.2) := by + let a := Procedure.first pointCode pointCode + let b := Procedure.second pointCode pointCode + let ax := (Procedure.first ratCode ratCode).comp a + let ay := (Procedure.second ratCode ratCode).comp a + let bx := (Procedure.first ratCode ratCode).comp b + let byCoord := (Procedure.second ratCode ratCode).comp b + let dx := Procedure.ratSub.comp (ax.pair bx) + let dy := Procedure.ratSub.comp (ay.pair byCoord) + let xx := Procedure.ratMul.comp (dx.pair dx) + let yy := Procedure.ratMul.comp (dy.pair dy) + exact (Procedure.ratAdd.comp (xx.pair yy)).congrFun + (by intro x; simp only [squaredDistance,pow_two]; rfl) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode precision := + (ResolventSchedule.mulProgram.comp ((Procedure.constant unaryCode unaryCode 2).pair + Procedure.unarySuccessor)).congrFun (by intro P; rfl) + +noncomputable opaque rootPrecisionProgram (rho : ℕ) : Procedure unaryCode unaryCode (rootPrecision rho) := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant unaryCode unaryCode (4*lipschitzGuard rho)).pair + Procedure.unarySuccessor)).congrFun (by intro P; rfl) + +noncomputable opaque distanceProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => distance rho x.1 x.2.1 x.2.2) := + (RationalSquareRoot.program.comp + (((rootPrecisionProgram rho).comp (Procedure.first unaryCode pairCode)).pair + (squaredDistanceProgram.comp (Procedure.second unaryCode pairCode)))).congrFun (by intro x; rfl) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode + (fun x => approximate rho x.1 x.2.1 x.2.2) := + ((CoulombEvaluation.program rho).comp + ((precisionProgram.comp (Procedure.first unaryCode pairCode)).pair + (distanceProgram rho))).congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => approximate rho x.1 x.2.1 x.2.2) := (program rho).toTM2 + +end ContinuumCoulomb.CoulombPairEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairSumProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairSumProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c51450f060fea383b1c7dc4964329f1e33b8bea9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CoulombPairSumProgram.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombPairSum +import OAI.Computability.QuantumFactoring.NativeAIGAddWrapper + +namespace OAI + +/-! The direct-interaction scalar uses two literal finite list traversals; +its precision increases only polynomially with the number of sites. -/ + +namespace ContinuumCoulomb.CoulombPairSum +open ExactQuantumFactoring.BitStackProgram + +def pointCode : Point → List Bool := CoulombPairEvaluation.pointCode +def inputCode : Input → List Bool := prodCode unaryCode (listCode pointCode) +def rowCode : (ℕ×(Point×List Point)) → List Bool := + prodCode unaryCode (prodCode pointCode (listCode pointCode)) + +noncomputable opaque offsiteProgram (rho : ℕ) : + Procedure CoulombPairEvaluation.inputCode ratCode + (fun x => offsite rho x.1 x.2.1 x.2.2) := by + let pairs := Procedure.second unaryCode CoulombPairEvaluation.pairCode + let dist := CoulombPairEvaluation.squaredDistanceProgram.comp pairs + let test := Procedure.binaryZero.comp (Procedure.intAbs.comp (Procedure.ratNum.comp dist)) + let zero := Procedure.constant CoulombPairEvaluation.inputCode ratCode (0:ℚ) + exact (Procedure.conditional test zero (CoulombPairEvaluation.program rho)).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,Int.natAbs_eq_zero,Rat.num_eq_zero,offsite]) + +noncomputable opaque offsiteEnvironmentProgram (rho : ℕ) : + Procedure (prodCode (prodCode unaryCode pointCode) pointCode) ratCode + (fun x => offsite rho x.1.1 x.1.2 x.2) := by + let env := Procedure.first (prodCode unaryCode pointCode) pointCode + let p := (Procedure.first unaryCode pointCode).comp env + let a := (Procedure.second unaryCode pointCode).comp env + let b := Procedure.second (prodCode unaryCode pointCode) pointCode + exact (offsiteProgram rho).comp (p.pair (a.pair b)) + +noncomputable opaque rowProgram (rho : ℕ) : Procedure rowCode ratCode + (fun x => row rho x.1 x.2.1 x.2.2) := by + let p := Procedure.first unaryCode (prodCode pointCode (listCode pointCode)) + let tail := Procedure.second unaryCode (prodCode pointCode (listCode pointCode)) + let a := (Procedure.first pointCode (listCode pointCode)).comp tail + let sites := (Procedure.second pointCode (listCode pointCode)).comp tail + let mapped := (Procedure.listMapWith (ea := prodCode unaryCode pointCode) + (eb := pointCode) (ec := ratCode) + (f := fun env b => offsite rho env.1 env.2 b) (0,0) 0 + (offsiteEnvironmentProgram rho)).comp ((p.pair a).pair sites) + exact (RationalSumProgram.sumProgram.comp mapped).congrFun (by intro x; rfl) + +noncomputable opaque rowEnvironmentProgram (rho : ℕ) : + Procedure (prodCode inputCode pointCode) ratCode (fun x => row rho x.1.1 x.2 x.1.2) := by + let env := Procedure.first inputCode pointCode + let p := (Procedure.first unaryCode (listCode pointCode)).comp env + let sites := (Procedure.second unaryCode (listCode pointCode)).comp env + let a := Procedure.second inputCode pointCode + exact (rowProgram rho).comp (p.pair (a.pair sites)) + +noncomputable opaque totalProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => total rho x.1 x.2) := by + let sites := Procedure.second unaryCode (listCode pointCode) + let mapped := (Procedure.listMapWith (ea := inputCode) (eb := pointCode) (ec := ratCode) + (f := fun env a => row rho env.1 a env.2) (0,0) 0 + (rowEnvironmentProgram rho)).comp ((Procedure.identity inputCode).pair sites) + let sum := RationalSumProgram.sumProgram.comp mapped + exact (Procedure.ratDiv.comp (sum.pair (Procedure.constant inputCode ratCode 2))).congrFun + (by intro x; rfl) + +noncomputable opaque lengthProgram : Procedure inputCode unaryCode (fun x => x.2.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength pointCode (0,0)).comp + (Procedure.second unaryCode (listCode pointCode)) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode + (fun x => precision x.2.length x.1) := by + let msq := ResolventSchedule.squareProgram.comp (Procedure.unarySuccessor.comp lengthProgram) + let pp := Procedure.unarySuccessor.comp (Procedure.first unaryCode (listCode pointCode)) + exact (ResolventSchedule.mulProgram.comp (msq.pair pp)).congrFun (by intro x; rfl) + +noncomputable opaque argumentProgram : Procedure inputCode inputCode + (fun x => (precision x.2.length x.1,x.2)) := + precisionProgram.pair (Procedure.second unaryCode (listCode pointCode)) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode (value rho) := by + let p := (totalProgram rho).comp argumentProgram + exact p.congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode ratCode + (value rho) := (program rho).toTM2 + +end ContinuumCoulomb.CoulombPairSum + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CountertermProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CountertermProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c96176f8bdfdc65b85ed5f939ade290737a9b45 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/CountertermProgram.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CountertermEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! Literal polynomial programs evaluate the exact counterterm formula +with the error certified in CountertermEvaluation. -/ + +namespace ContinuumCoulomb.CountertermEvaluation +open ExactQuantumFactoring.BitStackProgram + +abbrev EntryInput := CoulombPairEvaluation.Input +abbrev RowInput := ℕ×((ℚ×ℚ)×List (ℚ×ℚ)) +def rowCode : RowInput → List Bool := prodCode unaryCode + (prodCode CoulombPairEvaluation.pointCode (listCode CoulombPairEvaluation.pointCode)) + +noncomputable opaque maxOneProgram : Procedure ratCode ratCode (fun q => max 1 q) := by + let one := Procedure.constant ratCode ratCode (1:ℚ) + let q := Procedure.identity ratCode + let test := Procedure.intSign.comp (Procedure.ratNum.comp (Procedure.ratSub.comp (q.pair one))) + exact (Procedure.conditional test one q).congrFun (by + intro q + simp only [Function.comp_apply,Rat.num_neg,decide_eq_true_eq,id_eq] + by_cases h : q < 1 + · rw [ite_eq_left (by linarith),max_eq_left h.le] + · rw [ite_eq_right (by linarith),max_eq_right (le_of_not_gt h)]) + +noncomputable opaque onsiteArgumentProgram : Procedure unaryCode HoppingSchedule.inputCode + (fun p => ((1,p),0)) := by + let p := Procedure.identity unaryCode + let r := Procedure.constant unaryCode unaryCode 1 + let z := Procedure.constant unaryCode ratCode (0:ℚ) + exact (r.pair p).pair z + +noncomputable opaque onsiteProgram : Procedure unaryCode ratCode + (fun p => ComputableHopping.approximate ((1,p),0)) := + ComputableHopping.program.comp onsiteArgumentProgram + +noncomputable opaque guardProgram (rho : ℕ) : Procedure unaryCode ratCode + (fun _ => (guard rho:ℚ)) := Procedure.constant unaryCode ratCode (guard rho:ℚ) + +noncomputable opaque scaledOnsiteProgram (rho : ℕ) : Procedure unaryCode ratCode + (fun p => (guard rho:ℚ)*ComputableHopping.approximate ((1,p),0)) := + Procedure.ratMul.comp ((guardProgram rho).pair onsiteProgram) + +noncomputable opaque denominatorProgram (rho : ℕ) : Procedure unaryCode ratCode (denominator rho) := + maxOneProgram.comp (scaledOnsiteProgram rho) + +noncomputable opaque entryNumeratorProgram (rho : ℕ) : Procedure CoulombPairEvaluation.inputCode ratCode + (fun x => (guard rho:ℚ)*CoulombPairEvaluation.approximate rho x.1 x.2.1 x.2.2) := by + let C := Procedure.constant CoulombPairEvaluation.inputCode ratCode (guard rho:ℚ) + exact Procedure.ratMul.comp (C.pair (CoulombPairEvaluation.program rho)) + +noncomputable opaque entryDenominatorProgram (rho : ℕ) : Procedure CoulombPairEvaluation.inputCode ratCode + (fun x => denominator rho x.1) := + (denominatorProgram rho).comp (Procedure.first unaryCode CoulombPairEvaluation.pairCode) + +noncomputable opaque entryArgumentsProgram (rho : ℕ) : + Procedure CoulombPairEvaluation.inputCode (prodCode ratCode ratCode) + (fun x => ((guard rho:ℚ)*CoulombPairEvaluation.approximate rho x.1 x.2.1 x.2.2, + denominator rho x.1)) := + (entryNumeratorProgram rho).pair (entryDenominatorProgram rho) + +noncomputable opaque entryProgram (rho : ℕ) : Procedure CoulombPairEvaluation.inputCode ratCode + (fun x => entry rho x.1 x.2.1 x.2.2) := + Procedure.ratDiv.comp (entryArgumentsProgram rho) + +noncomputable opaque offsiteProgram (rho : ℕ) : Procedure CoulombPairEvaluation.inputCode ratCode + (fun x => offsite rho x.1 x.2.1 x.2.2) := by + let pairs := Procedure.second unaryCode CoulombPairEvaluation.pairCode + let dist := CoulombPairEvaluation.squaredDistanceProgram.comp pairs + let test := Procedure.binaryZero.comp (Procedure.intAbs.comp (Procedure.ratNum.comp dist)) + let zero := Procedure.constant CoulombPairEvaluation.inputCode ratCode (0:ℚ) + exact (Procedure.conditional test zero (entryProgram rho)).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,Int.natAbs_eq_zero,Rat.num_eq_zero,offsite]) + +noncomputable opaque offsiteEnvironmentProgram (rho : ℕ) : + Procedure (prodCode (prodCode unaryCode CoulombPairEvaluation.pointCode) + CoulombPairEvaluation.pointCode) ratCode (fun x => offsite rho x.1.1 x.1.2 x.2) := by + let env := Procedure.first (prodCode unaryCode CoulombPairEvaluation.pointCode) + CoulombPairEvaluation.pointCode + let p := (Procedure.first unaryCode CoulombPairEvaluation.pointCode).comp env + let a := (Procedure.second unaryCode CoulombPairEvaluation.pointCode).comp env + let b := Procedure.second (prodCode unaryCode CoulombPairEvaluation.pointCode) + CoulombPairEvaluation.pointCode + exact (offsiteProgram rho).comp (p.pair (a.pair b)) + +noncomputable opaque rowProgram (rho : ℕ) : Procedure rowCode ratCode + (fun x => row rho x.1 x.2.1 x.2.2) := by + let p := Procedure.first unaryCode + (prodCode CoulombPairEvaluation.pointCode (listCode CoulombPairEvaluation.pointCode)) + let tail := Procedure.second unaryCode + (prodCode CoulombPairEvaluation.pointCode (listCode CoulombPairEvaluation.pointCode)) + let a := (Procedure.first CoulombPairEvaluation.pointCode + (listCode CoulombPairEvaluation.pointCode)).comp tail + let sites := (Procedure.second CoulombPairEvaluation.pointCode + (listCode CoulombPairEvaluation.pointCode)).comp tail + let mapped := (Procedure.listMapWith (ea := prodCode unaryCode CoulombPairEvaluation.pointCode) + (eb := CoulombPairEvaluation.pointCode) (ec := ratCode) + (f := fun env b => offsite rho env.1 env.2 b) (0,0) 0 + (offsiteEnvironmentProgram rho)).comp ((p.pair a).pair sites) + exact (RationalSumProgram.sumProgram.comp mapped).congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime rowCode ratCode + (fun x => row rho x.1 x.2.1 x.2.2) := (rowProgram rho).toTM2 + +end ContinuumCoulomb.CountertermEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/DyadicRootProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/DyadicRootProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8255b1c3fa8ea9918f1c7026113452f26330f32f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/DyadicRootProgram.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SquareRootProgram +import OAI.Computability.QuantumFactoring.BitStackRationalDivision + +namespace OAI + +/-! A computed dyadic square root of a nonnegative rational, with strict +error below one unit in the requested binary precision. Precision is unary; +numerator, denominator, and result are binary. -/ + +namespace ContinuumCoulomb.DyadicRootProgram +open ExactQuantumFactoring.BitStackProgram + +def value (b N F : ℕ) : ℚ := + (SquareRootProgram.root (N * (2 ^ b) ^ 2 / F) : ℚ) / (2 : ℚ) ^ b + +theorem value_error (b N F : ℕ) (hF : 0 < F) : + 0 ≤ Real.sqrt ((N : ℝ) / F) - (value b N F : ℝ) ∧ + Real.sqrt ((N : ℝ) / F) - (value b N F : ℝ) < 1 / (2 : ℝ) ^ b := by + let p : ℕ := 2 ^ b + let m : ℕ := N * p ^ 2 / F + let r : ℕ := SquareRootProgram.root m + have hp : (0 : ℝ) < p := by dsimp [p]; positivity + have hFr : (0 : ℝ) < F := by exact_mod_cast hF + have hlo : r ^ 2 * F ≤ N * p ^ 2 := + (Nat.mul_le_mul_right F (SquareRootProgram.root_spec m).1).trans (Nat.div_mul_le_self _ _) + have hhi : N * p ^ 2 < (r + 1) ^ 2 * F := + (Nat.div_lt_iff_lt_mul hF).mp (SquareRootProgram.root_spec m).2 + have hlo' : (r : ℝ) ^ 2 * F ≤ (N : ℝ) * (p : ℝ) ^ 2 := by exact_mod_cast hlo + have hhi' : (N : ℝ) * (p : ℝ) ^ 2 < ((r : ℝ) + 1) ^ 2 * F := by exact_mod_cast hhi + have hrad : 0 ≤ (N : ℝ) / F := by positivity + have hsquare : (Real.sqrt ((N : ℝ) / F) * p) ^ 2 * F = (N : ℝ) * (p : ℝ) ^ 2 := by + rw [mul_pow, Real.sq_sqrt hrad] + field_simp [hFr.ne'] + have hs : 0 ≤ Real.sqrt ((N : ℝ) / F) * p := by positivity + have hslo : (r : ℝ) ^ 2 ≤ (Real.sqrt ((N : ℝ) / F) * p) ^ 2 := by + apply (mul_le_mul_iff_left₀ hFr).mp + rw [hsquare] + exact hlo' + have hshi : (Real.sqrt ((N : ℝ) / F) * p) ^ 2 < ((r : ℝ) + 1) ^ 2 := by + apply (mul_lt_mul_iff_left₀ hFr).mp + rw [hsquare] + exact hhi' + have hl : (r : ℝ) ≤ Real.sqrt ((N : ℝ) / F) * p := by + nlinarith only [hslo, hs, show 0 ≤ (r : ℝ) by positivity] + have hu : Real.sqrt ((N : ℝ) / F) * p < (r : ℝ) + 1 := by + nlinarith only [hshi, hs, show 0 ≤ (r : ℝ) by positivity] + have hvalue : (value b N F : ℝ) = (r : ℝ) / p := by + simp only [value, Rat.cast_div, Rat.cast_natCast, Rat.cast_pow, Rat.cast_ofNat, p, r, m, + Nat.cast_pow, Nat.cast_ofNat] + have hpcast : (p : ℝ) = (2 : ℝ) ^ b := by simp only [p, Nat.cast_pow, Nat.cast_ofNat] + rw [hvalue, ← hpcast] + constructor + · exact sub_nonneg.mpr ((div_le_iff₀ hp).mpr hl) + · apply (lt_div_iff₀ hp).mpr + rw [sub_mul, div_mul_cancel₀ _ hp.ne'] + linarith + +abbrev Input := ℕ × (ℕ × ℕ) + +def rawCode : Input → List Bool := prodCode unaryCode (prodCode Nat.bits Nat.bits) + +noncomputable def precisionProgram : Procedure rawCode unaryCode Prod.fst := + Procedure.first unaryCode (prodCode Nat.bits Nat.bits) + +noncomputable def numeratorProgram : Procedure rawCode Nat.bits (fun x => x.2.1) := + (Procedure.first Nat.bits Nat.bits).comp + (Procedure.second unaryCode (prodCode Nat.bits Nat.bits)) + +noncomputable def denominatorProgram : Procedure rawCode Nat.bits (fun x => x.2.2) := + (Procedure.second Nat.bits Nat.bits).comp + (Procedure.second unaryCode (prodCode Nat.bits Nat.bits)) + +noncomputable def powerProgram : Procedure rawCode Nat.bits (fun x => 2 ^ x.1) := + (Procedure.binaryPow.comp (precisionProgram.pair + (Procedure.constant rawCode Nat.bits 2))).congrFun (by intro x; rfl) + +noncomputable def squareProgram : Procedure rawCode Nat.bits (fun x => (2 ^ x.1) ^ 2) := + (Procedure.binaryMul.comp (powerProgram.pair powerProgram)).congrFun (by intro x; exact (pow_two _).symm) + +noncomputable def quotientProgram : Procedure rawCode Nat.bits + (fun x => x.2.1 * (2 ^ x.1) ^ 2 / x.2.2) := + (Procedure.binaryDiv.comp ((Procedure.binaryMul.comp + (numeratorProgram.pair squareProgram)).pair denominatorProgram)).congrFun (by intro x; rfl) + +noncomputable def rootNumeratorProgram : Procedure rawCode Nat.bits + (fun x => SquareRootProgram.root (x.2.1 * (2 ^ x.1) ^ 2 / x.2.2)) := + SquareRootProgram.rawProgram.comp quotientProgram + +noncomputable def rawProgram : Procedure rawCode ratCode + (fun x => value x.1 x.2.1 x.2.2) := + (Procedure.ratDiv.comp ((Procedure.natToRat.comp rootNumeratorProgram).pair + (Procedure.natToRat.comp powerProgram))).congrFun (by + intro x + simp only [Function.comp_apply, value, Nat.cast_pow, Nat.cast_ofNat]) + +def fractionParameters : BinaryEncoding.Codec (ℕ × ℕ) := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.natural) BinaryEncoding.natural + +def parameters : BinaryEncoding.Codec Input := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.unary) fractionParameters + +theorem parameters_length (b N F : ℕ) : + (parameters.encode (b, N, F)).length = 2 * b + 4 * N.size + 2 * F.size + 7 := by + unfold parameters fractionParameters + rw [BinaryEncoding.pair_length, BinaryEncoding.quoted_length, BinaryEncoding.unary_length, + BinaryEncoding.pair_length, BinaryEncoding.quoted_length, + BinaryEncoding.natural_length, BinaryEncoding.natural_length] + dsimp only [Prod.fst, Prod.snd] + omega + +noncomputable def inputProgram : Procedure parameters.encode rawCode id := by + let b := AmplificationProgram.inputProgram.comp + (EncodingPrograms.quotedFirst BinaryEncoding.unary fractionParameters) + let rest := EncodingPrograms.quotedSecond BinaryEncoding.unary fractionParameters + let n := EncodingPrograms.naturalInput.comp + ((EncodingPrograms.quotedFirst BinaryEncoding.natural BinaryEncoding.natural).comp rest) + let f := EncodingPrograms.naturalInput.comp + ((EncodingPrograms.quotedSecond BinaryEncoding.natural BinaryEncoding.natural).comp rest) + exact (b.pair (n.pair f)).congrFun (by intro x; rfl) + +def output : BinaryEncoding.Codec (ℤ × ℕ) := + BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.natural + +noncomputable def rationalOutput : Procedure ratCode output.encode (fun q => (q.num, q.den)) := by + let num := EncodingPrograms.integerOutput.comp Procedure.ratNum + let den := EncodingPrograms.naturalOutput.comp Procedure.ratDen + exact ((EncodingPrograms.appendPair BinaryEncoding.integer BinaryEncoding.natural).comp + (num.pair den)).congrFun (by intro q; rfl) + +/-- A concrete polynomial machine emits the canonical numerator and +denominator of the certified dyadic approximation. -/ +noncomputable def certificate : + Turing.TM2ComputableInPolyTime parameters.encode output.encode + (fun x => ((value x.1 x.2.1 x.2.2).num, (value x.1 x.2.1 x.2.2).den)) := + (rationalOutput.comp (rawProgram.comp inputProgram)).toTM2 + +end ContinuumCoulomb.DyadicRootProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EncodingPrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EncodingPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a84549506c62f41d1c8e33268453bb38189cb16 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EncodingPrograms.lean @@ -0,0 +1,170 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.AmplificationProgram +import OAI.Computability.QuantumFactoring.BitStackIntegers + +namespace OAI + +/-! Actual finite-stack parsing and serialization routines for the coordinate codes. Sign bits, natural-number marker bits, and field tails +are read by the program rather than by an assumed record-decoding operation. -/ + +namespace ContinuumCoulomb.BinaryEncoding + +/-- Quote a prefix code so an existing word-stack product parser can read +the field. The quoting overhead is exactly linear. -/ +def quoted {α : Type} (c : Codec α) : Codec α where + encode x := encodeDigits (c.encode x) + read s := let (xs, tail) := readDigits s; ((c.read xs).1, tail) + read_encode x tail := by + simp only [readDigits_encode] + have h := congrArg Prod.fst (c.read_encode x []) + simpa only [List.append_nil, Prod.fst] using congrArg (fun a => (a, tail)) h + +theorem quoted_length {α : Type} (c : Codec α) (x : α) : + ((quoted c).encode x).length = 2 * (c.encode x).length + 1 := + encodeDigits_length _ + +end ContinuumCoulomb.BinaryEncoding + +namespace ContinuumCoulomb.EncodingPrograms +open ExactQuantumFactoring.BitStackProgram + +def integerPayload : ℤ → ℕ + | .ofNat n => n + | .negSucc n => n + +def integerNegative : ℤ → Bool + | .ofNat _ => false + | .negSucc _ => true + +noncomputable def naturalInput : Procedure BinaryEncoding.natural.encode Nat.bits id := by + let p := (Procedure.first Nat.bits (fun _ : Unit => [])).precompose (fun n : ℕ => (n, ())) + exact p.congrEncoding (by + intro n + change quoteBits n.bits ++ [] = BinaryEncoding.encodeDigits n.bits + rw [List.append_nil, AmplificationProgram.encodeDigits_quote]) (by intro n; rfl) + +noncomputable def naturalOutput : Procedure Nat.bits BinaryEncoding.natural.encode id := + (Procedure.quote Nat.bits).result + (by intro n; exact (AmplificationProgram.encodeDigits_quote n.bits).symm) + +theorem quotedPair_encoding {α β : Type} (c : BinaryEncoding.Codec α) + (d : BinaryEncoding.Codec β) (x : α × β) : + (BinaryEncoding.pair (BinaryEncoding.quoted c) d).encode x = prodCode c.encode d.encode x := by + change BinaryEncoding.encodeDigits (c.encode x.1) ++ _ = quoteBits (c.encode x.1) ++ _ + rw [AmplificationProgram.encodeDigits_quote] + +noncomputable def quotedFirst {α β : Type} (c : BinaryEncoding.Codec α) + (d : BinaryEncoding.Codec β) : + Procedure (BinaryEncoding.pair (BinaryEncoding.quoted c) d).encode c.encode Prod.fst := + (Procedure.first c.encode d.encode).congrEncoding + (fun x => (quotedPair_encoding c d x).symm) (by intro x; rfl) + +noncomputable def quotedSecond {α β : Type} (c : BinaryEncoding.Codec α) + (d : BinaryEncoding.Codec β) : + Procedure (BinaryEncoding.pair (BinaryEncoding.quoted c) d).encode d.encode Prod.snd := + (Procedure.second c.encode d.encode).congrEncoding + (fun x => (quotedPair_encoding c d x).symm) (by intro x; rfl) + +/-- Serialize two already encoded fields by actual word concatenation. -/ +noncomputable def appendPair {α β : Type} (c : BinaryEncoding.Codec α) + (d : BinaryEncoding.Codec β) : + Procedure (prodCode c.encode d.encode) (BinaryEncoding.pair c d).encode id := + (Procedure.append.precompose (fun x : α × β => (c.encode x.1, d.encode x.2))).result + (by intro x; rfl) + +theorem naturalPair_encoding {α : Type} (c : BinaryEncoding.Codec α) (x : ℕ × α) : + prodCode Nat.bits c.encode x = (BinaryEncoding.pair BinaryEncoding.natural c).encode x := by + change quoteBits x.1.bits ++ _ = BinaryEncoding.encodeDigits x.1.bits ++ _ + rw [AmplificationProgram.encodeDigits_quote] + +noncomputable def naturalFirst {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.natural c).encode Nat.bits Prod.fst := + (Procedure.first Nat.bits c.encode).congrEncoding (naturalPair_encoding c) (by intro n; rfl) + +noncomputable def naturalSecond {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.natural c).encode c.encode Prod.snd := + (Procedure.second Nat.bits c.encode).congrEncoding (naturalPair_encoding c) (by intro n; rfl) + +/-- Read and remove the actual sign bit, retaining the coordinate payload +and the entire following encoded field. -/ +noncomputable def integerPairPayload {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.integer c).encode + (prodCode Nat.bits c.encode) (fun x => (integerPayload x.1, x.2)) := + (Procedure.tail.precompose (BinaryEncoding.pair BinaryEncoding.integer c).encode).result (by + rintro ⟨z, y⟩ + cases z with + | ofNat n => + change BinaryEncoding.encodeDigits n.bits ++ c.encode y = quoteBits n.bits ++ c.encode y + rw [AmplificationProgram.encodeDigits_quote] + | negSucc n => + change BinaryEncoding.encodeDigits n.bits ++ c.encode y = quoteBits n.bits ++ c.encode y + rw [AmplificationProgram.encodeDigits_quote]) + +noncomputable def integerPairSign {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.integer c).encode Procedure.boolCode + (fun x => integerNegative x.1) := + (Procedure.head.precompose (BinaryEncoding.pair BinaryEncoding.integer c).encode).congrFun (by + rintro ⟨z, y⟩ + cases z <;> rfl) + +noncomputable def integerFirst {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.integer c).encode intCode Prod.fst := by + let payload := (Procedure.first Nat.bits c.encode).comp (integerPairPayload c) + let positive := Procedure.natToInt.comp payload + let negative := Procedure.intNeg.comp (Procedure.natToInt.comp + (Procedure.successor.comp payload)) + exact (Procedure.conditional (integerPairSign c) negative positive).congrFun (by + rintro ⟨z, y⟩ + cases z with + | ofNat n => rfl + | negSucc n => + change -(↑(n + 1) : ℤ) = Int.negSucc n + omega) + +noncomputable def integerSecond {α : Type} (c : BinaryEncoding.Codec α) : + Procedure (BinaryEncoding.pair BinaryEncoding.integer c).encode c.encode Prod.snd := + ((Procedure.second Nat.bits c.encode).comp (integerPairPayload c)).congrFun (by intro x; rfl) + +def emptyUnit : BinaryEncoding.Codec Unit where + encode _ := [] + read s := ((), s) + read_encode x tail := by cases x; rfl + +noncomputable def integerInput : Procedure BinaryEncoding.integer.encode intCode id := + ((integerFirst emptyUnit).precompose (fun z => (z, ()))).congrEncoding + (by intro z; exact List.append_nil _) (by intro z; rfl) + +/-- Convert signed-magnitude stack integers to the exact signed-coordinate convention +whose negative payload is one less than its absolute value. -/ +noncomputable def integerOutput : Procedure intCode BinaryEncoding.integer.encode id := by + let positivePrefix : Procedure Nat.bits BinaryEncoding.integer.encode (fun n => (n : ℤ)) := + ((Procedure.prepend BinaryEncoding.natural.encode [false]).comp naturalOutput).result + (by intro n; rfl) + let negativePrefix : Procedure Nat.bits BinaryEncoding.integer.encode + (fun n => Int.negSucc n) := + ((Procedure.prepend BinaryEncoding.natural.encode [true]).comp naturalOutput).result + (by intro n; rfl) + let magnitudePred := Procedure.binarySub.comp + (Procedure.intAbs.pair (Procedure.constant intCode Nat.bits 1)) + exact (Procedure.conditional Procedure.intSign + (negativePrefix.comp magnitudePred) (positivePrefix.comp Procedure.intAbs)).congrFun (by + intro z + cases z <;> simp) + +/-- Scaling and translating a signed lattice coordinate uses genuine binary +arithmetic and emits the signed-coordinate code. -/ +noncomputable def affineCoordinate (scale offset : ℤ) : + Procedure BinaryEncoding.integer.encode BinaryEncoding.integer.encode + (fun z => scale * z + offset) := by + let product := Procedure.intMul.comp + ((Procedure.constant BinaryEncoding.integer.encode intCode scale).pair integerInput) + let sum := Procedure.intAdd.comp + (product.pair (Procedure.constant BinaryEncoding.integer.encode intCode offset)) + exact (integerOutput.comp sum).congrFun (by intro z; rfl) + +noncomputable def affineCoordinate_certificate (scale offset : ℤ) : + Turing.TM2ComputableInPolyTime BinaryEncoding.integer.encode BinaryEncoding.integer.encode + (fun z => scale * z + offset) := (affineCoordinate scale offset).toTM2 + +end ContinuumCoulomb.EncodingPrograms + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EnumeratedGridNuclei.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EnumeratedGridNuclei.lean new file mode 100644 index 0000000000000000000000000000000000000000..cac974a565ede21877aa0dcca3c2bf721976ad7e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EnumeratedGridNuclei.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CenteredGaussEquiv +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GridNuclei +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.FormStability + +namespace OAI + +/-! The centered label list and the analytic finite grid describe the same +nuclear cloud, including after physical dilation. -/ + +noncomputable section +open MeasureTheory +open scoped BigOperators Classical +namespace ContinuumCoulomb + +theorem formGroundEnergy_eq_of_attraction {m l : ℕ} (S : Coulomb.Nuclei m) + (T : Coulomb.Nuclei l) (h : ∀ x, Coulomb.attraction S x=Coulomb.attraction T x) (n : ℕ) : + formGroundEnergy S n=formGroundEnergy T n := by + have he (w : Coulomb.H1Vector n) : Coulomb.form S w=Coulomb.form T w := by + unfold Coulomb.form Coulomb.nuclearEnergy + simp_rw [h] + simp only [formGroundEnergy,he] + +instance centeredGridIndices_nonempty (r : Fin 3 → ℕ) : + Nonempty {k // k ∈ centeredGridIndices r} := + ⟨⟨0,(mem_centeredGridIndices r 0).mpr (fun i => by simp)⟩⟩ + +namespace CenteredGaussLabels + +private theorem gauss_point_injective {h : ℝ} (hh : 0 < h) : + Function.Injective (gaussLatticePoint h) := by + intro a b hab + by_contra hne + have hs := gaussLatticePoint_separation hh a b hne + rw [hab,sub_self,norm_zero] at hs + linarith + +def nuclei (r : Radii) (G : Position → Position) (hG : Function.Injective G) + {h : ℝ} (hh : 0 < h) : Coulomb.Nuclei (labels r).length where + nonempty := by rw [labels_length]; positivity + position a := G (gaussLatticePoint h (RationalGaussNodes.index ((labels r).get a).1 ((labels r).get a).2)) + distinct := by + intro a b hab + have he := gauss_point_injective hh (hG hab) + apply (enumerationEquiv r).injective + apply Prod.ext + · apply Subtype.ext + exact congrArg (fun x : GaussLatticeIndex => x.1) he + · exact congrArg (fun x : GaussLatticeIndex => x.2) he + charge _ := 1 + charge_ge_one _ := le_rfl + +theorem nuclei_attraction (r : Radii) (G : Position → Position) (hG : Function.Injective G) + {h : ℝ} (hh : 0 < h) (x : Position) : + Coulomb.attraction (nuclei r G hG hh) x = + Coulomb.attraction + (gridNuclei (fun k : {k // k ∈ centeredGridIndices (radiiVector r)} => k.val) + Subtype.val_injective G hG hh) x := by + rw [gridNuclei_attraction] + simp only [Coulomb.attraction,nuclei,one_mul] + simpa only [Fintype.sum_prod_type,gridGaussIndex] using + sum_enumeration r (fun a => Coulomb.coulombKernel (x-G (gaussLatticePoint h a))) + +theorem nuclei_ground (r : Radii) (G : Position → Position) (hG : Function.Injective G) + {h : ℝ} (hh : 0 < h) (n : ℕ) : + formGroundEnergy (nuclei r G hG hh) n = + formGroundEnergy + (gridNuclei (fun k : {k // k ∈ centeredGridIndices (radiiVector r)} => k.val) + Subtype.val_injective G hG hh) n := + formGroundEnergy_eq_of_attraction _ _ (nuclei_attraction r G hG hh) n + +theorem dilated_nuclei_ground (r : Radii) (G : Position → Position) (hG : Function.Injective G) + {h scale : ℝ} (hh : 0 < h) (hs : 0 < scale) (n : ℕ) : + formGroundEnergy (dilatedNuclei (nuclei r G hG hh) scale hs.ne') n = + formGroundEnergy (dilatedNuclei + (gridNuclei (fun k : {k // k ∈ centeredGridIndices (radiiVector r)} => k.val) + Subtype.val_injective G hG hh) scale hs.ne') n := by + apply formGroundEnergy_eq_of_attraction + intro x + rw [attraction_dilatedNuclei _ hs,attraction_dilatedNuclei _ hs,nuclei_attraction] + +theorem nuclei_totalCharge (r : Radii) (G : Position → Position) (hG : Function.Injective G) + {h : ℝ} (hh : 0 < h) : Coulomb.totalCharge (nuclei r G hG hh)=(labels r).length := by + simp [Coulomb.totalCharge,nuclei] + +end CenteredGaussLabels +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ca865e27d4a2df37fdb1588df9c8d2615ce3840 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerProgram.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EulerVectorPrograms + +namespace OAI + +/-! The bounded-register Euler loop is an actual polynomial-time TM2 +program whenever its field sampler is one. The size invariant was proved +for arbitrary sampler outputs, so this certificate holds on all inputs. -/ + +namespace ContinuumCoulomb.EulerRegisters +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) + +variable {E : Type} {ce : E → List Bool} + +noncomputable opaque parametersProgram : Procedure (configCode ce) (parametersCode ce) Prod.fst := + Procedure.first (parametersCode ce) (prodCode Nat.bits registersCode) +noncomputable opaque environmentProgram : Procedure (configCode ce) ce (fun c : Config E => c.1.1) := + (Procedure.first ce (prodCode Nat.bits (prodCode Nat.bits ratCode))).comp parametersProgram +noncomputable opaque parameterTailProgram : Procedure (configCode ce) + (prodCode Nat.bits (prodCode Nat.bits ratCode)) (fun c : Config E => c.1.2) := + (Procedure.second ce _).comp parametersProgram +noncomputable opaque denominatorProgram : Procedure (configCode ce) Nat.bits (fun c : Config E => c.1.2.1) := + (Procedure.first Nat.bits _).comp parameterTailProgram +noncomputable opaque boxStepProgram : Procedure (configCode ce) (prodCode Nat.bits ratCode) + (fun c : Config E => c.1.2.2) := (Procedure.second Nat.bits _).comp parameterTailProgram +noncomputable opaque boxProgram : Procedure (configCode ce) Nat.bits (fun c : Config E => c.1.2.2.1) := + (Procedure.first Nat.bits ratCode).comp boxStepProgram +noncomputable opaque stepProgram : Procedure (configCode ce) ratCode (fun c : Config E => c.1.2.2.2) := + (Procedure.second Nat.bits ratCode).comp boxStepProgram +noncomputable opaque stateProgram : Procedure (configCode ce) (prodCode Nat.bits registersCode) Prod.snd := + Procedure.second (parametersCode ce) (prodCode Nat.bits registersCode) +noncomputable opaque counterProgram : Procedure (configCode ce) Nat.bits (fun c : Config E => c.2.1) := + (Procedure.first Nat.bits registersCode).comp stateProgram +noncomputable opaque registersProgram : Procedure (configCode ce) registersCode (fun c : Config E => c.2.2) := + (Procedure.second Nat.bits registersCode).comp stateProgram + +noncomputable opaque currentPointProgram : Procedure (configCode ce) tripleCode + (fun c : Config E => point c.1.2.1 c.2.2) := + pointProgram.comp (denominatorProgram.pair registersProgram) + +noncomputable opaque timeProgram : Procedure (configCode ce) ratCode + (fun c : Config E => (c.2.1:ℚ)*c.1.2.2.2) := + Procedure.ratMul.comp ((Procedure.natToRat.comp counterProgram).pair stepProgram) + +noncomputable opaque sampleArgumentsProgram : + Procedure (configCode ce) (prodCode ce (prodCode ratCode tripleCode)) + (fun c : Config E => (c.1.1,((c.2.1:ℚ)*c.1.2.2.2,point c.1.2.1 c.2.2))) := + environmentProgram.pair (timeProgram.pair currentPointProgram) + +variable {evaluate : E → ℚ → Triple → Triple} + +noncomputable opaque velocityProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (configCode ce) tripleCode (fun c : Config E => + evaluate c.1.1 ((c.2.1:ℚ)*c.1.2.2.2) (point c.1.2.1 c.2.2)) := + sampleProgram.comp sampleArgumentsProgram + +noncomputable opaque proposalArgumentsProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (configCode ce) proposalCode (fun c : Config E => + (c.1.2.2.2,(point c.1.2.1 c.2.2,evaluate c.1.1 ((c.2.1:ℚ)*c.1.2.2.2) (point c.1.2.1 c.2.2)))) := + stepProgram.pair (currentPointProgram.pair (velocityProgram sampleProgram)) + +noncomputable opaque nextPointProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (configCode ce) tripleCode (fun c : Config E => + proposal c.1.2.2.2 (point c.1.2.1 c.2.2) + (evaluate c.1.1 ((c.2.1:ℚ)*c.1.2.2.2) (point c.1.2.1 c.2.2))) := + proposalProgram.comp (proposalArgumentsProgram sampleProgram) + +noncomputable opaque nextRegistersProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (configCode ce) registersCode (fun c : Config E => + round c.1.2.1 c.1.2.2.1 (proposal c.1.2.2.2 (point c.1.2.1 c.2.2) + (evaluate c.1.1 ((c.2.1:ℚ)*c.1.2.2.2) (point c.1.2.1 c.2.2)))) := + roundProgram.comp ((denominatorProgram.pair boxProgram).pair (nextPointProgram sampleProgram)) + +noncomputable opaque advanceProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (configCode ce) (configCode ce) (advance evaluate) := + parametersProgram.pair ((Procedure.successor.comp counterProgram).pair + (nextRegistersProgram sampleProgram)) + +noncomputable opaque repeatProgram + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (prodCode unaryCode (configCode ce)) (configCode ce) + (fun x => (advance evaluate)^[x.1] x.2) := + (advanceProgram sampleProgram).iterate (32*(Polynomial.X+1)^2) + (iterate_code_bound ce evaluate) + +def run (evaluate : E → ℚ → Triple → Triple) (x : ℕ×Config E) : Triple := + let c := (advance evaluate)^[x.1] x.2 + point c.1.2.1 c.2.2 + +noncomputable opaque program + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Procedure (prodCode unaryCode (configCode ce)) tripleCode (run evaluate) := + currentPointProgram.comp (repeatProgram sampleProgram) + +noncomputable def certificate + (sampleProgram : Procedure (prodCode ce (prodCode ratCode tripleCode)) tripleCode + (fun x => evaluate x.1 x.2.1 x.2.2)) : + Turing.TM2ComputableInPolyTime (prodCode unaryCode (configCode ce)) tripleCode (run evaluate) := + (program sampleProgram).toTM2 + +end ContinuumCoulomb.EulerRegisters + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerVectorPrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerVectorPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..c81efc33fe0a630f96db5d3941ebe667f293aa07 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/EulerVectorPrograms.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.EulerRegisters + +namespace OAI + +/-! Rational vector arithmetic and bounded rounding for the three Euler +registers. These are literal finite compositions of integer and rational +stack programs. -/ + +namespace ContinuumCoulomb.EulerRegisters +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) + +def pointInputCode : (ℕ×Registers) → List Bool := prodCode Nat.bits registersCode +def proposalCode : (ℚ×(Triple×Triple)) → List Bool := prodCode ratCode (prodCode tripleCode tripleCode) +def roundInputCode : ((ℕ×ℕ)×Triple) → List Bool := prodCode (prodCode Nat.bits Nat.bits) tripleCode + +noncomputable opaque pointDenominatorProgram : Procedure pointInputCode ratCode + (fun x => (x.1:ℚ)) := Procedure.natToRat.comp (Procedure.first Nat.bits registersCode) +noncomputable opaque pointRegistersProgram : Procedure pointInputCode registersCode Prod.snd := + Procedure.second Nat.bits registersCode +noncomputable opaque firstRegisterProgram : Procedure registersCode intCode Prod.fst := + Procedure.first intCode (prodCode intCode intCode) +noncomputable opaque tailRegisterProgram : Procedure registersCode (prodCode intCode intCode) Prod.snd := + Procedure.second intCode (prodCode intCode intCode) +noncomputable opaque secondRegisterProgram : Procedure registersCode intCode (fun r => r.2.1) := + (Procedure.first intCode intCode).comp tailRegisterProgram +noncomputable opaque thirdRegisterProgram : Procedure registersCode intCode (fun r => r.2.2) := + (Procedure.second intCode intCode).comp tailRegisterProgram + +noncomputable opaque pointFirstProgram : Procedure pointInputCode ratCode (fun x => (x.2.1:ℚ)/x.1) := + Procedure.ratDiv.comp ((Procedure.intToRat.comp (firstRegisterProgram.comp pointRegistersProgram)).pair + pointDenominatorProgram) +noncomputable opaque pointSecondProgram : Procedure pointInputCode ratCode (fun x => (x.2.2.1:ℚ)/x.1) := + Procedure.ratDiv.comp ((Procedure.intToRat.comp (secondRegisterProgram.comp pointRegistersProgram)).pair + pointDenominatorProgram) +noncomputable opaque pointThirdProgram : Procedure pointInputCode ratCode (fun x => (x.2.2.2:ℚ)/x.1) := + Procedure.ratDiv.comp ((Procedure.intToRat.comp (thirdRegisterProgram.comp pointRegistersProgram)).pair + pointDenominatorProgram) + +noncomputable opaque pointProgram : Procedure pointInputCode tripleCode (fun x => point x.1 x.2) := + pointFirstProgram.pair (pointSecondProgram.pair pointThirdProgram) + +noncomputable opaque tripleFirstProgram : Procedure tripleCode ratCode Prod.fst := + Procedure.first ratCode (prodCode ratCode ratCode) +noncomputable opaque tripleTailProgram : Procedure tripleCode (prodCode ratCode ratCode) Prod.snd := + Procedure.second ratCode (prodCode ratCode ratCode) +noncomputable opaque tripleSecondProgram : Procedure tripleCode ratCode (fun q => q.2.1) := + (Procedure.first ratCode ratCode).comp tripleTailProgram +noncomputable opaque tripleThirdProgram : Procedure tripleCode ratCode (fun q => q.2.2) := + (Procedure.second ratCode ratCode).comp tripleTailProgram + +noncomputable opaque proposalStepProgram : Procedure proposalCode ratCode Prod.fst := + Procedure.first ratCode (prodCode tripleCode tripleCode) +noncomputable opaque proposalPairProgram : Procedure proposalCode (prodCode tripleCode tripleCode) Prod.snd := + Procedure.second ratCode (prodCode tripleCode tripleCode) +noncomputable opaque proposalPointProgram : Procedure proposalCode tripleCode (fun x => x.2.1) := + (Procedure.first tripleCode tripleCode).comp proposalPairProgram +noncomputable opaque proposalVelocityProgram : Procedure proposalCode tripleCode (fun x => x.2.2) := + (Procedure.second tripleCode tripleCode).comp proposalPairProgram + +noncomputable opaque proposalCoordinateProgram {f : Triple → ℚ} (p : Procedure tripleCode ratCode f) : + Procedure proposalCode ratCode (fun x => f x.2.1+x.1*f x.2.2) := by + let a := p.comp proposalPointProgram + let b := p.comp proposalVelocityProgram + exact Procedure.ratAdd.comp (a.pair (Procedure.ratMul.comp (proposalStepProgram.pair b))) + +noncomputable opaque proposalProgram : Procedure proposalCode tripleCode + (fun x => proposal x.1 x.2.1 x.2.2) := + (proposalCoordinateProgram tripleFirstProgram).pair + ((proposalCoordinateProgram tripleSecondProgram).pair (proposalCoordinateProgram tripleThirdProgram)) + +noncomputable opaque roundParametersProgram : Procedure roundInputCode (prodCode Nat.bits Nat.bits) Prod.fst := + Procedure.first (prodCode Nat.bits Nat.bits) tripleCode +noncomputable opaque roundPointProgram : Procedure roundInputCode tripleCode Prod.snd := + Procedure.second (prodCode Nat.bits Nat.bits) tripleCode + +noncomputable opaque roundCoordinateProgram {f : Triple → ℚ} (p : Procedure tripleCode ratCode f) : + Procedure roundInputCode intCode (fun x => RationalBoxRound.numerator x.1.1 x.1.2 (f x.2)) := + RationalBoxRound.numeratorProgram.comp (roundParametersProgram.pair (p.comp roundPointProgram)) + +noncomputable opaque roundProgram : Procedure roundInputCode registersCode + (fun x => round x.1.1 x.1.2 x.2) := + (roundCoordinateProgram tripleFirstProgram).pair + ((roundCoordinateProgram tripleSecondProgram).pair (roundCoordinateProgram tripleThirdProgram)) + +end ContinuumCoulomb.EulerRegisters + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/FiniteDifferenceProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/FiniteDifferenceProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f178bc7008dfb25cd883f71fb58e4c8db2125a8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/FiniteDifferenceProgram.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalFieldDifferences + +namespace OAI + +/-! Literal rational programs for the three fixed coordinate differences. +Their scalar sampler is supplied as a concrete Procedure, and is evaluated +only a fixed number of times per gradient or Laplacian sample. -/ + +namespace ContinuumCoulomb.FiniteDifferenceProgram +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) +open RationalFieldDifferences + +noncomputable opaque shiftProgram (a : Fin 3) : Procedure (prodCode tripleCode ratCode) tripleCode + (fun x => shift x.1 x.2 a) := by + let q := Procedure.first tripleCode ratCode + let h := Procedure.second tripleCode ratCode + let zero := Procedure.constant (prodCode tripleCode ratCode) ratCode (0:ℚ) + let x := (Procedure.first ratCode (prodCode ratCode ratCode)).comp q + let yz := (Procedure.second ratCode (prodCode ratCode ratCode)).comp q + let y := (Procedure.first ratCode ratCode).comp yz + let z := (Procedure.second ratCode ratCode).comp yz + let dx : Procedure (prodCode tripleCode ratCode) ratCode (fun z => if a=0 then z.2 else 0) := by + by_cases ha : a=0 + · exact h.congrFun (by intro z; simp only [ha,ite_true]) + · exact zero.congrFun (by intro z; simp only [ha,ite_false]) + let dy : Procedure (prodCode tripleCode ratCode) ratCode (fun z => if a=1 then z.2 else 0) := by + by_cases ha : a=1 + · exact h.congrFun (by intro z; simp only [ha,ite_true]) + · exact zero.congrFun (by intro z; simp only [ha,ite_false]) + let dz : Procedure (prodCode tripleCode ratCode) ratCode (fun z => if a=2 then z.2 else 0) := by + by_cases ha : a=2 + · exact h.congrFun (by intro z; simp only [ha,ite_true]) + · exact zero.congrFun (by intro z; simp only [ha,ite_false]) + let xx := Procedure.ratAdd.comp (x.pair dx) + let yy := Procedure.ratAdd.comp (y.pair dy) + let zz := Procedure.ratAdd.comp (z.pair dz) + exact (xx.pair (yy.pair zz)).congrFun (by intro x; rfl) + +variable {E : Type} {ce : E → List Bool} {sample : E → Triple → ℚ} {step : E → ℚ} + +noncomputable opaque plusArgumentProgram (a : Fin 3) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) tripleCode (fun x => shift x.2 (step x.1) a) := + (shiftProgram a).comp ((Procedure.second ce tripleCode).pair + (stepProgram.comp (Procedure.first ce tripleCode))) + +noncomputable opaque minusArgumentProgram (a : Fin 3) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) tripleCode (fun x => shift x.2 (-step x.1) a) := + (shiftProgram a).comp ((Procedure.second ce tripleCode).pair + (Procedure.ratNeg.comp (stepProgram.comp (Procedure.first ce tripleCode)))) + +noncomputable opaque plusSampleProgram (a : Fin 3) + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 (shift x.2 (step x.1) a)) := + sampleProgram.comp ((Procedure.first ce tripleCode).pair (plusArgumentProgram a stepProgram)) + +noncomputable opaque minusSampleProgram (a : Fin 3) + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 (shift x.2 (-step x.1) a)) := + sampleProgram.comp ((Procedure.first ce tripleCode).pair (minusArgumentProgram a stepProgram)) + +noncomputable opaque firstProgram (a : Fin 3) + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode + (fun x => first (sample x.1) (step x.1) x.2 a) := by + let diff := Procedure.ratSub.comp ((plusSampleProgram a sampleProgram stepProgram).pair sampleProgram) + exact Procedure.ratDiv.comp (diff.pair (stepProgram.comp (Procedure.first ce tripleCode))) + +noncomputable opaque secondNumeratorProgram (a : Fin 3) + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode (fun x => + sample x.1 (shift x.2 (step x.1) a)+sample x.1 (shift x.2 (-step x.1) a)-2*sample x.1 x.2) := by + let ends := Procedure.ratAdd.comp ((plusSampleProgram a sampleProgram stepProgram).pair + (minusSampleProgram a sampleProgram stepProgram)) + let center := Procedure.ratMul.comp + ((Procedure.constant (prodCode ce tripleCode) ratCode (2:ℚ)).pair sampleProgram) + exact Procedure.ratSub.comp (ends.pair center) + +noncomputable opaque stepSquareProgram (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode (fun x => step x.1^2) := by + let h := stepProgram.comp (Procedure.first ce tripleCode) + exact (Procedure.ratMul.comp (h.pair h)).congrFun (by intro x; simp only [pow_two]; rfl) + +noncomputable opaque secondProgram (a : Fin 3) + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode + (fun x => second (sample x.1) (step x.1) x.2 a) := + Procedure.ratDiv.comp ((secondNumeratorProgram a sampleProgram stepProgram).pair + (stepSquareProgram stepProgram)) + +noncomputable opaque laplacianProgram + (sampleProgram : Procedure (prodCode ce tripleCode) ratCode (fun x => sample x.1 x.2)) + (stepProgram : Procedure ce ratCode step) : + Procedure (prodCode ce tripleCode) ratCode + (fun x => laplacian (sample x.1) (step x.1) x.2) := by + let p0 := secondProgram (0:Fin 3) sampleProgram stepProgram + let p1 := secondProgram (1:Fin 3) sampleProgram stepProgram + let p2 := secondProgram (2:Fin 3) sampleProgram stepProgram + exact (Procedure.ratAdd.comp (p0.pair (Procedure.ratAdd.comp (p1.pair p2)))).congrFun (by + intro x + simp only [RationalFieldDifferences.laplacian,Fin.sum_univ_succ,Fin.sum_univ_zero,add_zero] + rfl) + +end ContinuumCoulomb.FiniteDifferenceProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussNodeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussNodeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c68a0b1f30e15ff9e10b888a149ad5405f93a79b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussNodeProgram.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalGaussNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EulerVectorPrograms + +namespace OAI + +/-! Literal polynomial-time generation of an initial rational tensor-Gauss +node. Integer lattice coordinates and the reciprocal mesh denominator are +binary; the approximation precision is unary. -/ + +namespace ContinuumCoulomb.RationalGaussNodes +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) +open EulerRegisters (registersCode) + +def signsCode : Signs → List Bool := prodCode Procedure.boolCode + (prodCode Procedure.boolCode Procedure.boolCode) +abbrev Input := ℕ×(ℕ×(EulerRegisters.Registers×Signs)) +def inputCode : Input → List Bool := prodCode unaryCode (prodCode Nat.bits (prodCode registersCode signsCode)) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode (fun P => 2*(P+1)) := + Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode 2).pair Procedure.unarySuccessor) +noncomputable opaque abscissaProgram : Procedure unaryCode ratCode abscissa := by + let p := RationalSquareRoot.program.comp (precisionProgram.pair + (Procedure.constant unaryCode ratCode (1/3:ℚ))) + exact p.congrFun (by intro P; rfl) +noncomputable opaque signedProgram : Procedure (prodCode unaryCode Procedure.boolCode) ratCode + (fun x => signed x.1 x.2) := by + let p := abscissaProgram.comp (Procedure.first unaryCode Procedure.boolCode) + let b := Procedure.second unaryCode Procedure.boolCode + exact (Procedure.conditional b p (Procedure.ratNeg.comp p)).congrFun (by + intro x + cases h : x.2 <;> simp only [Function.comp_apply,Bool.false_eq_true,ite_false,ite_true,signed]) + +abbrev CoordinateInput := (ℕ×ℕ)×(ℤ×Bool) +def coordinateCode : CoordinateInput → List Bool := prodCode (prodCode unaryCode Nat.bits) + (prodCode intCode Procedure.boolCode) +noncomputable opaque coordinateParametersProgram : Procedure coordinateCode (prodCode unaryCode Nat.bits) Prod.fst := + Procedure.first _ _ +noncomputable opaque coordinateDataProgram : Procedure coordinateCode (prodCode intCode Procedure.boolCode) Prod.snd := + Procedure.second _ _ +noncomputable opaque coordinatePrecisionProgram : Procedure coordinateCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode Nat.bits).comp coordinateParametersProgram +noncomputable opaque coordinateDenominatorProgram : Procedure coordinateCode ratCode (fun x => (x.1.2:ℚ)) := + Procedure.natToRat.comp ((Procedure.second unaryCode Nat.bits).comp coordinateParametersProgram) +noncomputable opaque coordinateIntegerProgram : Procedure coordinateCode ratCode (fun x => (x.2.1:ℚ)) := + Procedure.intToRat.comp ((Procedure.first intCode Procedure.boolCode).comp coordinateDataProgram) +noncomputable opaque coordinateSignProgram : Procedure coordinateCode Procedure.boolCode (fun x => x.2.2) := + (Procedure.second intCode Procedure.boolCode).comp coordinateDataProgram +noncomputable opaque coordinateHalfProgram : Procedure coordinateCode ratCode + (fun x => signed x.1.1 x.2.2/2) := + Procedure.ratDiv.comp ((signedProgram.comp (coordinatePrecisionProgram.pair coordinateSignProgram)).pair + (Procedure.constant coordinateCode ratCode (2:ℚ))) +noncomputable opaque coordinateProgram : Procedure coordinateCode ratCode + (fun x => ((x.2.1:ℚ)+signed x.1.1 x.2.2/2)/x.1.2) := + Procedure.ratDiv.comp ((Procedure.ratAdd.comp (coordinateIntegerProgram.pair coordinateHalfProgram)).pair + coordinateDenominatorProgram) + +noncomputable opaque dataProgram : Procedure inputCode (prodCode Nat.bits (prodCode registersCode signsCode)) Prod.snd := + Procedure.second unaryCode _ +noncomputable opaque parametersProgram : Procedure inputCode (prodCode unaryCode Nat.bits) + (fun x => (x.1,x.2.1)) := + (Procedure.first unaryCode _).pair ((Procedure.first Nat.bits _).comp dataProgram) +noncomputable opaque nodeDataProgram : Procedure inputCode (prodCode registersCode signsCode) + (fun x => x.2.2) := (Procedure.second Nat.bits _).comp dataProgram +noncomputable opaque registersProgram : Procedure inputCode registersCode (fun x => x.2.2.1) := + (Procedure.first registersCode signsCode).comp nodeDataProgram +noncomputable opaque signsProgram : Procedure inputCode signsCode (fun x => x.2.2.2) := + (Procedure.second registersCode signsCode).comp nodeDataProgram +noncomputable opaque signFirstProgram : Procedure signsCode Procedure.boolCode Prod.fst := Procedure.first _ _ +noncomputable opaque signTailProgram : Procedure signsCode (prodCode Procedure.boolCode Procedure.boolCode) Prod.snd := + Procedure.second _ _ +noncomputable opaque signSecondProgram : Procedure signsCode Procedure.boolCode (fun x => x.2.1) := + (Procedure.first _ _).comp signTailProgram +noncomputable opaque signThirdProgram : Procedure signsCode Procedure.boolCode (fun x => x.2.2) := + (Procedure.second _ _).comp signTailProgram + +noncomputable opaque program : Procedure inputCode tripleCode + (fun x => value x.1 x.2.1 x.2.2.1 x.2.2.2) := by + let a := coordinateProgram.comp (parametersProgram.pair + ((EulerRegisters.firstRegisterProgram.comp registersProgram).pair (signFirstProgram.comp signsProgram))) + let b := coordinateProgram.comp (parametersProgram.pair + ((EulerRegisters.secondRegisterProgram.comp registersProgram).pair (signSecondProgram.comp signsProgram))) + let c := coordinateProgram.comp (parametersProgram.pair + ((EulerRegisters.thirdRegisterProgram.comp registersProgram).pair (signThirdProgram.comp signsProgram))) + exact a.pair (b.pair c) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode tripleCode + (fun x => value x.1 x.2.1 x.2.2.1 x.2.2.2) := program.toTM2 + +end ContinuumCoulomb.RationalGaussNodes + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianFrequencyProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianFrequencyProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3a905cdc4a8ba791749e3c0c54bef70905ea5d1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianFrequencyProgram.lean @@ -0,0 +1,34 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianFrequency + +namespace OAI + +/-! Literal arithmetic for the fixed-density Gaussian frequency evaluator. -/ + +namespace ContinuumCoulomb.GaussianFrequency +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque countProgram (rho : ℕ) : Procedure unaryCode unaryCode (count rho) := by + let sq := ResolventSchedule.squareProgram.comp Procedure.unarySuccessor + let c := Procedure.constant unaryCode unaryCode (512 * (rho + 1)) + exact (ResolventSchedule.mulProgram.comp (c.pair sq)).congrFun (by intro P; rfl) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode precision := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant unaryCode unaryCode 8).pair Procedure.unarySuccessor)).congrFun + (by intro P; rfl) + +noncomputable opaque radicandProgram (rho : ℕ) : Procedure unaryCode ratCode (radicand rho) := by + let p := PiProgram.program.comp (countProgram rho) + let c := Procedure.constant unaryCode ratCode (4 * (rho : ℚ)) + exact (Procedure.ratMul.comp (c.pair p)).congrFun (by intro P; rfl) + +noncomputable opaque program (rho : ℕ) : Procedure unaryCode ratCode (approximate rho) := + (RationalSquareRoot.program.comp (precisionProgram.pair (radicandProgram rho))).congrFun + (by intro P; rfl) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime unaryCode ratCode (approximate rho) := (program rho).toTM2 + +end ContinuumCoulomb.GaussianFrequency + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianPacketProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianPacketProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..801d83d8568dd627488ff352c1ee8024ef32f357 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/GaussianPacketProgram.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.GaussianPacket + +namespace OAI + +/-! The fixed-frequency Gaussian sample has an actual polynomial-time +Turing program. Both its frequency computation and its exponential +computation use explicit polynomial unary precision schedules. -/ + +namespace ContinuumCoulomb.GaussianPacket +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := prodCode (prodCode unaryCode unaryCode) ratCode + +noncomputable opaque radiusProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode unaryCode).comp + (Procedure.first (prodCode unaryCode unaryCode) ratCode) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode (fun x => x.1.2) := + (Procedure.second unaryCode unaryCode).comp + (Procedure.first (prodCode unaryCode unaryCode) ratCode) + +noncomputable opaque pointProgram : Procedure inputCode ratCode Prod.snd := + Procedure.second (prodCode unaryCode unaryCode) ratCode + +noncomputable opaque radiusSquareProgram : Procedure inputCode unaryCode (fun x => (x.1.1 + 1) ^ 2) := + ResolventSchedule.squareProgram.comp (Procedure.unarySuccessor.comp radiusProgram) + +noncomputable opaque frequencyPrecisionProgram : Procedure inputCode unaryCode + (fun x => frequencyPrecision x.1.1 x.1.2) := by + let scaled := ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 16).pair radiusSquareProgram) + exact (ResolventSchedule.mulProgram.comp + (scaled.pair (Procedure.unarySuccessor.comp precisionProgram))).congrFun + (by intro x; rfl) + +noncomputable opaque frequencyProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => GaussianFrequency.approximate rho (frequencyPrecision x.1.1 x.1.2)) := + (GaussianFrequency.program rho).comp frequencyPrecisionProgram + +noncomputable opaque exponentProgram (rho : ℕ) : Procedure inputCode ratCode (exponent rho) := by + let neg := Procedure.ratNeg.comp (frequencyProgram rho) + let square := Procedure.ratMul.comp (pointProgram.pair pointProgram) + exact (Procedure.ratMul.comp (neg.pair square)).congrFun + (by intro x; simp only [exponent, Function.comp_apply, pow_two]) + +noncomputable opaque magnitudeProgram (rho : ℕ) : Procedure inputCode unaryCode + (fun x => magnitude rho x.1.1) := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode (4 * rho + 4)).pair radiusSquareProgram)).congrFun + (by intro x; rfl) + +noncomputable opaque exponentialPrecisionProgram : Procedure inputCode unaryCode + (fun x => exponentialPrecision x.1.2) := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 8).pair + (Procedure.unarySuccessor.comp precisionProgram))).congrFun (by intro x; rfl) + +noncomputable opaque argumentProgram (rho : ℕ) : + Procedure inputCode RationalExponentialProgram.inputCode (argument rho) := + (magnitudeProgram rho).pair (exponentialPrecisionProgram.pair (exponentProgram rho)) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode (approximate rho) := + (rationalUnitClampProgram.comp + (RationalExponentialProgram.program.comp (argumentProgram rho))).congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime inputCode ratCode (approximate rho) := + (program rho).toTM2 + +end ContinuumCoulomb.GaussianPacket + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/HoppingProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/HoppingProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cdb77441c8a4c6f8fa6f1ab04b5d7b5f5430594 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/HoppingProgram.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HoppingSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.NormalizationProgram + +namespace OAI + +/-! A literal polynomial TM2 program for the contact numerator, with +unary displacement bound and inverse-accuracy parameter. -/ + +namespace ContinuumCoulomb.HoppingSchedule +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := prodCode (prodCode unaryCode unaryCode) ratCode + +noncomputable opaque meshFactorsProgram : Procedure unaryCode (prodCode unaryCode unaryCode) + (fun P => (4096, P + 1)) := + NormalizationSchedule.constant4096Program.pair Procedure.unarySuccessor + +noncomputable opaque meshRawProgram : Procedure unaryCode unaryCode + (fun P => 4096 * (P + 1)) := ResolventSchedule.mulProgram.comp meshFactorsProgram + +noncomputable opaque meshProgram : Procedure unaryCode unaryCode mesh := + meshRawProgram.congrFun (by intro P; rfl) + +noncomputable opaque accuracyProgram : Procedure unaryCode unaryCode accuracy := + ResolventSchedule.scaleProgram + +noncomputable opaque argumentProgram : + Procedure inputCode (RationalRectangleProgram.inputCode HoppingQuadrature.settingsCode) argument := by + let rp := Procedure.first (prodCode unaryCode unaryCode) ratCode + let r := (Procedure.first unaryCode unaryCode).comp rp + let p := (Procedure.second unaryCode unaryCode).comp rp + let d := Procedure.second (prodCode unaryCode unaryCode) ratCode + let n := meshProgram.comp p + let a := accuracyProgram.comp p + let r2 := ResolventSchedule.addProgram.comp (r.pair (Procedure.constant inputCode unaryCode 2)) + let nr := Procedure.natToRat.comp (Procedure.unaryToBits.comp n) + let step := Procedure.ratDiv.comp ((Procedure.constant inputCode ratCode 2).pair nr) + let lower := Procedure.constant inputCode ratCode (-1) + exact (n.pair (((r2.pair a).pair d).pair (lower.pair step))).congrFun (by intro x; rfl) + +noncomputable opaque program : Procedure inputCode ratCode approximate := + (HoppingQuadrature.program.comp argumentProgram).congrFun (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode approximate := program.toTM2 + +end ContinuumCoulomb.HoppingSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedFieldProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedFieldProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..86e6182b68f7aae4e8f30c6efe6e96c8759c641a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedFieldProgram.lean @@ -0,0 +1,171 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedFieldEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CountertermProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PlanarWellProgram + +namespace OAI + +/-! A literal polynomial TM2 scalar evaluator for the actual manufactured +three-dimensional well field. All sites, widths and scales are input data. -/ + +namespace ContinuumCoulomb.ManufacturedFieldEvaluation +open ExactQuantumFactoring.BitStackProgram + +def pointCode := CoulombPairEvaluation.pointCode +def sitesCode := listCode pointCode +abbrev PlanarInput := ℕ×(ℚ×(List (ℚ×ℚ)×(ℚ×ℚ))) +def planarCode : PlanarInput → List Bool := prodCode unaryCode + (prodCode ratCode (prodCode sitesCode pointCode)) +abbrev TermInput := PlanarInput×(ℚ×ℚ) +def termCode : TermInput → List Bool := prodCode planarCode pointCode +abbrev Input := ℕ×((ℚ×ℚ)×(List (ℚ×ℚ)×CappedKernelProgram.Triple)) +def inputCode : Input → List Bool := prodCode unaryCode + (prodCode (prodCode ratCode ratCode) (prodCode sitesCode CappedKernelProgram.tripleCode)) + +noncomputable opaque translateProgram : Procedure (prodCode pointCode pointCode) pointCode + (fun x => translate x.1 x.2) := by + let a := Procedure.first pointCode pointCode + let b := Procedure.second pointCode pointCode + let a0 := (Procedure.first ratCode ratCode).comp a + let a1 := (Procedure.second ratCode ratCode).comp a + let b0 := (Procedure.first ratCode ratCode).comp b + let b1 := (Procedure.second ratCode ratCode).comp b + exact (Procedure.ratSub.comp (a0.pair b0)).pair (Procedure.ratSub.comp (a1.pair b1)) + +noncomputable opaque termEnvironmentProgram : Procedure termCode planarCode Prod.fst := + Procedure.first planarCode pointCode +noncomputable opaque termSiteProgram : Procedure termCode pointCode Prod.snd := + Procedure.second planarCode pointCode +noncomputable opaque termPrecisionProgram : Procedure termCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode (prodCode ratCode (prodCode sitesCode pointCode))).comp termEnvironmentProgram +noncomputable opaque termDataProgram : Procedure termCode + (prodCode ratCode (prodCode sitesCode pointCode)) (fun x => x.1.2) := + (Procedure.second unaryCode _).comp termEnvironmentProgram +noncomputable opaque termScaleProgram : Procedure termCode ratCode (fun x => x.1.2.1) := + (Procedure.first ratCode _).comp termDataProgram +noncomputable opaque termListPointProgram : Procedure termCode (prodCode sitesCode pointCode) + (fun x => x.1.2.2) := (Procedure.second ratCode _).comp termDataProgram +noncomputable opaque termSitesProgram : Procedure termCode sitesCode (fun x => x.1.2.2.1) := + (Procedure.first sitesCode pointCode).comp termListPointProgram +noncomputable opaque termPointProgram : Procedure termCode pointCode (fun x => x.1.2.2.2) := + (Procedure.second sitesCode pointCode).comp termListPointProgram + +noncomputable opaque termRowProgram (rho : ℕ) : Procedure termCode ratCode + (fun x => CountertermEvaluation.row rho x.1.1 x.2 x.1.2.2.1) := + (CountertermEvaluation.rowProgram rho).comp + (termPrecisionProgram.pair (termSiteProgram.pair termSitesProgram)) + +noncomputable opaque termFractionProgram (rho : ℕ) : Procedure termCode ratCode + (fun x => CountertermEvaluation.row rho x.1.1 x.2 x.1.2.2.1/x.1.2.1) := + Procedure.ratDiv.comp ((termRowProgram rho).pair termScaleProgram) + +noncomputable opaque termClippedProgram (rho : ℕ) : Procedure termCode ratCode + (fun x => RationalSmoothTransition.clip + (CountertermEvaluation.row rho x.1.1 x.2 x.1.2.2.1/x.1.2.1)) := + SmoothTransitionProgram.clipProgram.comp (termFractionProgram rho) + +noncomputable opaque coefficientProgram (rho : ℕ) : Procedure termCode ratCode + (fun x => coefficient rho x.1.1 x.1.2.1 x.1.2.2.1 x.2) := + Procedure.ratAdd.comp ((Procedure.constant termCode ratCode (1:ℚ)).pair (termClippedProgram rho)) + +noncomputable opaque termRelativeProgram : Procedure termCode pointCode + (fun x => translate x.1.2.2.2 x.2) := + translateProgram.comp (termPointProgram.pair termSiteProgram) + +noncomputable opaque termWellProgram : Procedure termCode ratCode + (fun x => PlanarWellNumerics.approximate x.1.1 (translate x.1.2.2.2 x.2)) := + by + let p := PlanarWellNumerics.program.comp (termPrecisionProgram.pair termRelativeProgram) + exact p.congrFun (by intro x; rfl) + +noncomputable opaque termProgram (rho : ℕ) : Procedure termCode ratCode + (fun x => coefficient rho x.1.1 x.1.2.1 x.1.2.2.1 x.2 * + PlanarWellNumerics.approximate x.1.1 (translate x.1.2.2.2 x.2)) := + Procedure.ratMul.comp ((coefficientProgram rho).pair termWellProgram) + +noncomputable opaque planarProgram (rho : ℕ) : Procedure planarCode ratCode + (fun x => planar rho x.1 x.2.1 x.2.2.1 x.2.2.2) := by + let tail := Procedure.second unaryCode (prodCode ratCode (prodCode sitesCode pointCode)) + let listpoint := (Procedure.second ratCode (prodCode sitesCode pointCode)).comp tail + let sites := (Procedure.first sitesCode pointCode).comp listpoint + let mapped := (Procedure.listMapWith (ea := planarCode) (eb := pointCode) (ec := ratCode) + (f := fun env a => coefficient rho env.1 env.2.1 env.2.2.1 a * + PlanarWellNumerics.approximate env.1 (translate env.2.2.2 a)) + (0,0) 0 (termProgram rho)).comp ((Procedure.identity planarCode).pair sites) + exact RationalSumProgram.sumProgram.comp mapped + +noncomputable opaque precisionFactorsProgram : Procedure (prodCode unaryCode unaryCode) + (prodCode unaryCode unaryCode) (fun x => ((x.1+1)^2,x.2+1)) := by + let m := Procedure.unarySuccessor.comp (Procedure.first unaryCode unaryCode) + let p := Procedure.unarySuccessor.comp (Procedure.second unaryCode unaryCode) + exact ((Procedure.unaryMul.comp (m.pair m)).pair p).congrFun + (by intro x; simp only [pow_two]; rfl) + +noncomputable opaque precisionProgram (rho : ℕ) : Procedure (prodCode unaryCode unaryCode) + unaryCode (fun x => precision rho x.1 x.2) := by + let base := Procedure.unaryMul.comp precisionFactorsProgram + let C := Procedure.constant (prodCode unaryCode unaryCode) unaryCode + (16*(CountertermEvaluation.guard rho)^4) + exact (Procedure.unaryMul.comp (C.pair base)).congrFun (by intro x; change 16*(CountertermEvaluation.guard rho)^4*((x.1+1)^2*(x.2+1)) = _; unfold precision; ring) + +noncomputable opaque dataProgram : Procedure inputCode + (prodCode (prodCode ratCode ratCode) (prodCode sitesCode CappedKernelProgram.tripleCode)) + (fun x => x.2) := Procedure.second unaryCode _ +noncomputable opaque parametersProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.1) := (Procedure.first _ _).comp dataProgram +noncomputable opaque geometryProgram : Procedure inputCode (prodCode sitesCode CappedKernelProgram.tripleCode) + (fun x => x.2.2) := (Procedure.second _ _).comp dataProgram +noncomputable opaque sitesProgram : Procedure inputCode sitesCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp geometryProgram +noncomputable opaque pointProgram : Procedure inputCode CappedKernelProgram.tripleCode (fun x => x.2.2.2) := + (Procedure.second _ _).comp geometryProgram +noncomputable opaque scaleProgram : Procedure inputCode ratCode (fun x => x.2.1.1) := + (Procedure.first ratCode ratCode).comp parametersProgram +noncomputable opaque widthProgram : Procedure inputCode ratCode (fun x => x.2.1.2) := + (Procedure.second ratCode ratCode).comp parametersProgram +noncomputable opaque coordinateTailProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.2.2.2) := (Procedure.second ratCode (prodCode ratCode ratCode)).comp pointProgram +noncomputable opaque planarPointProgram : Procedure inputCode pointCode + (fun x => (x.2.2.2.1,x.2.2.2.2.1)) := + ((Procedure.first ratCode (prodCode ratCode ratCode)).comp pointProgram).pair + ((Procedure.first ratCode ratCode).comp coordinateTailProgram) +noncomputable opaque heightProgram : Procedure inputCode ratCode (fun x => x.2.2.2.2.2) := + (Procedure.second ratCode ratCode).comp coordinateTailProgram + +noncomputable opaque rawCutoffProgram : Procedure inputCode ratCode + (fun x => RationalSmoothTransition.clip (VerticalCutoffProgram.value (x.1,(x.2.1.2,x.2.2.2.2.2)))) := by + let p : Procedure inputCode unaryCode Prod.fst := Procedure.first unaryCode + (prodCode (prodCode ratCode ratCode) (prodCode sitesCode CappedKernelProgram.tripleCode)) + exact SmoothTransitionProgram.clipProgram.comp (VerticalCutoffProgram.program.comp + (p.pair (widthProgram.pair heightProgram))) + +noncomputable opaque rawPlanarProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => planar rho x.1 x.2.1.1 x.2.2.1 (x.2.2.2.1,x.2.2.2.2.1)) := + by + let p := (planarProgram rho).comp ((Procedure.first unaryCode + (prodCode (prodCode ratCode ratCode) (prodCode sitesCode CappedKernelProgram.tripleCode))).pair + (scaleProgram.pair (sitesProgram.pair planarPointProgram))) + exact p.congrFun (by intro x; rfl) + +noncomputable opaque rawProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => rawValue rho x.1 x.2.1.1 x.2.1.2 x.2.2.1 x.2.2.2) := + Procedure.ratMul.comp (rawCutoffProgram.pair (rawPlanarProgram rho)) + +noncomputable opaque inputPrecisionProgram (rho : ℕ) : Procedure inputCode unaryCode + (fun x => precision rho x.2.2.1.length x.1) := by + let p : Procedure inputCode unaryCode Prod.fst := Procedure.first unaryCode + (prodCode (prodCode ratCode ratCode) (prodCode sitesCode CappedKernelProgram.tripleCode)) + let m := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength pointCode (0,0)).comp sitesProgram + exact (precisionProgram rho).comp (m.pair p) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode + (fun x => value rho x.1 x.2.1.1 x.2.1.2 x.2.2.1 x.2.2.2) := + by + let p := (rawProgram rho).comp ((inputPrecisionProgram rho).pair dataProgram) + exact p.congrFun (by intro x; rfl) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => value rho x.1 x.2.1.1 x.2.1.2 x.2.2.1 x.2.2.2) := (program rho).toTM2 + +end ContinuumCoulomb.ManufacturedFieldEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedVelocityProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedVelocityProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..173459249198b7b7fda10664cc6bcbaef7002972 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ManufacturedVelocityProgram.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedVelocityEvaluation +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ManufacturedFieldProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MoserDifferenceProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.FiniteDifferenceProgram + +namespace OAI + +/-! The manufactured Moser velocity has a literal polynomial TM2 evaluator. +It composes the already certified field sampler, three fixed rational +coordinate differences, and the clamped positive-density quotient. -/ + +namespace ContinuumCoulomb.ManufacturedVelocityEvaluation +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) + +abbrev Environment := ℕ×((ℚ×ℚ)×List (ℚ×ℚ)) +def environmentCode : Environment → List Bool := prodCode unaryCode + (prodCode (prodCode ratCode ratCode) ManufacturedFieldEvaluation.sitesCode) +def sampleCode : (Environment×Triple) → List Bool := prodCode environmentCode tripleCode +abbrev Input := Environment×(ℚ×Triple) +def inputCode : Input → List Bool := prodCode environmentCode (prodCode ratCode tripleCode) + +noncomputable opaque envPrecisionProgram : Procedure environmentCode unaryCode Prod.fst := + Procedure.first unaryCode _ +noncomputable opaque envDataProgram : Procedure environmentCode + (prodCode (prodCode ratCode ratCode) ManufacturedFieldEvaluation.sitesCode) Prod.snd := + Procedure.second unaryCode _ +noncomputable opaque envParametersProgram : Procedure environmentCode (prodCode ratCode ratCode) + (fun e => e.2.1) := (Procedure.first _ _).comp envDataProgram +noncomputable opaque envSitesProgram : Procedure environmentCode ManufacturedFieldEvaluation.sitesCode + (fun e => e.2.2) := (Procedure.second _ _).comp envDataProgram +noncomputable opaque innerPrecisionProgram (rho : ℕ) : Procedure unaryCode unaryCode (precision rho) := + (Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode + (12*(1+MoserDifferenceBudget.guard*(4*rho+1)))).pair Procedure.unarySuccessor)) + +noncomputable opaque sampleEnvironmentProgram : Procedure sampleCode environmentCode Prod.fst := + Procedure.first environmentCode tripleCode +noncomputable opaque samplePointProgram : Procedure sampleCode tripleCode Prod.snd := + Procedure.second environmentCode tripleCode +noncomputable opaque samplePrecisionProgram : Procedure sampleCode unaryCode + (fun x => MoserDifferenceBudget.precision x.1.1) := + MoserDifferenceBudget.precisionProgram.comp (envPrecisionProgram.comp sampleEnvironmentProgram) +noncomputable opaque sampleDataProgram : Procedure sampleCode + (prodCode (prodCode ratCode ratCode) (prodCode ManufacturedFieldEvaluation.sitesCode tripleCode)) + (fun x => (x.1.2.1,(x.1.2.2,x.2))) := + (envParametersProgram.comp sampleEnvironmentProgram).pair + ((envSitesProgram.comp sampleEnvironmentProgram).pair samplePointProgram) +noncomputable opaque scalarSampleProgram (rho : ℕ) : Procedure sampleCode ratCode + (fun x => sample rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2) := + by + let p := (ManufacturedFieldEvaluation.program rho).comp (samplePrecisionProgram.pair sampleDataProgram) + exact p.congrFun (by intro x; rfl) +noncomputable opaque spatialStepProgram : Procedure environmentCode ratCode + (fun e => MoserDifferenceBudget.step e.1) := + MoserDifferenceBudget.stepProgram.comp envPrecisionProgram + +noncomputable opaque gradientProgram (rho : ℕ) (a : Fin 3) : Procedure sampleCode ratCode + (fun x => gradient rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2 a) := + by + let p := FiniteDifferenceProgram.firstProgram (E := Environment) (ce := environmentCode) + (sample := fun e q => sample rho e.1 e.2.1.1 e.2.1.2 e.2.2 q) + (step := fun e => MoserDifferenceBudget.step e.1) a (scalarSampleProgram rho) spatialStepProgram + exact p.congrFun (by intro x; rfl) +noncomputable opaque laplacianProgram (rho : ℕ) : Procedure sampleCode ratCode + (fun x => laplacian rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2) := + by + let p := FiniteDifferenceProgram.laplacianProgram (E := Environment) (ce := environmentCode) + (sample := fun e q => sample rho e.1 e.2.1.1 e.2.1.2 e.2.2 q) + (step := fun e => MoserDifferenceBudget.step e.1) (scalarSampleProgram rho) spatialStepProgram + exact p.congrFun (by intro x; rfl) +noncomputable opaque piProgram : Procedure environmentCode ratCode (fun e => pi e.1) := + PiProgram.program.comp ((Procedure.unaryMul.comp + ((Procedure.constant unaryCode unaryCode 8).pair Procedure.unarySuccessor)).comp envPrecisionProgram) + +noncomputable opaque inputEnvironmentProgram : Procedure inputCode environmentCode Prod.fst := + Procedure.first environmentCode (prodCode ratCode tripleCode) +noncomputable opaque inputTimePointProgram : Procedure inputCode (prodCode ratCode tripleCode) Prod.snd := + Procedure.second environmentCode (prodCode ratCode tripleCode) +noncomputable opaque inputTimeProgram : Procedure inputCode ratCode (fun x => x.2.1) := + (Procedure.first ratCode tripleCode).comp inputTimePointProgram +noncomputable opaque inputPointProgram : Procedure inputCode tripleCode (fun x => x.2.2) := + (Procedure.second ratCode tripleCode).comp inputTimePointProgram +noncomputable opaque inputSampleProgram : Procedure inputCode sampleCode (fun x => (x.1,x.2.2)) := + inputEnvironmentProgram.pair inputPointProgram +noncomputable opaque rawDenominatorProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => 4*pi x.1.1*(rho:ℚ)+x.2.1*laplacian rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.2) := by + let base := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode (4:ℚ)).pair + (piProgram.comp inputEnvironmentProgram)) + let first := Procedure.ratMul.comp (base.pair (Procedure.constant inputCode ratCode (rho:ℚ))) + let second := Procedure.ratMul.comp (inputTimeProgram.pair ((laplacianProgram rho).comp inputSampleProgram)) + exact Procedure.ratAdd.comp (first.pair second) + +noncomputable opaque maxDensityProgram (rho : ℕ) : Procedure ratCode ratCode (fun q => max (rho:ℚ) q) := by + let q := Procedure.identity ratCode + let r := Procedure.constant ratCode ratCode (rho:ℚ) + let negative := Procedure.intSign.comp (Procedure.ratNum.comp (Procedure.ratSub.comp (q.pair r))) + exact (Procedure.conditional negative r q).congrFun (by + intro q + simp only [Function.comp_apply,Rat.num_neg,decide_eq_true_eq,id_eq] + split_ifs with h + · exact (max_eq_left (by linarith)).symm + · exact (max_eq_right (by linarith)).symm) + +noncomputable opaque denominatorProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => max (rho:ℚ) (4*pi x.1.1*(rho:ℚ)+x.2.1* + laplacian rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.2)) := + (maxDensityProgram rho).comp (rawDenominatorProgram rho) +noncomputable opaque coreComponentProgram (rho : ℕ) (a : Fin 3) : Procedure inputCode ratCode + (fun x => -gradient rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.2 a / + max (rho:ℚ) (4*pi x.1.1*(rho:ℚ)+x.2.1* + laplacian rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.2)) := + Procedure.ratDiv.comp ((Procedure.ratNeg.comp ((gradientProgram rho a).comp inputSampleProgram)).pair + (denominatorProgram rho)) +noncomputable opaque preparedEnvironmentProgram (rho : ℕ) : Procedure environmentCode environmentCode + (fun e => (precision rho e.1,e.2)) := + ((innerPrecisionProgram rho).comp envPrecisionProgram).pair envDataProgram +noncomputable opaque preparedInputProgram (rho : ℕ) : Procedure inputCode inputCode + (fun x => ((precision rho x.1.1,x.1.2),x.2)) := + ((preparedEnvironmentProgram rho).comp inputEnvironmentProgram).pair inputTimePointProgram +noncomputable opaque componentProgram (rho : ℕ) (a : Fin 3) : Procedure inputCode ratCode + (fun x => component rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.1 x.2.2 a) := + by + let p := (coreComponentProgram rho a).comp (preparedInputProgram rho) + exact p.congrFun (by intro x; rfl) +noncomputable opaque program (rho : ℕ) : Procedure inputCode tripleCode + (fun x => value rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.1 x.2.2) := + (componentProgram rho 0).pair ((componentProgram rho 1).pair (componentProgram rho 2)) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode tripleCode + (fun x => value rho x.1.1 x.1.2.1.1 x.1.2.1.2 x.1.2.2 x.2.1 x.2.2) := (program rho).toTM2 + +end ContinuumCoulomb.ManufacturedVelocityEvaluation + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorListProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorListProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..72c501d9fe1f2bd2278be201c8856585789d66e4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorListProgram.lean @@ -0,0 +1,224 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorIteration + +namespace OAI + +/-! Actual TM2 programs which emit the central and spoke bond lists of one +simultaneous mediator stage. The index arithmetic follows the same +`n + 2e + spin` vertex enumeration as the proved finite-spin construction. -/ + +namespace ContinuumCoulomb.MediatorListProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Bond := ℕ × (ℕ × ℚ) + +def bondCode : Bond → List Bool := prodCode Nat.bits (prodCode Nat.bits ratCode) + +def zeroBond : Bond := (0, 0, 0) + +abbrev Env := ℕ × (ℕ × (ℕ × ℕ)) + +def envCode : Env → List Bool := prodCode unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + +abbrev IndexedBond := Env × (ℕ × Bond) + +def indexedCode : IndexedBond → List Bool := prodCode envCode (prodCode unaryCode bondCode) + +noncomputable def environment : Procedure indexedCode envCode Prod.fst := Procedure.first _ _ + +noncomputable def rProgram : Procedure indexedCode unaryCode (fun x => x.1.1) := + (Procedure.first _ _).comp environment + +noncomputable def wProgram : Procedure indexedCode unaryCode (fun x => x.1.2.1) := + ((Procedure.first _ _).comp (Procedure.second _ _)).comp environment + +noncomputable def gProgram : Procedure indexedCode unaryCode (fun x => x.1.2.2.1) := + (((Procedure.first _ _).comp (Procedure.second _ _)).comp (Procedure.second _ _)).comp environment + +noncomputable def nProgram : Procedure indexedCode unaryCode (fun x => x.1.2.2.2) := + (((Procedure.second _ _).comp (Procedure.second _ _)).comp (Procedure.second _ _)).comp environment + +noncomputable def indexProgram : Procedure indexedCode Nat.bits (fun x => x.2.1) := + Procedure.unaryToBits.comp ((Procedure.first _ _).comp (Procedure.second _ _)) + +noncomputable def bondProgram : Procedure indexedCode bondCode (fun x => x.2.2) := + (Procedure.second _ _).comp (Procedure.second _ _) + +noncomputable def leftProgram : Procedure indexedCode Nat.bits (fun x => x.2.2.1) := + (Procedure.first _ _).comp bondProgram + +noncomputable def rightProgram : Procedure indexedCode Nat.bits (fun x => x.2.2.2.1) := + ((Procedure.first _ _).comp (Procedure.second _ _)).comp bondProgram + +noncomputable def weightProgram : Procedure indexedCode ratCode (fun x => x.2.2.2.2) := + ((Procedure.second _ _).comp (Procedure.second _ _)).comp bondProgram + +noncomputable def parametersProgram : Procedure indexedCode MediatorProgram.rawCode + (fun x => (x.1.1, x.1.2.1, x.1.2.2.1, x.2.2.2.2)) := + rProgram.pair (wProgram.pair (gProgram.pair weightProgram)) + +noncomputable def amplitudeProgram : Procedure indexedCode ratCode + (fun x => MediatorParameters.spoke x.1.1 x.1.2.1 x.1.2.2.1 x.2.2.2.2) := + (MediatorProgram.spokeProgram.comp parametersProgram).congrFun (by intro x; rfl) + +noncomputable def halfProgram : Procedure indexedCode Nat.bits (fun x => x.2.1 / 2) := + Procedure.binaryDiv.comp (indexProgram.pair (Procedure.constant indexedCode Nat.bits 2)) + +noncomputable def evenProgram : Procedure indexedCode Procedure.boolCode (fun x => decide (x.2.1 % 2 = 0)) := + Procedure.binaryZero.comp (Procedure.binaryMod.comp + (indexProgram.pair (Procedure.constant indexedCode Nat.bits 2))) + +noncomputable def negativeProgram : Procedure indexedCode Procedure.boolCode + (fun x => decide (x.2.2.2.2 < 0)) := + (Procedure.intSign.comp (Procedure.ratNum.comp weightProgram)).congrFun (by + intro x + simp only [Function.comp_apply] + simp only [Rat.num_neg]) + +noncomputable def spokeLeftProgram : Procedure indexedCode Nat.bits + (fun x => if x.2.1 % 2 = 0 then x.2.2.1 else x.2.2.2.1) := + (Procedure.conditional evenProgram leftProgram rightProgram).congrFun (by intro x; simp) + +noncomputable def vertexBaseProgram : Procedure indexedCode Nat.bits + (fun x => x.1.2.2.2 + 2 * (x.2.1 / 2)) := + Procedure.binaryAdd.comp ((Procedure.unaryToBits.comp nProgram).pair + (Procedure.binaryMul.comp ((Procedure.constant indexedCode Nat.bits 2).pair halfProgram))) + +noncomputable def spokeRightProgram : Procedure indexedCode Nat.bits + (fun x => x.1.2.2.2 + 2 * (x.2.1 / 2) + + if x.2.1 % 2 = 0 then 0 else if x.2.2.2.2 < 0 then 0 else 1) := by + let zero := Procedure.constant indexedCode Nat.bits 0 + let one := Procedure.constant indexedCode Nat.bits 1 + let odd := Procedure.conditional negativeProgram zero one + let member := Procedure.conditional evenProgram zero odd + exact (Procedure.binaryAdd.comp (vertexBaseProgram.pair member)).congrFun (by intro x; simp) + +def spoke (x : IndexedBond) : Bond := + (if x.2.1 % 2 = 0 then x.2.2.1 else x.2.2.2.1, + x.1.2.2.2 + 2 * (x.2.1 / 2) + + if x.2.1 % 2 = 0 then 0 else if x.2.2.2.2 < 0 then 0 else 1, + MediatorParameters.spoke x.1.1 x.1.2.1 x.1.2.2.1 x.2.2.2.2) + +noncomputable def spokeProgram : Procedure indexedCode bondCode spoke := + spokeLeftProgram.pair (spokeRightProgram.pair amplitudeProgram) + +abbrev Input := Env × List Bond + +def inputCode : Input → List Bool := prodCode envCode (listCode bondCode) + +abbrev LoopInput := ℕ × Input + +def loopCode : LoopInput → List Bool := prodCode unaryCode inputCode + +noncomputable def loopIndex : Procedure loopCode unaryCode Prod.fst := Procedure.first _ _ + +noncomputable def loopInput : Procedure loopCode inputCode Prod.snd := Procedure.second _ _ + +noncomputable def loopEnvironment : Procedure loopCode envCode (fun x => x.2.1) := + (Procedure.first _ _).comp loopInput + +noncomputable def loopEdges : Procedure loopCode (listCode bondCode) (fun x => x.2.2) := + (Procedure.second _ _).comp loopInput + +noncomputable def loopBond : Procedure loopCode bondCode + (fun x => (x.2.2.drop (x.1 / 2)).headD zeroBond) := + (Procedure.listGet bondCode zeroBond).comp + ((Procedure.binaryDiv.comp ((Procedure.unaryToBits.comp loopIndex).pair + (Procedure.constant loopCode Nat.bits 2))).pair loopEdges) + +noncomputable def loopSpoke : Procedure loopCode bondCode + (fun x => spoke (x.2.1, x.1, (x.2.2.drop (x.1 / 2)).headD zeroBond)) := + spokeProgram.comp (loopEnvironment.pair (loopIndex.pair loopBond)) + +def spokes (x : Input) : List Bond := (List.range (2 * x.2.length)).map + (fun i => spoke (x.1, i, (x.2.drop (i / 2)).headD zeroBond)) + +noncomputable def spokesProgram : Procedure inputCode (listCode bondCode) spokes := by + let len : Procedure inputCode unaryCode (fun x => x.2.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp (Procedure.second _ _) + let twice := Procedure.unaryAdd.comp (len.pair len) + exact ((Procedure.tabulate (ea := inputCode) (eb := bondCode) + (f := fun (x : Input) i => spoke (x.1, i, (x.2.drop (i / 2)).headD zeroBond)) zeroBond loopSpoke).comp + (twice.pair (Procedure.identity inputCode))).congrFun (by intro x; simp only [Function.comp_apply, id_eq, spokes]; congr 2; omega) + +noncomputable def centralBase : Procedure loopCode Nat.bits (fun x => x.2.1.2.2.2 + 2 * x.1) := by + let n := (((Procedure.second unaryCode unaryCode).comp + (Procedure.second unaryCode (prodCode unaryCode unaryCode))).comp + (Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)))).comp loopEnvironment + exact Procedure.binaryAdd.comp ((Procedure.unaryToBits.comp n).pair + (Procedure.binaryMul.comp ((Procedure.constant loopCode Nat.bits 2).pair + (Procedure.unaryToBits.comp loopIndex)))) + +noncomputable def centralWeight : Procedure loopCode ratCode + (fun x => (MediatorParameters.delta x.2.1.1 x.2.1.2.1 x.2.1.2.2.1 : ℚ)) := by + let r : Procedure loopCode unaryCode (fun x => x.2.1.1) := + (Procedure.first unaryCode _).comp loopEnvironment + let rest : Procedure loopCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + (fun x => x.2.1.2) := (Procedure.second unaryCode _).comp loopEnvironment + let w : Procedure loopCode unaryCode (fun x => x.2.1.2.1) := + (Procedure.first unaryCode _).comp rest + let g : Procedure loopCode unaryCode (fun x => x.2.1.2.2.1) := + ((Procedure.first unaryCode unaryCode).comp (Procedure.second unaryCode _)).comp rest + let params : Procedure loopCode MediatorProgram.rawCode + (fun x => (x.2.1.1, x.2.1.2.1, x.2.1.2.2.1, 0)) := + r.pair (w.pair (g.pair (Procedure.constant loopCode ratCode 0))) + exact (MediatorProgram.deltaRationalProgram.comp params).congrFun (by intro x; rfl) + +def central (x : Input) : List Bond := (List.range x.2.length).map (fun i => + (x.1.2.2.2 + 2 * i, x.1.2.2.2 + 2 * i + 1, + (MediatorParameters.delta x.1.1 x.1.2.1 x.1.2.2.1 : ℚ))) + +noncomputable def centralProgram : Procedure inputCode (listCode bondCode) central := by + let len : Procedure inputCode unaryCode (fun x => x.2.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp (Procedure.second _ _) + let edge : Procedure loopCode bondCode (fun x => + (x.2.1.2.2.2 + 2 * x.1, x.2.1.2.2.2 + 2 * x.1 + 1, + (MediatorParameters.delta x.2.1.1 x.2.1.2.1 x.2.1.2.2.1 : ℚ))) := + centralBase.pair ((Procedure.successor.comp centralBase).pair centralWeight) + exact ((Procedure.tabulate (ea := inputCode) (eb := bondCode) + (f := fun (x : Input) i => (x.1.2.2.2 + 2 * i, x.1.2.2.2 + 2 * i + 1, + (MediatorParameters.delta x.1.1 x.1.2.1 x.1.2.2.1 : ℚ))) zeroBond edge).comp + (len.pair (Procedure.identity inputCode))).congrFun (by intro x; rfl) + +noncomputable def stageProgram : Procedure inputCode (listCode bondCode) + (fun x => central x ++ spokes x) := + (Procedure.listAppend bondCode zeroBond).comp (centralProgram.pair spokesProgram) + +noncomputable def encodedBondTuple : Procedure binaryHeisenbergEdgeCodec.encode + (prodCode BinaryEncoding.natural.encode + (BinaryEncoding.pair BinaryEncoding.natural binaryRationalCodec).encode) + binaryHeisenbergEdgeEquiv := + (SourcePrograms.pairInput _ _ PrefixPrograms.natural).precompose binaryHeisenbergEdgeEquiv + +noncomputable def encodedBondLeft : Procedure binaryHeisenbergEdgeCodec.encode Nat.bits + BinaryHeisenbergEdge.left := + EncodingPrograms.naturalInput.comp ((Procedure.first _ _).comp encodedBondTuple) + +noncomputable def encodedBondRest : Procedure binaryHeisenbergEdgeCodec.encode + (prodCode BinaryEncoding.natural.encode binaryRationalCodec.encode) + (fun e => (e.right, e.coefficient)) := + (SourcePrograms.pairInput _ _ PrefixPrograms.natural).comp + ((Procedure.second _ _).comp encodedBondTuple) + +noncomputable def encodedBondRight : Procedure binaryHeisenbergEdgeCodec.encode Nat.bits + BinaryHeisenbergEdge.right := + EncodingPrograms.naturalInput.comp ((Procedure.first _ _).comp encodedBondRest) + +noncomputable def encodedBondWeight : Procedure binaryHeisenbergEdgeCodec.encode ratCode + (fun e => e.coefficient.value) := + SourcePrograms.rationalValue.comp ((Procedure.second _ _).comp encodedBondRest) + +noncomputable def encodedBond : Procedure binaryHeisenbergEdgeCodec.encode bondCode + (fun e => (e.left, e.right, e.coefficient.value)) := + encodedBondLeft.pair (encodedBondRight.pair encodedBondWeight) + +noncomputable def sourceBonds : Procedure binaryHeisenbergCodec.encode (listCode bondCode) + (fun d => d.edges.map (fun e => (e.left, e.right, e.coefficient.value))) := + (Procedure.listMap ⟨0, 0, ⟨0, 1⟩⟩ zeroBond encodedBond).comp SourcePrograms.edges + +noncomputable def stage_certificate : Turing.TM2ComputableInPolyTime inputCode + (listCode bondCode) (fun x => central x ++ spokes x) := stageProgram.toTM2 + +end ContinuumCoulomb.MediatorListProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorOffsetProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorOffsetProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdd7e3816133b5c0d5ddc3f0aaa3842d9ce257ab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorOffsetProgram.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorThreeStageProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram + +namespace OAI + +/-! Exact rational threshold offsets for the fully computed mediator +construction, using actual gcd-based rational-list summation. -/ + +namespace ContinuumCoulomb.MediatorOffsetProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +noncomputable opaque absoluteWeight : Procedure bondCode ratCode (fun e => |e.2.2|) := + MediatorProgram.absoluteProgram.comp ((Procedure.second _ _).comp (Procedure.second _ _)) + +noncomputable opaque totalWeight : Procedure inputCode ratCode + (fun x => (x.2.map (fun e => |e.2.2|)).sum) := + RationalSumProgram.sumProgram.comp + ((Procedure.listMap zeroBond 0 absoluteWeight).comp (Procedure.second _ _)) + +noncomputable opaque parameters : Procedure inputCode MediatorProgram.rawCode + (fun x => (x.1.1, x.1.2.1, x.1.2.2.1, 0)) := by + let e := Procedure.first envCode (listCode bondCode) + let r := MediatorUnaryProgram.rProgram.comp e + let w := MediatorUnaryProgram.wProgram.comp e + let g := MediatorUnaryProgram.gProgram.comp e + exact r.pair (w.pair (g.pair (Procedure.constant inputCode ratCode 0))) + +noncomputable opaque rRational : Procedure inputCode ratCode (fun x => (x.1.1 : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp + (MediatorUnaryProgram.rProgram.comp (Procedure.first _ _))) + +noncomputable opaque penalty : Procedure inputCode ratCode + (fun x => (MediatorParameters.delta x.1.1 x.1.2.1 x.1.2.2.1 : ℚ)) := + (MediatorProgram.deltaRationalProgram.comp parameters).congrFun (by intro x; rfl) + +def stageOffset (x : Input) : ℚ := + 3 * x.1.1 * MediatorParameters.delta x.1.1 x.1.2.1 x.1.2.2.1 + + 3 * (x.2.map (fun e => |e.2.2|)).sum + +noncomputable opaque stageOffsetProgram : Procedure inputCode ratCode stageOffset := by + let three := Procedure.constant inputCode ratCode 3 + let head := Procedure.ratMul.comp ((Procedure.ratMul.comp (three.pair rRational)).pair penalty) + let tail := Procedure.ratMul.comp (three.pair totalWeight) + exact Procedure.ratAdd.comp (head.pair tail) + +def offset (x : Input) : ℚ := + stageOffset x + + stageOffset (MediatorUnaryProgram.secondEnv x.1, spokes x) + + stageOffset (MediatorUnaryProgram.thirdEnv x.1, + central (MediatorUnaryProgram.secondEnv x.1, spokes x) ++ + spokes (MediatorUnaryProgram.secondEnv x.1, spokes x)) + +noncomputable opaque offsetProgram : Procedure inputCode ratCode offset := by + let second := stageOffsetProgram.comp MediatorThreeStageProgram.secondInput + let third := stageOffsetProgram.comp MediatorThreeStageProgram.thirdInput + exact Procedure.ratAdd.comp ((Procedure.ratAdd.comp (stageOffsetProgram.pair second)).pair third) + +noncomputable opaque errorProgram : Procedure inputCode ratCode + (fun x => 3 / (512 * (x.1.2.2.1 : ℚ))) := by + let g := Procedure.natToRat.comp (Procedure.unaryToBits.comp + (MediatorUnaryProgram.gProgram.comp (Procedure.first envCode (listCode bondCode)))) + let denom := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 512).pair g) + exact Procedure.ratDiv.comp ((Procedure.constant inputCode ratCode 3).pair denom) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode offset := + offsetProgram.toTM2 + +end ContinuumCoulomb.MediatorOffsetProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3d77edd6884848ff6a9987dfd0b64133d245a34 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorProgram.lean @@ -0,0 +1,207 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorParameters +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialTimeSize + +namespace OAI + +/-! Actual polynomial-time arithmetic for the explicitly scaled rational +mediator stage. Edge count, weight bound and inverse-error bound are unary; +the entering coefficient and emitted spoke are canonical binary rationals. -/ + +namespace ContinuumCoulomb.MediatorProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × (ℕ × (ℕ × ℚ)) + +def rawCode : Input → List Bool := prodCode unaryCode + (prodCode unaryCode (prodCode unaryCode ratCode)) + +noncomputable def rProgram : Procedure rawCode unaryCode Prod.fst := + Procedure.first unaryCode (prodCode unaryCode (prodCode unaryCode ratCode)) + +noncomputable def wProgram : Procedure rawCode unaryCode (fun x => x.2.1) := + (Procedure.first unaryCode (prodCode unaryCode ratCode)).comp + (Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode ratCode))) + +noncomputable def gProgram : Procedure rawCode unaryCode (fun x => x.2.2.1) := + ((Procedure.first unaryCode ratCode).comp + (Procedure.second unaryCode (prodCode unaryCode ratCode))).comp + (Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode ratCode))) + +noncomputable def jProgram : Procedure rawCode ratCode (fun x => x.2.2.2) := + ((Procedure.second unaryCode ratCode).comp + (Procedure.second unaryCode (prodCode unaryCode ratCode))).comp + (Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode ratCode))) + +noncomputable def cubeProgram : Procedure Nat.bits Nat.bits (fun n => n ^ 3) := + (Procedure.binaryPow.comp ((Procedure.constant Nat.bits unaryCode 3).pair + (Procedure.identity Nat.bits))).congrFun (by intro n; rfl) + +noncomputable def rCubeProgram : Procedure rawCode Nat.bits (fun x => (x.1 + 1) ^ 3) := + (cubeProgram.comp (Procedure.unaryToBits.comp + (Procedure.unarySuccessor.comp rProgram))).congrFun (by intro x; rfl) + +noncomputable def wCubeProgram : Procedure rawCode Nat.bits (fun x => x.2.1 ^ 3) := + (cubeProgram.comp (Procedure.unaryToBits.comp wProgram)).congrFun (by intro x; rfl) + +noncomputable def cubicProductProgram : Procedure rawCode Nat.bits + (fun x => (x.1 + 1) ^ 3 * x.2.1 ^ 3) := + Procedure.binaryMul.comp (rCubeProgram.pair wCubeProgram) + +noncomputable def scaleProgram : Procedure rawCode Nat.bits + (fun x => MediatorParameters.scale x.1 x.2.1 x.2.2.1) := by + let product := Procedure.binaryMul.comp + (cubicProductProgram.pair (Procedure.unaryToBits.comp gProgram)) + exact (Procedure.binaryMul.comp ((Procedure.constant rawCode Nat.bits 1048576).pair + product)).congrFun (by + intro x + simp only [Function.comp_apply, id_eq, MediatorParameters.scale] + ring) + +noncomputable def deltaProgram : Procedure rawCode Nat.bits + (fun x => MediatorParameters.delta x.1 x.2.1 x.2.2.1) := + (Procedure.binaryMul.comp (scaleProgram.pair scaleProgram)).congrFun + (by intro x; exact (pow_two _).symm) + +noncomputable def precisionProgram : Procedure rawCode unaryCode + (fun x => MediatorParameters.precision x.1 x.2.2.1) := + (Procedure.unaryAdd.comp ((Procedure.unaryAdd.comp (rProgram.pair gProgram)).pair + (Procedure.constant rawCode unaryCode 20))).congrFun (by intro x; rfl) + +noncomputable def absoluteProgram : Procedure ratCode ratCode abs := + (Procedure.conditional (Procedure.intSign.comp Procedure.ratNum) + Procedure.ratNeg (Procedure.identity ratCode)).congrFun (by + intro q + by_cases hn : q.num < 0 + · have hq : q < 0 := lt_of_not_ge (fun hq => (not_lt_of_ge (Rat.num_nonneg.mpr hq)) hn) + simp [hn, abs_of_neg hq] + · have hq : 0 ≤ q := Rat.num_nonneg.mp (le_of_not_gt hn) + simp [hn, abs_of_nonneg hq]) + +noncomputable def deltaRationalProgram : Procedure rawCode ratCode + (fun x => (MediatorParameters.delta x.1 x.2.1 x.2.2.1 : ℚ)) := + Procedure.natToRat.comp deltaProgram + +noncomputable def radicandProgram : Procedure rawCode ratCode + (fun x => MediatorParameters.radicand x.1 x.2.1 x.2.2.1 x.2.2.2) := by + let product := Procedure.ratMul.comp (deltaRationalProgram.pair (absoluteProgram.comp jProgram)) + exact (Procedure.ratMul.comp ((Procedure.constant rawCode ratCode 2).pair product)).congrFun + (by + intro x + simp only [Function.comp_apply, MediatorParameters.radicand] + ring) + +noncomputable def numeratorProgram : Procedure rawCode Nat.bits + (fun x => (MediatorParameters.radicand x.1 x.2.1 x.2.2.1 x.2.2.2).num.toNat) := + ChargePrograms.intToNatProgram.comp (Procedure.ratNum.comp radicandProgram) + +noncomputable def denominatorProgram : Procedure rawCode Nat.bits + (fun x => (MediatorParameters.radicand x.1 x.2.1 x.2.2.1 x.2.2.2).den) := + Procedure.ratDen.comp radicandProgram + +noncomputable def rootInputProgram : Procedure rawCode DyadicRootProgram.rawCode + (fun x => (MediatorParameters.precision x.1 x.2.2.1, + (MediatorParameters.radicand x.1 x.2.1 x.2.2.1 x.2.2.2).num.toNat, + (MediatorParameters.radicand x.1 x.2.1 x.2.2.1 x.2.2.2).den)) := + precisionProgram.pair (numeratorProgram.pair denominatorProgram) + +noncomputable def spokeProgram : Procedure rawCode ratCode + (fun x => MediatorParameters.spoke x.1 x.2.1 x.2.2.1 x.2.2.2) := + (DyadicRootProgram.rawProgram.comp rootInputProgram).congrFun (by intro x; rfl) + +def rationalCodec : BinaryEncoding.Codec ℚ where + encode q := (BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.natural).encode (q.num, q.den) + read s := let (x, tail) := (BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.natural).read s + (mkRat x.1 x.2, tail) + read_encode q tail := by + rw [(BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.natural).read_encode] + dsimp only + rw [Rat.mkRat_eq_div, Rat.num_div_den] + +noncomputable def rationalInput : Procedure rationalCodec.encode ratCode id := by + let num := EncodingPrograms.integerFirst BinaryEncoding.natural + let den := EncodingPrograms.naturalInput.comp (EncodingPrograms.integerSecond BinaryEncoding.natural) + let p := Procedure.makeRat.comp (num.pair den) + exact (p.precompose (fun q : ℚ => (q.num, q.den))).congrFun (by + intro q + change mkRat q.num q.den = q + rw [Rat.mkRat_eq_div, Rat.num_div_den]) + +noncomputable def rationalOutput : Procedure ratCode rationalCodec.encode id := + DyadicRootProgram.rationalOutput.result (by intro q; rfl) + +def tailCodec : BinaryEncoding.Codec (ℕ × ℚ) := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.unary) rationalCodec + +def middleCodec : BinaryEncoding.Codec (ℕ × (ℕ × ℚ)) := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.unary) tailCodec + +def parameters : BinaryEncoding.Codec Input := + BinaryEncoding.pair (BinaryEncoding.quoted BinaryEncoding.unary) middleCodec + +noncomputable def inputR : Procedure parameters.encode unaryCode Prod.fst := + AmplificationProgram.inputProgram.comp (EncodingPrograms.quotedFirst BinaryEncoding.unary middleCodec) + +noncomputable def inputW : Procedure parameters.encode unaryCode (fun x => x.2.1) := + AmplificationProgram.inputProgram.comp + ((EncodingPrograms.quotedFirst BinaryEncoding.unary tailCodec).comp + (EncodingPrograms.quotedSecond BinaryEncoding.unary middleCodec)) + +noncomputable def inputG : Procedure parameters.encode unaryCode (fun x => x.2.2.1) := + AmplificationProgram.inputProgram.comp + (((EncodingPrograms.quotedFirst BinaryEncoding.unary rationalCodec).comp + (EncodingPrograms.quotedSecond BinaryEncoding.unary tailCodec)).comp + (EncodingPrograms.quotedSecond BinaryEncoding.unary middleCodec)) + +noncomputable def inputJ : Procedure parameters.encode ratCode (fun x => x.2.2.2) := + rationalInput.comp + (((EncodingPrograms.quotedSecond BinaryEncoding.unary rationalCodec).comp + (EncodingPrograms.quotedSecond BinaryEncoding.unary tailCodec)).comp + (EncodingPrograms.quotedSecond BinaryEncoding.unary middleCodec)) + +noncomputable def inputProgram : Procedure parameters.encode rawCode id := + inputR.pair (inputW.pair (inputG.pair inputJ)) + +noncomputable def publicDelta : Procedure parameters.encode BinaryEncoding.natural.encode + (fun x => MediatorParameters.delta x.1 x.2.1 x.2.2.1) := + (EncodingPrograms.naturalOutput.comp (deltaProgram.comp inputProgram)).congrFun (by intro x; rfl) + +noncomputable def publicSpoke : Procedure parameters.encode rationalCodec.encode + (fun x => MediatorParameters.spoke x.1 x.2.1 x.2.2.1 x.2.2.2) := + (rationalOutput.comp (spokeProgram.comp inputProgram)).congrFun (by intro x; rfl) + +def output : BinaryEncoding.Codec (ℕ × ℚ) := BinaryEncoding.pair BinaryEncoding.natural rationalCodec + +noncomputable def pairedProgram : Procedure parameters.encode + (prodCode BinaryEncoding.natural.encode rationalCodec.encode) + (fun x => (MediatorParameters.delta x.1 x.2.1 x.2.2.1, + MediatorParameters.spoke x.1 x.2.1 x.2.2.1 x.2.2.2)) := publicDelta.pair publicSpoke + +/-- The actual finite machine, including rational normalization and square +root search, has polynomial runtime in the explicit unary/binary inputs. -/ +noncomputable def certificate : + Turing.TM2ComputableInPolyTime parameters.encode output.encode + (fun x => (MediatorParameters.delta x.1 x.2.1 x.2.2.1, + MediatorParameters.spoke x.1 x.2.1 x.2.2.1 x.2.2.2)) := + ((EncodingPrograms.appendPair BinaryEncoding.natural rationalCodec).comp pairedProgram).toTM2 + +theorem parameters_length (x : Input) : + (parameters.encode x).length = 2 * x.1 + 2 * x.2.1 + 2 * x.2.2.1 + 9 + + (rationalCodec.encode x.2.2.2).length := by + simp only [parameters, middleCodec, tailCodec, BinaryEncoding.pair_length, + BinaryEncoding.quoted_length, BinaryEncoding.unary_length] + omega + +/-- The emitted coefficient code has a polynomial length bound obtained +from the actual finite machine, including the square-root computation. -/ +theorem output_polynomial_size : ∃ p : Polynomial ℕ, ∀ x : Input, + (output.encode (MediatorParameters.delta x.1 x.2.1 x.2.2.1, + MediatorParameters.spoke x.1 x.2.1 x.2.2.1 x.2.2.2)).length ≤ + p.eval (parameters.encode x).length := by + refine ⟨Polynomial.X + certificate.time * Polynomial.C (TM2Size.programPushes certificate.tm), ?_⟩ + intro x + simpa only [Polynomial.eval_add, Polynomial.eval_X, Polynomial.eval_mul, Polynomial.eval_C] + using TM2Size.output_length certificate x + +end ContinuumCoulomb.MediatorProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorThreeStageProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorThreeStageProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2648910abd48660a3dbbf48e08040f81cf882a52 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorThreeStageProgram.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorUnaryProgram + +namespace OAI + +/-! The actual finite-stack program for all three simultaneous mediator +stages. It retains the first central bonds, subdivides the first spokes, +then subdivides all resulting six-bond paths. -/ + +namespace ContinuumCoulomb.MediatorThreeStageProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +noncomputable opaque environment : Procedure inputCode envCode Prod.fst := Procedure.first _ _ + +noncomputable opaque secondInput : Procedure inputCode inputCode + (fun x => (MediatorUnaryProgram.secondEnv x.1, MediatorListProgram.spokes x)) := + (MediatorUnaryProgram.secondProgram.comp environment).pair spokesProgram + +noncomputable opaque secondPaths : Procedure inputCode (listCode bondCode) + (fun x => central (MediatorUnaryProgram.secondEnv x.1, spokes x) ++ + spokes (MediatorUnaryProgram.secondEnv x.1, spokes x)) := + stageProgram.comp secondInput + +noncomputable opaque thirdInput : Procedure inputCode inputCode + (fun x => (MediatorUnaryProgram.thirdEnv x.1, + central (MediatorUnaryProgram.secondEnv x.1, spokes x) ++ + spokes (MediatorUnaryProgram.secondEnv x.1, spokes x))) := + (MediatorUnaryProgram.thirdProgram.comp environment).pair secondPaths + +def finalBonds (x : Input) : List Bond := + central x ++ + central (MediatorUnaryProgram.thirdEnv x.1, + central (MediatorUnaryProgram.secondEnv x.1, spokes x) ++ + spokes (MediatorUnaryProgram.secondEnv x.1, spokes x)) ++ + spokes (MediatorUnaryProgram.thirdEnv x.1, + central (MediatorUnaryProgram.secondEnv x.1, spokes x) ++ + spokes (MediatorUnaryProgram.secondEnv x.1, spokes x)) + +noncomputable opaque bondsProgram : Procedure inputCode (listCode bondCode) finalBonds := + ((Procedure.listAppend bondCode zeroBond).comp + (centralProgram.pair (stageProgram.comp thirdInput))).congrFun + (by intro x; exact (List.append_assoc _ _ _).symm) + +noncomputable opaque verticesProgram : Procedure inputCode unaryCode + (fun x => x.1.2.2.2 + 18 * x.1.1) := + MediatorUnaryProgram.finalN.comp environment + +noncomputable opaque boundProgram : Procedure inputCode unaryCode + (fun x => MediatorParameters.finalWeight x.1.1 x.1.2.1 x.1.2.2.1) := + MediatorUnaryProgram.finalWeight.comp environment + +def outputCode (x : Input) : List Bool := + prodCode unaryCode (prodCode unaryCode (listCode bondCode)) + (x.1.2.2.2 + 18 * x.1.1, + MediatorParameters.finalWeight x.1.1 x.1.2.1 x.1.2.2.1, finalBonds x) + +noncomputable opaque outputProgram : Procedure inputCode outputCode id := + (verticesProgram.pair (boundProgram.pair bondsProgram)).result (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode outputCode id := + outputProgram.toTM2 + +theorem finalBonds_length (x : Input) : (finalBonds x).length = 19 * x.2.length := by + simp only [finalBonds, List.length_append, central, spokes, List.length_map, List.length_range] + omega + +end ContinuumCoulomb.MediatorThreeStageProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorUnaryProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorUnaryProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4ab0ce2c407d602d8929e60788c029a0fbda737 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MediatorUnaryProgram.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorUnaryThird + +namespace OAI + +/-! Actual final unary coefficient and vertex bounds, with the arithmetic +nodes kept separate from the fixed finite machine texts. -/ + +namespace ContinuumCoulomb.MediatorUnaryProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +noncomputable opaque thirdDeltaRaw : Procedure envCode unaryCode + ((fun x : Env => MediatorParameters.delta x.1 x.2.1 x.2.2.1) ∘ thirdEnv) := + delta.comp thirdProgram +noncomputable opaque thirdDelta : Procedure envCode unaryCode (fun x : Env => + MediatorParameters.delta (6 * x.1) (MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) x.2.2.1) := + thirdDeltaRaw.congrFun (by intro x; rfl) +noncomputable opaque thirdSpokesRaw : Procedure envCode unaryCode + ((fun x : Env => 2 * MediatorParameters.scale x.1 x.2.1 x.2.2.1 * x.2.1) ∘ thirdEnv) := + spokeBound.comp thirdProgram +noncomputable opaque thirdSpokes : Procedure envCode unaryCode (fun x : Env => + 2 * MediatorParameters.scale (6 * x.1) (MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) x.2.2.1 * + MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) := + thirdSpokesRaw.congrFun (by intro x; rfl) +noncomputable opaque finalBase : Procedure envCode unaryCode (fun x : Env => + 2 + MediatorParameters.delta x.1 x.2.1 x.2.2.1) := + add.comp ((Procedure.constant envCode unaryCode 2).pair delta) +noncomputable opaque finalHead : Procedure envCode unaryCode (fun x : Env => + 2 + MediatorParameters.delta x.1 x.2.1 x.2.2.1 + + MediatorParameters.delta (6 * x.1) (MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) x.2.2.1) := + add.comp (finalBase.pair thirdDelta) +noncomputable opaque finalWeightRaw : Procedure envCode unaryCode (fun x : Env => + 2 + MediatorParameters.delta x.1 x.2.1 x.2.2.1 + + MediatorParameters.delta (6 * x.1) (MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) x.2.2.1 + + 2 * MediatorParameters.scale (6 * x.1) (MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) x.2.2.1 * + MediatorParameters.thirdWeight x.1 x.2.1 x.2.2.1) := + add.comp (finalHead.pair thirdSpokes) +noncomputable opaque finalWeight : Procedure envCode unaryCode + (fun x : Env => MediatorParameters.finalWeight x.1 x.2.1 x.2.2.1) := + finalWeightRaw.congrFun (by intro x; rfl) + +noncomputable opaque finalN : Procedure envCode unaryCode (fun x : Env => x.2.2.2 + 18 * x.1) := + add.comp (nProgram.pair (mul.comp + ((Procedure.constant envCode unaryCode 18).pair rProgram))) + +end ContinuumCoulomb.MediatorUnaryProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserCoordinateProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserCoordinateProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2452909ab83ee0e355fbaef9a77301c9590fd176 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserCoordinateProgram.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedEuler +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.ManufacturedVelocityProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EulerProgram + +namespace OAI + +/-! A deterministic polynomial TM2 program for the actual rounded Moser +coordinate construction. The fixed integers U,C occur as hardcoded constants; +precision is unary and geometric input data are binary rationals. -/ + +namespace ContinuumCoulomb.ManufacturedEuler +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) +open EulerRegisters + +abbrev Input := ManufacturedFieldEvaluation.Input +def inputCode : Input → List Bool := ManufacturedFieldEvaluation.inputCode + +noncomputable def value (rho U C : ℕ) (x : Input) : Triple := + approximate rho U C x.1 x.2.1.1 x.2.1.2 x.2.2.1 x.2.2.2 + +noncomputable opaque stepsProgram (C : ℕ) : Procedure unaryCode unaryCode (steps C) := + Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode (16*C^2)).pair Procedure.unarySuccessor) +noncomputable opaque inputStepsProgram (C : ℕ) : Procedure inputCode unaryCode (fun x => steps C x.1) := + (stepsProgram C).comp (Procedure.first unaryCode + (prodCode (prodCode ratCode ratCode) (prodCode ManufacturedFieldEvaluation.sitesCode tripleCode))) +noncomputable opaque denominatorProgram (C : ℕ) : Procedure inputCode Nat.bits (fun x => denominator C x.1) := by + let n := Procedure.unaryToBits.comp (inputStepsProgram C) + exact (Procedure.binaryMul.comp (n.pair n)).congrFun (by intro x; simp only [denominator,pow_two]; rfl) +noncomputable opaque inputPointProgram : Procedure inputCode tripleCode (fun x => x.2.2.2) := + ManufacturedFieldEvaluation.pointProgram + +noncomputable opaque inputRadiusProgram : Procedure tripleCode Nat.bits inputRadius := by + let a := Procedure.intAbs.comp (Procedure.ratNum.comp tripleFirstProgram) + let b := Procedure.intAbs.comp (Procedure.ratNum.comp tripleSecondProgram) + let c := Procedure.intAbs.comp (Procedure.ratNum.comp tripleThirdProgram) + exact Procedure.binaryAdd.comp ((Procedure.binaryAdd.comp (a.pair b)).pair c) +noncomputable opaque boxProgram (U C : ℕ) : Procedure inputCode Nat.bits + (fun x => boxNumerator U (denominator C x.1) x.2.2.2) := by + let r := inputRadiusProgram.comp inputPointProgram + let u := Procedure.constant inputCode Nat.bits U + let r' := Procedure.successor.comp (Procedure.binaryAdd.comp (r.pair u)) + exact (Procedure.binaryMul.comp ((denominatorProgram C).pair r')).congrFun (by intro x; rfl) +noncomputable opaque stepProgram (C : ℕ) : Procedure inputCode ratCode + (fun x => (steps C x.1:ℚ)⁻¹) := + Procedure.ratInv.comp (Procedure.natToRat.comp (Procedure.unaryToBits.comp (inputStepsProgram C))) + +noncomputable opaque environmentProgram (C : ℕ) : + Procedure inputCode ManufacturedVelocityEvaluation.environmentCode + (fun x => (steps C x.1,(x.2.1,x.2.2.1))) := + (inputStepsProgram C).pair + (ManufacturedFieldEvaluation.parametersProgram.pair ManufacturedFieldEvaluation.sitesProgram) +noncomputable opaque parameterNumbersProgram (U C : ℕ) : + Procedure inputCode (prodCode Nat.bits (prodCode Nat.bits ratCode)) + (fun x => (denominator C x.1,(boxNumerator U (denominator C x.1) x.2.2.2,(steps C x.1:ℚ)⁻¹))) := + (denominatorProgram C).pair ((boxProgram U C).pair (stepProgram C)) +noncomputable opaque parametersProgram (U C : ℕ) : + Procedure inputCode (parametersCode ManufacturedVelocityEvaluation.environmentCode) + (fun x => ((steps C x.1,(x.2.1,x.2.2.1)), + (denominator C x.1,(boxNumerator U (denominator C x.1) x.2.2.2,(steps C x.1:ℚ)⁻¹)))) := + (environmentProgram C).pair (parameterNumbersProgram U C) +noncomputable opaque registersProgram (U C : ℕ) : Procedure inputCode registersCode + (fun x => round (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) x.2.2.2) := + by + let p := roundProgram.comp (((denominatorProgram C).pair (boxProgram U C)).pair inputPointProgram) + exact p.congrFun (by intro x; rfl) +noncomputable opaque initialProgram (U C : ℕ) : + Procedure inputCode (configCode ManufacturedVelocityEvaluation.environmentCode) + (fun x => initial (steps C x.1,(x.2.1,x.2.2.1)) (steps C x.1) (denominator C x.1) + (boxNumerator U (denominator C x.1) x.2.2.2) + (round (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) x.2.2.2)) := + (parametersProgram U C).pair + ((Procedure.constant inputCode Nat.bits 0).pair (registersProgram U C)) +noncomputable opaque runArgumentsProgram (U C : ℕ) : + Procedure inputCode (prodCode unaryCode (configCode ManufacturedVelocityEvaluation.environmentCode)) + (fun x => (steps C x.1, initial (steps C x.1,(x.2.1,x.2.2.1)) (steps C x.1) + (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) + (round (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) x.2.2.2))) := + (inputStepsProgram C).pair (initialProgram U C) + +private theorem run_initial (rho : ℕ) (e : Environment) (N D B : ℕ) (r : Registers) : + run (evaluate rho) (N,initial e N D B r) = trajectory (evaluate rho) e N D B r N := by + change point (((advance (evaluate rho))^[N] (initial e N D B r)).1.2.1) + (((advance (evaluate rho))^[N] (initial e N D B r)).2.2) = _ + rw [iterate_parameters] + rfl + +noncomputable opaque program (rho U C : ℕ) : Procedure inputCode tripleCode (value rho U C) := by + let p := (EulerRegisters.program (E := Environment) + (ce := ManufacturedVelocityEvaluation.environmentCode) (evaluate := evaluate rho) + (ManufacturedVelocityEvaluation.program rho)).comp + (runArgumentsProgram U C) + exact p.congrFun (by + intro x + change run (evaluate rho) (steps C x.1,initial (steps C x.1,(x.2.1,x.2.2.1)) + (steps C x.1) (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) + (round (denominator C x.1) (boxNumerator U (denominator C x.1) x.2.2.2) x.2.2.2)) = _ + rw [run_initial] + rfl) + +noncomputable def certificate (rho U C : ℕ) : + Turing.TM2ComputableInPolyTime inputCode tripleCode (value rho U C) := (program rho U C).toTM2 + +end ContinuumCoulomb.ManufacturedEuler + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserDifferenceProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserDifferenceProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d55b051f648f066e878832507618c250ba434ad1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/MoserDifferenceProgram.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.MoserDifferenceBudget +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PiProgram + +namespace OAI + +/-! Literal polynomial integer arithmetic for the fixed finite-difference +precision and rational step of the manufactured field evaluator. -/ + +namespace ContinuumCoulomb.MoserDifferenceBudget +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque nextSquareProgram : Procedure unaryCode unaryCode (fun P => (P+1)^2) := + (Procedure.unaryMul.comp (Procedure.unarySuccessor.pair Procedure.unarySuccessor)).congrFun + (by intro P; simp only [pow_two]; rfl) + +noncomputable opaque nextCubeProgram : Procedure unaryCode unaryCode (fun P => (P+1)^3) := + (Procedure.unaryMul.comp (nextSquareProgram.pair Procedure.unarySuccessor)).congrFun + (by intro P; simp only [pow_succ]; rfl) + +/-- A fixed integer bounds the finite-difference precision independently of the +input instance. -/ +noncomputable opaque precisionScaleData : {n : ℕ // n = 16384*guard^2} := ⟨16384*guard^2,rfl⟩ +noncomputable def precisionScale : ℕ := precisionScaleData.val + +theorem precisionScale_eq : precisionScale = 16384*guard^2 := precisionScaleData.property + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode precision := by + let p := Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode precisionScale).pair nextCubeProgram) + exact p.congrFun (by + intro P + change precisionScale*(P+1)^3 = precision P + rw [precisionScale_eq] + rfl) + +noncomputable opaque stepDenominatorProgram : Procedure unaryCode ratCode + (fun P => 16*(guard:ℚ)*(P+1)) := by + let c := Procedure.constant unaryCode ratCode (16*(guard:ℚ)) + let p := Procedure.natToRat.comp (Procedure.unaryToBits.comp Procedure.unarySuccessor) + exact (Procedure.ratMul.comp (c.pair p)).congrFun (by intro P; change 16*(guard:ℚ)*(Nat.succ P:ℚ) = _; simp only [Nat.cast_succ]) + +noncomputable opaque stepProgram : Procedure unaryCode ratCode step := + Procedure.ratInv.comp stepDenominatorProgram + +end ContinuumCoulomb.MoserDifferenceBudget + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/NormalizationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/NormalizationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..46da08e1dd53e9fe88dcc579b4fe386da0339714 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/NormalizationProgram.lean @@ -0,0 +1,43 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NormalizationArithmetic + +namespace OAI + +/-! Actual polynomial TM2 computation of the normalization integral at +inverse-polynomial precision. Every mesh and sample parameter is built +using the proved unary arithmetic procedures. -/ + +namespace ContinuumCoulomb.NormalizationSchedule +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque radiusRationalProgram : Procedure unaryCode ratCode (fun P => (radius P : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp radiusProgram) + +noncomputable opaque meshRationalProgram : Procedure unaryCode ratCode (fun P => (mesh P : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp meshProgram) + +noncomputable opaque doubleRadiusRationalProgram : Procedure unaryCode ratCode + (fun P => ((2 * radius P : ℕ) : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp doubleRadiusProgram) + +noncomputable opaque lowerProgram : Procedure unaryCode ratCode (fun P => -(radius P : ℚ)) := + Procedure.ratNeg.comp radiusRationalProgram + +noncomputable opaque stepProgram : Procedure unaryCode ratCode + (fun P => (2 * (radius P : ℚ)) / (mesh P : ℚ)) := + (Procedure.ratDiv.comp (doubleRadiusRationalProgram.pair meshRationalProgram)).congrFun + (by intro P; simp only [Function.comp_apply, Nat.cast_mul, Nat.cast_ofNat]) + +noncomputable opaque inputProgram : + Procedure unaryCode (RationalRectangleProgram.inputCode NormalizationQuadrature.settingsCode) input := + (meshProgram.pair ((doubleRadiusProgram.pair accuracyProgram).pair + (lowerProgram.pair stepProgram))).congrFun (by intro P; rfl) + +noncomputable opaque program : Procedure unaryCode ratCode approximate := + (NormalizationQuadrature.program.comp inputProgram).congrFun (by intro P; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime unaryCode ratCode approximate := program.toTM2 + +end ContinuumCoulomb.NormalizationSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalNuclearProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalNuclearProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ad328db03e3c65b5120e9f256098fcf61128d43 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalNuclearProgram.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CenteredNuclearProgram + +namespace OAI + +/-! Physical nuclear coordinates for h=1/N. The exact rational factor is +1/λ=rho/(8N^3), matching the manuscript's y=λx convention. -/ + +namespace ContinuumCoulomb.PhysicalNuclearProgram +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode position) + +def factor (rho N : ℕ) : ℚ := (rho:ℚ)/(8*(N:ℚ)^3) +def scale (a : ℚ) (p : Triple) : Triple := (a*p.1,(a*p.2.1,a*p.2.2)) + +theorem factor_positive {rho N : ℕ} (hrho : 0 < rho) (hN : 0 < N) : 0 < factor rho N := by + unfold factor + positivity + +theorem factor_real (rho N : ℕ) : (factor rho N:ℝ) = (rho:ℝ)/(8*(N:ℝ)^3) := by + simp only [factor,Rat.cast_div,Rat.cast_mul,Rat.cast_pow,Rat.cast_natCast,Rat.cast_ofNat] + +theorem scale_position (a : ℚ) (p : Triple) : position (scale a p) = (a:ℝ) • position p := by + ext i + fin_cases i <;> simp [position,scale] + +theorem scale_injective {a : ℚ} (ha : a ≠ 0) : Function.Injective (scale a) := by + intro p q h + have hx : a*p.1 = a*q.1 := congrArg Prod.fst h + have hy : a*p.2.1 = a*q.2.1 := congrArg (fun p : Triple => p.2.1) h + have hz : a*p.2.2 = a*q.2.2 := congrArg (fun p : Triple => p.2.2) h + exact Prod.ext (mul_left_cancel₀ ha hx) + (Prod.ext (mul_left_cancel₀ ha hy) (mul_left_cancel₀ ha hz)) + +theorem scale_error {a : ℚ} (ha : 0 ≤ a) (p : Triple) (x : Position) {ε : ℝ} + (he : ‖position p-x‖ ≤ ε) : ‖position (scale a p)-(a:ℝ) • x‖ ≤ (a:ℝ)*ε := by + rw [scale_position,← smul_sub,norm_smul,Real.norm_of_nonneg (by exact_mod_cast ha)] + exact mul_le_mul_of_nonneg_left he (by exact_mod_cast ha) + +abbrev Input := CenteredNuclearProgram.Input +def inputCode : Input → List Bool := CenteredNuclearProgram.inputCode + +noncomputable def triples (rho U C K : ℕ) (x : Input) : List Triple := + (TransformedGauss.nodes rho U C K (x.1,CenteredGaussLabels.labels x.2)).map + (scale (factor rho x.1.1.2)) +noncomputable def nuclei (rho U C K : ℕ) (x : Input) : List BinaryPosition := + NuclearCoordinateOutput.positions (triples rho U C K x) + +noncomputable opaque meshProgram : Procedure inputCode Nat.bits (fun x => x.1.1.2) := + (Procedure.second unaryCode Nat.bits).comp + ((Procedure.first _ _).comp (Procedure.first _ _)) + +noncomputable opaque factorProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => factor rho x.1.1.2) := by + let n := meshProgram + let n2 := Procedure.binaryMul.comp (n.pair n) + let n3 := Procedure.binaryMul.comp (n2.pair n) + let denominator := Procedure.binaryMul.comp + ((Procedure.constant inputCode Nat.bits 8).pair n3) + let p := Procedure.ratDiv.comp + ((Procedure.constant inputCode ratCode (rho:ℚ)).pair (Procedure.natToRat.comp denominator)) + exact p.congrFun (by + intro x + change (rho:ℚ)/((8*((x.1.1.2*x.1.1.2)*x.1.1.2):ℕ):ℚ) = factor rho x.1.1.2 + simp only [factor,Nat.cast_mul,Nat.cast_ofNat,pow_succ,pow_zero,one_mul]) + +noncomputable opaque scaleProgram : Procedure (prodCode ratCode tripleCode) tripleCode + (fun x => scale x.1 x.2) := by + let a := Procedure.first ratCode tripleCode + let p := Procedure.second ratCode tripleCode + let x := EulerRegisters.tripleFirstProgram.comp p + let y := EulerRegisters.tripleSecondProgram.comp p + let z := EulerRegisters.tripleThirdProgram.comp p + exact (Procedure.ratMul.comp (a.pair x)).pair + ((Procedure.ratMul.comp (a.pair y)).pair (Procedure.ratMul.comp (a.pair z))) + +noncomputable opaque triplesProgram (rho U C K : ℕ) : + Procedure inputCode (listCode tripleCode) (triples rho U C K) := by + let raw := (TransformedGauss.listProgram rho U C K).comp CenteredNuclearProgram.argumentsProgram + exact (Procedure.listMapWith (ea := ratCode) (eb := tripleCode) (ec := tripleCode) + (f := scale) (0,(0,0)) (0,(0,0)) scaleProgram).comp ((factorProgram rho).pair raw) + +noncomputable opaque program (rho U C K : ℕ) : + Procedure inputCode (BinaryEncoding.list binaryPositionCodec).encode (nuclei rho U C K) := + NuclearCoordinateOutput.positionsProgram.comp (triplesProgram rho U C K) + +noncomputable def certificate (rho U C K : ℕ) : Turing.TM2ComputableInPolyTime inputCode + (BinaryEncoding.list binaryPositionCodec).encode (nuclei rho U C K) := + (program rho U C K).toTM2 + +theorem nuclei_length (rho U C K : ℕ) (x : Input) : + (nuclei rho U C K x).length = 8*((2*x.2.1+1)*(2*x.2.2.1+1)*(2*x.2.2.2+1)) := by + rw [nuclei,NuclearCoordinateOutput.positions_length,triples,List.length_map, + TransformedGauss.nodes_length,CenteredGaussLabels.labels_length] + +theorem nuclei_valid (rho U C K : ℕ) (x : Input) {p : BinaryPosition} + (hp : p ∈ nuclei rho U C K x) : p.Valid := NuclearCoordinateOutput.positions_valid _ hp + +theorem nuclei_nonempty (rho U C K : ℕ) (x : Input) : 0 < (nuclei rho U C K x).length := by + rw [nuclei_length] + positivity + +theorem nuclei_values_nodup (rho U C K : ℕ) (x : Input) (hrho : 0 < rho) + (hN : 0 < x.1.1.2) + (hnodes : (TransformedGauss.nodes rho U C K (x.1,CenteredGaussLabels.labels x.2)).Nodup) : + ((nuclei rho U C K x).map BinaryPosition.value).Nodup := by + have hs := hnodes.map (scale_injective (factor_positive hrho hN).ne') + have hm := hs.map NuclearCoordinateOutput.position_value_injective + simpa only [nuclei,NuclearCoordinateOutput.positions,List.map_map,Function.comp_def,triples] using hm + +end ContinuumCoulomb.PhysicalNuclearProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalThresholdProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalThresholdProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..45dd8972874dce8376dd188c8f4076814243d4a2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PhysicalThresholdProgram.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.PhysicalThreshold + +namespace OAI + +/-! Polynomial-time arithmetic for the complete physical threshold pair. -/ + +namespace ContinuumCoulomb.PhysicalThreshold +open ExactQuantumFactoring.BitStackProgram + +def geometryCode : Geometry → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) +def metadataCode : (ℕ×(ℕ×(ℚ×ℚ))) → List Bool := + prodCode unaryCode (prodCode unaryCode (prodCode ratCode ratCode)) +def inputCode : Input → List Bool := prodCode geometryCode metadataCode + +noncomputable opaque geometryProgram : Procedure inputCode geometryCode Prod.fst := Procedure.first _ _ +noncomputable opaque metadataProgram : Procedure inputCode metadataCode Prod.snd := Procedure.second _ _ +noncomputable opaque meshProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first _ _).comp geometryProgram +noncomputable opaque boxProgram : Procedure inputCode (prodCode unaryCode unaryCode) + (fun x => x.1.2) := (Procedure.second _ _).comp geometryProgram +noncomputable opaque electronsProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp metadataProgram +noncomputable opaque restProgram : Procedure inputCode (prodCode unaryCode (prodCode ratCode ratCode)) + (fun x => x.2.2) := (Procedure.second _ _).comp metadataProgram +noncomputable opaque errorProgram : Procedure inputCode unaryCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp restProgram +noncomputable opaque endpointsProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.2.2) := (Procedure.second _ _).comp restProgram + +noncomputable opaque meshCubeProgram : Procedure inputCode unaryCode (fun x => x.1.1^3) := + (ResolventSchedule.mulProgram.comp + ((ResolventSchedule.squareProgram.comp meshProgram).pair meshProgram)).congrFun + (by intro x; dsimp; ring) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode precision := by + let c8 := Procedure.constant inputCode unaryCode 8 + let scale := ResolventSchedule.mulProgram.comp (c8.pair meshCubeProgram) + let sq := ResolventSchedule.squareProgram.comp (Procedure.unarySuccessor.comp scale) + let first := ResolventSchedule.mulProgram.comp (c8.pair sq) + let second := ResolventSchedule.mulProgram.comp + (first.pair (Procedure.unarySuccessor.comp electronsProgram)) + exact (ResolventSchedule.mulProgram.comp + (second.pair (Procedure.unarySuccessor.comp errorProgram))).congrFun (by intro x; rfl) + +noncomputable opaque amplificationProgram (rho : ℕ) : Procedure inputCode ratCode + (fun x => amplification rho x.1.1) := by + let cube := Procedure.natToRat.comp (Procedure.unaryToBits.comp meshCubeProgram) + let num := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 8).pair cube) + exact (Procedure.ratDiv.comp + (num.pair (Procedure.constant inputCode ratCode (rho:ℚ)))).congrFun + (by intro x; simp [amplification]) + +noncomputable opaque referenceProgram (rho : ℕ) : Procedure inputCode ratCode (reference rho) := by + let slab := (SlabOriginSchedule.program rho).comp (precisionProgram.pair boxProgram) + let freq := (GaussianFrequency.program rho).comp precisionProgram + let sub := Procedure.ratSub.comp (freq.pair (Procedure.constant inputCode ratCode 1)) + let e0 := Procedure.ratDiv.comp (sub.pair (Procedure.constant inputCode ratCode 2)) + exact (Procedure.ratAdd.comp (slab.pair e0)).congrFun (by intro x; rfl) + +noncomputable opaque offsetProgram (rho : ℕ) : Procedure inputCode ratCode (offset rho) := by + let lambda := amplificationProgram rho + let square := Procedure.ratMul.comp (lambda.pair lambda) + let n := Procedure.natToRat.comp (Procedure.unaryToBits.comp electronsProgram) + let factor := Procedure.ratMul.comp (square.pair n) + exact (Procedure.ratMul.comp (factor.pair (referenceProgram rho))).congrFun + (by intro x; simp only [offset,pow_two,Function.comp_apply,id_eq]) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode (prodCode ratCode ratCode) (value rho) := by + let endpoints := endpointsProgram + let a := (Procedure.first ratCode ratCode).comp endpoints + let b := (Procedure.second ratCode ratCode).comp endpoints + let lower := Procedure.ratAdd.comp + ((offsetProgram rho).pair (Procedure.ratMul.comp ((amplificationProgram rho).pair a))) + let upper := Procedure.ratAdd.comp + ((offsetProgram rho).pair (Procedure.ratMul.comp ((amplificationProgram rho).pair b))) + exact lower.pair upper + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode + (prodCode ratCode ratCode) (value rho) := (program rho).toTM2 + +end ContinuumCoulomb.PhysicalThreshold + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PiProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PiProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1eec7dfd8d10b23d4e7fc0892caaca6c257830b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PiProgram.lean @@ -0,0 +1,101 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalQuadratureProgram +import OAI.Computability.QuantumFactoring.BitStackRationalDivision +import Mathlib.Analysis.SpecialFunctions.Integrals.Basic + +namespace OAI + +/-! A rational polynomial-time approximation to π from the integral of +`4 / (1+x²)` on `[0,1]`. The unary sample count gives absolute error `8/N`. +This supplies the normalizing constant in the heat-kernel evaluator. -/ + +namespace ContinuumCoulomb.PiProgram +open ExactQuantumFactoring.BitStackProgram +open RationalQuadratureProgram + +def evaluate (_ : ℚ) (q : ℚ) : ℚ := (1 + q ^ 2)⁻¹ + +def input (N : ℕ) : Input ℚ := (N, 0, 0, (N : ℚ)⁻¹) + +def approximate (N : ℕ) : ℚ := 4 * value evaluate (input N) + +noncomputable def evaluateProgram : + Procedure (prodCode ratCode ratCode) ratCode (fun x => evaluate x.1 x.2) := by + let q := Procedure.second ratCode ratCode + let square := Procedure.ratMul.comp (q.pair q) + let one := Procedure.constant (prodCode ratCode ratCode) ratCode (1 : ℚ) + exact (Procedure.ratInv.comp (Procedure.ratAdd.comp (one.pair square))).congrFun + (by intro x; simp only [evaluate, pow_two]; rfl) + +noncomputable def inputProgram : Procedure unaryCode (inputCode ratCode) input := by + let n := Procedure.identity unaryCode + let zero := Procedure.constant unaryCode ratCode (0 : ℚ) + let reciprocal := Procedure.ratInv.comp (Procedure.natToRat.comp Procedure.unaryToBits) + exact (n.pair (zero.pair (zero.pair reciprocal))).congrFun (by intro N; rfl) + +noncomputable def program : Procedure unaryCode ratCode approximate := by + let q := (RationalQuadratureProgram.program ratCode evaluate evaluateProgram).comp inputProgram + let four := Procedure.constant unaryCode ratCode (4 : ℚ) + exact (Procedure.ratMul.comp (four.pair q)).congrFun (by intro N; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime unaryCode ratCode approximate := program.toTM2 + +theorem reciprocal_continuous : Continuous (fun x : ℝ => (1 + x ^ 2)⁻¹) := + ((continuous_const : Continuous (fun _ : ℝ => (1 : ℝ))).add + (continuous_id.pow 2)).inv₀ (by intro x; change (1 : ℝ) + x ^ 2 ≠ 0; positivity) + +theorem reciprocal_lipschitz (x y : ℝ) (hx : x ∈ Set.Icc (0 : ℝ) 1) + (hy : y ∈ Set.Icc (0 : ℝ) 1) : + |(1 + x ^ 2)⁻¹ - (1 + y ^ 2)⁻¹| ≤ 2 * |x - y| := by + have hx0 : (1 : ℝ) + x ^ 2 ≠ 0 := by positivity + have hy0 : (1 : ℝ) + y ^ 2 ≠ 0 := by positivity + have hid : (1 + x ^ 2)⁻¹ - (1 + y ^ 2)⁻¹ = + ((y - x) * (y + x)) / ((1 + x ^ 2) * (1 + y ^ 2)) := by + field_simp + ring + have hd : 1 ≤ (1 + x ^ 2) * (1 + y ^ 2) := by + nlinarith [sq_nonneg x, sq_nonneg y, mul_nonneg (sq_nonneg x) (sq_nonneg y)] + rw [hid, abs_div, abs_mul, abs_of_nonneg (show 0 ≤ y + x by linarith [hx.1, hy.1]), + abs_of_pos (show 0 < (1 + x ^ 2) * (1 + y ^ 2) by linarith), abs_sub_comm y x] + apply (div_le_iff₀ (show 0 < (1 + x ^ 2) * (1 + y ^ 2) by linarith)).mpr + have hnum := mul_le_mul_of_nonneg_left (show y + x ≤ (2 : ℝ) by linarith [hx.2, hy.2]) + (abs_nonneg (x - y)) + have hden := mul_le_mul_of_nonneg_left hd (show 0 ≤ 2 * |x - y| by positivity) + nlinarith + +theorem endpoint (N : ℕ) (hN : 0 < N) : node (0 : ℚ) (N : ℚ)⁻¹ N = 1 := by + have hn : (N : ℚ) ≠ 0 := by exact_mod_cast hN.ne' + simp [node, hn] + +theorem error (N : ℕ) (hN : 0 < N) : + |(approximate N : ℝ) - Real.pi| ≤ 8 / (N : ℝ) := by + have hn : (0 : ℝ) < N := by exact_mod_cast hN + have h := RationalQuadratureProgram.error evaluate (input N) + (fun x : ℝ => (1 + x ^ 2)⁻¹) (L := 2) (ε := 0) + (by dsimp [input]; positivity) (by norm_num) reciprocal_continuous + (by + intro x hx y hy + simp only [input, endpoint N hN, Rat.cast_zero, Rat.cast_one] at hx hy + exact reciprocal_lipschitz x y hx hy) + (by + intro i hi + simp [sample, evaluate, input]) + have hi : (∫ x : ℝ in (0 : ℝ)..1, (1 + x ^ 2)⁻¹) = Real.pi / 4 := by + rw [integral_inv_one_add_sq, Real.arctan_one, Real.arctan_zero, sub_zero] + simp only [input, endpoint N hN, Rat.cast_zero, Rat.cast_one, Rat.cast_inv, Rat.cast_natCast, + mul_zero, add_zero, hi] at h + have heq : (approximate N : ℝ) - Real.pi = + 4 * ((value evaluate (input N) : ℝ) - Real.pi / 4) := by + simp only [approximate, Rat.cast_mul, Rat.cast_ofNat] + ring + rw [heq, abs_mul] + rw [abs_of_pos (by norm_num : (0 : ℝ) < 4)] + have hm := mul_le_mul_of_nonneg_left h (by norm_num : (0 : ℝ) ≤ 4) + have hs : 4 * ((N : ℝ) * (2 * (N : ℝ)⁻¹ ^ 2)) = 8 / (N : ℝ) := by + field_simp + ring + exact hm.trans_eq hs + +end ContinuumCoulomb.PiProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarForcingProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarForcingProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..5001cdcbbf00de7e1064de57d9caf451da55ba72 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarForcingProgram.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarForcing +import OAI.Computability.QuantumFactoring.BitStackRationals +import OAI.Computability.QuantumFactoring.BitStackProcedures + +namespace OAI + +/-! Exact rational evaluation of the actual compact planar forcing. +Only rational arithmetic and a sign test occur. -/ + +namespace ContinuumCoulomb.PlanarForcingProgram +open ExactQuantumFactoring.BitStackProgram + +def position (q : ℚ × ℚ) : PlanarPosition := WithLp.toLp 2 ![(q.1 : ℝ), (q.2 : ℝ)] + +def value (q : ℚ × ℚ) : ℚ := max (1 - (q.1 ^ 2 + q.2 ^ 2)) 0 ^ 16 + +theorem position_norm_sq (q : ℚ × ℚ) : + ‖position q‖ ^ 2 = (q.1 : ℝ) ^ 2 + (q.2 : ℝ) ^ 2 := by + rw [EuclideanSpace.norm_sq_eq] + simp only [Fin.sum_univ_two, position, PiLp.toLp_apply, Matrix.cons_val_zero, + Matrix.cons_val_one, Matrix.cons_val_fin_one, Real.norm_eq_abs, sq_abs] + +theorem value_cast (q : ℚ × ℚ) : (value q : ℝ) = planarForcing (position q) := by + rw [planarForcing, positivePartSixteen, position_norm_sq] + unfold value + push_cast + rfl + +noncomputable def program : Procedure (prodCode ratCode ratCode) ratCode value := by + let x := Procedure.first ratCode ratCode + let y := Procedure.second ratCode ratCode + let xsq := Procedure.ratMul.comp (x.pair x) + let ysq := Procedure.ratMul.comp (y.pair y) + let squareSum := Procedure.ratAdd.comp (xsq.pair ysq) + let one := Procedure.constant (prodCode ratCode ratCode) ratCode (1 : ℚ) + let zero := Procedure.constant (prodCode ratCode ratCode) ratCode (0 : ℚ) + let z := Procedure.ratSub.comp (one.pair squareSum) + let negative := Procedure.intSign.comp (Procedure.ratNum.comp z) + let positive := Procedure.conditional negative zero z + let second := Procedure.ratMul.comp (positive.pair positive) + let fourth := Procedure.ratMul.comp (second.pair second) + let eighth := Procedure.ratMul.comp (fourth.pair fourth) + let sixteenth := Procedure.ratMul.comp (eighth.pair eighth) + exact sixteenth.congrFun (by + intro q + simp only [Function.comp_apply, Rat.num_neg, decide_eq_true_eq] + unfold value + simp only [pow_two] + split_ifs with h + · rw [max_eq_right (le_of_lt h)] + norm_num + · rw [max_eq_left (le_of_not_gt h)] + ring) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime (prodCode ratCode ratCode) ratCode value := program.toTM2 + +end ContinuumCoulomb.PlanarForcingProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarWellProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarWellProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e684216afa3a726129dc66ed7f553fca13f8a02 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PlanarWellProgram.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarWellNumerics + +namespace OAI + +/-! The fixed well profile has an actual rational polynomial-time +evaluator. The positive denominator guard is independent of all inputs. -/ + +namespace ContinuumCoulomb.PlanarWellNumerics +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × (ℚ × ℚ) +def inputCode : Input → List Bool := prodCode unaryCode (prodCode ratCode ratCode) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode precision := + (Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode (4*guard^2)).pair + Procedure.unarySuccessor)).congrFun (by intro p; rfl) + +noncomputable opaque normSquareProgram : Procedure (prodCode ratCode ratCode) ratCode + (fun q => q.1^2+q.2^2) := by + let x := Procedure.first ratCode ratCode + let y := Procedure.second ratCode ratCode + let xx := Procedure.ratMul.comp (x.pair x) + let yy := Procedure.ratMul.comp (y.pair y) + exact (Procedure.ratAdd.comp (xx.pair yy)).congrFun (by intro q; simp only [pow_two]; rfl) + +noncomputable opaque program : Procedure inputCode ratCode + (fun x => approximate x.1 x.2) := by + let p := precisionProgram.comp (Procedure.first unaryCode (prodCode ratCode ratCode)) + let q := Procedure.second unaryCode (prodCode ratCode ratCode) + let r := Procedure.constant inputCode unaryCode 2 + let one := Procedure.constant inputCode ratCode (1:ℚ) + let zero := Procedure.constant inputCode ratCode (0:ℚ) + let two := Procedure.constant inputCode ratCode (2:ℚ) + let norm := normSquareProgram.comp q + let inside := Procedure.intSign.comp (Procedure.ratNum.comp (Procedure.ratSub.comp (norm.pair one))) + let forcing := Procedure.ratNeg.comp (PlanarForcingProgram.program.comp q) + let phi := ResolventSchedule.program.comp ((r.pair p).pair q) + let sample := Procedure.ratDiv.comp (forcing.pair (Procedure.ratMul.comp (two.pair phi))) + exact (Procedure.conditional inside sample zero).congrFun (by + intro x + simp only [Function.comp_apply,Rat.num_neg,decide_eq_true_eq] + unfold approximate outside + change (if x.2.1^2+x.2.2^2-1 < 0 then + -PlanarForcingProgram.value x.2/(2*ResolventSchedule.approximate ((2,precision x.1),x.2)) + else 0) = (if 1 ≤ x.2.1^2+x.2.2^2 then 0 else + -PlanarForcingProgram.value x.2/(2*ResolventSchedule.approximate ((2,precision x.1),x.2))) + by_cases hq : 1 ≤ x.2.1^2+x.2.2^2 + · rw [ite_eq_right (by linarith),ite_eq_left hq] + · rw [ite_eq_left (by linarith),ite_eq_right hq]) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => approximate x.1 x.2) := program.toTM2 + +end ContinuumCoulomb.PlanarWellNumerics + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialConstantBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialConstantBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..e629e2d418441931ce64eb1c8463ba40f0e08880 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialConstantBounds.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CoulombCalibration + +namespace OAI + +/-! Fixed positive analytic constants fit uniform polynomial ranges for +every size parameter at least two. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem exists_polynomial_constant_bounds {c : ℝ} (hc : 0 < c) (C : ℝ) : + ∃ q : ℕ, 0 < q ∧ ∀ N : ℝ, 2 ≤ N → (N ^ q)⁻¹ ≤ c ∧ C ≤ N ^ q := by + obtain ⟨q, hq⟩ := exists_nat_ge (max 1 (max (1 / c) C)) + have hq₁ : (1 : ℝ) ≤ q := (le_max_left _ _).trans hq + have hqc : 1 / c ≤ (q : ℝ) := (le_max_left _ _).trans ((le_max_right _ _).trans hq) + have hqC : C ≤ (q : ℝ) := (le_max_right _ _).trans ((le_max_right _ _).trans hq) + have hpow : (q : ℝ) ≤ (2 : ℝ) ^ q := by exact_mod_cast (Nat.lt_two_pow_self (n := q)).le + refine ⟨q, by exact_mod_cast (by linarith : (0 : ℝ) < q), fun N hN => ?_⟩ + have hNp : 0 < N := by linarith + have hp := hpow.trans (pow_le_pow_left₀ (by norm_num) hN q) + refine ⟨?_, hqC.trans hp⟩ + rw [inv_eq_one_div] + apply (div_le_iff₀ (pow_pos hNp q)).mpr + have h := (div_le_iff₀ hc).mp (hqc.trans hp) + nlinarith only [h] + +theorem sqrt_polynomial_bounds {N K : ℝ} {A : ℕ} (hN : 1 ≤ N) + (hKlo : (N ^ A)⁻¹ ≤ K) (hKhi : K ≤ N ^ A) : + (N ^ A)⁻¹ ≤ Real.sqrt K ∧ Real.sqrt K ≤ N ^ A := by + have hp : 1 ≤ N ^ A := one_le_pow₀ hN + have hp0 : 0 < N ^ A := by positivity + have hi : 0 ≤ (N ^ A)⁻¹ := inv_nonneg.mpr hp0.le + have hi₁ : (N ^ A)⁻¹ ≤ 1 := (inv_le_one₀ hp0).mpr hp + constructor + · apply Real.le_sqrt_of_sq_le + exact (by nlinarith only [hi, hi₁] : ((N ^ A)⁻¹) ^ 2 ≤ (N ^ A)⁻¹).trans hKlo + · apply Real.sqrt_le_iff.mpr + exact ⟨hp0.le, hKhi.trans (by nlinarith only [hp])⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialHoppingSmallness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialHoppingSmallness.lean new file mode 100644 index 0000000000000000000000000000000000000000..f885baa38b1b36490e0ab7e672cd2c3eaebdbbe0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialHoppingSmallness.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibratedHoppingBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds + +namespace OAI + +/-! Explicit natural exponents make calibrated hopping perturbatively +small and leave an inverse-polynomial fraction of its squared scale. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +theorem pow_mul_inverse_add {N : ℝ} (hN : 0 < N) (a b : ℕ) : + N ^ a * (N ^ (a + b))⁻¹ = (N ^ b)⁻¹ := by + rw [pow_add, mul_inv_rev] + field_simp [pow_ne_zero a hN.ne', pow_ne_zero b hN.ne'] + +theorem inverse_power_lt_half {N : ℝ} (hN : 2 ≤ N) {E : ℕ} (hE : 2 ≤ E) : + (N ^ E)⁻¹ < 1 / 2 := by + have hNp : 0 < N := by linarith + have hp : (4 : ℝ) ≤ N ^ E := by + have hs : (4 : ℝ) ≤ N ^ 2 := by nlinarith + exact hs.trans (pow_le_pow_right₀ (by linarith : 1 ≤ N) hE) + have hi : (N ^ E)⁻¹ ≤ (4 : ℝ)⁻¹ := inv_anti₀ (by norm_num) hp + exact hi.trans_lt (by norm_num) + +theorem polynomial_hopping_smallness {Edge : Type*} [Fintype Edge] + {freq scale N : ℝ} (hN : 2 ≤ N) (R A L E : ℕ) + (hc : (N ^ L)⁻¹ ≤ localizedGramConstant freq) + (hU : Real.sqrt (localizedCoulombProfile freq 0) ≤ N ^ L) + (hr : (Fintype.card Edge : ℝ) ≤ N ^ R) (distance K : Edge → ℝ) + (hK : ∀ e, 0 ≤ K e) (hKhi : ∀ e, K e ≤ N ^ A) + (hcal : ∀ e, scale * planarHopping (distance e) = + coulombHoppingTarget freq (N ^ (E + (R + A + 2 * L + 2)))⁻¹ (K e) (distance e)) : + 4 * ∑ e, |scale * planarHopping (distance e)| ≤ (N ^ E)⁻¹ * localizedGramConstant freq := by + have hNp : 0 < N := by linarith + have hN₁ : 1 ≤ N := by linarith + let B := E + (R + A + 2 * L + 2) + have hτ : 0 ≤ (N ^ B)⁻¹ := inv_nonneg.mpr (pow_nonneg hNp.le B) + have hsqrt : Real.sqrt (N ^ A * localizedCoulombProfile freq 0) ≤ N ^ (A + L) := by + rw [Real.sqrt_mul (pow_nonneg hNp.le A), pow_add] + apply mul_le_mul ?_ hU (Real.sqrt_nonneg _) (pow_nonneg hNp.le A) + apply Real.sqrt_le_iff.mpr + have hp : 1 ≤ N ^ A := one_le_pow₀ hN₁ + exact ⟨by positivity, by nlinarith only [hp]⟩ + have hb := calibrated_hopping_sum_bound freq scale (N ^ B)⁻¹ (N ^ A) hτ distance K hK hKhi hcal + have hbound : 4 * (Fintype.card Edge : ℝ) * ((N ^ B)⁻¹ * + Real.sqrt (N ^ A * localizedCoulombProfile freq 0)) ≤ 4 * (N ^ (E + L + 2))⁻¹ := by + calc + _ ≤ 4 * N ^ R * ((N ^ B)⁻¹ * N ^ (A + L)) := + mul_le_mul (mul_le_mul_of_nonneg_left hr (by norm_num)) + (mul_le_mul_of_nonneg_left hsqrt hτ) + (mul_nonneg hτ (Real.sqrt_nonneg _)) (by positivity) + _ = 4 * (N ^ (R + (A + L)) * (N ^ B)⁻¹) := by rw [pow_add]; ring + _ = _ := by + rw [show B = (R + (A + L)) + (E + L + 2) by dsimp [B]; omega, + pow_mul_inverse_add hNp] + have hfour : 4 * (N ^ (E + L + 2))⁻¹ ≤ (N ^ (E + L))⁻¹ := by + have hsq : (4 : ℝ) ≤ N ^ 2 := by nlinarith + have h := mul_le_mul_of_nonneg_left hsq (pow_nonneg hNp.le (E + L)) + have hratio : 4 / N ^ (E + L + 2) ≤ 1 / N ^ (E + L) := + (div_le_div_iff₀ (pow_pos hNp (E + L + 2)) (pow_pos hNp (E + L))).mpr + (by simpa only [pow_add, one_mul, mul_one, mul_comm] using h) + simpa only [div_eq_mul_inv, one_mul] using hratio + have hlast : (N ^ (E + L))⁻¹ ≤ (N ^ E)⁻¹ * localizedGramConstant freq := by + have h := mul_le_mul_of_nonneg_left hc (inv_nonneg.mpr (pow_nonneg hNp.le E)) + simpa only [pow_add, mul_inv_rev, mul_comm] using h + exact hb.trans (hbound.trans (hfour.trans hlast)) + +theorem polynomial_hubbard_error_budget {N c : ℝ} (hN : 0 < N) (R A L g : ℕ) + (hc : 2 * c ≤ N ^ L) : + let C := R + A + 2 * L + 2 + let E := g + 2 * C + L + let B := E + C + 2 * c * ((N ^ E)⁻¹) ^ 3 ≤ (N ^ g)⁻¹ * ((N ^ B)⁻¹) ^ 2 := by + intro C E B + calc + _ ≤ N ^ L * ((N ^ E)⁻¹) ^ 3 := + mul_le_mul_of_nonneg_right hc (pow_nonneg (inv_nonneg.mpr (pow_nonneg hN.le E)) 3) + _ = N ^ L * (N ^ (E * 3))⁻¹ := by rw [inv_pow (N ^ E) 3, ← pow_mul] + _ = (N ^ (g + B * 2))⁻¹ := by + rw [show E * 3 = L + (g + B * 2) by dsimp [B, E, C]; omega, pow_mul_inverse_add hN] + _ = _ := by rw [pow_add, pow_mul, mul_inv_rev, inv_pow]; ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialResidualBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialResidualBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccf22fb6dd6f823ef132b98ac1af55028a341515 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialResidualBudget.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialConstantBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabPolynomialResidual + +namespace OAI + +/-! A fixed polynomial scale absorbs the four residual contributions after +physical amplification. The exponent can be chosen before the source size. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem logarithmic_separation_residual {N D : ℝ} (hN : 2 ≤ N) (k : ℕ) + (hD : 25*(k:ℝ)*Real.log N ≤ D) : + Real.exp (-(19/10:ℝ)*D) ≤ ((N^k)^40)⁻¹ := by + have hN0 : 0 < N := by linarith + have hklog : 0 ≤ (k:ℝ)*Real.log N := + mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by linarith)) + have he := Real.exp_le_exp.mpr + (show -(19/10:ℝ)*D ≤ -40*(k:ℝ)*Real.log N by nlinarith only [hD,hklog]) + apply he.trans_eq + rw [show -40*(k:ℝ)*Real.log N = -((40*k:ℕ):ℝ)*Real.log N by push_cast; ring, + neg_mul,Real.exp_neg,Real.exp_nat_mul,Real.exp_log hN0] + congr 1 + rw [← pow_mul] + congr 1 + omega + +theorem exists_four_residual_power (A B C D : ℝ) + (_hA : 0 ≤ A) (hB : 0 ≤ B) (hC : 0 ≤ C) (_hD : 0 ≤ D) (s p : ℕ) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ k : ℕ, k₀ ≤ k → ∀ N : ℝ, 2 ≤ N → + A*N^s/(N^k)^10+B*N^s/(N^k)^40+C*N^s/(N^k)^30+D*N^s/(N^k)^10 ≤ + (N^p)⁻¹ := by + obtain ⟨q,hq,hconst⟩ := exists_polynomial_constant_bounds + (show (0:ℝ)<1 by norm_num) (A+B+C+D) + refine ⟨q+s+p+1,by omega,fun k hk N hN => ?_⟩ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hR : 1 ≤ N^k := one_le_pow₀ hN1 + have hB' : B*N^s/(N^k)^40 ≤ B*N^s/(N^k)^10 := + div_le_div_of_nonneg_left (by positivity) (by positivity) + (pow_le_pow_right₀ hR (by decide : 10 ≤ 40)) + have hC' : C*N^s/(N^k)^30 ≤ C*N^s/(N^k)^10 := + div_le_div_of_nonneg_left (by positivity) (by positivity) + (pow_le_pow_right₀ hR (by decide : 10 ≤ 30)) + calc + _ ≤ A*N^s/(N^k)^10+B*N^s/(N^k)^10+C*N^s/(N^k)^10+D*N^s/(N^k)^10 := + add_le_add (add_le_add (add_le_add le_rfl hB') hC') le_rfl + _ = (A+B+C+D)*N^s/(N^k)^10 := by ring + _ ≤ N^q*N^s/(N^k)^10 := by + apply div_le_div_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_right (hconst N hN).2 (by positivity) + _ = N^(q+s)/N^(k*10) := by rw [pow_add,pow_mul] + _ ≤ (N^p)⁻¹ := by + rw [inv_eq_one_div,div_le_div_iff₀ (pow_pos hN0 _) (pow_pos hN0 _), + one_mul,← pow_add] + exact pow_le_pow_right₀ hN1 (by omega) + +theorem exists_four_residual_norm_offset (A B C D : ℝ) + (_hA : 0 ≤ A) (hB : 0 ≤ B) (hC : 0 ≤ C) (_hD : 0 ≤ D) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ s k : ℕ, k₀+s ≤ k → ∀ N : ℝ, 2 ≤ N → + A*N^s/(N^k)^40+B*N^s/(N^k)^70+C*N^s/(N^k)^60+D*N^s/(N^k)^40 ≤ + ((N^k)^19)⁻¹^2 := by + obtain ⟨q,hq,hconst⟩ := exists_polynomial_constant_bounds + (show (0:ℝ)<1 by norm_num) (A+B+C+D) + refine ⟨q+1,by omega,fun s k hk N hN => ?_⟩ + have hN0 : 0 < N := by linarith + have hN1 : 1 ≤ N := by linarith + have hR : 1 ≤ N^k := one_le_pow₀ hN1 + have hB' : B*N^s/(N^k)^70 ≤ B*N^s/(N^k)^40 := + div_le_div_of_nonneg_left (by positivity) (by positivity) + (pow_le_pow_right₀ hR (by decide : 40 ≤ 70)) + have hC' : C*N^s/(N^k)^60 ≤ C*N^s/(N^k)^40 := + div_le_div_of_nonneg_left (by positivity) (by positivity) + (pow_le_pow_right₀ hR (by decide : 40 ≤ 60)) + calc + _ ≤ A*N^s/(N^k)^40+B*N^s/(N^k)^40+C*N^s/(N^k)^40+D*N^s/(N^k)^40 := + add_le_add (add_le_add (add_le_add le_rfl hB') hC') le_rfl + _ = (A+B+C+D)*N^s/(N^k)^40 := by ring + _ ≤ N^q*N^s/(N^k)^40 := by + apply div_le_div_of_nonneg_right _ (by positivity) + exact mul_le_mul_of_nonneg_right (hconst N hN).2 (by positivity) + _ ≤ 1/(N^k)^38 := by + rw [div_le_div_iff₀ (pow_pos (pow_pos hN0 k) _) (pow_pos (pow_pos hN0 k) _), + one_mul,← pow_add,← pow_mul,← pow_add,← pow_mul] + exact pow_le_pow_right₀ hN1 (by omega) + _ = _ := by simp only [one_div,inv_pow,← pow_mul,Nat.mul_assoc] + +theorem exists_four_residual_norm_power (A B C D : ℝ) + (hA : 0 ≤ A) (hB : 0 ≤ B) (hC : 0 ≤ C) (hD : 0 ≤ D) (s : ℕ) : + ∃ k₀ : ℕ, 1 ≤ k₀ ∧ ∀ k : ℕ, k₀ ≤ k → ∀ N : ℝ, 2 ≤ N → + A*N^s/(N^k)^40+B*N^s/(N^k)^70+C*N^s/(N^k)^60+D*N^s/(N^k)^40 ≤ + ((N^k)^19)⁻¹^2 := by + obtain ⟨q,hq,hbound⟩ := exists_four_residual_norm_offset A B C D hA hB hC hD + exact ⟨q+s,by omega,fun k hk => hbound s k hk⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialTimeSize.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialTimeSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..16e2b2241364612cf07695318682c270c5143c77 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialTimeSize.lean @@ -0,0 +1,125 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumVerifier + +namespace OAI + +/-! A polynomial-time TM2 program has polynomial output bit length. The +constant below counts the pushes in its finite program text, rather than +assuming an output-size estimate as an additional complexity axiom. -/ + +namespace ContinuumCoulomb +open Turing StateTransition +open scoped BigOperators + +namespace TM2Size + +/-- Maximum number of pushes along one finite statement branch. -/ +def pushes {K : Type} {Γ : K → Type} {Λ σ : Type} : TM2.Stmt Γ Λ σ → ℕ + | .push _ _ q => pushes q + 1 + | .peek _ _ q => pushes q + | .pop _ _ q => pushes q + | .load _ q => pushes q + | .branch _ q r => max (pushes q) (pushes r) + | .goto _ => 0 + | .halt => 0 + +theorem stepAux_stack_length {K : Type} [DecidableEq K] {Γ : K → Type} {Λ σ : Type} + (q : TM2.Stmt Γ Λ σ) (v : σ) (S : ∀ k, List (Γ k)) (k : K) : + ((TM2.stepAux q v S).stk k).length ≤ (S k).length + pushes q := by + induction q generalizing v S with + | push j f q ih => + have h := ih v (Function.update S j (f v :: S j)) + have hu : (Function.update S j (f v :: S j) k).length ≤ (S k).length + 1 := by + by_cases hj : k = j + · subst k; simp + · simp [Function.update_of_ne hj] + change ((TM2.stepAux q v (Function.update S j (f v :: S j))).stk k).length ≤ _ + unfold pushes + omega + | peek j f q ih => exact ih _ _ + | pop j f q ih => + have h := ih (f v (S j).head?) (Function.update S j (S j).tail) + have hu : (Function.update S j (S j).tail k).length ≤ (S k).length := by + by_cases hj : k = j + · subst k; simp + · simp [Function.update_of_ne hj] + change ((TM2.stepAux q (f v (S j).head?) (Function.update S j (S j).tail)).stk k).length ≤ _ + unfold pushes + omega + | load f q ih => exact ih _ _ + | branch f q r ihq ihr => + change ((cond (f v) (TM2.stepAux q v S) (TM2.stepAux r v S)).stk k).length ≤ _ + cases hf : f v + · simpa only [hf, Bool.cond_false, pushes] using (ihr v S).trans + (Nat.add_le_add_left (le_max_right (pushes q) (pushes r)) (S k).length) + · simpa only [hf, Bool.cond_true, pushes] using (ihq v S).trans + (Nat.add_le_add_left (le_max_left (pushes q) (pushes r)) (S k).length) + | goto f => simp [pushes, TM2.stepAux] + | halt => simp [pushes, TM2.stepAux] + +/-- A finite program has a fixed bound on pushes in one machine step. -/ +def programPushes (tm : FinTM2) : ℕ := by + letI := tm.ΛFin + exact Finset.univ.sup (fun l => pushes (tm.m l)) + +theorem step_stack_length (tm : FinTM2) (a b : tm.Cfg) (k : tm.K) + (h : tm.step a = some b) : + (b.stk k).length ≤ (a.stk k).length + programPushes tm := by + let := tm.ΛFin + cases a with + | mk l v S => + cases l with + | none => simp [FinTM2.step, TM2.step] at h + | some l => + have hb : TM2.stepAux (tm.m l) v S = b := by + exact Option.some.inj h + rw [← hb] + exact (stepAux_stack_length (tm.m l) v S k).trans + (Nat.add_le_add_left (Finset.le_sup (f := fun l => pushes (tm.m l)) (Finset.mem_univ l)) _) + +theorem iterate_stack_length (tm : FinTM2) (n : ℕ) (a b : tm.Cfg) (k : tm.K) + (h : (fun x : Option tm.Cfg => x.bind tm.step)^[n] (some a) = some b) : + (b.stk k).length ≤ (a.stk k).length + n * programPushes tm := by + induction n generalizing b with + | zero => + have hab : a = b := by simpa only [Function.iterate_zero_apply, Option.some.injEq] using h + subst b + simp + | succ n ih => + rw [Function.iterate_succ_apply'] at h + cases he : (fun x : Option tm.Cfg => x.bind tm.step)^[n] (some a) with + | none => simp only [he, Option.bind_none] at h; contradiction + | some c => + have hs : tm.step c = some b := by simpa only [he, Option.bind_some] using h + have hc := ih c he + have hb := step_stack_length tm c b k hs + rw [Nat.succ_mul] + omega + +theorem init_stack_length (tm : FinTM2) (L : List (tm.Γ tm.k₀)) (k : tm.K) : + ((initList tm L).stk k).length ≤ L.length := by + by_cases hk : k = tm.k₀ + · subst k; simp [initList] + · simp [initList, hk] + +/-- Bit output length is bounded directly from a genuine polynomial-time +certificate; this is needed when composing the hardness reduction. -/ +theorem output_length {α β : Type} {ea : α → List Bool} {eb : β → List Bool} + {f : α → β} (h : TM2ComputableInPolyTime ea eb f) (a : α) : + (eb (f a)).length ≤ (ea a).length + h.time.eval (ea a).length * programPushes h.tm := by + have ho := h.outputsFun a + have hi : ((initList h.tm (List.map h.inputAlphabet.invFun (ea a))).stk h.tm.k₁).length ≤ + (ea a).length := by + simpa only [List.length_map] using + init_stack_length h.tm (List.map h.inputAlphabet.invFun (ea a)) h.tm.k₁ + have hv := iterate_stack_length h.tm ho.steps + (initList h.tm (List.map h.inputAlphabet.invFun (ea a))) + (haltList h.tm (List.map h.outputAlphabet.invFun (eb (f a)))) h.tm.k₁ ho.evals_in_steps + have hout : ((haltList h.tm (List.map h.outputAlphabet.invFun (eb (f a)))).stk h.tm.k₁).length = + (eb (f a)).length := by simp [haltList] + rw [hout] at hv + exact hv.trans (Nat.add_le_add hi (Nat.mul_le_mul_right _ ho.steps_le_m)) + +end TM2Size +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialUnaryBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialUnaryBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc272fa2fc733057de20778e407f5d7469ee72d7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PolynomialUnaryBounds.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceMetadataProgram + +namespace OAI + +/-! Convert the runtime bound of an actual unary-output procedure into a +single fixed power of the source input length, as needed by calibration. -/ + +namespace ContinuumCoulomb +open ExactQuantumFactoring.BitStackProgram + +theorem natPolynomial_power_bound (p : Polynomial ℕ) : + ∃ k : ℕ, ∀ n : ℕ, p.eval n ≤ (n + 2) ^ k := by + induction p using Polynomial.induction_on' with + | add p q hp hq => + obtain ⟨a, ha⟩ := hp + obtain ⟨b, hb⟩ := hq + refine ⟨a + b + 1, fun n => ?_⟩ + have hbase : 1 ≤ n + 2 := by omega + have hpa : (n + 2) ^ a ≤ (n + 2) ^ (a + b) := + pow_le_pow_right₀ hbase (by omega) + have hpb : (n + 2) ^ b ≤ (n + 2) ^ (a + b) := + pow_le_pow_right₀ hbase (by omega) + rw [Polynomial.eval_add, pow_succ] + calc + p.eval n + q.eval n ≤ (n + 2) ^ (a + b) + (n + 2) ^ (a + b) := + Nat.add_le_add ((ha n).trans hpa) ((hb n).trans hpb) + _ = (n + 2) ^ (a + b) * 2 := by omega + _ ≤ _ := Nat.mul_le_mul_left _ (by omega) + | monomial i c => + refine ⟨c + i, fun n => ?_⟩ + have hc : c ≤ (n + 2) ^ c := + (Nat.lt_two_pow_self (n := c)).le.trans (Nat.pow_le_pow_left (by omega) c) + rw [Polynomial.eval_monomial, pow_add] + exact Nat.mul_le_mul hc (Nat.pow_le_pow_left (by omega) i) + +theorem unaryProcedure_power_bound {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : + ∃ k : ℕ, ∀ a, f a ≤ ((ea a).length + 2) ^ k := by + obtain ⟨k, hk⟩ := natPolynomial_power_bound (Polynomial.X + p.bound) + refine ⟨k, fun a => ?_⟩ + have h := p.output_length_le a + simp only [unaryCode, List.length_replicate] at h + exact h.trans (by simpa only [Polynomial.eval_add, Polynomial.eval_X] using hk (ea a).length) + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorCalibrationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorCalibrationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..14b26690a9dd485b6a3d6c745b781755cc055415 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorCalibrationProgram.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PrefactorCalibration + +namespace OAI + +/-! The fixed rational prefactor needs only two extra arithmetic operations +before the existing certified calibration program. -/ + +namespace ContinuumCoulomb.PrefactorCalibration +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque weightProgram (a : ℚ) : Procedure ratCode ratCode (adjustedWeight a) := + Procedure.ratDiv.comp ((Procedure.identity ratCode).pair + (Procedure.constant ratCode ratCode (a^2))) + +noncomputable opaque precisionProgram (C : ℕ) : Procedure unaryCode unaryCode (precision C) := + Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode C).pair Procedure.unarySuccessor) + +noncomputable opaque inputProgram (a : ℚ) (C : ℕ) : + Procedure AutomaticCalibration.inputCode AutomaticCalibration.inputCode (input a C) := by + let base := Procedure.first unaryCode (prodCode unaryCode ratCode) + let tail := Procedure.second unaryCode (prodCode unaryCode ratCode) + let p := (precisionProgram C).comp ((Procedure.first unaryCode ratCode).comp tail) + let w := (weightProgram a).comp ((Procedure.second unaryCode ratCode).comp tail) + exact base.pair (p.pair w) + +noncomputable opaque program (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) (k A B : ℕ) : + Procedure AutomaticCalibration.inputCode ratCode (value rho a C ε c k A B) := + (AutomaticCalibration.program rho ε c k A B).comp (inputProgram a C) + +noncomputable def certificate (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) (k A B : ℕ) : + Turing.TM2ComputableInPolyTime AutomaticCalibration.inputCode ratCode + (value rho a C ε c k A B) := (program rho a C ε c k A B).toTM2 + +noncomputable opaque normalizedProgram (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) (k A B : ℕ) : + Procedure AutomaticCalibration.inputCode ratCode (normalizedValue rho a C ε c k A B) := + Procedure.ratDiv.comp ((program rho a C ε c k A B).pair + (AutomaticCalibration.spacingProgram c k)) + +noncomputable def normalizedCertificate (rho : ℕ) (a : ℚ) (C : ℕ) + (ε c : ℚ) (k A B : ℕ) : + Turing.TM2ComputableInPolyTime AutomaticCalibration.inputCode ratCode + (normalizedValue rho a C ε c k A B) := (normalizedProgram rho a C ε c k A B).toTM2 + +end ContinuumCoulomb.PrefactorCalibration + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorSourceContactProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorSourceContactProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ade22bf6f50de33cb62f91481295d119fa334570 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefactorSourceContactProgram.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefactorCalibrationProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceContactCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CalibrationMesh + +namespace OAI + +/-! Raw-source contact coordinates with precisely the amplification forced +by the unit-charge mesh. The calibration base is the thirtieth power of +the encoded source size, so its amplification is a cube. -/ + +namespace ContinuumCoulomb.PrefactorSourceContactProgram +open ExactQuantumFactoring.BitStackProgram + +def input (a : ℚ) (C s p h : ℕ) (d : BinaryHeisenberg) : CalibratedContactProgram.Input := + (SourceContactProgram.size d ^ h, + ((CalibrationMesh.base (SourceContactProgram.size d), + PrefactorCalibration.precision C (SourceContactProgram.size d ^ p)), + (d.coordinate,((SourcePositiveProgram.normalized s d).2, + ((SourcePositiveProgram.output s d).bonds.map (fun e => e.2.2)).map + (PrefactorCalibration.adjustedWeight a))))) + +noncomputable def value (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) + (s p h k A B : ℕ) (d : BinaryHeisenberg) : List (ℚ×ℚ) := + CalibratedContactProgram.value rho ε c k A B (input a C s p h d) + +noncomputable opaque coefficientsProgram (a : ℚ) (s : ℕ) : + Procedure binaryHeisenbergCodec.encode (listCode ratCode) + (fun d => ((SourcePositiveProgram.output s d).bonds.map (fun e => e.2.2)).map + (PrefactorCalibration.adjustedWeight a)) := + (Procedure.listMap 0 0 (PrefactorCalibration.weightProgram a)).comp + (SourceContactProgram.coefficientsProgram s) + +noncomputable opaque inputProgram (a : ℚ) (C s p h : ℕ) : + Procedure binaryHeisenbergCodec.encode CalibratedContactProgram.inputCode (input a C s p h) := + (SourceContactProgram.powerProgram h).pair + (((SourceContactProgram.powerProgram 30).pair + ((PrefactorCalibration.precisionProgram C).comp (SourceContactProgram.powerProgram p))).pair + (SourceContactProgram.coordinatesProgram.pair + ((SourceContactProgram.signedBondsProgram s).pair (coefficientsProgram a s)))) + +noncomputable opaque program (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) + (s p h k A B : ℕ) : Procedure binaryHeisenbergCodec.encode + (listCode ContactRationalGadget.pointCode) (value rho a C ε c s p h k A B) := + (CalibratedContactProgram.program rho ε c k A B).comp (inputProgram a C s p h) + +noncomputable def certificate (rho : ℕ) (a : ℚ) (C : ℕ) (ε c : ℚ) + (s p h k A B : ℕ) : Turing.TM2ComputableInPolyTime binaryHeisenbergCodec.encode + (listCode ContactRationalGadget.pointCode) (value rho a C ε c s p h k A B) := + (program rho a C ε c s p h k A B).toTM2 + +end ContinuumCoulomb.PrefactorSourceContactProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixListPrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixListPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..b421d7f6f43363e70cd46ed441d7d161733d05b2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixListPrograms.lean @@ -0,0 +1,223 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefixPrograms +import OAI.Computability.QuantumFactoring.BitStackListWords +import OAI.Computability.QuantumFactoring.NativeAIGAddWrapper + +namespace OAI + +/-! Actual conversion of the source's counted prefix list to quoted +machine list registers. Each field is parsed by its literal splitter; +the loop count and all temporary word lengths are bounded by the input. -/ + +namespace ContinuumCoulomb.PrefixListPrograms +open ExactQuantumFactoring.BitStackProgram PrefixPrograms + +abbrev State (α : Type) := List α × (List Bool × List α) + +def stateView {α : Type} (c : BinaryEncoding.Codec α) (s : State α) : + ℕ × (List Bool × List α) := (s.1.length, (s.1.flatMap c.encode ++ s.2.1, s.2.2)) + +def stateCode {α : Type} (c : BinaryEncoding.Codec α) : State α → List Bool := + fun s => prodCode Nat.bits (prodCode id (listCode c.encode)) (stateView c s) + +def step {α : Type} (s : State α) : State α := + match s.1 with + | [] => s + | a :: xs => (xs, s.2.1, a :: s.2.2) + +theorem step_iterate {α : Type} (i : ℕ) (xs : List α) (tail : List Bool) (acc : List α) : + step^[i] (xs, tail, acc) = (xs.drop i, tail, (xs.take i).reverse ++ acc) := by + induction i generalizing xs acc with + | zero => simp + | succ i ih => + rw [Function.iterate_succ_apply] + cases xs with + | nil => simpa [step] using ih [] acc + | cons a xs => simpa [step, List.reverse_cons, List.append_assoc] using ih xs (a :: acc) + +theorem flat_length {α : Type} (c : BinaryEncoding.Codec α) (hc : ∀ a, 0 < (c.encode a).length) + (xs : List α) : xs.length ≤ (xs.flatMap c.encode).length := by + induction xs with + | nil => simp + | cons a xs ih => + have ha := hc a + simp only [List.length_cons, List.flatMap_cons, List.length_append] + omega + +theorem quoted_length {α : Type} (c : BinaryEncoding.Codec α) (xs : List α) : + (listCode c.encode xs).length = 2 * (xs.flatMap c.encode).length + 2 * xs.length + 1 := by + induction xs with + | nil => simp [listCode] + | cons a xs ih => + simp only [listCode_length_cons, List.flatMap_cons, List.length_append, List.length_cons, ih] + omega + +theorem stateCode_length {α : Type} (c : BinaryEncoding.Codec α) (s : State α) : + (stateCode c s).length = 2 * s.1.length.bits.length + + 2 * ((s.1.flatMap c.encode).length + s.2.1.length) + 2 + (listCode c.encode s.2.2).length := by + simp only [stateCode, stateView, prodCode, pairBits_length, List.length_append, id_eq] + omega + +theorem state_growth {α : Type} (c : BinaryEncoding.Codec α) + (hc : ∀ a, 0 < (c.encode a).length) (s : State α) (i : ℕ) : + (stateCode c (step^[i] s)).length ≤ 3 * (stateCode c s).length + 1 := by + rcases s with ⟨xs, tail, acc⟩ + rw [step_iterate] + have hn := bits_length_mono (show (xs.drop i).length ≤ xs.length by simp only [List.length_drop]; omega) + have hsplit : ((xs.take i).flatMap c.encode).length + ((xs.drop i).flatMap c.encode).length = + (xs.flatMap c.encode).length := by + rw [← List.length_append, ← List.flatMap_append, List.take_append_drop] + have hl := flat_length c hc xs + have hacc := listCode_length_append c.encode (xs.take i).reverse acc + rw [listCode_length_rev] at hacc + have htake := listCode_length_take_le c.encode i xs + rw [quoted_length c xs] at htake + simp only [stateCode_length] + omega + +noncomputable def listOutput {α : Type} (c : BinaryEncoding.Codec α) (d : α) : + Procedure (listCode c.encode) (BinaryEncoding.list c).encode id := by + let emit : Procedure c.encode id c.encode := (Procedure.identity c.encode).result (by intro a; rfl) + let flat := Procedure.listFlatMapWords d emit + let count := Procedure.unaryToBits.comp (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength c.encode d) + let header : Procedure (listCode c.encode) id (fun xs => BinaryEncoding.natural.encode xs.length) := + (EncodingPrograms.naturalOutput.comp count).result (by intro xs; rfl) + exact (Procedure.append.comp (header.pair flat)).result (by intro xs; rfl) + +section Parser +variable {α : Type} (c : BinaryEncoding.Codec α) (pc : Splitter c) (d : α) + +noncomputable def countProgram : Procedure (stateCode c) Nat.bits (fun s => s.1.length) := + (Procedure.first Nat.bits (prodCode id (listCode c.encode))).precompose (stateView c) + +noncomputable def streamProgram : Procedure (stateCode c) id + (fun s => s.1.flatMap c.encode ++ s.2.1) := + ((Procedure.first id (listCode c.encode)).comp + (Procedure.second Nat.bits (prodCode id (listCode c.encode)))).precompose (stateView c) + +noncomputable def accProgram : Procedure (stateCode c) (listCode c.encode) (fun s => s.2.2) := + ((Procedure.second id (listCode c.encode)).comp + (Procedure.second Nat.bits (prodCode id (listCode c.encode)))).precompose (stateView c) + +abbrev NonemptyState (α : Type) := {s : State α // ¬s.1 = []} + +noncomputable def headerProgram : Procedure (fun s : NonemptyState α => stateCode c s.val) + (prodCode c.encode id) + (fun s => (s.val.1.headD d, s.val.1.tail.flatMap c.encode ++ s.val.2.1)) := by + let word := (streamProgram c).precompose (fun s : NonemptyState α => s.val) + let asPrefix : Procedure (fun s : NonemptyState α => stateCode c s.val) (prefixCode c) + (fun s => (s.val.1.headD d, s.val.1.tail.flatMap c.encode ++ s.val.2.1)) := + word.result (by + rintro ⟨⟨xs, tail, acc⟩, h⟩ + cases xs with + | nil => contradiction + | cons a xs => simp only [List.flatMap_cons, List.headD_cons, List.tail_cons, prefixCode, + id_eq, List.append_assoc]) + exact pc.comp asPrefix + +noncomputable def nonemptyStep : Procedure (fun s : NonemptyState α => stateCode c s.val) + (stateCode c) (fun s => step s.val) := by + let head : Procedure (fun s : NonemptyState α => stateCode c s.val) c.encode + (fun s => s.val.1.headD d) := + (Procedure.first c.encode id).comp (headerProgram c pc d) + let tail : Procedure (fun s : NonemptyState α => stateCode c s.val) id + (fun s => s.val.1.tail.flatMap c.encode ++ s.val.2.1) := + (Procedure.second c.encode id).comp (headerProgram c pc d) + let acc := (accProgram c).precompose (fun s : NonemptyState α => s.val) + let nextAcc := (Procedure.listCons c.encode).comp (head.pair acc) + let count := (countProgram c).precompose (fun s : NonemptyState α => s.val) + let nextCount := Procedure.binarySub.comp (count.pair + (Procedure.constant (fun s : NonemptyState α => stateCode c s.val) Nat.bits 1)) + exact (nextCount.pair (tail.pair nextAcc)).result (by + rintro ⟨⟨xs, tail, acc⟩, h⟩ + cases xs with + | nil => contradiction + | cons a xs => simp only [stateCode, stateView, step, List.headD_cons, List.tail_cons, + List.length_cons, Nat.add_sub_cancel, Function.comp_apply]) + +noncomputable def stepProgram : Procedure (stateCode c) (stateCode c) step := by + let test : Procedure (stateCode c) Procedure.boolCode (fun s => decide (s.1 = [])) := + (Procedure.binaryZero.comp (countProgram c)).congrFun (by + intro s + simp only [Function.comp_apply, List.length_eq_zero_iff]) + let yes : Procedure (fun s : {s : State α // s.1 = []} => stateCode c s.val) + (stateCode c) (fun s => step s.val) := + ((Procedure.identity (stateCode c)).precompose (fun s : {s : State α // s.1 = []} => s.val)).congrFun + (by intro s; simp only [id_eq, step, s.property]) + exact Procedure.splitOn (fun s : State α => s.1 = []) test yes (nonemptyStep c pc d) + +noncomputable def iterationProgram (hc : ∀ a, 0 < (c.encode a).length) : + Procedure (prodCode unaryCode (stateCode c)) (stateCode c) (fun x => step^[x.1] x.2) := + (stepProgram c pc d).iterate (Polynomial.C 3 * Polynomial.X + 1) (by + intro n s i _ + have h := state_growth c hc s i + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + Polynomial.eval_one] + omega) + +noncomputable def inputCount : Procedure (prefixCode (BinaryEncoding.list c)) Nat.bits + (fun x => x.1.length) := + ((Procedure.first Nat.bits id).precompose + (fun x : List α × List Bool => (x.1.length, x.1.flatMap c.encode ++ x.2))).congrEncoding (by + intro x + change quoteBits x.1.length.bits ++ (x.1.flatMap c.encode ++ x.2) = + (BinaryEncoding.encodeDigits x.1.length.bits ++ x.1.flatMap c.encode) ++ x.2 + rw [AmplificationProgram.encodeDigits_quote, List.append_assoc]) (by intro x; rfl) + +noncomputable def inputStream : Procedure (prefixCode (BinaryEncoding.list c)) id + (fun x => x.1.flatMap c.encode ++ x.2) := + ((Procedure.second Nat.bits id).precompose + (fun x : List α × List Bool => (x.1.length, x.1.flatMap c.encode ++ x.2))).congrEncoding (by + intro x + change quoteBits x.1.length.bits ++ (x.1.flatMap c.encode ++ x.2) = + (BinaryEncoding.encodeDigits x.1.length.bits ++ x.1.flatMap c.encode) ++ x.2 + rw [AmplificationProgram.encodeDigits_quote, List.append_assoc]) (by intro x; rfl) + +noncomputable def startProgram : Procedure (prefixCode (BinaryEncoding.list c)) (stateCode c) + (fun x => (x.1, x.2, [])) := + ((inputCount c).pair ((inputStream c).pair + (Procedure.constant (prefixCode (BinaryEncoding.list c)) (listCode c.encode) []))).result + (by intro x; rfl) + +theorem input_length (hc : ∀ a, 0 < (c.encode a).length) (x : List α × List Bool) : + x.1.length ≤ (prefixCode (BinaryEncoding.list c) x).length := by + have h := flat_length c hc x.1 + change x.1.length ≤ ((BinaryEncoding.natural.encode x.1.length ++ x.1.flatMap c.encode) ++ x.2).length + simp only [List.length_append] + omega + +noncomputable def parseProgram (hc : ∀ a, 0 < (c.encode a).length) : + Procedure (prefixCode (BinaryEncoding.list c)) (stateCode c) + (fun x => ([], x.2, x.1.reverse)) := by + let times : Procedure (prefixCode (BinaryEncoding.list c)) unaryCode + (fun x => (prefixCode (BinaryEncoding.list c) x).length) := + Procedure.length.precompose (prefixCode (BinaryEncoding.list c)) + exact ((iterationProgram c pc d hc).comp (times.pair (startProgram c))).congrFun (by + intro x + change step^[(prefixCode (BinaryEncoding.list c) x).length] (x.1, x.2, []) = _ + rw [step_iterate, List.drop_eq_nil_of_le (input_length c hc x), + List.take_of_length_le (input_length c hc x), List.append_nil]) + +noncomputable def parsedList (hc : ∀ a, 0 < (c.encode a).length) : + Procedure (prefixCode (BinaryEncoding.list c)) (listCode c.encode) Prod.fst := + ((Procedure.listReverse c.encode d).comp ((accProgram c).comp (parseProgram c pc d hc))).congrFun + (by intro x; exact List.reverse_reverse x.1) + +noncomputable def parsedTail (hc : ∀ a, 0 < (c.encode a).length) : + Procedure (prefixCode (BinaryEncoding.list c)) id Prod.snd := + ((streamProgram c).comp (parseProgram c pc d hc)).congrFun (by intro x; rfl) + +noncomputable def listSplitter (hc : ∀ a, 0 < (c.encode a).length) : Splitter (BinaryEncoding.list c) := + (((listOutput c d).comp (parsedList c pc d hc)).pair (parsedTail c pc d hc)).congrFun (by intro x; rfl) + +/-- Actual quoted-list conversion for a complete source field, with no +postulated record-decoding primitive. -/ +noncomputable def listInput (hc : ∀ a, 0 < (c.encode a).length) : + Procedure (BinaryEncoding.list c).encode (listCode c.encode) id := + ((parsedList c pc d hc).precompose (fun xs : List α => (xs, []))).congrEncoding + (by intro xs; exact List.append_nil _) (by intro xs; rfl) + +end Parser + +end ContinuumCoulomb.PrefixListPrograms + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixPrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bc38a5973f57eb93ee3061867a7ae568ff813c8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/PrefixPrograms.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorProgram +import OAI.Computability.QuantumFactoring.BitStackDependentChoice +import OAI.Computability.QuantumFactoring.BitStackBoundedUnary +import OAI.Computability.QuantumFactoring.BitStackListOps + +namespace OAI + +/-! Literal prefixCode parsing for the source serialization. A parser emits +the first encoded field and its untouched following bit string. -/ + +namespace ContinuumCoulomb.PrefixPrograms +open ExactQuantumFactoring.BitStackProgram + +def prefixCode {α : Type} (c : BinaryEncoding.Codec α) (x : α × List Bool) : List Bool := + c.encode x.1 ++ x.2 + +abbrev Splitter {α : Type} (c : BinaryEncoding.Codec α) := + Procedure (prefixCode c) (prodCode c.encode id) id + +noncomputable def natural : Splitter BinaryEncoding.natural := by + let num : Procedure (prodCode Nat.bits id) BinaryEncoding.natural.encode Prod.fst := + EncodingPrograms.naturalOutput.comp (Procedure.first Nat.bits id) + let tail : Procedure (prodCode Nat.bits id) id Prod.snd := Procedure.second Nat.bits id + exact (num.pair tail).congrEncoding (by + intro x + change quoteBits x.1.bits ++ x.2 = BinaryEncoding.encodeDigits x.1.bits ++ x.2 + rw [AmplificationProgram.encodeDigits_quote]) (by intro x; rfl) + +noncomputable def integerPayload : Procedure (prefixCode BinaryEncoding.integer) + (prodCode Nat.bits id) (fun x => (EncodingPrograms.integerPayload x.1, x.2)) := + (Procedure.tail.precompose (prefixCode BinaryEncoding.integer)).result (by + rintro ⟨z, s⟩ + cases z <;> + change BinaryEncoding.encodeDigits _ ++ s = quoteBits _ ++ s <;> + rw [AmplificationProgram.encodeDigits_quote] <;> rfl) + +noncomputable def integerSign : Procedure (prefixCode BinaryEncoding.integer) Procedure.boolCode + (fun x => EncodingPrograms.integerNegative x.1) := + (Procedure.head.precompose (prefixCode BinaryEncoding.integer)).congrFun (by + rintro ⟨z, s⟩ + cases z <;> rfl) + +noncomputable def integerValue : Procedure (prefixCode BinaryEncoding.integer) intCode Prod.fst := by + let payload : Procedure (prefixCode BinaryEncoding.integer) Nat.bits + (fun x => EncodingPrograms.integerPayload x.1) := + (Procedure.first Nat.bits id).comp integerPayload + let positive := Procedure.natToInt.comp payload + let negative := Procedure.intNeg.comp (Procedure.natToInt.comp (Procedure.successor.comp payload)) + exact (Procedure.conditional integerSign negative positive).congrFun (by + rintro ⟨z, s⟩ + cases z with + | ofNat n => rfl + | negSucc n => change -(↑(n + 1) : ℤ) = Int.negSucc n; omega) + +noncomputable def integer : Splitter BinaryEncoding.integer := + ((EncodingPrograms.integerOutput.comp integerValue).pair + ((Procedure.second Nat.bits id).comp integerPayload)).congrFun (by intro x; rfl) + +section Pair +variable {α β : Type} (c : BinaryEncoding.Codec α) (d : BinaryEncoding.Codec β) +variable (pc : Splitter c) (pd : Splitter d) + +noncomputable def pairHeader : Procedure (prefixCode (BinaryEncoding.pair c d)) + (prodCode c.encode (prefixCode d)) (fun x => (x.1.1, (x.1.2, x.2))) := + ((pc.precompose (fun x : (α × β) × List Bool => (x.1.1, d.encode x.1.2 ++ x.2))).congrEncoding + (by intro x; exact (List.append_assoc _ _ _).symm) (by intro x; rfl)).result + (by intro x; rfl) + +noncomputable def pairFirst : Procedure (prefixCode (BinaryEncoding.pair c d)) c.encode + (fun x => x.1.1) := (Procedure.first c.encode (prefixCode d)).comp (pairHeader c d pc) + +noncomputable def pairRest : Procedure (prefixCode (BinaryEncoding.pair c d)) (prodCode d.encode id) + (fun x => (x.1.2, x.2)) := + pd.comp ((Procedure.second c.encode (prefixCode d)).comp (pairHeader c d pc)) + +noncomputable def pairSecond : Procedure (prefixCode (BinaryEncoding.pair c d)) d.encode + (fun x => x.1.2) := (Procedure.first d.encode id).comp (pairRest c d pc pd) + +noncomputable def pairTail : Procedure (prefixCode (BinaryEncoding.pair c d)) id + (fun x => x.2) := (Procedure.second d.encode id).comp (pairRest c d pc pd) + +noncomputable def pairValue : Procedure (prefixCode (BinaryEncoding.pair c d)) + (BinaryEncoding.pair c d).encode (fun x => x.1) := + ((EncodingPrograms.appendPair c d).comp + ((pairFirst c d pc).pair (pairSecond c d pc pd))).congrFun (by intro x; rfl) + +noncomputable def pair : Splitter (BinaryEncoding.pair c d) := + ((pairValue c d pc pd).pair (pairTail c d pc pd)).congrFun (by intro x; rfl) + +end Pair + +noncomputable def rational : Splitter MediatorProgram.rationalCodec := by + let p := pair BinaryEncoding.integer BinaryEncoding.natural integer natural + exact (p.precompose (fun x : ℚ × List Bool => ((x.1.num, x.1.den), x.2))).result + (by intro x; rfl) + +end ContinuumCoulomb.PrefixPrograms + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ProgramGroundIdentity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ProgramGroundIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a16291c79ec716a107af24e004d9f041ab494d4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/ProgramGroundIdentity.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NumericalGridRounding +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.UnitCoulombProgram + +namespace OAI + +/-! The serialized unit-Coulomb instance has exactly the ground energy of +the rational array generated by the numerical node program. -/ + +noncomputable section +open scoped BigOperators Classical +namespace ContinuumCoulomb +open CappedKernelProgram (Triple position) + +theorem unitData_attraction_list (d : UnitCoulomb) (hd : d.Valid) (y : Position) : + Coulomb.attraction (d.toData hd).toNuclearData.toNuclei y = + (d.nuclei.map (fun p => Coulomb.coulombKernel (y-realPosition p.value))).sum := by + simp only [Coulomb.attraction,NuclearData.toNuclei,UnitNuclearData.toNuclearData, + UnitCoulomb.toData,Nat.cast_one,one_mul,List.get_eq_getElem] + exact Fin.sum_univ_fun_getElem d.nuclei (fun p => Coulomb.coulombKernel (y-realPosition p.value)) + +theorem program_ground_identity (rho U C K : ℕ) (x : UnitCoulombProgram.Input) + (hx : (UnitCoulombProgram.value rho U C K x).Valid) + {scale : ℝ} (hs : 0 < scale) + (hfactor : (PhysicalNuclearProgram.factor rho x.1.1.1.2:ℝ)=scale⁻¹) + (hq : Function.Injective (fun a : Fin (CenteredGaussLabels.labels x.1.2).length => + TransformedGauss.value rho U C K x.1.1.1.1 x.1.1.1.2 x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 + ((CenteredGaussLabels.labels x.1.2).get a).1 ((CenteredGaussLabels.labels x.1.2).get a).2)) : + unitGroundEnergy ((UnitCoulombProgram.value rho U C K x).toData hx) = + formGroundEnergy (physicalRationalNuclei + (by rw [CenteredGaussLabels.labels_length]; positivity) _ hq hs) x.2.1 := by + change formGroundEnergy ((UnitCoulombProgram.value rho U C K x).toData hx).toNuclearData.toNuclei _ = _ + apply formGroundEnergy_eq_of_attraction + intro y + rw [unitData_attraction_list] + change ((PhysicalNuclearProgram.nuclei rho U C K x.1).map + (fun p => Coulomb.coulombKernel (y-realPosition p.value))).sum = _ + simp only [PhysicalNuclearProgram.nuclei,NuclearCoordinateOutput.positions, + PhysicalNuclearProgram.triples,TransformedGauss.nodes,List.map_map,Function.comp_def, + NuclearCoordinateOutput.real_position,PhysicalNuclearProgram.scale_position,hfactor] + change ((CenteredGaussLabels.labels x.1.2).map (fun l => + Coulomb.coulombKernel (y-scale⁻¹ • position (TransformedGauss.value rho U C K + x.1.1.1.1 x.1.1.1.2 x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 l.1 l.2)))).sum = _ + simp only [Coulomb.attraction,physicalRationalNuclei,one_mul,List.get_eq_getElem] + exact (Fin.sum_univ_fun_getElem (CenteredGaussLabels.labels x.1.2) (fun l => + Coulomb.coulombKernel (y-scale⁻¹ • position (TransformedGauss.value rho U C K + x.1.1.1.1 x.1.1.1.2 x.1.1.2.1.1 x.1.1.2.1.2 x.1.1.2.2 l.1 l.2)))).symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalExponentialProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalExponentialProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..083de03336ff323b13f1ec5cfec2bc97984b4866 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalExponentialProgram.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalTaylorRegisters +import OAI.Computability.QuantumFactoring.BitStackProcedures + +namespace OAI + +/-! A polynomial-time rational exponential evaluator. Magnitude and +precision bounds are supplied in unary; the rational argument and result +are encoded in binary. Every arithmetic operation is an actual stack +program, including the shared-denominator Taylor recurrence. -/ + +namespace ContinuumCoulomb.RationalExponentialProgram +open ExactQuantumFactoring.BitStackProgram +open RationalTaylorRegisters + +noncomputable def stepProgram : Procedure code code step := by + let a := Procedure.first intCode + (prodCode Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))) + let s₁ := Procedure.second intCode + (prodCode Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))) + let b := (Procedure.first Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))).comp s₁ + let s₂ := (Procedure.second Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))).comp s₁ + let j := (Procedure.first Nat.bits (prodCode intCode (prodCode Nat.bits intCode))).comp s₂ + let s₃ := (Procedure.second Nat.bits (prodCode intCode (prodCode Nat.bits intCode))).comp s₂ + let A := (Procedure.first intCode (prodCode Nat.bits intCode)).comp s₃ + let s₄ := (Procedure.second intCode (prodCode Nat.bits intCode)).comp s₃ + let F := (Procedure.first Nat.bits intCode).comp s₄ + let P := (Procedure.second Nat.bits intCode).comp s₄ + let next := Procedure.successor.comp j + let factor := Procedure.binaryMul.comp (next.pair b) + let nextA := Procedure.intMul.comp ((Procedure.natToInt.comp factor).pair + (Procedure.intAdd.comp (A.pair P))) + let nextF := Procedure.binaryMul.comp (factor.pair F) + let nextP := Procedure.intMul.comp (a.pair P) + exact (a.pair (b.pair (next.pair (nextA.pair (nextF.pair nextP))))).congrFun + (by intro s; rfl) + +noncomputable def repeatProgram : Procedure (prodCode unaryCode code) code + (fun x => (step^[x.1]) x.2) := + stepProgram.iterate (64 * (Polynomial.X + 1) ^ 2 + 100) iterate_code_bound + +noncomputable def initialProgram : Procedure ratCode code initial := by + let a := Procedure.ratNum + let b := Procedure.ratDen + let zero := Procedure.constant ratCode Nat.bits 0 + let zeroInt := Procedure.constant ratCode intCode (0 : ℤ) + let one := Procedure.constant ratCode Nat.bits 1 + let oneInt := Procedure.constant ratCode intCode (1 : ℤ) + exact (a.pair (b.pair (zero.pair (zeroInt.pair (one.pair oneInt))))).congrFun + (by intro q; rfl) + +noncomputable def resultProgram : Procedure code ratCode result := by + let s₁ := Procedure.second intCode + (prodCode Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))) + let s₂ := (Procedure.second Nat.bits (prodCode Nat.bits (prodCode intCode (prodCode Nat.bits intCode)))).comp s₁ + let s₃ := (Procedure.second Nat.bits (prodCode intCode (prodCode Nat.bits intCode))).comp s₂ + let A := (Procedure.first intCode (prodCode Nat.bits intCode)).comp s₃ + let s₄ := (Procedure.second intCode (prodCode Nat.bits intCode)).comp s₃ + let F := (Procedure.first Nat.bits intCode).comp s₄ + exact (Procedure.makeRat.comp (A.pair F)).congrFun (by intro s; rfl) + +noncomputable def partialProgram : Procedure (prodCode unaryCode ratCode) ratCode + (fun x => RationalExponential.taylorSum x.2 x.1) := by + let n := Procedure.first unaryCode ratCode + let q := Procedure.second unaryCode ratCode + let run := repeatProgram.comp (n.pair (initialProgram.comp q)) + exact (resultProgram.comp run).congrFun (by intro x; exact result_correct x.2 x.1) + +noncomputable def orderProgram : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => RationalExponential.order x.1 x.2) := by + let m := Procedure.first unaryCode unaryCode + let p := Procedure.second unaryCode unaryCode + let two := Procedure.constant (prodCode unaryCode unaryCode) unaryCode 2 + let square := Procedure.unaryMul.comp (m.pair m) + let twiceSquare := Procedure.unaryMul.comp (two.pair square) + let sum := Procedure.unaryAdd.comp + ((Procedure.unaryAdd.comp (twiceSquare.pair p)).pair two) + exact (Procedure.unaryMul.comp (two.pair sum)).congrFun (by + intro x + change 2 * (2 * (x.1 * x.1) + x.2 + 2) = RationalExponential.order x.1 x.2 + unfold RationalExponential.order + ring) + +abbrev Input := ℕ × (ℕ × ℚ) + +def inputCode : Input → List Bool := prodCode unaryCode (prodCode unaryCode ratCode) + +def approximate (x : Input) : ℚ := RationalExponential.approximate x.1 x.2.1 x.2.2 + +noncomputable def program : Procedure inputCode ratCode approximate := by + let m := Procedure.first unaryCode (prodCode unaryCode ratCode) + let tail := Procedure.second unaryCode (prodCode unaryCode ratCode) + let p := (Procedure.first unaryCode ratCode).comp tail + let q := (Procedure.second unaryCode ratCode).comp tail + let order := orderProgram.comp (m.pair p) + exact (partialProgram.comp (order.pair q)).congrFun (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode approximate := program.toTM2 + +theorem error (x : Input) (hx : |(x.2.2 : ℝ)| ≤ x.1) : + |Real.exp (x.2.2 : ℝ) - (approximate x : ℝ)| ≤ (2 ^ x.2.1 : ℝ)⁻¹ := + RationalExponential.error x.1 x.2.1 x.2.2 hx + +end ContinuumCoulomb.RationalExponentialProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalLogScaleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalLogScaleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2442f548ae1f30d74bc50eb0b5eff213c4cfe659 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalLogScaleProgram.lean @@ -0,0 +1,36 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalLogScale +import OAI.Computability.QuantumFactoring.BitStackPowers + +namespace OAI + +/-! The logarithmic scale is computed from a binary power and a literal +bit-counting machine. Its fixed rational multiplier is independent of the +input instance. -/ + +namespace ContinuumCoulomb.RationalLogScale +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque powerProgram (k : ℕ) : Procedure unaryCode Nat.bits + (fun N => N ^ k) := + Procedure.binaryPow.comp + ((Procedure.constant unaryCode unaryCode k).pair Procedure.unaryToBits) + +noncomputable opaque bitLengthProgram (k : ℕ) : Procedure unaryCode unaryCode + (fun N => (N ^ k).bits.length) := + (Procedure.length.precompose Nat.bits).comp (powerProgram k) + +noncomputable opaque bitLengthRationalProgram (k : ℕ) : Procedure unaryCode ratCode + (fun N => ((N ^ k).bits.length : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp (bitLengthProgram k)) + +noncomputable opaque program (c : ℚ) (k : ℕ) : Procedure unaryCode ratCode (value c k) := + Procedure.ratMul.comp + ((Procedure.constant unaryCode ratCode c).pair (bitLengthRationalProgram k)) + +noncomputable def certificate (c : ℚ) (k : ℕ) : + Turing.TM2ComputableInPolyTime unaryCode ratCode (value c k) := + (program c k).toTM2 + +end ContinuumCoulomb.RationalLogScale + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalQuadratureProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalQuadratureProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef34a97b407504d6993d8bb95e637b4aec484e7c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalQuadratureProgram.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.UniformSamples +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram +import OAI.Computability.QuantumFactoring.BitStackTabulate + +namespace OAI + +/-! Literal tabulation and summation of rational quadrature samples. +The sample count is unary; bounds, spacing and evaluator data are encoded +as ordinary inputs to the machine. -/ + +namespace ContinuumCoulomb.RationalQuadratureProgram +open ExactQuantumFactoring.BitStackProgram +open scoped BigOperators + +variable {E : Type} + +abbrev Environment (E : Type) := E × (ℚ × ℚ) +abbrev Input (E : Type) := ℕ × Environment E + +def environmentCode (ce : E → List Bool) : Environment E → List Bool := + prodCode ce (prodCode ratCode ratCode) + +def inputCode (ce : E → List Bool) : Input E → List Bool := + prodCode unaryCode (environmentCode ce) + +def node (a h : ℚ) (i : ℕ) : ℚ := a + (i : ℚ) * h + +def sample (evaluate : E → ℚ → ℚ) (e : Environment E) (i : ℕ) : ℚ := + evaluate e.1 (node e.2.1 e.2.2 i) + +def value (evaluate : E → ℚ → ℚ) (x : Input E) : ℚ := + x.2.2.2 * ∑ i ∈ Finset.range x.1, sample evaluate x.2 i + +theorem range_sum (f : ℕ → ℚ) (N : ℕ) : + ((List.range N).map f).sum = ∑ i ∈ Finset.range N, f i := by + induction N with + | zero => simp + | succ N ih => simp [List.range_succ, Finset.sum_range_succ, ih] + +noncomputable def sampleProgram (ce : E → List Bool) (evaluate : E → ℚ → ℚ) + (p : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Procedure (inputCode ce) ratCode (fun x => sample evaluate x.2 x.1) := by + let i := Procedure.first unaryCode (environmentCode ce) + let env := Procedure.second unaryCode (environmentCode ce) + let e := (Procedure.first ce (prodCode ratCode ratCode)).comp env + let ah := (Procedure.second ce (prodCode ratCode ratCode)).comp env + let a := (Procedure.first ratCode ratCode).comp ah + let h := (Procedure.second ratCode ratCode).comp ah + let ir := Procedure.natToRat.comp (Procedure.unaryToBits.comp i) + let t := Procedure.ratAdd.comp (a.pair (Procedure.ratMul.comp (ir.pair h))) + exact (p.comp (e.pair t)).congrFun (by intro x; rfl) + +noncomputable def program (ce : E → List Bool) (evaluate : E → ℚ → ℚ) + (p : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Procedure (inputCode ce) ratCode (value evaluate) := by + let samples := Procedure.tabulate (0 : ℚ) (sampleProgram ce evaluate p) + let sum := RationalSumProgram.sumProgram.comp samples + let env := Procedure.second unaryCode (environmentCode ce) + let ah := (Procedure.second ce (prodCode ratCode ratCode)).comp env + let h := (Procedure.second ratCode ratCode).comp ah + exact (Procedure.ratMul.comp (h.pair sum)).congrFun (by + intro x + change x.2.2.2 * ((List.range x.1).map (sample evaluate x.2)).sum = value evaluate x + rw [range_sum] + rfl) + +noncomputable def certificate (ce : E → List Bool) (evaluate : E → ℚ → ℚ) + (p : Procedure (prodCode ce ratCode) ratCode (fun x => evaluate x.1 x.2)) : + Turing.TM2ComputableInPolyTime (inputCode ce) ratCode (value evaluate) := + (program ce evaluate p).toTM2 + +theorem node_cast (a h : ℚ) (i : ℕ) : + (node a h i : ℝ) = UniformQuadrature.node (a : ℝ) (h : ℝ) i := by + simp [node, UniformQuadrature.node] + +theorem value_cast (evaluate : E → ℚ → ℚ) (x : Input E) : + (value evaluate x : ℝ) = UniformQuadrature.sampleSum (x.2.2.2 : ℝ) x.1 + (fun i => (sample evaluate x.2 i : ℝ)) := by + simp [value, UniformQuadrature.sampleSum] + +theorem error (evaluate : E → ℚ → ℚ) (x : Input E) (f : ℝ → ℝ) {L ε : ℝ} + (hh : 0 ≤ (x.2.2.2 : ℝ)) (hL : 0 ≤ L) (hf : Continuous f) + (hLip : ∀ u ∈ Set.Icc (x.2.2.1 : ℝ) (node x.2.2.1 x.2.2.2 x.1 : ℝ), + ∀ v ∈ Set.Icc (x.2.2.1 : ℝ) (node x.2.2.1 x.2.2.2 x.1 : ℝ), + |f u - f v| ≤ L * |u - v|) + (heval : ∀ i < x.1, |(sample evaluate x.2 i : ℝ) - + f (node x.2.2.1 x.2.2.2 i : ℝ)| ≤ ε) : + |(value evaluate x : ℝ) - ∫ t in (x.2.2.1 : ℝ)..(node x.2.2.1 x.2.2.2 x.1 : ℝ), f t| ≤ + (x.1 : ℝ) * (L * (x.2.2.2 : ℝ) ^ 2 + (x.2.2.2 : ℝ) * ε) := by + rw [value_cast, node_cast] + apply UniformQuadrature.samples_error f _ _ _ _ hh hL hf + · simpa only [node_cast] using hLip + · simpa only [node_cast] using heval + +end ContinuumCoulomb.RationalQuadratureProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalRectangleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalRectangleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dec7f1e2de24ba47fe8376f7c171b976f242603 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalRectangleProgram.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalQuadratureProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RectangleQuadrature + +namespace OAI + +/-! A literal two-coordinate rational quadrature. The same mesh in both +coordinates is enough for the normalization and compact contact integrals. -/ + +namespace ContinuumCoulomb.RationalRectangleProgram +open ExactQuantumFactoring.BitStackProgram + +variable {E : Type} +abbrev Input (E : Type) := RationalQuadratureProgram.Input E + +def inputCode (ce : E → List Bool) : Input E → List Bool := + RationalQuadratureProgram.inputCode ce + +def lineInput (x : Input E × ℚ) : RationalQuadratureProgram.Input (E × ℚ) := + (x.1.1, ((x.1.2.1, x.2), x.1.2.2)) + +def line (evaluate : E → ℚ → ℚ → ℚ) (e : Input E) (x : ℚ) : ℚ := + RationalQuadratureProgram.value (fun q y => evaluate q.1 q.2 y) (lineInput (e, x)) + +def outerInput (x : Input E) : RationalQuadratureProgram.Input (Input E) := + (x.1, (x, x.2.2)) + +def value (evaluate : E → ℚ → ℚ → ℚ) (x : Input E) : ℚ := + RationalQuadratureProgram.value (line evaluate) (outerInput x) + +noncomputable opaque lineInputProgram (ce : E → List Bool) : + Procedure (prodCode (inputCode ce) ratCode) + (RationalQuadratureProgram.inputCode (prodCode ce ratCode)) lineInput := by + let e := Procedure.first (inputCode ce) ratCode + let x := Procedure.second (inputCode ce) ratCode + let n := (Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce)).comp e + let env := (Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce)).comp e + let data := (Procedure.first ce (prodCode ratCode ratCode)).comp env + let mesh := (Procedure.second ce (prodCode ratCode ratCode)).comp env + exact (n.pair ((data.pair x).pair mesh)).congrFun (by intro q; rfl) + +noncomputable opaque outerInputProgram (ce : E → List Bool) : + Procedure (inputCode ce) (RationalQuadratureProgram.inputCode (inputCode ce)) outerInput := by + let n := Procedure.first unaryCode (RationalQuadratureProgram.environmentCode ce) + let env := Procedure.second unaryCode (RationalQuadratureProgram.environmentCode ce) + let mesh := (Procedure.second ce (prodCode ratCode ratCode)).comp env + exact (n.pair ((Procedure.identity (inputCode ce)).pair mesh)).congrFun (by intro q; rfl) + +noncomputable opaque program (ce : E → List Bool) (evaluate : E → ℚ → ℚ → ℚ) + (p : Procedure (prodCode (prodCode ce ratCode) ratCode) ratCode + (fun q => evaluate q.1.1 q.1.2 q.2)) : + Procedure (inputCode ce) ratCode (value evaluate) := by + let inner := (RationalQuadratureProgram.program (prodCode ce ratCode) + (fun q y => evaluate q.1 q.2 y) p).comp (lineInputProgram ce) + exact ((RationalQuadratureProgram.program (inputCode ce) (line evaluate) + inner).comp (outerInputProgram ce)).congrFun (by intro q; rfl) + +noncomputable def certificate (ce : E → List Bool) (evaluate : E → ℚ → ℚ → ℚ) + (p : Procedure (prodCode (prodCode ce ratCode) ratCode) ratCode + (fun q => evaluate q.1.1 q.1.2 q.2)) : + Turing.TM2ComputableInPolyTime (inputCode ce) ratCode (value evaluate) := + (program ce evaluate p).toTM2 + +theorem value_cast (evaluate : E → ℚ → ℚ → ℚ) (x : Input E) : + (value evaluate x : ℝ) = + UniformQuadrature.rectangleSum (x.2.2.2 : ℝ) (x.2.2.2 : ℝ) x.1 x.1 + (fun i j => (evaluate x.2.1 + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 i) + (RationalQuadratureProgram.node x.2.2.1 x.2.2.2 j) : ℝ)) := by + simp [value, outerInput, line, lineInput, RationalQuadratureProgram.value, + RationalQuadratureProgram.sample, UniformQuadrature.rectangleSum, UniformQuadrature.sampleSum] + +end ContinuumCoulomb.RationalRectangleProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalSumProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalSumProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..9179b6f3de4ac5acb5490fe0f701199e5730fcbc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RationalSumProgram.lean @@ -0,0 +1,143 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorProgram +import OAI.Computability.QuantumFactoring.BitStackListFold + +namespace OAI + +/-! Actual polynomial rational-list summation. Unreduced numerator and +positive denominator registers are accumulated with ordinary integer +arithmetic, then reduced once. Their bit lengths grow cubically at most. -/ + +namespace ContinuumCoulomb.RationalSumProgram +open ExactQuantumFactoring.BitStackProgram +open scoped BigOperators + +abbrev State := ℤ × ℕ + +def stateCode : State → List Bool := prodCode intCode Nat.bits + +def step (s : State) (q : ℚ) : State := + (s.1 * q.den + q.num * s.2, s.2 * q.den) + +def value (s : State) : ℚ := (s.1 : ℚ) / s.2 + +theorem step_den_pos (s : State) (q : ℚ) (hs : 0 < s.2) : 0 < (step s q).2 := + Nat.mul_pos hs q.pos + +theorem step_value (s : State) (q : ℚ) (hs : 0 < s.2) : value (step s q) = value s + q := by + have hd : (q.den : ℚ) ≠ 0 := by exact_mod_cast q.den_nz + have hs' : (s.2 : ℚ) ≠ 0 := by exact_mod_cast hs.ne' + unfold step value + push_cast + conv_rhs => rw [← Rat.num_div_den q] + field_simp + +theorem fold_den_pos (xs : List ℚ) (s : State) (hs : 0 < s.2) : + 0 < (xs.foldl step s).2 := by + induction xs generalizing s with + | nil => exact hs + | cons q xs ih => exact ih _ (step_den_pos s q hs) + +theorem fold_value (xs : List ℚ) (s : State) (hs : 0 < s.2) : + value (xs.foldl step s) = value s + xs.sum := by + induction xs generalizing s with + | nil => simp + | cons q xs ih => + rw [List.foldl_cons, ih _ (step_den_pos s q hs), step_value s q hs, List.sum_cons] + ring + +theorem integer_bits_add (a b : ℤ) : + (a + b).natAbs.bits.length ≤ a.natAbs.bits.length + b.natAbs.bits.length + 1 := + (bits_length_mono (Int.natAbs_add_le a b)).trans (bits_length_add _ _) + +theorem step_bits (s : State) (q : ℚ) : + (step s q).2.bits.length ≤ s.2.bits.length + q.den.bits.length ∧ + (step s q).1.natAbs.bits.length ≤ s.1.natAbs.bits.length + q.den.bits.length + + q.num.natAbs.bits.length + s.2.bits.length + 1 := by + constructor + · exact bits_length_mul _ _ + · have h := integer_bits_add (s.1 * q.den) (q.num * s.2) + simp only [Int.natAbs_mul, Int.natAbs_natCast] at h + have h1 := bits_length_mul s.1.natAbs q.den + have h2 := bits_length_mul q.num.natAbs s.2 + exact h.trans (by omega) + +theorem fold_bits (xs : List ℚ) (s : State) (B : ℕ) + (hB : ∀ q ∈ xs, q.num.natAbs.bits.length + q.den.bits.length ≤ B) : + (xs.foldl step s).2.bits.length ≤ s.2.bits.length + xs.length * B ∧ + (xs.foldl step s).1.natAbs.bits.length ≤ s.1.natAbs.bits.length + + xs.length * (B + s.2.bits.length + xs.length * B + 1) := by + induction xs generalizing s with + | nil => simp + | cons q xs ih => + have hq := hB q (by simp) + have hi := ih (step s q) (by intro a ha; exact hB a (by simp [ha])) + have hs := step_bits s q + simp only [List.foldl_cons, List.length_cons] + constructor + · nlinarith [hi.1] + · nlinarith [hi.2] + +theorem state_length (s : State) : + (stateCode s).length = 2 * s.1.natAbs.bits.length + s.2.bits.length + 7 := by + simp only [stateCode, prodCode, intCode, intData, pairBits_length, Procedure.boolCode, + List.length_singleton] + omega + +theorem rational_length (q : ℚ) : + (ratCode q).length = 2 * q.num.natAbs.bits.length + q.den.bits.length + 7 := + state_length (q.num, q.den) + +noncomputable def stepProgram : Procedure (prodCode ratCode stateCode) stateCode + (fun x => step x.2 x.1) := by + let q := Procedure.first ratCode stateCode + let s := Procedure.second ratCode stateCode + let qn := Procedure.ratNum.comp q + let qd := Procedure.ratDen.comp q + let sn := (Procedure.first intCode Nat.bits).comp s + let sd := (Procedure.second intCode Nat.bits).comp s + let first := Procedure.intMul.comp (sn.pair (Procedure.natToInt.comp qd)) + let second := Procedure.intMul.comp (qn.pair (Procedure.natToInt.comp sd)) + exact ((Procedure.intAdd.comp (first.pair second)).pair + (Procedure.binaryMul.comp (sd.pair qd))).congrFun (by intro x; rfl) + +noncomputable def foldProgram : Procedure (prodCode (listCode ratCode) stateCode) stateCode + (fun x => x.1.foldl step x.2) := + Procedure.foldList 0 stepProgram (Polynomial.C 20 * (Polynomial.X + 1) ^ 3) (by + intro xs s i + let L := (listCode ratCode xs).length + (stateCode s).length + have hq : ∀ q ∈ xs.take i, q.num.natAbs.bits.length + q.den.bits.length ≤ L := by + intro q hq + have h := code_le_of_mem ratCode (List.mem_of_mem_take hq) + rw [rational_length] at h + dsimp only [L] + omega + have h := fold_bits (xs.take i) s L hq + have hs := state_length s + have hi : (xs.take i).length ≤ L := + (show (xs.take i).length ≤ xs.length by simp only [List.length_take]; omega).trans + ((list_length_le_code ratCode xs).trans (Nat.le_add_right _ _)) + rw [state_length] + simp only [Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_add, + Polynomial.eval_X, Polynomial.eval_one] + change _ ≤ 20 * (L + 1) ^ 3 + have hs1 : s.1.natAbs.bits.length ≤ L := by dsimp only [L]; omega + have hs2 : s.2.bits.length ≤ L := by dsimp only [L]; omega + have hmul : (xs.take i).length * L ≤ L * L := Nat.mul_le_mul_right L hi + have hn : (xs.take i).length * (L + s.2.bits.length + (xs.take i).length * L + 1) ≤ + L * (2 * L + L * L + 1) := + Nat.mul_le_mul hi (by omega) + nlinarith [h.1, h.2]) + +noncomputable def sumProgram : Procedure (listCode ratCode) ratCode List.sum := by + let start := (Procedure.identity (listCode ratCode)).pair + (Procedure.constant (listCode ratCode) stateCode (0, 1)) + exact (Procedure.makeRat.comp (foldProgram.comp start)).congrFun (by + intro xs + change mkRat (xs.foldl step (0, 1)).1 (xs.foldl step (0, 1)).2 = xs.sum + rw [Rat.mkRat_eq_div] + have h := fold_value xs (0, 1) (by norm_num) + simpa only [value, Int.cast_zero, Nat.cast_one, zero_div, zero_add] using h) + +end ContinuumCoulomb.RationalSumProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombMassBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombMassBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..628ac107b09745ea6f1f4df6c11d3c05f349150f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombMassBound.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedRawDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CoulombNormalizationProgram + +namespace OAI + +/-! Uniform raw-integral bounds for certified normalization of the +finite-box numerical output. -/ + +noncomputable section +open MeasureTheory +namespace ContinuumCoulomb + +theorem localizedRawCoulombBox_bound {freq ε : ℝ} (hf : 0 < freq) (hε : 0 < ε) + (L : ℝ) (u : PlanarPosition) : + |localizedRawCoulombBox freq ε L u| ≤ ε⁻¹ * localizedRawMass freq ^ 2 := by + let f := localizedRawDensity freq + let S := coulombNumericalBox L ×ˢ coulombNumericalBox L + let F := cappedPairIntegrand ε (planarCenter u) f f + have hfi := localizedRawDensity_integrable hf + have hm : Integrable (fun p : Position × Position => ε⁻¹ * (f p.1 * f p.2)) := by + have hp : Integrable (fun p : Position × Position => f p.1 * f p.2) := by + simpa only [Measure.volume_eq_prod] using hfi.mul_prod hfi + exact hp.const_mul _ + have hpoint (p : Position × Position) : ‖S.indicator F p‖ ≤ ε⁻¹ * (f p.1 * f p.2) := by + by_cases hp : p ∈ S + · rw [Set.indicator_of_mem hp, Real.norm_of_nonneg (show 0 ≤ F p from + mul_nonneg (mul_nonneg (localizedRawDensity_nonnegative _ _) + (localizedRawDensity_nonnegative _ _)) (cappedCoulombKernel_nonnegative hε _))] + change f p.1 * f p.2 * cappedCoulombKernel ε _ ≤ _ + calc + _ ≤ f p.1 * f p.2 * ε⁻¹ := mul_le_mul_of_nonneg_left (cappedCoulombKernel_le hε _) + (mul_nonneg (localizedRawDensity_nonnegative _ _) (localizedRawDensity_nonnegative _ _)) + _ = _ := by ring + · rw [Set.indicator_of_notMem hp, norm_zero] + exact mul_nonneg (inv_nonneg.mpr hε.le) + (mul_nonneg (localizedRawDensity_nonnegative _ _) (localizedRawDensity_nonnegative _ _)) + have hb := norm_integral_le_of_norm_le (f := S.indicator F) hm (Filter.Eventually.of_forall hpoint) + rw [integral_indicator ((coulombNumericalBox_measurable L).prod + (coulombNumericalBox_measurable L)), Real.norm_eq_abs] at hb + apply hb.trans_eq + rw [integral_const_mul, Measure.volume_eq_prod, integral_prod_mul] + change ε⁻¹ * ((∫ x, localizedRawDensity freq x) * ∫ x, localizedRawDensity freq x) = _ + rw [localizedRawDensity_mass hf] + ring + +theorem localizedCoulombBox_eq_normalizedRaw {freq : ℝ} (hf : 0 < freq) + (ε L : ℝ) (u : PlanarPosition) : + localizedCoulombBoxIntegral freq ε L u = + CoulombNormalization.coefficient freq * localizedRawCoulombBox freq ε L u := by + rw [← localizedRawCoulombBox_quotient hf ε L u] + unfold CoulombNormalization.coefficient + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b81d91a1d82d3aa0787992c608cecf8eaebf77a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSample.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensitySampleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.CappedRawModulus + +namespace OAI + +/-! A literal rational sample of the six-coordinate Coulomb integrand. +Both density factors and the capped kernel use the certified programs. -/ + +noncomputable section +namespace ContinuumCoulomb.RawCoulombSample +open CappedKernelProgram + +def difference (x y s : Triple) : Triple := + (x.1 - y.1 - s.1, x.2.1 - y.2.1 - s.2.1, x.2.2 - y.2.2 - s.2.2) + +theorem position_difference (x y s : Triple) : + position (difference x y s) = position x - position y - position s := by + ext i + fin_cases i <;> simp [position, difference] + +def value (rho R P b : ℕ) (ε : ℚ) (s x y : Triple) : ℚ := + RawDensitySample.value rho ((R, P), x) * RawDensitySample.value rho ((R, P), y) * + approximate ((b, ε), difference x y s) + +def inBox (R : ℕ) (x : Triple) : Prop := + |(x.1 : ℝ)| ≤ R ∧ |(x.2.1 : ℝ)| ≤ R ∧ |(x.2.2 : ℝ)| ≤ R + +theorem kernel_nonnegative (b : ℕ) {ε : ℚ} (hε : 0 < ε) (q : Triple) : + (0 : ℝ) ≤ approximate ((b, ε), q) := by + simp only [approximate, Rat.cast_inv, Rat.cast_max] + exact inv_nonneg.mpr ((show (0 : ℝ) ≤ ε by exact_mod_cast hε.le).trans (le_max_left _ _)) + +theorem kernel_le (b : ℕ) {ε : ℚ} (hε : 0 < ε) (q : Triple) : + (approximate ((b, ε), q) : ℝ) ≤ (ε : ℝ)⁻¹ := by + simp only [approximate, Rat.cast_inv, Rat.cast_max] + exact inv_anti₀ (by exact_mod_cast hε) (le_max_left _ _) + +theorem value_error (rho R P b : ℕ) {ε : ℚ} (hε : 0 < ε) + (s x y : Triple) (hx : inBox R x) (hy : inBox R y) : + |(value rho R P b ε s x y : ℝ) - + cappedPairIntegrand (ε : ℝ) (position s) + (localizedRawDensity (GaussianFrequency.frequency rho)) + (localizedRawDensity (GaussianFrequency.frequency rho)) (position x, position y)| ≤ + 8 * (ε : ℝ)⁻¹ * ((P : ℝ) + 1)⁻¹ + (ε : ℝ)⁻¹ ^ 2 * (2 : ℝ)⁻¹ ^ b := by + let f := localizedRawDensity (GaussianFrequency.frequency rho) + let a : ℝ := RawDensitySample.value rho ((R, P), x) + let c : ℝ := RawDensitySample.value rho ((R, P), y) + let k : ℝ := approximate ((b, ε), difference x y s) + let t := cappedCoulombKernel (ε : ℝ) (position x - position y - position s) + have hfreq : 0 ≤ GaussianFrequency.frequency rho := Real.sqrt_nonneg _ + have ha0 : 0 ≤ a := by + dsimp only [a] + exact_mod_cast RawDensitySample.value_nonnegative rho ((R, P), x) + have ha1 : a ≤ 1 := by + dsimp only [a] + exact_mod_cast RawDensitySample.value_le_one rho ((R, P), x) + have hprod := bounded_product_sub (a := a) (b := c) (c := f (position x)) + (d := f (position y)) ha0 ha1 + (localizedRawDensity_nonnegative _ _) (localizedRawDensity_le_one hfreq _) + have hxerr := RawDensitySample.value_error rho ((R, P), x) hx.1 hx.2.1 hx.2.2 + have hyerr := RawDensitySample.value_error rho ((R, P), y) hy.1 hy.2.1 hy.2.2 + have herr : |a * c - f (position x) * f (position y)| ≤ 8 * ((P : ℝ) + 1)⁻¹ := by + exact hprod.trans (by dsimp only [a, c, f] at *; linarith) + have hk0 : 0 ≤ k := kernel_nonnegative b hε _ + have hk1 : k ≤ (ε : ℝ)⁻¹ := kernel_le b hε _ + have hkerr : |k - t| ≤ (ε : ℝ)⁻¹ ^ 2 * (2 : ℝ)⁻¹ ^ b := by + have h := approximation_error ((b, ε), difference x y s) hε + simpa only [position_difference] using h + have hf0 : 0 ≤ f (position x) * f (position y) := + mul_nonneg (localizedRawDensity_nonnegative _ _) (localizedRawDensity_nonnegative _ _) + have hf1 : f (position x) * f (position y) ≤ 1 := by + exact (mul_le_mul (localizedRawDensity_le_one hfreq _) (localizedRawDensity_le_one hfreq _) + (localizedRawDensity_nonnegative _ _) zero_le_one).trans_eq (one_mul 1) + have he : (value rho R P b ε s x y : ℝ) - + cappedPairIntegrand (ε : ℝ) (position s) f f (position x, position y) = + (a * c - f (position x) * f (position y)) * k + + f (position x) * f (position y) * (k - t) := by + simp only [value, Rat.cast_mul, cappedPairIntegrand, a, c, k, t] + ring + rw [he] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg hk0, abs_of_nonneg hf0] + have h1 := mul_le_mul herr hk1 hk0 (by positivity) + have h2 := (mul_le_of_le_one_left (abs_nonneg (k - t)) hf1).trans hkerr + nlinarith + +end ContinuumCoulomb.RawCoulombSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSampleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSampleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d978ac92648e16894d748a80cb8f4561437aeaa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawCoulombSampleProgram.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawCoulombSample +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSixQuadrature + +namespace OAI + +/-! Literal polynomial programs for the Coulomb samples and their +six-coordinate summation. -/ + +namespace ContinuumCoulomb.RawCoulombSample +open ExactQuantumFactoring.BitStackProgram CappedKernelProgram + +abbrev Settings := (ℕ × ℕ) × ((ℕ × ℚ) × Triple) +abbrev Input := Settings × (Triple × Triple) +abbrev DifferenceInput := (Triple × Triple) × Triple + +def settingsCode : Settings → List Bool := + prodCode (prodCode unaryCode unaryCode) (prodCode (prodCode unaryCode ratCode) tripleCode) +def inputCode : Input → List Bool := prodCode settingsCode (prodCode tripleCode tripleCode) +def differenceCode : DifferenceInput → List Bool := prodCode (prodCode tripleCode tripleCode) tripleCode + +def evaluate (rho : ℕ) (z : Input) : ℚ := + value rho z.1.1.1 z.1.1.2 z.1.2.1.1 z.1.2.1.2 z.1.2.2 z.2.1 z.2.2 + +noncomputable opaque firstCoordinate : Procedure tripleCode ratCode Prod.fst := + Procedure.first ratCode (prodCode ratCode ratCode) +noncomputable opaque secondCoordinate : Procedure tripleCode ratCode (fun x => x.2.1) := + (Procedure.first ratCode ratCode).comp (Procedure.second ratCode (prodCode ratCode ratCode)) +noncomputable opaque thirdCoordinate : Procedure tripleCode ratCode (fun x => x.2.2) := + (Procedure.second ratCode ratCode).comp (Procedure.second ratCode (prodCode ratCode ratCode)) + +noncomputable opaque differenceProgram : Procedure differenceCode tripleCode + (fun z => difference z.1.1 z.1.2 z.2) := by + let xy := Procedure.first (prodCode tripleCode tripleCode) tripleCode + let x := (Procedure.first tripleCode tripleCode).comp xy + let y := (Procedure.second tripleCode tripleCode).comp xy + let s := Procedure.second (prodCode tripleCode tripleCode) tripleCode + let d0 := Procedure.ratSub.comp + ((Procedure.ratSub.comp ((firstCoordinate.comp x).pair (firstCoordinate.comp y))).pair + (firstCoordinate.comp s)) + let d1 := Procedure.ratSub.comp + ((Procedure.ratSub.comp ((secondCoordinate.comp x).pair (secondCoordinate.comp y))).pair + (secondCoordinate.comp s)) + let d2 := Procedure.ratSub.comp + ((Procedure.ratSub.comp ((thirdCoordinate.comp x).pair (thirdCoordinate.comp y))).pair + (thirdCoordinate.comp s)) + exact (d0.pair (d1.pair d2)).congrFun (by intro z; rfl) + +noncomputable opaque sampleProgram (rho : ℕ) : Procedure inputCode ratCode (evaluate rho) := by + let e := Procedure.first settingsCode (prodCode tripleCode tripleCode) + let xy := Procedure.second settingsCode (prodCode tripleCode tripleCode) + let x := (Procedure.first tripleCode tripleCode).comp xy + let y := (Procedure.second tripleCode tripleCode).comp xy + let rp := (Procedure.first (prodCode unaryCode unaryCode) + (prodCode (prodCode unaryCode ratCode) tripleCode)).comp e + let ks := (Procedure.second (prodCode unaryCode unaryCode) + (prodCode (prodCode unaryCode ratCode) tripleCode)).comp e + let kp := (Procedure.first (prodCode unaryCode ratCode) tripleCode).comp ks + let s := (Procedure.second (prodCode unaryCode ratCode) tripleCode).comp ks + let dx := (RawDensitySample.program rho).comp (rp.pair x) + let dy := (RawDensitySample.program rho).comp (rp.pair y) + let diff := differenceProgram.comp (xy.pair s) + let kernel := CappedKernelProgram.program.comp (kp.pair diff) + exact (Procedure.ratMul.comp ((Procedure.ratMul.comp (dx.pair dy)).pair kernel)).congrFun + (by intro z; rfl) + +def sixEvaluator (rho : ℕ) : RationalSixQuadrature.Evaluator Settings := + fun e a b c d f g => evaluate rho (e, ((a, b, c), (d, f, g))) + +abbrev SixInput := (((Settings × RationalSixQuadrature.Pair) × RationalSixQuadrature.Pair) × ℚ) × ℚ +def sixInputCode : SixInput → List Bool := + prodCode (prodCode (prodCode (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode) ratCode) ratCode + +def sixInput (z : SixInput) : Input := + (z.1.1.1.1, ((z.1.1.1.2.1, z.1.1.1.2.2, z.1.1.2.1), (z.1.1.2.2, z.1.2, z.2))) + +noncomputable opaque sixInputProgram : Procedure sixInputCode inputCode sixInput := by + let top := Procedure.first + (prodCode (prodCode (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode) ratCode) ratCode + let four := (Procedure.first (prodCode (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode) ratCode).comp top + let two := (Procedure.first (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode).comp four + let e := (Procedure.first settingsCode RationalSixQuadrature.pairCode).comp two + let ab := (Procedure.second settingsCode RationalSixQuadrature.pairCode).comp two + let cd := (Procedure.second (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode).comp four + let a := (Procedure.first ratCode ratCode).comp ab + let b := (Procedure.second ratCode ratCode).comp ab + let c := (Procedure.first ratCode ratCode).comp cd + let d := (Procedure.second ratCode ratCode).comp cd + let f := (Procedure.second (prodCode (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode) ratCode).comp top + let g := Procedure.second + (prodCode (prodCode (prodCode settingsCode RationalSixQuadrature.pairCode) + RationalSixQuadrature.pairCode) ratCode) ratCode + exact (e.pair ((a.pair (b.pair c)).pair (d.pair (f.pair g)))).congrFun (by intro z; rfl) + +noncomputable opaque sixSampleProgram (rho : ℕ) : Procedure sixInputCode ratCode + (fun z => RationalSixQuadrature.inner (sixEvaluator rho) z.1.1 z.1.2 z.2) := + ((sampleProgram rho).comp sixInputProgram).congrFun (by intro z; rfl) + +noncomputable opaque quadratureProgram (rho : ℕ) : + Procedure (RationalRectangleProgram.inputCode settingsCode) + ratCode (RationalSixQuadrature.value (sixEvaluator rho)) := + RationalSixQuadrature.program settingsCode (sixEvaluator rho) (sixSampleProgram rho) + +noncomputable def quadratureCertificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime (RationalRectangleProgram.inputCode settingsCode) + ratCode (RationalSixQuadrature.value (sixEvaluator rho)) := + (quadratureProgram rho).toTM2 + +end ContinuumCoulomb.RawCoulombSample + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensityModulus.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensityModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..31b17c83a2797c3577458f1dbeef34c4512c0381 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensityModulus.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedRawDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.PlanarResolventModulus +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.HeatKernelModulus + +namespace OAI + +/-! Quantitative continuity needed by the six-coordinate finite-box +quadrature. Only the box radius enters the Gaussian modulus. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem gaussian_box_modulus {freq L z w : ℝ} (hf : 0 ≤ freq) + (hz : |z| ≤ L) (hw : |w| ≤ L) : + |Real.exp (-freq * z ^ 2) - Real.exp (-freq * w ^ 2)| ≤ + 2 * freq * L * |z - w| := by + have he := HeatKernelModulus.exp_nonpositive_lipschitz + (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hf) (sq_nonneg z)) + (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hf) (sq_nonneg w)) + have hid : -freq * z ^ 2 - (-freq * w ^ 2) = -freq * (z - w) * (z + w) := by ring + rw [hid, abs_mul, abs_mul, abs_neg, abs_of_nonneg hf] at he + have hs : |z + w| ≤ 2 * L := (abs_add_le z w).trans (by linarith) + calc + _ ≤ freq * |z - w| * |z + w| := he + _ ≤ freq * |z - w| * (2 * L) := + mul_le_mul_of_nonneg_left hs (mul_nonneg hf (abs_nonneg _)) + _ = _ := by ring + +def splitRawDensity (freq : ℝ) (p : SplitPosition) : ℝ := + planarResolventMode p.1 ^ 2 * Real.exp (-freq * p.2 ^ 2) + +theorem splitRawDensity_eq (freq : ℝ) (x : Position) : + splitRawDensity freq (positionSplitCoordinates x) = localizedRawDensity freq x := rfl + +theorem splitRawDensity_modulus {freq L : ℝ} (hf : 0 ≤ freq) + (p q : SplitPosition) (hp : |p.2| ≤ L) (hq : |q.2| ≤ L) : + |splitRawDensity freq p - splitRawDensity freq q| ≤ + 64 * ‖p.1 - q.1‖ + 2 * freq * L * |p.2 - q.2| := by + have hφ : planarResolventMode q.1 ^ 2 ≤ 1 := by + simpa only [one_pow] using + (sq_le_sq₀ (planarResolventMode_positive q.1).le zero_le_one).mpr + (planarResolventMode_le_one q.1) + have he : Real.exp (-freq * p.2 ^ 2) ≤ 1 := + Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr hf) (sq_nonneg _)) + have hid : splitRawDensity freq p - splitRawDensity freq q = + (planarResolventMode p.1 ^ 2 - planarResolventMode q.1 ^ 2) * + Real.exp (-freq * p.2 ^ 2) + + planarResolventMode q.1 ^ 2 * + (Real.exp (-freq * p.2 ^ 2) - Real.exp (-freq * q.2 ^ 2)) := by + unfold splitRawDensity + ring + rw [hid] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_pos (Real.exp_pos _), + abs_of_nonneg (sq_nonneg (planarResolventMode q.1))] + have h1 := (mul_le_of_le_one_right (abs_nonneg _) he).trans + (planarResolventMode_square_norm_sub p.1 q.1) + have h2 := (mul_le_of_le_one_left (abs_nonneg _) hφ).trans + (gaussian_box_modulus hf hp hq) + exact add_le_add h1 h2 + +theorem positionSplit_planar_norm_sub_le (x y : Position) : + ‖(positionSplitCoordinates x).1 - (positionSplitCoordinates y).1‖ ≤ ‖x - y‖ := by + have h := positionSplitCoordinates_norm_sq (x - y) + rw [map_sub] at h + simp only [Prod.fst_sub, Prod.snd_sub] at h + exact (sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)).mp (by + nlinarith [sq_nonneg ((positionSplitCoordinates x).2 - (positionSplitCoordinates y).2)]) + +theorem positionSplit_vertical_norm_sub_le (x y : Position) : + |(positionSplitCoordinates x).2 - (positionSplitCoordinates y).2| ≤ ‖x - y‖ := by + have h := positionSplitCoordinates_norm_sq (x - y) + rw [map_sub] at h + simp only [Prod.fst_sub, Prod.snd_sub] at h + apply (sq_le_sq₀ (abs_nonneg _) (norm_nonneg _)).mp + rw [sq_abs] + nlinarith [sq_nonneg ‖(positionSplitCoordinates x).1 - (positionSplitCoordinates y).1‖] + +theorem localizedRawDensity_box_modulus {freq L : ℝ} (hf : 0 ≤ freq) + (x y : Position) (hx : |(positionSplitCoordinates x).2| ≤ L) + (hy : |(positionSplitCoordinates y).2| ≤ L) : + |localizedRawDensity freq x - localizedRawDensity freq y| ≤ + (64 + 2 * freq * L) * ‖x - y‖ := by + have hL : 0 ≤ L := (abs_nonneg _).trans hx + have h := splitRawDensity_modulus hf (positionSplitCoordinates x) (positionSplitCoordinates y) hx hy + rw [splitRawDensity_eq, splitRawDensity_eq] at h + apply h.trans + calc + _ ≤ 64 * ‖x - y‖ + 2 * freq * L * ‖x - y‖ := by + gcongr + · exact positionSplit_planar_norm_sub_le x y + · exact positionSplit_vertical_norm_sub_le x y + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySample.lean new file mode 100644 index 0000000000000000000000000000000000000000..585f7b5763039036e1cf5dfb4c4b3715a3fa7715 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySample.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.GaussianPacketProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CappedKernelProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.LocalizedRawDensity +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.ComputableResolvent +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.NumericalSquare + +namespace OAI + +/-! Literal bounded samples of the actual unnormalized three-dimensional +localized density, including the irrational fixed transverse frequency. -/ + +noncomputable section +namespace ContinuumCoulomb.RawDensitySample +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := (ℕ × ℕ) × CappedKernelProgram.Triple + +def planarArgument (x : Input) : ResolventSchedule.Input := + ((2 * x.1.1, x.1.2), (x.2.1, x.2.2.1)) + +def verticalArgument (x : Input) : GaussianPacket.Input := (x.1, x.2.2.2) + +def value (rho : ℕ) (x : Input) : ℚ := + rationalUnitClamp (ResolventSchedule.approximate (planarArgument x)) ^ 2 * + GaussianPacket.approximate rho (verticalArgument x) + +theorem value_nonnegative (rho : ℕ) (x : Input) : 0 ≤ value rho x := + mul_nonneg (sq_nonneg _) (rationalUnitClamp_nonnegative _) + +theorem value_le_one (rho : ℕ) (x : Input) : value rho x ≤ 1 := by + have hs := (sq_le_sq₀ (rationalUnitClamp_nonnegative _) zero_le_one).mpr + (rationalUnitClamp_le_one (ResolventSchedule.approximate (planarArgument x))) + exact (mul_le_mul hs (rationalUnitClamp_le_one _) + (rationalUnitClamp_nonnegative _) (by positivity)).trans_eq (by norm_num) + +theorem position_split (q : CappedKernelProgram.Triple) : + positionSplitCoordinates (CappedKernelProgram.position q) = + (PlanarForcingProgram.position (q.1, q.2.1), (q.2.2 : ℝ)) := by + apply Prod.ext + · ext i + fin_cases i <;> rfl + · rfl + +theorem planar_norm_le (x : Input) + (hx : |(x.2.1 : ℝ)| ≤ (x.1.1 : ℝ)) (hy : |(x.2.2.1 : ℝ)| ≤ (x.1.1 : ℝ)) : + ‖PlanarForcingProgram.position (x.2.1, x.2.2.1)‖ ≤ (2 * x.1.1 : ℕ) := by + have hx2 := (sq_le_sq₀ (abs_nonneg _) (Nat.cast_nonneg _)).mpr hx + have hy2 := (sq_le_sq₀ (abs_nonneg _) (Nat.cast_nonneg _)).mpr hy + rw [sq_abs] at hx2 hy2 + apply (sq_le_sq₀ (norm_nonneg _) (Nat.cast_nonneg _)).mp + rw [PlanarForcingProgram.position_norm_sq] + push_cast + nlinarith [sq_nonneg (x.1.1 : ℝ)] + +theorem unit_product_error {a b a' b' ε δ : ℝ} + (ha'0 : 0 ≤ a') (ha'1 : a' ≤ 1) (hb0 : 0 ≤ b) (hb1 : b ≤ 1) + (ha : |a' - a| ≤ ε) (hb : |b' - b| ≤ δ) : + |a' * b' - a * b| ≤ ε + δ := by + have he : a' * b' - a * b = a' * (b' - b) + (a' - a) * b := by ring + rw [he] + apply (abs_add_le _ _).trans + rw [abs_mul, abs_mul, abs_of_nonneg ha'0, abs_of_nonneg hb0] + have h1 := mul_le_of_le_one_left (abs_nonneg (b' - b)) ha'1 + have h2 := mul_le_of_le_one_right (abs_nonneg (a' - a)) hb1 + linarith + +theorem value_error (rho : ℕ) (x : Input) + (hx : |(x.2.1 : ℝ)| ≤ (x.1.1 : ℝ)) (hy : |(x.2.2.1 : ℝ)| ≤ (x.1.1 : ℝ)) + (hz : |(x.2.2.2 : ℝ)| ≤ (x.1.1 : ℝ)) : + |(value rho x : ℝ) - + localizedRawDensity (GaussianFrequency.frequency rho) (CappedKernelProgram.position x.2)| ≤ + 4 * ((x.1.2 : ℝ) + 1)⁻¹ := by + let r := PlanarForcingProgram.position (x.2.1, x.2.2.1) + let a : ℝ := rationalUnitClamp (ResolventSchedule.approximate (planarArgument x)) + let b : ℝ := GaussianPacket.approximate rho (verticalArgument x) + have hφ := ResolventSchedule.approximation_error (planarArgument x) (planar_norm_le x hx hy) + have ha : |a - planarResolventMode r| ≤ ((x.1.2 : ℝ) + 1)⁻¹ := + (rationalUnitClamp_error _ (planarResolventMode_positive r).le + (planarResolventMode_le_one r)).trans hφ + have hε : ((x.1.2 : ℝ) + 1)⁻¹ ≤ 1 := + (inv_le_one₀ (by positivity)).mpr (by linarith [show (0 : ℝ) ≤ x.1.2 from Nat.cast_nonneg _]) + have ha2 := unitInterval_square_error (planarResolventMode_positive r).le + (planarResolventMode_le_one r) hε ha + have hb := GaussianPacket.approximation_error rho (verticalArgument x) hz + have ha0 : 0 ≤ a := by + dsimp only [a] + exact_mod_cast rationalUnitClamp_nonnegative (ResolventSchedule.approximate (planarArgument x)) + have ha1 : a ≤ 1 := by + dsimp only [a] + exact_mod_cast rationalUnitClamp_le_one (ResolventSchedule.approximate (planarArgument x)) + have hsq : a ^ 2 ≤ 1 := by simpa only [one_pow] using (sq_le_sq₀ ha0 zero_le_one).mpr ha1 + have hexp : Real.exp (-GaussianFrequency.frequency rho * (x.2.2.2 : ℝ) ^ 2) ≤ 1 := + Real.exp_le_one_iff.mpr (mul_nonpos_of_nonpos_of_nonneg + (neg_nonpos.mpr (Real.sqrt_nonneg _)) (sq_nonneg _)) + have hp := unit_product_error (sq_nonneg a) hsq (Real.exp_pos _).le hexp ha2 hb + have hout : |(value rho x : ℝ) - + localizedRawDensity (GaussianFrequency.frequency rho) (CappedKernelProgram.position x.2)| ≤ + 3 * ((x.1.2 : ℝ) + 1)⁻¹ + ((x.1.2 : ℝ) + 1)⁻¹ := by + simpa only [value, Rat.cast_mul, Rat.cast_pow, localizedRawDensity, position_split, + Prod.fst, Prod.snd, r, a, b, verticalArgument] using hp + convert hout using 1 + ring + +end ContinuumCoulomb.RawDensitySample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySampleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySampleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..311a194ad095f00cdd5507b210e26308a0744774 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/RawDensitySampleProgram.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RawDensitySample + +namespace OAI + +/-! Literal arithmetic and TM2 compilation of the raw localized density +sampler. The coordinate radius and requested accuracy are encoded unary. -/ + +namespace ContinuumCoulomb.RawDensitySample +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := prodCode (prodCode unaryCode unaryCode) + CappedKernelProgram.tripleCode + +noncomputable opaque paramsProgram : Procedure inputCode (prodCode unaryCode unaryCode) Prod.fst := + Procedure.first (prodCode unaryCode unaryCode) CappedKernelProgram.tripleCode + +noncomputable opaque radiusProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode unaryCode).comp paramsProgram + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode (fun x => x.1.2) := + (Procedure.second unaryCode unaryCode).comp paramsProgram + +noncomputable opaque coordinatesProgram : Procedure inputCode CappedKernelProgram.tripleCode Prod.snd := + Procedure.second (prodCode unaryCode unaryCode) CappedKernelProgram.tripleCode + +noncomputable opaque firstCoordinateProgram : Procedure inputCode ratCode (fun x => x.2.1) := + (Procedure.first ratCode (prodCode ratCode ratCode)).comp coordinatesProgram + +noncomputable opaque remainingCoordinatesProgram : + Procedure inputCode (prodCode ratCode ratCode) (fun x => x.2.2) := + (Procedure.second ratCode (prodCode ratCode ratCode)).comp coordinatesProgram + +noncomputable opaque secondCoordinateProgram : Procedure inputCode ratCode (fun x => x.2.2.1) := + (Procedure.first ratCode ratCode).comp remainingCoordinatesProgram + +noncomputable opaque thirdCoordinateProgram : Procedure inputCode ratCode (fun x => x.2.2.2) := + (Procedure.second ratCode ratCode).comp remainingCoordinatesProgram + +noncomputable opaque planarArgumentProgram : + Procedure inputCode ResolventSchedule.inputCode planarArgument := by + let r := ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 2).pair radiusProgram) + exact (r.pair precisionProgram).pair (firstCoordinateProgram.pair secondCoordinateProgram) + +noncomputable opaque verticalArgumentProgram : + Procedure inputCode GaussianPacket.inputCode verticalArgument := + paramsProgram.pair thirdCoordinateProgram + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode (value rho) := by + let p := rationalUnitClampProgram.comp (ResolventSchedule.program.comp planarArgumentProgram) + let p2 := Procedure.ratMul.comp (p.pair p) + let z := (GaussianPacket.program rho).comp verticalArgumentProgram + exact (Procedure.ratMul.comp (p2.pair z)).congrFun (by intro x; simp only [value, pow_two]; rfl) + +noncomputable def certificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime inputCode ratCode (value rho) := (program rho).toTM2 + +end ContinuumCoulomb.RawDensitySample + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabBoxProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabBoxProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..97e2327a0ebb2059559076975cd58b60b5376609 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabBoxProgram.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabBoxSchedule + +namespace OAI + +/-! Polynomial evaluation of rational-width slabs and of the exact centered +mesh half-widths. Bounds remain unary; the actual widths remain rational. -/ + +namespace ContinuumCoulomb.SlabBoxSchedule +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := + prodCode SlabOriginSchedule.inputCode (prodCode ratCode ratCode) + +noncomputable opaque boundsProgram : Procedure inputCode SlabOriginSchedule.inputCode Prod.fst := + Procedure.first _ _ +noncomputable opaque widthsProgram : Procedure inputCode (prodCode ratCode ratCode) Prod.snd := + Procedure.second _ _ + +noncomputable opaque inputProgram (rho : ℕ) : Procedure inputCode + (RationalQuadratureProgram.inputCode SlabOriginValue.parameterCode) (input rho) := by + let n := (SlabOriginSchedule.countProgram rho).comp boundsProgram + let nq := Procedure.natToRat.comp (Procedure.unaryToBits.comp n) + let q := Procedure.natToRat.comp (Procedure.unaryToBits.comp + ((SlabOriginSchedule.capDenominatorProgram rho).comp boundsProgram)) + let cap := Procedure.ratInv.comp q + let step := Procedure.ratDiv.comp ((Procedure.constant inputCode ratCode (2:ℚ)).pair nq) + exact n.pair (((n.pair cap).pair widthsProgram).pair + ((Procedure.constant inputCode ratCode (-1:ℚ)).pair step)) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode (value rho) := + (SlabOriginValue.program (rho:ℚ)).comp (inputProgram rho) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode ratCode + (value rho) := (program rho).toTM2 + +def centeredCode : (ℕ×(ℕ×(ℕ×ℕ))) → List Bool := + prodCode unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + +noncomputable opaque centeredInputProgram : Procedure centeredCode inputCode + (fun x => centered x.1 x.2.1 x.2.2.1 x.2.2.2) := by + let p := Procedure.first unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + let tail := Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + let n := (Procedure.first unaryCode (prodCode unaryCode unaryCode)).comp tail + let box := (Procedure.second unaryCode (prodCode unaryCode unaryCode)).comp tail + let h := (Procedure.first unaryCode unaryCode).comp box + let s := (Procedure.second unaryCode unaryCode).comp box + let nq := Procedure.natToRat.comp (Procedure.unaryToBits.comp n) + let hq := Procedure.natToRat.comp (Procedure.unaryToBits.comp h) + let sq := Procedure.natToRat.comp (Procedure.unaryToBits.comp s) + let half := Procedure.constant centeredCode ratCode (1/2:ℚ) + let hw := Procedure.ratDiv.comp ((Procedure.ratAdd.comp (hq.pair half)).pair nq) + let sw := Procedure.ratDiv.comp ((Procedure.ratAdd.comp (sq.pair half)).pair nq) + exact (p.pair ((Procedure.unarySuccessor.comp h).pair + (Procedure.unarySuccessor.comp s))).pair (hw.pair sw) + +noncomputable opaque centeredProgram (rho : ℕ) : Procedure centeredCode ratCode + (fun x => value rho (centered x.1 x.2.1 x.2.2.1 x.2.2.2)) := + (program rho).comp centeredInputProgram + +noncomputable def centeredCertificate (rho : ℕ) : + Turing.TM2ComputableInPolyTime centeredCode ratCode + (fun x => value rho (centered x.1 x.2.1 x.2.2.1 x.2.2.2)) := + (centeredProgram rho).toTM2 + +end ContinuumCoulomb.SlabBoxSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabOriginProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabOriginProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e68d0ac358345350acce121ca63c5965c98b25c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SlabOriginProgram.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Nuclei.SlabOriginSchedule + +namespace OAI + +/-! Literal polynomial-time program for the slab origin potential. -/ + +namespace ContinuumCoulomb.SlabOriginSchedule +open ExactQuantumFactoring.BitStackProgram + +def inputCode : Input → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first _ _ +noncomputable opaque boxProgram : Procedure inputCode (prodCode unaryCode unaryCode) Prod.snd := + Procedure.second _ _ +noncomputable opaque horizontalProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp boxProgram +noncomputable opaque verticalProgram : Procedure inputCode unaryCode (fun x => x.2.2) := + (Procedure.second _ _).comp boxProgram + +noncomputable opaque capDenominatorProgram (rho : ℕ) : Procedure inputCode unaryCode + (fun x => capDenominator rho x.1) := + (ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode (16*(rho+1))).pair + (Procedure.unarySuccessor.comp precisionProgram))).congrFun (by intro x; rfl) + +noncomputable opaque boxWeightProgram (rho : ℕ) : Procedure inputCode unaryCode + (fun x => boxWeight rho x.2.1 x.2.2) := by + let hp := Procedure.unarySuccessor.comp horizontalProgram + let hs := ResolventSchedule.squareProgram.comp hp + let sp := Procedure.unarySuccessor.comp verticalProgram + let total := Procedure.unarySuccessor.comp + (ResolventSchedule.addProgram.comp (horizontalProgram.pair verticalProgram)) + let first := ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode (rho+1)).pair hs) + let second := ResolventSchedule.mulProgram.comp (first.pair sp) + exact (ResolventSchedule.mulProgram.comp (second.pair total)).congrFun (by intro x; rfl) + +noncomputable opaque countProgram (rho : ℕ) : Procedure inputCode unaryCode (count rho) := by + let first := ResolventSchedule.mulProgram.comp + ((Procedure.constant inputCode unaryCode 128).pair (boxWeightProgram rho)) + let second := ResolventSchedule.mulProgram.comp + (first.pair (Procedure.unarySuccessor.comp precisionProgram)) + let sq := ResolventSchedule.squareProgram.comp (capDenominatorProgram rho) + exact (ResolventSchedule.mulProgram.comp (second.pair sq)).congrFun (by intro x; rfl) + +noncomputable opaque inputProgram (rho : ℕ) : Procedure inputCode + (RationalQuadratureProgram.inputCode SlabOriginValue.parameterCode) (input rho) := by + let n := countProgram rho + let nq := Procedure.natToRat.comp (Procedure.unaryToBits.comp n) + let q := Procedure.natToRat.comp (Procedure.unaryToBits.comp (capDenominatorProgram rho)) + let cap := Procedure.ratInv.comp q + let hq := Procedure.natToRat.comp (Procedure.unaryToBits.comp horizontalProgram) + let sq := Procedure.natToRat.comp (Procedure.unaryToBits.comp verticalProgram) + let step := Procedure.ratDiv.comp ((Procedure.constant inputCode ratCode (2:ℚ)).pair nq) + let start := Procedure.constant inputCode ratCode (-1:ℚ) + exact n.pair (((n.pair cap).pair (hq.pair sq)).pair (start.pair step)) + +noncomputable opaque program (rho : ℕ) : Procedure inputCode ratCode (value rho) := + (SlabOriginValue.program (rho:ℚ)).comp (inputProgram rho) + +noncomputable def certificate (rho : ℕ) : Turing.TM2ComputableInPolyTime inputCode ratCode + (value rho) := (program rho).toTM2 + +end ContinuumCoulomb.SlabOriginSchedule + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SmoothTransitionProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SmoothTransitionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b27f364bb4ebb6f44d13081e9905202dbb47a3f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SmoothTransitionProgram.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSmoothTransition +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalExponentialProgram +import OAI.Computability.QuantumFactoring.BitStackRationalDivision +import OAI.Computability.QuantumFactoring.BitStackUnary + +namespace OAI + +/-! Literal polynomial-time rational programs for the smooth transition +and the fixed transverse cutoff. All large parameters are unary and each +Taylor exponent has already been bounded in `RationalSmoothTransition`. -/ + +namespace ContinuumCoulomb.SmoothTransitionProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × ℚ +def inputCode : Input → List Bool := prodCode unaryCode ratCode + +noncomputable opaque clipProgram : Procedure ratCode ratCode RationalSmoothTransition.clip := by + let q := Procedure.identity ratCode + let zero := Procedure.constant ratCode ratCode (0:ℚ) + let one := Procedure.constant ratCode ratCode (1:ℚ) + let negative := Procedure.intSign.comp Procedure.ratNum + let large := Procedure.intSign.comp (Procedure.ratNum.comp + (Procedure.ratSub.comp (one.pair q))) + exact (Procedure.conditional negative zero (Procedure.conditional large one q)).congrFun (by + intro q + simp only [Function.comp_apply,Rat.num_neg,decide_eq_true_eq,id_eq] + unfold RationalSmoothTransition.clip + split_ifs with hneg hlarge + · rw [min_eq_right (le_of_lt (hneg.trans (by norm_num))), max_eq_left hneg.le] + · rw [min_eq_left (by linarith : (1:ℚ) ≤ q), max_eq_right (by norm_num)] + · rw [min_eq_right (by linarith : q ≤ 1), max_eq_right (le_of_not_gt hneg)]) + +noncomputable opaque flatProgram : Procedure inputCode ratCode + (fun x => RationalSmoothTransition.flat x.1 x.2) := by + let p := Procedure.first unaryCode ratCode + let q := Procedure.second unaryCode ratCode + let next := Procedure.unarySuccessor.comp p + let nextQ := Procedure.natToRat.comp (Procedure.unaryToBits.comp next) + let cutoff := Procedure.ratInv.comp nextQ + let positive := Procedure.intSign.comp (Procedure.ratNum.comp + (Procedure.ratSub.comp (cutoff.pair q))) + let exponent := Procedure.ratNeg.comp (Procedure.ratInv.comp q) + let sample := clipProgram.comp (RationalExponentialProgram.program.comp + (next.pair (next.pair exponent))) + let zero := Procedure.constant inputCode ratCode (0:ℚ) + exact (Procedure.conditional positive sample zero).congrFun (by + intro x + simp only [Function.comp_apply,Rat.num_neg,decide_eq_true_eq,id_eq, + Nat.succ_eq_add_one,Nat.cast_add,Nat.cast_one] + unfold RationalSmoothTransition.flat + congr 1 + simp only [sub_neg]) + +noncomputable opaque precisionProgram : Procedure unaryCode unaryCode RationalSmoothTransition.precision := + (Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode 1000).pair + Procedure.unarySuccessor)).congrFun (by intro p; rfl) + +noncomputable opaque program : Procedure inputCode ratCode + (fun x => RationalSmoothTransition.approximate x.1 x.2) := by + let p := precisionProgram.comp (Procedure.first unaryCode ratCode) + let q := Procedure.second unaryCode ratCode + let one := Procedure.constant inputCode ratCode (1:ℚ) + let complement := Procedure.ratSub.comp (one.pair q) + let left := flatProgram.comp (p.pair q) + let right := flatProgram.comp (p.pair complement) + exact (Procedure.ratDiv.comp (left.pair (Procedure.ratAdd.comp (left.pair right)))).congrFun + (by intro x; rfl) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => RationalSmoothTransition.approximate x.1 x.2) := program.toTM2 + +def cutoffArgument (q : ℚ) : ℚ := (4-q^2)/3 +def cutoff (p : ℕ) (q : ℚ) : ℚ := + RationalSmoothTransition.approximate p (cutoffArgument q) + +noncomputable opaque cutoffArgumentProgram : Procedure ratCode ratCode cutoffArgument := by + let q := Procedure.identity ratCode + let four := Procedure.constant ratCode ratCode (4:ℚ) + let three := Procedure.constant ratCode ratCode (3:ℚ) + let square := Procedure.ratMul.comp (q.pair q) + exact (Procedure.ratDiv.comp ((Procedure.ratSub.comp (four.pair square)).pair three)).congrFun + (by intro q; simp only [cutoffArgument,pow_two]; rfl) + +noncomputable opaque cutoffProgram : Procedure inputCode ratCode (fun x => cutoff x.1 x.2) := + (program.comp ((Procedure.first unaryCode ratCode).pair + (cutoffArgumentProgram.comp (Procedure.second unaryCode ratCode)))).congrFun (by intro x; rfl) + +noncomputable def cutoffCertificate : Turing.TM2ComputableInPolyTime inputCode ratCode + (fun x => cutoff x.1 x.2) := cutoffProgram.toTM2 + +end ContinuumCoulomb.SmoothTransitionProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceBranchProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceBranchProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e6c16136a6c1f9dd633f9133c66726e3f96581 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceBranchProgram.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SingleSpinSource +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourcePositiveCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.UnitBinaryProgram + +namespace OAI + +/-! Literal completion of a many-spin source map on the one-spin branch. +The resulting reduction covers every valid source instance. -/ + +noncomputable section +namespace ContinuumCoulomb.SourceBranchProgram +open ExactQuantumFactoring.BitStackProgram + +def value (f : BinaryHeisenberg → UnitCoulomb) (d : BinaryHeisenberg) : UnitCoulomb := + if d.coordinate.length ≤ 1 then SingleSpinSource.value d else f d + +noncomputable opaque program (f : BinaryHeisenberg → UnitCoulomb) + (pf : Procedure binaryHeisenbergCodec.encode unitCoulombCodec.encode f) : + Procedure binaryHeisenbergCodec.encode unitCoulombCodec.encode (value f) := by + let test := Procedure.unaryLe.comp (SourceMetadataProgram.vertexCount.pair + (Procedure.constant binaryHeisenbergCodec.encode unaryCode 1)) + exact (Procedure.conditional test SingleSpinSource.program pf).congrFun + (by intro d; simp only [Function.comp_apply,value,decide_eq_true_eq]) + +theorem positive_output_vertices (s : ℕ) (d : BinaryHeisenberg) (hd : d.Valid) + (hv : 2 ≤ d.coordinate.length) : 2 ≤ (SourcePositiveProgram.output s d).vertices := by + rw [SourcePositiveProgram.vertices_eq s d hd] + omega + +def reduction (hh : PublishedHydrogenBottom) (k : ℕ) + (f : BinaryHeisenberg → UnitCoulomb) + (pf : Procedure binaryHeisenbergCodec.encode unitCoulombCodec.encode f) + (hyes : ∀ (d : BinaryHeisenberg) (hd : d.Valid), d.PolynomialPromise k → + 2 ≤ d.coordinate.length → realSourceGroundEnergy (d.toSource hd) ≤ d.lower.value → + f d ∈ unitCoulombPromise.yes) + (hno : ∀ (d : BinaryHeisenberg) (hd : d.Valid), d.PolynomialPromise k → + 2 ≤ d.coordinate.length → (d.upper.value : ℝ) ≤ realSourceGroundEnergy (d.toSource hd) → + f d ∈ unitCoulombPromise.no) : + PolynomialManyOne binaryHeisenbergCodec.encode unitCoulombCodec.encode + (sourceHeisenbergPromise k) unitCoulombPromise where + map := value f + polynomialTime := (program f pf).toTM2 + maps_yes := by + rintro d ⟨hd,hp,hy⟩ + have hyR : realSourceGroundEnergy (d.toSource hd) ≤ d.lower.value := by + apply EReal.coe_le_coe_iff.mp + rw [realSourceGroundEnergy_coe] + exact hy + by_cases hv : d.coordinate.length ≤ 1 + · simpa only [value,hv,ite_true] using SingleSpinSource.yes hh d hd hv hyR + · simpa only [value,hv,ite_false] using hyes d hd hp (by omega) hyR + maps_no := by + rintro d ⟨hd,hp,hn⟩ + have hnR : (d.upper.value : ℝ) ≤ realSourceGroundEnergy (d.toSource hd) := by + apply EReal.coe_le_coe_iff.mp + rw [realSourceGroundEnergy_coe] + exact hn + by_cases hv : d.coordinate.length ≤ 1 + · simpa only [value,hv,ite_true] using SingleSpinSource.no hh d hd hv hnR + · simpa only [value,hv,ite_false] using hno d hd hp (by omega) hnR + +end ContinuumCoulomb.SourceBranchProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceContactProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceContactProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..663471e0dbc8b25dc9c689d5f2c14dd2ec9d73ff --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceContactProgram.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.CalibratedContactProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePositiveProgram + +namespace OAI + +/-! Literal composition from the encoded source to the calibrated +contact coordinates. The signed retained bonds determine the geometric +strips; the final positive bond list supplies their nineteen target weights. -/ + +namespace ContinuumCoulomb.SourceContactProgram +open ExactQuantumFactoring.BitStackProgram + +def size (d : BinaryHeisenberg) : ℕ := SourceMetadataProgram.size d + 1 + +def input (s p h : ℕ) (d : BinaryHeisenberg) : CalibratedContactProgram.Input := + (size d ^ h, ((size d, size d ^ p), (d.coordinate, + ((SourcePositiveProgram.normalized s d).2, + (SourcePositiveProgram.output s d).bonds.map (fun e => e.2.2))))) + +noncomputable def value (rho : ℕ) (ε c : ℚ) (s p h k A B : ℕ) (d : BinaryHeisenberg) : + List (ℚ × ℚ) := + CalibratedContactProgram.value rho ε c k A B (input s p h d) + +noncomputable opaque coordinateProgram : Procedure SourcePrograms.coordinateCodec.encode + ContactCanonicalEdgeProgram.latticeCode id := by + let parsed := SourcePrograms.pairInput BinaryEncoding.integer BinaryEncoding.integer + PrefixPrograms.integer + exact ((EncodingPrograms.integerInput.comp ((Procedure.first _ _).comp parsed)).pair + (EncodingPrograms.integerInput.comp ((Procedure.second _ _).comp parsed))).result + (by intro x; rfl) + +noncomputable opaque coordinatesProgram : Procedure binaryHeisenbergCodec.encode + (listCode ContactCanonicalEdgeProgram.latticeCode) BinaryHeisenberg.coordinate := + ((Procedure.listMap (0,0) (0,0) coordinateProgram).comp SourcePrograms.coordinates).result + (by intro d; simp only [Function.comp_apply,List.map_id]) + +noncomputable opaque sizeProgram : Procedure binaryHeisenbergCodec.encode unaryCode size := + Procedure.unarySuccessor.comp SourceMetadataProgram.sizeProgram + +noncomputable def powerProgram : (p : ℕ) → Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => size d ^ p) + | 0 => Procedure.constant _ unaryCode 1 + | p+1 => (Procedure.unaryMul.comp ((powerProgram p).pair sizeProgram)).congrFun + (by intro d; exact (pow_succ (size d) p).symm) + +noncomputable opaque signedBondsProgram (s : ℕ) : Procedure binaryHeisenbergCodec.encode + (listCode MediatorListProgram.bondCode) (fun d => (SourcePositiveProgram.normalized s d).2) := + (Procedure.second _ _).comp (SourcePositiveProgram.normalizedProgram s) + +noncomputable opaque coefficientProgram : Procedure MediatorListProgram.bondCode ratCode + (fun e => e.2.2) := (Procedure.second _ _).comp (Procedure.second _ _) + +noncomputable opaque coefficientsProgram (s : ℕ) : Procedure binaryHeisenbergCodec.encode + (listCode ratCode) (fun d => (SourcePositiveProgram.output s d).bonds.map (fun e => e.2.2)) := + (Procedure.listMap MediatorListProgram.zeroBond 0 coefficientProgram).comp + (SourcePositiveProgram.bondsProgram s) + +noncomputable opaque inputProgram (s p h : ℕ) : Procedure binaryHeisenbergCodec.encode + CalibratedContactProgram.inputCode (input s p h) := + (powerProgram h).pair ((sizeProgram.pair (powerProgram p)).pair + (coordinatesProgram.pair ((signedBondsProgram s).pair (coefficientsProgram s)))) + +noncomputable opaque program (rho : ℕ) (ε c : ℚ) (s p h k A B : ℕ) : + Procedure binaryHeisenbergCodec.encode (listCode ContactRationalGadget.pointCode) + (value rho ε c s p h k A B) := + (CalibratedContactProgram.program rho ε c k A B).comp (inputProgram s p h) + +noncomputable def certificate (rho : ℕ) (ε c : ℚ) (s p h k A B : ℕ) : + Turing.TM2ComputableInPolyTime binaryHeisenbergCodec.encode + (listCode ContactRationalGadget.pointCode) (value rho ε c s p h k A B) := + (program rho ε c s p h k A B).toTM2 + +theorem size_ge_two (d : BinaryHeisenberg) : 2 ≤ size d := by + simp only [size,SourceMetadataProgram.size] + omega + +end ContinuumCoulomb.SourceContactProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceMetadataProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceMetadataProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..50b0efabf6c2990a61f38650a11e8eb9a8c91f4c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceMetadataProgram.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourceNormalizationProgram + +namespace OAI + +/-! The actual source parser computes unary polynomial bounds from the raw +encoding length. No polynomial bound is supplied as an unverified oracle. -/ + +namespace ContinuumCoulomb.SourceMetadataProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +def size (d : BinaryHeisenberg) : ℕ := (binaryHeisenbergCodec.encode d).length + 1 + +noncomputable opaque sizeProgram : Procedure binaryHeisenbergCodec.encode unaryCode size := + Procedure.unarySuccessor.comp (Procedure.length.precompose binaryHeisenbergCodec.encode) + +noncomputable def boundProgram : (k : ℕ) → Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => size d ^ k) + | 0 => Procedure.constant _ unaryCode 1 + | k + 1 => (SourceNormalizationProgram.mul.comp ((boundProgram k).pair sizeProgram)).congrFun + (by intro d; exact (pow_succ (size d) k).symm) + +noncomputable opaque vertexCount : Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => d.coordinate.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength + SourcePrograms.coordinateCodec.encode (0, 0)).comp SourcePrograms.coordinates +noncomputable opaque edgeCount : Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => d.edges.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength + binaryHeisenbergEdgeCodec.encode ⟨0, 0, ⟨0, 1⟩⟩).comp SourcePrograms.edges + +def input (k : ℕ) (d : BinaryHeisenberg) : Input := + ((d.edges.length, size d ^ k, size d ^ k, d.coordinate.length), + d.edges.map (fun e => (e.left, e.right, e.coefficient.value))) + +noncomputable opaque environment (k : ℕ) : Procedure binaryHeisenbergCodec.encode envCode + (fun d => (input k d).1) := + edgeCount.pair ((boundProgram k).pair ((boundProgram k).pair vertexCount)) +noncomputable opaque inputProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode inputCode + (input k) := (environment k).pair MediatorListProgram.sourceBonds + +noncomputable def normalizedProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode inputCode + (fun d => SourceNormalizationProgram.normalized (input k d)) := + SourceNormalizationProgram.normalizedProgram.comp (inputProgram k) +noncomputable def certificate (k : ℕ) : Turing.TM2ComputableInPolyTime + binaryHeisenbergCodec.encode inputCode + (fun d => SourceNormalizationProgram.normalized (input k d)) := + (normalizedProgram k).toTM2 + +end ContinuumCoulomb.SourceMetadataProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNormalizationProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNormalizationProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3a8173c77a33f5f356c44953a63faeb9bf952bf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNormalizationProgram.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceNormalizedPromise + +namespace OAI + +/-! Actual polynomial-time normalization of a literal source-bond list. +The input coefficient bound and inverse precision are unary metadata; the +rounding denominator uses the actual list length, and zero bonds are deleted. -/ + +namespace ContinuumCoulomb.SourceNormalizationProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +noncomputable opaque add : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => x.1 + x.2) := Procedure.unaryAdd +noncomputable opaque mul : Procedure (prodCode unaryCode unaryCode) unaryCode + (fun x => x.1 * x.2) := Procedure.unaryMul + +noncomputable opaque xsProgram : Procedure inputCode (listCode bondCode) Prod.snd := + Procedure.second _ _ +noncomputable opaque environment : Procedure inputCode envCode Prod.fst := Procedure.first _ _ +noncomputable opaque lengthProgram : Procedure inputCode unaryCode (fun x => x.2.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp xsProgram +noncomputable opaque wProgram : Procedure inputCode unaryCode (fun x => x.1.2.1) := + ((Procedure.first unaryCode _).comp (Procedure.second unaryCode _)).comp environment +noncomputable opaque gProgram : Procedure inputCode unaryCode (fun x => x.1.2.2.1) := + (((Procedure.first unaryCode unaryCode).comp (Procedure.second unaryCode _)).comp + (Procedure.second unaryCode _)).comp environment +noncomputable opaque nProgram : Procedure inputCode unaryCode (fun x => x.1.2.2.2) := + (((Procedure.second unaryCode unaryCode).comp (Procedure.second unaryCode _)).comp + (Procedure.second unaryCode _)).comp environment + +noncomputable opaque denominatorProgram : Procedure inputCode unaryCode + (fun x => SourceNormalizedSpectrum.denominator x.2.length x.1.2.2.1) := by + let rPlus : Procedure inputCode unaryCode (fun x => x.2.length + 1) := + Procedure.unarySuccessor.comp lengthProgram + let base : Procedure inputCode unaryCode (fun x => 1024 * (x.2.length + 1)) := + mul.comp ((Procedure.constant inputCode unaryCode 1024).pair rPlus) + exact (mul.comp (base.pair gProgram)).congrFun (by intro x; rfl) + +def rounded (x : Input) : List Bond := x.2.map (fun e => + (e.1, e.2.1, SourceCoefficientRounding.coefficient + (SourceNormalizedSpectrum.denominator x.2.length x.1.2.2.1) e.2.2)) + +def retained (x : Input) : List Bond := (rounded x).filter SourceZeroFilter.keep + +noncomputable opaque roundList : Procedure (prodCode unaryCode (listCode bondCode)) + (listCode bondCode) (fun x => x.2.map (fun e => + (e.1, e.2.1, SourceCoefficientRounding.coefficient x.1 e.2.2))) := + SourceCoefficientRounding.listProgram +noncomputable opaque roundedProgram : Procedure inputCode (listCode bondCode) rounded := by + let p : Procedure inputCode (prodCode unaryCode (listCode bondCode)) + (fun x => (SourceNormalizedSpectrum.denominator x.2.length x.1.2.2.1, x.2)) := + denominatorProgram.pair xsProgram + exact (roundList.comp p).congrFun (by intro x; rfl) +noncomputable opaque retainedProgram : Procedure inputCode (listCode bondCode) retained := + SourceZeroFilter.filterProgram.comp roundedProgram +noncomputable opaque retainedLength : Procedure inputCode unaryCode + (fun x => (retained x).length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp retainedProgram +noncomputable opaque boundProgram : Procedure inputCode unaryCode + (fun x => SourceNormalizedSpectrum.denominator x.2.length x.1.2.2.1 + x.1.2.1 + 1) := + Procedure.unarySuccessor.comp (add.comp (denominatorProgram.pair wProgram)) + +def normalized (x : Input) : Input := + (((retained x).length, + SourceNormalizedSpectrum.denominator x.2.length x.1.2.2.1 + x.1.2.1 + 1, + x.1.2.2.1, x.1.2.2.2), retained x) + +noncomputable opaque normalizedEnv : Procedure inputCode envCode (fun x => (normalized x).1) := + retainedLength.pair (boundProgram.pair (gProgram.pair nProgram)) +noncomputable opaque normalizedProgram : Procedure inputCode inputCode normalized := + normalizedEnv.pair retainedProgram +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode inputCode normalized := + normalizedProgram.toTM2 + +end ContinuumCoulomb.SourceNormalizationProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNuclearProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNuclearProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6a6f10a852ba4d24ad93ddd9b2275eff2359f30 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourceNuclearProgram.lean @@ -0,0 +1,117 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourcePhysicalThreshold +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PhysicalNuclearProgram + +namespace OAI + +/-! Raw-source assembly of the actual transported unit nuclei. The well +scale is exactly lambda, the cutoff width is the exact centered slab width, +and all three lattice radii come from the same powers as the thresholds. -/ + +namespace ContinuumCoulomb.SourceNuclearProgram +open ExactQuantumFactoring.BitStackProgram + +noncomputable def sites (rho C : ℕ) (ε c : ℚ) (s p h k A B : ℕ) + (d : BinaryHeisenberg) : List (ℚ×ℚ) := + PrefactorSourceContactProgram.value rho (CalibrationMesh.prefactor rho) C ε c s p h k A B d + +def amplification (rho k : ℕ) (d : BinaryHeisenberg) : ℚ := + CenteredPhysicalThreshold.amplification rho (SourcePhysicalThreshold.mesh k d) + +noncomputable def input (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) + (d : BinaryHeisenberg) : PhysicalNuclearProgram.Input := + (((SourceContactProgram.size d^r,SourcePhysicalThreshold.mesh k d), + ((amplification rho k d,SourcePhysicalThreshold.slabVertical k d), + sites rho C ε c s p h k A B d)), + (SourcePhysicalThreshold.horizontalRadius k d, + (SourcePhysicalThreshold.horizontalRadius k d,SourcePhysicalThreshold.verticalRadius k d))) + +noncomputable def nuclei (rho C U F K : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) + (d : BinaryHeisenberg) : List BinaryPosition := + PhysicalNuclearProgram.nuclei rho U F K (input rho C ε c s p h k A B r d) + +noncomputable opaque amplificationProgram (rho k : ℕ) : + Procedure binaryHeisenbergCodec.encode ratCode (amplification rho k) := by + let n := Procedure.natToRat.comp + (Procedure.unaryToBits.comp (SourceContactProgram.powerProgram (10*k))) + let n2 := Procedure.ratMul.comp (n.pair n) + let n3 := Procedure.ratMul.comp (n2.pair n) + let num := Procedure.ratMul.comp + ((Procedure.constant binaryHeisenbergCodec.encode ratCode 8).pair n3) + exact (Procedure.ratDiv.comp (num.pair + (Procedure.constant binaryHeisenbergCodec.encode ratCode (rho:ℚ)))).congrFun (by + intro d + change (8*((((SourceContactProgram.size d^(10*k):ℕ):ℚ)* + ((SourceContactProgram.size d^(10*k):ℕ):ℚ))* + ((SourceContactProgram.size d^(10*k):ℕ):ℚ)))/(rho:ℚ) = _ + simp only [amplification,CenteredPhysicalThreshold.amplification,SourcePhysicalThreshold.mesh] + ring) + +noncomputable opaque verticalProgram (k : ℕ) : + Procedure binaryHeisenbergCodec.encode ratCode (SourcePhysicalThreshold.slabVertical k) := by + let m := Procedure.natToRat.comp + (Procedure.unaryToBits.comp (SourceContactProgram.powerProgram (10*k))) + let s := Procedure.natToRat.comp + (Procedure.unaryToBits.comp (SourceContactProgram.powerProgram (15*k))) + let num := Procedure.ratAdd.comp + (s.pair (Procedure.constant binaryHeisenbergCodec.encode ratCode (1/2:ℚ))) + exact (Procedure.ratDiv.comp (num.pair m)).congrFun (by intro d; rfl) + +noncomputable opaque inputProgram (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) : + Procedure binaryHeisenbergCodec.encode PhysicalNuclearProgram.inputCode + (input rho C ε c s p h k A B r) := by + let mesh := Procedure.unaryToBits.comp (SourceContactProgram.powerProgram (10*k)) + let precise := SourceContactProgram.powerProgram r + let hs := SourceContactProgram.powerProgram (60*k) + let vs := SourceContactProgram.powerProgram (15*k) + let points := PrefactorSourceContactProgram.program rho (CalibrationMesh.prefactor rho) C ε c + s p h k A B + let field := ((amplificationProgram rho k).pair (verticalProgram k)).pair points + exact ((precise.pair mesh).pair field).pair (hs.pair (hs.pair vs)) + +noncomputable opaque program (rho C U F K : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) : + Procedure binaryHeisenbergCodec.encode (BinaryEncoding.list binaryPositionCodec).encode + (nuclei rho C U F K ε c s p h k A B r) := + (PhysicalNuclearProgram.program rho U F K).comp (inputProgram rho C ε c s p h k A B r) + +noncomputable def certificate (rho C U F K : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) : + Turing.TM2ComputableInPolyTime binaryHeisenbergCodec.encode + (BinaryEncoding.list binaryPositionCodec).encode (nuclei rho C U F K ε c s p h k A B r) := + (program rho C U F K ε c s p h k A B r).toTM2 + +theorem mesh (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) (d : BinaryHeisenberg) : + (input rho C ε c s p h k A B r d).1.1.2 = SourcePhysicalThreshold.mesh k d := rfl + +theorem field_scale (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) (d : BinaryHeisenberg) : + (input rho C ε c s p h k A B r d).1.2.1.1 = amplification rho k d := rfl + +theorem field_width (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) (d : BinaryHeisenberg) : + (input rho C ε c s p h k A B r d).1.2.1.2 = SourcePhysicalThreshold.slabVertical k d := rfl + +theorem field_sites (rho C : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) (d : BinaryHeisenberg) : + (input rho C ε c s p h k A B r d).1.2.2 = sites rho C ε c s p h k A B d := rfl + +theorem real_positions (rho C U F K : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) + (d : BinaryHeisenberg) : + (nuclei rho C U F K ε c s p h k A B r d).map (fun a => realPosition a.value) = + (TransformedGauss.nodes rho U F K + ((input rho C ε c s p h k A B r d).1, + CenteredGaussLabels.labels (input rho C ε c s p h k A B r d).2)).map + (fun a => (PhysicalNuclearProgram.factor rho (SourcePhysicalThreshold.mesh k d):ℝ) • + CappedKernelProgram.position a) := by + simp only [nuclei,PhysicalNuclearProgram.nuclei,PhysicalNuclearProgram.triples, + NuclearCoordinateOutput.positions,List.map_map,Function.comp_def, + NuclearCoordinateOutput.real_position,PhysicalNuclearProgram.scale_position] + rfl + +theorem nuclei_length (rho C U F K : ℕ) (ε c : ℚ) (s p h k A B r : ℕ) + (d : BinaryHeisenberg) : + (nuclei rho C U F K ε c s p h k A B r d).length = + 8*((2*SourcePhysicalThreshold.horizontalRadius k d+1)^2* + (2*SourcePhysicalThreshold.verticalRadius k d+1)) := by + rw [nuclei,PhysicalNuclearProgram.nuclei_length] + dsimp only [input] + ring + +end ContinuumCoulomb.SourceNuclearProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePositiveProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePositiveProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..0285ae324bbf2216f7dfb4373a7349c5847e9f8f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePositiveProgram.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorOffsetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceNormalizationCorrectness + +namespace OAI + +/-! The complete literal source-to-positive-spin program. It parses the +original source, computes the fixed polynomial metadata, rounds and deletes +zero coefficients, emits all three graph stages, and shifts both thresholds. -/ + +namespace ContinuumCoulomb.SourcePositiveProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +structure Registers where + coordinate : List SourcePrograms.Coordinate + vertices : ℕ + bound : ℕ + gapScale : ℕ + bonds : List Bond + offset : ℚ + lower : ℚ + upper : ℚ + +def registerCode (x : Registers) : List Bool := + prodCode (listCode SourcePrograms.coordinateCodec.encode) + (prodCode unaryCode (prodCode unaryCode (prodCode unaryCode + (prodCode (listCode bondCode) (prodCode ratCode (prodCode ratCode ratCode)))))) + (x.coordinate, x.vertices, x.bound, x.gapScale, x.bonds, x.offset, x.lower, x.upper) + +def normalized (k : ℕ) (d : BinaryHeisenberg) : Input := + SourceNormalizationProgram.normalized (SourceMetadataProgram.input k d) + +def offset (k : ℕ) (d : BinaryHeisenberg) : ℚ := MediatorOffsetProgram.offset (normalized k d) + +def error (k : ℕ) (d : BinaryHeisenberg) : ℚ := + 1 / (128 * ((SourceMetadataProgram.size d ^ k : ℕ) : ℚ)) + +def output (k : ℕ) (d : BinaryHeisenberg) : Registers where + coordinate := d.coordinate + vertices := (normalized k d).1.2.2.2 + 18 * (normalized k d).1.1 + bound := MediatorParameters.finalWeight (normalized k d).1.1 + (normalized k d).1.2.1 (normalized k d).1.2.2.1 + gapScale := SourceMetadataProgram.size d ^ k + bonds := MediatorThreeStageProgram.finalBonds (normalized k d) + offset := offset k d + lower := d.lower.value - offset k d + error k d + upper := d.upper.value - offset k d - error k d + +noncomputable opaque normalizedProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode inputCode + (normalized k) := SourceMetadataProgram.normalizedProgram k +noncomputable opaque verticesProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => (output k d).vertices) := + MediatorThreeStageProgram.verticesProgram.comp (normalizedProgram k) +noncomputable opaque boundProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode unaryCode + (fun d => (output k d).bound) := + MediatorThreeStageProgram.boundProgram.comp (normalizedProgram k) +noncomputable opaque bondsProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode (listCode bondCode) + (fun d => (output k d).bonds) := + MediatorThreeStageProgram.bondsProgram.comp (normalizedProgram k) +noncomputable opaque offsetProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (offset k) := MediatorOffsetProgram.offsetProgram.comp (normalizedProgram k) + +noncomputable opaque gRationalProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => ((SourceMetadataProgram.size d ^ k : ℕ) : ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp (SourceMetadataProgram.boundProgram k)) +noncomputable opaque denominatorProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => 128 * ((SourceMetadataProgram.size d ^ k : ℕ) : ℚ)) := + Procedure.ratMul.comp ((Procedure.constant binaryHeisenbergCodec.encode ratCode 128).pair + (gRationalProgram k)) +noncomputable opaque errorProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode (error k) := + Procedure.ratDiv.comp ((Procedure.constant binaryHeisenbergCodec.encode ratCode 1).pair + (denominatorProgram k)) +noncomputable opaque lowerShiftProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => d.lower.value - offset k d) := + Procedure.ratSub.comp (SourcePrograms.lower.pair (offsetProgram k)) +noncomputable opaque upperShiftProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => d.upper.value - offset k d) := + Procedure.ratSub.comp (SourcePrograms.upper.pair (offsetProgram k)) +noncomputable opaque lowerProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => (output k d).lower) := + Procedure.ratAdd.comp ((lowerShiftProgram k).pair (errorProgram k)) +noncomputable opaque upperProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => (output k d).upper) := + Procedure.ratSub.comp ((upperShiftProgram k).pair (errorProgram k)) + +noncomputable opaque outputProgram (k : ℕ) : Procedure binaryHeisenbergCodec.encode registerCode + (output k) := + (SourcePrograms.coordinates.pair ((verticesProgram k).pair ((boundProgram k).pair + ((SourceMetadataProgram.boundProgram k).pair ((bondsProgram k).pair ((offsetProgram k).pair + ((lowerProgram k).pair (upperProgram k)))))))).result (by intro d; rfl) + +noncomputable def certificate (k : ℕ) : Turing.TM2ComputableInPolyTime + binaryHeisenbergCodec.encode registerCode (output k) := (outputProgram k).toTM2 + +end ContinuumCoulomb.SourcePositiveProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..fca1d006f2745debf231e504d0d11398ca93d382 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SourcePrograms.lean @@ -0,0 +1,152 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PrefixListPrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourcePromise +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! Literal finite-stack decoding of every source field, including counted +coordinate/edge lists and noncanonical rational pairs. The resulting +registers use the existing proved machine list and rational arithmetic. -/ + +namespace ContinuumCoulomb.SourcePrograms +open ExactQuantumFactoring.BitStackProgram PrefixPrograms + +noncomputable def equivSplitter {α β : Type} (c : BinaryEncoding.Codec α) + (e : β ≃ α) (p : Splitter c) : Splitter (BinaryEncoding.equiv c e) := + (p.precompose (fun x : β × List Bool => (e x.1, x.2))).result (by intro x; rfl) + +noncomputable def fieldInput {α : Type} (c : BinaryEncoding.Codec α) (p : Splitter c) : + Procedure c.encode c.encode id := + ((Procedure.first c.encode id).comp (p.precompose (fun x : α => (x, [])))).congrEncoding + (by intro x; exact List.append_nil _) (by intro x; rfl) + +noncomputable def pairInput {α β : Type} (c : BinaryEncoding.Codec α) + (d : BinaryEncoding.Codec β) (p : Splitter c) : + Procedure (BinaryEncoding.pair c d).encode (prodCode c.encode d.encode) id := + (p.precompose (fun x : α × β => (x.1, d.encode x.2))).result (by intro x; rfl) + +noncomputable def rationalSplitter : Splitter binaryRationalCodec := + equivSplitter _ binaryRationalEquiv + (PrefixPrograms.pair BinaryEncoding.integer BinaryEncoding.natural integer natural) + +noncomputable def coordinateSplitter : Splitter (BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.integer) := + PrefixPrograms.pair _ _ integer integer + +noncomputable def edgeSplitter : Splitter binaryHeisenbergEdgeCodec := + equivSplitter _ binaryHeisenbergEdgeEquiv + (PrefixPrograms.pair _ _ natural + (PrefixPrograms.pair _ _ natural rationalSplitter)) + +theorem integer_length_pos (z : ℤ) : 0 < (BinaryEncoding.integer.encode z).length := by + cases z <;> simp only [BinaryEncoding.integer, List.length_cons] <;> omega + +theorem coordinate_length_pos (p : ℤ × ℤ) : + 0 < ((BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.integer).encode p).length := by + have h := integer_length_pos p.1 + simp only [BinaryEncoding.pair_length] + omega + +theorem edge_length_pos (e : BinaryHeisenbergEdge) : + 0 < (binaryHeisenbergEdgeCodec.encode e).length := by + have h := BinaryEncoding.natural_length e.left + change 0 < ((BinaryEncoding.natural.encode e.left ++ + (BinaryEncoding.natural.encode e.right ++ binaryRationalCodec.encode e.coefficient))).length + simp only [List.length_append] + omega + +abbrev Coordinate := ℤ × ℤ + +def coordinateCodec := BinaryEncoding.pair BinaryEncoding.integer BinaryEncoding.integer + +def coordinateListCodec := BinaryEncoding.list coordinateCodec + +def edgeListCodec := BinaryEncoding.list binaryHeisenbergEdgeCodec + +def thresholdCodec := BinaryEncoding.pair binaryRationalCodec binaryRationalCodec + +def sourceTailCodec := BinaryEncoding.pair edgeListCodec thresholdCodec + +def sourceTupleCodec := BinaryEncoding.pair coordinateListCodec sourceTailCodec + +noncomputable def coordinateListSplitter : Splitter coordinateListCodec := + PrefixListPrograms.listSplitter coordinateCodec coordinateSplitter (0, 0) coordinate_length_pos + +noncomputable def edgeListSplitter : Splitter edgeListCodec := + PrefixListPrograms.listSplitter binaryHeisenbergEdgeCodec edgeSplitter ⟨0, 0, ⟨0, 1⟩⟩ edge_length_pos + +noncomputable def thresholdSplitter : Splitter thresholdCodec := + PrefixPrograms.pair _ _ rationalSplitter rationalSplitter + +noncomputable def sourceTailSplitter : Splitter sourceTailCodec := + PrefixPrograms.pair _ _ edgeListSplitter thresholdSplitter + +noncomputable def sourceSplitter : Splitter binaryHeisenbergCodec := + equivSplitter _ binaryHeisenbergEquiv + (PrefixPrograms.pair _ _ coordinateListSplitter sourceTailSplitter) + +/-- The rational denominator is parsed and reduced by the actual gcd-based +machine routine, so noncanonical input fractions are handled correctly. -/ +noncomputable def rationalValue : Procedure binaryRationalCodec.encode ratCode BinaryRational.value := by + let p := (pairInput BinaryEncoding.integer BinaryEncoding.natural integer).precompose + binaryRationalEquiv + let numerator : Procedure binaryRationalCodec.encode intCode BinaryRational.numerator := + EncodingPrograms.integerInput.comp ((Procedure.first _ _).comp p) + let denominator : Procedure binaryRationalCodec.encode Nat.bits BinaryRational.denominator := + EncodingPrograms.naturalInput.comp ((Procedure.second _ _).comp p) + exact (Procedure.makeRat.comp (numerator.pair denominator)).congrFun (by + intro q + exact Rat.mkRat_eq_div q.numerator q.denominator) + +noncomputable def sourceTuple : Procedure binaryHeisenbergCodec.encode + (prodCode coordinateListCodec.encode sourceTailCodec.encode) binaryHeisenbergEquiv := + (pairInput coordinateListCodec sourceTailCodec coordinateListSplitter).precompose binaryHeisenbergEquiv + +noncomputable def coordinatesRaw : Procedure binaryHeisenbergCodec.encode coordinateListCodec.encode + BinaryHeisenberg.coordinate := (Procedure.first _ _).comp sourceTuple + +noncomputable def tailRaw : Procedure binaryHeisenbergCodec.encode sourceTailCodec.encode + (fun d => (d.edges, d.lower, d.upper)) := (Procedure.second _ _).comp sourceTuple + +noncomputable def tailTuple : Procedure binaryHeisenbergCodec.encode + (prodCode edgeListCodec.encode thresholdCodec.encode) (fun d => (d.edges, d.lower, d.upper)) := + (pairInput edgeListCodec thresholdCodec edgeListSplitter).comp tailRaw + +noncomputable def edgesRaw : Procedure binaryHeisenbergCodec.encode edgeListCodec.encode + BinaryHeisenberg.edges := (Procedure.first _ _).comp tailTuple + +noncomputable def thresholdsRaw : Procedure binaryHeisenbergCodec.encode thresholdCodec.encode + (fun d => (d.lower, d.upper)) := (Procedure.second _ _).comp tailTuple + +noncomputable def thresholdTuple : Procedure binaryHeisenbergCodec.encode + (prodCode binaryRationalCodec.encode binaryRationalCodec.encode) (fun d => (d.lower, d.upper)) := + (pairInput binaryRationalCodec binaryRationalCodec rationalSplitter).comp thresholdsRaw + +noncomputable def coordinates : Procedure binaryHeisenbergCodec.encode + (listCode coordinateCodec.encode) BinaryHeisenberg.coordinate := + (PrefixListPrograms.listInput coordinateCodec coordinateSplitter (0, 0) coordinate_length_pos).comp coordinatesRaw + +noncomputable def edges : Procedure binaryHeisenbergCodec.encode + (listCode binaryHeisenbergEdgeCodec.encode) BinaryHeisenberg.edges := + (PrefixListPrograms.listInput binaryHeisenbergEdgeCodec edgeSplitter ⟨0, 0, ⟨0, 1⟩⟩ edge_length_pos).comp edgesRaw + +noncomputable def lower : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => d.lower.value) := rationalValue.comp ((Procedure.first _ _).comp thresholdTuple) + +noncomputable def upper : Procedure binaryHeisenbergCodec.encode ratCode + (fun d => d.upper.value) := rationalValue.comp ((Procedure.second _ _).comp thresholdTuple) + +def registerCode (d : BinaryHeisenberg) : List Bool := + prodCode (listCode coordinateCodec.encode) + (prodCode (listCode binaryHeisenbergEdgeCodec.encode) (prodCode ratCode ratCode)) + (d.coordinate, d.edges, d.lower.value, d.upper.value) + +/-- A concrete polynomial TM2 parser for the entire source instance. -/ +noncomputable def registers : Procedure binaryHeisenbergCodec.encode registerCode id := + (coordinates.pair (edges.pair (lower.pair upper))).result (by intro d; rfl) + +noncomputable def registers_certificate : Turing.TM2ComputableInPolyTime + binaryHeisenbergCodec.encode registerCode id := registers.toTM2 + +end ContinuumCoulomb.SourcePrograms + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SquareRootProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SquareRootProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3973bfe06849e6de271673a8ef04eb5d51e1c96 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/SquareRootProgram.lean @@ -0,0 +1,145 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.EncodingPrograms +import OAI.Computability.QuantumFactoring.BitStackPowers +import OAI.Computability.QuantumFactoring.BinaryRoots + +namespace OAI + +/-! Bitwise integer square-root search and its actual polynomial-time +Boolean-stack implementation. This supplies arithmetic for finite-precision +geometric constants and mediator amplitudes without a real square-root oracle. -/ + +namespace ContinuumCoulomb.SquareRootProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev State := ℕ × (ℕ × ℕ) + +def code : State → List Bool := prodCode Nat.bits (prodCode Nat.bits Nat.bits) + +def step (s : State) : State := + let half := s.2.1 / 2 + let candidate := s.2.2 + half + (s.1, half, if candidate * candidate ≤ s.1 then candidate else s.2.2) + +def root (m : ℕ) : ℕ := + ExactQuantumFactoring.Primality.boundedRoot m 2 m.bits.length + +theorem iterate_power (m k g : ℕ) : + (step^[k]) (m, 2 ^ k, g) = + (m, 1, ExactQuantumFactoring.Primality.rootSearch m 2 k g) := by + induction k generalizing g with + | zero => rfl + | succ k ih => + rw [Function.iterate_succ_apply] + have hhalf : 2 ^ (k + 1) / 2 = 2 ^ k := by simp [pow_succ] + simp only [step, hhalf, ← pow_two, ExactQuantumFactoring.Primality.rootSearch] + exact ih _ + +/-- The returned integer brackets the true square root by adjacent integers. -/ +theorem root_spec (m : ℕ) : root m ^ 2 ≤ m ∧ m < (root m + 1) ^ 2 := by + apply ExactQuantumFactoring.Primality.boundedRoot_spec (by decide) + simpa only [Nat.size_eq_bits_len] using Nat.lt_size_self m + +theorem root_le_sqrt (m : ℕ) : (root m : ℝ) ≤ Real.sqrt m := by + apply (Real.le_sqrt (by positivity) (by positivity)).mpr + exact_mod_cast (root_spec m).1 + +theorem sqrt_lt_root_add_one (m : ℕ) : Real.sqrt m < (root m : ℝ) + 1 := by + apply (Real.sqrt_lt (by positivity) (by positivity)).mpr + exact_mod_cast (root_spec m).2 + +def measure (s : State) : ℕ := s.1.bits.length + s.2.1.bits.length + s.2.2.bits.length + +theorem code_length (s : State) : + (code s).length = 2 * s.1.bits.length + 2 * s.2.1.bits.length + s.2.2.bits.length + 2 := by + simp only [code, prodCode, pairBits_length] + omega + +theorem measure_le_code (s : State) : measure s ≤ (code s).length := by + rw [code_length] + unfold measure + omega + +theorem code_le_measure (s : State) : (code s).length ≤ 2 * measure s + 2 := by + rw [code_length] + unfold measure + omega + +theorem step_measure (s : State) : measure (step s) ≤ measure s + s.2.1.bits.length + 1 := by + have hhalf : (s.2.1 / 2).bits.length ≤ s.2.1.bits.length := + bits_length_mono (Nat.div_le_self _ _) + have hc := bits_length_add s.2.2 (s.2.1 / 2) + dsimp only [measure, step] + split_ifs <;> omega + +theorem iterate_half_bits (s : State) (i : ℕ) : + ((step^[i]) s).2.1.bits.length ≤ s.2.1.bits.length := by + induction i with + | zero => rfl + | succ i ih => + rw [Function.iterate_succ_apply'] + exact (bits_length_mono (Nat.div_le_self _ _)).trans ih + +theorem iterate_measure (s : State) (i : ℕ) : + measure ((step^[i]) s) ≤ measure s + i * (measure s + 1) := by + induction i with + | zero => simp + | succ i ih => + rw [Function.iterate_succ_apply'] + have h := step_measure ((step^[i]) s) + have hp := iterate_half_bits s i + have hp0 : s.2.1.bits.length ≤ measure s := by unfold measure; omega + nlinarith + +theorem iterate_code_bound (n : ℕ) (s : State) (i : ℕ) (hi : i ≤ n) : + (code ((step^[i]) s)).length ≤ + (8 * (Polynomial.X + 1) ^ 2 + 8 : Polynomial ℕ).eval (n + (code s).length) := by + have hc := code_le_measure ((step^[i]) s) + have hm := iterate_measure s i + have hs := measure_le_code s + have him := Nat.mul_le_mul hi hs + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_ofNat, + Polynomial.eval_pow, Polynomial.eval_X, Polynomial.eval_one] + nlinarith + +noncomputable def stepProgram : Procedure code code step := by + let m := Procedure.first Nat.bits (prodCode Nat.bits Nat.bits) + let rest := Procedure.second Nat.bits (prodCode Nat.bits Nat.bits) + let p := (Procedure.first Nat.bits Nat.bits).comp rest + let g := (Procedure.second Nat.bits Nat.bits).comp rest + let half := Procedure.binaryDiv.comp (p.pair (Procedure.constant code Nat.bits 2)) + let candidate := Procedure.binaryAdd.comp (g.pair half) + let square := Procedure.binaryMul.comp (candidate.pair candidate) + let test := Procedure.binaryLe.comp (square.pair m) + let newGuess := Procedure.conditional test candidate g + exact (m.pair (half.pair newGuess)).congrFun (by + intro s + simp only [step, Function.comp_apply, decide_eq_true_eq]) + +noncomputable def repeatProgram : Procedure (prodCode unaryCode code) code + (fun x => (step^[x.1]) x.2) := + stepProgram.iterate (8 * (Polynomial.X + 1) ^ 2 + 8) iterate_code_bound + +noncomputable def rawProgram : Procedure Nat.bits Nat.bits root := by + let m := Procedure.identity Nat.bits + let n := Procedure.length.precompose Nat.bits + let power := Procedure.binaryPow.comp (n.pair (Procedure.constant Nat.bits Nat.bits 2)) + let state := m.pair (power.pair (Procedure.constant Nat.bits Nat.bits 0)) + let run := repeatProgram.comp (n.pair state) + let guess := (Procedure.second Nat.bits Nat.bits).comp + (Procedure.second Nat.bits (prodCode Nat.bits Nat.bits)) + exact (guess.comp run).congrFun (by + intro m + change ((step^[m.bits.length]) (m, 2 ^ m.bits.length, 0)).2.2 = root m + rw [iterate_power] + rfl) + +noncomputable def program : Procedure BinaryEncoding.natural.encode BinaryEncoding.natural.encode root := + EncodingPrograms.naturalOutput.comp (rawProgram.comp EncodingPrograms.naturalInput) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime BinaryEncoding.natural.encode BinaryEncoding.natural.encode root := + program.toTM2 + +end ContinuumCoulomb.SquareRootProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/TransformedGaussProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/TransformedGaussProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..39b9e72c42e4b372d596b67fad166371d65f98d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/TransformedGaussProgram.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TransformedGauss + +namespace OAI + +/-! A literal polynomial TM2 program for the transported rational Gauss +node. The reciprocal mesh denominator and lattice coordinates are binary; +the requested reciprocal error bound is unary. -/ + +namespace ContinuumCoulomb.TransformedGauss +open ExactQuantumFactoring.BitStackProgram +open CappedKernelProgram (Triple tripleCode) +open EulerRegisters (Registers registersCode) +open RationalGaussNodes (Signs signsCode) + +abbrev Input := (ℕ×ℕ)×((ℚ×ℚ)×(List (ℚ×ℚ)×(Registers×Signs))) +def inputCode : Input → List Bool := + prodCode (prodCode unaryCode Nat.bits) + (prodCode (prodCode ratCode ratCode) + (prodCode ManufacturedFieldEvaluation.sitesCode (prodCode registersCode signsCode))) + +noncomputable def output (rho U C K : ℕ) (x : Input) : Triple := + value rho U C K x.1.1 x.1.2 x.2.1.1 x.2.1.2 x.2.2.1 x.2.2.2.1 x.2.2.2.2 + +noncomputable opaque precisionProgram (K : ℕ) : Procedure unaryCode unaryCode (precision K) := by + let p := Procedure.unaryMul.comp + ((Procedure.constant unaryCode unaryCode (2*(K+1))).pair Procedure.unarySuccessor) + exact p.congrFun (by intro P; rfl) + +noncomputable opaque inputParametersProgram : Procedure inputCode (prodCode unaryCode Nat.bits) Prod.fst := + Procedure.first _ _ +noncomputable opaque dataProgram : Procedure inputCode + (prodCode (prodCode ratCode ratCode) + (prodCode ManufacturedFieldEvaluation.sitesCode (prodCode registersCode signsCode))) Prod.snd := + Procedure.second _ _ +noncomputable opaque inputPrecisionProgram (K : ℕ) : Procedure inputCode unaryCode + (fun x => precision K x.1.1) := + (precisionProgram K).comp ((Procedure.first unaryCode Nat.bits).comp inputParametersProgram) +noncomputable opaque denominatorProgram : Procedure inputCode Nat.bits (fun x => x.1.2) := + (Procedure.second unaryCode Nat.bits).comp inputParametersProgram +noncomputable opaque fieldParametersProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.1) := (Procedure.first _ _).comp dataProgram +noncomputable opaque tailProgram : Procedure inputCode + (prodCode ManufacturedFieldEvaluation.sitesCode (prodCode registersCode signsCode)) + (fun x => x.2.2) := (Procedure.second _ _).comp dataProgram +noncomputable opaque sitesProgram : Procedure inputCode ManufacturedFieldEvaluation.sitesCode + (fun x => x.2.2.1) := (Procedure.first _ _).comp tailProgram +noncomputable opaque nodeDataProgram : Procedure inputCode (prodCode registersCode signsCode) + (fun x => x.2.2.2) := (Procedure.second _ _).comp tailProgram + +noncomputable opaque nodeArgumentsProgram (K : ℕ) : Procedure inputCode RationalGaussNodes.inputCode + (fun x => (precision K x.1.1,(x.1.2,x.2.2.2))) := + (inputPrecisionProgram K).pair (denominatorProgram.pair nodeDataProgram) +noncomputable opaque initialNodeProgram (K : ℕ) : Procedure inputCode tripleCode + (fun x => RationalGaussNodes.value (precision K x.1.1) x.1.2 x.2.2.2.1 x.2.2.2.2) := + RationalGaussNodes.program.comp (nodeArgumentsProgram K) +noncomputable opaque flowArgumentsProgram (K : ℕ) : Procedure inputCode ManufacturedEuler.inputCode + (fun x => (precision K x.1.1,(x.2.1,(x.2.2.1, + RationalGaussNodes.value (precision K x.1.1) x.1.2 x.2.2.2.1 x.2.2.2.2)))) := + (inputPrecisionProgram K).pair + (fieldParametersProgram.pair (sitesProgram.pair (initialNodeProgram K))) + +noncomputable opaque program (rho U C K : ℕ) : Procedure inputCode tripleCode (output rho U C K) := by + let p := (ManufacturedEuler.program rho U C).comp (flowArgumentsProgram K) + exact p.congrFun (by intro x; rfl) + +noncomputable def certificate (rho U C K : ℕ) : + Turing.TM2ComputableInPolyTime inputCode tripleCode (output rho U C K) := + (program rho U C K).toTM2 + +end ContinuumCoulomb.TransformedGauss + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitBinaryProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitBinaryProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..9315a9c0d5da5aea66151d8140c9819479b91954 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitBinaryProgram.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.UnitBinaryInclusion +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.HardnessComposition + +namespace OAI + +/-! Literal polynomial-time inclusion of unit-charge Coulomb instances +into the binary-charge promise. The machine parses the position list, +attaches charge one to each position and preserves the entire encoded +electron/threshold tail. -/ + +namespace ContinuumCoulomb.UnitBinaryProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev positionListCodec := BinaryEncoding.list binaryPositionCodec +abbrev nucleusCodec := BinaryEncoding.pair binaryPositionCodec BinaryEncoding.natural +abbrev nucleusListCodec := BinaryEncoding.list nucleusCodec +abbrev tailCodec := BinaryEncoding.pair BinaryEncoding.unary SourcePrograms.thresholdCodec + +def zeroPosition : BinaryPosition := ⟨⟨0, 1⟩, ⟨0, 1⟩, ⟨0, 1⟩⟩ + +noncomputable opaque positionSplitter : PrefixPrograms.Splitter binaryPositionCodec := + SourcePrograms.equivSplitter _ binaryPositionEquiv + (PrefixPrograms.pair _ _ SourcePrograms.rationalSplitter + (PrefixPrograms.pair _ _ SourcePrograms.rationalSplitter SourcePrograms.rationalSplitter)) + +theorem position_length_pos (p : BinaryPosition) : 0 < (binaryPositionCodec.encode p).length := by + have hx := SourcePrograms.integer_length_pos p.x.numerator + change 0 < ((BinaryEncoding.integer.encode p.x.numerator ++ + BinaryEncoding.natural.encode p.x.denominator) ++ _).length + simp only [List.length_append] + omega + +noncomputable opaque positionListSplitter : PrefixPrograms.Splitter positionListCodec := + PrefixListPrograms.listSplitter binaryPositionCodec positionSplitter zeroPosition position_length_pos + +noncomputable opaque inputTuple : Procedure unitCoulombCodec.encode + (prodCode positionListCodec.encode tailCodec.encode) unitCoulombEquiv := + (SourcePrograms.pairInput positionListCodec tailCodec positionListSplitter).precompose unitCoulombEquiv + +noncomputable opaque positionsRaw : Procedure unitCoulombCodec.encode positionListCodec.encode + UnitCoulomb.nuclei := (Procedure.first _ _).comp inputTuple +noncomputable opaque tailRaw : Procedure unitCoulombCodec.encode tailCodec.encode + (fun d => (d.electrons, d.lower, d.upper)) := (Procedure.second _ _).comp inputTuple +noncomputable opaque positions : Procedure unitCoulombCodec.encode (listCode binaryPositionCodec.encode) + UnitCoulomb.nuclei := + (PrefixListPrograms.listInput binaryPositionCodec positionSplitter zeroPosition position_length_pos).comp positionsRaw + +noncomputable opaque attachOne : Procedure binaryPositionCodec.encode nucleusCodec.encode + (fun r => (r, 1)) := + (EncodingPrograms.appendPair binaryPositionCodec BinaryEncoding.natural).comp + ((Procedure.identity binaryPositionCodec.encode).pair + (Procedure.constant binaryPositionCodec.encode BinaryEncoding.natural.encode 1)) + +noncomputable opaque nuclei : Procedure unitCoulombCodec.encode nucleusListCodec.encode + (fun d => d.nuclei.map (fun r => (r, 1))) := + (PrefixListPrograms.listOutput nucleusCodec (zeroPosition, 1)).comp + ((Procedure.listMap zeroPosition (zeroPosition, 1) attachOne).comp positions) + +noncomputable opaque program : Procedure unitCoulombCodec.encode binaryCoulombCodec.encode + UnitCoulomb.toBinary := + ((EncodingPrograms.appendPair nucleusListCodec tailCodec).comp (nuclei.pair tailRaw)).result + (by intro d; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime + unitCoulombCodec.encode binaryCoulombCodec.encode UnitCoulomb.toBinary := program.toTM2 + +noncomputable def reduction : PolynomialManyOne + unitCoulombCodec.encode binaryCoulombCodec.encode unitCoulombPromise binaryCoulombPromise where + map := UnitCoulomb.toBinary + polynomialTime := certificate + maps_yes _ := unitBinary_yes + maps_no _ := unitBinary_no + +theorem binary_hard_of_unit (h : QMAHard unitCoulombCodec.encode unitCoulombPromise) : + QMAHard binaryCoulombCodec.encode binaryCoulombPromise := h.of_reduction reduction + +end ContinuumCoulomb.UnitBinaryProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitCoulombProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitCoulombProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff339d542ea32ed68f53a27d900cd1d73c04c85c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/UnitCoulombProgram.lean @@ -0,0 +1,85 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PhysicalNuclearProgram + +namespace OAI + +/-! The literal output codec for a complete unit-charge Coulomb instance. +The electron count is unary, and both rational thresholds are emitted in +canonical numerator/positive-denominator form. -/ + +namespace ContinuumCoulomb.UnitCoulombProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := PhysicalNuclearProgram.Input×(ℕ×(ℚ×ℚ)) +def metadataCode : (ℕ×(ℚ×ℚ)) → List Bool := prodCode unaryCode (prodCode ratCode ratCode) +def inputCode : Input → List Bool := prodCode PhysicalNuclearProgram.inputCode metadataCode + +noncomputable def value (rho U C K : ℕ) (x : Input) : UnitCoulomb where + nuclei := PhysicalNuclearProgram.nuclei rho U C K x.1 + electrons := x.2.1 + lower := NuclearCoordinateOutput.rational x.2.2.1 + upper := NuclearCoordinateOutput.rational x.2.2.2 + +noncomputable opaque unaryOutput : Procedure unaryCode BinaryEncoding.unary.encode id := by + let bytes : Procedure unaryCode (id : List Bool → List Bool) unaryCode := + (Procedure.identity unaryCode).result (by intro n; rfl) + let p := Procedure.append.comp + (bytes.pair (Procedure.constant unaryCode (id : List Bool → List Bool) [false])) + exact p.result (by intro n; exact (AmplificationProgram.encodeUnary_replicate n).symm) + +noncomputable opaque geometryProgram : Procedure inputCode PhysicalNuclearProgram.inputCode Prod.fst := + Procedure.first _ _ +noncomputable opaque metadataProgram : Procedure inputCode metadataCode Prod.snd := Procedure.second _ _ +noncomputable opaque electronsProgram : Procedure inputCode BinaryEncoding.unary.encode (fun x => x.2.1) := + unaryOutput.comp ((Procedure.first _ _).comp metadataProgram) +noncomputable opaque thresholdsInputProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.2.2) := (Procedure.second _ _).comp metadataProgram + +noncomputable opaque thresholdsProgram : Procedure inputCode SourcePrograms.thresholdCodec.encode + (fun x => (NuclearCoordinateOutput.rational x.2.2.1,NuclearCoordinateOutput.rational x.2.2.2)) := + (EncodingPrograms.appendPair binaryRationalCodec binaryRationalCodec).comp + ((NuclearCoordinateOutput.rationalProgram.comp ((Procedure.first _ _).comp thresholdsInputProgram)).pair + (NuclearCoordinateOutput.rationalProgram.comp ((Procedure.second _ _).comp thresholdsInputProgram))) + +noncomputable opaque tailProgram : Procedure inputCode UnitBinaryProgram.tailCodec.encode + (fun x => (x.2.1,(NuclearCoordinateOutput.rational x.2.2.1,NuclearCoordinateOutput.rational x.2.2.2))) := + (EncodingPrograms.appendPair BinaryEncoding.unary SourcePrograms.thresholdCodec).comp + (electronsProgram.pair thresholdsProgram) + +noncomputable opaque program (rho U C K : ℕ) : Procedure inputCode unitCoulombCodec.encode (value rho U C K) := + ((EncodingPrograms.appendPair (BinaryEncoding.list binaryPositionCodec) UnitBinaryProgram.tailCodec).comp + (((PhysicalNuclearProgram.program rho U C K).comp geometryProgram).pair tailProgram)).result + (by intro x; rfl) + +noncomputable def certificate (rho U C K : ℕ) : Turing.TM2ComputableInPolyTime inputCode + unitCoulombCodec.encode (value rho U C K) := (program rho U C K).toTM2 + +private theorem positions_injective {ns : List BinaryPosition} + (h : (ns.map BinaryPosition.value).Nodup) : + Function.Injective (fun a : Fin ns.length => (ns.get a).value) := by + intro i j hij + apply Fin.ext + apply h.eq_of_getElem_eq (by simp) (by simp) + simpa only [List.getElem_map,List.get_eq_getElem] using hij + +theorem valid (rho U C K : ℕ) (x : Input) (helectrons : 0 < x.2.1) + (hpositions : ((PhysicalNuclearProgram.nuclei rho U C K x.1).map BinaryPosition.value).Nodup) + (hgap : (1:ℚ) ≤ x.2.2.2-x.2.2.1) : (value rho U C K x).Valid where + nuclei_pos := PhysicalNuclearProgram.nuclei_nonempty rho U C K x.1 + electrons_pos := helectrons + positions a := PhysicalNuclearProgram.nuclei_valid rho U C K x.1 (List.get_mem _ a) + distinct := positions_injective hpositions + lower_denominator := x.2.2.1.den_pos + upper_denominator := x.2.2.2.den_pos + gap := by simpa only [value,NuclearCoordinateOutput.rational_value] using hgap + +theorem valid_of_nodes (rho U C K : ℕ) (x : Input) (hrho : 0 < rho) + (hN : 0 < x.1.1.1.2) (helectrons : 0 < x.2.1) + (hnodes : (TransformedGauss.nodes rho U C K + (x.1.1,CenteredGaussLabels.labels x.1.2)).Nodup) + (hgap : (1:ℚ) ≤ x.2.2.2-x.2.2.1) : (value rho U C K x).Valid := + valid rho U C K x helectrons + (PhysicalNuclearProgram.nuclei_values_nodup rho U C K x.1 hrho hN hnodes) hgap + +end ContinuumCoulomb.UnitCoulombProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/VerticalCutoffProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/VerticalCutoffProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f2512f4a5a04f97b78629d8ce624d09904fa3b7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Programs/VerticalCutoffProgram.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SmoothTransitionProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.ManufacturedWellField + +namespace OAI + +/-! Polynomial-time approximation of the actual transverse cutoff in the +manufactured well field. The rational slab width and coordinate are arbitrary. -/ + +namespace ContinuumCoulomb.VerticalCutoffProgram +open ExactQuantumFactoring.BitStackProgram + +theorem cutoff_error (p : ℕ) (q : ℚ) : + |(SmoothTransitionProgram.cutoff p q:ℝ)-verticalCutoffBump (q:ℝ)| ≤ + ((p:ℝ)+1)⁻¹ := by + simpa only [SmoothTransitionProgram.cutoff,SmoothTransitionProgram.cutoffArgument, + verticalCutoffBump,Rat.cast_div,Rat.cast_sub,Rat.cast_pow,Rat.cast_ofNat] + using RationalSmoothTransition.approximation_error p (SmoothTransitionProgram.cutoffArgument q) + +abbrev Input := ℕ × (ℚ × ℚ) +def inputCode : Input → List Bool := prodCode unaryCode (prodCode ratCode ratCode) +def argument (x : Input) : ℚ := 2/x.2.1*x.2.2 +def value (x : Input) : ℚ := SmoothTransitionProgram.cutoff x.1 (argument x) + +noncomputable opaque argumentProgram : Procedure inputCode ratCode argument := by + let rest := Procedure.second unaryCode (prodCode ratCode ratCode) + let S := (Procedure.first ratCode ratCode).comp rest + let z := (Procedure.second ratCode ratCode).comp rest + let two := Procedure.constant inputCode ratCode (2:ℚ) + exact (Procedure.ratMul.comp ((Procedure.ratDiv.comp (two.pair S)).pair z)).congrFun + (by intro x; rfl) + +noncomputable opaque program : Procedure inputCode ratCode value := + (SmoothTransitionProgram.cutoffProgram.comp + ((Procedure.first unaryCode (prodCode ratCode ratCode)).pair argumentProgram)).congrFun + (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode ratCode value := program.toTM2 + +theorem approximation_error (x : Input) : + |(value x:ℝ)-slabWellCutoff (x.2.1:ℝ) (x.2.2:ℝ)| ≤ ((x.1:ℝ)+1)⁻¹ := by + simpa only [value,argument,slabWellCutoff,Rat.cast_mul,Rat.cast_div,Rat.cast_ofNat] + using cutoff_error x.1 (argument x) + +end ContinuumCoulomb.VerticalCutoffProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockPathBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockPathBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..a29349d1a5bff01026a18ec1cb40693d63b13866 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockPathBound.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateUnitary +import Mathlib.Algebra.Order.Chebyshev + +namespace OAI + +/-! Elementary quantitative propagation estimates for the finite clock. +They compare every clock slice to its initial slice. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb + +def clockPathEnergy {E : Type*} [NormedAddCommGroup E] (f : ℕ → E) (T : ℕ) : ℝ := + ∑ i ∈ Finset.range T, ‖f (i+1)-f i‖^2 + +theorem clockPathEnergy_nonneg {E : Type*} [NormedAddCommGroup E] + (f : ℕ → E) (T : ℕ) : 0 ≤ clockPathEnergy f T := + Finset.sum_nonneg (fun _ _ => sq_nonneg _) + +theorem clock_path_anchor_bound {E : Type*} [NormedAddCommGroup E] + (f : ℕ → E) (T i : ℕ) (hi : i ≤ T) : + ‖f i-f 0‖^2 ≤ (T:ℝ)*clockPathEnergy f T := by + have ht : ∑ j ∈ Finset.range i, (f (j+1)-f j) = f i-f 0 := by + exact Finset.sum_range_sub f i + have hn : ‖f i-f 0‖ ≤ ∑ j ∈ Finset.range i, ‖f (j+1)-f j‖ := by + rw [←ht] + exact norm_sum_le _ _ + have hsq : ‖f i-f 0‖^2 ≤ (∑ j ∈ Finset.range i, ‖f (j+1)-f j‖)^2 := + pow_le_pow_left₀ (norm_nonneg _) hn 2 + have hc := sq_sum_le_card_mul_sum_sq (s := Finset.range i) (f := fun j => ‖f (j+1)-f j‖) + have he : (∑ j ∈ Finset.range i, ‖f (j+1)-f j‖^2) ≤ clockPathEnergy f T := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hi) + intro _ _ _ + positivity + apply (hsq.trans hc).trans + simp only [Finset.card_range] + exact mul_le_mul (by exact_mod_cast hi) he (by positivity) (Nat.cast_nonneg T) + +theorem clock_path_mass_bound {E : Type*} [NormedAddCommGroup E] + (f : ℕ → E) (T : ℕ) : + (∑ i ∈ Finset.range (T+1), ‖f i‖^2) ≤ + 2*(T+1:ℝ)*‖f 0‖^2 + 2*T*(T+1:ℝ)*clockPathEnergy f T := by + have hb (i : ℕ) (hi : i ∈ Finset.range (T+1)) : + ‖f i‖^2 ≤ 2*‖f 0‖^2 + 2*(T:ℝ)*clockPathEnergy f T := by + have ha := clock_path_anchor_bound f T i (Nat.le_of_lt_succ (Finset.mem_range.mp hi)) + have hn : ‖f i‖ ≤ ‖f i-f 0‖+‖f 0‖ := by + simpa only [add_comm] using norm_le_insert' (f i) (f 0) + have hs : ‖f i‖^2 ≤ (‖f i-f 0‖+‖f 0‖)^2 := + pow_le_pow_left₀ (norm_nonneg _) hn 2 + nlinarith [sq_nonneg (‖f i-f 0‖-‖f 0‖)] + apply (Finset.sum_le_sum hb).trans_eq + simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] + push_cast + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockWeightedBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockWeightedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..09b3625b158a36c56a84fb64f200e78c8899b21f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/ClockWeightedBound.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.ClockPathBound + +namespace OAI + +/-! Fixed-weight clock bounds retain a strict completeness/soundness margin. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem norm_add_sq_two {E : Type*} [NormedAddCommGroup E] (a b : E) : + ‖a+b‖^2 ≤ 2*‖a‖^2+2*‖b‖^2 := by + have h := pow_le_pow_left₀ (norm_nonneg (a+b)) (norm_add_le a b) 2 + nlinarith [sq_nonneg (‖a‖-‖b‖)] + +theorem norm_add_sq_four {E : Type*} [NormedAddCommGroup E] (a b : E) : + 4*‖a+b‖^2 ≤ 5*‖a‖^2+20*‖b‖^2 := by + have h := pow_le_pow_left₀ (norm_nonneg (a+b)) (norm_add_le a b) 2 + nlinarith [sq_nonneg (‖a‖-4*‖b‖)] + +theorem norm_add_sq_three {E : Type*} [NormedAddCommGroup E] (a b : E) : + 3*‖a+b‖^2 ≤ 4*‖a‖^2+12*‖b‖^2 := by + have h := pow_le_pow_left₀ (norm_nonneg (a+b)) (norm_add_le a b) 2 + nlinarith [sq_nonneg (‖a‖-3*‖b‖)] + +theorem clock_path_weighted_mass_bound {E : Type*} [NormedAddCommGroup E] + (f : ℕ → E) (T : ℕ) : + 4*(∑ i ∈ Finset.range (T+1), ‖f i‖^2) ≤ + 5*(T+1:ℝ)*‖f 0‖^2+20*T*(T+1:ℝ)*clockPathEnergy f T := by + have hb (i : ℕ) (hi : i ∈ Finset.range (T+1)) : + 4*‖f i‖^2 ≤ 5*‖f 0‖^2+20*(T:ℝ)*clockPathEnergy f T := by + have ha := clock_path_anchor_bound f T i (Nat.le_of_lt_succ (Finset.mem_range.mp hi)) + have h := norm_add_sq_four (f 0) (f i-f 0) + have he : f 0+(f i-f 0) = f i := by abel + rw [he] at h + linarith + calc + 4*(∑ i ∈ Finset.range (T+1), ‖f i‖^2) = + ∑ i ∈ Finset.range (T+1), 4*‖f i‖^2 := by rw [Finset.mul_sum] + _ ≤ ∑ _i ∈ Finset.range (T+1), + (5*‖f 0‖^2+20*(T:ℝ)*clockPathEnergy f T) := Finset.sum_le_sum hb + _ = _ := by + simp only [Finset.sum_const,Finset.card_range,nsmul_eq_mul] + push_cast + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAcceptance.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAcceptance.lean new file mode 100644 index 0000000000000000000000000000000000000000..19e45a413045d045940a26a7036ca79a6a7a2719 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAcceptance.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGates +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.FockBlocks + +namespace OAI + +/-! Zero-ancilla witness inclusion and the actual Born probability bounds. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix HubbardGlobal +open scoped BigOperators + +/-- A witness basis vector with every ancillary qubit set to zero. -/ +def qmaWitnessBasis (c : QMACircuit) (s : SourceSpinBasis c.witness) : + SourceSpinBasis (c.work + 1) := + fun i => if hi : i.val < c.witness then s ⟨i.val, hi⟩ else 0 + +/-- Restriction to the witness register of a well-formed circuit. -/ +def qmaWitnessPrefix (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis (c.work + 1)) : SourceSpinBasis c.witness := + fun i => s ⟨i.val, lt_of_lt_of_le i.isLt (hc.1.trans (Nat.le_succ _))⟩ + +@[simp] theorem qmaWitnessPrefix_basis (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis c.witness) : qmaWitnessPrefix c hc (qmaWitnessBasis c s) = s := by + funext i + simp [qmaWitnessPrefix, qmaWitnessBasis, i.isLt] + +theorem qmaWitnessBasis_injective (c : QMACircuit) (hc : c.WellFormed) : + Function.Injective (qmaWitnessBasis c) := + Function.LeftInverse.injective (qmaWitnessPrefix_basis c hc) + +theorem qmaWitnessBasis_prefix (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis (c.work + 1)) + (hs : ∀ i : Fin (c.work + 1), c.witness ≤ i.val → s i = 0) : + qmaWitnessBasis c (qmaWitnessPrefix c hc s) = s := by + funext i + by_cases hi : i.val < c.witness + · simp [qmaWitnessBasis, qmaWitnessPrefix, hi] + · simp [qmaWitnessBasis, hi, hs i (Nat.le_of_not_gt hi)] + +/-- The initial-state definition is the concrete coordinate inclusion of the +witness subspace, and therefore applies to arbitrary entangled witnesses. -/ +theorem qmaInitialState_eq_inclusion (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + WithLp.toLp 2 (qmaInitialState c hc psi) = coordinateInclusion (qmaWitnessBasis c) psi := by + classical + ext s + by_cases hs : ∀ i : Fin (c.work + 1), c.witness ≤ i.val → s i = 0 + · have heq := qmaWitnessBasis_prefix c hc s hs + rw [← heq, coordinateInclusion_apply_image _ (qmaWitnessBasis_injective c hc)] + change qmaInitialState c hc psi (qmaWitnessBasis c (qmaWitnessPrefix c hc s)) = + psi (qmaWitnessPrefix c hc s) + rw [heq, qmaInitialState, ite_eq_left hs] + rfl + · rw [coordinateInclusion_apply_outside] + · simp [qmaInitialState, hs] + · intro a ha + apply hs + intro i hi + rw [← ha] + simp [qmaWitnessBasis, Nat.not_lt.mpr hi] + +theorem qmaInitialState_norm (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + ‖WithLp.toLp 2 (qmaInitialState c hc psi)‖ = ‖psi‖ := by + rw [qmaInitialState_eq_inclusion] + exact coordinateInclusion_norm_map _ (qmaWitnessBasis_injective c hc) psi + +/-- The complete output distribution has exactly the witness norm squared. -/ +theorem qmaOutput_total (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + (∑ s, Complex.normSq ((qmaCircuitMatrix c).mulVec (qmaInitialState c hc psi) s)) = + ‖psi‖ ^ 2 := by + let initial : EuclideanSpace ℂ (SourceSpinBasis (c.work + 1)) := + WithLp.toLp 2 (qmaInitialState c hc psi) + have hnorm := qmaCircuit_preserves_norm c hc initial + rw [qmaInitialState_norm c hc psi] at hnorm + rw [← hnorm, EuclideanSpace.norm_sq_eq] + apply Finset.sum_congr rfl + intro s _ + rw [Complex.normSq_eq_norm_sq] + rfl + +theorem qmaAcceptance_nonneg (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + 0 ≤ qmaAcceptance c hc psi := by + unfold qmaAcceptance + apply Finset.sum_nonneg + intro s _ + split_ifs + · exact Complex.normSq_nonneg _ + · exact le_rfl + +theorem qmaAcceptance_le_norm_sq (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaAcceptance c hc psi ≤ ‖psi‖ ^ 2 := by + rw [← qmaOutput_total c hc psi] + apply Finset.sum_le_sum + intro s _ + split_ifs + · exact le_rfl + · exact Complex.normSq_nonneg _ + +/-- A normalized witness produces an actual probability in the unit interval. -/ +theorem qmaAcceptance_mem_unitInterval (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) : + qmaAcceptance c hc psi ∈ Set.Icc (0 : ℝ) 1 := by + refine ⟨qmaAcceptance_nonneg c hc psi, ?_⟩ + simpa only [hpsi, one_pow] using qmaAcceptance_le_norm_sq c hc psi + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentCnot.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentCnot.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fc2bbbb4a151d15d1da25a7ff97ec81b31baf02 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentCnot.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSwapConjugation + +namespace OAI + +/-! A linear-size adjacent-CNOT program for one arbitrarily separated CNOT. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Classical + +def qmaAdjacentCnot (work : ℕ) : (a d : ℕ) → a+d+1 < work+1 → Bool → List QMAGate + | a,0,_,forward => [qmaOrderedCnot a (a+1) forward] + | a,d+1,h,forward => + qmaWireSwapGates (⟨a,by omega⟩ : Fin (work+1)) ⟨a+1,by omega⟩ ++ + qmaAdjacentCnot work (a+1) d (by omega) forward ++ + qmaWireSwapGates (⟨a,by omega⟩ : Fin (work+1)) ⟨a+1,by omega⟩ + +theorem qmaAdjacentCnot_length (work a d : ℕ) (h : a+d+1 < work+1) (b : Bool) : + (qmaAdjacentCnot work a d h b).length = 6*d+1 := by + induction d generalizing a with + | zero => rfl + | succ d ih => simp [qmaAdjacentCnot,qmaWireSwapGates,ih]; omega + +theorem qmaAdjacentCnot_matrix (work a d : ℕ) (h : a+d+1 < work+1) (b : Bool) : + qmaGateProduct work (qmaAdjacentCnot work a d h b) = + qmaGateMatrix work (qmaOrderedCnot a (a+d+1) b) := by + induction d generalizing a with + | zero => exact qmaGateProduct_singleton _ _ + | succ d ih => + let i : Fin (work+1) := ⟨a,by omega⟩ + let j : Fin (work+1) := ⟨a+1,by omega⟩ + let k : Fin (work+1) := ⟨a+(d+1)+1,h⟩ + have hij : i ≠ j := by intro he; have := congrArg Fin.val he; simp [i,j] at this + have hki : k ≠ i := by intro he; have := congrArg Fin.val he; dsimp [k,i] at this; omega + have hkj : k ≠ j := by intro he; have := congrArg Fin.val he; dsimp [k,j] at this; omega + simp only [qmaAdjacentCnot,qmaGateProduct_append,ih] + rw [←mul_assoc] + have he : a+1+d+1 = k.val := by dsimp [k]; omega + rw [he] + exact (qmaWireSwap_conjugate i j hij (qmaOrderedCnot j.val k.val b)).trans + (congrArg (qmaGateMatrix work) (qmaSwap_relabels_ordered i j k hki hkj b)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfad706834d616f11b578a749842d523d7da3b1e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAdjacentProgram.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateCode +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawFamilyProgram + +namespace OAI + +/-! The recursive adjacent-CNOT construction is a literal finite prefix, +one central gate, and its reversed prefix. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCircuitCode +open ExactQuantumFactoring.BitStackProgram + +def swapPrefix (a d : ℕ) : List QMAGate := + ((List.range d).map (fun k => swapList (a+k))).flatten + +theorem swapPrefix_succ (a d : ℕ) : + swapPrefix a (d+1)=swapList a++swapPrefix (a+1) d := by + have hf : (fun k => swapList (a+Nat.succ k))=(fun k => swapList (a+1+k)) := by + funext k + congr 1 + omega + simp only [swapPrefix,List.range_succ_eq_map,List.map_cons,List.flatten_cons, + Nat.add_zero,List.map_map,Function.comp_def] + rw [hf] + +def adjacentList (a d : ℕ) (b : Bool) : List QMAGate := + swapPrefix a d++[qmaOrderedCnot (a+d) (a+d+1) b]++(swapPrefix a d).reverse + +theorem adjacentList_eq (work a d : ℕ) (h : a+d+1 < work+1) (b : Bool) : + qmaAdjacentCnot work a d h b=adjacentList a d b := by + induction d generalizing a with + | zero => rfl + | succ d ih => + change swapList a++qmaAdjacentCnot work (a+1) d _ b++swapList a=adjacentList a (d+1) b + rw [ih] + unfold adjacentList + rw [swapPrefix_succ,List.reverse_append,swapList_reverse] + have ha : a+1+d=a+(d+1) := by omega + rw [ha] + simp only [List.append_assoc] + +noncomputable def swapPrefixProgram : + Procedure (prodCode unaryCode Nat.bits) (listCode gateCode) + (fun x => swapPrefix x.2 x.1) := by + let k := Procedure.unaryToBits.comp (Procedure.first unaryCode Nat.bits) + let a := Procedure.second unaryCode Nat.bits + let step := swapListProgram.comp (Procedure.binaryAdd.comp (a.pair k)) + let table := Procedure.tabulate (f := fun a k => swapList (a+k)) [] step + exact ((QuantumRawExchange.flattenProgram gateCode (.hadamard 0)).comp table).congrFun + (by intro x; rfl) + +noncomputable def orderedCnotProgram : + Procedure (prodCode (prodCode Nat.bits Nat.bits) Procedure.boolCode) gateCode + (fun x => qmaOrderedCnot x.1.1 x.1.2 x.2) := by + let p := Procedure.first (prodCode Nat.bits Nat.bits) Procedure.boolCode + let b := Procedure.second (prodCode Nat.bits Nat.bits) Procedure.boolCode + let forward := cnotProgram.comp p + let backward := cnotProgram.comp + (((Procedure.second Nat.bits Nat.bits).comp p).pair + ((Procedure.first Nat.bits Nat.bits).comp p)) + exact (Procedure.conditional b forward backward).congrFun (by intro x; rfl) + +abbrev AdjacentInput := ℕ × (ℕ × Bool) +def adjacentInputCode : AdjacentInput → List Bool := + prodCode unaryCode (prodCode Nat.bits Procedure.boolCode) + +noncomputable def adjacentProgram : + Procedure adjacentInputCode (listCode gateCode) + (fun x => adjacentList x.2.1 x.1 x.2.2) := by + let d := Procedure.first unaryCode (prodCode Nat.bits Procedure.boolCode) + let ab := Procedure.second unaryCode (prodCode Nat.bits Procedure.boolCode) + let a := (Procedure.first Nat.bits Procedure.boolCode).comp ab + let b := (Procedure.second Nat.bits Procedure.boolCode).comp ab + let p := swapPrefixProgram.comp (d.pair a) + let left := Procedure.binaryAdd.comp (a.pair (Procedure.unaryToBits.comp d)) + let right := Procedure.successor.comp left + let center := orderedCnotProgram.comp ((left.pair right).pair b) + let singleton := (Procedure.listCons gateCode).comp + (center.pair (Procedure.constant adjacentInputCode (listCode gateCode) [])) + let first := (Procedure.listAppend gateCode (.hadamard 0)).comp (p.pair singleton) + exact (Procedure.listAppend gateCode (.hadamard 0)).comp + (first.pair ((Procedure.listReverse gateCode (.hadamard 0)).comp p)) + +end ContinuumCoulomb.QuantumCircuitCode + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHeight.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..2088bad3cfbf091f5ea154013c1f935287d49439 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHeight.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicScalar + +namespace OAI + +/-! Rational coefficient-height bounds for the fixed history expressions. +These bounds provide a polynomial precision budget before real evaluation. -/ + +namespace ContinuumCoulomb.QuantumAlgebraicScalar +open scoped BigOperators + +def realHeight (x : RealScalar) : ℚ := |x.1|+|x.2| +def height (x : Scalar) : ℚ := realHeight x.1+realHeight x.2 + +theorem realHeight_nonnegative (x : RealScalar) : 0 ≤ realHeight x := + add_nonneg (abs_nonneg _) (abs_nonneg _) + +theorem height_nonnegative (x : Scalar) : 0 ≤ height x := + add_nonneg (realHeight_nonnegative _) (realHeight_nonnegative _) + +@[simp] theorem realHeight_rat (a : ℚ) : realHeight (realRat a) = |a| := by + simp [realHeight,realRat] + +@[simp] theorem realHeight_neg (x : RealScalar) : realHeight (realNeg x) = realHeight x := by + simp [realHeight,realNeg] + +theorem realHeight_add (x y : RealScalar) : + realHeight (realAdd x y) ≤ realHeight x+realHeight y := by + have ha := abs_add_le x.1 y.1 + have hb := abs_add_le x.2 y.2 + dsimp only [realHeight,realAdd] + linarith + +theorem realHeight_sub (x y : RealScalar) : + realHeight (realSub x y) ≤ realHeight x+realHeight y := by + simpa only [realSub,realHeight_neg] using realHeight_add x (realNeg y) + +theorem realHeight_mul (x y : RealScalar) : + realHeight (realMul x y) ≤ realHeight x*realHeight y := by + have ha := abs_add_le (x.1*y.1) (x.2*y.2/2) + have hb := abs_add_le (x.1*y.2) (x.2*y.1) + norm_num only [abs_mul,abs_div,abs_of_pos (by norm_num : (0:ℚ) < 2)] at ha hb + dsimp only [realHeight,realMul] + nlinarith [mul_nonneg (abs_nonneg x.2) (abs_nonneg y.2)] + +@[simp] theorem height_rat (a : ℚ) : height (rat a) = |a| := by + simp [height,rat] + +@[simp] theorem height_neg (x : Scalar) : height (neg x) = height x := by + simp [height,neg] + +theorem height_add (x y : Scalar) : height (add x y) ≤ height x+height y := by + have ha := realHeight_add x.1 y.1 + have hb := realHeight_add x.2 y.2 + dsimp only [height,add] + linarith + +theorem height_sub (x y : Scalar) : height (sub x y) ≤ height x+height y := by + simpa only [sub,height_neg] using height_add x (neg y) + +theorem height_mul (x y : Scalar) : height (mul x y) ≤ height x*height y := by + have hr := realHeight_sub (realMul x.1 y.1) (realMul x.2 y.2) + have hi := realHeight_add (realMul x.1 y.2) (realMul x.2 y.1) + have hrr := realHeight_mul x.1 y.1 + have hii := realHeight_mul x.2 y.2 + have hri := realHeight_mul x.1 y.2 + have hir := realHeight_mul x.2 y.1 + dsimp only [height,mul] + nlinarith + +@[simp] theorem height_conj (x : Scalar) : height (conj x) = height x := by + simp [height,conj] + +@[simp] theorem height_sqrtHalf : height sqrtHalf = 1 := by + norm_num [height,realHeight,sqrtHalf] + +@[simp] theorem height_imaginary : height imaginary = 1 := by + norm_num [height,realHeight,imaginary] + +theorem height_realPart (x : Scalar) : height (realPart x) ≤ height x := by + simp only [height,realPart,realHeight_rat,abs_zero,add_zero] + exact le_add_of_nonneg_right (realHeight_nonnegative _) + +theorem height_imagPart (x : Scalar) : height (imagPart x) ≤ height x := by + simp only [height,imagPart,realHeight_rat,abs_zero,add_zero] + exact le_add_of_nonneg_left (realHeight_nonnegative _) + +theorem height_sum (xs : List Scalar) : height (sum xs) ≤ (xs.map height).sum := by + induction xs with + | nil => simp [sum] + | cons x xs ih => + change height (add x (sum xs)) ≤ height x+(xs.map height).sum + exact (height_add x (sum xs)).trans (add_le_add (le_refl (height x)) ih) + +theorem height_product (xs : List Scalar) : height (product xs) ≤ (xs.map height).prod := by + induction xs with + | nil => simp [product] + | cons x xs ih => + change height (mul x (product xs)) ≤ height x*(xs.map height).prod + exact (height_mul x (product xs)).trans + (mul_le_mul_of_nonneg_left ih (height_nonnegative x)) + +theorem sample_error_height (k : ℕ) (x : RealScalar) : + |(sample k x:ℝ)-realValue x| ≤ (realHeight x:ℝ)*(2:ℝ)⁻¹^k := by + apply (sample_error k x).trans + apply mul_le_mul_of_nonneg_right _ (by positivity) + have h : |x.2| ≤ realHeight x := le_add_of_nonneg_left (abs_nonneg _) + exact_mod_cast h + +end ContinuumCoulomb.QuantumAlgebraicScalar + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHistory.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..6836bfebd84dd1571c7919265195ded78cebaf89 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicHistory.lean @@ -0,0 +1,159 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFixedPauli +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedModel + +namespace OAI + +/-! Actual ordered history cores have exact four-rational entries. The +propagation Gram is formed on its at-most-five-site core; the construction +does not sum over spectator configurations. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open QuantumAlgebraicScalar QuantumFixedPauli Matrix +open scoped BigOperators Classical + +def denote {α β : Type} (A : Matrix α β Scalar) : Matrix α β ℂ := + fun s t => value (A s t) + +def matMul {α β γ : Type} [Fintype β] + (A : Matrix α β Scalar) (B : Matrix β γ Scalar) : Matrix α γ Scalar := + fun s t => finiteSum (fun u => mul (A s u) (B u t)) + +def adjoint {α β : Type} (A : Matrix α β Scalar) : Matrix β α Scalar := + fun s t => conj (A t s) + +theorem denote_mul {α β γ : Type} [Fintype β] + (A : Matrix α β Scalar) (B : Matrix β γ Scalar) : + denote (matMul A B) = denote A * denote B := by + ext s t + simp only [denote,matMul,value_finiteSum,value_mul,Matrix.mul_apply] + +theorem denote_adjoint {α β : Type} (A : Matrix α β Scalar) : + denote (adjoint A) = (denote A).conjTranspose := by + ext s t + simp only [denote,adjoint,value_conj,Matrix.conjTranspose_apply] + +def hadamard (s t : Fin 2) : Scalar := + mul sqrtHalf (rat (if s = 1 ∧ t = 1 then -1 else 1)) + +def phaseT (s t : Fin 2) : Scalar := + if s = t then (if s = 0 then rat 1 else mul sqrtHalf (add (rat 1) imaginary)) else rat 0 + +theorem value_hadamard (s t : Fin 2) : value (hadamard s t) = qmaHadamard s t := by + fin_cases s <;> fin_cases t <;> simp [hadamard,qmaHadamard] + +theorem value_phaseT (s t : Fin 2) : value (phaseT s t) = qmaPhaseT s t := by + fin_cases s <;> fin_cases t <;> simp [phaseT,qmaPhaseT] + +def identity {α : Type} [DecidableEq α] (s t : α) : Scalar := rat (if s = t then 1 else 0) + +theorem value_identity {α : Type} [DecidableEq α] (s t : α) : + value (identity s t) = (1 : Matrix α α ℂ) s t := by + by_cases h : s = t <;> simp [identity,Matrix.one_apply,h] + +def gate (work : ℕ) (g : QMAGate) (s t : SourceSpinBasis (work+1)) : Scalar := + match g with + | .hadamard i => finiteProduct (fun k => + if k = qmaQubit work i then hadamard (s k) (t k) else identity (s k) (t k)) + | .phaseT i => finiteProduct (fun k => + if k = qmaQubit work i then phaseT (s k) (t k) else identity (s k) (t k)) + | .controlledNot i j => rat + (if s = qmaControlledNot work (qmaQubit work i) (qmaQubit work j) t then 1 else 0) + +theorem value_gate (work : ℕ) (g : QMAGate) (s t : SourceSpinBasis (work+1)) : + value (gate work g s t) = qmaGateMatrix work g s t := by + cases g with + | hadamard i => + rw [gate,value_finiteProduct] + unfold qmaGateMatrix sourceTensor + apply Finset.prod_congr rfl + intro k _ + by_cases h : k = qmaQubit work i + · simp only [h,ite_true,value_hadamard] + · simp only [h,ite_false,value_identity] + | phaseT i => + rw [gate,value_finiteProduct] + unfold qmaGateMatrix sourceTensor + apply Finset.prod_congr rfl + intro k _ + by_cases h : k = qmaQubit work i + · simp only [h,ite_true,value_phaseT] + · simp only [h,ite_false,value_identity] + | controlledNot i j => + by_cases h : s = qmaControlledNot work (qmaQubit work i) (qmaQubit work j) t + <;> simp [gate,qmaGateMatrix,h] + +def delta (c : QMACircuit) (t : Fin c.gates.length) + (s r : QMACircuitQubit c → Fin 2) : Scalar := + if QMAClockGuard c.gates.length t (s ∘ Sum.inl) ∧ + s (Sum.inl (qmaClockMiddle c.gates.length t)) = 0 then + sub (identity s (qmaBitFlip (Sum.inl (qmaClockMiddle c.gates.length t)) r)) + (mul (identity (s ∘ Sum.inl) (r ∘ Sum.inl)) + (gate c.work (c.gates.getD t.val (.hadamard 0)) (s ∘ Sum.inr) (r ∘ Sum.inr))) + else rat 0 + +theorem value_delta (c : QMACircuit) (t : Fin c.gates.length) + (s r : QMACircuitQubit c → Fin 2) : + value (delta c t s r) = qmaLocalPropagationDelta c t s r := by + rw [qmaLocalPropagationDelta,qmaGuardProjection,Matrix.diagonal_mul] + by_cases h : QMAClockGuard c.gates.length t (s ∘ Sum.inl) ∧ + s (Sum.inl (qmaClockMiddle c.gates.length t)) = 0 + · simp [delta,h,Matrix.sub_apply,qmaBitFlipMatrix,qmaJoinMatrix, + Matrix.submatrix_apply,Matrix.kroneckerMap_apply,Matrix.one_apply,qmaStepMatrix, + value_identity,value_gate] + rfl + · simp [delta,h] + +def deltaCore (c : QMACircuit) (t : Fin c.gates.length) : + Matrix (QMASupportBasis (qmaPropagationSites c t)) + (QMASupportBasis (qmaPropagationSites c t)) Scalar := + fun s r => delta c t (qmaSupportExtend _ s) (qmaSupportExtend _ r) + +theorem denote_deltaCore (c : QMACircuit) (t : Fin c.gates.length) : + denote (deltaCore c t) = qmaLocalCore (qmaPropagationSites c t) + (qmaLocalPropagationDelta c t) := by + ext s r + exact value_delta c t _ _ + +theorem core_mul {ι : Type} [Fintype ι] [DecidableEq ι] + {S : Finset ι} {A B : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) (hB : QMALocalOn S B) : + qmaLocalCore S (A*B) = qmaLocalCore S A*qmaLocalCore S B := by + obtain ⟨A,rfl⟩ := hA + obtain ⟨B,rfl⟩ := hB + rw [← qmaLocalLift_mul,qmaLocalCore_lift,qmaLocalCore_lift,qmaLocalCore_lift] + +theorem core_adjoint {ι : Type} [Fintype ι] [DecidableEq ι] + {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) : + qmaLocalCore S A.conjTranspose = (qmaLocalCore S A).conjTranspose := by + obtain ⟨A,rfl⟩ := hA + rw [← qmaLocalLift_adjoint,qmaLocalCore_lift,qmaLocalCore_lift] + +def propagationCore (c : QMACircuit) (t : Fin c.gates.length) := + matMul (adjoint (deltaCore c t)) (deltaCore c t) + +theorem denote_propagationCore (c : QMACircuit) (t : Fin c.gates.length) : + denote (propagationCore c t) = qmaLocalCore (qmaPropagationSites c t) + ((qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t) := by + rw [propagationCore,denote_mul,denote_adjoint,denote_deltaCore, + core_mul (qmaLocalPropagationDelta_local c t).adjoint (qmaLocalPropagationDelta_local c t), + core_adjoint (qmaLocalPropagationDelta_local c t)] + +def lift {ι : Type} [Fintype ι] [DecidableEq ι] (S : Finset ι) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) Scalar) + (s t : ι → Fin 2) : Scalar := + mul (A (fun i => s i.val) (fun i => t i.val)) + (identity (fun i : {i // i ∉ S} => s i.val) (fun i => t i.val)) + +theorem denote_lift {ι : Type} [Fintype ι] [DecidableEq ι] (S : Finset ι) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) Scalar) : + denote (lift S A) = qmaLocalLift S (denote A) := by + ext s t + simp only [denote,lift,value_mul,value_identity,Matrix.one_apply,qmaLocalLift_apply] + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalar.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalar.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c4d3e132f1b04b01da83f199c460bee797c42a4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalar.lean @@ -0,0 +1,131 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliBasis +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot + +namespace OAI + +/-! Exact scalar arithmetic for the H,T,CNOT history compiler. A real +scalar is a+b/sqrt(2); a complex scalar consists of two such pairs. The +representation is rational data throughout, including multiplication. -/ + +namespace ContinuumCoulomb.QuantumAlgebraicScalar + +abbrev RealScalar := ℚ × ℚ +abbrev Scalar := RealScalar × RealScalar + +def realRat (a : ℚ) : RealScalar := (a,0) +def realAdd (x y : RealScalar) : RealScalar := (x.1+y.1,x.2+y.2) +def realNeg (x : RealScalar) : RealScalar := (-x.1,-x.2) +def realSub (x y : RealScalar) : RealScalar := realAdd x (realNeg y) +def realMul (x y : RealScalar) : RealScalar := + (x.1*y.1+x.2*y.2/2,x.1*y.2+x.2*y.1) +def rat (a : ℚ) : Scalar := (realRat a,realRat 0) +def add (x y : Scalar) : Scalar := (realAdd x.1 y.1,realAdd x.2 y.2) +def neg (x : Scalar) : Scalar := (realNeg x.1,realNeg x.2) +def sub (x y : Scalar) : Scalar := add x (neg y) +def mul (x y : Scalar) : Scalar := + (realSub (realMul x.1 y.1) (realMul x.2 y.2), + realAdd (realMul x.1 y.2) (realMul x.2 y.1)) +def conj (x : Scalar) : Scalar := (x.1,realNeg x.2) +def sqrtHalf : Scalar := ((0,1),(0,0)) +def imaginary : Scalar := ((0,0),(1,0)) +def realPart (x : Scalar) : Scalar := (x.1,realRat 0) +def imagPart (x : Scalar) : Scalar := (x.2,realRat 0) + +noncomputable def realValue (x : RealScalar) : ℝ := + (x.1:ℝ)+(x.2:ℝ)*Real.sqrt (1/2:ℝ) +noncomputable def value (x : Scalar) : ℂ := + (realValue x.1:ℂ)+(realValue x.2:ℂ)*Complex.I + +@[simp] theorem realValue_rat (a : ℚ) : realValue (realRat a) = (a:ℝ) := by + simp [realValue,realRat] + +@[simp] theorem realValue_add (x y : RealScalar) : + realValue (realAdd x y) = realValue x+realValue y := by + simp only [realValue,realAdd,Rat.cast_add] + ring + +@[simp] theorem realValue_neg (x : RealScalar) : realValue (realNeg x) = -realValue x := by + simp only [realValue,realNeg,Rat.cast_neg] + ring + +@[simp] theorem realValue_sub (x y : RealScalar) : + realValue (realSub x y) = realValue x-realValue y := by + simp [realSub,sub_eq_add_neg] + +@[simp] theorem realValue_mul (x y : RealScalar) : + realValue (realMul x y) = realValue x*realValue y := by + have hs := Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 1/2) + simp only [realValue,realMul,Rat.cast_add,Rat.cast_mul,Rat.cast_div,Rat.cast_ofNat] + linear_combination -(x.2:ℝ)*(y.2:ℝ)*hs + +@[simp] theorem value_re (x : Scalar) : (value x).re = realValue x.1 := by + simp [value] + +@[simp] theorem value_im (x : Scalar) : (value x).im = realValue x.2 := by + simp [value] + +@[simp] theorem value_rat (a : ℚ) : value (rat a) = (a:ℂ) := by + simp [value,rat] + +@[simp] theorem value_add (x y : Scalar) : value (add x y) = value x+value y := by + apply Complex.ext <;> simp [add] + +@[simp] theorem value_neg (x : Scalar) : value (neg x) = -value x := by + apply Complex.ext <;> simp [neg] + +@[simp] theorem value_sub (x y : Scalar) : value (sub x y) = value x-value y := by + simp [sub,sub_eq_add_neg] + +@[simp] theorem value_mul (x y : Scalar) : value (mul x y) = value x*value y := by + apply Complex.ext <;> simp [mul,Complex.mul_re,Complex.mul_im] + +@[simp] theorem value_conj (x : Scalar) : value (conj x) = star (value x) := by + apply Complex.ext <;> simp [conj] + +@[simp] theorem value_sqrtHalf : value sqrtHalf = bellScale := by + simp [value,sqrtHalf,realValue,bellScale] + +@[simp] theorem value_imaginary : value imaginary = Complex.I := by + simp [value,imaginary,realValue] + +@[simp] theorem value_realPart (x : Scalar) : value (realPart x) = ((value x).re:ℂ) := by + simp [value,realPart] + +@[simp] theorem value_imagPart (x : Scalar) : value (imagPart x) = ((value x).im:ℂ) := by + simp [value,imagPart] + +def sum : List Scalar → Scalar + | [] => rat 0 + | x::xs => add x (sum xs) + +def product : List Scalar → Scalar + | [] => rat 1 + | x::xs => mul x (product xs) + +@[simp] theorem value_sum (xs : List Scalar) : value (sum xs) = (xs.map value).sum := by + induction xs with + | nil => simp [sum] + | cons x xs ih => simp [sum,ih] + +@[simp] theorem value_product (xs : List Scalar) : value (product xs) = (xs.map value).prod := by + induction xs with + | nil => simp [product] + | cons x xs ih => simp [product,ih] + +def sample (k : ℕ) (x : RealScalar) : ℚ := + x.1+x.2*RationalSquareRoot.value (k,1/2) + +theorem sample_error (k : ℕ) (x : RealScalar) : + |(sample k x:ℝ)-realValue x| ≤ |(x.2:ℝ)| * (2:ℝ)⁻¹^k := by + have h := RationalSquareRoot.value_error k (q := 1/2) (by norm_num) + norm_num only [Rat.cast_div,Rat.cast_one,Rat.cast_ofNat] at h + have he : (sample k x:ℝ)-realValue x = + (x.2:ℝ)*((RationalSquareRoot.value (k,1/2):ℝ)-Real.sqrt (1/2:ℝ)) := by + simp only [sample,realValue,Rat.cast_add,Rat.cast_mul] + ring + rw [he,abs_mul] + simpa only [one_div] using mul_le_mul_of_nonneg_left h (abs_nonneg (x.2:ℝ)) + +end ContinuumCoulomb.QuantumAlgebraicScalar + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalarProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalarProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..aecd0ebb9c76fec80602675906545ef25e5207e6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAlgebraicScalarProgram.lean @@ -0,0 +1,138 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicScalar +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawProgram + +namespace OAI + +/-! Literal polynomial programs for the exact algebraic history scalars. +Each operation uses only rational arithmetic on four registers. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicScalar +open ExactQuantumFactoring.BitStackProgram + +def realCode : RealScalar → List Bool := prodCode ratCode ratCode +def scalarCode : Scalar → List Bool := prodCode realCode realCode + +noncomputable opaque realRatProgram : Procedure ratCode realCode realRat := + (Procedure.identity ratCode).pair (Procedure.constant ratCode ratCode 0) + +noncomputable opaque realAddProgram : Procedure (prodCode realCode realCode) realCode + (fun x => realAdd x.1 x.2) := by + let l := Procedure.first realCode realCode + let r := Procedure.second realCode realCode + let a := (Procedure.first ratCode ratCode).comp l + let b := (Procedure.second ratCode ratCode).comp l + let c := (Procedure.first ratCode ratCode).comp r + let d := (Procedure.second ratCode ratCode).comp r + exact (Procedure.ratAdd.comp (a.pair c)).pair (Procedure.ratAdd.comp (b.pair d)) + +noncomputable opaque realNegProgram : Procedure realCode realCode realNeg := + (Procedure.ratNeg.comp (Procedure.first ratCode ratCode)).pair + (Procedure.ratNeg.comp (Procedure.second ratCode ratCode)) + +noncomputable opaque realSubProgram : Procedure (prodCode realCode realCode) realCode + (fun x => realSub x.1 x.2) := + realAddProgram.comp ((Procedure.first realCode realCode).pair + (realNegProgram.comp (Procedure.second realCode realCode))) + +noncomputable opaque realMulProgram : Procedure (prodCode realCode realCode) realCode + (fun x => realMul x.1 x.2) := by + let l := Procedure.first realCode realCode + let r := Procedure.second realCode realCode + let a := (Procedure.first ratCode ratCode).comp l + let b := (Procedure.second ratCode ratCode).comp l + let c := (Procedure.first ratCode ratCode).comp r + let d := (Procedure.second ratCode ratCode).comp r + let ac := Procedure.ratMul.comp (a.pair c) + let bd := Procedure.ratMul.comp (b.pair d) + let ad := Procedure.ratMul.comp (a.pair d) + let bc := Procedure.ratMul.comp (b.pair c) + let half := Procedure.ratDiv.comp + (bd.pair (Procedure.constant (prodCode realCode realCode) ratCode 2)) + exact (Procedure.ratAdd.comp (ac.pair half)).pair (Procedure.ratAdd.comp (ad.pair bc)) + +noncomputable opaque ratProgram : Procedure ratCode scalarCode rat := + realRatProgram.pair (Procedure.constant ratCode realCode (realRat 0)) + +noncomputable opaque addProgram : Procedure (prodCode scalarCode scalarCode) scalarCode + (fun x => add x.1 x.2) := by + let l := Procedure.first scalarCode scalarCode + let r := Procedure.second scalarCode scalarCode + let re := Procedure.first realCode realCode + let im := Procedure.second realCode realCode + exact (realAddProgram.comp ((re.comp l).pair (re.comp r))).pair + (realAddProgram.comp ((im.comp l).pair (im.comp r))) + +noncomputable opaque negProgram : Procedure scalarCode scalarCode neg := + (realNegProgram.comp (Procedure.first realCode realCode)).pair + (realNegProgram.comp (Procedure.second realCode realCode)) + +noncomputable opaque subProgram : Procedure (prodCode scalarCode scalarCode) scalarCode + (fun x => sub x.1 x.2) := + addProgram.comp ((Procedure.first scalarCode scalarCode).pair + (negProgram.comp (Procedure.second scalarCode scalarCode))) + +noncomputable opaque mulProgram : Procedure (prodCode scalarCode scalarCode) scalarCode + (fun x => mul x.1 x.2) := by + let l := Procedure.first scalarCode scalarCode + let r := Procedure.second scalarCode scalarCode + let re := Procedure.first realCode realCode + let im := Procedure.second realCode realCode + let ac := realMulProgram.comp ((re.comp l).pair (re.comp r)) + let bd := realMulProgram.comp ((im.comp l).pair (im.comp r)) + let ad := realMulProgram.comp ((re.comp l).pair (im.comp r)) + let bc := realMulProgram.comp ((im.comp l).pair (re.comp r)) + exact (realSubProgram.comp (ac.pair bd)).pair (realAddProgram.comp (ad.pair bc)) + +noncomputable opaque conjProgram : Procedure scalarCode scalarCode conj := + (Procedure.first realCode realCode).pair + (realNegProgram.comp (Procedure.second realCode realCode)) + +noncomputable opaque realPartProgram : Procedure scalarCode scalarCode realPart := + (Procedure.first realCode realCode).pair (Procedure.constant scalarCode realCode (realRat 0)) + +noncomputable opaque imagPartProgram : Procedure scalarCode scalarCode imagPart := + (Procedure.second realCode realCode).pair (Procedure.constant scalarCode realCode (realRat 0)) + +/-- Finite sums used by a fixed local matrix are bounded-depth compositions. -/ +noncomputable def fixedSumProgram {α : Type} (ea : α → List Bool) (m : ℕ) + (f : Fin m → α → Scalar) (p : ∀ i, Procedure ea scalarCode (f i)) : + Procedure ea scalarCode (fun x => sum (List.ofFn (fun i => f i x))) := by + induction m with + | zero => exact (Procedure.constant ea scalarCode (rat 0)).congrFun (by intro x; rfl) + | succ m ih => + exact (addProgram.comp ((p 0).pair + (ih (fun i => f i.succ) (fun i => p i.succ)))).congrFun (by + intro x + simp only [List.ofFn_succ,sum,Function.comp_apply]) + +noncomputable def fixedProductProgram {α : Type} (ea : α → List Bool) (m : ℕ) + (f : Fin m → α → Scalar) (p : ∀ i, Procedure ea scalarCode (f i)) : + Procedure ea scalarCode (fun x => product (List.ofFn (fun i => f i x))) := by + induction m with + | zero => exact (Procedure.constant ea scalarCode (rat 1)).congrFun (by intro x; rfl) + | succ m ih => + exact (mulProgram.comp ((p 0).pair + (ih (fun i => f i.succ) (fun i => p i.succ)))).congrFun (by + intro x + simp only [List.ofFn_succ,product,Function.comp_apply]) + +def sampleCode : (ℕ × RealScalar) → List Bool := prodCode unaryCode realCode + +noncomputable opaque sampleProgram : Procedure sampleCode ratCode (fun x => sample x.1 x.2) := by + let k := Procedure.first unaryCode realCode + let x := Procedure.second unaryCode realCode + let a := (Procedure.first ratCode ratCode).comp x + let b := (Procedure.second ratCode ratCode).comp x + let root := RationalSquareRoot.program.comp + (k.pair (Procedure.constant sampleCode ratCode (1/2))) + exact Procedure.ratAdd.comp (a.pair (Procedure.ratMul.comp (b.pair root))) + +noncomputable def sampleCertificate : Turing.TM2ComputableInPolyTime sampleCode ratCode + (fun x => sample x.1 x.2) := sampleProgram.toTM2 + +end ContinuumCoulomb.QuantumAlgebraicScalar + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAnchorDensity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAnchorDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..327bdef7d2453268ec0476b21681f9a24ff1bbb7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAnchorDensity.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGraphDegree +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighbors + +namespace OAI + +/-! Bounded vertex density and degree bound the number of nearby edge anchors. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaNearVertexCard_bound {n rows width A : ℕ} (cell : Fin n → QMAGridCell rows width) + (hc : ∀ p, (Finset.univ.filter (fun v => cell v = p)).card ≤ A) (p : QMAGridCell rows width) : + (Finset.univ.filter (fun v => cell v ∈ qmaGridNeighbors p)).card ≤ 9*A := by + let fiber := fun q => Finset.univ.filter (fun v => cell v = q) + have heq : Finset.univ.filter (fun v => cell v ∈ qmaGridNeighbors p) = + (qmaGridNeighbors p).biUnion fiber := by + ext v + simp [fiber] + rw [heq] + calc + _ ≤ ∑ q ∈ qmaGridNeighbors p, (fiber q).card := Finset.card_biUnion_le + _ ≤ ∑ _q ∈ qmaGridNeighbors p, A := Finset.sum_le_sum (fun q _ => hc q) + _ = (qmaGridNeighbors p).card*A := by simp + _ ≤ 9*A := Nat.mul_le_mul_right A (qmaGridNeighbors_card p) + +theorem qmaLeftIncidence_le_degree {ν : Type*} [Fintype ν] {n : ℕ} + (left right : ν → Fin n) (v : Fin n) : + (Finset.univ.filter (fun e => left e = v)).card ≤ qmaGraphDegree left right v := by + have heq : (Finset.univ.filter (fun e => left e = v)).card = + (∑ e, if left e = v then 1 else 0 : ℕ) := by simp + rw [heq] + apply Finset.sum_le_sum + intro e _ + by_cases h : left e = v + · simp [h] + · simp [h] + +theorem qmaAnchor_density {ν : Type*} [Fintype ν] {n rows width A D : ℕ} + (left right : ν → Fin n) (cell : Fin n → QMAGridCell rows width) + (anchor : ν → QMAGridCell rows width) + (hnear : ∀ e, QMAGridCellsNear (cell (left e)) (anchor e)) + (hc : ∀ p, (Finset.univ.filter (fun v => cell v = p)).card ≤ A) + (hd : ∀ v, qmaGraphDegree left right v ≤ D) (p : QMAGridCell rows width) : + (Finset.univ.filter (fun e => anchor e = p)).card ≤ 9*A*D := by + let near := Finset.univ.filter (fun v => cell v ∈ qmaGridNeighbors p) + let fiber := fun v => Finset.univ.filter (fun e => left e = v) + have hsub : Finset.univ.filter (fun e => anchor e = p) ⊆ near.biUnion fiber := by + intro e he + have hp := (Finset.mem_filter.mp he).2 + apply Finset.mem_biUnion.mpr + refine ⟨left e,?_,?_⟩ + · apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _,(qmaGridNeighbors_mem p _).mpr ?_⟩ + simpa only [hp] using hnear e + · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,rfl⟩ + calc + _ ≤ (near.biUnion fiber).card := Finset.card_le_card hsub + _ ≤ ∑ v ∈ near, (fiber v).card := Finset.card_biUnion_le + _ ≤ ∑ _v ∈ near, D := Finset.sum_le_sum (fun v _ => + (qmaLeftIncidence_le_degree left right v).trans (hd v)) + _ = near.card*D := by simp + _ ≤ (9*A)*D := Nat.mul_le_mul_right D (qmaNearVertexCard_bound cell hc p) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncilla.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncilla.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe21674fcc5c17c699fc1de892c95477c636be6a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncilla.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvolution + +namespace OAI + +/-! Exact witness embedding into the zero-ancilla subspace. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +def QMAAncillaZero (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) : Prop := + ∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 + +def qmaWitnessRestrict (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis (c.work+1)) : SourceSpinBasis c.witness := + fun i => s ⟨i.val,lt_of_lt_of_le i.isLt (hc.1.trans (Nat.le_succ _))⟩ + +def qmaWitnessExtend (c : QMACircuit) (s : SourceSpinBasis c.witness) : + SourceSpinBasis (c.work+1) := + fun i => if h : i.val < c.witness then s ⟨i.val,h⟩ else 0 + +theorem qmaWitnessExtend_ancilla (c : QMACircuit) (s : SourceSpinBasis c.witness) : + QMAAncillaZero c (qmaWitnessExtend c s) := by + intro i hi + simp [qmaWitnessExtend,not_lt.mpr hi] + +theorem qmaWitnessRestrict_extend (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis c.witness) : + qmaWitnessRestrict c hc (qmaWitnessExtend c s) = s := by + funext i + simp [qmaWitnessRestrict,qmaWitnessExtend,i.isLt] + +theorem qmaWitnessExtend_restrict (c : QMACircuit) (hc : c.WellFormed) + (s : SourceSpinBasis (c.work+1)) (hs : QMAAncillaZero c s) : + qmaWitnessExtend c (qmaWitnessRestrict c hc s) = s := by + funext i + by_cases hi : i.val < c.witness + · simp [qmaWitnessExtend,qmaWitnessRestrict,hi] + · simp [qmaWitnessExtend,hi,hs i (Nat.le_of_not_gt hi)] + +def qmaZeroAncillaEquiv (c : QMACircuit) (hc : c.WellFormed) : + {s : SourceSpinBasis (c.work+1) // QMAAncillaZero c s} ≃ SourceSpinBasis c.witness where + toFun s := qmaWitnessRestrict c hc s.val + invFun s := ⟨qmaWitnessExtend c s,qmaWitnessExtend_ancilla c s⟩ + left_inv s := Subtype.ext (qmaWitnessExtend_restrict c hc s.val s.property) + right_inv := qmaWitnessRestrict_extend c hc + +theorem qmaInitialState_mass (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + sourceSpinMass (qmaInitialState c hc psi) = ‖psi‖^2 := by + classical + have he := (qmaZeroAncillaEquiv c hc).sum_comp (fun s => Complex.normSq (psi s)) + rw [EuclideanSpace.norm_sq_eq] + simp only [Complex.sq_norm] + rw [←he] + have hp (s : SourceSpinBasis (c.work+1)) : + Complex.normSq (qmaInitialState c hc psi s) = if QMAAncillaZero c s then + Complex.normSq (psi (qmaWitnessRestrict c hc s)) else 0 := by + by_cases hs : QMAAncillaZero c s + · have hs' : ∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 := hs + simp only [qmaInitialState,ite_eq_left hs',ite_eq_left hs] + rfl + · have hs' : ¬∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 := hs + simp only [qmaInitialState,ite_eq_right hs',ite_eq_right hs,Complex.normSq_zero] + unfold sourceSpinMass + simp_rw [hp] + have hsub := Finset.sum_subtype (F := inferInstance) (Finset.univ.filter (QMAAncillaZero c)) + (by simp : ∀ s, s ∈ Finset.univ.filter (QMAAncillaZero c) ↔ QMAAncillaZero c s) + (fun s => Complex.normSq (psi (qmaWitnessRestrict c hc s))) + rw [Finset.sum_filter] at hsub + exact hsub + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCompression.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCompression.lean new file mode 100644 index 0000000000000000000000000000000000000000..e40456be519ace3272d339bc5df3f242b61da0a3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCompression.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QubitMediatorAncilla + +namespace OAI + +/-! Exact vacuum-to-one-excitation columns and their compressions. +All matrices retain every original system coordinate. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical +variable {σ α κ : Type*} [Fintype σ] + [Fintype α] [DecidableEq α] [Fintype κ] [DecidableEq κ] + +def qmaSliceColumn (a : α) (A : Matrix σ σ ℂ) : Matrix (σ × α) σ ℂ := + fun p t => if p.2 = a then A p.1 t else 0 + +theorem qmaSliceColumn_gram (a b : α) (A B : Matrix σ σ ℂ) : + (qmaSliceColumn a A).conjTranspose*qmaSliceColumn b B = + if a = b then A.conjTranspose*B else 0 := by + ext s t + simp only [Matrix.mul_apply,Matrix.conjTranspose_apply,qmaSliceColumn, + Fintype.sum_prod_type] + by_cases hab : a = b + · subst b + simp [Matrix.mul_apply,Matrix.conjTranspose_apply] + · simp [hab,Ne.symm hab] + +theorem qmaSliceColumn_kronecker_apply (b : α) (D B : Matrix σ σ ℂ) + (P : Matrix α α ℂ) (s : σ) (a : α) (t : σ) : + ((D ⊗ₖ P)*qmaSliceColumn b B) (s,a) t = P a b*(D*B) s t := by + simp only [Matrix.mul_apply,Fintype.sum_prod_type,Matrix.kronecker_apply, + qmaSliceColumn,mul_ite,mul_zero] + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + ring + +theorem qmaSliceColumn_sandwich (a b : α) (A B D : Matrix σ σ ℂ) + (P : Matrix α α ℂ) : + (qmaSliceColumn a A).conjTranspose*(D ⊗ₖ P)*qmaSliceColumn b B = + P a b • (A.conjTranspose*D*B) := by + rw [Matrix.mul_assoc] + ext s t + change (∑ p : σ × α, star (qmaSliceColumn a A p s)* + ((D ⊗ₖ P)*qmaSliceColumn b B) p t) = P a b*((A.conjTranspose*D*B) s t) + rw [Fintype.sum_prod_type] + simp only [qmaSliceColumn_kronecker_apply,qmaSliceColumn] + simp only [apply_ite,star_zero,ite_mul,zero_mul,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rw [Matrix.mul_assoc,Matrix.mul_apply,Finset.mul_sum] + simp only [Matrix.conjTranspose_apply] + apply Finset.sum_congr rfl + intro u _ + ring + +def qmaAncillaColumn (V : κ → Matrix σ σ ℂ) : Matrix (σ × (κ → Fin 2)) σ ℂ := + ∑ e, qmaSliceColumn (qmaAncillaSingle e) (V e) + +theorem qmaAncillaColumn_gram (V W : κ → Matrix σ σ ℂ) : + (qmaAncillaColumn V).conjTranspose*qmaAncillaColumn W = ∑ e, (V e).conjTranspose*W e := by + simp only [qmaAncillaColumn,Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.mul_sum, + qmaSliceColumn_gram,qmaAncillaSingle_injective.eq_iff] + simp + +theorem qmaAncillaColumn_sandwich (V W : κ → Matrix σ σ ℂ) (D : Matrix σ σ ℂ) + (P : Matrix (κ → Fin 2) (κ → Fin 2) ℂ) : + (qmaAncillaColumn V).conjTranspose*(D ⊗ₖ P)*qmaAncillaColumn W = + ∑ e, ∑ f, P (qmaAncillaSingle e) (qmaAncillaSingle f) • + ((V e).conjTranspose*D*W f) := by + unfold qmaAncillaColumn + rw [Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.sum_mul] + apply Finset.sum_congr rfl + intro e _ + rw [Matrix.mul_sum] + apply Finset.sum_congr rfl + intro f _ + exact qmaSliceColumn_sandwich (qmaAncillaSingle e) (qmaAncillaSingle f) (V e) (W f) D P + +theorem qmaAncillaColumn_occupation (V W : κ → Matrix σ σ ℂ) + (D : Matrix σ σ ℂ) (e : κ) : + (qmaAncillaColumn V).conjTranspose*(D ⊗ₖ qmaAncillaOccupation e)*qmaAncillaColumn W = + (V e).conjTranspose*D*W e := by + rw [qmaAncillaColumn_sandwich] + simp only [qmaAncillaOccupation_single,ite_smul,one_smul,zero_smul] + simp only [ite_and] + simp + +theorem qmaAncillaColumn_flip (V W : κ → Matrix σ σ ℂ) (D : Matrix σ σ ℂ) (e : κ) : + (qmaAncillaColumn V).conjTranspose*(D ⊗ₖ qmaBitFlipMatrix e)*qmaAncillaColumn W = 0 := by + rw [qmaAncillaColumn_sandwich] + simp only [qmaBitFlipMatrix_single,zero_smul,Finset.sum_const_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCount.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9d070005747cfea3ba302cc42caed33c1cedfaa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAncillaCount.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySpectrum + +namespace OAI + +/-! Replace the joint ancilla penalty by a sum of individual qubit penalties. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaAncillaCount (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) : ℝ := + ∑ i : Fin (c.work+1), if c.witness ≤ i.val ∧ s i ≠ 0 then 1 else 0 + +theorem qmaAncillaCount_nonneg (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) : + 0 ≤ qmaAncillaCount c s := by + unfold qmaAncillaCount + positivity + +theorem qmaAncillaCount_zero (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) + (hs : QMAAncillaZero c s) : qmaAncillaCount c s = 0 := by + apply Finset.sum_eq_zero + intro i _ + have hi : ¬(c.witness ≤ i.val ∧ s i ≠ 0) := by + rintro ⟨hi,hne⟩ + exact hne (hs i hi) + simp [hi] + +theorem qmaAncillaCount_one_le (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) + (hs : ¬QMAAncillaZero c s) : 1 ≤ qmaAncillaCount c s := by + obtain ⟨i,hi,hne⟩ : ∃ i : Fin (c.work+1), c.witness ≤ i.val ∧ s i ≠ 0 := by + by_contra hn + apply hs + intro i hi + by_contra hne + exact hn ⟨i,hi,hne⟩ + have h := Finset.single_le_sum + (f := fun j : Fin (c.work+1) => if c.witness ≤ j.val ∧ s j ≠ 0 then (1:ℝ) else 0) + (s := Finset.univ) (a := i) (by intro j _; positivity) (Finset.mem_univ _) + simpa only [qmaAncillaCount,ite_eq_left (show c.witness ≤ i.val ∧ s i ≠ 0 from ⟨hi,hne⟩)] using h + +theorem qmaAncillaCount_le (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) : + qmaAncillaCount c s ≤ c.work+1 := by + calc + qmaAncillaCount c s ≤ ∑ _i : Fin (c.work+1), (1:ℝ) := by + apply Finset.sum_le_sum + intro i _ + split <;> norm_num + _ = _ := by simp + +theorem qmaAncillaCount_dominates (c : QMACircuit) (s : SourceSpinBasis (c.work+1)) : + (if QMAAncillaZero c s then (0:ℝ) else 1) ≤ qmaAncillaCount c s := by + by_cases hs : QMAAncillaZero c s + · simpa only [ite_eq_left hs] using qmaAncillaCount_nonneg c s + · simpa only [ite_eq_right hs] using qmaAncillaCount_one_le c s hs + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..3aec02233e095619c253f6c8d8fb7b28132c8a1b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSample.lean @@ -0,0 +1,139 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.RationalSquareRoot +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockCoefficientBounds + +namespace OAI + +/-! Rational sampling of the fixed algebraic constants in the four-spin encoding. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open scoped Classical + +def inverseScale (a : Fin 2) : ℝ := if a = 0 then Real.sqrt 3/384 else 3/4 + +theorem inverseScale_mul (a : Fin 2) : inverseScale a*qmaFourAxisScale a = 1 := by + have hs : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + fin_cases a + · dsimp [inverseScale,qmaFourAxisScale] + nlinarith + · norm_num [inverseScale,qmaFourAxisScale] + +theorem inverseScale_bounds (a : Fin 2) : 0 ≤ inverseScale a ∧ inverseScale a ≤ 1 := by + have hs := Real.sqrt_nonneg 3 + have hs2 : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + fin_cases a + · dsimp [inverseScale] + constructor <;> nlinarith + · norm_num [inverseScale] + +def value (k : ℕ) (a : Fin 2) : ℚ := + if a = 0 then RationalSquareRoot.value (k,3)/384 else 3/4 + +theorem root_nonneg (k : ℕ) (q : ℚ) : 0 ≤ RationalSquareRoot.value (k,q) := by + unfold RationalSquareRoot.value DyadicRootProgram.value + positivity + +theorem value_nonneg (k : ℕ) (a : Fin 2) : 0 ≤ value k a := by + unfold value + split_ifs + · exact div_nonneg (root_nonneg k 3) (by norm_num) + · norm_num + +theorem value_error (k : ℕ) (a : Fin 2) : + |(value k a:ℝ)-inverseScale a| ≤ (2:ℝ)⁻¹^k := by + have h := RationalSquareRoot.value_error k (by norm_num : (0:ℚ) ≤ 3) + have hd : 0 ≤ (2:ℝ)⁻¹^k := by positivity + norm_num only [Rat.cast_ofNat] at h + by_cases ha : a = 0 + · simp only [value,inverseScale,ha,ite_true,Rat.cast_div,Rat.cast_ofNat] + obtain ⟨hl,hu⟩ := abs_le.mp h + apply abs_le.mpr + constructor <;> linarith + · simp [value,inverseScale,ha] + +theorem value_bounds (k : ℕ) (a : Fin 2) : 0 ≤ (value k a:ℝ) ∧ (value k a:ℝ) ≤ 1 := by + have hn : (0:ℝ) ≤ value k a := by exact_mod_cast value_nonneg k a + refine ⟨hn,?_⟩ + have h := RationalSquareRoot.value_error k (by norm_num : (0:ℚ) ≤ 3) + have hd : (2:ℝ)⁻¹^k ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) + have hs := Real.sqrt_nonneg 3 + have hs2 : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + by_cases ha : a = 0 + · simp only [value,ha,ite_true,Rat.cast_div,Rat.cast_ofNat] + have hh := (abs_le.mp h).2 + norm_num only [Rat.cast_ofNat] at hh + nlinarith + · norm_num [value,ha] + +theorem product_error (k : ℕ) (a b : Fin 2) : + |(value k a:ℝ)*(value k b:ℝ)-inverseScale a*inverseScale b| ≤ 2*(2:ℝ)⁻¹^k := by + have hd : 0 ≤ (2:ℝ)⁻¹^k := by positivity + have ha := value_error k a + have hb := value_error k b + have hav : |inverseScale a| ≤ 1 := by rw [abs_of_nonneg (inverseScale_bounds a).1]; exact (inverseScale_bounds a).2 + have hbv : |(value k b:ℝ)| ≤ 1 := by rw [abs_of_nonneg (value_bounds k b).1]; exact (value_bounds k b).2 + calc + _ = |((value k a:ℝ)-inverseScale a)*(value k b:ℝ)+inverseScale a*((value k b:ℝ)-inverseScale b)| := by + congr 1 + ring + _ ≤ |((value k a:ℝ)-inverseScale a)*(value k b:ℝ)|+|inverseScale a*((value k b:ℝ)-inverseScale b)| := abs_add_le _ _ + _ = |(value k a:ℝ)-inverseScale a| * |(value k b:ℝ)|+ + |inverseScale a| * |(value k b:ℝ)-inverseScale b| := by rw [abs_mul,abs_mul] + _ ≤ (2:ℝ)⁻¹^k*1+1*(2:ℝ)⁻¹^k := add_le_add + (mul_le_mul ha hbv (abs_nonneg _) hd) (mul_le_mul hav hb (abs_nonneg _) (by norm_num)) + _ = _ := by ring + +def radicand (k : ℕ) (a b : Fin 2) (t : ℚ) : ℚ := (8/3)*|t| *value k a*value k b + +theorem radicand_nonneg (k : ℕ) (a b : Fin 2) (t : ℚ) : 0 ≤ radicand k a b t := by + unfold radicand + exact mul_nonneg (mul_nonneg (mul_nonneg (by norm_num) (abs_nonneg t)) (value_nonneg k a)) + (value_nonneg k b) + +theorem coupling_eq (a b : Fin 2) (t : ℝ) : + qmaFourCouplingSize a b t = Real.sqrt ((8/3)*|t| *inverseScale a*inverseScale b) := by + unfold qmaFourCouplingSize + congr 1 + have ha := inverseScale_mul a + have hb := inverseScale_mul b + have han := (qmaFourAxisScale_pos a).ne' + have hbn := (qmaFourAxisScale_pos b).ne' + apply (div_eq_iff (mul_ne_zero (mul_ne_zero (by norm_num) han) hbn)).mpr + calc + _ = 8*|t| *(inverseScale a*qmaFourAxisScale a)*(inverseScale b*qmaFourAxisScale b) := by rw [ha,hb]; ring + _ = _ := by ring + +theorem radicand_error (k : ℕ) (a b : Fin 2) (t : ℚ) : + |(radicand k a b t:ℝ)-(8/3)*|(t:ℝ)| *inverseScale a*inverseScale b| ≤ + (16/3)*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + simp only [radicand,Rat.cast_mul,Rat.cast_div,Rat.cast_ofNat,Rat.cast_abs] + calc + _ = |((8/3)*|(t:ℝ)|)*((value k a:ℝ)*(value k b:ℝ)-inverseScale a*inverseScale b)| := by + congr 1 + ring + _ = ((8/3)*|(t:ℝ)|)*|(value k a:ℝ)*(value k b:ℝ)-inverseScale a*inverseScale b| := by + rw [abs_mul,abs_of_nonneg (by positivity : 0 ≤ (8/3:ℝ)*|(t:ℝ)|)] + _ ≤ ((8/3)*|(t:ℝ)|)*(2*(2:ℝ)⁻¹^k) := + mul_le_mul_of_nonneg_left (product_error k a b) (by positivity) + _ = _ := by ring + +def coupling (k l : ℕ) (a b : Fin 2) (t : ℚ) : ℚ := + RationalSquareRoot.value (l,radicand k a b t) + +theorem coupling_error (k l : ℕ) (a b : Fin 2) (t : ℚ) : + |(coupling k l a b t:ℝ)-qmaFourCouplingSize a b (t:ℝ)| ≤ + (2:ℝ)⁻¹^l+Real.sqrt ((16/3)*|(t:ℝ)| *(2:ℝ)⁻¹^k) := by + have hr := RationalSquareRoot.value_error l (radicand_nonneg k a b t) + have hs := RationalSquareRoot.sqrt_perturbation + (show (0:ℝ) ≤ radicand k a b t by exact_mod_cast radicand_nonneg k a b t) + (show 0 ≤ (8/3)*|(t:ℝ)| *inverseScale a*inverseScale b from + mul_nonneg (mul_nonneg (mul_nonneg (by norm_num) (abs_nonneg _)) (inverseScale_bounds a).1) + (inverseScale_bounds b).1) + rw [coupling_eq] + exact (abs_sub_le _ _ _).trans (add_le_add hr (hs.trans (Real.sqrt_le_sqrt (radicand_error k a b t)))) + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..2aa8b4a7b1be813312476da7c93c99270470abfe --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleAccuracy.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSampleProgram + +namespace OAI + +/-! A linear precision schedule for the literal four-spin coupling sampler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample + +theorem calibrated_error (a b : Fin 2) (k : ℕ) (t : ℚ) : + |(calibrated a b (k,t):ℝ)-qmaFourCouplingSize a b (t:ℝ)| ≤ + 2*(1+|(t:ℝ)|)*(2:ℝ)⁻¹^k := by + have h := coupling_error (2*k+6) k a b t + have he : (2:ℝ)⁻¹^(2*k+6) = ((2:ℝ)⁻¹^k)^2/64 := by + rw [show 2*k+6=k*2+6 by omega,pow_add,pow_mul] + norm_num + ring + have heps : 0 ≤ (2:ℝ)⁻¹^k := by positivity + have hs : Real.sqrt ((16/3)*|(t:ℝ)| *(2:ℝ)⁻¹^(2*k+6)) ≤ + (1+|(t:ℝ)|)*(2:ℝ)⁻¹^k := by + apply Real.sqrt_le_iff.mpr + refine ⟨by positivity,?_⟩ + rw [he,mul_pow] + have hb : |(t:ℝ)|/12 ≤ (1+|(t:ℝ)|)^2 := by nlinarith [abs_nonneg (t:ℝ),sq_nonneg |(t:ℝ)|] + calc + _ = (|(t:ℝ)|/12)*((2:ℝ)⁻¹^k)^2 := by ring + _ ≤ (1+|(t:ℝ)|)^2*((2:ℝ)⁻¹^k)^2 := mul_le_mul_of_nonneg_right hb (sq_nonneg _) + change |(coupling (2*k+6) k a b t:ℝ)-qmaFourCouplingSize a b (t:ℝ)| ≤ _ + apply h.trans + have hp := mul_nonneg (abs_nonneg (t:ℝ)) heps + linarith + +theorem calibrated_nonneg (a b : Fin 2) (k : ℕ) (t : ℚ) : 0 ≤ calibrated a b (k,t) := + root_nonneg _ _ + +theorem calibrated_bound (a b : Fin 2) (k : ℕ) (t : ℚ) : + |(calibrated a b (k,t):ℝ)| ≤ 5*(1+|(t:ℝ)|) := by + have h := (abs_le.mp (calibrated_error a b k t)).2 + have hc := qmaFourCouplingSize_bound a b (t:ℝ) + have he : (2:ℝ)⁻¹^k ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) + have he' := mul_le_mul_of_nonneg_left he (by positivity : (0:ℝ) ≤ 2*(1+|(t:ℝ)|)) + have hp : (0:ℝ) ≤ calibrated a b (k,t) := by exact_mod_cast calibrated_nonneg a b k t + rw [abs_of_nonneg hp] + linarith + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e22d8d76b9d6afea6efceaea571bf99bf2cfeaad --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumAxisSampleProgram.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSample +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.MediatorProgram + +namespace OAI + +/-! Literal polynomial programs for the algebraic four-spin coupling samples. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque valueProgram (a : Fin 2) : Procedure unaryCode ratCode (fun k => value k a) := by + by_cases ha : a = 0 + · let root := RationalSquareRoot.program.comp + ((Procedure.identity unaryCode).pair (Procedure.constant unaryCode ratCode 3)) + exact (Procedure.ratMul.comp (root.pair (Procedure.constant unaryCode ratCode (1/384)))).congrFun + (by intro k; simp only [value,ha,ite_true,Function.comp_apply,id_eq]; ring) + · exact (Procedure.constant unaryCode ratCode (3/4)).congrFun (by intro k; simp only [value,ha,ite_false]) + +def radialCode : (ℕ × ℚ) → List Bool := prodCode unaryCode ratCode + +noncomputable opaque radicandProgram (a b : Fin 2) : + Procedure radialCode ratCode (fun x => radicand x.1 a b x.2) := by + let precision := Procedure.first unaryCode ratCode + let coefficient := Procedure.second unaryCode ratCode + let absolute := MediatorProgram.absoluteProgram.comp coefficient + let factor := Procedure.ratMul.comp ((Procedure.constant radialCode ratCode (8/3)).pair absolute) + let left := (valueProgram a).comp precision + let right := (valueProgram b).comp precision + exact (Procedure.ratMul.comp ((Procedure.ratMul.comp (factor.pair left)).pair right)).congrFun + (by intro x; rfl) + +def couplingCode : (ℕ × (ℕ × ℚ)) → List Bool := prodCode unaryCode (prodCode unaryCode ratCode) + +noncomputable opaque couplingProgram (a b : Fin 2) : Procedure couplingCode ratCode + (fun x => coupling x.1 x.2.1 a b x.2.2) := by + let inner := Procedure.first unaryCode (prodCode unaryCode ratCode) + let rest := Procedure.second unaryCode (prodCode unaryCode ratCode) + let outer := (Procedure.first unaryCode ratCode).comp rest + let coefficient := (Procedure.second unaryCode ratCode).comp rest + let argument := (radicandProgram a b).comp (inner.pair coefficient) + exact (RationalSquareRoot.program.comp (outer.pair argument)).congrFun (by intro x; rfl) + +noncomputable def couplingCertificate (a b : Fin 2) : Turing.TM2ComputableInPolyTime + couplingCode ratCode (fun x => coupling x.1 x.2.1 a b x.2.2) := + (couplingProgram a b).toTM2 + +def calibrated (a b : Fin 2) (x : ℕ × ℚ) : ℚ := coupling (2*x.1+6) x.1 a b x.2 + +noncomputable opaque inputPrecisionProgram : Procedure radialCode unaryCode Prod.fst := + Procedure.first unaryCode ratCode + +noncomputable opaque inputCoefficientProgram : Procedure radialCode ratCode Prod.snd := + Procedure.second unaryCode ratCode + +noncomputable opaque doubledPrecisionProgram : Procedure radialCode unaryCode (fun x => 2*x.1) := + Procedure.unaryMul.comp ((Procedure.constant radialCode unaryCode 2).pair inputPrecisionProgram) + +noncomputable opaque innerPrecisionProgram : Procedure radialCode unaryCode (fun x => 2*x.1+6) := + Procedure.unaryAdd.comp (doubledPrecisionProgram.pair (Procedure.constant radialCode unaryCode 6)) + +noncomputable opaque calibratedArgumentsProgram : Procedure radialCode couplingCode + (fun x => (2*x.1+6,x.1,x.2)) := + innerPrecisionProgram.pair (inputPrecisionProgram.pair inputCoefficientProgram) + +noncomputable opaque calibratedProgram (a b : Fin 2) : Procedure radialCode ratCode (calibrated a b) := + ((couplingProgram a b).comp calibratedArgumentsProgram).congrFun (by intro x; rfl) + +noncomputable def calibratedCertificate (a b : Fin 2) : Turing.TM2ComputableInPolyTime + radialCode ratCode (calibrated a b) := (calibratedProgram a b).toTM2 + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBitTransfer.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBitTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..59ec5f1ae0694c395b91dfea6add46573fec8d41 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBitTransfer.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.TM2Composition + +namespace OAI + +/-! Transfer a bit-coded word between the verifier machine and the Boolean +prefix tapes. Only the bit register is added to the finite control. -/ + +namespace ContinuumCoulomb.QuantumBitTransfer +open Turing +open MinUncutGames.Reduction.MachineTransfer + +variable {K Λ σ : Type} {Γ : K → Type} [DecidableEq K] + +def loop (src dst : K) (read : Γ src → Bool) (write : Bool → Γ dst) + (label : Λ) (exit : Option Λ) : TM2.Stmt Γ Λ (σ × Option Bool) := + .pop src (fun s h => (s.1,h.map read)) + (.branch (fun s => s.2.isSome) + (.push dst (fun s => write (s.2.getD false)) (.goto fun _ => label)) + (match exit with | none => .halt | some l => .goto fun _ => l)) + +private theorem update_src (src dst : K) (hne : src ≠ dst) + (base : ∀ k, List (Γ k)) (xs ys : List (Γ src)) (zs : List (Γ dst)) : + Function.update (tapesAt src dst base xs zs) src ys = tapesAt src dst base ys zs := by + funext k + by_cases hs : k=src + · subst k + simp [tapesAt,hne] + · by_cases hd : k=dst + · subst k + simp [tapesAt,Ne.symm hne] + · simp [tapesAt,hs,hd] + +private theorem update_dst (src dst : K) (base : ∀ k, List (Γ k)) + (xs : List (Γ src)) (ys zs : List (Γ dst)) : + Function.update (tapesAt src dst base xs ys) dst zs = tapesAt src dst base xs zs := by + funext k + by_cases h : k=dst + · subst k + simp [tapesAt] + · simp [tapesAt,h] + +theorem step_empty (src dst : K) (hne : src ≠ dst) + (read : Γ src → Bool) (write : Bool → Γ dst) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option Bool)) + (hl : program label=loop src dst read write label exit) + (base : ∀ k, List (Γ k)) (ys : List (Γ dst)) (state : σ) (r : Option Bool) : + TM2.step program ⟨some label,(state,r),tapesAt src dst base [] ys⟩= + some ⟨exit,(state,none),tapesAt src dst base [] ys⟩ := by + change some (TM2.stepAux (program label) _ _)=_ + rw [hl] + cases exit <;> simp [loop,TM2.stepAux,tapesAt_src,hne,update_src] + +theorem step_cons (src dst : K) (hne : src ≠ dst) + (read : Γ src → Bool) (write : Bool → Γ dst) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option Bool)) + (hl : program label=loop src dst read write label exit) + (base : ∀ k, List (Γ k)) (x : Γ src) (xs : List (Γ src)) (ys : List (Γ dst)) + (state : σ) (r : Option Bool) : + TM2.step program ⟨some label,(state,r),tapesAt src dst base (x::xs) ys⟩= + some ⟨some label,(state,some (read x)), + tapesAt src dst base xs (write (read x)::ys)⟩ := by + change some (TM2.stepAux (program label) _ _)=_ + rw [hl] + simp [loop,TM2.stepAux,tapesAt_src,tapesAt_dst,hne,update_src,update_dst] + +theorem transfer_steps (src dst : K) (hne : src ≠ dst) + (read : Γ src → Bool) (write : Bool → Γ dst) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option Bool)) + (hl : program label=loop src dst read write label exit) + (base : ∀ k, List (Γ k)) (xs : List (Γ src)) (ys : List (Γ dst)) + (state : σ) (r : Option Bool) : + (fun c => c.bind (TM2.step program))^[xs.length+1] + (some ⟨some label,(state,r),tapesAt src dst base xs ys⟩)= + some ⟨exit,(state,none), + tapesAt src dst base [] (xs.reverse.map (write ∘ read)++ys)⟩ := by + induction xs generalizing ys r with + | nil => + simpa only [List.length_nil,Nat.zero_add,Function.iterate_one,Option.bind_some, + List.reverse_nil,List.map_nil,List.nil_append] using + step_empty src dst hne read write label exit program hl base ys state r + | cons x xs ih => + rw [List.length_cons,Function.iterate_succ_apply] + change (fun c => c.bind (TM2.step program))^[xs.length+1] + (TM2.step program ⟨some label,(state,r),tapesAt src dst base (x::xs) ys⟩)=_ + rw [step_cons src dst hne read write label exit program hl,ih] + simp only [List.reverse_cons,List.map_append,List.map_singleton, + List.append_assoc,List.singleton_append,Function.comp_apply] + +def transfer (src dst : K) (hne : src ≠ dst) + (read : Γ src → Bool) (write : Bool → Γ dst) (label : Λ) (exit : Option Λ) + (program : Λ → TM2.Stmt Γ Λ (σ × Option Bool)) + (hl : program label=loop src dst read write label exit) + (base : ∀ k, List (Γ k)) (state : σ) (r : Option Bool) : + StateTransition.EvalsToInTime (TM2.step program) + ⟨some label,(state,r),base⟩ + (some ⟨exit,(state,none),tapesAt src dst base [] + ((base src).reverse.map (write ∘ read)++base dst)⟩) ((base src).length+1) where + steps := (base src).length+1 + evals_in_steps := by + change (fun c : Option (TM2.Cfg Γ Λ (σ × Option Bool)) => c.bind (TM2.step program))^[ + (base src).length+1] (some ⟨some label,(state,r),base⟩)=_ + simpa only [tapesAt_self] using + transfer_steps src dst hne read write label exit program hl base (base src) (base dst) state r + steps_le_m := le_rfl + +end ContinuumCoulomb.QuantumBitTransfer + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBasis.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..47f4bc5674e50cbe438e2b01c37bdde086ca1ddf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBasis.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFullFamily + +namespace OAI + +/-! The tensor code's physical coordinates are exactly ordinary groups of four qubits. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaBlockBasisEquiv (n : ℕ) : SourceSpinBasis (n*4) ≃ (Fin n → Fin 16) where + toFun s i := qmaFourBasisEquiv (fun p => s (finProdFinEquiv (i,p))) + invFun x k := qmaFourBasisEquiv.symm (x (finProdFinEquiv.symm k).1) (finProdFinEquiv.symm k).2 + left_inv s := by + funext k + obtain ⟨⟨i,p⟩,rfl⟩ := finProdFinEquiv.surjective k + simp only [Equiv.symm_apply_apply] + right_inv x := by + funext i + simp only [Equiv.symm_apply_apply,Equiv.apply_symm_apply] + +theorem qmaBlockBasisEquiv_symm_site (n : ℕ) (x : Fin n → Fin 16) (i : Fin n) (p : Fin 4) : + (qmaBlockBasisEquiv n).symm x (finProdFinEquiv (i,p)) = qmaFourBits (x i) p := by + change qmaFourBasisEquiv.symm (x (finProdFinEquiv.symm (finProdFinEquiv (i,p))).1) + (finProdFinEquiv.symm (finProdFinEquiv (i,p))).2 = _ + simp only [Equiv.symm_apply_apply] + rfl + +theorem qmaBlockTensor_source (n : ℕ) (A : Fin n → Fin 4 → Matrix (Fin 2) (Fin 2) ℂ) : + (sourceTensor (n*4) (fun k => A (finProdFinEquiv.symm k).1 (finProdFinEquiv.symm k).2)).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaTensorMatrix (fun i => (sourceTensor 4 (A i)).submatrix qmaFourBits qmaFourBits) := by + ext x y + change (∏ k : Fin (n*4), A (finProdFinEquiv.symm k).1 (finProdFinEquiv.symm k).2 + ((qmaBlockBasisEquiv n).symm x k) ((qmaBlockBasisEquiv n).symm y k)) = + ∏ i, ∏ p, A i p (qmaFourBits (x i) p) (qmaFourBits (y i) p) + rw [← finProdFinEquiv.prod_comp] + simp only [Equiv.symm_apply_apply,qmaBlockBasisEquiv_symm_site,Fintype.prod_prod_type] + +theorem qmaBlockPauli_source (n : ℕ) (i : Fin n) (p : Fin 4) (μ : Fin 3) : + (sourceLocalPauli (n*4) (finProdFinEquiv (i,p)) μ).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = qmaSiteMatrix i (qmaFourSpin p μ) := by + have hsource : sourceLocalPauli (n*4) (finProdFinEquiv (i,p)) μ = + sourceTensor (n*4) (fun k => if (finProdFinEquiv.symm k).1 = i then + (if (finProdFinEquiv.symm k).2 = p then pauli μ else 1) else 1) := by + unfold sourceLocalPauli + congr 1 + funext k + obtain ⟨⟨j,q⟩,rfl⟩ := finProdFinEquiv.surjective k + simp only [Equiv.symm_apply_apply,Equiv.apply_eq_iff_eq,Prod.mk.injEq] + by_cases hj : j = i <;> by_cases hq : q = p <;> simp [hj,hq] + rw [hsource,qmaBlockTensor_source n (fun j q => if j = i then (if q = p then pauli μ else 1) else 1),qmaSiteMatrix] + congr 1 + funext j + by_cases hj : j = i + · subst j + simp only [ite_true,qmaFourSpin_source,sourceLocalPauli] + · simp only [hj,ite_false,sourceTensor_one] + exact Matrix.submatrix_one_equiv qmaFourBasisEquiv.symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBudget.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..85a2e486c25a2b11176b54afddc7181c9b9cb765 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockBudget.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockCoefficientBounds + +namespace OAI + +/-! A rationally evaluable budget suffices for every physical simulator coefficient. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ : Type*} [Fintype κ] + +def qmaXZInputSize (J : κ → ℝ) : ℝ := Fintype.card κ+∑ e, |J e| + +def qmaXZPolynomialBudget (J : κ → ℝ) : ℝ := + 1+2000000*qmaXZInputSize J+(7056*qmaXZInputSize J)^2 + +theorem qmaXZBlockBudget_bound (t : κ → QMAXZTerm n) (J : κ → ℝ) : + qmaXZBlockBudget t J ≤ qmaXZPolynomialBudget J := by + let U := qmaXZInputSize J + have hU : 0 ≤ U := by dsimp [U,qmaXZInputSize]; positivity + have hs : (∑ e, |J e|) ≤ U := by + dsimp [U,qmaXZInputSize] + exact le_add_of_nonneg_left (Nat.cast_nonneg _) + have hp : (∑ e : QMAXZPairIndex t, (1+|J e.val|)) ≤ U := by + rw [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,mul_one] + have hc := Fintype.card_subtype_le (fun e => (t e).IsPair) + change Fintype.card (QMAXZPairIndex t) ≤ Fintype.card κ at hc + exact add_le_add (by exact_mod_cast hc) (qmaSum_subtype_abs_le (fun e => (t e).IsPair) J) + have hf := (qmaSum_subtype_abs_le (fun e => (t e).IsField) J).trans hs + have hc := (qmaXZFamilyConstant_bound t J).trans + (mul_le_mul_of_nonneg_left hs (by norm_num)) + have hpair0 : 0 ≤ ∑ e : QMAXZPairIndex t, (1+|J e.val|) := by positivity + have hsq := pow_le_pow_left₀ (mul_nonneg (by norm_num : (0:ℝ) ≤ 7056) hpair0) + (mul_le_mul_of_nonneg_left hp (by norm_num : (0:ℝ) ≤ 7056)) 2 + change 1+7056*(∑ e : QMAXZPairIndex t, (1+|J e.val|))+ + (1228800*(∑ e : QMAXZPairIndex t, (1+|J e.val|))+ + 7*(∑ e : QMAXZFieldIndex t, |J e.val|)+|qmaXZFamilyConstant t J|)+ + (7056*(∑ e : QMAXZPairIndex t, (1+|J e.val|)))^2 ≤ + 1+2000000*U+(7056*U)^2 + nlinarith + +variable {τ : Type*} [Fintype τ] + +theorem qmaFourTensorFull_accuracy_of_budget (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant B : ℝ) + (hbudget : qmaFourTensorFullBudget t weight constant ≤ B) (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix (9*B^3*N) + (((9*B^3*N:ℝ):ℂ) • qmaFourTensorFamilyCoupling left right a b t+ + qmaFourTensorFullCounterterm left right a b t site axis weight constant))- + MediatorGraph.normalizedBottom (qmaFourTensorFullTarget left right a b t site axis weight constant)| ≤ 1/(N:ℝ) := by + let V := qmaFourTensorFamilyCoupling left right a b t + let C := qmaFourTensorFullCounterterm left right a b t site axis weight constant + have hB := (qmaFourTensorFull_budget left right a b t site axis weight constant).trans hbudget + have hb := qmaFourTensorNormBudget_bounds V C + have hCs : C.conjTranspose = C := by + simp only [C,qmaFourTensorFullCounterterm,Matrix.conjTranspose_add,qmaFourTensorFamilyCounterterm_star, + qmaFourTensorOnsite_star] + have h := qmaFourTensor_polynomial_accuracy B (hb.1.trans hB) + V C (qmaFourTensorFamily_star left right a b t hneq) hCs + (qmaFourTensorFamily_orthogonal left right a b t hneq) + (qmaFourTensorFamily_excitation left right a b t hneq) + (hb.2.1.trans hB) (hb.2.2.1.trans hB) (hb.2.2.2.trans hB) + (EuclideanSpace.single (fun _ => 0) 1) (by simp [PiLp.norm_single]) N hN + rw [show qmaFourTensorEffectiveMatrix V C = qmaFourTensorFullTarget left right a b t site axis weight constant + from qmaFourTensorFull_effective left right a b t hneq hdist site axis weight constant] at h + exact h + +omit [Fintype τ] in +theorem qmaXZBlock_polynomial_accuracy (t : κ → QMAXZTerm n) (J : κ → ℝ) + (hprivate : ∀ e f, (qmaPauliSupport (t e).word).card = 2 → + qmaPauliSupport (t e).word = qmaPauliSupport (t f).word → e = f) + (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaXZBlockSource (9*(qmaXZPolynomialBudget J)^3*N) t J)- + MediatorGraph.normalizedBottom (∑ e, (J e:ℂ) • (t e).matrix)| ≤ 1/(N:ℝ) := by + have h := qmaFourTensorFull_accuracy_of_budget + (fun e => (qmaXZPairData t e).left) (fun e => (qmaXZPairData t e).right) + (fun e => (qmaXZPairData t e).axisLeft) (fun e => (qmaXZPairData t e).axisRight) + (fun e => J e.val) + (fun e => (qmaXZPairData t e).distinct) + (fun e f hef => qmaXZPairData_distinct t hprivate e f hef) + (fun e => (qmaXZFieldData t e).site) (fun e => (qmaXZFieldData t e).axis) + (fun e => J e.val) (qmaXZFamilyConstant t J) (qmaXZPolynomialBudget J) + (qmaXZBlockBudget_bound t J) N hN + rw [qmaXZFamily_target, + ← qmaBlockSourceFull_reindex _ _ _ _ _ _ (fun e => (qmaXZPairData t e).distinct), + MediatorGraph.normalizedBottom_reindex] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockCoefficientBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockCoefficientBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0354c97fc94c16739bc837684d25b680c88ee884 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockCoefficientBounds.lean @@ -0,0 +1,157 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockRational + +namespace OAI + +/-! Explicit polynomial magnitude bounds for the physical exchange list. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFieldEdgeWeight_bound (a : Fin 2) (t : ℝ) (k : Fin 3) : + |qmaFieldEdgeWeight a t k| ≤ |t| := by + have hs : 1 ≤ Real.sqrt 3 := by + have hs0 := Real.sqrt_nonneg 3 + have hs2 : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + nlinarith + have hd : |t/(2*Real.sqrt 3)| ≤ |t| := by + rw [abs_div,abs_of_pos (by positivity : 0 < 2*Real.sqrt 3)] + apply (div_le_iff₀ (by positivity : 0 < 2*Real.sqrt 3)).mpr + nlinarith [abs_nonneg t] + have hz : |t/2| ≤ |t| := by rw [abs_div]; norm_num + by_cases ha : a = 0 + · subst a + fin_cases k + · simpa [qmaFieldEdgeWeight] using hd + · simpa [qmaFieldEdgeWeight,neg_div] using hd + · simp [qmaFieldEdgeWeight] + · fin_cases k + · simp [qmaFieldEdgeWeight,ha] + · simp [qmaFieldEdgeWeight,ha] + · simpa [qmaFieldEdgeWeight,ha,neg_div] using hz + +theorem qmaFourAxisWeights_pointwise (a : Fin 2) (s : Bool) (p : Fin 4) : + |qmaFourAxisWeights a s p| ≤ 28 := + (Finset.single_le_sum (fun q _ => abs_nonneg (qmaFourAxisWeights a s q)) + (Finset.mem_univ p)).trans (qmaFourAxisWeights_abs_sum a s) + +theorem qmaFourCrossWeight_bound (r t : ℝ) (a b : Fin 2) (p q : Fin 4) : + |r*qmaFourCouplingSize a b t* + (qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign t) q)| ≤ + 2352*|r| *(1+|t|) := by + rw [abs_mul,abs_mul,abs_mul,abs_of_nonneg (qmaFourCouplingSize_nonneg a b t)] + have hw : |qmaFourAxisWeights a true p| * |qmaFourAxisWeights b (qmaFourCouplingSign t) q| ≤ 784 := by + have h := mul_le_mul (qmaFourAxisWeights_pointwise a true p) + (qmaFourAxisWeights_pointwise b (qmaFourCouplingSign t) q) + (abs_nonneg _) (by norm_num : (0:ℝ) ≤ 28) + norm_num at h + exact h + calc + _ ≤ (|r| * (3*(1+|t|)))*784 := mul_le_mul + (mul_le_mul_of_nonneg_left (qmaFourCouplingSize_bound a b t) (abs_nonneg r)) + hw (by positivity) (by positivity) + _ = _ := by ring + +theorem qmaFourEnergyOffset_bound (a b : Fin 2) (t : ℝ) : + |qmaFourEnergyOffset a b t| ≤ 364800*|t| := by + have ha := qmaFourAxisFieldShift_abs a (qmaFourCounterA a b t) + have hb := qmaFourAxisFieldShift_abs b (qmaFourCounterB a b t) + have hca := qmaFourCounterA_bound a b t + have hcb := qmaFourCounterB_bound a b t + have hm : |qmaFourCouplingFactor a b t*qmaFourAxisShift a true* + qmaFourAxisShift b (qmaFourCouplingSign t)| ≤ 160000*|t| := by + rw [abs_mul,abs_mul,abs_of_nonneg (qmaFourCouplingFactor_nonneg a b t)] + calc + _ ≤ (|t| * 400)*400 := mul_le_mul + (mul_le_mul (qmaFourCouplingFactor_bound a b t) (qmaFourAxisShift_abs_bound a true) + (abs_nonneg _) (abs_nonneg t)) (qmaFourAxisShift_abs_bound b _) + (abs_nonneg _) (by positivity) + _ = _ := by ring + have hsum := abs_add_le (qmaFourAxisFieldShift a (qmaFourCounterA a b t)) + (qmaFourAxisFieldShift b (qmaFourCounterB a b t)) + have hsub := abs_sub + (qmaFourAxisFieldShift a (qmaFourCounterA a b t)+qmaFourAxisFieldShift b (qmaFourCounterB a b t)) + (qmaFourCouplingFactor a b t*qmaFourAxisShift a true*qmaFourAxisShift b (qmaFourCouplingSign t)) + unfold qmaFourEnergyOffset + linarith + +variable {n : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +omit [Fintype κ] [Fintype τ] in +theorem qmaFourExchangeWeight_bound (r : ℝ) (a b : κ → Fin 2) (t : κ → ℝ) + (axis : τ → Fin 2) (weight : τ → ℝ) (B : ℝ) (hB : 0 ≤ B) + (ht : ∀ e, |t e| ≤ B) (hw : ∀ e, |weight e| ≤ B) (x : QMAFourExchangeIndex n κ τ) : + |qmaFourExchangeWeight r a b t axis weight x| ≤ + r^2+2352*|r| *(1+B)+102400*B+B := by + have hc0 : 0 ≤ 2352*|r| *(1+B) := by positivity + cases x with + | inl x => + change |r^2| ≤ _ + rw [abs_of_nonneg (sq_nonneg r)] + nlinarith + | inr x => + cases x with + | inl x => + have h := (qmaFourCrossWeight_bound r (t x.1) (a x.1) (b x.1) x.2.1 x.2.2).trans + (mul_le_mul_of_nonneg_left (add_le_add le_rfl (ht x.1)) (by positivity : 0 ≤ 2352*|r|)) + exact h.trans (by nlinarith [sq_nonneg r]) + | inr x => + cases x with + | inl x => + change |if x.2.1 = 0 then _ else _| ≤ _ + split_ifs + · have h := (qmaFieldEdgeWeight_bound (a x.1) (qmaFourCounterA (a x.1) (b x.1) (t x.1)) x.2.2).trans + ((qmaFourCounterA_bound (a x.1) (b x.1) (t x.1)).trans + (mul_le_mul_of_nonneg_left (ht x.1) (by norm_num))) + exact h.trans (by nlinarith [sq_nonneg r]) + · have h := (qmaFieldEdgeWeight_bound (b x.1) (qmaFourCounterB (a x.1) (b x.1) (t x.1)) x.2.2).trans + ((qmaFourCounterB_bound (a x.1) (b x.1) (t x.1)).trans + (mul_le_mul_of_nonneg_left (ht x.1) (by norm_num))) + exact h.trans (by nlinarith [sq_nonneg r]) + | inr x => + have h := (qmaFieldEdgeWeight_bound (axis x.1) (weight x.1) x.2).trans (hw x.1) + exact h.trans (by nlinarith [sq_nonneg r]) + +omit [Fintype τ] in +theorem qmaSum_subtype_abs_le (p : κ → Prop) [DecidablePred p] (J : κ → ℝ) : + (∑ e : {x // p x}, |J e.val|) ≤ ∑ e, |J e| := by + have h := Fintype.sum_subtype_add_sum_subtype p (fun e => |J e|) + have hn : 0 ≤ ∑ e : {x // ¬p x}, |J e.val| := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + linarith + +omit [Fintype τ] in +theorem qmaXZFamilyConstant_bound (t : κ → QMAXZTerm n) (J : κ → ℝ) : + |qmaXZFamilyConstant t J| ≤ 364801*(∑ e, |J e|) := by + have hp := qmaSum_subtype_abs_le (fun e => (t e).IsPair) J + have hs := qmaSum_subtype_abs_le (fun e => (t e).IsScalar) J + have hsp := Finset.abs_sum_le_sum_abs (fun e : QMAXZScalarIndex t => J e.val) Finset.univ + have hpp := Finset.abs_sum_le_sum_abs (fun e : QMAXZPairIndex t => + qmaFourEnergyOffset (qmaXZPairData t e).axisLeft (qmaXZPairData t e).axisRight (J e.val)) Finset.univ + have he : (∑ e : QMAXZPairIndex t, + |qmaFourEnergyOffset (qmaXZPairData t e).axisLeft (qmaXZPairData t e).axisRight (J e.val)|) ≤ + 364800*(∑ e : QMAXZPairIndex t, |J e.val|) := by + rw [Finset.mul_sum] + exact Finset.sum_le_sum (fun _ _ => qmaFourEnergyOffset_bound _ _ _) + have hd := abs_sub (∑ e : QMAXZScalarIndex t, J e.val) + (∑ e : QMAXZPairIndex t, qmaFourEnergyOffset + (qmaXZPairData t e).axisLeft (qmaXZPairData t e).axisRight (J e.val)) + unfold qmaXZFamilyConstant + linarith + +omit [Fintype τ] in +theorem qmaXZBlock_exchange_count (t : κ → QMAXZTerm n) : + Fintype.card (QMAFourExchangeIndex n (QMAXZPairIndex t) (QMAXZFieldIndex t)) ≤ + 6*n+25*Fintype.card κ := by + rw [qmaFourExchange_count] + have hp := Fintype.card_subtype_le (fun e => (t e).IsPair) + have hf := Fintype.card_subtype_le (fun e => (t e).IsField) + change Fintype.card (QMAXZPairIndex t) ≤ Fintype.card κ at hp + change Fintype.card (QMAXZFieldIndex t) ≤ Fintype.card κ at hf + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockEdges.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockEdges.lean new file mode 100644 index 0000000000000000000000000000000000000000..572936adf1019a96af7a2bf2f3dab8145938ce2a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockEdges.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockFull + +namespace OAI + +/-! An explicit finite list of physical exchanges, with no implicit many-body terms. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +def qmaFieldEdgeRight (k : Fin 3) : Fin 4 := ![3,2,1] k + +def qmaFieldEdgeWeight (a : Fin 2) (t : ℝ) (k : Fin 3) : ℝ := + if a = 0 then ![t/(2*Real.sqrt 3),-t/(2*Real.sqrt 3),0] k else ![0,0,-t/2] k + +theorem qmaFieldEdgeRight_ne (k : Fin 3) : (0:Fin 4) ≠ qmaFieldEdgeRight k := by + fin_cases k <;> decide + +theorem qmaBlockSourceAxisField_edges (i : Fin n) (a : Fin 2) (t : ℝ) : + qmaBlockSourceAxisField i a t = ∑ k : Fin 3, (qmaFieldEdgeWeight a t k:ℂ) • + sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,0)) (finProdFinEquiv (i,qmaFieldEdgeRight k)) := by + unfold qmaBlockSourceAxisField qmaFieldEdgeWeight + split_ifs <;> + simp only [qmaFieldEdgeRight,Fin.sum_univ_succ,Fin.sum_univ_zero,Matrix.cons_val_zero, + Matrix.cons_val_succ,add_zero,qmaBlockSourceField,zero_div,Complex.ofReal_zero, + zero_smul,sub_zero,zero_sub,zero_add,neg_div,Complex.ofReal_neg,neg_smul] + · rw [smul_sub] + rw [sub_eq_add_neg] + +abbrev QMAFourExchangeIndex (n : ℕ) (κ τ : Type*) := + (Fin n × Fin 6) ⊕ ((κ × Fin 4 × Fin 4) ⊕ ((κ × Fin 2 × Fin 3) ⊕ (τ × Fin 3))) + +def qmaFourExchangeLeft (left right : κ → Fin n) (site : τ → Fin n) : + QMAFourExchangeIndex n κ τ → Fin (n*4) + | .inl (i,k) => finProdFinEquiv (i,qmaFourEdgeLeft k) + | .inr (.inl (e,p,_)) => finProdFinEquiv (left e,p) + | .inr (.inr (.inl (e,s,_))) => finProdFinEquiv ((if s = 0 then left e else right e),0) + | .inr (.inr (.inr (e,_))) => finProdFinEquiv (site e,0) + +def qmaFourExchangeRight (left right : κ → Fin n) (site : τ → Fin n) : + QMAFourExchangeIndex n κ τ → Fin (n*4) + | .inl (i,k) => finProdFinEquiv (i,qmaFourEdgeRight k) + | .inr (.inl (e,_,q)) => finProdFinEquiv (right e,q) + | .inr (.inr (.inl (e,s,k))) => finProdFinEquiv ((if s = 0 then left e else right e),qmaFieldEdgeRight k) + | .inr (.inr (.inr (e,k))) => finProdFinEquiv (site e,qmaFieldEdgeRight k) + +def qmaFourExchangeWeight (r : ℝ) (a b : κ → Fin 2) (t : κ → ℝ) + (axis : τ → Fin 2) (weight : τ → ℝ) : QMAFourExchangeIndex n κ τ → ℝ + | .inl _ => r^2 + | .inr (.inl (e,p,q)) => r*qmaFourCouplingSize (a e) (b e) (t e)* + (qmaFourAxisWeights (a e) true p*qmaFourAxisWeights (b e) (qmaFourCouplingSign (t e)) q) + | .inr (.inr (.inl (e,s,k))) => if s = 0 then + qmaFieldEdgeWeight (a e) (qmaFourCounterA (a e) (b e) (t e)) k else + qmaFieldEdgeWeight (b e) (qmaFourCounterB (a e) (b e) (t e)) k + | .inr (.inr (.inr (e,k))) => qmaFieldEdgeWeight (axis e) (weight e) k + +omit [Fintype κ] [Fintype τ] in +theorem qmaFourExchange_distinct (left right : κ → Fin n) (site : τ → Fin n) + (hne : ∀ e, left e ≠ right e) (x : QMAFourExchangeIndex n κ τ) : + qmaFourExchangeLeft left right site x ≠ qmaFourExchangeRight left right site x := by + cases x with + | inl x => + intro h + exact qmaFourEdge_distinct x.2 (congrArg Prod.snd (finProdFinEquiv.injective h)) + | inr x => + cases x with + | inl x => + intro h + exact hne x.1 (congrArg Prod.fst (finProdFinEquiv.injective h)) + | inr x => + cases x with + | inl x => + intro h + exact qmaFieldEdgeRight_ne x.2.2 (congrArg Prod.snd (finProdFinEquiv.injective h)) + | inr x => + intro h + exact qmaFieldEdgeRight_ne x.2 (congrArg Prod.snd (finProdFinEquiv.injective h)) + +theorem qmaFourExchange_count : Fintype.card (QMAFourExchangeIndex n κ τ) = + 6*n+22*Fintype.card κ+3*Fintype.card τ := by + simp only [QMAFourExchangeIndex,Fintype.card_sum,Fintype.card_prod,Fintype.card_fin] + omega + +def qmaFourExchangeScalar (n : ℕ) (r : ℝ) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : ℝ := + r^2*(n*6)+constant-qmaFourTensorFieldShift axis weight + +theorem qmaFourExchange_sum (r : ℝ) (left right : κ → Fin n) + (a b : κ → Fin 2) (t : κ → ℝ) (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + (∑ x : QMAFourExchangeIndex n κ τ, + (qmaFourExchangeWeight r a b t axis weight x:ℂ) • sourceHeisenbergMatrix (n*4) + (qmaFourExchangeLeft left right site x) (qmaFourExchangeRight left right site x))+ + (qmaFourExchangeScalar n r axis weight constant:ℂ) • 1 = + qmaBlockSourceFull r left right a b t site axis weight constant := by + simp only [QMAFourExchangeIndex,Fintype.sum_sum_type,Fintype.sum_prod_type, + qmaFourExchangeLeft,qmaFourExchangeRight,qmaFourExchangeWeight, + qmaBlockSourceFull,qmaBlockSourcePenalty,qmaBlockSourceCoupling, + qmaBlockSourceCounterterm,qmaBlockSourceOnsite,qmaBlockSourceAxisField_edges, + Fin.sum_univ_two,ite_true,show (1:Fin 2) ≠ 0 by decide,ite_false] + simp only [smul_add,Finset.smul_sum,smul_smul,Finset.sum_add_distrib, + qmaFourExchangeScalar,Complex.ofReal_sub,Complex.ofReal_add,Complex.ofReal_mul, + Complex.ofReal_pow,Complex.ofReal_natCast,mul_assoc] + module + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockExchange.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockExchange.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffcf61af3fe137c17396707c991cd5ecb946a6c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockExchange.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockBasis + +namespace OAI + +/-! Both internal and cross-block couplings are ordinary source Heisenberg exchanges. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +theorem qmaBlockExchange_source (i : Fin n) (p q : Fin 4) (hpq : p ≠ q) : + (sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,p)) (finProdFinEquiv (i,q))).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = qmaSiteMatrix i (qmaFourExchange p q) := by + have hij : finProdFinEquiv (i,p) ≠ finProdFinEquiv (i,q) := by + intro h + exact hpq (congrArg Prod.snd (finProdFinEquiv.injective h)) + rw [← sourceLocalPauli_sum (n*4) _ _ hij,MediatorGraph.submatrix_sum, + qmaFourExchange_pauli p q hpq,qmaSiteMatrix_sum] + apply Finset.sum_congr rfl + intro μ _ + rw [← Matrix.submatrix_mul_equiv _ _ _ (qmaBlockBasisEquiv n).symm _, + qmaBlockPauli_source,qmaBlockPauli_source,qmaSiteMatrix_mul] + +theorem qmaBlockCross_source (i j : Fin n) (hij : i ≠ j) (p q : Fin 4) : + (sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,p)) (finProdFinEquiv (j,q))).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = qmaFourTensorCross i j p q := by + have hne : finProdFinEquiv (i,p) ≠ finProdFinEquiv (j,q) := by + intro h + exact hij (congrArg Prod.fst (finProdFinEquiv.injective h)) + rw [← sourceLocalPauli_sum (n*4) _ _ hne,MediatorGraph.submatrix_sum,qmaFourTensorCross] + apply Finset.sum_congr rfl + intro μ _ + rw [← Matrix.submatrix_mul_equiv _ _ _ (qmaBlockBasisEquiv n).symm _, + qmaBlockPauli_source,qmaBlockPauli_source] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockFull.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockFull.lean new file mode 100644 index 0000000000000000000000000000000000000000..00ea6455f85cf33f6e116083ce2327fc750deef3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockFull.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockHamiltonian +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFullFamily + +namespace OAI + +/-! The full physical simulator as a sum of ordinary Heisenberg exchanges. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +def qmaBlockSourceCounterterm (i j : Fin n) (a b : Fin 2) (t : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + qmaBlockSourceAxisField i a (qmaFourCounterA a b t)+ + qmaBlockSourceAxisField j b (qmaFourCounterB a b t) + +theorem qmaBlockSourceCounterterm_reindex (i j : Fin n) (a b : Fin 2) (t : ℝ) : + (qmaBlockSourceCounterterm i j a b t).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = qmaFourTensorCounterterm i j a b t := by + simp only [qmaBlockSourceCounterterm,MediatorGraph.submatrix_add_apply, + qmaBlockSourceAxisField_reindex,qmaFourTensorCounterterm] + +def qmaBlockSourceOnsite (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + (∑ e, qmaBlockSourceAxisField (site e) (axis e) (weight e))+ + ((constant-qmaFourTensorFieldShift axis weight:ℝ):ℂ) • 1 + +theorem qmaBlockSourceOnsite_reindex (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + (qmaBlockSourceOnsite site axis weight constant).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaFourTensorOnsite site axis weight constant := by + simp only [qmaBlockSourceOnsite,MediatorGraph.submatrix_add_apply, + MediatorGraph.submatrix_sum,qmaBlockSourceAxisField_reindex, + MediatorGraph.submatrix_smul_apply,Matrix.submatrix_one_equiv, + qmaFourTensorOnsite,qmaFourTensorFields] + +def qmaBlockSourceFull (r : ℝ) (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + ((r^2:ℝ):ℂ) • qmaBlockSourcePenalty n+ + (r:ℂ) • (∑ e, qmaBlockSourceCoupling (left e) (right e) (a e) (b e) (t e))+ + (∑ e, qmaBlockSourceCounterterm (left e) (right e) (a e) (b e) (t e))+ + qmaBlockSourceOnsite site axis weight constant + +theorem qmaBlockSourceFull_reindex (r : ℝ) (left right : κ → Fin n) + (a b : κ → Fin 2) (t : κ → ℝ) (hneq : ∀ e, left e ≠ right e) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + (qmaBlockSourceFull r left right a b t site axis weight constant).submatrix + (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaFourTensorPhysicalMatrix r + ((r:ℂ) • qmaFourTensorFamilyCoupling left right a b t+ + qmaFourTensorFullCounterterm left right a b t site axis weight constant) := by + simp only [qmaBlockSourceFull,MediatorGraph.submatrix_add_apply, + MediatorGraph.submatrix_smul_apply,MediatorGraph.submatrix_sum,qmaBlockSourcePenalty_reindex, + qmaBlockSourceCoupling_reindex _ _ (hneq _),qmaBlockSourceCounterterm_reindex, + qmaBlockSourceOnsite_reindex,qmaFourTensorPhysicalMatrix,qmaFourTensorFamilyCoupling, + qmaFourTensorFullCounterterm,qmaFourTensorFamilyCounterterm,Complex.ofReal_pow] + abel + +theorem qmaBlockSourceFull_accuracy (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaBlockSourceFull + (9*(qmaFourTensorFullBudget t weight constant)^3*N) + left right a b t site axis weight constant)- + MediatorGraph.normalizedBottom (qmaFourTensorFullTarget left right a b t site axis weight constant)| ≤ + 1/(N:ℝ) := by + have h := qmaFourTensorFull_accuracy left right a b t hneq hdist site axis weight constant N hN + rw [← qmaBlockSourceFull_reindex _ left right a b t hneq site axis weight constant, + MediatorGraph.normalizedBottom_reindex] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockHamiltonian.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockHamiltonian.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b8d756614411dcf185176c21c9e28b3a6d61bfb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockHamiltonian.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockExchange + +namespace OAI + +/-! Literal exchange sums for the real-coefficient four-spin Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +def qmaFourEdgeLeft (e : Fin 6) : Fin 4 := ![0,0,0,1,1,2] e +def qmaFourEdgeRight (e : Fin 6) : Fin 4 := ![1,2,3,2,3,3] e + +theorem qmaFourEdge_distinct (e : Fin 6) : qmaFourEdgeLeft e ≠ qmaFourEdgeRight e := by + fin_cases e <;> decide + +theorem qmaFourPenalty_edgeSum : qmaFourPenalty = + (∑ e : Fin 6, qmaFourExchange (qmaFourEdgeLeft e) (qmaFourEdgeRight e))+ + (6:ℂ) • (1 : Matrix (Fin 16) (Fin 16) ℂ) := by + rw [qmaFourPenalty_exchange] + simp only [qmaFourEdgeLeft,qmaFourEdgeRight,Fin.sum_univ_succ,Fin.sum_univ_zero, + Matrix.cons_val_zero,Matrix.cons_val_succ,add_zero] + abel + +def qmaBlockSourcePenalty (n : ℕ) : Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + (∑ i : Fin n, ∑ e : Fin 6, sourceHeisenbergMatrix (n*4) + (finProdFinEquiv (i,qmaFourEdgeLeft e)) (finProdFinEquiv (i,qmaFourEdgeRight e)))+ + ((n:ℂ)*6) • 1 + +theorem qmaBlockSourcePenalty_reindex (n : ℕ) : + (qmaBlockSourcePenalty n).submatrix (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaFourTensorPenalty n := by + simp only [qmaBlockSourcePenalty,MediatorGraph.submatrix_add_apply,MediatorGraph.submatrix_sum, + MediatorGraph.submatrix_smul_apply,Matrix.submatrix_one_equiv, + qmaBlockExchange_source _ _ _ (qmaFourEdge_distinct _),qmaFourTensorPenalty,qmaTensorPenalty, + qmaFourPenalty_edgeSum,qmaSiteMatrix_add,qmaSiteMatrix_sum,qmaSiteMatrix_smul,qmaSiteMatrix_one, + Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin] + congr 1 + module + +def qmaBlockSourceField (i : Fin n) (x z : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + ((x/(2*Real.sqrt 3):ℝ):ℂ) • + (sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,0)) (finProdFinEquiv (i,3))- + sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,0)) (finProdFinEquiv (i,2)))- + ((z/2:ℝ):ℂ) • sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,0)) (finProdFinEquiv (i,1)) + +theorem qmaBlockSourceField_reindex (i : Fin n) (x z : ℝ) : + (qmaBlockSourceField i x z).submatrix (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaSiteMatrix i (qmaFourField x z) := by + simp only [qmaBlockSourceField,Matrix.submatrix_sub,Pi.sub_apply,MediatorGraph.submatrix_smul_apply, + qmaBlockExchange_source i 0 3 (by decide),qmaBlockExchange_source i 0 2 (by decide), + qmaBlockExchange_source i 0 1 (by decide),qmaFourField,qmaSiteMatrix_sub,qmaSiteMatrix_smul] + +def qmaBlockSourceAxisField (i : Fin n) (a : Fin 2) (t : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + if a = 0 then qmaBlockSourceField i t 0 else qmaBlockSourceField i 0 t + +theorem qmaBlockSourceAxisField_reindex (i : Fin n) (a : Fin 2) (t : ℝ) : + (qmaBlockSourceAxisField i a t).submatrix (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaSiteMatrix i (qmaFourAxisField a t) := by + unfold qmaBlockSourceAxisField qmaFourAxisField + split_ifs <;> exact qmaBlockSourceField_reindex _ _ _ + +def qmaBlockSourceCoupling (i j : Fin n) (a b : Fin 2) (t : ℝ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + (qmaFourCouplingSize a b t:ℂ) • + ∑ p : Fin 4, ∑ q : Fin 4, + ((qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign t) q:ℝ):ℂ) • + sourceHeisenbergMatrix (n*4) (finProdFinEquiv (i,p)) (finProdFinEquiv (j,q)) + +theorem qmaBlockSourceCoupling_reindex (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + (qmaBlockSourceCoupling i j a b t).submatrix (qmaBlockBasisEquiv n).symm (qmaBlockBasisEquiv n).symm = + qmaFourTensorCoupling i j a b t := by + simp only [qmaBlockSourceCoupling,MediatorGraph.submatrix_smul_apply,MediatorGraph.submatrix_sum, + qmaBlockCross_source i j hij,qmaFourTensorCoupling,qmaFourTensorWeighted] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockRational.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockRational.lean new file mode 100644 index 0000000000000000000000000000000000000000..abebf2a7d0f5f37238cf34ad4900c5b6db337093 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBlockRational.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumExchangeRounding +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumXZHeisenberg + +namespace OAI + +/-! A rational finite Heisenberg family with controlled error, before lattice routing. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +theorem qmaBlockSourceFull_exchange (r : ℝ) (left right : κ → Fin n) + (a b : κ → Fin 2) (t : κ → ℝ) (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + qmaBlockSourceFull r left right a b t site axis weight constant = + qmaExchangeMatrix (qmaFourExchangeLeft left right site) (qmaFourExchangeRight left right site) + (qmaFourExchangeWeight r a b t axis weight) (qmaFourExchangeScalar n r axis weight constant) := + (qmaFourExchange_sum r left right a b t site axis weight constant).symm + +theorem qmaBlock_rational_accuracy (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) (N : ℕ) (hN : 0 < N) : + let r := 9*(qmaFourTensorFullBudget t weight constant)^3*N + let m := (3*Fintype.card (QMAFourExchangeIndex n κ τ)+1)*N + let J := fun x => qmaRationalRound m (qmaFourExchangeWeight r a b t axis weight x) + let s := qmaRationalRound m (qmaFourExchangeScalar n r axis weight constant) + |MediatorGraph.normalizedBottom (qmaExchangeMatrix + (qmaFourExchangeLeft left right site) (qmaFourExchangeRight left right site) (fun x => (J x:ℝ)) (s:ℝ))- + MediatorGraph.normalizedBottom (qmaFourTensorFullTarget left right a b t site axis weight constant)| ≤ + 2/(N:ℝ) := by + dsimp only + let r := 9*(qmaFourTensorFullBudget t weight constant)^3*N + have hphys := qmaBlockSourceFull_accuracy left right a b t hneq hdist site axis weight constant N hN + have hround := qmaExchangeMatrix_round_accuracy + (qmaFourExchangeLeft left right site) (qmaFourExchangeRight left right site) + (qmaFourExchange_distinct left right site hneq) + (qmaFourExchangeWeight r a b t axis weight) + (qmaFourExchangeScalar n r axis weight constant) N hN + dsimp only at hround + rw [← qmaBlockSourceFull_exchange r left right a b t site axis weight constant] at hround + rw [abs_sub_comm] at hround + exact (abs_sub_le _ _ _).trans ((add_le_add hround hphys).trans_eq (by ring)) + +theorem qmaXZ_rational_heisenberg (t : κ → QMAXZTerm n) (J : κ → ℝ) + (hprivate : ∀ e f, (qmaPauliSupport (t e).word).card = 2 → + qmaPauliSupport (t e).word = qmaPauliSupport (t f).word → e = f) + (N : ℕ) (hN : 0 < N) : + ∃ (left right : QMAFourExchangeIndex n (QMAXZPairIndex t) (QMAXZFieldIndex t) → Fin (n*4)) + (weight : QMAFourExchangeIndex n (QMAXZPairIndex t) (QMAXZFieldIndex t) → ℚ) (s : ℚ), + (∀ e, left e ≠ right e) ∧ + |MediatorGraph.normalizedBottom (qmaExchangeMatrix left right (fun e => (weight e:ℝ)) (s:ℝ))- + MediatorGraph.normalizedBottom (∑ e, (J e:ℂ) • (t e).matrix)| ≤ 2/(N:ℝ) := by + let left := fun e => (qmaXZPairData t e).left + let right := fun e => (qmaXZPairData t e).right + let a := fun e => (qmaXZPairData t e).axisLeft + let b := fun e => (qmaXZPairData t e).axisRight + let site := fun e => (qmaXZFieldData t e).site + let axis := fun e => (qmaXZFieldData t e).axis + let r := 9*(qmaXZBlockBudget t J)^3*N + let m := (3*Fintype.card (QMAFourExchangeIndex n (QMAXZPairIndex t) (QMAXZFieldIndex t))+1)*N + refine ⟨qmaFourExchangeLeft left right site,qmaFourExchangeRight left right site, + (fun x => qmaRationalRound m (qmaFourExchangeWeight r a b (fun e => J e.val) axis (fun e => J e.val) x)), + qmaRationalRound m (qmaFourExchangeScalar n r axis (fun e => J e.val) (qmaXZFamilyConstant t J)),?_,?_⟩ + · exact qmaFourExchange_distinct left right site (fun e => (qmaXZPairData t e).distinct) + · have h := qmaBlock_rational_accuracy left right a b (fun e => J e.val) + (fun e => (qmaXZPairData t e).distinct) + (fun e f hef => qmaXZPairData_distinct t hprivate e f hef) + site axis (fun e => J e.val) (qmaXZFamilyConstant t J) N hN + change |_-MediatorGraph.normalizedBottom (qmaFourTensorFullTarget left right a b + (fun e => J e.val) site axis (fun e => J e.val) (qmaXZFamilyConstant t J))| ≤ _ at h + rw [qmaXZFamily_target] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArmProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArmProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..777d10d391dab1e44194a3fdb14375f245760caa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArmProgram.lean @@ -0,0 +1,110 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedArms +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteProgram +import OAI.Computability.QuantumFactoring.BitStackTabulate +import OAI.Computability.QuantumFactoring.BitStackUnary + +namespace OAI + +/-! Literal evaluation and enumeration of the three buffered endpoint arms. +The lane color is unary, as required by the polynomial geometric size bound. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumBufferedArmProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +private noncomputable def add {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea Nat.bits f) (q : Procedure ea Nat.bits g) : + Procedure ea Nat.bits (fun x => f x+g x) := Procedure.binaryAdd.comp (p.pair q) +private noncomputable def sub {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea Nat.bits f) (q : Procedure ea Nat.bits g) : + Procedure ea Nat.bits (fun x => f x-g x) := Procedure.binarySub.comp (p.pair q) +private noncomputable def mul {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea Nat.bits f) (q : Procedure ea Nat.bits g) : + Procedure ea Nat.bits (fun x => f x*g x) := Procedure.binaryMul.comp (p.pair q) +private noncomputable def le {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea Nat.bits f) (q : Procedure ea Nat.bits g) : + Procedure ea Procedure.boolCode (fun x => decide (f x ≤ g x)) := + Procedure.binaryLe.comp (p.pair q) + +private noncomputable def u : Procedure axisCode Nat.bits (fun x => x.1.1) := axisStartProgram +private noncomputable def v : Procedure axisCode Nat.bits (fun x => x.1.2) := axisEndProgram +private noncomputable def k : Procedure axisCode Nat.bits (fun x => x.2) := axisCursorProgram +private noncomputable def c (n : ℕ) : Procedure axisCode Nat.bits (fun _ => n) := + Procedure.constant _ _ n + +noncomputable def doglegProgram : Procedure axisCode pairCode + (fun x => qmaBufferedDoglegPoint x.1.1 x.1.2 x.2) := + (Procedure.conditional (le k (sub v (c 17))) ((add (c 17) k).pair (c 17)) + (Procedure.conditional (le k (add (sub v (c 17)) (sub u (c 17)))) + (v.pair (add (c 17) (sub k (sub v (c 17))))) (u.pair u))).congrFun (by + intro x + simp only [qmaBufferedDoglegPoint,decide_eq_true_eq]) + +noncomputable def detourProgram : Procedure axisCode pairCode + (fun x => qmaBufferedDetourPoint x.1.1 x.1.2 x.2) := + (Procedure.conditional (le k (c 8)) ((sub (c 17) k).pair (c 17)) + (Procedure.conditional (le k u) ((c 9).pair (add k (c 9))) + (Procedure.conditional (le k (sub (add u v) (c 9))) + ((add (sub k u) (c 9)).pair (add u (c 9))) + (Procedure.conditional (le k (add u v)) + (v.pair (sub (add (mul (c 2) u) v) k)) (u.pair u))))).congrFun (by + intro x + simp only [qmaBufferedDetourPoint,decide_eq_true_eq]) + +def point (a : Fin 3) (color j : ℕ) : Pair := + let u := 8*(color+3) + if a = 0 then qmaBufferedDoglegPoint u (u-1) j + else if a = 1 then (qmaBufferedDoglegPoint u (u-1) j).swap + else qmaBufferedDetourPoint u (u-1) j + +def length (a : Fin 3) (color : ℕ) : ℕ := + if a = 2 then 16*color+48 else 16*color+14 + + theorem point_eq (colors : Fin 3 → ℕ) (a : Fin 3) (j : ℕ) : + qmaBufferedArmPoint colors (fun _ => false) a j = point a (colors a) j := rfl + + theorem length_eq (colors : Fin 3 → ℕ) (a : Fin 3) : + qmaBufferedArmLength colors (fun _ => false) a = length a (colors a) := by + simp only [qmaBufferedArmLength,qmaBufferedPort,qmaBufferedOffset,Bool.false_eq_true, + ite_false,length,qmaBufferedDoglegLength] + split_ifs <;> omega + +noncomputable def pointProgram (a : Fin 3) : + Procedure (prodCode unaryCode Nat.bits) pairCode (fun x => point a x.1 x.2) := by + let en := prodCode unaryCode Nat.bits + let color := Procedure.unaryToBits.comp (Procedure.first unaryCode Nat.bits) + let port := mul (Procedure.constant en Nat.bits 8) + (add color (Procedure.constant en Nat.bits 3)) + let arg := (port.pair (sub port (Procedure.constant en Nat.bits 1))).pair + (Procedure.second unaryCode Nat.bits) + let dog := doglegProgram.comp arg + by_cases ha : a=0 + · exact dog.congrFun (by intro x; simp [point,ha]) + · by_cases hb : a=1 + · exact (Procedure.swap Nat.bits Nat.bits |>.comp dog).congrFun (by + intro x; simp [point,hb]) + · exact (detourProgram.comp arg).congrFun (by + intro x; simp [point,ha,hb]) + +noncomputable def lengthProgram (a : Fin 3) : Procedure unaryCode unaryCode (length a) := + (Procedure.unaryAdd.comp + ((Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode 16).pair + (Procedure.identity unaryCode))).pair + (Procedure.constant unaryCode unaryCode (if a=2 then 48 else 14)))).congrFun (by + intro color + simp only [Function.comp_apply,id_eq,length] + split_ifs <;> rfl) + +noncomputable def listProgram (a : Fin 3) : Procedure unaryCode (listCode pairCode) + (fun color => (List.range (length a color+1)).map (point a color)) := by + let step := (pointProgram a).comp ((Procedure.second unaryCode unaryCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode unaryCode))) + let all := Procedure.tabulate (0,0) step + let n := Procedure.unarySuccessor.comp (lengthProgram a) + exact all.comp (n.pair (Procedure.identity unaryCode)) + +end ContinuumCoulomb.QuantumBufferedArmProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArms.lean new file mode 100644 index 0000000000000000000000000000000000000000..c700e64f4dd2e2f18b3b892c96dcc9960b595a94 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedArms.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedDetour +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridWalk + +namespace OAI + +/-! Uniform finite-walk interface for all three buffered endpoint arms. -/ + +namespace ContinuumCoulomb + +def qmaBufferedArmLength (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : ℕ := + if a = 2 then qmaBufferedPort c a + qmaBufferedOffset c side a + 1 + else qmaBufferedDoglegLength (qmaBufferedPort c a) (qmaBufferedOffset c side a) + +def qmaBufferedArmPoint (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) (k : ℕ) : ℕ × ℕ := + if a = 0 then qmaBufferedDoglegPoint (qmaBufferedPort c a) (qmaBufferedOffset c side a) k + else if a = 1 then (qmaBufferedDoglegPoint (qmaBufferedPort c a) (qmaBufferedOffset c side a) k).swap + else qmaBufferedDetourPoint (qmaBufferedPort c a) (qmaBufferedOffset c side a) k + +theorem qmaBufferedOffset_ne (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedPort c a ≠ qmaBufferedOffset c side a := by + unfold qmaBufferedOffset qmaBufferedPort + split_ifs <;> omega + +@[simp] theorem qmaBufferedArm_zero (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedArmPoint c side a 0 = (17,17) := by + fin_cases a <;> simp [qmaBufferedArmPoint,qmaBufferedDogleg_zero,qmaBufferedDetour_zero] + +@[simp] theorem qmaBufferedArm_last (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedArmPoint c side a (qmaBufferedArmLength c side a) = + (qmaBufferedPort c a,qmaBufferedPort c a) := by + have hu : 24 ≤ qmaBufferedPort c 2 := by unfold qmaBufferedPort; omega + fin_cases a <;> simp [qmaBufferedArmPoint,qmaBufferedArmLength, + qmaBufferedDogleg_last,qmaBufferedDetour_last hu] + +theorem qmaBufferedArm_support (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) (k : ℕ) : + qmaBufferedFanoutSupport c side a (qmaBufferedArmPoint c side a k) := by + have hu : 24 ≤ qmaBufferedPort c 1 := by unfold qmaBufferedPort; omega + have hv : 23 ≤ qmaBufferedOffset c side 1 := by + have h := qmaBufferedOffset_bounds c side 1 + omega + fin_cases a + · exact qmaBufferedFanout_direct_support c side k + · have h := qmaBufferedDogleg_support hu hv k + simpa [qmaBufferedFanoutSupport,qmaBufferedDoglegSupport,qmaBufferedArmPoint] using h + · exact qmaBufferedFanout_detour_support c side k + +theorem qmaBufferedArm_step (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) + (k : ℕ) (hk : k < qmaBufferedArmLength c side a) : + qmaSquareGrid.Adj (qmaBufferedArmPoint c side a k) (qmaBufferedArmPoint c side a (k+1)) := by + have hu : 24 ≤ qmaBufferedPort c a := by unfold qmaBufferedPort; omega + have hc := qmaBufferedOffset_bounds c side a + have hv : 23 ≤ qmaBufferedOffset c side a := by omega + have hn := qmaBufferedOffset_ne c side a + fin_cases a + · simpa [qmaBufferedArmPoint,qmaSquareGrid] using + qmaBufferedDogleg_step hu hv hc hn k hk + · simpa [qmaBufferedArmPoint,qmaSquareGrid,Nat.add_comm] using + qmaBufferedDogleg_step hu hv hc hn k hk + · simpa [qmaBufferedArmPoint,qmaSquareGrid] using + qmaBufferedDetour_step hu hv hc hn k hk + +theorem qmaBufferedArm_length_bound (c : Fin 3 → ℕ) (side : Fin 3 → Bool) + {C : ℕ} (hC : ∀ a, c a < C) (a : Fin 3) : qmaBufferedArmLength c side a ≤ 16*(C+3)+2 := by + have hu : qmaBufferedPort c a ≤ 8*(C+3) := by + have h := hC a + unfold qmaBufferedPort + omega + have hc := qmaBufferedOffset_bounds c side a + unfold qmaBufferedArmLength + split_ifs + · omega + · exact (qmaBufferedDogleg_length_bound hu hc.2).trans (by omega) + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..06e0ab02fa64726dec90a7bfefbd6d2f8c12cdb8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedBounds.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedSupport + +namespace OAI + +/-! Buffered routes lie strictly inside the nonnegative lattice quadrant. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem endpointArmSupport_positive (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {z : ℕ × ℕ} (hz : M.endpointArmSupport hd v e z) : + 0 < z.1 ∧ 0 < z.2 := by + obtain ⟨p,hp,hs⟩ := hz + have hb := qmaBufferedFanout_bounded (M.endpointColors hd v) + ((M.endpointPorts hd v).increasing (show (0 : Fin 3) < 1 by decide)) + ((M.endpointPorts hd v).increasing (show (1 : Fin 3) < 2 by decide)) + ((M.endpointPorts hd v).slot 2).isLt (fun _ => false) _ hs + rw [← hp] + dsimp [qmaBufferedCellPoint] + omega + +theorem spacedSupport_positive (e : M.Term) {z : ℕ × ℕ} (hz : M.spacedSupport e z) : + 0 < z.1 ∧ 0 < z.2 := by + have hc : 0 < (M.spacedColor e).val := by + dsimp [spacedColor,qmaSpacedLaneColor] + omega + rcases hz with ⟨hy,hx⟩ | ⟨hx,hy⟩ <;> + dsimp [qmaLanePoint,qmaBetween] at * <;> omega + +theorem bufferedPath_positive (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) {z : ℕ × ℕ} (hz : z ∈ (M.bufferedPath hd e).val.support) : + 0 < z.1 ∧ 0 < z.2 := by + rcases M.bufferedPath_support hd e hz with h | h | h + · exact M.endpointArmSupport_positive hd _ _ h + · exact M.spacedSupport_positive e h + · exact M.endpointArmSupport_positive hd _ _ h + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..495da365fe4a38490ec47c29a9584b6fa446d8f4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCells.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedFanout +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteLanes + +namespace OAI + +/-! Buffered endpoint cells align with spaced lanes and are mutually disjoint. -/ + +namespace ContinuumCoulomb + +def qmaBufferedCellPoint (C : ℕ) (p z : ℕ × ℕ) : ℕ × ℕ := + (8*(C+6)*p.1+z.1,8*(C+6)*p.2+z.2) + +def qmaBufferedLaneColor {C : ℕ} (c : Fin C) : Fin (C+6) := ⟨c.val+3,by omega⟩ + +theorem qmaBufferedLaneColor_injective (C : ℕ) : Function.Injective (@qmaBufferedLaneColor C) := by + intro a b h + apply Fin.ext + have hh := congrArg Fin.val h + dsimp [qmaBufferedLaneColor] at hh + omega + +theorem qmaBufferedFanout_bounded (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + {C : ℕ} (hC : c 2 < C) (side : Fin 3 → Bool) (a : Fin 3) {z : ℕ × ℕ} + (hz : qmaBufferedFanoutSupport c side a z) : + 0 < z.1 ∧ z.1 < 8*(C+6) ∧ 0 < z.2 ∧ z.2 < 8*(C+6) := by + have h0 := qmaBufferedOffset_bounds c side 0 + have h1 := qmaBufferedOffset_bounds c side 1 + have h2 := qmaBufferedOffset_bounds c side 2 + dsimp [qmaBufferedPort] at h0 h1 h2 + fin_cases a <;> simp [qmaBufferedFanoutSupport,qmaBufferedPort,qmaBetween] at hz <;> omega + +theorem qmaBufferedCellPoint_cell (C : ℕ) (p z : ℕ × ℕ) + (hx : z.1 < 8*(C+6)) (hy : z.2 < 8*(C+6)) : + ((qmaBufferedCellPoint C p z).1/(8*(C+6)), + (qmaBufferedCellPoint C p z).2/(8*(C+6))) = p := by + have hw : 0 < 8*(C+6) := by omega + apply Prod.ext <;> dsimp [qmaBufferedCellPoint] + · rw [Nat.add_comm,Nat.add_mul_div_left _ _ hw,Nat.div_eq_of_lt hx,zero_add] + · rw [Nat.add_comm,Nat.add_mul_div_left _ _ hw,Nat.div_eq_of_lt hy,zero_add] + +theorem qmaBufferedCellPoint_disjoint {C : ℕ} {p q x y : ℕ × ℕ} (hpq : p ≠ q) + (hx : x.1 < 8*(C+6) ∧ x.2 < 8*(C+6)) + (hy : y.1 < 8*(C+6) ∧ y.2 < 8*(C+6)) : + qmaBufferedCellPoint C p x ≠ qmaBufferedCellPoint C q y := by + intro h + have hd := congrArg (fun z : ℕ × ℕ => (z.1/(8*(C+6)),z.2/(8*(C+6)))) h + rw [qmaBufferedCellPoint_cell C p x hx.1 hx.2,qmaBufferedCellPoint_cell C q y hy.1 hy.2] at hd + exact hpq hd + +theorem qmaBufferedEndpoint_alignment {C : ℕ} (p : ℕ × ℕ) (c : Fin 3 → ℕ) + (a : Fin 3) (hc : c a < C) : + qmaBufferedCellPoint C p (qmaBufferedPort c a,qmaBufferedPort c a) = + (8*(qmaLanePoint (qmaBufferedLaneColor ⟨c a,hc⟩) p).1, + 8*(qmaLanePoint (qmaBufferedLaneColor ⟨c a,hc⟩) p).2) := by + apply Prod.ext <;> dsimp [qmaBufferedCellPoint,qmaBufferedPort,qmaLanePoint,qmaBufferedLaneColor] <;> ring + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCongestion.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCongestion.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bdbbd694b36fc9a3a8c2918c04aff6f7324b557 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCongestion.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedIntersections + +namespace OAI + +/-! Away from graph vertices, at most two of the actual simple routes meet. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def armedAt (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) (z : ℕ × ℕ) : Prop := + ∃ (v : Fin M.n) (h : M.left e = v ∨ M.right e = v), M.endpointArmSupport hd v ⟨e,h⟩ z + +theorem armedAt_unique (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {e f : M.Term} {z : ℕ × ℕ} (hv : ∀ v, z ≠ M.placedVertex v) + (he : M.armedAt hd e z) (hf : M.armedAt hd f z) : e = f := by + obtain ⟨v,he,hes⟩ := he + obtain ⟨w,hf,hfs⟩ := hf + rcases M.endpointArmSupport_meet hA hd v w ⟨e,he⟩ ⟨f,hf⟩ hes hfs with h | h + · exact h + · exact (hv v h).elim + +theorem armedAt_avoids_crossing (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {e f g : M.Term} (hef : e ≠ f) {z : ℕ × ℕ} + (he : M.spacedSupport e z) (hf : M.spacedSupport f z) : ¬M.armedAt hd g z := by + rintro ⟨v,hg,hs⟩ + exact M.endpointArm_avoids_crossing hA hd v ⟨g,hg⟩ hef he hf hs + +theorem spaced_third_eq (hA : 0 < A) {e f g : M.Term} (hef : e ≠ f) {z : ℕ × ℕ} + (he : M.spacedSupport e z) (hf : M.spacedSupport f z) (hg : M.spacedSupport g z) : + g = e ∨ g = f := by + by_contra hn + have hge : g ≠ e := fun h => hn (Or.inl h) + have hgf : g ≠ f := fun h => hn (Or.inr h) + have hceg : M.spacedColor e ≠ M.spacedColor g := fun h => + Set.disjoint_left.mp (M.spaced_color_disjoint hA hge.symm h) he hg + have hcfg : M.spacedColor f ≠ M.spacedColor g := fun h => + Set.disjoint_left.mp (M.spaced_color_disjoint hA hgf.symm h) hf hg + have hcef : M.spacedColor e ≠ M.spacedColor f := fun h => + Set.disjoint_left.mp (M.spaced_color_disjoint hA hef h) he hf + rcases he with ⟨he,_⟩ | ⟨he,_⟩ <;> + rcases hf with ⟨hf,_⟩ | ⟨hf,_⟩ <;> rcases hg with ⟨hg,_⟩ | ⟨hg,_⟩ + all_goals first + | exact hcef (qmaHorizontalLane_color he hf) + | exact hcef (qmaVerticalLane_color he hf) + | exact hceg (qmaHorizontalLane_color he hg) + | exact hceg (qmaVerticalLane_color he hg) + | exact hcfg (qmaHorizontalLane_color hf hg) + | exact hcfg (qmaVerticalLane_color hf hg) + +theorem bufferedPath_arm_or_lane (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) {z : ℕ × ℕ} (he : z ∈ (M.bufferedPath hd e).val.support) : + M.armedAt hd e z ∨ M.spacedSupport e z := by + rcases M.bufferedPath_support hd e he with h | h | h + · exact Or.inl ⟨M.left e,Or.inl rfl,h⟩ + · exact Or.inr h + · exact Or.inl ⟨M.right e,Or.inr rfl,h⟩ + +theorem bufferedPath_third_eq (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {e f g : M.Term} (hef : e ≠ f) {z : ℕ × ℕ} (hv : ∀ v, z ≠ M.placedVertex v) + (he : z ∈ (M.bufferedPath hd e).val.support) + (hf : z ∈ (M.bufferedPath hd f).val.support) + (hg : z ∈ (M.bufferedPath hd g).val.support) : g = e ∨ g = f := by + by_contra hn + have hge : g ≠ e := fun h => hn (Or.inl h) + have hgf : g ≠ f := fun h => hn (Or.inr h) + rcases M.bufferedPath_arm_or_lane hd e he with he | he <;> + rcases M.bufferedPath_arm_or_lane hd f hf with hf | hf <;> + rcases M.bufferedPath_arm_or_lane hd g hg with hg | hg + · exact hef (M.armedAt_unique hA hd hv he hf) + · exact hef (M.armedAt_unique hA hd hv he hf) + · exact hge (M.armedAt_unique hA hd hv hg he) + · exact M.armedAt_avoids_crossing hA hd hgf.symm hf hg he + · exact hgf (M.armedAt_unique hA hd hv hg hf) + · exact M.armedAt_avoids_crossing hA hd hge.symm he hg hf + · exact M.armedAt_avoids_crossing hA hd hef he hf hg + · exact hn (M.spaced_third_eq hA hef he hf hg) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCounts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..826d33083c37c2227185acdbe9f452fe7806e9be --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedCounts.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedCongestion + +namespace OAI + +/-! The assembled simple paths have linearly many candidate crossing points. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def bufferedSites (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : Finset (ℕ × ℕ) := + (M.bufferedPath hd e).val.support.toFinset + +def bufferedAllSites (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : Finset (ℕ × ℕ) := + Finset.univ.biUnion (M.bufferedSites hd) + +theorem bufferedSites_card (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + (M.bufferedSites hd e).card ≤ 2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2)+1 := by + unfold bufferedSites + rw [List.toFinset_card_of_nodup (M.bufferedPath hd e).nodup_support, + SimpleGraph.Walk.length_support] + exact Nat.add_le_add_right (M.bufferedPath_length hd e) 1 + +theorem bufferedAllSites_card (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : + (M.bufferedAllSites hd).card ≤ + Fintype.card M.Term * (2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2)+1) := by + calc + _ ≤ ∑ e : M.Term, (M.bufferedSites hd e).card := Finset.card_biUnion_le + _ ≤ ∑ _e : M.Term, (2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2)+1) := + Finset.sum_le_sum (fun e _ => M.bufferedSites_card hd e) + _ = _ := by simp + +theorem bufferedSites_third_eq (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {e f g : M.Term} (hef : e ≠ f) {z : ℕ × ℕ} (hv : ∀ v, z ≠ M.placedVertex v) + (he : z ∈ M.bufferedSites hd e) (hf : z ∈ M.bufferedSites hd f) + (hg : z ∈ M.bufferedSites hd g) : g = e ∨ g = f := by + exact M.bufferedPath_third_eq hA hd hef hv + (List.mem_toFinset.mp he) (List.mem_toFinset.mp hf) (List.mem_toFinset.mp hg) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDetour.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDetour.lean new file mode 100644 index 0000000000000000000000000000000000000000..a153358c5b7f7c7e40d0623333891f4c54ab0fa3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDetour.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedDogleg + +namespace OAI + +/-! Explicit western detour for the third buffered endpoint arm. -/ + +namespace ContinuumCoulomb + +def qmaBufferedDetourPoint (u v k : ℕ) : ℕ × ℕ := + if k ≤ 8 then (17-k,17) + else if k ≤ u then (9,k+9) + else if k ≤ u+v-9 then (k-u+9,u+9) + else if k ≤ u+v then (v,2*u+v-k) + else (u,u) + +def qmaBufferedDetourSupport (u v : ℕ) (p : ℕ × ℕ) : Prop := + (p.2 = 17 ∧ 9 ≤ p.1 ∧ p.1 ≤ 17) ∨ + (p.1 = 9 ∧ 17 ≤ p.2 ∧ p.2 ≤ u+9) ∨ + (p.2 = u+9 ∧ 9 ≤ p.1 ∧ p.1 ≤ v) ∨ + (p.1 = v ∧ u ≤ p.2 ∧ p.2 ≤ u+9) ∨ + (p.2 = u ∧ qmaBetween v u p.1) + +theorem qmaBufferedDetour_zero (u v : ℕ) : qmaBufferedDetourPoint u v 0 = (17,17) := by + simp [qmaBufferedDetourPoint] + +theorem qmaBufferedDetour_last {u v : ℕ} (hu : 24 ≤ u) : qmaBufferedDetourPoint u v (u+v+1) = (u,u) := by + unfold qmaBufferedDetourPoint + by_cases h : u+v+1 ≤ 8 + · omega + · rw [ite_eq_right h,ite_eq_right (by omega),ite_eq_right (by omega),ite_eq_right (by omega)] + +theorem qmaBufferedDetour_support {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) (k : ℕ) : + qmaBufferedDetourSupport u v (qmaBufferedDetourPoint u v k) := by + unfold qmaBufferedDetourPoint + split_ifs <;> simp [qmaBufferedDetourSupport,qmaBetween] <;> omega + +theorem qmaBufferedDetour_step {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) + (hclose : u ≤ v+1 ∧ v ≤ u+1) (hne : u ≠ v) (k : ℕ) (hk : k < u+v+1) : + Nat.dist (qmaBufferedDetourPoint u v k).1 (qmaBufferedDetourPoint u v (k+1)).1+ + Nat.dist (qmaBufferedDetourPoint u v k).2 (qmaBufferedDetourPoint u v (k+1)).2 = 1 := by + unfold qmaBufferedDetourPoint + split_ifs <;> simp_all [Nat.dist] <;> omega + +theorem qmaBufferedDetour_injective {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) (hne : u ≠ v) : + Function.Injective (fun k : Fin (u+v+2) => qmaBufferedDetourPoint u v k.val) := by + intro k j h + have hk := k.isLt + have hj := j.isLt + apply Fin.ext + change qmaBufferedDetourPoint u v k.val = qmaBufferedDetourPoint u v j.val at h + unfold qmaBufferedDetourPoint at h + split_ifs at h <;> simp_all <;> omega + +theorem qmaBufferedFanout_detour_support (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (k : ℕ) : + qmaBufferedFanoutSupport c side 2 + (qmaBufferedDetourPoint (qmaBufferedPort c 2) (qmaBufferedOffset c side 2) k) := by + have hb := qmaBufferedOffset_bounds c side 2 + have hu : 24 ≤ qmaBufferedPort c 2 := by unfold qmaBufferedPort; omega + have hv : 23 ≤ qmaBufferedOffset c side 2 := by omega + have hs := qmaBufferedDetour_support hu hv k + have he : qmaBufferedPort c 2+9 = 8*(c 2+4)+1 := by unfold qmaBufferedPort; omega + simpa [qmaBufferedDetourSupport,qmaBufferedFanoutSupport,he] using hs + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDogleg.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDogleg.lean new file mode 100644 index 0000000000000000000000000000000000000000..185f31f84a78332898fc9a8d226acc0e2c9d282d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedDogleg.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedFanout + +namespace OAI + +/-! The two direct buffered endpoint arms, including their one-step joins. -/ + +namespace ContinuumCoulomb + +def qmaBufferedDoglegLength (u v : ℕ) : ℕ := (v-17)+(u-17)+1 + +def qmaBufferedDoglegPoint (u v k : ℕ) : ℕ × ℕ := + if k ≤ v-17 then (17+k,17) + else if k ≤ (v-17)+(u-17) then (v,17+(k-(v-17))) + else (u,u) + +def qmaBufferedDoglegSupport (u v : ℕ) (p : ℕ × ℕ) : Prop := + (p.2 = 17 ∧ 17 ≤ p.1 ∧ p.1 ≤ v) ∨ + (p.1 = v ∧ 17 ≤ p.2 ∧ p.2 ≤ u) ∨ + (p.2 = u ∧ qmaBetween v u p.1) + +theorem qmaBufferedDogleg_zero (u v : ℕ) : qmaBufferedDoglegPoint u v 0 = (17,17) := by + simp [qmaBufferedDoglegPoint] + +theorem qmaBufferedDogleg_last (u v : ℕ) : + qmaBufferedDoglegPoint u v (qmaBufferedDoglegLength u v) = (u,u) := by + unfold qmaBufferedDoglegPoint qmaBufferedDoglegLength + rw [ite_eq_right (by omega),ite_eq_right (by omega)] + +theorem qmaBufferedDogleg_support {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) (k : ℕ) : + qmaBufferedDoglegSupport u v (qmaBufferedDoglegPoint u v k) := by + unfold qmaBufferedDoglegPoint + split_ifs <;> simp [qmaBufferedDoglegSupport,qmaBetween] <;> omega + +theorem qmaBufferedDogleg_step {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) + (hclose : u ≤ v+1 ∧ v ≤ u+1) (hne : u ≠ v) (k : ℕ) + (hk : k < qmaBufferedDoglegLength u v) : + Nat.dist (qmaBufferedDoglegPoint u v k).1 (qmaBufferedDoglegPoint u v (k+1)).1+ + Nat.dist (qmaBufferedDoglegPoint u v k).2 (qmaBufferedDoglegPoint u v (k+1)).2 = 1 := by + unfold qmaBufferedDoglegPoint qmaBufferedDoglegLength at * + split_ifs <;> simp_all [Nat.dist] <;> omega + +theorem qmaBufferedDogleg_injective {u v : ℕ} (hu : 24 ≤ u) (hv : 23 ≤ v) (hne : u ≠ v) : + Function.Injective (fun k : Fin (qmaBufferedDoglegLength u v+1) => qmaBufferedDoglegPoint u v k.val) := by + intro k j h + have hk := k.isLt + have hj := j.isLt + apply Fin.ext + change qmaBufferedDoglegPoint u v k.val = qmaBufferedDoglegPoint u v j.val at h + unfold qmaBufferedDoglegPoint qmaBufferedDoglegLength at * + split_ifs at h <;> simp_all <;> omega + +theorem qmaBufferedDogleg_length_bound {u v U : ℕ} (hu : u ≤ U) (hv : v ≤ u+1) : + qmaBufferedDoglegLength u v ≤ 2*U+2 := by + unfold qmaBufferedDoglegLength + omega + +theorem qmaBufferedFanout_direct_support (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (k : ℕ) : + qmaBufferedFanoutSupport c side 0 + (qmaBufferedDoglegPoint (qmaBufferedPort c 0) (qmaBufferedOffset c side 0) k) := by + have hb := qmaBufferedOffset_bounds c side 0 + have hu : 24 ≤ qmaBufferedPort c 0 := by unfold qmaBufferedPort; omega + have hv : 23 ≤ qmaBufferedOffset c side 0 := by omega + exact qmaBufferedDogleg_support hu hv k + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedEndpointWalk.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedEndpointWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..22e8682b00671ec49d1bc7e2f5e274b50b832324 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedEndpointWalk.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedArms +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedLanes + +namespace OAI + +/-! Actual unit-step walks join the degree-three vertices through their separated lanes. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def routeVertex (v : Fin M.n) : ℕ × ℕ := + qmaFineGridNat (M.qubitSlots.site v) + +def placedVertex (v : Fin M.n) : ℕ × ℕ := + qmaBufferedCellPoint (9*B+3) (M.routeVertex v) (17,17) + +def endpointColors (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (v : Fin M.n) + (a : Fin 3) : ℕ := ((M.endpointPorts hd v).slot a).val + +theorem endpointColors_assigned (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : + M.endpointColors hd v ((M.endpointPorts hd v).assign e) = (M.laneColor e.val).val := + congrArg Fin.val ((M.endpointPorts hd v).aligned e) + +def endpointArmLength (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : ℕ := + qmaBufferedArmLength (M.endpointColors hd v) (fun _ => false) ((M.endpointPorts hd v).assign e) + +def endpointArmPoint (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) (k : ℕ) : ℕ × ℕ := + qmaBufferedCellPoint (9*B+3) (M.routeVertex v) + (qmaBufferedArmPoint (M.endpointColors hd v) (fun _ => false) ((M.endpointPorts hd v).assign e) k) + +@[simp] theorem endpointArm_zero (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : M.endpointArmPoint hd v e 0 = M.placedVertex v := by + simp [endpointArmPoint,placedVertex] + +@[simp] theorem endpointArm_last (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : + M.endpointArmPoint hd v e (M.endpointArmLength hd v e) = + qmaLanePoint (M.spacedColor e.val) (M.routeVertex v) := by + dsimp only [endpointArmPoint,endpointArmLength] + rw [qmaBufferedArm_last] + change qmaBufferedCellPoint (9*B+3) (M.routeVertex v) + (8*(M.endpointColors hd v ((M.endpointPorts hd v).assign e)+3), + 8*(M.endpointColors hd v ((M.endpointPorts hd v).assign e)+3)) = _ + rw [M.endpointColors_assigned] + exact (qmaSpacedEndpoint (M.routeVertex v) ((M.laneColor e.val).castAdd 3)).symm + +theorem endpointArm_step (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) (k : ℕ) (hk : k < M.endpointArmLength hd v e) : + qmaSquareGrid.Adj (M.endpointArmPoint hd v e k) (M.endpointArmPoint hd v e (k+1)) := by + have h := qmaBufferedArm_step (M.endpointColors hd v) (fun _ => false) + ((M.endpointPorts hd v).assign e) k hk + simpa only [endpointArmPoint,qmaBufferedCellPoint,qmaSquareGrid,Nat.dist_add_add_left] using h + +theorem endpointArm_length_bound (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : M.endpointArmLength hd v e ≤ 16*(9*B+6)+2 := + qmaBufferedArm_length_bound (M.endpointColors hd v) (fun _ => false) + (fun a => ((M.endpointPorts hd v).slot a).isLt) _ + +def endpointArmWalk (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : + qmaSquareGrid.Walk (M.placedVertex v) (qmaLanePoint (M.spacedColor e.val) (M.routeVertex v)) := + (qmaGridWalk (M.endpointArmPoint hd v e) (M.endpointArmLength hd v e) + (M.endpointArm_step hd v e)).copy (M.endpointArm_zero hd v e) (M.endpointArm_last hd v e) + +@[simp] theorem endpointArmWalk_length (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) : + (M.endpointArmWalk hd v e).length = M.endpointArmLength hd v e := by + simp [endpointArmWalk,SimpleGraph.Walk.length_copy,qmaGridWalk_length] + +def spacedWalk (e : M.Term) : + qmaSquareGrid.Walk (qmaLanePoint (M.spacedColor e) (M.routeVertex (M.left e))) + (qmaLanePoint (M.spacedColor e) (M.routeVertex (M.right e))) := + let p := qmaLanePoint (M.spacedColor e) (M.routeVertex (M.left e)) + let q := qmaLanePoint (M.spacedColor e) (M.routeVertex (M.right e)) + (qmaGridWalk (qmaManhattanPoint p q) (qmaManhattanLength p q) + (qmaManhattanPoint_adj p q)).copy (qmaManhattanPoint_zero p q) (qmaManhattanPoint_last p q) + +theorem spacedWalk_length (e : M.Term) : (M.spacedWalk e).length ≤ 8*(9*B+9)*(3*A+2) := by + dsimp only [spacedWalk] + rw [SimpleGraph.Walk.length_copy,qmaGridWalk_length] + exact M.spaced_length e + +def bufferedWalk (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + qmaSquareGrid.Walk (M.placedVertex (M.left e)) (M.placedVertex (M.right e)) := + ((M.endpointArmWalk hd (M.left e) ⟨e,Or.inl rfl⟩).append (M.spacedWalk e)).append + (M.endpointArmWalk hd (M.right e) ⟨e,Or.inr rfl⟩).reverse + +theorem bufferedWalk_length (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + (M.bufferedWalk hd e).length ≤ 2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2) := by + have hl := M.endpointArm_length_bound hd (M.left e) ⟨e,Or.inl rfl⟩ + have hr := M.endpointArm_length_bound hd (M.right e) ⟨e,Or.inr rfl⟩ + have hg := M.spacedWalk_length e + simp only [bufferedWalk,SimpleGraph.Walk.length_append,SimpleGraph.Walk.length_reverse, + endpointArmWalk_length] + omega + +def bufferedPath (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + qmaSquareGrid.Path (M.placedVertex (M.left e)) (M.placedVertex (M.right e)) := + (M.bufferedWalk hd e).toPath + +theorem bufferedPath_length (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + (M.bufferedPath hd e).val.length ≤ 2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2) := + ((M.bufferedWalk hd e).length_bypass_le_length).trans (M.bufferedWalk_length hd e) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedExtent.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedExtent.lean new file mode 100644 index 0000000000000000000000000000000000000000..3da7420f044977ee5495dbd6859e6ac855997042 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedExtent.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedCounts +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedBounds + +namespace OAI + +/-! Explicit rectangular bounds for every vertex and every buffered route. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaCellCoordinate_lt {W x X z : ℕ} (hx : x < X) (hz : z < W) : + W*x+z < W*X := by + calc + W*x+z < W*x+W := Nat.add_lt_add_left hz _ + _ = W*(x+1) := by ring + _ ≤ W*X := Nat.mul_le_mul_left W (by omega) + +theorem qmaManhattanSupport_rectangle {p q z : ℕ × ℕ} {X Y : ℕ} + (hp : p.1 < X ∧ p.2 < Y) (hq : q.1 < X ∧ q.2 < Y) + (hz : qmaManhattanSupport p q z) : z.1 < X ∧ z.2 < Y := by + rcases hz with ⟨hy,hx⟩ | ⟨hx,hy⟩ <;> unfold qmaBetween at * <;> omega + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def bufferedWidth : ℕ := 8*(9*B+9)*((M.rows+1)*A) +def bufferedHeight : ℕ := 8*(9*B+9)*(M.width+1) + +theorem routeVertex_bounds (v : Fin M.n) : + (M.routeVertex v).1 < (M.rows+1)*A ∧ (M.routeVertex v).2 < M.width+1 := + ⟨(M.qubitSlots.site v).1.isLt,(M.qubitSlots.site v).2.isLt⟩ + +theorem placedVertex_bounds (v : Fin M.n) : + (M.placedVertex v).1 < M.bufferedWidth ∧ (M.placedVertex v).2 < M.bufferedHeight := by + have hb := M.routeVertex_bounds v + exact ⟨qmaCellCoordinate_lt hb.1 (by omega),qmaCellCoordinate_lt hb.2 (by omega)⟩ + +theorem endpointArmSupport_bounds (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {z : ℕ × ℕ} (hz : M.endpointArmSupport hd v e z) : + z.1 < M.bufferedWidth ∧ z.2 < M.bufferedHeight := by + obtain ⟨p,hp,hs⟩ := hz + have hb := M.routeVertex_bounds v + have hs' := qmaBufferedFanout_bounded (M.endpointColors hd v) + ((M.endpointPorts hd v).increasing (show (0 : Fin 3) < 1 by decide)) + ((M.endpointPorts hd v).increasing (show (1 : Fin 3) < 2 by decide)) + ((M.endpointPorts hd v).slot 2).isLt (fun _ => false) _ hs + rw [← hp] + exact ⟨qmaCellCoordinate_lt hb.1 hs'.2.1,qmaCellCoordinate_lt hb.2 hs'.2.2.2⟩ + +theorem spacedSupport_bounds (e : M.Term) {z : ℕ × ℕ} (hz : M.spacedSupport e z) : + z.1 < M.bufferedWidth ∧ z.2 < M.bufferedHeight := by + have bound (v : Fin M.n) : + (qmaLanePoint (M.spacedColor e) (M.routeVertex v)).1 < M.bufferedWidth ∧ + (qmaLanePoint (M.spacedColor e) (M.routeVertex v)).2 < M.bufferedHeight := by + have hb := M.routeVertex_bounds v + exact ⟨qmaCellCoordinate_lt hb.1 (M.spacedColor e).isLt, + qmaCellCoordinate_lt hb.2 (M.spacedColor e).isLt⟩ + exact qmaManhattanSupport_rectangle (bound (M.left e)) (bound (M.right e)) hz + +theorem bufferedPath_bounds (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) {z : ℕ × ℕ} (hz : z ∈ (M.bufferedPath hd e).val.support) : + z.1 < M.bufferedWidth ∧ z.2 < M.bufferedHeight := by + rcases M.bufferedPath_support hd e hz with h | h | h + · exact M.endpointArmSupport_bounds hd _ _ h + · exact M.spacedSupport_bounds e h + · exact M.endpointArmSupport_bounds hd _ _ h + +def routedVertices (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : Finset (ℕ × ℕ) := + (Finset.univ.image M.placedVertex) ∪ M.bufferedAllSites hd + +theorem routedVertices_bounds (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {z : ℕ × ℕ} (hz : z ∈ M.routedVertices hd) : + z.1 < M.bufferedWidth ∧ z.2 < M.bufferedHeight := by + rcases Finset.mem_union.mp hz with h | h + · obtain ⟨v,_,rfl⟩ := Finset.mem_image.mp h + exact M.placedVertex_bounds v + · obtain ⟨e,_,he⟩ := Finset.mem_biUnion.mp h + exact M.bufferedPath_bounds hd e (List.mem_toFinset.mp he) + +theorem routedVertices_card (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : + (M.routedVertices hd).card ≤ M.n+ + Fintype.card M.Term*(2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2)+1) := by + exact (Finset.card_union_le _ _).trans (Nat.add_le_add + ((Finset.card_image_le).trans_eq (by simp)) (M.bufferedAllSites_card hd)) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedFanout.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedFanout.lean new file mode 100644 index 0000000000000000000000000000000000000000..19a43f9f9ec861019d049c3eafe7035ee8c553fe --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedFanout.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFanoutPorts + +namespace OAI + +/-! Endpoint arms offset from all global grid lines, with a one-step terminal join. -/ + +namespace ContinuumCoulomb + +def qmaBufferedPort (c : Fin 3 → ℕ) (a : Fin 3) : ℕ := 8*(c a+3) +def qmaBufferedOffset (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : ℕ := + if side a then qmaBufferedPort c a+1 else qmaBufferedPort c a-1 + +theorem qmaBufferedOffset_bounds (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedPort c a ≤ qmaBufferedOffset c side a+1 ∧ + qmaBufferedOffset c side a ≤ qmaBufferedPort c a+1 := by + unfold qmaBufferedOffset + split_ifs <;> omega + +theorem qmaBufferedOffset_not_grid (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) (u : ℕ) : + qmaBufferedOffset c side a ≠ 8*u := by + unfold qmaBufferedOffset qmaBufferedPort + split_ifs <;> omega + +def qmaBufferedFanoutSupport (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) (p : ℕ × ℕ) : Prop := + if a = 0 then + (p.2 = 17 ∧ 17 ≤ p.1 ∧ p.1 ≤ qmaBufferedOffset c side 0) ∨ + (p.1 = qmaBufferedOffset c side 0 ∧ 17 ≤ p.2 ∧ p.2 ≤ qmaBufferedPort c 0) ∨ + (p.2 = qmaBufferedPort c 0 ∧ qmaBetween (qmaBufferedOffset c side 0) (qmaBufferedPort c 0) p.1) + else if a = 1 then + (p.1 = 17 ∧ 17 ≤ p.2 ∧ p.2 ≤ qmaBufferedOffset c side 1) ∨ + (p.2 = qmaBufferedOffset c side 1 ∧ 17 ≤ p.1 ∧ p.1 ≤ qmaBufferedPort c 1) ∨ + (p.1 = qmaBufferedPort c 1 ∧ qmaBetween (qmaBufferedOffset c side 1) (qmaBufferedPort c 1) p.2) + else + (p.2 = 17 ∧ 9 ≤ p.1 ∧ p.1 ≤ 17) ∨ + (p.1 = 9 ∧ 17 ≤ p.2 ∧ p.2 ≤ 8*(c 2+4)+1) ∨ + (p.2 = 8*(c 2+4)+1 ∧ 9 ≤ p.1 ∧ p.1 ≤ qmaBufferedOffset c side 2) ∨ + (p.1 = qmaBufferedOffset c side 2 ∧ qmaBufferedPort c 2 ≤ p.2 ∧ p.2 ≤ 8*(c 2+4)+1) ∨ + (p.2 = qmaBufferedPort c 2 ∧ qmaBetween (qmaBufferedOffset c side 2) (qmaBufferedPort c 2) p.1) + +theorem qmaBufferedFanout_center (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedFanoutSupport c side a (17,17) := by + have h := qmaBufferedOffset_bounds c side a + fin_cases a <;> simp [qmaBufferedFanoutSupport] <;> dsimp [qmaBufferedPort] at h <;> omega + +theorem qmaBufferedFanout_port (c : Fin 3 → ℕ) (side : Fin 3 → Bool) (a : Fin 3) : + qmaBufferedFanoutSupport c side a (qmaBufferedPort c a,qmaBufferedPort c a) := by + fin_cases a <;> simp [qmaBufferedFanoutSupport,qmaBetween] + +theorem qmaBufferedFanout_only_center (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + (side : Fin 3 → Bool) {a b : Fin 3} (hab : a ≠ b) {p : ℕ × ℕ} + (ha : qmaBufferedFanoutSupport c side a p) (hb : qmaBufferedFanoutSupport c side b p) : p = (17,17) := by + have h0 := qmaBufferedOffset_bounds c side 0 + have h1 := qmaBufferedOffset_bounds c side 1 + have h2 := qmaBufferedOffset_bounds c side 2 + dsimp [qmaBufferedPort] at h0 h1 h2 + rcases p with ⟨x,y⟩ + fin_cases a <;> fin_cases b <;> + simp [qmaBufferedFanoutSupport,qmaBufferedPort,qmaBetween] at ha hb hab ⊢ <;> omega + +theorem qmaBufferedFanout_grid_point (c : Fin 3 → ℕ) (side : Fin 3 → Bool) + (a : Fin 3) (u v : ℕ) (h : qmaBufferedFanoutSupport c side a (8*u,8*v)) : + (8*u,8*v) = (qmaBufferedPort c a,qmaBufferedPort c a) := by + have h0 := qmaBufferedOffset_bounds c side 0 + have h1 := qmaBufferedOffset_bounds c side 1 + have h2 := qmaBufferedOffset_bounds c side 2 + have h0x := qmaBufferedOffset_not_grid c side 0 u + have h1y := qmaBufferedOffset_not_grid c side 1 v + have h2x := qmaBufferedOffset_not_grid c side 2 u + dsimp [qmaBufferedPort] at h0 h1 h2 ⊢ + fin_cases a <;> simp [qmaBufferedFanoutSupport,qmaBufferedPort,qmaBetween] at h ⊢ <;> omega + +theorem qmaBufferedStub_avoids_outgoing (c : Fin 3 → ℕ) (side : Fin 3 → Bool) + (a : Fin 3) (x : ℕ) + (hx : qmaBetween (qmaBufferedOffset c side a) (qmaBufferedPort c a) x) + (hout : if side a then x ≤ qmaBufferedPort c a else qmaBufferedPort c a ≤ x) : + x = qmaBufferedPort c a := by + unfold qmaBufferedOffset qmaBetween at hx + split_ifs at hx hout <;> omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedGridEdge.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedGridEdge.lean new file mode 100644 index 0000000000000000000000000000000000000000..90a6b97201ede00695726f38249587a279996313 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedGridEdge.lean @@ -0,0 +1,31 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedArms + +namespace OAI + +/-! An arm can overlap a grid-aligned unit edge only at its terminal grid point. -/ + +namespace ContinuumCoulomb + +theorem qmaBufferedFanout_horizontal_grid_edge (c : Fin 3 → ℕ) (a : Fin 3) + {p q : ℕ × ℕ} (hp : qmaBufferedFanoutSupport c (fun _ => false) a p) + (hq : qmaBufferedFanoutSupport c (fun _ => false) a q) + (hy : p.2 = q.2) (hm : p.2 % 8 = 0) (hd : Nat.dist p.1 q.1 = 1) : + p.1 % 8 = 0 ∨ q.1 % 8 = 0 := by + rcases p with ⟨x,y⟩ + rcases q with ⟨u,v⟩ + fin_cases a <;> + simp [qmaBufferedFanoutSupport,qmaBufferedOffset,qmaBufferedPort,qmaBetween,Nat.dist] at * <;> omega + +theorem qmaBufferedFanout_vertical_grid_edge (c : Fin 3 → ℕ) (a : Fin 3) + {p q : ℕ × ℕ} (hp : qmaBufferedFanoutSupport c (fun _ => false) a p) + (hq : qmaBufferedFanoutSupport c (fun _ => false) a q) + (hx : p.1 = q.1) (hm : p.1 % 8 = 0) (hd : Nat.dist p.2 q.2 = 1) : + p.2 % 8 = 0 ∨ q.2 % 8 = 0 := by + rcases p with ⟨x,y⟩ + rcases q with ⟨u,v⟩ + fin_cases a <;> + simp [qmaBufferedFanoutSupport,qmaBufferedOffset,qmaBufferedPort,qmaBetween,Nat.dist] at * <;> omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedIntersections.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedIntersections.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7440f6b736856dd3e478809e19c243577aaa358 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedIntersections.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedSupport + +namespace OAI + +/-! Buffered arms are mutually disjoint away from their common graph vertex. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaBufferedCellPoint_injective (C : ℕ) (p : ℕ × ℕ) : + Function.Injective (qmaBufferedCellPoint C p) := by + intro x y h + apply Prod.ext + · exact Nat.add_left_cancel (congrArg Prod.fst h) + · exact Nat.add_left_cancel (congrArg Prod.snd h) + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem endpointLocal_bounds (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (a : Fin 3) {p : ℕ × ℕ} + (hs : qmaBufferedFanoutSupport (M.endpointColors hd v) (fun _ => false) a p) : + 0 < p.1 ∧ p.1 < 8*(9*B+9) ∧ 0 < p.2 ∧ p.2 < 8*(9*B+9) := + qmaBufferedFanout_bounded (M.endpointColors hd v) + ((M.endpointPorts hd v).increasing (show (0 : Fin 3) < 1 by decide)) + ((M.endpointPorts hd v).increasing (show (1 : Fin 3) < 2 by decide)) + ((M.endpointPorts hd v).slot 2).isLt (fun _ => false) a hs + +theorem endpointArmSupport_meet (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v w : Fin M.n) (e : M.Incident v) (f : M.Incident w) {z : ℕ × ℕ} + (he : M.endpointArmSupport hd v e z) (hf : M.endpointArmSupport hd w f z) : + e.val = f.val ∨ z = M.placedVertex v := by + obtain ⟨p,hp,hps⟩ := he + obtain ⟨q,hq,hqs⟩ := hf + have hpb := M.endpointLocal_bounds hd v _ hps + have hqb := M.endpointLocal_bounds hd w _ hqs + have heq := hp.trans hq.symm + have hvw : v = w := by + apply M.routeVertex_injective + by_contra hn + exact qmaBufferedCellPoint_disjoint hn ⟨hpb.2.1,hpb.2.2.2⟩ ⟨hqb.2.1,hqb.2.2.2⟩ heq + subst w + have hpq := qmaBufferedCellPoint_injective (9*B+3) (M.routeVertex v) heq + subst q + by_cases hef : e.val = f.val + · exact Or.inl hef + · have ha : (M.endpointPorts hd v).assign e ≠ (M.endpointPorts hd v).assign f := by + intro h + exact hef (congrArg Subtype.val (M.endpointPorts_assign_injective hA hd v h)) + have hc := qmaBufferedFanout_only_center (M.endpointColors hd v) + ((M.endpointPorts hd v).increasing (show (0 : Fin 3) < 1 by decide)) + ((M.endpointPorts hd v).increasing (show (1 : Fin 3) < 2 by decide)) + (fun _ => false) ha hps hqs + exact Or.inr (hp.symm.trans (congrArg (qmaBufferedCellPoint (9*B+3) (M.routeVertex v)) hc)) + +theorem endpointArmSupport_grid (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {z : ℕ × ℕ} + (he : M.endpointArmSupport hd v e z) (hz : z.1 % 8 = 0 ∧ z.2 % 8 = 0) : + z = qmaLanePoint (M.spacedColor e.val) (M.routeVertex v) := by + obtain ⟨p,hp,hs⟩ := he + have hx : p.1 % 8 = 0 := by + have h := congrArg (fun z : ℕ × ℕ => z.1 % 8) hp + simpa [qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hz.1] using h + have hy : p.2 % 8 = 0 := by + have h := congrArg (fun z : ℕ × ℕ => z.2 % 8) hp + simpa [qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hz.2] using h + have hx' : 8*(p.1/8) = p.1 := by omega + have hy' : 8*(p.2/8) = p.2 := by omega + have hg := qmaBufferedFanout_grid_point (M.endpointColors hd v) (fun _ => false) + ((M.endpointPorts hd v).assign e) (p.1/8) (p.2/8) (by simpa only [hx',hy'] using hs) + have hg' : p = (qmaBufferedPort (M.endpointColors hd v) ((M.endpointPorts hd v).assign e), + qmaBufferedPort (M.endpointColors hd v) ((M.endpointPorts hd v).assign e)) := by + simpa only [hx',hy'] using hg + rw [hg'] at hp + have halign := M.endpointArm_last hd v e + simp only [endpointArmPoint,endpointArmLength,qmaBufferedArm_last] at halign + exact hp.symm.trans halign + +theorem spaced_crossing_grid (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (he : M.spacedSupport e z) (hf : M.spacedSupport f z) : + z.1 % 8 = 0 ∧ z.2 % 8 = 0 := by + have hc : M.spacedColor e ≠ M.spacedColor f := fun h => + Set.disjoint_left.mp (M.spaced_color_disjoint hA hef h) he hf + rcases qmaLaneSupport_transverse hc he hf with ⟨hy,hx⟩ | ⟨hx,hy⟩ + all_goals + constructor + · rw [hx] + simp [spacedColor,qmaSpacedLaneColor,Nat.add_mod,Nat.mul_mod] + · rw [hy] + simp [spacedColor,qmaSpacedLaneColor,Nat.add_mod,Nat.mul_mod] + +theorem endpointArm_avoids_crossing (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (g : M.Incident v) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (he : M.spacedSupport e z) (hf : M.spacedSupport f z) : + ¬M.endpointArmSupport hd v g z := by + intro hg + exact M.spaced_crossing_not_vertex hA hef he hf g.val (M.routeVertex v) + (M.endpointArmSupport_grid hd v g hg (M.spaced_crossing_grid hA hef he hf)) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedLanes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedLanes.lean new file mode 100644 index 0000000000000000000000000000000000000000..7832c8d816eaf0b13432cbb74f87c3a5387cd29d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedLanes.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEndpointPorts + +namespace OAI + +/-! Eightfold lane spacing leaves room for the buffered endpoint arms. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaSpacedLaneColor {C : ℕ} (c : Fin C) : Fin (8*(C+6)) := ⟨8*(c.val+3),by omega⟩ + +theorem qmaSpacedLaneColor_injective (C : ℕ) : Function.Injective (@qmaSpacedLaneColor C) := by + intro a b h + apply Fin.ext + have hh := congrArg Fin.val h + dsimp [qmaSpacedLaneColor] at hh + omega + +theorem qmaSpacedEndpoint {C : ℕ} (p : ℕ × ℕ) (c : Fin C) : + qmaLanePoint (qmaSpacedLaneColor c) p = + qmaBufferedCellPoint C p (8*(c.val+3),8*(c.val+3)) := by + apply Prod.ext <;> dsimp [qmaSpacedLaneColor,qmaLanePoint,qmaBufferedCellPoint] + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def spacedColor (e : M.Term) : Fin (8*(9*B+9)) := + qmaSpacedLaneColor ((M.laneColor e).castAdd 3) + +def spacedSupport (e : M.Term) (z : ℕ × ℕ) : Prop := + qmaLaneSupport (M.spacedColor e) (qmaFineGridNat (M.routeLeft e)) + (qmaFineGridNat (M.routeRight e)) z + +theorem spacedColor_eq {e f : M.Term} (h : M.spacedColor e = M.spacedColor f) : + M.laneColor e = M.laneColor f := by + have hc := qmaSpacedLaneColor_injective (9*B+3) h + apply Fin.ext + exact congrArg (fun c : Fin (9*B+3) => c.val) hc + +theorem spaced_color_disjoint (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + (hcolor : M.spacedColor e = M.spacedColor f) : + Disjoint {z | M.spacedSupport e z} {z | M.spacedSupport f z} := by + have hc := M.spacedColor_eq hcolor + have hd := M.routes_of_color_disjoint hA hef ((qmaGridColorEquiv B).injective hc) + have hs : Disjoint + {z | qmaManhattanSupport (qmaFineGridNat (M.routeLeft e)) (qmaFineGridNat (M.routeRight e)) z} + {z | qmaManhattanSupport (qmaFineGridNat (M.routeLeft f)) (qmaFineGridNat (M.routeRight f)) z} := by + apply Set.disjoint_left.mpr + intro z he hf + obtain ⟨u,hu,huz⟩ := (qmaFineRouteSites_nat _ _ z).mp he + obtain ⟨v,hv,hvz⟩ := (qmaFineRouteSites_nat _ _ z).mp hf + have huv := qmaFineGridNat_injective (huz.trans hvz.symm) + subst v + exact Finset.disjoint_left.mp hd hu hv + change Disjoint {z | qmaLaneSupport (M.spacedColor e) _ _ z} + {z | qmaLaneSupport (M.spacedColor f) _ _ z} + rw [← hcolor] + exact qmaLaneSupport_disjoint _ hs + +theorem spaced_length (e : M.Term) : + qmaManhattanLength (qmaLanePoint (M.spacedColor e) (qmaFineGridNat (M.routeLeft e))) + (qmaLanePoint (M.spacedColor e) (qmaFineGridNat (M.routeRight e))) ≤ + 8*(9*B+9)*(3*A+2) := by + rw [qmaLane_length] + exact Nat.mul_le_mul_left _ (M.routeLength_bound e) + +theorem spaced_crossing_not_vertex (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (he : M.spacedSupport e z) (hf : M.spacedSupport f z) + (g : M.Term) (p : ℕ × ℕ) : z ≠ qmaLanePoint (M.spacedColor g) p := by + have hc : M.spacedColor e ≠ M.spacedColor f := fun h => + Set.disjoint_left.mp (M.spaced_color_disjoint hA hef h) he hf + exact qmaLaneSupport_crossing_not_vertex hc he hf _ p + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedListProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedListProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..70d403a287f8f333606079e7a35cdf8660a4380d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedListProgram.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpacedListProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumWalkErasureProgram + +namespace OAI + +/-! Literal construction and loop erasure of the complete buffered route. +The input consists of two computed fine-grid endpoints, one lane color and +the two computed incident port ranks. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumBufferedListProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +abbrev Input := (Pair × Pair) × (ℕ × (ℕ × ℕ)) +def inputCode : Input → List Bool := + prodCode (prodCode pairCode pairCode) (prodCode unaryCode (prodCode unaryCode unaryCode)) + +def value (A B : ℕ) (x : Input) : List Pair := + QuantumEndpointListProgram.value B (x.1.1,x.2.2.1,x.2.1) ++ + (QuantumSpacedListProgram.value A B (x.2.1,x.1.1,x.1.2)).tail ++ + (QuantumEndpointListProgram.value B (x.1.2,x.2.2.2,x.2.1)).reverse.tail + +noncomputable def program (A B : ℕ) : Procedure inputCode (listCode pairCode) (value A B) := by + let ends := Procedure.first (prodCode pairCode pairCode) (prodCode unaryCode (prodCode unaryCode unaryCode)) + let nums := Procedure.second (prodCode pairCode pairCode) (prodCode unaryCode (prodCode unaryCode unaryCode)) + let left := (Procedure.first pairCode pairCode).comp ends + let right := (Procedure.second pairCode pairCode).comp ends + let lane := (Procedure.first unaryCode (prodCode unaryCode unaryCode)).comp nums + let ports := (Procedure.second unaryCode (prodCode unaryCode unaryCode)).comp nums + let la := (Procedure.first unaryCode unaryCode).comp ports + let ra := (Procedure.second unaryCode unaryCode).comp ports + let leftArm := (QuantumEndpointListProgram.program B).comp (left.pair (la.pair lane)) + let rightArm := (QuantumEndpointListProgram.program B).comp (right.pair (ra.pair lane)) + let middle := (Procedure.listTail pairCode).comp + ((QuantumSpacedListProgram.program A B).comp (lane.pair (left.pair right))) + let last := (Procedure.listTail pairCode).comp ((Procedure.listReverse pairCode (0,0)).comp rightArm) + let append := Procedure.listAppend pairCode (0,0) + exact append.comp ((append.comp (leftArm.pair middle)).pair last) + +def actualInput {A B : ℕ} (M : QMASpatialExchangeModel A B) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : Input := + ((M.routeVertex (M.left e),M.routeVertex (M.right e)), + (M.laneColor e).val, + ((M.endpointPorts hd (M.left e)).assign ⟨e,Or.inl rfl⟩).val, + ((M.endpointPorts hd (M.right e)).assign ⟨e,Or.inr rfl⟩).val) + +theorem value_actual {A B : ℕ} (M : QMASpatialExchangeModel A B) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + value A B (actualInput M hd e) = M.bufferedList hd e := by + unfold value actualInput + rw [QuantumEndpointListProgram.value_actual,QuantumSpacedListProgram.value_actual, + QuantumEndpointListProgram.value_actual] + rfl + +def path (A B : ℕ) (x : Input) : List Pair := QuantumWalkErasure.erase (value A B x) + +noncomputable def pathProgram (A B : ℕ) : Procedure inputCode (listCode pairCode) (path A B) := + QuantumWalkErasure.cellProgram.comp (program A B) + +theorem path_actual {A B : ℕ} (M : QMASpatialExchangeModel A B) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + path A B (actualInput M hd e) = (M.bufferedPath hd e).val.support := by + rw [path,value_actual,M.bufferedPath_support_list] + +end ContinuumCoulomb.QuantumBufferedListProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedNodes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedNodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea0ae42a53f2654f50ade151a6531205748021ed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedNodes.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedExtent +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPorts + +namespace OAI + +/-! Finite coordinate arrays for every assembled simple route. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def bufferedNode (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : Fin ((M.bufferedPath hd e).val.length+1)) : ℕ × ℕ := + (M.bufferedPath hd e).val.getVert i.val + +theorem bufferedNode_injective (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + Function.Injective (M.bufferedNode hd e) := by + intro i j h + apply Fin.ext + exact (M.bufferedPath hd e).property.getVert_injOn + (show i.val ≤ (M.bufferedPath hd e).val.length by omega) + (show j.val ≤ (M.bufferedPath hd e).val.length by omega) h + +@[simp] theorem bufferedNode_zero (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + M.bufferedNode hd e 0 = M.placedVertex (M.left e) := + SimpleGraph.Walk.getVert_zero _ + +@[simp] theorem bufferedNode_last (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + M.bufferedNode hd e (Fin.last (M.bufferedPath hd e).val.length) = M.placedVertex (M.right e) := + SimpleGraph.Walk.getVert_length _ + +theorem bufferedNode_step (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : Fin (M.bufferedPath hd e).val.length) : + qmaSquareGrid.Adj (M.bufferedNode hd e i.castSucc) (M.bufferedNode hd e i.succ) := + qmaGridPath_getVert_step (M.bufferedPath hd e) i + +theorem bufferedNode_bounds (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : Fin ((M.bufferedPath hd e).val.length+1)) : + (M.bufferedNode hd e i).1 < M.bufferedWidth ∧ (M.bufferedNode hd e i).2 < M.bufferedHeight := + M.bufferedPath_bounds hd e ((M.bufferedPath hd e).val.getVert_mem_support i.val) + +def bufferedGridNode (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : Fin ((M.bufferedPath hd e).val.length+1)) : Fin M.bufferedWidth × Fin M.bufferedHeight := + (⟨(M.bufferedNode hd e i).1,(M.bufferedNode_bounds hd e i).1⟩, + ⟨(M.bufferedNode hd e i).2,(M.bufferedNode_bounds hd e i).2⟩) + +theorem bufferedNode_mem (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : Fin ((M.bufferedPath hd e).val.length+1)) : M.bufferedNode hd e i ∈ M.routedVertices hd := by + apply Finset.mem_union.mpr + right + apply Finset.mem_biUnion.mpr + refine ⟨e,Finset.mem_univ _,?_⟩ + exact List.mem_toFinset.mpr ((M.bufferedPath hd e).val.getVert_mem_support i.val) + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortChain.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortChain.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0d5f616ad1d09f9559e718b41d3fb88ea0c8fc3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortChain.lean @@ -0,0 +1,156 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortRouteData +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedNodes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedSharedEdge +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutedSubdivision + +namespace OAI + +/-! The actual bounded spatial routes give distinct physical spin locations at every +cell port, including cells at which two coarse routes cross. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +abbrev exchangeGraph : QMARationalExchangeGraph where + n := M.n + Edge := M.Term + left := M.left + right := M.right + distinct := M.distinct + weight := M.weight + constant := M.constant + +@[simp] theorem exchangeGraph_energy : M.exchangeGraph.energy = M.energy := rfl + +def coarseRoute (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) (i : ℕ) : ℕ × ℕ := + (M.bufferedPath hd e).val.getVert i + +def coarseLength (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : ℕ := + (M.bufferedPath hd e).val.length + +theorem coarseLength_pos (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + 0 < M.coarseLength hd e := by + by_contra h + have hz : (M.bufferedPath hd e).val.length = 0 := by exact Nat.eq_zero_of_not_pos h + have he := (M.bufferedPath hd e).val.getVert_length + rw [hz,SimpleGraph.Walk.getVert_zero] at he + exact M.distinct e (M.placedVertex_injective he) + +@[simp] theorem coarseRoute_zero (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + M.coarseRoute hd e 0 = M.placedVertex (M.left e) := SimpleGraph.Walk.getVert_zero _ + +@[simp] theorem coarseRoute_last (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + M.coarseRoute hd e (M.coarseLength hd e) = M.placedVertex (M.right e) := + SimpleGraph.Walk.getVert_length _ + +theorem coarseRoute_step (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) + (i : ℕ) (hi : i < M.coarseLength hd e) : + qmaSquareGrid.Adj (M.coarseRoute hd e i) (M.coarseRoute hd e (i+1)) := + qmaGridPath_getVert_step (M.bufferedPath hd e) ⟨i,hi⟩ + +theorem coarseRoute_positive (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (i : ℕ) : 0 < (M.coarseRoute hd e i).1 ∧ 0 < (M.coarseRoute hd e i).2 := + M.bufferedPath_positive hd e ((M.bufferedPath hd e).val.getVert_mem_support i) + +theorem coarseRoute_simple (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (i j : ℕ) (hi : i ≤ M.coarseLength hd e) (hj : j ≤ M.coarseLength hd e) + (he : M.coarseRoute hd e i = M.coarseRoute hd e j) : i = j := + (M.bufferedPath hd e).property.getVert_injOn hi hj he + +theorem coarseRoute_edges_disjoint (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {e f : M.Term} (hef : e ≠ f) + (i j : ℕ) (hi : i < M.coarseLength hd e) (hj : j < M.coarseLength hd f) : + ¬(M.coarseRoute hd e i = M.coarseRoute hd f j ∧ + M.coarseRoute hd e (i+1) = M.coarseRoute hd f (j+1)) ∧ + ¬(M.coarseRoute hd e i = M.coarseRoute hd f (j+1) ∧ + M.coarseRoute hd e (i+1) = M.coarseRoute hd f j) := by + have he : s(M.coarseRoute hd e i,M.coarseRoute hd e (i+1)) ∈ (M.bufferedPath hd e).val.edges := + ((M.bufferedPath hd e).val.mk_mem_edges_iff_exists).mpr ⟨i,hi,rfl⟩ + have hf : s(M.coarseRoute hd f j,M.coarseRoute hd f (j+1)) ∈ (M.bufferedPath hd f).val.edges := + ((M.bufferedPath hd f).val.mk_mem_edges_iff_exists).mpr ⟨j,hj,rfl⟩ + constructor + · rintro ⟨h1,h2⟩ + rw [h1,h2] at he + exact M.bufferedPath_no_shared_edge hA hd hef he hf + · rintro ⟨h1,h2⟩ + rw [h1,h2,Sym2.eq_swap] at he + exact M.bufferedPath_no_shared_edge hA hd hef he hf + +abbrev portSchedule (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : QMAPathSchedule where + graph := M.exchangeGraph + work := M.coarseLength hd + +def portGraph (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : SimpleGraph (ℕ × ℕ) := + SimpleGraph.fromRel (fun x y => ∃ (e : M.Term) (k : ℕ), k < 2*M.coarseLength hd e+1 ∧ + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) k = x ∧ + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) (k+1) = y) + +theorem portChain_first (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) 0 = + qmaExpandedPoint (M.placedVertex (M.left e)) := by + rw [qmaPortChain_zero] + exact congrArg qmaExpandedPoint (M.coarseRoute_zero hd e) + +theorem portChain_last (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (e : M.Term) : + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) (2*M.coarseLength hd e+1) = + qmaExpandedPoint (M.placedVertex (M.right e)) := by + rw [qmaPortChain_last] + exact congrArg qmaExpandedPoint (M.coarseRoute_last hd e) + +theorem portChain_simple (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (i j : ℕ) (hi : i ≤ 2*M.coarseLength hd e+1) (hj : j ≤ 2*M.coarseLength hd e+1) + (h : qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) i = + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) j) : i = j := + qmaPortChain_injective _ (M.coarseLength_pos hd e) + (M.coarseRoute_step hd e) (fun k _ => M.coarseRoute_positive hd e k) + (M.coarseRoute_simple hd e) hi hj h + +theorem portChain_step (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (i : ℕ) (hi : i < 2*M.coarseLength hd e+1) : + (M.portGraph hd).Adj + (qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) i) + (qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) (i+1)) := by + apply (SimpleGraph.fromRel_adj _ _ _).mpr + refine ⟨?_,Or.inl ⟨e,i,hi,rfl,rfl⟩⟩ + intro h + have he := M.portChain_simple hd e i (i+1) (Nat.le_of_lt hi) (by omega) h + omega + +theorem portChain_disjoint (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e f : M.Term) (i j : ℕ) (hef : e ≠ f) (hi0 : 0 < i) + (hi : i < 2*M.coarseLength hd e+1) (hj : j ≤ 2*M.coarseLength hd f+1) : + qmaPortChain (M.coarseRoute hd e) (M.coarseLength hd e) i ≠ + qmaPortChain (M.coarseRoute hd f) (M.coarseLength hd f) j := + qmaPortChain_interiors_disjoint _ _ (M.coarseRoute_step hd e) (M.coarseRoute_step hd f) + (fun k _ => M.coarseRoute_positive hd e k) (fun k _ => M.coarseRoute_positive hd f k) + (M.coarseRoute_edges_disjoint hA hd hef) hi0 hi hj + +def portRouteData (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : + QMAPortRouteData M.exchangeGraph where + length := M.coarseLength hd + length_pos := M.coarseLength_pos hd + position := M.placedVertex + position_injective := M.placedVertex_injective + point := M.coarseRoute hd + first := M.coarseRoute_zero hd + last := M.coarseRoute_last hd + simple := M.coarseRoute_simple hd + step := M.coarseRoute_step hd + positive := fun e i _ => M.coarseRoute_positive hd e i + edges_disjoint := fun _e _f hef => M.coarseRoute_edges_disjoint hA hd hef + +theorem portRouteData_graph (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : + (M.portRouteData hA hd).graph = M.portGraph hd := rfl + +def portEmbedding (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) := + (M.portRouteData hA hd).toEmbedding + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortLinks.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortLinks.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce9f49eeb5ad2d64a84cab08d6b5961750958067 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortLinks.lean @@ -0,0 +1,25 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedPortRealization +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortLinks + +namespace OAI + +/-! The physical port graph has only the three local interaction geometries. -/ + +noncomputable section +namespace ContinuumCoulomb +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem portGraph_link (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + {x y : ℕ × ℕ} (h : (M.portGraph hd).Adj x y) : QMAPortLink x y := by + change x ≠ y ∧ _ at h + rcases h.2 with ⟨e,k,hk,rfl,rfl⟩ | ⟨e,k,hk,rfl,rfl⟩ + · exact qmaPortChain_link _ (M.coarseLength_pos hd e) (M.coarseRoute_step hd e) k hk + · exact (qmaPortChain_link _ (M.coarseLength_pos hd e) (M.coarseRoute_step hd e) k hk).symm + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee3cc982caf13386a9d9e10eb7336e73f0336a75 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedPortRealization.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedPortChain +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortChainBounds + +namespace OAI + +/-! A fixed number of rational mediator layers realizes every bounded spatial +route on its explicit port graph, with full-space energy comparison. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def routeLengthBound (A B : ℕ) : ℕ := 2*(16*(9*B+6)+2)+8*(9*B+9)*(3*A+2) + +theorem portEmbedding_bounded (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) : + (M.portEmbedding hA hd).Bounded (32*M.bufferedWidth) (32*M.bufferedHeight) := by + constructor + · intro v + exact qmaExpandedPoint_bounds (M.placedVertex_bounds v).1 (M.placedVertex_bounds v).2 + · intro e k hk + exact qmaPortChain_bounds (M.coarseRoute hd e) + (fun i _ => M.bufferedPath_bounds hd e ((M.bufferedPath hd e).val.getVert_mem_support i)) k hk + +theorem port_realize (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {N : ℚ} (hN : 0 < N) : + ∃ (H : QMARationalExchangeGraph) (position : Fin H.n → ℕ × ℕ), + Function.Injective position ∧ + (∀ v, (position v).1 < 32*M.bufferedWidth ∧ (position v).2 < 32*M.bufferedHeight) ∧ + (∀ e, (M.portGraph hd).Adj (position (H.left e)) (position (H.right e))) ∧ + (∀ v, qmaGraphDegree H.left H.right v ≤ 3) ∧ + H.n+Fintype.card H.Edge ≤ 5^(routeLengthBound A B)*(M.n+Fintype.card M.Term) ∧ + |H.energy-M.energy| ≤ (routeLengthBound A B:ℝ)/(N:ℝ) := by + have hD : ∀ e, (M.portRouteData hA hd).schedule.work e ≤ routeLengthBound A B := M.bufferedPath_length hd + obtain ⟨H,pos,hinj,hbox,hadj,hdeg,hsize,herror⟩ := + (M.portEmbedding hA hd).realize hN (by decide : 3 ≤ 3) hD (M.portEmbedding_bounded hA hd) hd + rw [M.portRouteData_graph hA hd] at hadj + refine ⟨H,pos,hinj,hbox,hadj,hdeg,hsize,?_⟩ + exact herror + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8e93a9f663ff64ea45e837c19468265b66e2ef9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedProgram.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedDetour +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteProgram + +namespace OAI + +/-! Literal binary TM2 programs for every buffered endpoint path point. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumBufferedCode +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +noncomputable opaque uProgram : Procedure axisCode Nat.bits (fun x => x.1.1) := axisStartProgram +noncomputable opaque vProgram : Procedure axisCode Nat.bits (fun x => x.1.2) := axisEndProgram +noncomputable opaque kProgram : Procedure axisCode Nat.bits (fun x => x.2) := axisCursorProgram +noncomputable def constProgram (k : ℕ) : Procedure axisCode Nat.bits (fun _ => k) := + Procedure.constant axisCode Nat.bits k + +noncomputable opaque horizontalProgram : Procedure axisCode Nat.bits (fun x => x.1.2-17) := + Procedure.binarySub.comp (vProgram.pair (constProgram 17)) +noncomputable opaque verticalProgram : Procedure axisCode Nat.bits (fun x => x.1.1-17) := + Procedure.binarySub.comp (uProgram.pair (constProgram 17)) +noncomputable opaque doglegCutProgram : Procedure axisCode Nat.bits (fun x => (x.1.2-17)+(x.1.1-17)) := + Procedure.binaryAdd.comp (horizontalProgram.pair verticalProgram) + +noncomputable opaque doglegProgram : Procedure axisCode pairCode + (fun x => qmaBufferedDoglegPoint x.1.1 x.1.2 x.2) := by + let first := (Procedure.binaryAdd.comp ((constProgram 17).pair kProgram)).pair (constProgram 17) + let second := vProgram.pair (Procedure.binaryAdd.comp ((constProgram 17).pair + (Procedure.binarySub.comp (kProgram.pair horizontalProgram)))) + let last := uProgram.pair uProgram + exact (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair horizontalProgram)) first + (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair doglegCutProgram)) second last)).congrFun + (by intro x; simp [qmaBufferedDoglegPoint]) + +noncomputable opaque totalProgram : Procedure axisCode Nat.bits (fun x => x.1.1+x.1.2) := + Procedure.binaryAdd.comp (uProgram.pair vProgram) +noncomputable opaque detourCutProgram : Procedure axisCode Nat.bits (fun x => x.1.1+x.1.2-9) := + Procedure.binarySub.comp (totalProgram.pair (constProgram 9)) +noncomputable opaque twiceUProgram : Procedure axisCode Nat.bits (fun x => 2*x.1.1) := + Procedure.binaryMul.comp ((constProgram 2).pair uProgram) + +noncomputable opaque detourProgram : Procedure axisCode pairCode + (fun x => qmaBufferedDetourPoint x.1.1 x.1.2 x.2) := by + let first := (Procedure.binarySub.comp ((constProgram 17).pair kProgram)).pair (constProgram 17) + let second := (constProgram 9).pair (Procedure.binaryAdd.comp (kProgram.pair (constProgram 9))) + let third := (Procedure.binaryAdd.comp ((Procedure.binarySub.comp (kProgram.pair uProgram)).pair + (constProgram 9))).pair (Procedure.binaryAdd.comp (uProgram.pair (constProgram 9))) + let fourth := vProgram.pair (Procedure.binarySub.comp + ((Procedure.binaryAdd.comp (twiceUProgram.pair vProgram)).pair kProgram)) + let last := uProgram.pair uProgram + exact (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair (constProgram 8))) first + (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair uProgram)) second + (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair detourCutProgram)) third + (Procedure.conditional (Procedure.binaryLe.comp (kProgram.pair totalProgram)) fourth last)))).congrFun + (by intro x; simp [qmaBufferedDetourPoint]) + +noncomputable def doglegCertificate : Turing.TM2ComputableInPolyTime axisCode pairCode + (fun x => qmaBufferedDoglegPoint x.1.1 x.1.2 x.2) := doglegProgram.toTM2 +noncomputable def detourCertificate : Turing.TM2ComputableInPolyTime axisCode pairCode + (fun x => qmaBufferedDetourPoint x.1.1 x.1.2 x.2) := detourProgram.toTM2 + +end ContinuumCoulomb.QuantumBufferedCode + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedRay.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedRay.lean new file mode 100644 index 0000000000000000000000000000000000000000..63f52d64bfa99faf8a392578b64604c46db02438 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedRay.lean @@ -0,0 +1,31 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedFanout + +namespace OAI + +/-! A direction choice keeps each endpoint arm disjoint from its own outgoing ray. -/ + +namespace ContinuumCoulomb + +def qmaBufferedRay (u : ℕ) (vertical positive : Bool) (z : ℕ × ℕ) : Prop := + if vertical then z.1 = u ∧ (if positive then u ≤ z.2 else z.2 ≤ u) + else z.2 = u ∧ (if positive then u ≤ z.1 else z.1 ≤ u) + +def qmaBufferedRaySide (a : Fin 3) (vertical positive : Bool) : Bool := + if vertical = (a == 1) then !positive else false + +theorem qmaBufferedFanout_ray (c : Fin 3 → ℕ) (side : Fin 3 → Bool) + (a : Fin 3) (vertical positive : Bool) + (hs : side a = qmaBufferedRaySide a vertical positive) + (hd : a ≠ 2 ∨ vertical = true ∨ positive = true) {z : ℕ × ℕ} + (ha : qmaBufferedFanoutSupport c side a z) + (hr : qmaBufferedRay (qmaBufferedPort c a) vertical positive z) : + z = (qmaBufferedPort c a,qmaBufferedPort c a) := by + rcases z with ⟨x,y⟩ + cases vertical <;> cases positive <;> fin_cases a <;> + simp [qmaBufferedRaySide] at hs <;> + simp [qmaBufferedFanoutSupport,qmaBufferedRay,qmaBufferedOffset, + qmaBufferedPort,qmaBetween,hs] at ha hr hd ⊢ <;> omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSharedEdge.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSharedEdge.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d49f6b6c493917e94bb5c2621edffea0ec51861 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSharedEdge.lean @@ -0,0 +1,154 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedIntersections +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedGridEdge + +namespace OAI + +/-! Different routes do not share lattice edges, including at buffered endpoint cells. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaSquareGrid_not_eightfold {p q : ℕ × ℕ} + (hp : p.1 % 8 = 0 ∧ p.2 % 8 = 0) (hq : q.1 % 8 = 0 ∧ q.2 % 8 = 0) : + ¬qmaSquareGrid.Adj p q := by + intro h + change Nat.dist p.1 q.1 + Nat.dist p.2 q.2 = 1 at h + unfold Nat.dist at h + omega + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem spaced_incident_support (v : Fin M.n) (e : M.Incident v) : + M.spacedSupport e.val (qmaLanePoint (M.spacedColor e.val) (M.routeVertex v)) := by + rcases e.property with h | h + · left + dsimp [spacedSupport,qmaLaneSupport,routeLeft,routeRight,routeVertex] + rw [h] + exact ⟨rfl,min_le_left _ _,le_max_left _ _⟩ + · right + dsimp [spacedSupport,qmaLaneSupport,routeLeft,routeRight,routeVertex] + rw [h] + exact ⟨rfl,min_le_right _ _,le_max_right _ _⟩ + +theorem arm_lane_not_grid (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {f : M.Term} (hef : e.val ≠ f) {p : ℕ × ℕ} + (he : M.endpointArmSupport hd v e p) (hf : M.spacedSupport f p) : + ¬(p.1 % 8 = 0 ∧ p.2 % 8 = 0) := by + intro hp + have ht := M.endpointArmSupport_grid hd v e he hp + have hg : M.spacedSupport e.val p := by rw [ht]; exact M.spaced_incident_support v e + exact M.spaced_crossing_not_vertex hA hef hg hf e.val (M.routeVertex v) ht + +theorem spaced_unit_direction (e : M.Term) {p q : ℕ × ℕ} + (hp : M.spacedSupport e p) (hq : M.spacedSupport e q) (ha : qmaSquareGrid.Adj p q) : + (p.1 = q.1 ∧ p.1 % 8 = 0) ∨ (p.2 = q.2 ∧ p.2 % 8 = 0) := by + have haxis : p.1 = q.1 ∨ p.2 = q.2 := by + change Nat.dist p.1 q.1 + Nat.dist p.2 q.2 = 1 at ha + unfold Nat.dist at ha + omega + have hxm : (qmaLanePoint (M.spacedColor e) (qmaFineGridNat (M.routeRight e))).1 % 8 = 0 := by + simp [qmaLanePoint,spacedColor,qmaSpacedLaneColor,Nat.add_mod,Nat.mul_mod] + have hym : (qmaLanePoint (M.spacedColor e) (qmaFineGridNat (M.routeLeft e))).2 % 8 = 0 := by + simp [qmaLanePoint,spacedColor,qmaSpacedLaneColor,Nat.add_mod,Nat.mul_mod] + rcases hp with ⟨hpy,_⟩ | ⟨hpx,_⟩ <;> rcases hq with ⟨hqy,_⟩ | ⟨hqx,_⟩ + · exact Or.inr ⟨hpy.trans hqy.symm,by rw [hpy]; exact hym⟩ + · rcases haxis with hx | hy + · exact Or.inl ⟨hx,by rw [hx,hqx]; exact hxm⟩ + · exact Or.inr ⟨hy,by rw [hpy]; exact hym⟩ + · rcases haxis with hx | hy + · exact Or.inl ⟨hx,by rw [hpx]; exact hxm⟩ + · exact Or.inr ⟨hy,by rw [hy,hqy]; exact hym⟩ + · exact Or.inl ⟨hpx.trans hqx.symm,by rw [hpx]; exact hxm⟩ + +theorem endpointArm_lane_no_edge (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {f : M.Term} (hef : e.val ≠ f) {p q : ℕ × ℕ} + (hp : M.endpointArmSupport hd v e p) (hq : M.endpointArmSupport hd v e q) + (hpf : M.spacedSupport f p) (hqf : M.spacedSupport f q) (ha : qmaSquareGrid.Adj p q) : False := by + obtain ⟨r,hr,hrs⟩ := hp + obtain ⟨s,hs,hss⟩ := hq + have har : qmaSquareGrid.Adj r s := by + rw [← hr,← hs] at ha + simpa only [qmaSquareGrid,qmaBufferedCellPoint,Nat.dist_add_add_left] using ha + rcases M.spaced_unit_direction f hpf hqf ha with ⟨hxy,hm⟩ | ⟨hxy,hm⟩ + · have hx : r.1 = s.1 := by + have h := congrArg Prod.fst hr + have h' := congrArg Prod.fst hs + dsimp [qmaBufferedCellPoint] at h h' + omega + have hm' : r.1 % 8 = 0 := by + have h := congrArg (fun x : ℕ × ℕ => x.1 % 8) hr + simpa [qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hm] using h + have hd' : Nat.dist r.2 s.2 = 1 := by simpa [qmaSquareGrid,hx] using har + rcases qmaBufferedFanout_vertical_grid_edge _ _ hrs hss hx hm' hd' with ht | ht + · apply M.arm_lane_not_grid hA hd v e hef ⟨r,hr,hrs⟩ hpf + simp [← hr,qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hm',ht] + · apply M.arm_lane_not_grid hA hd v e hef ⟨s,hs,hss⟩ hqf + simp [← hs,qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,← hx,hm',ht] + · have hy : r.2 = s.2 := by + have h := congrArg Prod.snd hr + have h' := congrArg Prod.snd hs + dsimp [qmaBufferedCellPoint] at h h' + omega + have hm' : r.2 % 8 = 0 := by + have h := congrArg (fun x : ℕ × ℕ => x.2 % 8) hr + simpa [qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hm] using h + have hd' : Nat.dist r.1 s.1 = 1 := by simpa [qmaSquareGrid,hy] using har + rcases qmaBufferedFanout_horizontal_grid_edge _ _ hrs hss hy hm' hd' with ht | ht + · apply M.arm_lane_not_grid hA hd v e hef ⟨r,hr,hrs⟩ hpf + simp [← hr,qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,hm',ht] + · apply M.arm_lane_not_grid hA hd v e hef ⟨s,hs,hss⟩ hqf + simp [← hs,qmaBufferedCellPoint,Nat.add_mod,Nat.mul_mod,← hy,hm',ht] + + +theorem bufferedPath_edge_piece (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) {p q : ℕ × ℕ} (he : s(p,q) ∈ (M.bufferedPath hd e).val.edges) : + (∃ (v : Fin M.n) (h : M.left e = v ∨ M.right e = v), + M.endpointArmSupport hd v ⟨e,h⟩ p ∧ M.endpointArmSupport hd v ⟨e,h⟩ q) ∨ + (M.spacedSupport e p ∧ M.spacedSupport e q) := by + have h := (M.bufferedWalk hd e).edges_toPath_subset_edges he + simp only [bufferedWalk,SimpleGraph.Walk.edges_append,SimpleGraph.Walk.edges_reverse, + List.mem_append,List.mem_reverse] at h + rcases h with (h | h) | h + · exact Or.inl ⟨M.left e,Or.inl rfl, + M.endpointArmWalk_support hd _ _ ((M.endpointArmWalk hd _ _).fst_mem_support_of_mem_edges h), + M.endpointArmWalk_support hd _ _ ((M.endpointArmWalk hd _ _).snd_mem_support_of_mem_edges h)⟩ + · exact Or.inr ⟨M.spacedWalk_support e ((M.spacedWalk e).fst_mem_support_of_mem_edges h), + M.spacedWalk_support e ((M.spacedWalk e).snd_mem_support_of_mem_edges h)⟩ + · exact Or.inl ⟨M.right e,Or.inr rfl, + M.endpointArmWalk_support hd _ _ ((M.endpointArmWalk hd _ _).fst_mem_support_of_mem_edges h), + M.endpointArmWalk_support hd _ _ ((M.endpointArmWalk hd _ _).snd_mem_support_of_mem_edges h)⟩ + +theorem bufferedPath_no_shared_edge (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {e f : M.Term} (hef : e ≠ f) + {p q : ℕ × ℕ} (he : s(p,q) ∈ (M.bufferedPath hd e).val.edges) + (hf : s(p,q) ∈ (M.bufferedPath hd f).val.edges) : False := by + have ha := (M.bufferedPath hd e).val.adj_of_mem_edges he + rcases M.bufferedPath_edge_piece hd e he with ⟨v,hv,hpe,hqe⟩ | ⟨hpe,hqe⟩ <;> + rcases M.bufferedPath_edge_piece hd f hf with ⟨w,hw,hpf,hqf⟩ | ⟨hpf,hqf⟩ + · have hp := M.endpointArmSupport_meet hA hd v w ⟨e,hv⟩ ⟨f,hw⟩ hpe hpf + have hq := M.endpointArmSupport_meet hA hd v w ⟨e,hv⟩ ⟨f,hw⟩ hqe hqf + have hp' : p = M.placedVertex v := hp.resolve_left hef + have hq' : q = M.placedVertex v := hq.resolve_left hef + rw [hp',hq'] at ha + exact qmaSquareGrid.irrefl ha + · exact M.endpointArm_lane_no_edge hA hd v ⟨e,hv⟩ hef hpe hqe hpf hqf ha + · exact M.endpointArm_lane_no_edge hA hd w ⟨f,hw⟩ hef.symm hpf hqf hpe hqe ha + · exact qmaSquareGrid_not_eightfold (M.spaced_crossing_grid hA hef hpe hpf) + (M.spaced_crossing_grid hA hef hqe hqf) ha + +theorem bufferedPath_edge_disjoint (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {e f : M.Term} (hef : e ≠ f) : + Disjoint (M.bufferedPath hd e).val.edgeSet (M.bufferedPath hd f).val.edgeSet := by + apply Set.disjoint_left.mpr + intro z he hf + induction z using Sym2.inductionOn with + | _ p q => exact M.bufferedPath_no_shared_edge hA hd hef he hf + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSourceCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSourceCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f863fdc84ef130c6ad8e345f424b5baad0be8b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSourceCells.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedPortChain +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPassages + +namespace OAI + +/-! Original spin cells contain no internal route passage. Their local connections +are precisely the vertex fanout rays, separated from crossing cells. -/ + +noncomputable section +namespace ContinuumCoulomb +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem coarseRoute_avoids (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (i : ℕ) (v : Fin M.n) (hi0 : 0 < i) (hi : i < M.coarseLength hd e) : + M.coarseRoute hd e i ≠ M.placedVertex v := by + intro h + have hm := (M.bufferedPath hd e).val.getVert_mem_support i + change M.coarseRoute hd e i ∈ _ at hm + rw [h] at hm + rcases M.bufferedPath_vertex hd e v hm with hv | hv + · rw [hv] at h + have he := M.coarseRoute_simple hd e i 0 hi.le (Nat.zero_le _) + (h.trans (M.coarseRoute_zero hd e).symm) + omega + · rw [hv] at h + have he := M.coarseRoute_simple hd e i (M.coarseLength hd e) hi.le le_rfl + (h.trans (M.coarseRoute_last hd e).symm) + omega + +theorem sourceCell_no_passage (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (i : (M.portRouteData hA hd).Interior) (v : Fin M.n) : + (M.portRouteData hA hd).cell i ≠ M.placedVertex v := by + apply M.coarseRoute_avoids hd i.1 (i.2.val+1) v (by omega) + exact (M.portRouteData hA hd).cell_index_lt i + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSupport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a1822f6f6ccce4d3801ebbc078615257139b8e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumBufferedSupport.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedEndpointWalk + +namespace OAI + +/-! The routed paths visit original graph vertices only at their own endpoints. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem routeVertex_injective : Function.Injective M.routeVertex := by + intro v w h + exact M.qubitSlots.site_injective (qmaFineGridNat_injective h) + +theorem placedVertex_injective : Function.Injective M.placedVertex := by + intro v w h + have hh := congrArg (fun z : ℕ × ℕ => + (z.1/(8*(9*B+3+6)),z.2/(8*(9*B+3+6)))) h + dsimp only [placedVertex] at hh + rw [qmaBufferedCellPoint_cell (9*B+3) _ (17,17) (by omega) (by omega), + qmaBufferedCellPoint_cell (9*B+3) _ (17,17) (by omega) (by omega)] at hh + exact M.routeVertex_injective hh + +def endpointArmSupport (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) (z : ℕ × ℕ) : Prop := + ∃ p, qmaBufferedCellPoint (9*B+3) (M.routeVertex v) p = z ∧ + qmaBufferedFanoutSupport (M.endpointColors hd v) (fun _ => false) + ((M.endpointPorts hd v).assign e) p + +theorem endpointArmWalk_support (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v : Fin M.n) (e : M.Incident v) {z : ℕ × ℕ} + (hz : z ∈ (M.endpointArmWalk hd v e).support) : M.endpointArmSupport hd v e z := by + simp only [endpointArmWalk,SimpleGraph.Walk.support_copy] at hz + obtain ⟨k,_,hk⟩ := qmaGridWalk_support _ _ _ hz + exact ⟨_,hk,qmaBufferedArm_support _ _ _ k⟩ + +theorem endpointArmSupport_vertex (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (v w : Fin M.n) (e : M.Incident v) + (hz : M.endpointArmSupport hd v e (M.placedVertex w)) : v = w := by + obtain ⟨p,hp,hs⟩ := hz + have hb := qmaBufferedFanout_bounded (M.endpointColors hd v) + ((M.endpointPorts hd v).increasing (show (0 : Fin 3) < 1 by decide)) + ((M.endpointPorts hd v).increasing (show (1 : Fin 3) < 2 by decide)) + ((M.endpointPorts hd v).slot 2).isLt (fun _ => false) _ hs + apply M.routeVertex_injective + have hh := congrArg (fun z : ℕ × ℕ => + (z.1/(8*(9*B+3+6)),z.2/(8*(9*B+3+6)))) hp + dsimp only [placedVertex] at hh + rw [qmaBufferedCellPoint_cell (9*B+3) _ p hb.2.1 hb.2.2.2, + qmaBufferedCellPoint_cell (9*B+3) _ (17,17) (by omega) (by omega)] at hh + exact hh + +theorem spacedSupport_not_vertex (e : M.Term) (v : Fin M.n) : + ¬M.spacedSupport e (M.placedVertex v) := by + intro h + rcases h with ⟨h,_⟩ | ⟨h,_⟩ + all_goals + have hm := congrArg (fun x : ℕ => x % 8) h + simp [placedVertex,qmaBufferedCellPoint,qmaLanePoint,spacedColor,qmaSpacedLaneColor, + Nat.add_mod,Nat.mul_mod] at hm + +theorem spacedWalk_support (e : M.Term) {z : ℕ × ℕ} + (hz : z ∈ (M.spacedWalk e).support) : M.spacedSupport e z := by + simp only [spacedWalk,SimpleGraph.Walk.support_copy] at hz + obtain ⟨k,hk,he⟩ := qmaGridWalk_support _ _ _ hz + rw [← he] + exact qmaManhattanPoint_support _ _ k hk + +theorem bufferedPath_support (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) {z : ℕ × ℕ} (hz : z ∈ (M.bufferedPath hd e).val.support) : + M.endpointArmSupport hd (M.left e) ⟨e,Or.inl rfl⟩ z ∨ M.spacedSupport e z ∨ + M.endpointArmSupport hd (M.right e) ⟨e,Or.inr rfl⟩ z := by + have h := (M.bufferedWalk hd e).support_toPath_subset_support hz + simp only [bufferedWalk,SimpleGraph.Walk.mem_support_append_iff, + SimpleGraph.Walk.support_reverse,List.mem_reverse] at h + rcases h with (h | h) | h + · exact Or.inl (M.endpointArmWalk_support hd _ _ h) + · exact Or.inr (Or.inl (M.spacedWalk_support e h)) + · exact Or.inr (Or.inr (M.endpointArmWalk_support hd _ _ h)) + +theorem bufferedPath_vertex (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (e : M.Term) (v : Fin M.n) (hz : M.placedVertex v ∈ (M.bufferedPath hd e).val.support) : + v = M.left e ∨ v = M.right e := by + rcases M.bufferedPath_support hd e hz with h | h | h + · exact Or.inl (M.endpointArmSupport_vertex hd _ _ _ h).symm + · exact (M.spacedSupport_not_vertex e v h).elim + · exact Or.inr (M.endpointArmSupport_vertex hd _ _ _ h).symm + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCatalogProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCatalogProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d41f8a61e693690594841d56f882b5563d3d797c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCatalogProgram.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPathProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawProgram + +namespace OAI + +/-! Literal polynomial evaluation of all 140 path candidates. Every template +is constant-sized, and only its endpoint cell coordinates vary. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCellPathProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +private noncomputable def appendPaths {f g : Pair → List (List Pair)} + (p : Procedure pairCode (listCode (listCode pairCode)) f) + (q : Procedure pairCode (listCode (listCode pairCode)) g) : + Procedure pairCode (listCode (listCode pairCode)) (fun x => f x++g x) := + (Procedure.listAppend (listCode pairCode) []).comp (p.pair q) + +private noncomputable def singletonPath {f : Pair → List Pair} + (p : Procedure pairCode (listCode pairCode) f) : + Procedure pairCode (listCode (listCode pairCode)) (fun x => [f x]) := + (Procedure.listCons (listCode pairCode)).comp + (p.pair (Procedure.constant pairCode (listCode (listCode pairCode)) [])) + +noncomputable def flatFamilyProgram (m : ℕ) (f : Fin m → Pair → List (List Pair)) + (p : ∀ i, Procedure pairCode (listCode (listCode pairCode)) (f i)) : + Procedure pairCode (listCode (listCode pairCode)) + (fun x => (List.ofFn (fun i => f i x)).flatten) := by + induction m with + | zero => exact (Procedure.constant _ _ []).congrFun (by intro x; simp) + | succ m ih => + exact (appendPaths (p 0) (ih (fun i => f i.succ) (fun i => p i.succ))).congrFun (by + intro x + simp only [List.ofFn_succ,List.flatten_cons]) + +noncomputable opaque corridorBlockProgram (a : Fin 4) : + Procedure pairCode (listCode (listCode pairCode)) (fun p => + [(QMACellRouteBody.corridor p a false false).path, + (QMACellRouteBody.corridor p a false true).path, + (QMACellRouteBody.corridor p a true false).path, + (QMACellRouteBody.corridor p a true true).path]) := + (appendPaths + (appendPaths (singletonPath (corridorProgram a false false)) (singletonPath (corridorProgram a false true))) + (appendPaths (singletonPath (corridorProgram a true false)) (singletonPath (corridorProgram a true true)))).congrFun + (by intro p; rfl) + +noncomputable opaque bodyPathsProgram : Procedure pairCode (listCode (listCode pairCode)) + (fun p => (qmaCellBodies p).map QMACellRouteBody.path) := by + let rays := QuantumRawExchange.fixedListProgram pairCode (listCode pairCode) 4 _ rayProgram + let pairs := QuantumRawExchange.fixedListProgram pairCode (listCode pairCode) 6 _ pairProgram + let patches := QuantumRawExchange.fixedListProgram pairCode (listCode pairCode) 9 _ patchProgram + let corridors := flatFamilyProgram 4 _ corridorBlockProgram + exact (appendPaths (appendPaths (appendPaths rays pairs) patches) corridors).congrFun (by + intro p + simp only [qmaCellBodies,List.map_append,List.ofFn_eq_map,List.map_map, + List.flatMap_def,List.map_flatten,List.map_cons,List.map_nil,Function.comp_def]) + +noncomputable opaque orientedPathProgram : Procedure (listCode pairCode) (listCode (listCode pairCode)) + (fun xs => [xs,xs.reverse]) := + ((Procedure.listCons (listCode pairCode)).comp + ((Procedure.identity (listCode pairCode)).pair + ((Procedure.listCons (listCode pairCode)).comp + ((Procedure.listReverse pairCode (0,0)).pair + (Procedure.constant (listCode pairCode) (listCode (listCode pairCode)) []))))) + +noncomputable opaque bodyAtProgram (i : Fin 35) : Procedure pairCode (listCode pairCode) + (fun p => (((qmaCellBodies p).map QMACellRouteBody.path).drop i.val).headD []) := + (Procedure.listGet (listCode pairCode) []).comp + ((Procedure.constant pairCode Nat.bits i.val).pair bodyPathsProgram) + +private theorem ofFn_headD_map {α β : Type} (xs : List α) (default : α) (f : α → β) : + (List.ofFn (fun i : Fin xs.length => f ((xs.drop i.val).headD default))) = xs.map f := by + apply List.ext_getElem + · simp + · intro i hi hj + have h : i < xs.length := by simpa using hi + simp only [List.getElem_ofFn,List.getElem_map] + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_eq_getElem h,Option.getD_some] + +noncomputable opaque cellPathsProgram : Procedure pairCode (listCode (listCode pairCode)) + (fun p => (qmaCellRoutes p).map QMACellRoute.path) := + (flatFamilyProgram 35 _ (fun i => orientedPathProgram.comp (bodyAtProgram i))).congrFun (by + intro p + have hlen : ((qmaCellBodies p).map QMACellRouteBody.path).length = 35 := by + simp only [List.length_map,qmaCellBodies_length] + have h := ofFn_headD_map ((qmaCellBodies p).map QMACellRouteBody.path) [] + (fun xs => [xs,xs.reverse]) + rw [hlen] at h + simp only [Function.comp_apply] + rw [h] + simp only [qmaCellRoutes,List.flatMap_def,List.map_flatten,List.map_map, + Function.comp_def,List.map_cons,List.map_nil,QMACellRoute.path,Bool.false_eq_true, + ite_false,ite_true]) + +abbrev Endpoints := Pair × Pair +def endpointsCode : Endpoints → List Bool := prodCode pairCode pairCode + +noncomputable opaque pointCellProgram : Procedure pairCode pairCode qmaPointCell := by + let c := Procedure.constant pairCode Nat.bits 32 + exact (Procedure.binaryDiv.comp ((Procedure.first Nat.bits Nat.bits).pair c)).pair + (Procedure.binaryDiv.comp ((Procedure.second Nat.bits Nat.bits).pair c)) + +noncomputable opaque candidatePathsProgram : Procedure endpointsCode (listCode (listCode pairCode)) + (fun x => (qmaRouteCandidates x.1 x.2).map QMACellRoute.path) := by + let left := cellPathsProgram.comp (pointCellProgram.comp (Procedure.first pairCode pairCode)) + let right := cellPathsProgram.comp (pointCellProgram.comp (Procedure.second pairCode pairCode)) + exact ((Procedure.listAppend (listCode pairCode) []).comp (left.pair right)).congrFun (by + intro x + simp only [qmaRouteCandidates,List.map_append,Function.comp_apply]) + +end ContinuumCoulomb.QuantumCellPathProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCorridor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCorridor.lean new file mode 100644 index 0000000000000000000000000000000000000000..c10fe165de510ad805330224568ae6f4fc909fb8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCorridor.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellTranslate + +namespace OAI + +/-! The actual short lattice corridor between neighboring cells, with either +ordinary or inward-moved terminals at each end. -/ + +namespace ContinuumCoulomb + +def qmaPortOpposite : Fin 4 → Fin 4 := ![2,3,0,1] + +theorem qmaCellBoundary_step (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) : + qmaSquareGrid.Adj (qmaCellTranslate p (qmaCellBoundary a)) + (qmaCellTranslate (qmaGridNeighbor p a) (qmaCellBoundary (qmaPortOpposite a))) := by + fin_cases a <;> + dsimp [qmaCellTranslate,qmaCellBoundary,qmaPortOpposite,qmaGridNeighbor] + all_goals change Nat.dist _ _ + Nat.dist _ _ = 1 + all_goals unfold Nat.dist; omega + +def qmaHalfPathAt (p : ℕ × ℕ) (cross : Bool) (a : Fin 4) : List (ℕ × ℕ) := + (qmaHalfCorridorPath cross a).map (qmaCellTranslate p) + +theorem qmaHalfPathAt_endpoints (p : ℕ × ℕ) (cross : Bool) (a : Fin 4) : + (qmaHalfPathAt p cross a).head? = some (qmaCellTranslate p (qmaLocalPort cross a)) ∧ + (qmaHalfPathAt p cross a).getLast? = some (qmaCellTranslate p (qmaCellBoundary a)) := by + simp only [qmaHalfPathAt,List.head?_map,List.getLast?_map, + (qmaHalfCorridor_endpoints cross a).1,(qmaHalfCorridor_endpoints cross a).2,Option.map_some] + constructor <;> trivial + +theorem qmaHalfPathAt_chain (p : ℕ × ℕ) (cross : Bool) (a : Fin 4) : + (qmaHalfPathAt p cross a).IsChain (fun x y => qmaSquareGrid.Adj x y) := by + apply List.isChain_map_of_isChain (qmaCellTranslate p) _ (qmaHalfCorridor_chain cross a) + intro x y h + change Nat.dist _ _ + Nat.dist _ _ = 1 + simpa only [qmaCellTranslate_step] using h + +theorem qmaHalfPathAt_simple (p : ℕ × ℕ) (cross : Bool) (a : Fin 4) : + (qmaHalfPathAt p cross a).Nodup := + (qmaHalfCorridor_simple cross a).map (qmaCellTranslate_injective p) + +theorem qmaHalfPathAt_mem {p z : ℕ × ℕ} {cross : Bool} {a : Fin 4} + (hz : z ∈ qmaHalfPathAt p cross a) : + ∃ u, u.1 < 32 ∧ u.2 < 32 ∧ qmaCellTranslate p u = z := by + obtain ⟨u,hu,he⟩ := List.mem_map.mp hz + exact ⟨u,(qmaHalfCorridor_bounded cross a u hu).1, + (qmaHalfCorridor_bounded cross a u hu).2,he⟩ + +def qmaCellCorridor (p : ℕ × ℕ) (a : Fin 4) (cross nextCross : Bool) : List (ℕ × ℕ) := + qmaHalfPathAt p cross a ++ + (qmaHalfPathAt (qmaGridNeighbor p a) nextCross (qmaPortOpposite a)).reverse + +theorem qmaCellCorridor_endpoints (p : ℕ × ℕ) (a : Fin 4) (cross nextCross : Bool) : + (qmaCellCorridor p a cross nextCross).head? = + some (qmaCellTranslate p (qmaLocalPort cross a)) ∧ + (qmaCellCorridor p a cross nextCross).getLast? = + some (qmaCellTranslate (qmaGridNeighbor p a) (qmaLocalPort nextCross (qmaPortOpposite a))) := by + simp only [qmaCellCorridor,List.head?_append,List.getLast?_append,List.head?_reverse,List.getLast?_reverse, + (qmaHalfPathAt_endpoints p cross a).1, + (qmaHalfPathAt_endpoints (qmaGridNeighbor p a) nextCross (qmaPortOpposite a)).1,Option.some_or] + constructor <;> trivial + +theorem qmaCellCorridor_chain (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) + (cross nextCross : Bool) : + (qmaCellCorridor p a cross nextCross).IsChain (fun x y => qmaSquareGrid.Adj x y) := by + apply (qmaHalfPathAt_chain p cross a).append + · apply List.isChain_reverse.mpr + exact (qmaHalfPathAt_chain (qmaGridNeighbor p a) nextCross (qmaPortOpposite a)).imp + (fun _ _ h => h.symm) + · intro x hx y hy + rw [(qmaHalfPathAt_endpoints p cross a).2] at hx + rw [List.head?_reverse, + (qmaHalfPathAt_endpoints (qmaGridNeighbor p a) nextCross (qmaPortOpposite a)).2] at hy + have hx' := Option.mem_def.mp hx + have hy' := Option.mem_def.mp hy + cases hx' + cases hy' + exact qmaCellBoundary_step p hp a + +theorem qmaCellCorridor_simple (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) + (cross nextCross : Bool) : (qmaCellCorridor p a cross nextCross).Nodup := by + apply (qmaHalfPathAt_simple p cross a).append + (List.nodup_reverse.mpr (qmaHalfPathAt_simple (qmaGridNeighbor p a) nextCross (qmaPortOpposite a))) + apply List.disjoint_left.mpr + intro z hz hy + obtain ⟨u,hu,hv,he⟩ := qmaHalfPathAt_mem hz + obtain ⟨v,hv1,hv2,hf⟩ := qmaHalfPathAt_mem (List.mem_reverse.mp hy) + have hh := qmaCellTranslate_unique ⟨hu,hv⟩ ⟨hv1,hv2⟩ (he.trans hf.symm) + exact (qmaGridNeighbor_adj p hp.1 hp.2 a).ne hh.1 + +theorem qmaCellCorridor_length (p : ℕ × ℕ) (a : Fin 4) (cross nextCross : Bool) : + 18 ≤ (qmaCellCorridor p a cross nextCross).length ∧ + (qmaCellCorridor p a cross nextCross).length ≤ 21 := by + simp only [qmaCellCorridor,qmaHalfPathAt,List.length_append,List.length_reverse,List.length_map] + cases cross <;> cases nextCross <;> fin_cases a <;> decide + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCrossings.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCrossings.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a7a3e06c4bfe843812fa1773684cfaac57dd94a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellCrossings.lean @@ -0,0 +1,45 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellMatching + +namespace OAI + +/-! An exact finite set of crossing cells, selected from the route visits. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +def pairing (i j : P.Interior) : Finset (Sym2 (Fin 4)) := + qmaPortPairing ![P.port i 0,P.port i 1,P.port j 0,P.port j 1] + +theorem pairing_classify {i j : P.Interior} (hij : i ≠ j) (hc : P.cell i = P.cell j) : + P.pairing i j = qmaCrossPortPairing ∨ P.pairing i j = qmaCornerPortPairing false ∨ + P.pairing i j = qmaCornerPortPairing true := + qmaPortPairing_classify _ (P.two_visits_port_injective hij hc) + +def IsCrossing (p : ℕ × ℕ) : Prop := + ∃ i j : P.Interior, i ≠ j ∧ P.cell i = p ∧ P.cell j = p ∧ P.pairing i j = qmaCrossPortPairing + +def crossingCells : Finset (ℕ × ℕ) := (Finset.univ.image P.cell).filter P.IsCrossing + +@[simp] theorem mem_crossingCells {p : ℕ × ℕ} : p ∈ P.crossingCells ↔ P.IsCrossing p := by + constructor + · intro h + exact (Finset.mem_filter.mp h).2 + · intro h + obtain ⟨i,j,hij,hi,hj,hp⟩ := h + exact Finset.mem_filter.mpr ⟨Finset.mem_image.mpr ⟨i,Finset.mem_univ _,hi⟩,i,j,hij,hi,hj,hp⟩ + +theorem crossingCells_card : P.crossingCells.card ≤ ∑ e, (P.length e-1) := by + calc + _ ≤ (Finset.univ.image P.cell).card := Finset.card_filter_le _ _ + _ ≤ Fintype.card P.Interior := (Finset.card_image_le).trans_eq (Finset.card_univ) + _ = _ := by simp [Interior,Fintype.card_sigma] + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellMatching.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..4485ae94e4fed138dd73e9300ec2ff904478c3c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellMatching.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPassages +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortPairing + +namespace OAI + +/-! Internal visits form a matching on the four ports of each cell. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +abbrev CellVisits (p : ℕ × ℕ) := {i : P.Interior // P.cell i = p} + +def cellPort (p : ℕ × ℕ) (x : P.CellVisits p × Fin 2) : Fin 4 := P.port x.1.val x.2 + +theorem cellPort_injective (p : ℕ × ℕ) : Function.Injective (P.cellPort p) := by + rintro ⟨i,a⟩ ⟨j,b⟩ h + have he : (i.val,a) = (j.val,b) := P.incidence_injective (Prod.ext (i.property.trans j.property.symm) h) + have hi : i = j := Subtype.ext (congrArg Prod.fst he) + have hab : a = b := congrArg Prod.snd he + exact Prod.ext hi hab + +theorem cellVisits_card (p : ℕ × ℕ) : Fintype.card (P.CellVisits p) ≤ 2 := by + have h := Fintype.card_le_of_injective (P.cellPort p) (P.cellPort_injective p) + simp only [Fintype.card_prod,Fintype.card_fin] at h + omega + +theorem different_visits_ports {i j : P.Interior} (hij : i ≠ j) (hc : P.cell i = P.cell j) + (a b : Fin 2) : P.port i a ≠ P.port j b := by + intro h + have he : (i,a) = (j,b) := P.incidence_injective (Prod.ext hc h) + exact hij (congrArg Prod.fst he) + +theorem two_visits_port_injective {i j : P.Interior} (hij : i ≠ j) (hc : P.cell i = P.cell j) : + Function.Injective (![P.port i 0,P.port i 1,P.port j 0,P.port j 1] : Fin 4 → Fin 4) := by + have hi : P.port i 0 ≠ P.port i 1 := (P.port_injective i).ne (by decide) + have hj : P.port j 0 ≠ P.port j 1 := (P.port_injective j).ne (by decide) + have h00 := P.different_visits_ports hij hc 0 0 + have h01 := P.different_visits_ports hij hc 0 1 + have h10 := P.different_visits_ports hij hc 1 0 + have h11 := P.different_visits_ports hij hc 1 1 + intro a b h + fin_cases a <;> fin_cases b <;> simp_all + +def twoVisitsEquiv {i j : P.Interior} (hij : i ≠ j) (hc : P.cell i = P.cell j) : Fin 4 ≃ Fin 4 := + Equiv.ofBijective ![P.port i 0,P.port i 1,P.port j 0,P.port j 1] + ⟨P.two_visits_port_injective hij hc,Finite.surjective_of_injective (P.two_visits_port_injective hij hc)⟩ + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPassages.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPassages.lean new file mode 100644 index 0000000000000000000000000000000000000000..5896650a227217845134e971fd94654f9b5c7633 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPassages.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortRouteData + +namespace OAI + +/-! A visit to an internal coarse cell occupies two different directional ports. -/ + +noncomputable section +namespace ContinuumCoulomb +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +abbrev Interior := Σ e : G.Edge, Fin (P.length e-1) + +def cell (i : P.Interior) : ℕ × ℕ := P.point i.1 (i.2.val+1) + +def armIndex (i : P.Interior) (a : Fin 2) : ℕ := i.2.val+2*a.val + +def arm (i : P.Interior) (a : Fin 2) : ℕ × ℕ := P.point i.1 (P.armIndex i a) + +theorem cell_index_lt (i : P.Interior) : i.2.val+1 < P.length i.1 := by + have hi := i.2.isLt + omega + +theorem armIndex_le (i : P.Interior) (a : Fin 2) : P.armIndex i a ≤ P.length i.1 := by + have hi := i.2.isLt + have ha := a.isLt + dsimp [armIndex] + omega + +theorem arm_adjacent (i : P.Interior) (a : Fin 2) : qmaSquareGrid.Adj (P.cell i) (P.arm i a) := by + have hi := P.cell_index_lt i + fin_cases a + · exact (P.step i.1 i.2.val (by omega)).symm + · exact P.step i.1 (i.2.val+1) hi + +def port (i : P.Interior) (a : Fin 2) : Fin 4 := qmaGridNeighborIndex (P.cell i) (P.arm i a) + +theorem port_spec (i : P.Interior) (a : Fin 2) : + qmaGridNeighbor (P.cell i) (P.port i a) = P.arm i a := + qmaGridNeighborIndex_spec (P.positive i.1 _ (P.cell_index_lt i).le).1 + (P.positive i.1 _ (P.cell_index_lt i).le).2 (P.arm_adjacent i a) + +theorem port_injective (i : P.Interior) : Function.Injective (P.port i) := by + intro a b h + have he := congrArg (qmaGridNeighbor (P.cell i)) h + rw [P.port_spec,P.port_spec] at he + have hi := P.simple i.1 (P.armIndex i a) (P.armIndex i b) + (P.armIndex_le i a) (P.armIndex_le i b) he + apply Fin.ext + dsimp [armIndex] at hi + omega + +theorem cell_eq_same_edge {i j : P.Interior} (he : i.1 = j.1) (hc : P.cell i = P.cell j) : i = j := by + rcases i with ⟨e,i⟩ + rcases j with ⟨f,j⟩ + dsimp only at he + subst f + have hi := P.simple e (i.val+1) (j.val+1) (P.cell_index_lt ⟨e,i⟩).le + (P.cell_index_lt ⟨e,j⟩).le hc + have hij : i = j := Fin.ext (by omega) + subst j + rfl + +theorem incidence_injective : Function.Injective + (fun x : P.Interior × Fin 2 => (P.cell x.1,P.port x.1 x.2)) := by + rintro ⟨i,a⟩ ⟨j,b⟩ h + have hc : P.cell i = P.cell j := congrArg Prod.fst h + have hp : P.port i a = P.port j b := congrArg Prod.snd h + have ha : P.arm i a = P.arm j b := by + rw [← P.port_spec i a,← P.port_spec j b,hc,hp] + have hij : i.1 = j.1 := by + by_contra hef + have hdis := P.edges_disjoint i.1 j.1 hef + have hi := P.cell_index_lt i + have hj := P.cell_index_lt j + have hib := i.2.isLt + have hjb := j.2.isLt + fin_cases a <;> fin_cases b + · exact (hdis i.2.val j.2.val (by omega) (by omega)).1 ⟨ha,hc⟩ + · exact (hdis i.2.val (j.2.val+1) (by omega) hj).2 ⟨ha,hc⟩ + · exact (hdis (i.2.val+1) j.2.val hi (by omega)).2 ⟨hc,ha⟩ + · exact (hdis (i.2.val+1) (j.2.val+1) hi hj).1 ⟨hc,ha⟩ + have he : i = j := P.cell_eq_same_edge hij hc + subst j + have hab : a = b := P.port_injective i hp + subst b + rfl + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..59905b5a2cde7d156a2161ceee6b7115bad1e7a9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathProgram.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteEnumeration +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteProgram +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! Literal rational-register-free programs evaluate all four finite cell path +families, including the two translated halves of an external corridor. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCellPathProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +abbrev TranslateInput := Pair × Pair +def translateCode : TranslateInput → List Bool := prodCode pairCode pairCode + +noncomputable opaque translateProgram : Procedure translateCode pairCode + (fun x => qmaCellTranslate x.1 x.2) := by + let p := Procedure.first pairCode pairCode + let z := Procedure.second pairCode pairCode + let px := (Procedure.first Nat.bits Nat.bits).comp p + let py := (Procedure.second Nat.bits Nat.bits).comp p + let zx := (Procedure.first Nat.bits Nat.bits).comp z + let zy := (Procedure.second Nat.bits Nat.bits).comp z + let c := Procedure.constant translateCode Nat.bits 32 + let x := Procedure.binaryAdd.comp ((Procedure.binaryMul.comp (c.pair px)).pair zx) + let y := Procedure.binaryAdd.comp ((Procedure.binaryMul.comp (c.pair py)).pair zy) + exact (x.pair y).congrFun (by intro x; rfl) + +noncomputable opaque translatedPathProgram (xs : List Pair) : + Procedure pairCode (listCode pairCode) (fun p => xs.map (qmaCellTranslate p)) := + (Procedure.listMapWith (0,0) (0,0) translateProgram).comp + ((Procedure.identity pairCode).pair (Procedure.constant pairCode (listCode pairCode) xs)) + +noncomputable opaque neighborProgram (a : Fin 4) : Procedure pairCode pairCode + (fun p => qmaGridNeighbor p a) := by + let x := Procedure.first Nat.bits Nat.bits + let y := Procedure.second Nat.bits Nat.bits + let c := Procedure.constant pairCode Nat.bits 1 + by_cases h0 : a = 0 + · subst a + exact ((Procedure.binaryAdd.comp (x.pair c)).pair y).congrFun (by intro p; rfl) + by_cases h1 : a = 1 + · subst a + exact (x.pair (Procedure.binaryAdd.comp (y.pair c))).congrFun (by intro p; rfl) + by_cases h2 : a = 2 + · subst a + exact ((Procedure.binarySub.comp (x.pair c)).pair y).congrFun (by intro p; rfl) + have h3 : a = 3 := by omega + subst a + exact (x.pair (Procedure.binarySub.comp (y.pair c))).congrFun (by intro p; rfl) + +noncomputable opaque rayProgram (a : Fin 4) : Procedure pairCode (listCode pairCode) + (fun p => (QMACellRouteBody.ray p a).path) := translatedPathProgram (qmaCellRayPath a) + +noncomputable opaque pairProgram (e : Fin 6) : Procedure pairCode (listCode pairCode) + (fun p => (QMACellRouteBody.pair p e).path) := translatedPathProgram (qmaCellPairPath e) + +noncomputable opaque patchProgram (e : Fin 9) : Procedure pairCode (listCode pairCode) + (fun p => (QMACellRouteBody.patch p e).path) := + (translatedPathProgram (qmaLocalPatchPath e)).congrFun (by + intro p + simp only [qmaLocalPatchPath,List.map_map,Function.comp_def,QMACellRouteBody.path, + qmaCrossingPathAt] + congr 1 + funext z + exact qmaCellTranslate_patch p z) + +noncomputable opaque halfProgram (a : Fin 4) (b : Bool) : Procedure pairCode (listCode pairCode) + (fun p => qmaHalfPathAt p b a) := translatedPathProgram (qmaHalfCorridorPath b a) + +noncomputable opaque corridorProgram (a : Fin 4) (b c : Bool) : + Procedure pairCode (listCode pairCode) (fun p => (QMACellRouteBody.corridor p a b c).path) := by + let first := halfProgram a b + let second := (Procedure.listReverse pairCode (0,0)).comp + ((halfProgram (qmaPortOpposite a) c).comp (neighborProgram a)) + exact (Procedure.listAppend pairCode (0,0)).comp (first.pair second) + +end ContinuumCoulomb.QuantumCellPathProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathTemplates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathTemplates.lean new file mode 100644 index 0000000000000000000000000000000000000000..7df37ead36820f3fcbb353871adfa2ee130607c6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellPathTemplates.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPatchPoints +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortPairing + +namespace OAI + +/-! The six possible ordinary-cell connections and four source rays. The two +opposite pairs are the only disjoint-port pair whose paths cross. -/ + +namespace ContinuumCoulomb + +def qmaCellPairLeft : Fin 6 → Fin 4 := ![0,0,0,1,1,2] +def qmaCellPairRight : Fin 6 → Fin 4 := ![1,2,3,2,3,3] +def qmaCellPairPath : Fin 6 → List (ℕ × ℕ) := ![ + [(23,16),(23,17),(23,18),(23,19),(23,20),(23,21),(23,22),(23,23),(22,23),(21,23),(20,23),(19,23),(18,23),(17,23),(16,23)], + [(23,16),(22,16),(21,16),(20,16),(19,16),(18,16),(17,16),(16,16),(15,16),(14,16),(13,16),(12,16),(11,16),(10,16),(9,16)], + [(23,16),(23,15),(23,14),(23,13),(23,12),(23,11),(23,10),(23,9),(22,9),(21,9),(20,9),(19,9),(18,9),(17,9),(16,9)], + [(16,23),(15,23),(14,23),(13,23),(12,23),(11,23),(10,23),(9,23),(9,22),(9,21),(9,20),(9,19),(9,18),(9,17),(9,16)], + [(16,23),(16,22),(16,21),(16,20),(16,19),(16,18),(16,17),(16,16),(16,15),(16,14),(16,13),(16,12),(16,11),(16,10),(16,9)], + [(9,16),(9,15),(9,14),(9,13),(9,12),(9,11),(9,10),(9,9),(10,9),(11,9),(12,9),(13,9),(14,9),(15,9),(16,9)]] + +def qmaCellRayPath : Fin 4 → List (ℕ × ℕ) := ![ + [(16,16),(17,16),(18,16),(19,16),(20,16),(21,16),(22,16),(23,16)], + [(16,16),(16,17),(16,18),(16,19),(16,20),(16,21),(16,22),(16,23)], + [(16,16),(15,16),(14,16),(13,16),(12,16),(11,16),(10,16),(9,16)], + [(16,16),(16,15),(16,14),(16,13),(16,12),(16,11),(16,10),(16,9)]] + +def qmaCellPort : Fin 4 → ℕ × ℕ := ![(23,16),(16,23),(9,16),(16,9)] + +theorem qmaCellPair_distinct (e : Fin 6) : qmaCellPairLeft e ≠ qmaCellPairRight e := by + fin_cases e <;> decide + +theorem qmaCellPair_complete (a b : Fin 4) (hab : a ≠ b) : + ∃ e : Fin 6, (a = qmaCellPairLeft e ∧ b = qmaCellPairRight e) ∨ + (a = qmaCellPairRight e ∧ b = qmaCellPairLeft e) := by + fin_cases a <;> fin_cases b <;> first | exact (hab rfl).elim | decide + +theorem qmaCellPair_endpoints (e : Fin 6) : + (qmaCellPairPath e).head? = some (qmaCellPort (qmaCellPairLeft e)) ∧ + (qmaCellPairPath e).getLast? = some (qmaCellPort (qmaCellPairRight e)) := by + fin_cases e <;> decide + +theorem qmaCellPair_length (e : Fin 6) : (qmaCellPairPath e).length = 15 := by + fin_cases e <;> decide + +theorem qmaCellPair_chain (e : Fin 6) : (qmaCellPairPath e).IsChain + (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := by + fin_cases e <;> decide + +theorem qmaCellPair_simple (e : Fin 6) : (qmaCellPairPath e).Nodup := by + fin_cases e <;> decide + +theorem qmaCellPair_bounded (e : Fin 6) : + ∀ p ∈ qmaCellPairPath e, 9 ≤ p.1 ∧ p.1 ≤ 23 ∧ 9 ≤ p.2 ∧ p.2 ≤ 23 := by + fin_cases e <;> decide + +theorem qmaCellPair_ports (e : Fin 6) : + Disjoint ((qmaCellPairPath e).drop 1 |>.dropLast).toFinset + (Finset.univ.image qmaCellPort) := by + fin_cases e <;> decide + +theorem qmaCellPair_disjoint (e f : Fin 6) + (h00 : qmaCellPairLeft e ≠ qmaCellPairLeft f) + (h01 : qmaCellPairLeft e ≠ qmaCellPairRight f) + (h10 : qmaCellPairRight e ≠ qmaCellPairLeft f) + (h11 : qmaCellPairRight e ≠ qmaCellPairRight f) + (hc : ¬(e = 1 ∧ f = 4) ∧ ¬(e = 4 ∧ f = 1)) : + Disjoint (qmaCellPairPath e).toFinset (qmaCellPairPath f).toFinset := by + fin_cases e <;> fin_cases f <;> + first | exact (h00 rfl).elim | exact (h01 rfl).elim | + exact (h10 rfl).elim | exact (h11 rfl).elim | + exact (hc.1 ⟨rfl,rfl⟩).elim | exact (hc.2 ⟨rfl,rfl⟩).elim | decide + +theorem qmaCellRay_endpoints (a : Fin 4) : + (qmaCellRayPath a).head? = some (16,16) ∧ + (qmaCellRayPath a).getLast? = some (qmaCellPort a) := by + fin_cases a <;> decide + +theorem qmaCellRay_length (a : Fin 4) : (qmaCellRayPath a).length = 8 := by + fin_cases a <;> decide + +theorem qmaCellRay_chain (a : Fin 4) : (qmaCellRayPath a).IsChain + (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := by + fin_cases a <;> decide + +theorem qmaCellRay_simple (a : Fin 4) : (qmaCellRayPath a).Nodup := by + fin_cases a <;> decide + +theorem qmaCellRay_disjoint (a b : Fin 4) (hab : a ≠ b) : + Disjoint ((qmaCellRayPath a).drop 1).toFinset (qmaCellRayPath b).toFinset := by + fin_cases a <;> fin_cases b <;> first | exact (hab rfl).elim | decide + +theorem qmaCellRay_bounded (a : Fin 4) : + ∀ p ∈ qmaCellRayPath a, 9 ≤ p.1 ∧ p.1 ≤ 23 ∧ 9 ≤ p.2 ∧ p.2 ≤ 23 := by + fin_cases a <;> decide + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteCatalog.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteCatalog.lean new file mode 100644 index 0000000000000000000000000000000000000000..e690fcf2d286d48457029d3d1b87125abdaa8f22 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteCatalog.lean @@ -0,0 +1,136 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellCorridor + +namespace OAI + +/-! A finite catalog of the four local route types used by the physical graph. +Every valid catalog entry is a simple grid path of at most twenty steps. -/ + +namespace ContinuumCoulomb + +inductive QMACellRouteBody where + | ray (cell : ℕ × ℕ) (port : Fin 4) + | pair (cell : ℕ × ℕ) (edge : Fin 6) + | patch (cell : ℕ × ℕ) (edge : Fin 9) + | corridor (cell : ℕ × ℕ) (port : Fin 4) (cross nextCross : Bool) + +namespace QMACellRouteBody + +def path : QMACellRouteBody → List (ℕ × ℕ) + | .ray p a => (qmaCellRayPath a).map (qmaCellTranslate p) + | .pair p e => (qmaCellPairPath e).map (qmaCellTranslate p) + | .patch p e => qmaCrossingPathAt p e + | .corridor p a b c => qmaCellCorridor p a b c + +def source : QMACellRouteBody → ℕ × ℕ + | .ray p _ => qmaExpandedPoint p + | .pair p e => qmaGridPort p (qmaCellPairLeft e) + | .patch p e => qmaPatchTranslate p (qmaCrossingPatchVertex (qmaCrossingPatchLeft e)) + | .corridor p a b _ => qmaCellTranslate p (qmaLocalPort b a) + +def target : QMACellRouteBody → ℕ × ℕ + | .ray p a => qmaGridPort p a + | .pair p e => qmaGridPort p (qmaCellPairRight e) + | .patch p e => qmaPatchTranslate p (qmaCrossingPatchVertex (qmaCrossingPatchRight e)) + | .corridor p a _ c => qmaCellTranslate (qmaGridNeighbor p a) (qmaLocalPort c (qmaPortOpposite a)) + +def Valid : QMACellRouteBody → Prop + | .corridor p _ _ _ => 0 < p.1 ∧ 0 < p.2 + | _ => True + +theorem endpoints (R : QMACellRouteBody) : + R.path.head? = some R.source ∧ R.path.getLast? = some R.target := by + cases R with + | ray p a => + simpa only [path,source,target,List.head?_map,List.getLast?_map, + (qmaCellRay_endpoints a).1,(qmaCellRay_endpoints a).2,Option.map_some, + qmaCellTranslate_port] using + (show some (qmaCellTranslate p (16,16)) = some (qmaExpandedPoint p) ∧ + some (qmaGridPort p a) = some (qmaGridPort p a) from ⟨rfl,rfl⟩) + | pair p e => + simp only [path,source,target,List.head?_map,List.getLast?_map, + (qmaCellPair_endpoints e).1,(qmaCellPair_endpoints e).2,Option.map_some,qmaCellTranslate_port] + constructor <;> trivial + | patch p e => + simp only [path,source,target,qmaCrossingPathAt,List.head?_map,List.getLast?_map, + (qmaCrossingPatch_endpoints e).1,(qmaCrossingPatch_endpoints e).2,Option.map_some] + constructor <;> trivial + | corridor p a b c => exact qmaCellCorridor_endpoints p a b c + +theorem length_bounds (R : QMACellRouteBody) : 3 ≤ R.path.length ∧ R.path.length ≤ 21 := by + cases R with + | ray p a => simp only [path,List.length_map,qmaCellRay_length]; omega + | pair p e => simp only [path,List.length_map,qmaCellPair_length]; omega + | patch p e => + have hlo : 3 ≤ (qmaCrossingPatchPath e).length := by fin_cases e <;> decide + have hhi := qmaCrossingPatch_length e + simp only [path,qmaCrossingPathAt,List.length_map] + omega + | corridor p a b c => + have h := qmaCellCorridor_length p a b c + exact ⟨(by decide : 3 ≤ 18).trans h.1,h.2⟩ + +theorem simple (R : QMACellRouteBody) (hR : R.Valid) : R.path.Nodup := by + cases R with + | ray p a => exact (qmaCellRay_simple a).map (qmaCellTranslate_injective p) + | pair p e => exact (qmaCellPair_simple e).map (qmaCellTranslate_injective p) + | patch p e => exact qmaCrossingPathAt_simple p e + | corridor p a b c => exact qmaCellCorridor_simple p hR a b c + +theorem chain (R : QMACellRouteBody) (hR : R.Valid) : + R.path.IsChain (fun x y => qmaSquareGrid.Adj x y) := by + cases R with + | ray p a => + apply List.isChain_map_of_isChain (qmaCellTranslate p) _ (qmaCellRay_chain a) + intro x y h + change Nat.dist _ _ + Nat.dist _ _ = 1 + simpa only [qmaCellTranslate_step] using h + | pair p e => + apply List.isChain_map_of_isChain (qmaCellTranslate p) _ (qmaCellPair_chain e) + intro x y h + change Nat.dist _ _ + Nat.dist _ _ = 1 + simpa only [qmaCellTranslate_step] using h + | patch p e => exact qmaCrossingPathAt_chain p e + | corridor p a b c => exact qmaCellCorridor_chain p hR a b c + +end QMACellRouteBody + +structure QMACellRoute where + body : QMACellRouteBody + reversed : Bool + +namespace QMACellRoute + +def path (R : QMACellRoute) := if R.reversed then R.body.path.reverse else R.body.path +def source (R : QMACellRoute) := if R.reversed then R.body.target else R.body.source +def target (R : QMACellRoute) := if R.reversed then R.body.source else R.body.target +def Valid (R : QMACellRoute) := R.body.Valid + +theorem endpoints (R : QMACellRoute) : + R.path.head? = some R.source ∧ R.path.getLast? = some R.target := by + rcases R with ⟨body,b⟩ + cases b + · exact body.endpoints + · simpa only [path,source,target,ite_true,List.head?_reverse,List.getLast?_reverse] using + body.endpoints.symm + +theorem length_bounds (R : QMACellRoute) : 3 ≤ R.path.length ∧ R.path.length ≤ 21 := by + rcases R with ⟨body,b⟩ + cases b <;> simpa only [path,Bool.false_eq_true,ite_false,ite_true,List.length_reverse] using body.length_bounds + +theorem simple (R : QMACellRoute) (hR : R.Valid) : R.path.Nodup := by + rcases R with ⟨body,b⟩ + cases b + · exact body.simple hR + · exact List.nodup_reverse.mpr (body.simple hR) + +theorem chain (R : QMACellRoute) (hR : R.Valid) : + R.path.IsChain (fun x y => qmaSquareGrid.Adj x y) := by + rcases R with ⟨body,b⟩ + cases b + · exact body.chain hR + · exact List.isChain_reverse.mpr ((body.chain hR).imp (fun _ _ h => h.symm)) + +end QMACellRoute +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteSupport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..edb2c23f0599bbf11a2195c1289189f272257604 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellRouteSupport.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPermittedRouteSeparation + +namespace OAI + +/-! A catalog path stays in the cells of its two endpoints. This transfers +positivity and box bounds from physical spins to all subdivision sites. -/ + +namespace ContinuumCoulomb + +theorem qmaLocalPort_bounded (b : Bool) (a : Fin 4) : + (qmaLocalPort b a).1 < 32 ∧ (qmaLocalPort b a).2 < 32 := by + cases b <;> fin_cases a <;> decide + +theorem qmaPointCell_localPort (p : ℕ × ℕ) (b : Bool) (a : Fin 4) : + qmaPointCell (qmaCellTranslate p (qmaLocalPort b a)) = p := + qmaCellTranslate_cell p _ (qmaLocalPort_bounded b a) + +theorem qmaPointCell_halfPath {p z : ℕ × ℕ} {b : Bool} {a : Fin 4} + (hz : z ∈ qmaHalfPathAt p b a) : qmaPointCell z = p := by + obtain ⟨u,hu,hv,rfl⟩ := qmaHalfPathAt_mem hz + exact qmaCellTranslate_cell p u ⟨hu,hv⟩ + +theorem qmaPointCell_internalPath {p z : ℕ × ℕ} {e : QMAInternalEdge} + (hz : z ∈ (qmaInternalBody p e).path) : qmaPointCell z = p := by + rw [qmaInternalBody_path] at hz + obtain ⟨u,hu,rfl⟩ := List.mem_map.mp hz + exact qmaCellTranslate_cell p u (qmaInternalPath_bounded e u hu) + +namespace QMACellRouteBody + +theorem path_cells (R : QMACellRouteBody) {z : ℕ × ℕ} (hz : z ∈ R.path) : + qmaPointCell z = qmaPointCell R.source ∨ qmaPointCell z = qmaPointCell R.target := by + rcases qmaCellBody_cases R with ⟨p,e,rfl⟩ | ⟨p,a,b,c,rfl⟩ + · have hp := qmaPointCell_internalPath hz + have hs := qmaPointCell_internalPath (List.mem_of_head? (qmaInternalBody p e).endpoints.1) + exact Or.inl (hp.trans hs.symm) + · rcases List.mem_append.mp hz with h | h + · have hp := qmaPointCell_halfPath h + exact Or.inl (hp.trans (qmaPointCell_localPort p b a).symm) + · have hp := qmaPointCell_halfPath (List.mem_reverse.mp h) + exact Or.inr (hp.trans (qmaPointCell_localPort (qmaGridNeighbor p a) c (qmaPortOpposite a)).symm) + +end QMACellRouteBody +namespace QMACellRoute + +theorem path_cells (R : QMACellRoute) {z : ℕ × ℕ} (hz : z ∈ R.path) : + qmaPointCell z = qmaPointCell R.source ∨ qmaPointCell z = qmaPointCell R.target := by + rcases R with ⟨R,b⟩ + cases b + · exact R.path_cells hz + · have h := R.path_cells (List.mem_reverse.mp hz) + exact h.elim Or.inr Or.inl + +theorem path_positive (R : QMACellRoute) + (hs : 0 < (qmaPointCell R.source).1 ∧ 0 < (qmaPointCell R.source).2) + (ht : 0 < (qmaPointCell R.target).1 ∧ 0 < (qmaPointCell R.target).2) + {z : ℕ × ℕ} (hz : z ∈ R.path) : 0 < z.1 ∧ 0 < z.2 := by + have hp : 0 < (qmaPointCell z).1 ∧ 0 < (qmaPointCell z).2 := by + rcases R.path_cells hz with h | h + · simpa only [h] using hs + · simpa only [h] using ht + change 0 < z.1/32 ∧ 0 < z.2/32 at hp + omega + +theorem path_bounded (R : QMACellRoute) {X Y : ℕ} + (hs : R.source.1 < 32*X ∧ R.source.2 < 32*Y) + (ht : R.target.1 < 32*X ∧ R.target.2 < 32*Y) + {z : ℕ × ℕ} (hz : z ∈ R.path) : z.1 < 32*X ∧ z.2 < 32*Y := by + have hp : (qmaPointCell z).1 < X ∧ (qmaPointCell z).2 < Y := by + rcases R.path_cells hz with h | h + · rw [h] + change R.source.1/32 < X ∧ R.source.2/32 < Y + omega + · rw [h] + change R.target.1/32 < X ∧ R.target.2/32 < Y + omega + change z.1/32 < X ∧ z.2/32 < Y at hp + omega + +end QMACellRoute +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellTranslate.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellTranslate.lean new file mode 100644 index 0000000000000000000000000000000000000000..44fb4993c4f079fa1f365b70379ebc31d589c0d7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellTranslate.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHalfCorridor + +namespace OAI + +/-! Cell-local paths translate injectively and different cells are disjoint. -/ + +namespace ContinuumCoulomb + +def qmaCellTranslate (p z : ℕ × ℕ) : ℕ × ℕ := (32*p.1+z.1,32*p.2+z.2) + +theorem qmaCellTranslate_injective (p : ℕ × ℕ) : Function.Injective (qmaCellTranslate p) := by + intro x y h + exact Prod.ext (Nat.add_left_cancel (congrArg Prod.fst h)) + (Nat.add_left_cancel (congrArg Prod.snd h)) + +theorem qmaCellTranslate_cell (p z : ℕ × ℕ) (hz : z.1 < 32 ∧ z.2 < 32) : + ((qmaCellTranslate p z).1/32,(qmaCellTranslate p z).2/32) = p := by + apply Prod.ext <;> dsimp [qmaCellTranslate] <;> omega + +theorem qmaCellTranslate_unique {p q x y : ℕ × ℕ} + (hx : x.1 < 32 ∧ x.2 < 32) (hy : y.1 < 32 ∧ y.2 < 32) + (h : qmaCellTranslate p x = qmaCellTranslate q y) : p = q ∧ x = y := by + have he := congrArg (fun z : ℕ × ℕ => (z.1/32,z.2/32)) h + rw [qmaCellTranslate_cell p x hx,qmaCellTranslate_cell q y hy] at he + subst q + exact ⟨rfl,qmaCellTranslate_injective p h⟩ + +theorem qmaCellTranslate_step (p x y : ℕ × ℕ) : + Nat.dist (qmaCellTranslate p x).1 (qmaCellTranslate p y).1+ + Nat.dist (qmaCellTranslate p x).2 (qmaCellTranslate p y).2 = + Nat.dist x.1 y.1+Nat.dist x.2 y.2 := by + simp only [qmaCellTranslate,Nat.dist_add_add_left] + +theorem qmaCellTranslate_port (p : ℕ × ℕ) (a : Fin 4) : + qmaCellTranslate p (qmaCellPort a) = qmaGridPort p a := by + fin_cases a <;> rfl + +theorem qmaCellTranslate_inner (p : ℕ × ℕ) (a : Fin 4) : + qmaCellTranslate p (qmaInnerPort (0,0) a) = qmaInnerPort p a := by + fin_cases a <;> rfl + +theorem qmaCellTranslate_patch (p z : ℕ × ℕ) : + qmaCellTranslate p (10+z.1,10+z.2) = qmaPatchTranslate p z := by + simp only [qmaCellTranslate,qmaPatchTranslate,Nat.add_assoc] + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellVisitPaths.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellVisitPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..6462d7ad09518e224ff507530f6eab8b0425ecb6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCellVisitPaths.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPathTemplates +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPairSupport + +namespace OAI + +/-! The actual two-port visits choose compatible ordinary-cell paths. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +def cellPairIndex (i : P.Interior) : Fin 6 := + Classical.choose (qmaCellPair_complete (P.port i 0) (P.port i 1) + ((P.port_injective i).ne (by decide))) + +theorem cellPairIndex_spec (i : P.Interior) : + (P.port i 0 = qmaCellPairLeft (P.cellPairIndex i) ∧ + P.port i 1 = qmaCellPairRight (P.cellPairIndex i)) ∨ + (P.port i 0 = qmaCellPairRight (P.cellPairIndex i) ∧ + P.port i 1 = qmaCellPairLeft (P.cellPairIndex i)) := + Classical.choose_spec (qmaCellPair_complete (P.port i 0) (P.port i 1) + ((P.port_injective i).ne (by decide))) + +theorem cellPairIndex_pair (i : P.Interior) : + s(qmaCellPairLeft (P.cellPairIndex i),qmaCellPairRight (P.cellPairIndex i)) = + s(P.port i 0,P.port i 1) := by + rcases P.cellPairIndex_spec i with ⟨ha,hb⟩ | ⟨ha,hb⟩ + · rw [ha,hb] + · rw [ha,hb] + exact Sym2.eq_swap + +theorem cellPairIndex_left (i : P.Interior) : + qmaCellPairLeft (P.cellPairIndex i) = P.port i 0 ∨ + qmaCellPairLeft (P.cellPairIndex i) = P.port i 1 := by + rcases P.cellPairIndex_spec i with h | h + · exact Or.inl h.1.symm + · exact Or.inr h.2.symm + +theorem cellPairIndex_right (i : P.Interior) : + qmaCellPairRight (P.cellPairIndex i) = P.port i 0 ∨ + qmaCellPairRight (P.cellPairIndex i) = P.port i 1 := by + rcases P.cellPairIndex_spec i with h | h + · exact Or.inr h.2.symm + · exact Or.inl h.1.symm + +theorem cellPairIndex_non_cross {i j : P.Interior} (hij : i ≠ j) + (hc : P.cell i = P.cell j) (hn : ¬P.IsCrossing (P.cell i)) : + ¬(P.cellPairIndex i = 1 ∧ P.cellPairIndex j = 4) ∧ + ¬(P.cellPairIndex i = 4 ∧ P.cellPairIndex j = 1) := by + have hp : P.pairing i j = + {s(qmaCellPairLeft (P.cellPairIndex i),qmaCellPairRight (P.cellPairIndex i)), + s(qmaCellPairLeft (P.cellPairIndex j),qmaCellPairRight (P.cellPairIndex j))} := by + rw [P.cellPairIndex_pair,P.cellPairIndex_pair] + rfl + constructor + · rintro ⟨hi,hj⟩ + apply hn + refine ⟨i,j,hij,rfl,hc.symm,?_⟩ + rw [hp,hi,hj] + rfl + · rintro ⟨hi,hj⟩ + apply hn + refine ⟨i,j,hij,rfl,hc.symm,?_⟩ + rw [hp,hi,hj] + change {s(1,3),s(0,2)} = {s(0,2),s(1,3)} + exact Finset.pair_comm _ _ + +theorem ordinary_visit_paths_disjoint {i j : P.Interior} (hij : i ≠ j) + (hc : P.cell i = P.cell j) (hn : ¬P.IsCrossing (P.cell i)) : + Disjoint (qmaCellPairPath (P.cellPairIndex i)).toFinset + (qmaCellPairPath (P.cellPairIndex j)).toFinset := by + have hne (x y : Fin 4) (hx : x = P.port i 0 ∨ x = P.port i 1) + (hy : y = P.port j 0 ∨ y = P.port j 1) : x ≠ y := by + rcases hx with rfl | rfl <;> rcases hy with rfl | rfl + all_goals exact P.different_visits_ports hij hc _ _ + exact qmaCellPair_disjoint _ _ + (hne _ _ (P.cellPairIndex_left i) (P.cellPairIndex_left j)) + (hne _ _ (P.cellPairIndex_left i) (P.cellPairIndex_right j)) + (hne _ _ (P.cellPairIndex_right i) (P.cellPairIndex_left j)) + (hne _ _ (P.cellPairIndex_right i) (P.cellPairIndex_right j)) + (P.cellPairIndex_non_cross hij hc hn) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumChosenSlots.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumChosenSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b8f21cfb5cae0fd6a492d7dfbe3c060479df6f2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumChosenSlots.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteCongestion + +namespace OAI + +/-! Geometry only needs a bounded slot map injective inside each cell. This +interface permits the literal ordinal slot map without fixing abstract choices. -/ + +noncomputable section +namespace ContinuumCoulomb + +structure QMACellSlots {Q : Type*} {rows width : ℕ} + (cell : Q → QMAGridCell rows width) (A : ℕ) where + index : Q → Fin A + injective : ∀ {q r}, cell q = cell r → index q = index r → q=r + +namespace QMACellSlots +variable {Q : Type*} {rows width A : ℕ} {cell : Q → QMAGridCell rows width} + + def ofDensity [Fintype Q] + (h : ∀ p, (Finset.univ.filter (fun q => cell q=p)).card ≤ A) : QMACellSlots cell A := + ⟨qmaGridSlot cell h,qmaGridSlot_injective_on_cell cell h⟩ + + def site (S : QMACellSlots cell A) (q : Q) : QMAFineGrid rows width A := + (finProdFinEquiv ((cell q).1,S.index q),(cell q).2) + + theorem site_injective (S : QMACellSlots cell A) : Function.Injective S.site := by + intro q r h + have hx := finProdFinEquiv.injective (congrArg Prod.fst h) + have hrow : (cell q).1 = (cell r).1 := + congrArg (fun x : Fin (rows+1) × Fin A => x.1) hx + have hcol : (cell q).2 = (cell r).2 := + congrArg (fun x : QMAFineGrid rows width A => x.2) h + have hslot : S.index q = S.index r := + congrArg (fun x : Fin (rows+1) × Fin A => x.2) hx + exact S.injective (Prod.ext hrow hcol) hslot + + theorem site_cell (S : QMACellSlots cell A) (hA : 0 < A) (q : Q) : + qmaFineGridCell hA (S.site q) = cell q := by + apply Prod.ext + · apply Fin.ext + change ((S.index q).val+A*(cell q).1.val)/A = (cell q).1.val + rw [Nat.add_mul_div_left _ _ hA,Nat.div_eq_of_lt (S.index q).isLt,zero_add] + · rfl + + theorem site_bounds (S : QMACellSlots cell A) (q : Q) (p : QMAGridCell rows width) + (hne : QMAGridCellsNear (cell q) p) : + (S.site q).1.val < (p.1.val+2)*A ∧ p.1.val*A ≤ (S.site q).1.val+A ∧ + (S.site q).2.val ≤ p.2.val+1 ∧ p.2.val ≤ (S.site q).2.val+1 := by + obtain ⟨hr,hr',hc,hc'⟩ := hne + have hs := (S.index q).isLt + have hm := Nat.mul_le_mul_right A hr + have hm' := Nat.mul_le_mul_right A hr' + change (S.index q).val+A*(cell q).1.val < (p.1.val+2)*A ∧ + p.1.val*A ≤ (S.index q).val+A*(cell q).1.val+A ∧ _ + exact ⟨by nlinarith,by nlinarith,hc,hc'⟩ + + theorem route_length (S : QMACellSlots cell A) (p q : Q) + (a : QMAGridCell rows width) (hp : QMAGridCellsNear (cell p) a) + (hq : QMAGridCellsNear (cell q) a) : + qmaManhattanLength (qmaFineGridNat (S.site p)) (qmaFineGridNat (S.site q)) ≤ 3*A+2 := by + obtain ⟨hp1,hp2,hp3,hp4⟩ := S.site_bounds p a hp + obtain ⟨hq1,hq2,hq3,hq4⟩ := S.site_bounds q a hq + simp only [Nat.add_mul] at hp1 hq1 + unfold qmaManhattanLength qmaFineGridNat Nat.dist + omega + + def color (S : QMACellSlots cell A) (q : Q) : Fin 3 × Fin 3 × Fin A := + (⟨(cell q).1.val%3,Nat.mod_lt _ (by decide)⟩, + ⟨(cell q).2.val%3,Nat.mod_lt _ (by decide)⟩,S.index q) + + theorem color_eq (S : QMACellSlots cell A) {p q : Q} (he : S.color p = S.color q) + (hr : (cell p).1.val ≤ (cell q).1.val+2) (hr' : (cell q).1.val ≤ (cell p).1.val+2) + (hc : (cell p).2.val ≤ (cell q).2.val+2) (hc' : (cell q).2.val ≤ (cell p).2.val+2) : p=q := by + have hrow := congrArg (fun c : Fin 3 × Fin 3 × Fin A => c.1.val) he + have hcol := congrArg (fun c : Fin 3 × Fin 3 × Fin A => c.2.1.val) he + have hslot := congrArg (fun c : Fin 3 × Fin 3 × Fin A => c.2.2) he + change (cell p).1.val%3 = (cell q).1.val%3 at hrow + change (cell p).2.val%3 = (cell q).2.val%3 at hcol + apply S.injective _ hslot + apply Prod.ext <;> apply Fin.ext <;> omega + + theorem color_disjoint {E : Type*} (S : QMACellSlots cell A) + (location : E → QMAGridCell rows width) (sites : Q → Finset E) + (hl : ∀ q, ∀ z ∈ sites q, QMAGridCellsNear (location z) (cell q)) + {p q : Q} (hpq : p ≠ q) (he : S.color p = S.color q) : Disjoint (sites p) (sites q) := by + apply Finset.disjoint_left.mpr + intro z hz hz' + have hp := hl p z hz + have hq := hl q z hz' + apply hpq + apply S.color_eq he <;> dsimp [QMAGridCellsNear] at hp hq <;> omega + +end QMACellSlots +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitCode.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..225dc5f6852c08e881bb09024df7ff51d1f452d1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitCode.lean @@ -0,0 +1,150 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePrograms +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCircuitPadding +import OAI.Computability.QuantumFactoring.BitStackSumInjection + +namespace OAI + +/-! Actual parsing of the verifier's prefix circuit encoding. Register sizes +are clipped to supplied unary bounds before later finite enumerations. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCircuitCode +open ExactQuantumFactoring.BitStackProgram +open PrefixPrograms + +def gateCode (g : QMAGate) : List Bool := + sumCode (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits) (qmaGateEquiv g) + +def rawCode (c : QMACircuit) : List Bool := + prodCode Nat.bits (prodCode Nat.bits (listCode gateCode)) (qmaCircuitEquiv c) + +def circuitCode (c : QMACircuit) : List Bool := + prodCode unaryCode (prodCode unaryCode (listCode gateCode)) (qmaCircuitEquiv c) + +private def sumView {α β : Type} (x : (α ⊕ β) × List Bool) : + (α × List Bool) ⊕ (β × List Bool) := + match x.1 with + | .inl a => .inl (a,x.2) + | .inr b => .inr (b,x.2) + +private noncomputable def sumSplitter {α β : Type} + (c : BinaryEncoding.Codec α) (d : BinaryEncoding.Codec β) + (pc : Splitter c) (pd : Splitter d) : Splitter (BinaryEncoding.sum c d) := by + let outCode := prodCode (BinaryEncoding.sum c d).encode id + let left : Procedure (prefixCode c) outCode + (fun x : α × List Bool => (Sum.inl x.1,x.2)) := + (((Procedure.sumLeft c.encode d.encode).comp + ((Procedure.first c.encode id).comp pc)).pair + ((Procedure.second c.encode id).comp pc)).result (by intro x; rfl) + let right : Procedure (prefixCode d) outCode + (fun x : β × List Bool => (Sum.inr x.1,x.2)) := + (((Procedure.sumRight c.encode d.encode).comp + ((Procedure.first d.encode id).comp pd)).pair + ((Procedure.second d.encode id).comp pd)).result (by intro x; rfl) + exact (((Procedure.casesSum left right).precompose sumView).congrEncoding + (by rintro ⟨a,s⟩; cases a <;> rfl) (by intro x; rfl)).congrFun (by + rintro ⟨a,s⟩ + cases a <;> rfl) + +noncomputable def gateSplitter : Splitter qmaGateCodec := + SourcePrograms.equivSplitter _ qmaGateEquiv + (sumSplitter _ _ (sumSplitter _ _ natural natural) + (PrefixPrograms.pair _ _ natural natural)) + +noncomputable def gateInput : Procedure qmaGateCodec.encode gateCode id := by + let left := Procedure.casesSum + ((Procedure.sumLeft Nat.bits Nat.bits).comp EncodingPrograms.naturalInput) + ((Procedure.sumRight Nat.bits Nat.bits).comp EncodingPrograms.naturalInput) + let pairInput := SourcePrograms.pairInput BinaryEncoding.natural BinaryEncoding.natural natural + let right := ((EncodingPrograms.naturalInput.comp (Procedure.first _ _)).pair + (EncodingPrograms.naturalInput.comp (Procedure.second _ _))).comp pairInput + let first := (Procedure.sumLeft (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits)).comp left + let second := (Procedure.sumRight (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits)).comp right + exact ((Procedure.casesSum first second).precompose qmaGateEquiv).result (by + intro g + cases g <;> rfl) + +theorem gate_length_pos (g : QMAGate) : 0 < (qmaGateCodec.encode g).length := by + cases g <;> exact Nat.succ_pos _ + +noncomputable def gateListSplitter : Splitter (BinaryEncoding.list qmaGateCodec) := + PrefixListPrograms.listSplitter qmaGateCodec gateSplitter (.hadamard 0) gate_length_pos + +noncomputable def gateListInput : + Procedure (BinaryEncoding.list qmaGateCodec).encode (listCode gateCode) id := + ((Procedure.listMap (.hadamard 0) (.hadamard 0) gateInput).comp + (PrefixListPrograms.listInput qmaGateCodec gateSplitter (.hadamard 0) gate_length_pos)).congrFun + (by intro gs; simp only [Function.comp_apply,List.map_id,id_eq]) + +private def tailCodec := BinaryEncoding.pair BinaryEncoding.natural + (BinaryEncoding.list qmaGateCodec) + +noncomputable def circuitTuple : + Procedure qmaCircuitCodec.encode (prodCode BinaryEncoding.natural.encode tailCodec.encode) + qmaCircuitEquiv := + (SourcePrograms.pairInput BinaryEncoding.natural tailCodec natural).precompose qmaCircuitEquiv + +noncomputable def workInput : Procedure qmaCircuitCodec.encode Nat.bits QMACircuit.work := + EncodingPrograms.naturalInput.comp ((Procedure.first _ _).comp circuitTuple) + +private noncomputable def restInput : + Procedure qmaCircuitCodec.encode + (prodCode BinaryEncoding.natural.encode (BinaryEncoding.list qmaGateCodec).encode) + (fun c => (c.witness,c.gates)) := + (SourcePrograms.pairInput BinaryEncoding.natural (BinaryEncoding.list qmaGateCodec) natural).comp + ((Procedure.second _ _).comp circuitTuple) + +noncomputable def witnessInput : Procedure qmaCircuitCodec.encode Nat.bits QMACircuit.witness := + EncodingPrograms.naturalInput.comp ((Procedure.first _ _).comp restInput) + +noncomputable def gatesInput : Procedure qmaCircuitCodec.encode (listCode gateCode) QMACircuit.gates := + gateListInput.comp ((Procedure.second _ _).comp restInput) + +noncomputable def rawInput : Procedure qmaCircuitCodec.encode rawCode id := + (workInput.pair (witnessInput.pair gatesInput)).result (by intro c; rfl) + +def cap (x : ℕ × QMACircuit) : QMACircuit := + ⟨min x.1 x.2.work,min x.1 x.2.witness,x.2.gates⟩ + +noncomputable def boundedInput : + Procedure (prodCode unaryCode qmaCircuitCodec.encode) circuitCode cap := by + let b := Procedure.first unaryCode qmaCircuitCodec.encode + let c := Procedure.second unaryCode qmaCircuitCodec.encode + let work := Procedure.clippedUnary.comp (b.pair (workInput.comp c)) + let witness := Procedure.clippedUnary.comp (b.pair (witnessInput.comp c)) + exact (work.pair (witness.pair (gatesInput.comp c))).result (by intro x; rfl) + +theorem cap_eq (b : ℕ) (c : QMACircuit) (hw : c.work ≤ b) (hv : c.witness ≤ b) : + cap (b,c)=c := by + cases c + simp only [cap,min_eq_right hw,min_eq_right hv] + +theorem cap_eq_of_wellFormed (b : ℕ) (c : QMACircuit) (hc : c.WellFormed) + (hw : c.work ≤ b) : cap (b,c)=c := + cap_eq b c hw (hc.1.trans hw) + +noncomputable def workProgram : Procedure circuitCode unaryCode QMACircuit.work := + (Procedure.first unaryCode (prodCode unaryCode (listCode gateCode))).precompose qmaCircuitEquiv + +private noncomputable def tailProgram : + Procedure circuitCode (prodCode unaryCode (listCode gateCode)) + (fun c => (c.witness,c.gates)) := + (Procedure.second unaryCode (prodCode unaryCode (listCode gateCode))).precompose qmaCircuitEquiv + +noncomputable def witnessProgram : Procedure circuitCode unaryCode QMACircuit.witness := + (Procedure.first unaryCode (listCode gateCode)).comp tailProgram + +noncomputable def gatesProgram : Procedure circuitCode (listCode gateCode) QMACircuit.gates := + (Procedure.second unaryCode (listCode gateCode)).comp tailProgram + +noncomputable def nonemptyProgram : Procedure circuitCode circuitCode qmaNonemptyCircuit := by + let extra := Procedure.constant circuitCode (listCode gateCode) + [QMAGate.hadamard 0,QMAGate.hadamard 0] + let gates := (Procedure.listAppend gateCode (.hadamard 0)).comp (gatesProgram.pair extra) + exact (workProgram.pair (witnessProgram.pair gates)).result (by intro c; rfl) + +end ContinuumCoulomb.QuantumCircuitCode + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPadding.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPadding.lean new file mode 100644 index 0000000000000000000000000000000000000000..af54dd399e3bbefaa31d84a152f307a87ee78323 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPadding.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialXZBounds + +namespace OAI + +/-! Two cancelling Hadamards remove the empty-circuit exception without changing acceptance. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Classical + +theorem qmaHadamard_selfAdjoint : qmaHadamard.conjTranspose = qmaHadamard := by + ext a b + fin_cases a <;> fin_cases b <;> + simp [qmaHadamard,Matrix.conjTranspose_apply,bellScale_star] + +theorem qmaHadamard_square : qmaHadamard*qmaHadamard = 1 := by + simpa only [qmaHadamard_selfAdjoint] using qmaHadamard_gram + +theorem qmaGateMatrix_hadamard_square (work i : ℕ) : + qmaGateMatrix work (.hadamard i)*qmaGateMatrix work (.hadamard i) = 1 := by + change sourceTensor _ _*sourceTensor _ _ = _ + rw [sourceTensor_mul,← sourceTensor_one (work+1)] + congr 1 + funext k + split_ifs <;> simp [qmaHadamard_square] + +def qmaNonemptyCircuit (c : QMACircuit) : QMACircuit := + ⟨c.work,c.witness,c.gates++[.hadamard 0,.hadamard 0]⟩ + +theorem qmaNonemptyCircuit_wellFormed (c : QMACircuit) (hc : c.WellFormed) : + (qmaNonemptyCircuit c).WellFormed := by + refine ⟨hc.1,?_⟩ + intro g hg + rcases List.mem_append.mp hg with hg | hg + · exact hc.2 g hg + · simp only [List.mem_cons,List.not_mem_nil,or_false] at hg + rcases hg with rfl | rfl <;> exact Nat.succ_pos _ + +theorem qmaNonemptyCircuit_matrix (c : QMACircuit) : + qmaCircuitMatrix (qmaNonemptyCircuit c) = qmaCircuitMatrix c := by + change qmaGateProduct c.work (c.gates++[.hadamard 0,.hadamard 0]) = _ + rw [qmaGateProduct_append] + have hh : qmaGateProduct c.work [.hadamard 0,.hadamard 0] = 1 := by + simpa only [qmaGateProduct,qmaCircuitMatrix,List.foldl_cons,List.foldl_nil,mul_one] using + qmaGateMatrix_hadamard_square c.work 0 + rw [hh,one_mul] + rfl + +theorem qmaNonemptyCircuit_acceptance (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaAcceptance (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) psi = + qmaAcceptance c hc psi := by + unfold qmaAcceptance + rw [qmaNonemptyCircuit_matrix] + rfl + +theorem qmaNonemptyCircuit_length (c : QMACircuit) : + (qmaNonemptyCircuit c).gates.length = c.gates.length+2 := by + simp [qmaNonemptyCircuit] + +theorem qmaNonemptyCircuit_nearest (c : QMACircuit) : + (qmaNearestCircuit (qmaNonemptyCircuit c)).gates ≠ [] := by + simp [qmaNonemptyCircuit,List.flatMap_append,qmaNearestGate] + +theorem qmaNonemptyCircuit_sparse_pos (c : QMACircuit) : + 0 < (qmaSparseCircuit (qmaNonemptyCircuit c)).gates.length := by + have hn := List.length_pos_iff.mpr (qmaNonemptyCircuit_nearest c) + change 0 < (qmaSweepCircuitFrom _ _ 0 _ _).length + rw [qmaSweepCircuitFrom_length] + exact Nat.mul_pos (by omega) hn + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPauli.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPauli.lean new file mode 100644 index 0000000000000000000000000000000000000000..411eff5448fc6169f0f219cc2d85333e7caf256b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPauli.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalCore +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliParity + +namespace OAI + +/-! An explicit polynomial-size Pauli family for the actual real circuit +Hamiltonian. Every nonzero coefficient has even Y parity. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +abbrev QMACircuitPauliTerm (c : QMACircuit) := + (i : QMACircuitTerm c) × ({x // x ∈ qmaRealCircuitTermSites c i} → Fin 4) + +def qmaCircuitPauliCoefficient (c : QMACircuit) (p : QMACircuitPauliTerm c) : ℝ := + (qmaPauliCoefficient (qmaLocalCore (qmaRealCircuitTermSites c p.1) + (qmaRealCircuitTermMatrix c p.1)) p.2).re + +def qmaCircuitPauliMatrix (c : QMACircuit) (p : QMACircuitPauliTerm c) : + Matrix (Unit ⊕ QMACircuitQubit c → Fin 2) (Unit ⊕ QMACircuitQubit c → Fin 2) ℂ := + (qmaCircuitPauliCoefficient c p : ℂ) • + qmaLocalLift (qmaRealCircuitTermSites c p.1) (qmaPauliWord p.2) + +theorem qmaCircuitPauli_sum (c : QMACircuit) : + (∑ p : QMACircuitPauliTerm c, qmaCircuitPauliMatrix c p) = qmaRealQubitHamiltonian c := by + rw [Fintype.sum_sigma] + have he (i : QMACircuitTerm c) : (∑ w : {x // x ∈ qmaRealCircuitTermSites c i} → Fin 4, + qmaCircuitPauliMatrix c ⟨i,w⟩) = qmaRealCircuitTermMatrix c i := + (qmaRealCircuitTerm_local c i).pauli_expansion (qmaRealCircuitTerm_hermitian c i) + simp_rw [he] + exact qmaRealCircuitTerm_sum c + +theorem qmaCircuitPauli_count (c : QMACircuit) : + Fintype.card (QMACircuitPauliTerm c) ≤ 4096*(2*c.gates.length+c.work+5) := by + calc + _ = ∑ i : QMACircuitTerm c, 4^(qmaRealCircuitTermSites c i).card := by + simp only [QMACircuitPauliTerm,Fintype.card_sigma,Fintype.card_fun, + Fintype.card_fin,Fintype.card_coe] + _ ≤ ∑ _i : QMACircuitTerm c, 4096 := by + apply Finset.sum_le_sum + intro i _ + have h := qmaRealCircuitTerm_support_card c i + have hp := pow_le_pow_right₀ (by norm_num : (1:ℕ) ≤ 4) h + exact hp.trans (by norm_num) + _ = _ := by + rw [Finset.sum_const] + simp only [nsmul_eq_mul,Finset.card_univ,qmaCircuitTerm_card] + exact Nat.mul_comm _ _ + +theorem qmaCircuitPauli_odd_zero (c : QMACircuit) (p : QMACircuitPauliTerm c) + (hp : Odd (qmaPauliYCount p.2)) : qmaCircuitPauliCoefficient c p = 0 := by + have hH := qmaLocalCore_hermitian (qmaRealCircuitTermSites c p.1) + (qmaRealCircuitTermMatrix c p.1) (qmaRealCircuitTerm_hermitian c p.1) + have hR := qmaLocalCore_real (qmaRealCircuitTermSites c p.1) + (qmaRealCircuitTermMatrix c p.1) (qmaRealCircuitTerm_real c p.1) + exact congrArg Complex.re (qmaPauliCoefficient_odd_zero _ hH hR p.2 hp) + +theorem qmaCircuitPauli_support (c : QMACircuit) (p : QMACircuitPauliTerm c) : + QMALocalOn (qmaRealCircuitTermSites c p.1) (qmaCircuitPauliMatrix c p) := by + apply QMALocalOn.smul + exact ⟨qmaPauliWord p.2,rfl⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPromise.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPromise.lean new file mode 100644 index 0000000000000000000000000000000000000000..50e4aaac338cb1e13c8552551507fddb8987b0e7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitPromise.lean @@ -0,0 +1,37 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumVerifier + +namespace OAI + +/-! The finite circuit acceptance promise, with its actual polynomial +reduction from every verifier in the fixed QMA model. -/ + +noncomputable section +open Set +namespace ContinuumCoulomb + +def qmaCircuitPromise : PromiseProblem QMACircuit where + yes := {c | ∃ hc : c.WellFormed, + ∃ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 ∧ 2/3 ≤ qmaAcceptance c hc psi} + no := {c | ∃ hc : c.WellFormed, + ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3} + disjoint := by + apply Set.disjoint_left.mpr + rintro c ⟨hc,psi,hpsi,hyes⟩ ⟨hc',hno⟩ + have hn := hno psi hpsi + linarith + +theorem qmaCircuitPromise_qmaHard : QMAHard qmaCircuitCodec.encode qmaCircuitPromise := by + rintro P ⟨V,hyes,hno⟩ + refine ⟨{ map := V.generate, polynomialTime := V.uniform, maps_yes := ?_, maps_no := ?_ }⟩ + · intro x hx + exact ⟨V.wellFormed x,hyes x hx⟩ + · intro x hx + exact ⟨V.wellFormed x,hno x hx⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitTwoLocal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitTwoLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..7374ff444b29bb0f892e7a32a3f8534c2946b785 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCircuitTwoLocal.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalModel + +namespace OAI + +/-! The actual unary-clock circuit matrix admits a polynomial-size real +2-local approximation with an explicit finite interaction family. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaCircuitLocalModel (c : QMACircuit) : QMARealLocalModel 6 where + Q := Unit ⊕ QMACircuitQubit c + Term := QMACircuitTerm c + qFinite := inferInstance + qDecidable := inferInstance + termFinite := inferInstance + matrix := qmaRealCircuitTermMatrix c + sites := qmaRealCircuitTermSites c + localOn := qmaRealCircuitTerm_local c + card := qmaRealCircuitTerm_support_card c + hermitian := qmaRealCircuitTerm_hermitian c + real := qmaRealCircuitTerm_real c + +theorem qmaCircuitLocalModel_energy (c : QMACircuit) : + (qmaCircuitLocalModel c).energy = MediatorGraph.normalizedBottom (qmaRealQubitHamiltonian c) := by + change MediatorGraph.normalizedBottom (∑ i, qmaRealCircuitTermMatrix c i) = _ + rw [qmaRealCircuitTerm_sum] + +theorem qmaCircuitLocalModel_size (c : QMACircuit) : + (qmaCircuitLocalModel c).qubits = c.gates.length+c.work+4 ∧ + (qmaCircuitLocalModel c).terms = 2*c.gates.length+c.work+5 := + ⟨qmaRealCircuitQubit_card c,qmaCircuitTerm_card c⟩ + +theorem qmaCircuitLocalModel_yes (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + (qmaCircuitLocalModel c).energy ≤ 1/(3*(c.gates.length+1:ℝ)) := by + obtain ⟨u,hu,he⟩ := qmaRealQubitHamiltonian_accepting c hc psi hpsi hacc + rw [qmaCircuitLocalModel_energy] + apply (qmaNormalizedBottom_le _ u hu).trans + apply (le_div_iff₀ (by positivity : 0 < 3*(c.gates.length+1:ℝ))).mpr + linarith + +theorem qmaCircuitLocalModel_no (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) : + 2/(5*(c.gates.length+1:ℝ)) ≤ (qmaCircuitLocalModel c).energy := by + rw [qmaCircuitLocalModel_energy] + apply le_qmaNormalizedBottom _ (EuclideanSpace.single (fun _ => (0:Fin 2)) (1:ℂ)) + (by simp [PiLp.norm_single]) + intro u hu + have hs := qmaRealQubitHamiltonian_sound c hc hsound u + rw [hu,one_pow,mul_one] at hs + apply (div_le_iff₀ (by positivity : 0 < 5*(c.gates.length+1:ℝ))).mpr + linarith + +theorem qmaCircuit_two_local (c : QMACircuit) {N : ℝ} (hN : 1 ≤ N) : + ∃ G : QMARealLocalModel 2, + |G.energy-MediatorGraph.normalizedBottom (qmaRealQubitHamiltonian c)| ≤ 1/N ∧ + G.qubits ≤ c.gates.length+c.work+4+1077940224*(2*c.gates.length+c.work+5) ∧ + G.terms ≤ 7516192768*(2*c.gates.length+c.work+5) := by + obtain ⟨G,hG,hQ,hT⟩ := (qmaCircuitLocalModel c).six_to_two hN + rw [qmaCircuitLocalModel_energy] at hG + rw [(qmaCircuitLocalModel_size c).1,(qmaCircuitLocalModel_size c).2] at hQ + rw [(qmaCircuitLocalModel_size c).2] at hT + exact ⟨G,hG,hQ,hT⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockAnchor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockAnchor.lean new file mode 100644 index 0000000000000000000000000000000000000000..194947805433a283e8c87a0fb3c43bc3e486c82f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockAnchor.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumClockPath +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSparseFirstUse + +namespace OAI + +/-! The two endpoint clock bits and each internal clock bit have a local time anchor. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaClockAnchorIndex (T : ℕ) (hT : 0 < T) (b : Fin (T+2)) : Fin T := + ⟨min (b.val-1) (T-1),by omega⟩ + +theorem qmaClockAnchorIndex_near (T : ℕ) (hT : 0 < T) (t : Fin T) (b : Fin (T+2)) + (hb : t.val ≤ b.val ∧ b.val ≤ t.val+2) : + (qmaClockAnchorIndex T hT b).val ≤ t.val+1 ∧ t.val ≤ (qmaClockAnchorIndex T hT b).val+1 := by + change min (b.val-1) (T-1) ≤ t.val+1 ∧ t.val ≤ min (b.val-1) (T-1)+1 + have ht := t.isLt + omega + +theorem qmaClockAnchorIndex_middle (T : ℕ) (hT : 0 < T) (t : Fin T) : + qmaClockAnchorIndex T hT (qmaClockMiddle T t) = t := by + apply Fin.ext + change min (t.val+1-1) (T-1) = t.val + have ht := t.isLt + omega + +theorem qmaClockAnchorIndex_fiber (T : ℕ) (hT : 0 < T) (t : Fin T) (b : Fin (T+2)) + (hb : qmaClockAnchorIndex T hT b = t) : + b = 0 ∨ b = qmaClockMiddle T t ∨ b = Fin.last (T+1) := by + have hv := congrArg Fin.val hb + change min (b.val-1) (T-1) = t.val at hv + have ht := t.isLt + have hb' := b.isLt + have h : b.val = 0 ∨ b.val = t.val+1 ∨ b.val = T+1 := by omega + exact h.imp (fun h => Fin.ext h) (fun h => h.imp (fun h => Fin.ext h) (fun h => Fin.ext h)) + +theorem qmaClockAnchorIndex_fiber_card (T : ℕ) (hT : 0 < T) (t : Fin T) : + (Finset.univ.filter (fun b : Fin (T+2) => qmaClockAnchorIndex T hT b = t)).card ≤ 3 := by + have hs : Finset.univ.filter (fun b : Fin (T+2) => qmaClockAnchorIndex T hT b = t) ⊆ + {0,qmaClockMiddle T t,Fin.last (T+1)} := by + intro b hb + simpa only [Finset.mem_insert,Finset.mem_singleton] using + qmaClockAnchorIndex_fiber T hT t b (Finset.mem_filter.mp hb).2 + apply (Finset.card_le_card hs).trans + have h1 := Finset.card_insert_le (0 : Fin (T+2)) {qmaClockMiddle T t,Fin.last (T+1)} + have h2 := Finset.card_insert_le (qmaClockMiddle T t) {Fin.last (T+1)} + simp only [Finset.card_singleton] at h2 + omega + +theorem qmaGridTagNear_refl {rows width : ℕ} (p : QMAGate × QMAGridCell rows width) : + QMAGridTagNear p p := by + unfold QMAGridTagNear + omega + +theorem qmaGridTagNear_symm {rows width : ℕ} {p q : QMAGate × QMAGridCell rows width} + (h : QMAGridTagNear p q) : QMAGridTagNear q p := ⟨h.2.1,h.1,h.2.2.2,h.2.2.1⟩ + +theorem qmaGridTagChain_near {rows width : ℕ} (ps : List (QMAGate × QMAGridCell rows width)) + (hp : ps.IsChain QMAGridTagNear) (i j : Fin ps.length) + (hij : i.val ≤ j.val+1) (hji : j.val ≤ i.val+1) : + QMAGridTagNear ps[i.val] ps[j.val] := by + have h : i.val = j.val ∨ i.val+1 = j.val ∨ j.val+1 = i.val := by omega + rcases h with h | h | h + · have he : i = j := Fin.ext h + subst j + exact qmaGridTagNear_refl _ + · have hh := (List.isChain_iff_getElem.mp hp) i.val (by omega) + simpa only [h] using hh + · apply qmaGridTagNear_symm + have hh := (List.isChain_iff_getElem.mp hp) j.val (by omega) + simpa only [h] using hh + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..782ea434f3d28c5248e70bc8825636147e83984e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockCells.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumClockAnchor + +namespace OAI + +/-! The actual unary clock bits stay next to their computation gates with bounded cell occupancy. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def QMAGridCellsNear {rows width : ℕ} (p q : QMAGridCell rows width) : Prop := + p.1.val ≤ q.1.val+1 ∧ q.1.val ≤ p.1.val+1 ∧ + p.2.val ≤ q.2.val+1 ∧ q.2.val ≤ p.2.val+1 + +def qmaSparseGateCell (c : QMACircuit) (t : Fin (qmaSparseCircuit c).gates.length) : + QMAGridCell (qmaNearestCircuit c).gates.length c.work := + qmaSparseCell c (t.cast (qmaSparseTags_length c).symm) + +def qmaSparseClockCell (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (b : Fin ((qmaSparseCircuit c).gates.length+2)) : + QMAGridCell (qmaNearestCircuit c).gates.length c.work := + qmaSparseGateCell c (qmaClockAnchorIndex _ hT b) + +theorem qmaSparseGateCells_near (c : QMACircuit) (i j : Fin (qmaSparseCircuit c).gates.length) + (hij : i.val ≤ j.val+1) (hji : j.val ≤ i.val+1) : + QMAGridCellsNear (qmaSparseGateCell c i) (qmaSparseGateCell c j) := by + exact qmaGridTagChain_near (qmaSparseTags c) (qmaSparseTags_chain c) + (i.cast (qmaSparseTags_length c).symm) (j.cast (qmaSparseTags_length c).symm) hij hji + +theorem qmaSparseClockCells_near_gate (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (t : Fin (qmaSparseCircuit c).gates.length) (b : Fin ((qmaSparseCircuit c).gates.length+2)) + (hb : t.val ≤ b.val ∧ b.val ≤ t.val+2) : + QMAGridCellsNear (qmaSparseClockCell c hT b) (qmaSparseGateCell c t) := + qmaSparseGateCells_near c _ t (qmaClockAnchorIndex_near _ hT t b hb).1 + (qmaClockAnchorIndex_near _ hT t b hb).2 + +theorem qmaSparseClockCell_middle (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (t : Fin (qmaSparseCircuit c).gates.length) : + qmaSparseClockCell c hT (qmaClockMiddle _ t) = qmaSparseGateCell c t := by + unfold qmaSparseClockCell + rw [qmaClockAnchorIndex_middle] + +def qmaSparseClockCellBits (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (p : QMAGridCell (qmaNearestCircuit c).gates.length c.work) : + Finset (Fin ((qmaSparseCircuit c).gates.length+2)) := + (qmaSparseCellTimes c p).biUnion (fun t => Finset.univ.filter + (fun b => qmaClockAnchorIndex _ hT b = qmaSparseTime c t)) + +theorem qmaSparseClockCellBits_card (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (p : QMAGridCell (qmaNearestCircuit c).gates.length c.work) : + (qmaSparseClockCellBits c hT p).card ≤ 12 := by + calc + _ ≤ ∑ t ∈ qmaSparseCellTimes c p, (Finset.univ.filter + (fun b => qmaClockAnchorIndex _ hT b = qmaSparseTime c t)).card := Finset.card_biUnion_le + _ ≤ ∑ _t ∈ qmaSparseCellTimes c p, 3 := + Finset.sum_le_sum (fun t _ => qmaClockAnchorIndex_fiber_card _ hT (qmaSparseTime c t)) + _ = (qmaSparseCellTimes c p).card*3 := by simp + _ ≤ 12 := by have := qmaSparseCellTimes_card c p; omega + +theorem qmaSparseClockCellBits_mem (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) + (b : Fin ((qmaSparseCircuit c).gates.length+2)) : + b ∈ qmaSparseClockCellBits c hT (qmaSparseClockCell c hT b) := by + let t := (qmaClockAnchorIndex _ hT b).cast (qmaSparseTags_length c).symm + apply Finset.mem_biUnion.mpr + refine ⟨t,?_,?_⟩ + · simp only [qmaSparseCellTimes,Finset.mem_filter,Finset.mem_univ,true_and] + rfl + · simp only [Finset.mem_filter,Finset.mem_univ,true_and] + apply Fin.ext + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockPath.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockPath.lean new file mode 100644 index 0000000000000000000000000000000000000000..84bb782d7b14b0def316a5aa434302edc0197cb1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockPath.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumStagePath + +namespace OAI + +/-! The full literal clock path has bounded steps, including every row transition. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaTaggedSweepFrom_head (rows width start : ℕ) (g : QMAGate) (gs : List QMAGate) + (h : start+(g::gs).length ≤ rows) : + (qmaTaggedSweepFrom rows width start (g::gs) h).head?.map Prod.snd = + some ((⟨start,by simp only [List.length_cons] at h; omega⟩ : Fin (rows+1)), + qmaSweepOrder width (rows-1-start) 0) := by + have hs : start < rows := by simp only [List.length_cons] at h; omega + change ((qmaGridStageTags rows width ⟨start,hs⟩ (qmaSweepOrder width (rows-1-start)) g) ++ + qmaTaggedSweepFrom rows width (start+1) gs _).head?.map Prod.snd = _ + rw [List.head?_append_of_ne_nil _ (qmaGridStageTags_nonempty _ _ _ _ _)] + exact qmaGridStageTags_head _ _ _ _ _ + +theorem qmaTaggedSweepFrom_chain (rows width start : ℕ) (gs : List QMAGate) + (h : start+gs.length ≤ rows) : + (qmaTaggedSweepFrom rows width start gs h).IsChain QMAGridTagNear := by + induction gs generalizing start with + | nil => exact List.IsChain.nil + | cons g gs ih => + have hs : start < rows := by simp only [List.length_cons] at h; omega + let r : Fin rows := ⟨start,hs⟩ + change (qmaGridStageTags rows width r (qmaSweepOrder width (rows-1-start)) g ++ + qmaTaggedSweepFrom rows width (start+1) gs _).IsChain QMAGridTagNear + apply List.IsChain.append (qmaGridStageTags_chain rows width r g) (ih (start+1) _) + intro x hx y hy + cases gs with + | nil => simp [qmaTaggedSweepFrom] at hy + | cons g' gs' => + have hlast := qmaGridStageTags_last rows width r (qmaSweepOrder width (rows-1-start)) g + have hhead := qmaTaggedSweepFrom_head rows width (start+1) g' gs' (by + simp only [List.length_cons] at h ⊢; omega) + have hx' := Option.mem_map_of_mem Prod.snd hx + have hy' := Option.mem_map_of_mem Prod.snd hy + rw [hlast] at hx' + rw [hhead] at hy' + have hxc := (Option.mem_some_iff.mp hx').symm + have hyc := (Option.mem_some_iff.mp hy').symm + have hrow : 0 < rows-1-start := by simp only [List.length_cons] at h; omega + have hturn := qmaSweepOrder_turn width (rows-1-start) hrow + have he : rows-1-start-1 = rows-1-(start+1) := by omega + rw [he] at hturn + unfold QMAGridTagNear + rw [hxc,hyc] + change start ≤ start+1+1 ∧ start+1 ≤ start+1 ∧ + (qmaSweepOrder width (rows-1-start) (Fin.last width)).val ≤ + (qmaSweepOrder width (rows-1-(start+1)) 0).val+1 ∧ + (qmaSweepOrder width (rows-1-(start+1)) 0).val ≤ + (qmaSweepOrder width (rows-1-start) (Fin.last width)).val+1 + rw [hturn] + exact ⟨by omega,le_rfl,by omega,by omega⟩ + +theorem qmaSparseTags_chain (c : QMACircuit) : (qmaSparseTags c).IsChain QMAGridTagNear := + qmaTaggedSweepFrom_chain _ _ _ _ _ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockSector.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockSector.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ea7a669c36655d522e7915c00112749939f3f56 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockSector.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumClockStep + +namespace OAI + +/-! The valid clock sector is exactly the finite circuit clock, with its +full complement retained in the norm decomposition. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaHistoryClockEquiv (T : ℕ) : + Fin (T+1) ≃ {s : SourceSpinBasis (T+2) // QMALegalClock T s} := + Equiv.ofBijective (fun t => ⟨qmaHistoryClock T t,qmaHistoryClock_legal T t⟩) (by + constructor + · intro s t h + exact qmaHistoryClock_injective T (congrArg Subtype.val h) + · intro s + obtain ⟨t,ht⟩ := qmaHistoryClock_of_legal T s.val s.property + exact ⟨t,Subtype.ext ht⟩) + +theorem qmaClock_sector_sum (T : ℕ) (f : SourceSpinBasis (T+2) → ℝ) : + (∑ s, f s) = (∑ t : Fin (T+1), f (qmaHistoryClock T t))+ + ∑ s, if QMALegalClock T s then 0 else f s := by + have he := (qmaHistoryClockEquiv T).sum_comp (fun s => f s.val) + have hs := Finset.sum_subtype (F := inferInstance) + (Finset.univ.filter (QMALegalClock T)) + (by simp : ∀ s, s ∈ Finset.univ.filter (QMALegalClock T) ↔ QMALegalClock T s) f + rw [Finset.sum_filter] at hs + have hsplit : (∑ s, f s) = + (∑ s, if QMALegalClock T s then f s else 0)+ + ∑ s, if QMALegalClock T s then 0 else f s := by + rw [←Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro s _ + by_cases h : QMALegalClock T s <;> simp [h] + rw [hsplit,hs,←he] + rfl + +theorem qmaClock_invalid_mass_bound (T : ℕ) (f : SourceSpinBasis (T+2) → ℝ) + (hf : ∀ s, 0 ≤ f s) : + (∑ s, if QMALegalClock T s then 0 else f s) ≤ + ∑ s, qmaPinnedClockPenalty T s*f s := by + apply Finset.sum_le_sum + intro s _ + by_cases hs : QMALegalClock T s + · simp only [ite_eq_left hs] + exact mul_nonneg (qmaPinnedClockPenalty_nonneg T s) (hf s) + · simp only [ite_eq_right hs] + simpa only [one_mul] using + mul_le_mul_of_nonneg_right (qmaPinnedClockPenalty_one_le T s hs) (hf s) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockStep.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..431742b0543d04a3808b4233fc70b4cfe868b0f8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockStep.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumClockTransition + +namespace OAI + +/-! Each active guarded clock pair is either entirely legal or entirely +illegal; its legal pair is the intended consecutive history pair. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaClock_step_guard (T : ℕ) (i : Fin T) : + QMAClockGuard T i (qmaHistoryClock T i.castSucc) := by + constructor + · simp [qmaHistoryClock,qmaUnaryClock,qmaClockLeft] + · simp [qmaHistoryClock,qmaUnaryClock,qmaClockRight] + +theorem qmaClock_step_zero (T : ℕ) (i : Fin T) : + qmaHistoryClock T i.castSucc (qmaClockMiddle T i) = 0 := by + simp [qmaHistoryClock,qmaUnaryClock,qmaClockMiddle] + +theorem qmaClock_step_update (T : ℕ) (i : Fin T) : + Function.update (qmaHistoryClock T i.castSucc) (qmaClockMiddle T i) 1 = + qmaHistoryClock T i.succ := by + funext j + by_cases hj : j = qmaClockMiddle T i + · subst j + simp [qmaHistoryClock,qmaUnaryClock,qmaClockMiddle] + · rw [Function.update_of_ne hj] + have hn : j.val ≠ i.val+1 := fun h => hj (Fin.ext h) + have he : j.val < i.val+1 ↔ j.val < i.val+1+1 := by omega + simp only [qmaHistoryClock,qmaUnaryClock,Fin.val_castSucc,Fin.val_succ,he] + +theorem qmaClock_step_legal_iff (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) + (hg : QMAClockGuard T i s) (hz : s (qmaClockMiddle T i) = 0) : + QMALegalClock T (Function.update s (qmaClockMiddle T i) 1) ↔ QMALegalClock T s := by + constructor + · intro hs + have hg' : QMAClockGuard T i (Function.update s (qmaClockMiddle T i) 1) := + (qmaClockGuard_update T i s 1).mpr hg + have h := qmaClock_update_legal T i _ hs hg' 0 + rw [Function.update_idem,←hz,Function.update_eq_self] at h + exact h + · intro hs + exact qmaClock_update_legal T i s hs hg 1 + +theorem qmaClock_step_legal_before (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) + (hg : QMAClockGuard T i s) (hz : s (qmaClockMiddle T i) = 0) + (hs : QMALegalClock T s) : qmaHistoryClock T i.castSucc = s := by + obtain ⟨t,ht⟩ := qmaHistoryClock_of_legal T s hs + have hl : i.val < t.val+1 := by + by_contra hn + have h := hg.1 + rw [←ht] at h + simp [qmaHistoryClock,qmaUnaryClock,qmaClockLeft,hn] at h + have hm : ¬i.val+1 < t.val+1 := by + intro hn + rw [←ht] at hz + simp [qmaHistoryClock,qmaUnaryClock,qmaClockMiddle,hn] at hz + have he : t = i.castSucc := by + apply Fin.ext + simp only [Fin.val_castSucc] + omega + simpa only [he] using ht + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockTransition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bef96771c00fedf3c8b78c1f9e0c4168b88a4d6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumClockTransition.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPinnedClock + +namespace OAI + +/-! A guarded single-bit clock update preserves the legal clock sector. +The guard inspects only the two adjacent clock bits. -/ + +noncomputable section +namespace ContinuumCoulomb + +def qmaClockLeft (T : ℕ) (i : Fin T) : Fin (T+2) := ⟨i.val,by omega⟩ +def qmaClockMiddle (T : ℕ) (i : Fin T) : Fin (T+2) := ⟨i.val+1,by omega⟩ +def qmaClockRight (T : ℕ) (i : Fin T) : Fin (T+2) := ⟨i.val+2,by omega⟩ + +def QMAClockGuard (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) : Prop := + s (qmaClockLeft T i) = 1 ∧ s (qmaClockRight T i) = 0 + +theorem qmaClockLeft_ne_middle (T : ℕ) (i : Fin T) : + qmaClockLeft T i ≠ qmaClockMiddle T i := by + intro h + have hv := congrArg Fin.val h + dsimp [qmaClockLeft,qmaClockMiddle] at hv + omega + +theorem qmaClockRight_ne_middle (T : ℕ) (i : Fin T) : + qmaClockRight T i ≠ qmaClockMiddle T i := by + intro h + have hv := congrArg Fin.val h + dsimp [qmaClockRight,qmaClockMiddle] at hv + omega + +theorem qmaClockGuard_update (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) (a : Fin 2) : + QMAClockGuard T i (Function.update s (qmaClockMiddle T i) a) ↔ QMAClockGuard T i s := by + simp only [QMAClockGuard,Function.update_of_ne (qmaClockLeft_ne_middle T i), + Function.update_of_ne (qmaClockRight_ne_middle T i)] + +theorem qmaClock_update_antitone (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) + (hs : Antitone s) (hg : QMAClockGuard T i s) (a : Fin 2) : + Antitone (Function.update s (qmaClockMiddle T i) a) := by + apply Fin.antitone_iff_succ_le.mpr + intro j + by_cases hl : j.castSucc = qmaClockMiddle T i + · have hr : j.succ = qmaClockRight T i := by + apply Fin.ext + have hv := congrArg Fin.val hl + dsimp [qmaClockMiddle] at hv + change j.val+1 = i.val+2 + omega + rw [hl,hr,Function.update_self,Function.update_of_ne (qmaClockRight_ne_middle T i),hg.2] + exact Fin.zero_le a + · by_cases hr : j.succ = qmaClockMiddle T i + · have hleft : j.castSucc = qmaClockLeft T i := by + apply Fin.ext + have hv := congrArg Fin.val hr + dsimp [qmaClockMiddle] at hv + change j.val = i.val + omega + rw [hr,hleft,Function.update_self,Function.update_of_ne (qmaClockLeft_ne_middle T i),hg.1] + change a.val ≤ 1 + have ha := a.isLt + omega + · rw [Function.update_of_ne hl,Function.update_of_ne hr] + exact hs (Fin.castSucc_lt_succ (i := j)).le + +theorem qmaClock_update_legal (T : ℕ) (i : Fin T) (s : SourceSpinBasis (T+2)) + (hs : QMALegalClock T s) (hg : QMAClockGuard T i s) (a : Fin 2) : + QMALegalClock T (Function.update s (qmaClockMiddle T i) a) := by + refine ⟨qmaClock_update_antitone T i s hs.1 hg a,?_,?_⟩ + · have hn : (0 : Fin (T+2)) ≠ qmaClockMiddle T i := by + intro h + have hv := congrArg Fin.val h + dsimp [qmaClockMiddle] at hv + omega + rw [Function.update_of_ne hn] + exact hs.2.1 + · have hn : Fin.last (T+1) ≠ qmaClockMiddle T i := by + intro h + have hv := congrArg Fin.val h + dsimp [qmaClockMiddle] at hv + have hi := i.isLt + omega + rw [Function.update_of_ne hn] + exact hs.2.2 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientEnvelopeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientEnvelopeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c43e8e5a4033f81cfdba7f0cc097cfb7ec65bea0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientEnvelopeProgram.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawEnvelope +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedFinalBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeEnvelope + +namespace OAI + +/-! Literal unary programs for the logical and physical coefficient bounds. +The only arguments are qubit count, term count, initial magnitude and precision. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCoefficientEnvelopeProgram +open ExactQuantumFactoring.BitStackProgram + +private noncomputable def add {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x+g x) := Procedure.unaryAdd.comp (p.pair q) +private noncomputable def mul {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x*g x) := Procedure.unaryMul.comp (p.pair q) +private noncomputable def constant {α : Type} (ea : α → List Bool) (n : ℕ) : + Procedure ea unaryCode (fun _ => n) := Procedure.constant ea unaryCode n +private noncomputable def square {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^2) := + (mul p p).congrFun (by intro x; exact (pow_two _).symm) +private noncomputable def cube {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^3) := + (mul (square p) p).congrFun (by intro x; exact (pow_succ _ 2).symm) +private noncomputable def fourth {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^4) := + (square (square p)).congrFun (by intro x; simp only [← pow_mul]) + +noncomputable opaque weightProgram {α : Type} {ea : α → List Bool} {R B : α → ℕ} + (pr : Procedure ea unaryCode R) (pb : Procedure ea unaryCode B) : + Procedure ea unaryCode (fun x => QuantumOrderedXZ.weightNat (R x) (B x)) := by + let c := constant ea + exact (add (add (add (add (add (cube pr) (mul (square pr) pb)) (square pr)) + (mul pr (add (c 1) (square pb)))) (c 1)) (square pb)).congrFun (by intro x; rfl) + +noncomputable opaque logicalScaleProgram {α : Type} {ea : α → List Bool} {m B N : α → ℕ} + (pm : Procedure ea unaryCode m) (pb : Procedure ea unaryCode B) + (pn : Procedure ea unaryCode N) : + Procedure ea unaryCode (fun x => QuantumOrderedXZ.scaleNat (m x) (B x) (N x)) := by + let c := constant ea + exact (mul (mul (c 8) (fourth (mul (c 4) (add (c 1) + (mul pm (square (add (c 1) pb))))))) pn).congrFun (by intro x; rfl) + +noncomputable opaque stepProgram {α : Type} {ea : α → List Bool} {m B N : α → ℕ} + (pm : Procedure ea unaryCode m) (pb : Procedure ea unaryCode B) + (pn : Procedure ea unaryCode N) : + Procedure ea unaryCode (fun x => QuantumOrderedXZ.stepNat (m x) (B x) (N x)) := + weightProgram (logicalScaleProgram pm pb pn) pb + +noncomputable def logicalProgram {α : Type} {ea : α → List Bool} {m B N : α → ℕ} + (pm : Procedure ea unaryCode m) (pb : Procedure ea unaryCode B) + (pn : Procedure ea unaryCode N) (k : ℕ) : + Procedure ea unaryCode (fun x => QuantumOrderedXZ.pipelineNat (m x) (B x) (N x) k) := by + induction k with + | zero => exact pb + | succ k ih => exact stepProgram (mul (constant ea 3136) pm) ih pn + +noncomputable opaque rawBudgetProgram {α : Type} {ea : α → List Bool} {m B : α → ℕ} + (pm : Procedure ea unaryCode m) (pb : Procedure ea unaryCode B) : + Procedure ea unaryCode (fun x => QuantumRawExchange.budgetNat (m x) (B x)) := by + let c := constant ea + let s := add pm (mul pm pb) + exact (add (add (c 1) (mul (c 2000000) s)) (square (mul (c 7056) s))).congrFun + (by intro x; rfl) + +noncomputable opaque rawScaleProgram {α : Type} {ea : α → List Bool} {m B N : α → ℕ} + (pm : Procedure ea unaryCode m) (pb : Procedure ea unaryCode B) + (pn : Procedure ea unaryCode N) : + Procedure ea unaryCode (fun x => QuantumRawExchange.scaleNat (m x) (B x) (N x)) := + mul (mul (constant ea 9) (cube (rawBudgetProgram pm pb))) pn + +noncomputable opaque rawOutputProgram {α : Type} {ea : α → List Bool} {n m B N : α → ℕ} + (pc : Procedure ea unaryCode n) (pm : Procedure ea unaryCode m) + (pb : Procedure ea unaryCode B) (pn : Procedure ea unaryCode N) : + Procedure ea unaryCode (fun x => QuantumRawExchange.outputNat (n x) (m x) (B x) (N x)) := by + let c := constant ea + let r := rawScaleProgram pm pb pn + exact (add (add (add (mul (add (mul (c 6) pc) (c 1)) (square r)) + (mul (mul (c 3920) r) (add (c 1) pb))) + (mul (add (mul (c 685600) pm) (c 26000)) pb)) (c 1)).congrFun (by intro x; rfl) + +abbrev Input := QuantumCoefficientPrograms.LatticeInput +def inputCode : Input → List Bool := QuantumCoefficientPrograms.latticeInputCode +def value (x : Input) : ℕ := QuantumRawExchange.outputNat + (x.1+3717*x.2.1) (12544*x.2.1) + (QuantumOrderedXZ.pipelineNat x.2.1 x.2.2.1 x.2.2.2 6) x.2.2.2 + +noncomputable opaque program : Procedure inputCode unaryCode value := by + let n := Procedure.first unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + let rest := Procedure.second unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + let m := (Procedure.first unaryCode (prodCode unaryCode unaryCode)).comp rest + let bn := (Procedure.second unaryCode (prodCode unaryCode unaryCode)).comp rest + let b := (Procedure.first unaryCode unaryCode).comp bn + let p := (Procedure.second unaryCode unaryCode).comp bn + exact rawOutputProgram (add n (mul (constant inputCode 3717) m)) + (mul (constant inputCode 12544) m) (logicalProgram m b p 6) p + +theorem polynomial_bound : ∃ a : ℕ, ∀ x : Input, value x ≤ (inputCode x).length.succ.succ^a := + unaryProcedure_power_bound program + +end ContinuumCoulomb.QuantumCoefficientEnvelopeProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientHeight.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f7f3dafc10370e5aceb2ecec84af5fba15ea827 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientHeight.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicHeight +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFixedPauli + +namespace OAI + +/-! Uniform rational-register bounds for the actual fixed-arity Pauli +trace. These supply an explicit precision budget before scalar sampling. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFixedPauli +open QuantumAlgebraicScalar +open scoped BigOperators Classical + +theorem height_finiteSum {α : Type} [Fintype α] (f : α → Scalar) : + height (finiteSum f) ≤ ∑ a, height (f a) := by + calc + _ ≤ ∑ i : Fin (Fintype.card α), height (f ((Fintype.equivFin α).symm i)) := by + simpa only [finiteSum,enumerate,List.map_map,List.map_ofFn,List.sum_ofFn, + Function.comp_apply] using + height_sum ((enumerate α).map f) + _ = _ := (Fintype.equivFin α).symm.sum_comp (fun a => height (f a)) + +theorem height_finiteProduct {α : Type} [Fintype α] (f : α → Scalar) : + height (finiteProduct f) ≤ ∏ a, height (f a) := by + calc + _ ≤ ∏ i : Fin (Fintype.card α), height (f ((Fintype.equivFin α).symm i)) := by + simpa only [finiteProduct,enumerate,List.map_map,List.map_ofFn,List.prod_ofFn, + Function.comp_apply] using + height_product ((enumerate α).map f) + _ = _ := (Fintype.equivFin α).symm.prod_comp (fun a => height (f a)) + +theorem height_pauli (μ : Fin 4) (a b : Fin 2) : height (pauli μ a b) ≤ 1 := by + fin_cases μ <;> fin_cases a <;> fin_cases b <;> + norm_num [pauli,height,realHeight,rat,realRat,neg,realNeg,imaginary] + +theorem height_word {ι : Type} [Fintype ι] + (w : ι → Fin 4) (s t : ι → Fin 2) : height (word w s t) ≤ 1 := by + apply (height_finiteProduct _).trans + exact Finset.prod_le_one₀ (fun _ _ => height_nonnegative _) + (fun _ _ => height_pauli _ _ _) + +theorem height_coefficient {ι : Type} [Fintype ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) + (C : ℚ) (hA : ∀ s t, height (A s t) ≤ C) : + height (coefficient A w) ≤ (2:ℚ)^Fintype.card ι*C := by + have hcell (s t : ι → Fin 2) : height (mul (A s t) (word w t s)) ≤ C := by + calc + _ ≤ height (A s t)*height (word w t s) := height_mul _ _ + _ ≤ height (A s t)*1 := + mul_le_mul_of_nonneg_left (height_word _ _ _) (height_nonnegative _) + _ ≤ C := by simpa using hA s t + have hsum : height (finiteSum (fun s : ι → Fin 2 => + finiteSum (fun t : ι → Fin 2 => mul (A s t) (word w t s)))) ≤ + ∑ _s : ι → Fin 2, ∑ _t : ι → Fin 2, C := by + apply (height_finiteSum _).trans + apply Finset.sum_le_sum + intro s _ + exact (height_finiteSum _).trans (Finset.sum_le_sum (fun t _ => hcell s t)) + have hp : 0 < (2:ℚ)^Fintype.card ι := pow_pos (by norm_num) _ + calc + _ ≤ height (rat ((2:ℚ)^Fintype.card ι)⁻¹)* + height (finiteSum (fun s => finiteSum (fun t => mul (A s t) (word w t s)))) := + height_mul _ _ + _ ≤ ((2:ℚ)^Fintype.card ι)⁻¹*(∑ _s : ι → Fin 2, ∑ _t : ι → Fin 2, C) := by + rw [height_rat,abs_of_pos (inv_pos.mpr hp)] + exact mul_le_mul_of_nonneg_left hsum (inv_nonneg.mpr hp.le) + _ = _ := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Fintype.card_fun, + Fintype.card_fin,Nat.cast_pow,Nat.cast_ofNat] + field_simp + +theorem realHeight_coefficient {ι : Type} [Fintype ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) + (C : ℚ) (hA : ∀ s t, height (A s t) ≤ C) : + realHeight (realCoefficient A w) ≤ (2:ℚ)^Fintype.card ι*C := by + apply le_trans (le_add_of_nonneg_right (realHeight_nonnegative (coefficient A w).2)) + exact height_coefficient A w C hA + +end ContinuumCoulomb.QuantumFixedPauli + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientPrograms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf8c9bd12b501f4279254f504b92176b6cbdab3d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoefficientPrograms.lean @@ -0,0 +1,136 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathIteratedBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingCoefficientBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.PolynomialUnaryBounds + +namespace OAI + +/-! Literal unary programs for the actual routing coefficient envelopes. +Their output lengths give polynomial bounds without choosing giant exponents. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCoefficientPrograms +open ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × (ℕ × ℕ) +def inputCode : Input → List Bool := prodCode unaryCode (prodCode unaryCode unaryCode) + +def pathBudget (m L : ℕ) : ℕ := 3*m*L+L+3*m*(1+2*L)+4*m*(1+L)^2+1 +def pathRadius (m L T : ℕ) : ℕ := L+16*(pathBudget m L)^3*T+4*pathBudget m L+1 +def pathCoefficient (m L T : ℕ) : ℕ := 1+L+(7*m+2)*(pathRadius m L T)^2 + +def iterated (m L T : ℕ) : ℕ → ℕ + | 0 => L + | k+1 => pathCoefficient (3^k*m) (iterated m L T k) T + +@[simp] theorem pathBudget_cast (m L : ℕ) : (pathBudget m L:ℝ) = qmaPathBudget m L := by + simp [pathBudget,qmaPathBudget] +@[simp] theorem pathRadius_cast (m L T : ℕ) : (pathRadius m L T:ℝ) = qmaPathRadiusBound m L T := by + simp [pathRadius,qmaPathRadiusBound] +@[simp] theorem pathCoefficient_cast (m L T : ℕ) : + (pathCoefficient m L T:ℝ) = qmaPathCoefficientBound m L T := by + simp [pathCoefficient,qmaPathCoefficientBound] +@[simp] theorem iterated_cast (m L T k : ℕ) : + (iterated m L T k:ℝ) = qmaPathIteratedBound m L T k := by + induction k with + | zero => rfl + | succ k ih => simp only [iterated,pathCoefficient_cast,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat,ih,qmaPathIteratedBound] + +private noncomputable def add {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x+g x) := Procedure.unaryAdd.comp (p.pair q) +private noncomputable def mul {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x*g x) := Procedure.unaryMul.comp (p.pair q) +private noncomputable def constant {α : Type} (ea : α → List Bool) (n : ℕ) : + Procedure ea unaryCode (fun _ => n) := Procedure.constant ea unaryCode n +private noncomputable def square {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^2) := + (mul p p).congrFun (by intro x; simp only [pow_two]) +private noncomputable def cube {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^3) := + (mul (mul p p) p).congrFun (by intro x; simp only [pow_succ,pow_zero,one_mul]) + +noncomputable opaque pathBudgetProgram {α : Type} {ea : α → List Bool} {m L : α → ℕ} + (pm : Procedure ea unaryCode m) (pl : Procedure ea unaryCode L) : + Procedure ea unaryCode (fun x => pathBudget (m x) (L x)) := by + let c := constant ea + exact (add (add (add (add (mul (mul (c 3) pm) pl) pl) + (mul (mul (c 3) pm) (add (c 1) (mul (c 2) pl)))) + (mul (mul (c 4) pm) (square (add (c 1) pl)))) (c 1)).congrFun (by intro x; rfl) + +noncomputable opaque pathRadiusProgram {α : Type} {ea : α → List Bool} {m L T : α → ℕ} + (pm : Procedure ea unaryCode m) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => pathRadius (m x) (L x) (T x)) := by + let c := constant ea + let pb := pathBudgetProgram pm pl + exact (add (add (add pl (mul (mul (c 16) (cube pb)) pt)) + (mul (c 4) pb)) (c 1)).congrFun (by intro x; rfl) + +noncomputable opaque pathCoefficientProgram {α : Type} {ea : α → List Bool} {m L T : α → ℕ} + (pm : Procedure ea unaryCode m) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => pathCoefficient (m x) (L x) (T x)) := by + let c := constant ea + exact (add (add (c 1) pl) (mul (add (mul (c 7) pm) (c 2)) + (square (pathRadiusProgram pm pl pt)))).congrFun (by intro x; rfl) + +noncomputable opaque mProgram : Procedure inputCode unaryCode (fun x => x.1) := Procedure.first _ _ +noncomputable opaque lProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp (Procedure.second _ _) +noncomputable opaque tProgram : Procedure inputCode unaryCode (fun x => x.2.2) := + (Procedure.second _ _).comp (Procedure.second _ _) + +noncomputable def iteratedProgram (k : ℕ) : + Procedure inputCode unaryCode (fun x => iterated x.1 x.2.1 x.2.2 k) := by + induction k with + | zero => exact lProgram + | succ k ih => + exact pathCoefficientProgram (mul (constant inputCode (3^k)) mProgram) ih tProgram + +theorem iterated_power (k : ℕ) : ∃ a : ℕ, ∀ x : Input, + iterated x.1 x.2.1 x.2.2 k ≤ ((inputCode x).length+2)^a := + unaryProcedure_power_bound (iteratedProgram k) + +def crossingBudget (m r L : ℕ) : ℕ := 3*m*L+L+6*r*(1+2*L)+12*r*(1+2*L)^2+1 +def crossingRadius (m r L T : ℕ) : ℕ := L+16*(crossingBudget m r L)^3*T+4*crossingBudget m r L+1 +def crossingCoefficient (m r L T : ℕ) : ℕ := 1+L+(11*r+2)*(crossingRadius m r L T)^2 + +@[simp] theorem crossingBudget_cast (m r L : ℕ) : + (crossingBudget m r L:ℝ) = qmaCrossingBudget m r L := by simp [crossingBudget,qmaCrossingBudget] +@[simp] theorem crossingRadius_cast (m r L T : ℕ) : + (crossingRadius m r L T:ℝ) = qmaCrossingRadiusBound m r L T := by simp [crossingRadius,qmaCrossingRadiusBound] +@[simp] theorem crossingCoefficient_cast (m r L T : ℕ) : + (crossingCoefficient m r L T:ℝ) = qmaCrossingCoefficientBound m r L T := by + simp [crossingCoefficient,qmaCrossingCoefficientBound] + +noncomputable opaque crossingBudgetProgram {α : Type} {ea : α → List Bool} {m r L : α → ℕ} + (pm : Procedure ea unaryCode m) (pr : Procedure ea unaryCode r) (pl : Procedure ea unaryCode L) : + Procedure ea unaryCode (fun x => crossingBudget (m x) (r x) (L x)) := by + let c := constant ea + let p := add (c 1) (mul (c 2) pl) + exact (add (add (add (add (mul (mul (c 3) pm) pl) pl) + (mul (mul (c 6) pr) p)) (mul (mul (c 12) pr) (square p))) (c 1)).congrFun (by intro x; rfl) + +noncomputable opaque crossingRadiusProgram {α : Type} {ea : α → List Bool} {m r L T : α → ℕ} + (pm : Procedure ea unaryCode m) (pr : Procedure ea unaryCode r) + (pl : Procedure ea unaryCode L) (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => crossingRadius (m x) (r x) (L x) (T x)) := by + let c := constant ea + let pb := crossingBudgetProgram pm pr pl + exact (add (add (add pl (mul (mul (c 16) (cube pb)) pt)) + (mul (c 4) pb)) (c 1)).congrFun (by intro x; rfl) + +noncomputable opaque crossingCoefficientProgram {α : Type} {ea : α → List Bool} {m r L T : α → ℕ} + (pm : Procedure ea unaryCode m) (pr : Procedure ea unaryCode r) + (pl : Procedure ea unaryCode L) (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => crossingCoefficient (m x) (r x) (L x) (T x)) := by + let c := constant ea + exact (add (add (c 1) pl) (mul (add (mul (c 11) pr) (c 2)) + (square (crossingRadiusProgram pm pr pl pt)))).congrFun (by intro x; rfl) + +end ContinuumCoulomb.QuantumCoefficientPrograms + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoerciveInverse.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoerciveInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..d39d6479bb5649d6d804178d308235531d3c857a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoerciveInverse.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.OneParticle.SharpBlockPerturbation +import Mathlib.Analysis.Normed.Module.FiniteDimension + +namespace OAI + +/-! The finite coercive inverse needed for the padded four-spin penalty. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped InnerProductSpace +variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] + +theorem qmaCoerciveInverse_exists (A : E →L[ℝ] E) {g : ℝ} (hg : 0 < g) + (hgap : ∀ x, g*‖x‖^2 ≤ ⟪x,A x⟫_ℝ) : + ∃ T : E →L[ℝ] E, (∀ x, A (T x) = x) ∧ (∀ x, T (A x) = x) ∧ ‖T‖ ≤ 1/g := by + have hi : Function.Injective A := by + intro x y hxy + have hz : A (x-y) = 0 := by simp only [map_sub,hxy,sub_self] + have hh := hgap (x-y) + rw [hz,inner_zero_right] at hh + have hn : ‖x-y‖ = 0 := by + by_contra hn + have hp : 0 < ‖x-y‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hn) + exact (not_lt_of_ge hh) (mul_pos hg (sq_pos_of_pos hp)) + exact sub_eq_zero.mp (norm_eq_zero.mp hn) + let e : E ≃ₗ[ℝ] E := LinearEquiv.ofBijective A.toLinearMap + ⟨hi,LinearMap.injective_iff_surjective.mp hi⟩ + let T : E →L[ℝ] E := e.symm.toContinuousLinearEquiv.toContinuousLinearMap + have hAT (x : E) : A (T x) = x := by + change e (e.symm x) = x + exact e.apply_symm_apply x + have hTA (x : E) : T (A x) = x := by + change e.symm (e x) = x + exact e.symm_apply_apply x + refine ⟨T,hAT,hTA,?_⟩ + apply T.opNorm_le_bound (by positivity) + intro x + have hh := hgap (T x) + rw [hAT] at hh + have hc := real_inner_le_norm (T x) x + have hb : g*‖T x‖ ≤ ‖x‖ := by + by_cases hz : ‖T x‖ = 0 + · rw [hz,mul_zero] + exact norm_nonneg _ + · have hp : 0 < ‖T x‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hz) + nlinarith + calc + ‖T x‖ ≤ ‖x‖/g := (le_div_iff₀ hg).mpr (by nlinarith) + _ = (1/g)*‖x‖ := by ring + +omit [FiniteDimensional ℝ E] in +theorem qmaInverse_eigenvector (A T : E →L[ℝ] E) (hTA : ∀ x, T (A x) = x) + (x : E) {c : ℝ} (hc : c ≠ 0) (hx : A x = c • x) : T x = c⁻¹ • x := by + have h := hTA x + rw [hx,map_smul] at h + calc + T x = c⁻¹ • (c • T x) := by rw [smul_smul,inv_mul_cancel₀ hc,one_smul] + _ = c⁻¹ • x := by rw [h] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7869eaf9c45cf0bfa6a926c0abcb7aeb2861622 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedAccuracy.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSamplePrecision + +namespace OAI + +/-! A computable binary-precision choice closes the full rational four-spin error. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ : Type*} [Fintype κ] + +def rationalErrorBudget (r : ℚ) (t : κ → QMAXZTerm n) (J : κ → ℚ) : ℚ := + 3*Fintype.card (QMAFourExchangeIndex n (QMAXZPairIndex t) (QMAXZFieldIndex t))* + (1568*|r| *(1+rationalInputSize J)+26064*rationalInputSize J)+320800*(∑ e, |J e|) + +theorem rationalErrorBudget_cast (r : ℚ) (t : κ → QMAXZTerm n) (J : κ → ℚ) : + (rationalErrorBudget r t J:ℝ) = matrixErrorBudget r t J := by + simp only [rationalErrorBudget,matrixErrorBudget,weightErrorBudget,rationalInputSize,qmaXZInputSize, + Rat.cast_add,Rat.cast_mul,Rat.cast_abs,Rat.cast_sum,Rat.cast_one,Rat.cast_ofNat,Rat.cast_natCast] + +def outputPrecision (N : ℕ) (t : κ → QMAXZTerm n) (J : κ → ℚ) : ℕ := + precision (rationalErrorBudget (rationalPenalty N J) t J) N + +def outputMatrix (N : ℕ) (t : κ → QMAXZTerm n) (J : κ → ℚ) : + Matrix (SourceSpinBasis (n*4)) (SourceSpinBasis (n*4)) ℂ := + matrixValue (outputPrecision N t J) (rationalPenalty N J) t J + +theorem outputMatrix_accuracy (N : ℕ) (hN : 0 < N) (t : κ → QMAXZTerm n) (J : κ → ℚ) + (hprivate : ∀ e f, (qmaPauliSupport (t e).word).card = 2 → + qmaPauliSupport (t e).word = qmaPauliSupport (t f).word → e = f) : + |MediatorGraph.normalizedBottom (outputMatrix N t J)- + MediatorGraph.normalizedBottom (∑ e, (J e:ℂ) • (t e).matrix)| ≤ 2/(N:ℝ) := by + have h := matrixValue_accuracy (outputPrecision N t J) N hN t J hprivate + have he := precision_error (rationalErrorBudget (rationalPenalty N J) t J) N hN + rw [rationalErrorBudget_cast] at he + change matrixErrorBudget (rationalPenalty N J) t J*(2:ℝ)⁻¹^(outputPrecision N t J) ≤ 1/(N:ℝ) at he + apply h.trans + calc + _ ≤ 1/(N:ℝ)+1/(N:ℝ) := add_le_add he le_rfl + _ = 2/(N:ℝ) := by ring + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7b1a0e5bec2ad7b275b7450d9dcd82f31431332 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingBounds.lean @@ -0,0 +1,130 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingCompiled +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGraphCoefficientBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientPrograms + +namespace OAI + +/-! Polynomial coefficient bounds for the literal endpoint scan, including +its retained background, selected couplings and merged output. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open MediatorListProgram +open scoped Classical + +theorem weight_abs_le (xs : List Bond) (p : QuantumRouteCode.Pair) {L : ℝ} + (hL : 0 ≤ L) (h : ∀ e ∈ xs, |(e.2.2 : ℝ)| ≤ L) : + |(weight (xs,p) : ℝ)| ≤ xs.length*L := by + induction xs with + | nil => simp [weight] + | cons e xs ih => + have he := h e List.mem_cons_self + have ht := ih (fun b hb => h b (List.mem_cons_of_mem _ hb)) + have hc : |(contribution (e,p) : ℝ)| ≤ L := by + unfold contribution + split_ifs + · exact he + · simpa only [Rat.cast_zero,abs_zero] using hL + change |((contribution (e,p)+weight (xs,p) : ℚ) : ℝ)| ≤ _ + rw [Rat.cast_add] + have ha := abs_add_le (contribution (e,p) : ℝ) (weight (xs,p) : ℝ) + simp only [List.length_cons,Nat.cast_add,Nat.cast_one] + nlinarith + +variable {G : QMARationalExchangeGraph} {r k : ℕ} + (S : QMARationalCrossingSelection G r) (labels : G.Edge ≃ Fin k) + +theorem packed_weight_bound {L : ℝ} (hc : G.CoefficientBound L) : + ∀ e ∈ QuantumListGraph.packed G labels, |(e.2.2 : ℝ)| ≤ L := by + intro e he + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp he + exact hc.2 (labels.symm i) + +theorem retainedGraph_count : Fintype.card (retainedGraph S labels).Edge ≤ Fintype.card G.Edge := by + change Fintype.card (Fin + (retained (pairs (List.ofFn (encodedSites S.site)),QuantumListGraph.packed G labels)).length) ≤ _ + rw [Fintype.card_fin,Fintype.card_congr labels,Fintype.card_fin] + simpa only [retained,QuantumListGraph.packed,List.length_ofFn] using + (List.length_filter_le (fun e => keep (pairs (List.ofFn (encodedSites S.site)),e)) + (QuantumListGraph.packed G labels)) + +theorem retainedGraph_coefficientBound {L : ℝ} (hc : G.CoefficientBound L) : + (retainedGraph S labels).CoefficientBound L := by + refine ⟨hc.1,?_⟩ + intro e + apply packed_weight_bound labels hc + exact ((retained_mem _ _).mp + (List.get_mem (retained (pairs (List.ofFn (encodedSites S.site)), + QuantumListGraph.packed G labels)) e)).1 + +theorem computed_coupling_bound {m L : ℝ} + (hm : (Fintype.card G.Edge : ℝ) ≤ m) (hL : 0 ≤ L) (hc : G.CoefficientBound L) + (i : Fin r) (a : Fin 2) : + |(weight (QuantumListGraph.packed G labels,terminalPair a (encodedSites S.site i)) : ℝ)| ≤ m*L := by + have hk : ((QuantumListGraph.packed G labels).length : ℝ) ≤ m := by + have hk' : k = Fintype.card G.Edge := + ((Fintype.card_congr labels).trans (Fintype.card_fin k)).symm + simpa only [QuantumListGraph.packed,List.length_ofFn,hk'] using hm + exact (weight_abs_le _ _ hL (packed_weight_bound labels hc)).trans + (mul_le_mul_of_nonneg_right hk hL) + +theorem computedLayer_output_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card G.Edge : ℝ) ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + ((computedLayer S labels).output N).CoefficientBound + (qmaCrossingCoefficientBound m r ((m+1)*L) T) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hLL : L ≤ (m+1)*L := by nlinarith + have hcount : (Fintype.card (computedLayer S labels).base.Edge : ℝ) ≤ m := by + exact (show (Fintype.card (retainedGraph S labels).Edge : ℝ) ≤ + (Fintype.card G.Edge : ℝ) by exact_mod_cast retainedGraph_count S labels).trans hm + have hbase : (computedLayer S labels).base.CoefficientBound ((m+1)*L) := by + have h := retainedGraph_coefficientBound S labels hc + exact ⟨h.1.trans hLL,fun e => (h.2 e).trans hLL⟩ + apply (computedLayer S labels).output_coefficientBound hN hcount (hL.trans hLL) hT hbase + · intro i + exact (computed_coupling_bound S labels hm hL0 hc i 0).trans (by nlinarith) + · intro i + exact (computed_coupling_bound S labels hm hL0 hc i 1).trans (by nlinarith) + +theorem computedLayer_output_count {m : ℝ} (hm : (Fintype.card G.Edge : ℝ) ≤ m) (N : ℚ) : + (Fintype.card ((computedLayer S labels).output N).Edge : ℝ) ≤ m+9*r := by + rw [(computedLayer S labels).output_edge_count,Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] + have h : (Fintype.card (retainedGraph S labels).Edge : ℝ) ≤ (Fintype.card G.Edge : ℝ) := by + exact_mod_cast retainedGraph_count S labels + exact add_le_add (h.trans hm) (le_refl (9*(r : ℝ))) + +theorem computedLayer_merged_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card G.Edge : ℝ) ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + ((computedLayer S labels).output N).merge.CoefficientBound + ((m+9*r+1)*qmaCrossingCoefficientBound m r ((m+1)*L) T) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have henv : 1 ≤ qmaCrossingCoefficientBound m r ((m+1)*L) T := by + unfold qmaCrossingCoefficientBound + have hmul : 0 ≤ (11*(r : ℝ)+2)* + (qmaCrossingRadiusBound m r ((m+1)*L) T)^2 := by positivity + have hbase : 0 ≤ (m+1)*L := by positivity + linarith + exact (((computedLayer S labels).output N).merge_coefficientBound + (computedLayer_output_count S labels hm N) henv + (computedLayer_output_coefficientBound S labels hN hm hL hT hc)) + +theorem computedLayer_output_nat {N : ℚ} (hN : 0 ≤ N) {m L T : ℕ} + (hm : Fintype.card G.Edge ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + ((computedLayer S labels).output N).CoefficientBound + (QuantumCoefficientPrograms.crossingCoefficient m r ((m+1)*L) T) := by + have hm' : (Fintype.card G.Edge : ℝ) ≤ m := by exact_mod_cast hm + have hL' : (1 : ℝ) ≤ L := by exact_mod_cast hL + simpa only [QuantumCoefficientPrograms.crossingCoefficient_cast,Nat.cast_mul, + Nat.cast_add,Nat.cast_one] using + computedLayer_output_coefficientBound S labels hN hm' hL' hT hc + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f627dcd4a063895f94933b39151e442452e57545 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedCrossingRelabel.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRetainedSupport +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectionRelabel +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSupportRelabel + +namespace OAI + +/-! The computed retained-edge scan and the canonical crossing layer have +the same physical edges after the old spins and crossing cells are relabeled. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open scoped Classical + +variable {G H : QMARationalExchangeGraph} {r t m : ℕ} + (vertex : Fin G.n ≃ Fin H.n) (edge : G.Edge ≃ H.Edge) + (left : ∀ e, vertex (G.left e)=H.left (edge e)) + (right : ∀ e, vertex (G.right e)=H.right (edge e)) + (s : Fin r → Fin 4 → Fin G.n) (u : Fin t → Fin 4 → Fin H.n) + (cell : Fin r ≃ Fin t) (site : ∀ i a, vertex (s i a)=u (cell i) a) + (hs : ∀ i, Function.Injective (s i)) (hu : ∀ i, Function.Injective (u i)) + (hglobal : Function.Injective (fun p : Fin r × Fin 4 => s p.1 p.2)) + (labels : G.Edge ≃ Fin m) + +include left right site hglobal in +theorem computed_base_source + (e : (computedLayer (G.crossingSelection s hs) labels).base.Edge) : + ∃ f : (H.crossingSelection u hu).layer.base.Edge, + vertex ((computedLayer (G.crossingSelection s hs) labels).base.left e) = + (H.crossingSelection u hu).layer.base.left f ∧ + vertex ((computedLayer (G.crossingSelection s hs) labels).base.right e) = + (H.crossingSelection u hu).layer.base.right f := by + have ht := fun e i a => G.crossingTag_some_iff s hglobal e (i,a) + obtain ⟨k,hk1,hk2⟩ := retained_edge_source (G.crossingSelection s hs) labels ht e + obtain ⟨f,hf1,hf2⟩ := QMARationalExchangeGraph.retained_source vertex edge left right s u cell site hs hu k + exact ⟨f,(congrArg vertex hk1).trans hf1,(congrArg vertex hk2).trans hf2⟩ + +include left right site hglobal in +theorem computed_base_target (f : (H.crossingSelection u hu).layer.base.Edge) : + ∃ e : (computedLayer (G.crossingSelection s hs) labels).base.Edge, + vertex ((computedLayer (G.crossingSelection s hs) labels).base.left e) = + (H.crossingSelection u hu).layer.base.left f ∧ + vertex ((computedLayer (G.crossingSelection s hs) labels).base.right e) = + (H.crossingSelection u hu).layer.base.right f := by + have ht := fun e i a => G.crossingTag_some_iff s hglobal e (i,a) + obtain ⟨k,hk1,hk2⟩ := QMARationalExchangeGraph.retained_target vertex edge left right s u cell site hs hu f + obtain ⟨e,he1,he2⟩ := retained_edge_target (G.crossingSelection s hs) labels ht k + exact ⟨e,(congrArg vertex he1).trans hk1,(congrArg vertex he2).trans hk2⟩ + +include left right site hglobal in +theorem computed_output_support (N M : ℚ) : + let C := computedLayer (G.crossingSelection s hs) labels + let E := (H.crossingSelection u hu).layer + (∀ e : (C.output N).Edge, ∃ f : (E.output M).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f)) ∧ + (∀ f : (E.output M).Edge, ∃ e : (C.output N).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f)) := by + let C := computedLayer (G.crossingSelection s hs) labels + let E := (H.crossingSelection u hu).layer + apply C.output_support E vertex cell site + · intro e + obtain ⟨f,h1,h2⟩ := computed_base_source vertex edge left right s u cell site hs hu hglobal labels e + exact ⟨f,congrArg₂ (fun a b : Fin H.n => s(a,b)) h1 h2⟩ + · intro f + obtain ⟨e,h1,h2⟩ := computed_base_target vertex edge left right s u cell site hs hu hglobal labels f + exact ⟨e,congrArg₂ (fun a b : Fin H.n => s(a,b)) h1 h2⟩ + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRouteSelector.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRouteSelector.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cf1b06e611ec6e1cb3bd0a53d3eb9750567233e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRouteSelector.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathTable +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteSelectorCorrectness + +namespace OAI + +/-! Route selection directly from source-position and coarse-path lists. The +crossing and permission tables are computed inside the polynomial program. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumComputedRouteSelector +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode +open QuantumRouteSelectorProgram QuantumTaggedRouteProgram + +abbrev Input := QuantumPathTable.Input × Ends +def inputCode : Input → List Bool := prodCode QuantumPathTable.inputCode endsCode + +def value (x : Input) : List Pair := + QuantumRouteSelectorProgram.value (QuantumPathTable.compile x.1,x.2) + +noncomputable def program : Procedure inputCode (listCode pairCode) value := + QuantumRouteSelectorProgram.program.comp + ((QuantumPathTable.compileProgram.comp (Procedure.first QuantumPathTable.inputCode endsCode)).pair + (Procedure.second QuantumPathTable.inputCode endsCode)) + + theorem value_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (es : List G.Edge) (hcover : ∀ e, e ∈ es) (ends : Ends) : + value ((List.ofFn P.position,es.map P.routeList),ends) = + QuantumRouteSelectorProgram.value (P.routingTable,ends) := by + have ht (R : QMACellRoute) : + tagged (QuantumPathTable.compile (List.ofFn P.position,es.map P.routeList)) R = + tagged P.routingTable R := by + simp only [tagged,bodyPermitted,QuantumPathTable.compile_allowed P es hcover] + unfold value QuantumRouteSelectorProgram.value candidates + rw [show tagged (QuantumPathTable.compile (List.ofFn P.position,es.map P.routeList)) = + tagged P.routingTable from funext ht] + + theorem value_merged {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (es : List G.Edge) (hcover : ∀ e, e ∈ es) + (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (e : (P.crossingOutput N hD).merge.Edge) : + value ((List.ofFn P.position,es.map P.routeList), + P.crossingPosition N D ((P.crossingOutput N hD).merge.left e), + P.crossingPosition N D ((P.crossingOutput N hD).merge.right e)) = + (P.mergedOutputRoute N hD havoid e).path := by + rw [value_actual P es hcover] + exact P.selected_merged_path N hD havoid e + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode (listCode pairCode) value := + program.toTM2 + +end ContinuumCoulomb.QuantumComputedRouteSelector + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRoutingTable.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRoutingTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..8847f2470d09ad88870acf9f9bb0d42732252410 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumComputedRoutingTable.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingCrossingTest +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawFamilyProgram + +namespace OAI + +/-! Compute the crossing list from encoded visits, and preserve exactly the +routing permissions of the geometric construction. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumRoutingTable +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +private theorem filter_eq_flatten {α : Type} (p : α → Bool) (xs : List α) : + (xs.map (fun a => if p a then [a] else [])).flatten = xs.filter p := by + induction xs with + | nil => rfl + | cons a xs ih => + simp only [List.map_cons,List.flatten_cons,List.filter_cons,ih] + cases p a <;> simp + +private noncomputable def selectCrossingProgram : + Procedure inputCode (listCode pairCode) + (fun x => if crossingTest x.1 x.2 then [x.2] else []) := + Procedure.conditional crossingTestProgram + ((Procedure.listCons pairCode).comp + (cellProgram.pair (Procedure.constant inputCode (listCode pairCode) []))) + (Procedure.constant inputCode (listCode pairCode) []) + +noncomputable def computedCrossingsProgram : Procedure tableCode (listCode pairCode) + computedCrossings := by + let visits : Procedure tableCode (listCode visitCode) (fun t => t.2.1) := + (Procedure.first (listCode visitCode) (listCode pairCode)).comp + (Procedure.second (listCode pairCode) (prodCode (listCode visitCode) (listCode pairCode))) + let cells := (Procedure.listMap ((0,0),(0,0)) (0,0) + (Procedure.first pairCode pairCode)).comp visits + let selected := (Procedure.listMapWith (f := fun t p => if crossingTest t p then [p] else []) + (0,0) [] selectCrossingProgram).comp ((Procedure.identity tableCode).pair cells) + exact ((QuantumRawExchange.flattenProgram pairCode (0,0)).comp selected).congrFun (by + intro t + change ((t.2.1.map Prod.fst).map (fun p => if crossingTest t p then [p] else [])).flatten = _ + exact filter_eq_flatten (crossingTest t) (t.2.1.map Prod.fst)) + +def computedTable (t : Table) : Table := (t.1,t.2.1,computedCrossings t) + +noncomputable def computedTableProgram : Procedure tableCode tableCode computedTable := by + let rest := Procedure.second (listCode pairCode) (prodCode (listCode visitCode) (listCode pairCode)) + let visits := (Procedure.first (listCode visitCode) (listCode pairCode)).comp rest + exact (Procedure.first (listCode pairCode) _).pair (visits.pair computedCrossingsProgram) + + theorem computedTable_allowed {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (R : QMACellRouteBody) : + allowed (computedTable P.routingTable) R = allowed P.routingTable R := by + have h (p : Pair) : p ∈ computedCrossings P.routingTable ↔ + p ∈ P.routingTable.2.2 := + (computedCrossings_correct P p).trans (P.routingTable_crossing p).symm + apply Bool.eq_iff_iff.mpr + cases R with + | ray p a => + simp only [allowed,computedTable,Bool.and_eq_true,Bool.not_eq_true_eq_eq_false, + decide_eq_true_eq,decide_eq_false_iff_not,h] + constructor + · rintro ⟨hs,hc⟩; exact ⟨of_decide_eq_true hs,hc⟩ + · rintro ⟨hs,hc⟩; exact ⟨decide_eq_true hs,hc⟩ + | pair p e => + simp only [allowed,computedTable,Bool.and_eq_true,Bool.not_eq_true_eq_eq_false, + decide_eq_true_eq,decide_eq_false_iff_not,h] + constructor + · rintro ⟨hc,hv⟩; exact ⟨hc,of_decide_eq_true hv⟩ + · rintro ⟨hc,hv⟩; exact ⟨hc,decide_eq_true hv⟩ + | patch p e => simp only [allowed,computedTable,decide_eq_true_eq,h] + | corridor p a b c => + cases b <;> cases c <;> simp [allowed,computedTable,h] + +end ContinuumCoulomb.QuantumRoutingTable + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoordinateSpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoordinateSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..80105425df40ecb2dc402b0cea2ebea8bdad1df7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCoordinateSpectrum.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalFamily +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalRealification + +namespace OAI + +/-! The local qubit-coordinate matrices retain the full-space spectral +bounds, through explicit basis equivalences. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaQuadratic_reindex {α β : Type*} [Fintype α] [Fintype β] + (e : β ≃ α) (A : Matrix α α ℂ) (u : α → ℂ) : + qmaQuadratic (A.submatrix e e) (u ∘ e) = qmaQuadratic A u := by + have he : (u ∘ e) ∘ e.symm = u := by funext i; simp + unfold qmaQuadratic + rw [Matrix.submatrix_mulVec_equiv,he] + change (∑ i : β, star (u (e i))*A.mulVec u (e i)).re = + (∑ i : α, star (u i)*A.mulVec u i).re + exact congrArg Complex.re (e.sum_comp (fun i => star (u i)*A.mulVec u i)) + +theorem qmaNorm_reindex {α β : Type*} [Fintype α] [Fintype β] + (e : β ≃ α) (u : α → ℂ) : ‖WithLp.toLp 2 (u ∘ e)‖ = ‖WithLp.toLp 2 u‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + simp only [EuclideanSpace.norm_sq_eq,Function.comp_apply] + exact e.sum_comp (fun i => ‖u i‖^2) + +def qmaRebitQubitSplit (ι : Type*) : (Unit ⊕ ι → Fin 2) ≃ Fin 2 × (ι → Fin 2) where + toFun s := (s (Sum.inl ()),s ∘ Sum.inr) + invFun p := Sum.elim (fun _ => p.1) p.2 + left_inv s := by + funext i + cases i with + | inl u => cases u; rfl + | inr i => rfl + right_inv p := rfl + +def qmaRealCircuitQubitSplit (c : QMACircuit) : + (Unit ⊕ QMACircuitQubit c → Fin 2) ≃ QMARealBasis c := + (qmaRebitQubitSplit (QMACircuitQubit c)).trans + (Equiv.prodCongr (Equiv.refl _) (qmaCircuitQubitSplit c)) + +def qmaRealQubitHamiltonian (c : QMACircuit) := qmaRebitOnQubits (qmaQubitHamiltonian c) + +theorem qmaRealQubitHamiltonian_reindex (c : QMACircuit) : + qmaRealQubitHamiltonian c = (qmaRealHamiltonian c).submatrix + (qmaRealCircuitQubitSplit c) (qmaRealCircuitQubitSplit c) := rfl + +theorem qmaRealQubitHamiltonian_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : EuclideanSpace ℂ (Unit ⊕ QMACircuitQubit c → Fin 2)) : + 2*‖u‖^2 ≤ 5*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaRealQubitHamiltonian c) (fun p => u p) := by + let e := qmaRealCircuitQubitSplit c + let v := (fun p => u p) ∘ e.symm + have hu : v ∘ e = fun p => u p := by funext p; simp [v] + have hn := qmaNorm_reindex e v + rw [hu] at hn + have hq := qmaQuadratic_reindex e (qmaRealHamiltonian c) v + rw [hu,←qmaRealQubitHamiltonian_reindex] at hq + have h := qmaRealHamiltonian_sound c hc hsound (WithLp.toLp 2 v) + simpa only [←hn,PiLp.toLp_apply,←hq] using h + +theorem qmaRealQubitHamiltonian_accepting (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : EuclideanSpace ℂ (Unit ⊕ QMACircuitQubit c → Fin 2), ‖u‖ = 1 ∧ + 3*(c.gates.length+1:ℝ)*qmaQuadratic (qmaRealQubitHamiltonian c) (fun p => u p) ≤ 1 := by + obtain ⟨v,hv,he⟩ := qmaRealHamiltonian_accepting c hc psi hpsi hacc + let e := qmaRealCircuitQubitSplit c + refine ⟨WithLp.toLp 2 ((fun p => v p) ∘ e),?_,?_⟩ + · rw [qmaNorm_reindex] + exact hv + · change 3*(c.gates.length+1:ℝ)*qmaQuadratic (qmaRealQubitHamiltonian c) + ((fun p => v p) ∘ e) ≤ 1 + rw [qmaRealQubitHamiltonian_reindex,qmaQuadratic_reindex] + exact he + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCornerPatch.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCornerPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..1101f9cf92ea19784155516629745bebb5e0caf7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCornerPatch.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPatch + +namespace OAI + +/-! The two noncrossing pairings of four boundary ports use disjoint corner paths. -/ + +namespace ContinuumCoulomb + +def qmaCornerPatchEdge (mode : Bool) (a : Fin 2) : Fin 9 := + if mode then ![6,8] a else ![5,7] a + +def qmaCornerPatchLeft (mode : Bool) (a : Fin 2) : Fin 4 := + if mode then ![1,3] a else ![0,2] a + +def qmaCornerPatchRight (mode : Bool) (a : Fin 2) : Fin 4 := + if mode then ![2,0] a else ![1,3] a + +def qmaCornerPatchPath (mode : Bool) (a : Fin 2) : List (ℕ × ℕ) := + qmaCrossingPatchPath (qmaCornerPatchEdge mode a) + +theorem qmaCornerPatch_endpoints (mode : Bool) (a : Fin 2) : + (qmaCornerPatchPath mode a).head? = + some (qmaCrossingPatchVertex ((qmaCornerPatchLeft mode a).castLE (by decide))) ∧ + (qmaCornerPatchPath mode a).getLast? = + some (qmaCrossingPatchVertex ((qmaCornerPatchRight mode a).castLE (by decide))) := by + cases mode <;> fin_cases a <;> decide + +theorem qmaCornerPatch_chain (mode : Bool) (a : Fin 2) : + (qmaCornerPatchPath mode a).IsChain + (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := + qmaCrossingPatch_chain _ + +theorem qmaCornerPatch_simple (mode : Bool) (a : Fin 2) : + (qmaCornerPatchPath mode a).Nodup := qmaCrossingPatch_simple _ + +theorem qmaCornerPatch_disjoint (mode : Bool) : + Disjoint (qmaCornerPatchPath mode 0).toFinset (qmaCornerPatchPath mode 1).toFinset := by + cases mode <;> decide + +theorem qmaCornerPatch_length (mode : Bool) (a : Fin 2) : + (qmaCornerPatchPath mode a).length = 13 := by + cases mode <;> fin_cases a <;> decide + +theorem qmaCornerPatch_bounded (mode : Bool) (a : Fin 2) : + ∀ p ∈ qmaCornerPatchPath mode a, p.1 ≤ 12 ∧ p.2 ≤ 12 := + qmaCrossingPatch_bounded _ + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorEndpoints.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorEndpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..7732771ee72a73cb10ca7b3cbce3d02f0a0bee48 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorEndpoints.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRetainedRoutes + +namespace OAI + +/-! Either half of a corridor determines its unordered physical endpoints. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaPortOpposite_involutive (a : Fin 4) : qmaPortOpposite (qmaPortOpposite a) = a := by + fin_cases a <;> rfl + +theorem qmaGridNeighbor_opposite (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) : + qmaGridNeighbor (qmaGridNeighbor p a) (qmaPortOpposite a) = p := by + fin_cases a + · exact Prod.ext (Nat.add_sub_cancel p.1 1) rfl + · exact Prod.ext rfl (Nat.add_sub_cancel p.2 1) + · exact Prod.ext (by change p.1-1+1 = p.1; omega) rfl + · exact Prod.ext rfl (by change p.2-1+1 = p.2; omega) + +def qmaCorridorHalfCell (p : ℕ × ℕ) (a : Fin 4) (t : Fin 2) : ℕ × ℕ := + if t = 0 then p else qmaGridNeighbor p a + +def qmaCorridorHalfPort (a : Fin 4) (t : Fin 2) : Fin 4 := if t = 0 then a else qmaPortOpposite a +def qmaCorridorHalfMode (b c : Bool) (t : Fin 2) : Bool := if t = 0 then b else c + +def qmaCorridorEndPair (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + (p : ℕ × ℕ) (a : Fin 4) : Sym2 (ℕ × ℕ) := + s(qmaMovedPort cross p a,qmaMovedPort cross (qmaGridNeighbor p a) (qmaPortOpposite a)) + +theorem qmaCorridorEndPair_reverse (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) : + qmaCorridorEndPair cross (qmaGridNeighbor p a) (qmaPortOpposite a) = qmaCorridorEndPair cross p a := by + unfold qmaCorridorEndPair + rw [qmaGridNeighbor_opposite p hp a,qmaPortOpposite_involutive] + exact Sym2.eq_swap + +theorem qmaCellCorridor_mem_half {p z : ℕ × ℕ} {a : Fin 4} {b c : Bool} + (hz : z ∈ qmaCellCorridor p a b c) : + ∃ t : Fin 2, z ∈ qmaHalfPathAt (qmaCorridorHalfCell p a t) + (qmaCorridorHalfMode b c t) (qmaCorridorHalfPort a t) := by + rcases List.mem_append.mp hz with h | h + · exact ⟨0,h⟩ + · exact ⟨1,List.mem_reverse.mp h⟩ + +theorem qmaCorridorBody_half_pair (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + (p : ℕ × ℕ) (hp : 0 < p.1 ∧ 0 < p.2) (a : Fin 4) (b c : Bool) + (hb : b = decide (cross p)) (hc : c = decide (cross (qmaGridNeighbor p a))) (t : Fin 2) : + s((QMACellRouteBody.corridor p a b c).source,(QMACellRouteBody.corridor p a b c).target) = + qmaCorridorEndPair cross (qmaCorridorHalfCell p a t) (qmaCorridorHalfPort a t) := by + have h0 : s((QMACellRouteBody.corridor p a b c).source, + (QMACellRouteBody.corridor p a b c).target) = qmaCorridorEndPair cross p a := by + change s(qmaCellTranslate p (qmaLocalPort b a), + qmaCellTranslate (qmaGridNeighbor p a) (qmaLocalPort c (qmaPortOpposite a))) = _ + rw [hb,hc,← qmaMovedPort_local,← qmaMovedPort_local] + rfl + fin_cases t + · exact h0 + · exact h0.trans (qmaCorridorEndPair_reverse cross p hp a).symm + +theorem qmaCorridorHalf_mode (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + (p : ℕ × ℕ) (a : Fin 4) (b c : Bool) + (hb : b = decide (cross p)) (hc : c = decide (cross (qmaGridNeighbor p a))) (t : Fin 2) : + qmaCorridorHalfMode b c t = decide (cross (qmaCorridorHalfCell p a t)) := by + fin_cases t + · exact hb + · exact hc + +theorem qmaHalfPathAt_collision (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + {p q z : ℕ × ℕ} {a d : Fin 4} {b c : Bool} + (hb : b = decide (cross p)) (hc : c = decide (cross q)) + (hz : z ∈ qmaHalfPathAt p b a) (hw : z ∈ qmaHalfPathAt q c d) : p = q ∧ a = d := by + obtain ⟨u,hu,heu⟩ := List.mem_map.mp hz + obtain ⟨v,hv,hev⟩ := List.mem_map.mp hw + have hh := qmaCellTranslate_unique (qmaHalfCorridor_bounded b a u hu) + (qmaHalfCorridor_bounded c d v hv) (heu.trans hev.symm) + rcases hh with ⟨rfl,rfl⟩ + have hbc : b = c := hb.trans hc.symm + have hv' : u ∈ qmaHalfCorridorPath b d := by rw [hbc]; exact hv + refine ⟨rfl,?_⟩ + by_contra had + exact Finset.disjoint_left.mp (qmaHalfCorridor_disjoint b a d had) + (List.mem_toFinset.mpr hu) (List.mem_toFinset.mpr hv') + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorInterior.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorInterior.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1b75163dd5dafcddfbabc3e28f99fd0a7c83734 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorInterior.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTranslatedInternalSeparation + +namespace OAI + +/-! An interior corridor point belongs to the nonterminal part of one of its +two cell-local halves. -/ + +namespace ContinuumCoulomb + +theorem qmaListInterior_ne_head {α : Type*} {l : List α} (hl : l.Nodup) + {z a : α} (ha : l.head? = some a) (hz : z ∈ (l.drop 1).dropLast) : z ≠ a := by + obtain ⟨t,rfl⟩ := List.head?_eq_some_iff.mp ha + have ht : z ∈ t := List.mem_of_mem_dropLast hz + intro h + subst z + exact (List.nodup_cons.mp hl).1 ht + +theorem qmaListInterior_ne_last {l : List (ℕ × ℕ)} (hl : l.Nodup) + {z a : ℕ × ℕ} (ha : l.getLast? = some a) (hz : z ∈ (l.drop 1).dropLast) : z ≠ a := by + apply qmaListInterior_ne_head (List.nodup_reverse.mpr hl) + · simpa only [List.head?_reverse] using ha + · apply List.mem_toFinset.mp + rw [qmaInterior_reverse] + exact List.mem_toFinset.mpr hz + +theorem qmaList_mem_drop_one {α : Type*} {l : List α} {z a : α} + (ha : l.head? = some a) (hz : z ∈ l) (hne : z ≠ a) : z ∈ l.drop 1 := by + obtain ⟨t,rfl⟩ := List.head?_eq_some_iff.mp ha + rcases List.mem_cons.mp hz with h | h + · exact (hne h).elim + · exact h + +theorem qmaCellCorridor_interior {p z : ℕ × ℕ} (hp : 0 < p.1 ∧ 0 < p.2) + {a : Fin 4} {b c : Bool} (hz : z ∈ ((qmaCellCorridor p a b c).drop 1).dropLast) : + z ∈ (qmaHalfPathAt p b a).drop 1 ∨ + z ∈ (qmaHalfPathAt (qmaGridNeighbor p a) c (qmaPortOpposite a)).drop 1 := by + have hs := qmaCellCorridor_simple p hp a b c + have hfirst := qmaListInterior_ne_head hs (qmaCellCorridor_endpoints p a b c).1 hz + have hlast := qmaListInterior_ne_last hs (qmaCellCorridor_endpoints p a b c).2 hz + have hm := List.mem_of_mem_drop (List.mem_of_mem_dropLast hz) + rcases List.mem_append.mp hm with h | h + · exact Or.inl (qmaList_mem_drop_one (qmaHalfPathAt_endpoints p b a).1 h hfirst) + · exact Or.inr (qmaList_mem_drop_one + (qmaHalfPathAt_endpoints (qmaGridNeighbor p a) c (qmaPortOpposite a)).1 + (List.mem_reverse.mp h) hlast) + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c07d346eccc6a528c1e9e372c84106cb93bd243d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCorridorSeparation.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCorridorEndpoints +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInternalHalfSeparation +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCorridorInterior + +namespace OAI + +/-! Complete corridor separation: internal paths only meet corridors at their +terminals, and different physical corridors have disjoint full paths. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +theorem internal_corridor_disjoint (p q : ℕ × ℕ) (e : QMAInternalEdge) (a : Fin 4) + (b c : Bool) (he : P.RoutingAllowed (qmaInternalBody p e)) + (hc : P.RoutingAllowed (.corridor q a b c)) : + Disjoint ((((qmaInternalBody p e).path).drop 1).dropLast).toFinset + (qmaCellCorridor q a b c).toFinset := by + apply Finset.disjoint_left.mpr + intro z hz hw + obtain ⟨t,ht⟩ := qmaCellCorridor_mem_half (List.mem_toFinset.mp hw) + exact Finset.disjoint_left.mp (P.internal_halfAt_disjoint p (qmaCorridorHalfCell q a t) e + (qmaCorridorHalfPort a t) (qmaCorridorHalfMode b c t) he + (qmaCorridorHalf_mode P.IsCrossing q a b c hc.1 hc.2 t)) hz (List.mem_toFinset.mpr ht) + +theorem corridor_internal_disjoint (p q : ℕ × ℕ) (a : Fin 4) (b c : Bool) (e : QMAInternalEdge) + (hp : 0 < p.1 ∧ 0 < p.2) (hc : P.RoutingAllowed (.corridor p a b c)) + (he : P.RoutingAllowed (qmaInternalBody q e)) : + Disjoint (((qmaCellCorridor p a b c).drop 1).dropLast).toFinset + (qmaInternalBody q e).path.toFinset := by + apply Finset.disjoint_left.mpr + intro z hz hw + rcases qmaCellCorridor_interior hp (List.mem_toFinset.mp hz) with h | h + · exact Finset.disjoint_left.mp (P.halfAt_internal_disjoint p q a b e he hc.1) + (List.mem_toFinset.mpr h) hw + · exact Finset.disjoint_left.mp (P.halfAt_internal_disjoint (qmaGridNeighbor p a) q + (qmaPortOpposite a) c e he hc.2) (List.mem_toFinset.mpr h) hw + +theorem corridors_disjoint (p q : ℕ × ℕ) (a d : Fin 4) (b c f g : Bool) + (hp : 0 < p.1 ∧ 0 < p.2) (hq : 0 < q.1 ∧ 0 < q.2) + (hR : P.RoutingAllowed (.corridor p a b c)) (hS : P.RoutingAllowed (.corridor q d f g)) + (hne : s((QMACellRouteBody.corridor p a b c).source,(QMACellRouteBody.corridor p a b c).target) ≠ + s((QMACellRouteBody.corridor q d f g).source,(QMACellRouteBody.corridor q d f g).target)) : + Disjoint (qmaCellCorridor p a b c).toFinset (qmaCellCorridor q d f g).toFinset := by + apply Finset.disjoint_left.mpr + intro z hz hw + obtain ⟨t,ht⟩ := qmaCellCorridor_mem_half (List.mem_toFinset.mp hz) + obtain ⟨u,hu⟩ := qmaCellCorridor_mem_half (List.mem_toFinset.mp hw) + have hc := qmaHalfPathAt_collision P.IsCrossing + (qmaCorridorHalf_mode P.IsCrossing p a b c hR.1 hR.2 t) + (qmaCorridorHalf_mode P.IsCrossing q d f g hS.1 hS.2 u) ht hu + apply hne + rw [qmaCorridorBody_half_pair P.IsCrossing p hp a b c hR.1 hR.2 t, + qmaCorridorBody_half_pair P.IsCrossing q hq d f g hS.1 hS.2 u,hc.1,hc.2] + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountedHistory.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountedHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ee50629fc80879b3a4fe02cbafa1642b30516ce --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountedHistory.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalInput + +namespace OAI + +/-! The actual history Hamiltonian with individual input-qubit penalties. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix + +def qmaCountedHistoryHamiltonian (c : QMACircuit) : + Matrix (QMAHistoryBasis c) (QMAHistoryBasis c) ℂ := + Matrix.diagonal (qmaFinalDiagonal c)+ + (7:ℂ) • Matrix.diagonal (fun k => (qmaInitialCountDiagonal c k : ℂ))+ + (8*c.gates.length:ℂ) • ((qmaPropagationMatrix c).conjTranspose*qmaPropagationMatrix c) + +theorem qmaCountedHistoryHamiltonian_hermitian (c : QMACircuit) : + (qmaCountedHistoryHamiltonian c).IsHermitian := by + have hi : (Matrix.diagonal (fun k => (qmaInitialCountDiagonal c k : ℂ))).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro k + simp [isSelfAdjoint_iff] + have ho : (Matrix.diagonal (qmaFinalDiagonal c)).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro p + unfold qmaFinalDiagonal + split <;> simp + exact (ho.add (hi.smul (by simp))).add + ((Matrix.isHermitian_conjTranspose_mul_self (qmaPropagationMatrix c)).smul + (by simp [isSelfAdjoint_iff])) + +theorem qmaCountedHistoryHamiltonian_form (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (qmaCountedHistoryHamiltonian c) u = + qmaOutputPenalty c (qmaHistoryFromVector c u)+ + 7*qmaQuadratic (Matrix.diagonal (fun k => (qmaInitialCountDiagonal c k : ℂ))) u+ + 8*c.gates.length*qmaPropagationEnergy c (qmaHistoryFromVector c u) := by + unfold qmaCountedHistoryHamiltonian + rw [qmaQuadratic_add,qmaQuadratic_add] + have hs : (8*c.gates.length:ℂ) = ((8*(c.gates.length:ℝ):ℝ):ℂ) := by push_cast; rfl + have h7 : (7:ℂ) = ((7:ℝ):ℂ) := by norm_num + rw [hs,h7,qmaQuadratic_smul,qmaQuadratic_smul, + qmaFinalDiagonal_energy,qmaPropagationMatrix_energy] + +theorem qmaCountedHistoryHamiltonian_dominates (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (qmaHistoryHamiltonian c) u ≤ + qmaQuadratic (qmaCountedHistoryHamiltonian c) u := by + rw [qmaHistoryHamiltonian_form,qmaCountedHistoryHamiltonian_form] + have h := qmaInitialCountDiagonal_energy_ge c u + rw [qmaInitialDiagonal_energy] at h + unfold qmaHistoryEnergy + linarith + +theorem qmaCountedHistoryHamiltonian_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : EuclideanSpace ℂ (QMAHistoryBasis c)) : + 2*‖u‖^2 ≤ 5*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaCountedHistoryHamiltonian c) (fun p => u p) := by + exact (qmaHistoryHamiltonian_sound c hc hsound u).trans + (mul_le_mul_of_nonneg_left (qmaCountedHistoryHamiltonian_dominates c (fun p => u p)) + (by positivity)) + +theorem qmaCountedHistoryHamiltonian_ideal (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaQuadratic (qmaCountedHistoryHamiltonian c) + (fun k => qmaHistoryVector c (qmaIdealHistory c hc psi) k) = + ‖qmaRejectVector c hc psi‖^2 := by + rw [qmaCountedHistoryHamiltonian_form,qmaInitialCountDiagonal_ideal_zero, + qmaHistoryVector_propagation,qmaIdealHistory_propagation] + unfold qmaOutputPenalty + rw [qmaHistoryVector_slice c _ c.gates.length le_rfl] + simp only [qmaIdealHistory,qmaPrefixMatrix_length,qmaRejectVector,qmaOutputVector, + mul_zero,add_zero] + +theorem qmaCountedHistoryHamiltonian_accepting (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : EuclideanSpace ℂ (QMAHistoryBasis c), ‖u‖ = 1 ∧ + 3*(c.gates.length+1:ℝ)*qmaQuadratic (qmaCountedHistoryHamiltonian c) (fun p => u p) ≤ 1 := by + let w := qmaHistoryVector c (qmaIdealHistory c hc psi) + have hw : ‖w‖^2 = (c.gates.length+1:ℝ) := by + simp only [w,qmaHistoryVector_norm,qmaIdealHistory_mass,hpsi,one_pow,mul_one] + have hn : ‖w‖ ≠ 0 := by + intro h + rw [h] at hw + have hp : (0:ℝ) < c.gates.length+1 := by positivity + norm_num at hw + linarith + have he : 3*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaCountedHistoryHamiltonian c) (fun p => w p) ≤ ‖w‖^2 := by + rw [hw] + dsimp only [w] + rw [qmaCountedHistoryHamiltonian_ideal] + have h := mul_le_mul_of_nonneg_left (qmaRejectVector_of_accept c hc psi hpsi hacc) + (by positivity : 0 ≤ 3*(c.gates.length+1:ℝ)) + nlinarith + let v := ((‖w‖⁻¹:ℝ):ℂ) • w + refine ⟨v,by simp [v,norm_smul,hn],?_⟩ + have hq : qmaQuadratic (qmaCountedHistoryHamiltonian c) (fun p => v p) = + (‖w‖⁻¹)^2*qmaQuadratic (qmaCountedHistoryHamiltonian c) (fun p => w p) := by + convert qmaQuadratic_vector_smul (qmaCountedHistoryHamiltonian c) (‖w‖⁻¹) + (fun p => w p) using 1 + congr 1 + have hm := mul_le_mul_of_nonneg_left he (sq_nonneg (‖w‖⁻¹)) + have hi : (‖w‖⁻¹)^2*‖w‖^2 = 1 := by field_simp + rw [hq] + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..32ebc8f123c6ec204b06954446d2a7ce3f07e18f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermProgram.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCountertermSample +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSampleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.BisectionProgram + +namespace OAI + +/-! Literal rational arithmetic for the internal four-spin counterterms. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque positiveProgram : Procedure ratCode Procedure.boolCode (fun t : ℚ => decide (0 < t)) := + BisectionProgram.rationalLess.comp ((Procedure.constant ratCode ratCode 0).pair (Procedure.identity ratCode)) + +noncomputable opaque polarityProgram : Procedure ratCode ratCode polarity := by + exact (Procedure.conditional positiveProgram (Procedure.constant ratCode ratCode (-1)) + (Procedure.constant ratCode ratCode 1)).congrFun (by + intro t + by_cases ht : 0 < t + · simp [polarity,ht,not_le_of_gt ht] + · simp [polarity,ht,le_of_not_gt ht]) + +noncomputable opaque shiftProgram (a : Fin 2) : Procedure ratCode ratCode + (fun t => shift a (decide (t ≤ 0))) := by + by_cases ha : a = 0 + · exact (Procedure.constant ratCode ratCode 400).congrFun (by intro t; simp [shift,ha]) + · exact (Procedure.conditional positiveProgram (Procedure.constant ratCode ratCode (4/3)) + (Procedure.constant ratCode ratCode (8/3))).congrFun (by + intro t + by_cases ht : 0 < t + · simp [shift,ha,ht,not_le_of_gt ht] + · simp [shift,ha,ht,le_of_not_gt ht]) + +noncomputable opaque absoluteInputProgram : Procedure radialCode ratCode (fun x => |x.2|) := + MediatorProgram.absoluteProgram.comp inputCoefficientProgram + +noncomputable opaque factorProgram (a b : Fin 2) : Procedure radialCode ratCode + (fun x => factor x.1 a b x.2) := by + let l := (valueProgram a).comp inputPrecisionProgram + let r := (valueProgram b).comp inputPrecisionProgram + exact (Procedure.ratMul.comp ((Procedure.ratMul.comp (absoluteInputProgram.pair l)).pair r)).congrFun + (by intro x; rfl) + +noncomputable opaque counterAProgram (a b : Fin 2) : Procedure radialCode ratCode + (fun x => counterA x.1 a b x.2) := by + let v := (valueProgram b).comp inputPrecisionProgram + let s := (shiftProgram b).comp inputCoefficientProgram + exact (Procedure.ratMul.comp ((Procedure.ratMul.comp (absoluteInputProgram.pair v)).pair s)).congrFun + (by intro x; rfl) + +noncomputable opaque counterBProgram (a b : Fin 2) : Procedure radialCode ratCode + (fun x => counterB x.1 a b x.2) := by + let v := (valueProgram a).comp inputPrecisionProgram + let sign := polarityProgram.comp inputCoefficientProgram + let initial := Procedure.ratMul.comp (absoluteInputProgram.pair v) + let signed := Procedure.ratMul.comp (initial.pair sign) + exact (Procedure.ratMul.comp (signed.pair (Procedure.constant radialCode ratCode (shift a true)))).congrFun + (by intro x; rfl) + +noncomputable def counterACertificate (a b : Fin 2) : Turing.TM2ComputableInPolyTime + radialCode ratCode (fun x => counterA x.1 a b x.2) := (counterAProgram a b).toTM2 + +noncomputable def counterBCertificate (a b : Fin 2) : Turing.TM2ComputableInPolyTime + radialCode ratCode (fun x => counterB x.1 a b x.2) := (counterBProgram a b).toTM2 + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..88cdfb766e2388a38ddbb54447ed8af0b4e084ab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCountertermSample.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSample + +namespace OAI + +/-! The counterterms use only rational arithmetic and the fixed inverse-scale sample. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open scoped Classical + +theorem factor_eq (a b : Fin 2) (t : ℝ) : + qmaFourCouplingFactor a b t = |t| *inverseScale a*inverseScale b := by + have ha := inverseScale_mul a + have hb := inverseScale_mul b + have he : qmaFourCouplingFactor a b t*qmaFourAxisScale a*qmaFourAxisScale b = |t| := + qmaFourCouplingSize_square a b t + calc + _ = qmaFourCouplingFactor a b t*(inverseScale a*qmaFourAxisScale a)* + (inverseScale b*qmaFourAxisScale b) := by rw [ha,hb]; ring + _ = (qmaFourCouplingFactor a b t*qmaFourAxisScale a*qmaFourAxisScale b)*inverseScale a*inverseScale b := by ring + _ = _ := by rw [he] + +theorem counterA_eq (a b : Fin 2) (t : ℝ) : + qmaFourCounterA a b t = |t| *inverseScale b*qmaFourAxisShift b (qmaFourCouplingSign t) := by + rw [qmaFourCounterA,factor_eq] + calc + _ = |t| *inverseScale b*(inverseScale a*qmaFourAxisScale a)*qmaFourAxisShift b (qmaFourCouplingSign t) := by ring + _ = _ := by rw [inverseScale_mul]; ring + +theorem counterB_eq (a b : Fin 2) (t : ℝ) : + qmaFourCounterB a b t = |t| *inverseScale a*qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisShift a true := by + rw [qmaFourCounterB,factor_eq] + calc + _ = |t| *inverseScale a*qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisShift a true* + (inverseScale b*qmaFourAxisScale b) := by ring + _ = _ := by rw [inverseScale_mul]; ring + +def shift (a : Fin 2) (p : Bool) : ℚ := if a = 0 then 400 else if p then 8/3 else 4/3 +def polarity (t : ℚ) : ℚ := if t ≤ 0 then 1 else -1 + +theorem shift_cast (a : Fin 2) (p : Bool) : (shift a p:ℝ) = qmaFourAxisShift a p := by + unfold shift qmaFourAxisShift + split_ifs <;> norm_num + +theorem polarity_cast (t : ℚ) : (polarity t:ℝ) = qmaFourAxisSign (qmaFourCouplingSign (t:ℝ)) := by + by_cases ht : t ≤ 0 + · have htR : (t:ℝ) ≤ 0 := by exact_mod_cast ht + simp [polarity,qmaFourAxisSign,qmaFourCouplingSign,ht,htR] + · have htR : ¬(t:ℝ) ≤ 0 := by exact_mod_cast ht + simp [polarity,qmaFourAxisSign,qmaFourCouplingSign,ht,htR] + +theorem sign_cast (t : ℚ) : decide (t ≤ 0) = qmaFourCouplingSign (t:ℝ) := by + unfold qmaFourCouplingSign + congr 1 + exact propext (by exact_mod_cast (Iff.rfl : t ≤ 0 ↔ t ≤ 0)) + +def factor (k : ℕ) (a b : Fin 2) (t : ℚ) : ℚ := |t| *value k a*value k b +def counterA (k : ℕ) (_a b : Fin 2) (t : ℚ) : ℚ := |t| *value k b*shift b (decide (t ≤ 0)) +def counterB (k : ℕ) (a _b : Fin 2) (t : ℚ) : ℚ := |t| *value k a*polarity t*shift a true + +theorem factor_error (k : ℕ) (a b : Fin 2) (t : ℚ) : + |(factor k a b t:ℝ)-qmaFourCouplingFactor a b (t:ℝ)| ≤ 2*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + rw [factor_eq] + simp only [factor,Rat.cast_mul,Rat.cast_abs] + calc + _ = abs (|(t:ℝ)| *((value k a:ℝ)*(value k b:ℝ)-inverseScale a*inverseScale b)) := by + congr 1 + ring + _ = |(t:ℝ)| *|(value k a:ℝ)*(value k b:ℝ)-inverseScale a*inverseScale b| := by rw [abs_mul,abs_abs] + _ ≤ |(t:ℝ)| *(2*(2:ℝ)⁻¹^k) := mul_le_mul_of_nonneg_left (product_error k a b) (abs_nonneg _) + _ = _ := by ring + +theorem counterA_error (k : ℕ) (a b : Fin 2) (t : ℚ) : + |(counterA k a b t:ℝ)-qmaFourCounterA a b (t:ℝ)| ≤ 400*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + rw [counterA_eq] + simp only [counterA,Rat.cast_mul,Rat.cast_abs,shift_cast,sign_cast] + calc + _ = abs (|(t:ℝ)| *((value k b:ℝ)-inverseScale b)*qmaFourAxisShift b (qmaFourCouplingSign (t:ℝ))) := by + congr 1 + ring + _ = |(t:ℝ)| *|(value k b:ℝ)-inverseScale b| *|qmaFourAxisShift b (qmaFourCouplingSign (t:ℝ))| := by + rw [abs_mul,abs_mul,abs_abs] + _ ≤ (|(t:ℝ)| *(2:ℝ)⁻¹^k)*400 := mul_le_mul + (mul_le_mul_of_nonneg_left (value_error k b) (abs_nonneg _)) + (qmaFourAxisShift_abs_bound b _) (abs_nonneg _) (by positivity) + _ = _ := by ring + +theorem counterB_error (k : ℕ) (a b : Fin 2) (t : ℚ) : + |(counterB k a b t:ℝ)-qmaFourCounterB a b (t:ℝ)| ≤ 400*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + rw [counterB_eq] + simp only [counterB,Rat.cast_mul,Rat.cast_abs,shift_cast,polarity_cast] + calc + _ = abs (|(t:ℝ)| *((value k a:ℝ)-inverseScale a)*qmaFourAxisSign (qmaFourCouplingSign (t:ℝ))* + qmaFourAxisShift a true) := by + congr 1 + ring + _ = |(t:ℝ)| *|(value k a:ℝ)-inverseScale a| *|qmaFourAxisSign (qmaFourCouplingSign (t:ℝ))| * + |qmaFourAxisShift a true| := by + rw [abs_mul,abs_mul,abs_mul,abs_abs] + _ = |(t:ℝ)| *|(value k a:ℝ)-inverseScale a| *|qmaFourAxisShift a true| := by + rw [qmaFourAxisSign_abs,mul_one] + _ ≤ (|(t:ℝ)| *(2:ℝ)⁻¹^k)*400 := mul_le_mul + (mul_le_mul_of_nonneg_left (value_error k a) (abs_nonneg _)) + (qmaFourAxisShift_abs_bound a true) (abs_nonneg _) (by positivity) + _ = _ := by ring + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..07eb7e379729145c80df0db7963d2d007aff5902 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingBounds.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingGraph + +namespace OAI + +/-! Polynomial coefficient and operator bounds for the crossing construction. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaCrossingLeft : Fin 4 → Fin 4 := ![0,0,1,2] +def qmaCrossingRight : Fin 4 → Fin 4 := ![1,3,2,3] +def qmaCrossingWeight (J K : ℝ) : Fin 4 → ℝ := ![1/2,-K,-J,2*J*K] +def qmaCrossingOffset (J K : ℝ) : ℝ := 3/2+3*J^2+3*K^2 + +theorem qmaCrossingCorrection_exchange {n : ℕ} (site : Fin 4 → Fin n) (J K : ℝ) : + qmaCrossingCorrection site J K = + qmaExchangeMatrix (fun a => site (qmaCrossingLeft a)) + (fun a => site (qmaCrossingRight a)) (qmaCrossingWeight J K) (qmaCrossingOffset J K) := by + simp [qmaCrossingCorrection,qmaExchangeMatrix,qmaCrossingLeft,qmaCrossingRight, + qmaCrossingWeight,qmaCrossingOffset,Fin.sum_univ_succ] + module + +theorem qmaCrossingCorrection_lift_norm {n r : ℕ} (site : Fin 4 → Fin n) + (hsite : Function.Injective site) (J K : ℝ) : + ‖spinMatrixOperator (qmaCrossingCorrection site J K ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ 12*(1+|J|+|K|)^2 := by + have hneq (a : Fin 4) : site (qmaCrossingLeft a) ≠ site (qmaCrossingRight a) := by + intro h + have hh := hsite h + fin_cases a <;> norm_num [qmaCrossingLeft,qmaCrossingRight] at hh + rw [qmaCrossingCorrection_exchange] + apply (qmaExchangeMatrix_lift_norm _ _ hneq _ _).trans + have hoff : 0 ≤ qmaCrossingOffset J K := by unfold qmaCrossingOffset; positivity + rw [abs_of_nonneg hoff] + simp [qmaCrossingWeight,qmaCrossingOffset,Fin.sum_univ_succ,abs_mul,abs_neg] + nlinarith [sq_abs J,sq_abs K,abs_nonneg J,abs_nonneg K,mul_nonneg (abs_nonneg J) (abs_nonneg K)] + +theorem qmaCrossingAmplitude_norm (R J K : ℝ) (hR : 0 ≤ R) : + 3*(∑ a, |qmaCrossingAmplitude R J K a|) = 6*R*(1+|J|+|K|) := by + simp [qmaCrossingAmplitude,Fin.sum_univ_succ,abs_mul,abs_of_nonneg hR] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab686003a2a7d2b6792afa9208e884d94072aace --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCalibration.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingParallel +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingScale + +namespace OAI + +/-! Explicit polynomial calibration for a simultaneous crossing stage. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +theorem qmaCrossings_correction_norm {n r : ℕ} (site : Fin r → Fin 4 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) : + ‖spinMatrixOperator ((∑ e, qmaCrossingCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ + 12*∑ e, (1+|J e|+|K e|)^2 := by + rw [MediatorGraph.sum_kronecker,spinMatrixOperator_sum,Finset.mul_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun e _ => + qmaCrossingCorrection_lift_norm (site e) (hsite e) (J e) (K e))) + +theorem qmaCrossings_amplitude (r : ℕ) (R : ℝ) (hR : 0 ≤ R) (J K : Fin r → ℝ) : + 3*(∑ e, ∑ a, |qmaCrossingAmplitude R (J e) (K e) a|) = + (6*∑ e, (1+|J e|+|K e|))*R := by + rw [Finset.mul_sum] + simp_rw [qmaCrossingAmplitude_norm R _ _ hR] + rw [← Finset.mul_sum] + ring + +theorem qmaCrossings_accuracy {n r : ℕ} (site : Fin r → Fin 4 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) + {B N : ℝ} (hB : 0 ≤ B) (hN : 0 < N) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + (hCn : ‖spinMatrixOperator (C ⊗ₖ (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ B) : + let A := 6*∑ e, (1+|J e|+|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) + (qmaRoutingStars n r site (fun _ => qmaCrossingMember) + (fun e => qmaCrossingAmplitude R (J e) (K e)))) - + sourceMatrixBottom n (C + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 1) (site e 3)))| ≤ 1/N := by + let A := 6*∑ e, (1+|J e|+|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + have hA : 0 ≤ A := by dsimp [A]; positivity + have hD : 0 ≤ D := by dsimp [D]; positivity + obtain ⟨hR,he,hes,hbound,herr⟩ := qmaRoutingScale_bounds hA hD hN + have hCC : ‖spinMatrixOperator ((C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ D := by + rw [Matrix.add_kronecker,spinMatrixOperator_add] + exact (norm_add_le _ _).trans (add_le_add hCn (qmaCrossings_correction_norm site hsite J K)) + have hb : ‖spinMatrixOperator ((C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ e, ∑ a, |qmaCrossingAmplitude R (J e) (K e) a| ≤ ((A+D+1)/R)*(4*R^2) := by + rw [qmaCrossings_amplitude r R hR.le J K] + exact (add_le_add hCC (le_refl (A*R))).trans hbound + exact (qmaCrossings_bottom site hsite R hR J K C hC he hes hb).trans herr + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCoefficientBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCoefficientBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f3197ea586826d64523b625f262446025036926 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCoefficientBound.lean @@ -0,0 +1,165 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathPolynomialBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalCrossing + +namespace OAI + +/-! Polynomial coefficient envelopes for the actual rational crossing layer. +The bounds include its scalar counterterms. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaCrossingWeight_abs_le {J K L : ℝ} (hL : 1 ≤ L) + (hJ : |J| ≤ L) (hK : |K| ≤ L) (a : Fin 4) : + |qmaCrossingWeight J K a| ≤ 2*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hLL : L ≤ L^2 := by nlinarith + have hprod := mul_le_mul hJ hK (abs_nonneg K) hL0 + fin_cases a <;> simp [qmaCrossingWeight,abs_mul] <;> nlinarith + +theorem qmaCrossingAmplitude_abs_le {R J K L : ℝ} (hL : 1 ≤ L) + (hR : |R| ≤ L) (hJ : |J| ≤ L) (hK : |K| ≤ L) (a : Fin 4) : + |qmaCrossingAmplitude R J K a| ≤ 2*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hLL : L ≤ L^2 := by nlinarith + have hprodJ := mul_le_mul hR hJ (abs_nonneg J) hL0 + have hprodK := mul_le_mul hR hK (abs_nonneg K) hL0 + fin_cases a <;> simp [qmaCrossingAmplitude,abs_mul] <;> nlinarith + +theorem qmaCrossingOffset_abs_le {J K L : ℝ} (hL : 1 ≤ L) + (hJ : |J| ≤ L) (hK : |K| ≤ L) : + |qmaCrossingOffset J K| ≤ 8*L^2 := by + have hJ2 : J^2 ≤ L^2 := by nlinarith [sq_abs J,mul_self_le_mul_self (abs_nonneg J) hJ] + have hK2 : K^2 ≤ L^2 := by nlinarith [sq_abs K,mul_self_le_mul_self (abs_nonneg K) hK] + have hL2 : 1 ≤ L^2 := one_le_pow₀ hL + rw [abs_of_nonneg (by unfold qmaCrossingOffset; positivity)] + unfold qmaCrossingOffset + linarith + +def qmaCrossingBudget (m r L : ℝ) : ℝ := + 3*m*L+L+6*r*(1+2*L)+12*r*(1+2*L)^2+1 + +def qmaCrossingRadiusBound (m r L T : ℝ) : ℝ := + L+16*(qmaCrossingBudget m r L)^3*T+4*qmaCrossingBudget m r L+1 + +def qmaCrossingCoefficientBound (m r L T : ℝ) : ℝ := + 1+L+(11*r+2)*(qmaCrossingRadiusBound m r L T)^2 + +namespace QMARationalCrossingLayer +variable {r : ℕ} (C : QMARationalCrossingLayer r) + +theorem scale_abs_bound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card C.base.Edge:ℝ) ≤ m) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : C.base.CoefficientBound L) + (hJ : ∀ i, |(C.J i:ℝ)| ≤ L) (hK : ∀ i, |(C.K i:ℝ)| ≤ L) : + |(C.scale N:ℝ)| ≤ qmaCrossingRadiusBound m r L T := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hn0 : 0 ≤ (N:ℝ) := by exact_mod_cast hN + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hret : (∑ e, |(C.base.weight e:ℝ)|) ≤ m*L := by + calc + _ ≤ ∑ _e : C.base.Edge, L := Finset.sum_le_sum (fun e _ => hc.2 e) + _ = (Fintype.card C.base.Edge:ℝ)*L := by simp + _ ≤ m*L := mul_le_mul_of_nonneg_right hm hL0 + have ha : (∑ i, (1+|(C.J i:ℝ)|+|(C.K i:ℝ)|)) ≤ r*(1+2*L) := by + calc + _ ≤ ∑ _i : Fin r, (1+2*L) := Finset.sum_le_sum (fun i _ => by linarith [hJ i,hK i]) + _ = (r:ℝ)*(1+2*L) := by simp [mul_add] + have hd : (∑ i, (1+|(C.J i:ℝ)|+|(C.K i:ℝ)|)^2) ≤ r*(1+2*L)^2 := by + calc + _ ≤ ∑ _i : Fin r, (1+2*L)^2 := Finset.sum_le_sum (fun i _ => + pow_le_pow_left₀ (by positivity) (by linarith [hJ i,hK i]) 2) + _ = (r:ℝ)*(1+2*L)^2 := by simp + let A := 6*∑ i, (1+|(C.J i:ℝ)|+|(C.K i:ℝ)|) + let D := 3*(∑ e, |(C.base.weight e:ℝ)|)+|(C.base.constant:ℝ)|+ + 12*∑ i, (1+|(C.J i:ℝ)|+|(C.K i:ℝ)|)^2 + have hAD0 : 0 ≤ A+D+1 := by dsimp [A,D]; positivity + have hAD : A+D+1 ≤ qmaCrossingBudget m r L := by + dsimp [A,D,qmaCrossingBudget] + linarith [hc.1] + have hcube := pow_le_pow_left₀ hAD0 hAD 3 + have hnT : (N:ℝ) ≤ T := by simpa only [abs_of_nonneg hn0] using hT + have hprod := mul_le_mul hcube hnT hn0 (pow_nonneg (hAD0.trans hAD) 3) + rw [C.scale_cast] + change |16*(A+D+1)^3*(N:ℝ)+4*(A+D+1)+1| ≤ _ + rw [abs_of_nonneg (by positivity)] + dsimp [qmaCrossingRadiusBound] + nlinarith + +theorem output_weight_abs_le (N : ℚ) {L : ℝ} (hL : 1 ≤ L) + (hR : |(C.scale N:ℝ)| ≤ L) (hw : ∀ e, |(C.base.weight e:ℝ)| ≤ L) + (hJ : ∀ i, |(C.J i:ℝ)| ≤ L) (hK : ∀ i, |(C.K i:ℝ)| ≤ L) + (e : (C.output N).Edge) : |((C.output N).weight e:ℝ)| ≤ 2*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hLL : L ≤ L^2 := by nlinarith + rcases e with (e | ⟨i,a⟩) | (i | ⟨i,a⟩) + · exact (hw e).trans (by nlinarith) + · change |(QuantumRoutingCode.coefficients (C.scale N,C.J i,C.K i) ⟨a.val+5,by omega⟩:ℝ)| ≤ _ + rw [QuantumRoutingCode.coefficients_perimeter] + exact qmaCrossingWeight_abs_le hL (hJ i) (hK i) a + · change |(((C.scale N)^2:ℚ):ℝ)| ≤ _ + push_cast + rw [abs_of_nonneg (sq_nonneg _)] + nlinarith [sq_abs (C.scale N:ℝ),mul_self_le_mul_self (abs_nonneg _) hR] + · change |(QuantumRoutingCode.coefficients (C.scale N,C.J i,C.K i) ⟨a.val+1,by omega⟩:ℝ)| ≤ _ + rw [QuantumRoutingCode.coefficients_spoke] + exact qmaCrossingAmplitude_abs_le hL hR (hJ i) (hK i) a + +theorem output_constant_abs_le (N : ℚ) {L : ℝ} (hL : 1 ≤ L) + (hR : |(C.scale N:ℝ)| ≤ L) (hJ : ∀ i, |(C.J i:ℝ)| ≤ L) + (hK : ∀ i, |(C.K i:ℝ)| ≤ L) : + |((C.output N).constant:ℝ)| ≤ |(C.base.constant:ℝ)|+11*(r:ℝ)*L^2 := by + have hR2 : (C.scale N:ℝ)^2 ≤ L^2 := by + nlinarith [sq_abs (C.scale N:ℝ),mul_self_le_mul_self (abs_nonneg _) hR] + have hs : |∑ i, qmaCrossingOffset (C.J i:ℝ) (C.K i:ℝ)| ≤ (r:ℝ)*(8*L^2) := by + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _i : Fin r, 8*L^2 := Finset.sum_le_sum (fun i _ => + qmaCrossingOffset_abs_le hL (hJ i) (hK i)) + _ = _ := by simp + have ha := abs_add_le (C.base.constant:ℝ) (∑ i, qmaCrossingOffset (C.J i:ℝ) (C.K i:ℝ)) + have hb := abs_add_le ((C.base.constant:ℝ)+∑ i, qmaCrossingOffset (C.J i:ℝ) (C.K i:ℝ)) + (3*(r:ℝ)*(C.scale N:ℝ)^2) + rw [abs_of_nonneg (by positivity : 0 ≤ 3*(r:ℝ)*(C.scale N:ℝ)^2)] at hb + change |((((C.base.constant+∑ i, (3/2+3*(C.J i)^2+3*(C.K i)^2))+ + 3*(r:ℚ)*(C.scale N)^2):ℚ):ℝ)| ≤ _ + push_cast + change |((C.base.constant:ℝ)+∑ i, qmaCrossingOffset (C.J i:ℝ) (C.K i:ℝ))+ + 3*(r:ℝ)*(C.scale N:ℝ)^2| ≤ _ + nlinarith [mul_le_mul_of_nonneg_left hR2 (by positivity : 0 ≤ (r:ℝ))] + +theorem output_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card C.base.Edge:ℝ) ≤ m) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : C.base.CoefficientBound L) + (hJ : ∀ i, |(C.J i:ℝ)| ≤ L) (hK : ∀ i, |(C.K i:ℝ)| ≤ L) : + (C.output N).CoefficientBound (qmaCrossingCoefficientBound m r L T) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hbudget : 0 ≤ qmaCrossingBudget m r L := by unfold qmaCrossingBudget; positivity + have hrad : L ≤ qmaCrossingRadiusBound m r L T := by + unfold qmaCrossingRadiusBound + have h : 0 ≤ 16*(qmaCrossingBudget m r L)^3*T := by positivity + linarith + have hr1 : 1 ≤ qmaCrossingRadiusBound m r L T := hL.trans hrad + have hr := C.scale_abs_bound hN hm hL hT hc hJ hK + have hj : ∀ i, |(C.J i:ℝ)| ≤ qmaCrossingRadiusBound m r L T := fun i => (hJ i).trans hrad + have hk : ∀ i, |(C.K i:ℝ)| ≤ qmaCrossingRadiusBound m r L T := fun i => (hK i).trans hrad + constructor + · have h := C.output_constant_abs_le N hr1 hr hj hk + unfold qmaCrossingCoefficientBound + nlinarith [hc.1,sq_nonneg (qmaCrossingRadiusBound m r L T)] + · intro e + have h := C.output_weight_abs_le N hr1 hr (fun e => (hc.2 e).trans hrad) hj hk e + unfold qmaCrossingCoefficientBound + nlinarith [sq_nonneg (qmaCrossingRadiusBound m r L T), + mul_nonneg (Nat.cast_nonneg r : (0:ℝ) ≤ r) (sq_nonneg (qmaCrossingRadiusBound m r L T))] + +end QMARationalCrossingLayer +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCompiled.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCompiled.lean new file mode 100644 index 0000000000000000000000000000000000000000..05ca580184a26be7abf4b92f9dbc07ab50448ff9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingCompiled.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingRetention +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListMatrix + +namespace OAI + +/-! Full-space correctness of the computed crossing transformation, starting +from an ordinary finite bond tape and its selected physical terminals. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open QuantumCrossingListBlock +open scoped Classical + +variable {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) {m : ℕ} (labels : G.Edge ≃ Fin m) + +def retainedGraph : QMARationalExchangeGraph := + QuantumListGraph.ofBonds G.n + (retained (pairs (List.ofFn (encodedSites S.site)),QuantumListGraph.packed G labels)) + G.constant + (retained_bounded _ _ (QuantumListGraph.packed_bounded G labels)) + (retained_noLoops _ _ (QuantumListGraph.packed_noLoops G labels)) + +def computedLayer : QMARationalCrossingLayer r where + base := retainedGraph S labels + site := S.site + injective := S.injective + J i := weight (QuantumListGraph.packed G labels,terminalPair 0 (encodedSites S.site i)) + K i := weight (QuantumListGraph.packed G labels,terminalPair 1 (encodedSites S.site i)) + +private theorem packed_ofBonds (n : ℕ) (xs : List MediatorListProgram.Bond) (c : ℚ) + (hb : SourceBondLists.bounded n xs) (hn : ∀ e ∈ xs, e.1 ≠ e.2.1) : + QuantumListGraph.packed (QuantumListGraph.ofBonds n xs c hb hn) (Equiv.refl _)=xs := by + change List.ofFn (fun i : Fin xs.length => xs.get i)=xs + exact List.ofFn_get xs + +theorem compiled_packet (N : ℚ) : + value (N,(G.n,QuantumListGraph.packed G labels,G.constant), + List.ofFn (encodedSites S.site)) = + QuantumCrossingListLayer.actualInput (computedLayer S labels) N (Equiv.refl _) := by + apply Prod.ext + · apply Prod.ext + · rfl + · apply Prod.ext + · rfl + · apply Prod.ext + · exact (packed_ofBonds G.n + (retained (pairs (List.ofFn (encodedSites S.site)),QuantumListGraph.packed G labels)) + G.constant (retained_bounded _ _ (QuantumListGraph.packed_bounded G labels)) + (retained_noLoops _ _ (QuantumListGraph.packed_noLoops G labels))).symm + · rfl + · simp only [value,crossings,QuantumCrossingListLayer.actualInput,List.map_ofFn] + apply congrArg List.ofFn + funext i + rfl + +variable (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) +include htag + +theorem retainedGraph_matrix : + qmaExchangeMatrix (retainedGraph S labels).left (retainedGraph S labels).right + (fun e => ((retainedGraph S labels).weight e:ℝ)) (retainedGraph S labels).constant = + qmaExchangeMatrix S.retained.left S.retained.right + (fun e => (S.retained.weight e:ℝ)) S.retained.constant := by + exact (QuantumListGraph.ofBonds_matrix G.n + (retained (pairs (List.ofFn (encodedSites S.site)),QuantumListGraph.packed G labels)) + G.constant (retained_bounded _ _ (QuantumListGraph.packed_bounded G labels)) + (retained_noLoops _ _ (QuantumListGraph.packed_noLoops G labels))).trans + (retained_matrix S htag labels) + +theorem computedLayer_source_matrix : + qmaExchangeMatrix (computedLayer S labels).source.left (computedLayer S labels).source.right + (fun e => ((computedLayer S labels).source.weight e:ℝ)) + (computedLayer S labels).source.constant = + qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant := by + apply (QMARationalCrossingLayer.source_matrix (computedLayer S labels)).trans + apply Eq.trans _ ((S.layer.source_matrix).symm.trans S.source_matrix) + apply congrArg₂ (fun a b : Matrix (SourceSpinBasis G.n) (SourceSpinBasis G.n) ℂ => a+b) + · exact retainedGraph_matrix S labels htag + · apply Finset.sum_congr rfl + intro i _ + change + (weight (QuantumListGraph.packed G labels,terminalPair 0 (encodedSites S.site i)):ℂ) • + sourceHeisenbergMatrix G.n (S.site i 0) (S.site i 2) + + (weight (QuantumListGraph.packed G labels,terminalPair 1 (encodedSites S.site i)):ℂ) • + sourceHeisenbergMatrix G.n (S.site i 1) (S.site i 3) = _ + rw [weight_selected S htag,weight_selected S htag] + rfl + +theorem computedLayer_source_energy : (computedLayer S labels).source.energy=G.energy := by + exact congrArg (sourceMatrixBottom G.n) (computedLayer_source_matrix S labels htag) + +theorem compiled_energy_error {N : ℚ} (hN : 0 < N) : + |(QuantumCrossingListLayer.actualGraph (computedLayer S labels) N (Equiv.refl _)).energy- + G.energy| ≤ 1/(N:ℝ) := by + rw [← computedLayer_source_energy S labels htag] + exact QuantumCrossingListLayer.energy_error (computedLayer S labels) hN (Equiv.refl _) + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingDirections.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingDirections.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cb9c293612c650cf490ec4b26bf1b7dfaeea3c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingDirections.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPorts +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighborsFour +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedBounds + +namespace OAI + +/-! The four crossing ports form a permutation of the four lattice directions. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaGridPorts_permutation {z : ℕ × ℕ} (hx : 0 < z.1) (hy : 0 < z.2) + (port : Fin 4 → ℕ × ℕ) (hi : Function.Injective port) + (ha : ∀ i, qmaSquareGrid.Adj z (port i)) : + ∃ σ : Fin 4 ≃ Fin 4, ∀ i, port i = qmaGridNeighbor z (σ i) := by + let index := fun i => qmaGridNeighborIndex z (port i) + have he (i) : qmaGridNeighbor z (index i) = port i := qmaGridNeighborIndex_spec hx hy (ha i) + have hinj : Function.Injective index := by + intro i j h + apply hi + rw [← he i,← he j,h] + let σ : Fin 4 ≃ Fin 4 := Equiv.ofBijective index ⟨hinj,Finite.surjective_of_injective hinj⟩ + exact ⟨σ,fun i => (he i).symm⟩ + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem buffered_crossing_directions (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (hv : ∀ v, z ≠ M.placedVertex v) + (he : z ∈ (M.bufferedPath hd e).val.support) + (hf : z ∈ (M.bufferedPath hd f).val.support) : + ∃ σ : Fin 4 ≃ Fin 4, + s(z,qmaGridNeighbor z (σ 0)) ∈ (M.bufferedPath hd e).val.edges ∧ + s(z,qmaGridNeighbor z (σ 1)) ∈ (M.bufferedPath hd e).val.edges ∧ + s(z,qmaGridNeighbor z (σ 2)) ∈ (M.bufferedPath hd f).val.edges ∧ + s(z,qmaGridNeighbor z (σ 3)) ∈ (M.bufferedPath hd f).val.edges := by + obtain ⟨port,hi,ha,h0,h1,h2,h3⟩ := M.buffered_crossing_ports hA hd hef hv he hf + have hp := M.bufferedPath_positive hd e he + obtain ⟨σ,hσ⟩ := qmaGridPorts_permutation hp.1 hp.2 port hi ha + refine ⟨σ,?_,?_,?_,?_⟩ + · simpa only [hσ] using h0 + · simpa only [hσ] using h1 + · simpa only [hσ] using h2 + · simpa only [hσ] using h3 + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingEffective.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingEffective.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e747ad819950beb7222dbcee75e8cca19308372 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingEffective.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSingletStar + +namespace OAI + +/-! Exact four-terminal crossing gadget and its perimeter counterterms. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaCrossingMember : Fin 4 → Fin 2 := ![0,0,1,1] + +def qmaCrossingAmplitude (R J K : ℝ) : Fin 4 → ℝ := ![R,R,2*R*J,2*R*K] + +def qmaCrossingCorrection {n : ℕ} (site : Fin 4 → Fin n) (J K : ℝ) : + Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ := + ((3/2+3*J^2+3*K^2:ℝ):ℂ) • 1 + + (1/2:ℂ) • sourceHeisenbergMatrix n (site 0) (site 1) - + (K:ℂ) • sourceHeisenbergMatrix n (site 0) (site 3) - + (J:ℂ) • sourceHeisenbergMatrix n (site 1) (site 2) + + ((2*J*K:ℝ):ℂ) • sourceHeisenbergMatrix n (site 2) (site 3) + +theorem qmaCrossing_effective {n r : ℕ} (e : Fin r) (site : Fin 4 → Fin n) + (hsite : Function.Injective site) (R J K : ℝ) (hR : R ≠ 0) : + qmaCrossingCorrection site J K - + mediatorCompression n r + (qmaSingletStar n r e site qmaCrossingMember (qmaCrossingAmplitude R J K) * + liftedMediatorInverse n r (R^2) * + qmaSingletStar n r e site qmaCrossingMember (qmaCrossingAmplitude R J K)) = + (J:ℂ) • sourceHeisenbergMatrix n (site 0) (site 2) + + (K:ℂ) • sourceHeisenbergMatrix n (site 1) (site 3) := by + have hk (a b : Fin 4) : qmaPauliKernel n (site a) (site b) = + if a = b then (3:ℂ) • 1 else sourceHeisenbergMatrix n (site a) (site b) := by + by_cases hab : a = b + · subst b + simp only [ite_true,qmaPauliKernel_self] + · rw [ite_eq_right hab] + exact qmaPauliKernel_eq n _ _ (fun h => hab (hsite h)) + rw [qmaSingletStar_compression] + simp only [hk,qmaCrossingCorrection] + simp [qmaCrossingMember,qmaCrossingAmplitude,Fin.sum_univ_succ] + rw [qmaHeisenberg_symm n (site 1) (site 0),qmaHeisenberg_symm n (site 2) (site 0), + qmaHeisenberg_symm n (site 2) (site 1),qmaHeisenberg_symm n (site 3) (site 0), + qmaHeisenberg_symm n (site 3) (site 1),qmaHeisenberg_symm n (site 3) (site 2)] + ext s t + simp only [Matrix.add_apply,Matrix.sub_apply,Matrix.neg_apply,Matrix.smul_apply, + smul_eq_mul,RCLike.real_smul_eq_coe_smul (K := ℂ),RCLike.ofReal_eq_complex_ofReal] + have hRC : (R:ℂ) ≠ 0 := by exact_mod_cast hR + field_simp [hRC] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..576eff07a28d2f8892f61aa3c52b4ed5c3a2f725 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingGraph.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingBounds + +namespace OAI + +/-! The ordinary nine-edge crossing gadget, retaining arbitrary old graph terms. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Kronecker Classical +variable {ν : Type*} [Fintype ν] + +def qmaCrossingBaseLeft {n : ℕ} (left : ν → Fin n) (site : Fin 4 → Fin n) : ν ⊕ Fin 4 → Fin n := + Sum.elim left (fun a => site (qmaCrossingLeft a)) +def qmaCrossingBaseRight {n : ℕ} (right : ν → Fin n) (site : Fin 4 → Fin n) : ν ⊕ Fin 4 → Fin n := + Sum.elim right (fun a => site (qmaCrossingRight a)) +def qmaCrossingBaseWeight (weight : ν → ℝ) (J K : ℝ) : ν ⊕ Fin 4 → ℝ := + Sum.elim weight (qmaCrossingWeight J K) + +omit [Fintype ν] in +theorem qmaCrossingBase_distinct {n : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (site : Fin 4 → Fin n) (hsite : Function.Injective site) : + ∀ a, qmaCrossingBaseLeft left site a ≠ qmaCrossingBaseRight right site a := by + intro a + cases a with + | inl a => exact hneq a + | inr a => + intro h + have hh := hsite h + fin_cases a <;> norm_num [qmaCrossingLeft,qmaCrossingRight] at hh + +theorem qmaCrossingBase_matrix {n : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant J K : ℝ) (site : Fin 4 → Fin n) : + qmaExchangeMatrix (qmaCrossingBaseLeft left site) (qmaCrossingBaseRight right site) + (qmaCrossingBaseWeight weight J K) (constant+qmaCrossingOffset J K) = + qmaExchangeMatrix left right weight constant + qmaCrossingCorrection site J K := by + rw [qmaCrossingCorrection_exchange] + simp only [qmaExchangeMatrix,Fintype.sum_sum_type,qmaCrossingBaseLeft,qmaCrossingBaseRight, + qmaCrossingBaseWeight,Sum.elim_inl,Sum.elim_inr,Complex.ofReal_add,add_smul] + abel + +def qmaCrossingGraph {n : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant R J K : ℝ) (site : Fin 4 → Fin n) : + Matrix (SourceSpinBasis (n+1*2)) (SourceSpinBasis (n+1*2)) ℂ := + qmaExchangeMatrix + (qmaStarGraphLeft (qmaCrossingBaseLeft left site) (0:Fin 1) site) + (qmaStarGraphRight (qmaCrossingBaseRight right site) (0:Fin 1) qmaCrossingMember) + (qmaStarGraphWeight (qmaCrossingBaseWeight weight J K) (R^2) (qmaCrossingAmplitude R J K)) + ((constant+qmaCrossingOffset J K)+3*1*(R^2)) + +theorem qmaCrossingGraph_matrix {n : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant R J K : ℝ) + (site : Fin 4 → Fin n) (hsite : Function.Injective site) : + (qmaCrossingGraph left right weight constant R J K site).submatrix + (basisEquiv n 1) (basisEquiv n 1) = + qmaPhysicalRoutingHamiltonian n 1 (R^2) + (qmaExchangeMatrix left right weight constant+qmaCrossingCorrection site J K) + 0 site qmaCrossingMember (qmaCrossingAmplitude R J K) := by + unfold qmaCrossingGraph + simpa only [Nat.cast_one,qmaCrossingBase_matrix] using + qmaStarGraph_matrix (r := 1) _ _ (qmaCrossingBase_distinct left right hneq site hsite) + (qmaCrossingBaseWeight weight J K) (constant+qmaCrossingOffset J K) (R^2) + 0 site qmaCrossingMember (qmaCrossingAmplitude R J K) + +theorem qmaCrossingGraph_bottom {n : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant R J K : ℝ) + (site : Fin 4 → Fin n) (hsite : Function.Injective site) (hR : 0 < R) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon ≤ 1/4) + (hbound : ‖spinMatrixOperator + ((qmaExchangeMatrix left right weight constant+qmaCrossingCorrection site J K) ⊗ₖ + (1 : Matrix (MediatorBasis 1) (MediatorBasis 1) ℂ))‖ + + 3*∑ a, |qmaCrossingAmplitude R J K a| ≤ epsilon*(4*R^2)) : + |sourceMatrixBottom (n+1*2) (qmaCrossingGraph left right weight constant R J K site) - + sourceMatrixBottom n (qmaExchangeMatrix left right weight constant + + ((J:ℂ) • sourceHeisenbergMatrix n (site 0) (site 2) + + (K:ℂ) • sourceHeisenbergMatrix n (site 1) (site 3)))| ≤ 16*R^2*epsilon^3 := by + rw [sourceMatrixBottom_eq_mediator n 1,qmaCrossingGraph_matrix left right hneq weight constant R J K site hsite] + have hC : (qmaExchangeMatrix left right weight constant).conjTranspose = + qmaExchangeMatrix left right weight constant := by + simp only [qmaExchangeMatrix,Matrix.conjTranspose_add,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,sourceHeisenbergMatrix_star n _ _ (hneq _), + Complex.star_def,Complex.conj_ofReal,Matrix.conjTranspose_one] + exact qmaPhysicalCrossing_bottom 0 site hsite R J K hR _ hC hepsilon hsmall hbound + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListActual.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListActual.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c94df340cd71d2369fc7421276b388df3b0edfb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListActual.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListLayer + +namespace OAI + +/-! The literal crossing packet has exactly the sites, scale and scalar +shift of the rational crossing layer used by the spectral comparison. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListLayer +open QuantumCrossingListBlock +open scoped BigOperators Classical + +def actualCrossing {r : ℕ} (C : QMARationalCrossingLayer r) (i : Fin r) : Crossing := + ((C.J i,C.K i),((C.site i 0).val,(C.site i 1).val), + ((C.site i 2).val,(C.site i 3).val)) +def actualInput {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : Input := + ((N,C.base.n,QuantumListGraph.packed C.base labels,C.base.constant), + List.ofFn (actualCrossing C)) + +theorem site_actual {r : ℕ} (C : QMARationalCrossingLayer r) (i : Fin r) (a : Fin 4) : + site (actualCrossing C i).2 a=(C.site i a).val := by + fin_cases a <;> rfl + +theorem scaleInput_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + scaleInput (actualInput C N labels)=QuantumCrossingScaleProgram.actualInput C N labels := by + simp only [scaleInput,actualInput,QuantumListGraph.packed,List.map_ofFn] + rfl + +theorem parameters_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + parameters (actualInput C N labels)=(C.base.n,C.scale N) := by + unfold parameters + rw [scaleInput_actual,QuantumCrossingScaleProgram.value_actual] + rfl + +theorem count_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + count (actualInput C N labels)=(C.output N).n := by + simp only [count,actualInput,List.length_ofFn,QMARationalCrossingLayer.output] + omega + +theorem constant_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + constant (actualInput C N labels)=(C.output N).constant := by + unfold constant familyInput + rw [parameters_actual] + change C.base.constant+familyOffset ((C.base.n,C.scale N),List.ofFn (actualCrossing C)) = _ + simp only [familyOffset,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + change C.base.constant+(∑ i, (3/2+3*(C.J i)^2+3*(C.K i)^2+3*(C.scale N)^2)) = + (C.base.constant+∑ i, (3/2+3*(C.J i)^2+3*(C.K i)^2))+3*(r:ℚ)*(C.scale N)^2 + rw [Finset.sum_add_distrib] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +theorem sites_bounded {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + ∀ c ∈ (actualInput C N labels).2, ∀ a, site c.2 a < (actualInput C N labels).1.2.1 := by + intro c hc a + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hc + rw [site_actual] + exact (C.site i a).isLt + +theorem sites_injective {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + ∀ c ∈ (actualInput C N labels).2, Function.Injective (site c.2) := by + intro c hc + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hc + intro a b hab + rw [site_actual,site_actual] at hab + exact C.injective i (Fin.ext hab) + +def actualGraph {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : QMARationalExchangeGraph := + graph (actualInput C N labels) (QuantumListGraph.packed_bounded C.base labels) + (QuantumListGraph.packed_noLoops C.base labels) + (sites_bounded C N labels) (sites_injective C N labels) + +end ContinuumCoulomb.QuantumCrossingListLayer + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListBlock.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1f020c6077548998cc0732aea4b8dd8288f5736 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListBlock.lean @@ -0,0 +1,169 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingProgram + +namespace OAI + +/-! The nine ordinary exchange interactions in a crossing gadget, serialized +in a fixed order. Every endpoint and rational coefficient is computed literally. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListBlock +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev Sites := (ℕ × ℕ) × (ℕ × ℕ) +def sitesCode : Sites → List Bool := + prodCode (prodCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits) +def site (s : Sites) : Fin 4 → ℕ := ![s.1.1,s.1.2,s.2.1,s.2.2] +abbrev Crossing := (ℚ × ℚ) × Sites +def crossingCode : Crossing → List Bool := prodCode (prodCode ratCode ratCode) sitesCode +abbrev Parameters := ℕ × ℚ +def parametersCode : Parameters → List Bool := prodCode unaryCode ratCode +abbrev Input := Parameters × (ℕ × Crossing) +def inputCode : Input → List Bool := prodCode parametersCode (prodCode unaryCode crossingCode) + +def base (x : Input) : ℕ := x.1.1+2*x.2.1 + +def left (x : Input) : Fin 9 → ℕ := + ![site x.2.2.2 0,site x.2.2.2 0,site x.2.2.2 1,site x.2.2.2 2, + base x,site x.2.2.2 0,site x.2.2.2 1,site x.2.2.2 2,site x.2.2.2 3] +def right (x : Input) : Fin 9 → ℕ := + ![site x.2.2.2 1,site x.2.2.2 3,site x.2.2.2 2,site x.2.2.2 3, + base x+1,base x,base x,base x+1,base x+1] +def coefficient (x : Input) : Fin 9 → ℚ := + let c := QuantumRoutingCode.coefficients (x.1.2,x.2.2.1) + ![c 5,c 6,c 7,c 8,x.1.2^2,c 1,c 2,c 3,c 4] +def bond (x : Input) (k : Fin 9) : Bond := (left x k,right x k,coefficient x k) +def block (x : Input) : List Bond := List.ofFn (bond x) + +noncomputable opaque crossingProgram : Procedure inputCode crossingCode (fun x => x.2.2) := + (Procedure.second unaryCode crossingCode).comp (Procedure.second parametersCode _) +noncomputable opaque sitesProgram : Procedure inputCode sitesCode (fun x => x.2.2.2) := + (Procedure.second (prodCode ratCode ratCode) sitesCode).comp crossingProgram +noncomputable opaque siteProgram (k : Fin 4) : Procedure inputCode Nat.bits (fun x => site x.2.2.2 k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact (Procedure.first Nat.bits Nat.bits).comp + ((Procedure.first (prodCode Nat.bits Nat.bits) _).comp sitesProgram) + refine Fin.cases ?_ (fun k => ?_) k + · exact (Procedure.second Nat.bits Nat.bits).comp + ((Procedure.first (prodCode Nat.bits Nat.bits) _).comp sitesProgram) + refine Fin.cases ?_ (fun k => ?_) k + · exact (Procedure.first Nat.bits Nat.bits).comp + ((Procedure.second (prodCode Nat.bits Nat.bits) _).comp sitesProgram) + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact (Procedure.second Nat.bits Nat.bits).comp + ((Procedure.second (prodCode Nat.bits Nat.bits) _).comp sitesProgram) + +noncomputable opaque radiusProgram : Procedure inputCode ratCode (fun x => x.1.2) := + (Procedure.second unaryCode ratCode).comp (Procedure.first parametersCode _) +noncomputable opaque baseProgram : Procedure inputCode Nat.bits base := by + let n := Procedure.unaryToBits.comp + ((Procedure.first unaryCode ratCode).comp (Procedure.first parametersCode (prodCode unaryCode crossingCode))) + let i := Procedure.unaryToBits.comp + ((Procedure.first unaryCode crossingCode).comp (Procedure.second parametersCode (prodCode unaryCode crossingCode))) + exact Procedure.binaryAdd.comp (n.pair + (Procedure.binaryMul.comp ((Procedure.constant inputCode Nat.bits 2).pair i))) +noncomputable opaque nextProgram : Procedure inputCode Nat.bits (fun x => base x+1) := + Procedure.binaryAdd.comp (baseProgram.pair (Procedure.constant inputCode Nat.bits 1)) +noncomputable opaque leftProgram (k : Fin 9) : Procedure inputCode Nat.bits (fun x => left x k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 0 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 0 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 1 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 2 + refine Fin.cases ?_ (fun k => ?_) k + · exact baseProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 0 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 1 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 2 + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact siteProgram 3 + +noncomputable opaque rightProgram (k : Fin 9) : Procedure inputCode Nat.bits (fun x => right x k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 1 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 3 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 2 + refine Fin.cases ?_ (fun k => ?_) k + · exact siteProgram 3 + refine Fin.cases ?_ (fun k => ?_) k + · exact nextProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact baseProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact baseProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact nextProgram + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact nextProgram + +noncomputable opaque coefficientsProgram (k : Fin 10) : + Procedure inputCode ratCode (fun x => QuantumRoutingCode.coefficients (x.1.2,x.2.2.1) k) := + (QuantumRoutingCode.coefficientProgram k).comp + (radiusProgram.pair ((Procedure.first (prodCode ratCode ratCode) sitesCode).comp crossingProgram)) +noncomputable opaque coefficientProgram (k : Fin 9) : + Procedure inputCode ratCode (fun x => coefficient x k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 5 + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 6 + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 7 + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 8 + refine Fin.cases ?_ (fun k => ?_) k + · exact QuantumRoutingCode.squareProgram radiusProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 1 + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 2 + refine Fin.cases ?_ (fun k => ?_) k + · exact coefficientsProgram 3 + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact coefficientsProgram 4 + +noncomputable opaque bondProgram (k : Fin 9) : Procedure inputCode bondCode (fun x => bond x k) := + (leftProgram k).pair ((rightProgram k).pair (coefficientProgram k)) +noncomputable opaque blockProgram : Procedure inputCode (listCode bondCode) block := + QuantumRawExchange.fixedListProgram inputCode bondCode 9 (fun k x => bond x k) bondProgram + +theorem block_length (x : Input) : (block x).length=9 := List.length_ofFn + +theorem block_bounded (x : Input) (r : ℕ) (hi : x.2.1 < r) + (hs : ∀ a, site x.2.2.2 a < x.1.1) : + SourceBondLists.bounded (x.1.1+2*r) (block x) := by + intro e he + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp he + have h0 := hs 0 + have h1 := hs 1 + have h2 := hs 2 + have h3 := hs 3 + fin_cases k <;> simp [bond,left,right,base,site] at * <;> omega + +theorem block_noLoops (x : Input) (hs : ∀ a, site x.2.2.2 a < x.1.1) + (hinj : Function.Injective (site x.2.2.2)) : + ∀ e ∈ block x, e.1 ≠ e.2.1 := by + intro e he + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp he + have h0 := hs 0 + have h1 := hs 1 + have h2 := hs 2 + have h3 := hs 3 + have h01 := hinj.ne (by decide : (0 : Fin 4) ≠ 1) + have h03 := hinj.ne (by decide : (0 : Fin 4) ≠ 3) + have h12 := hinj.ne (by decide : (1 : Fin 4) ≠ 2) + have h23 := hinj.ne (by decide : (2 : Fin 4) ≠ 3) + fin_cases k <;> simp [bond,left,right,base,site] at * <;> omega + +end ContinuumCoulomb.QuantumCrossingListBlock + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListFamily.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..74ddfa56a229cf77de9bc39fcd73a16579778427 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListFamily.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListBlock + +namespace OAI + +/-! A literal simultaneous crossing layer: nine bonds and two fresh spins per +crossing, with every scalar correction retained. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListBlock +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev FamilyInput := Parameters × List Crossing +def familyCode : FamilyInput → List Bool := prodCode parametersCode (listCode crossingCode) +def zeroCrossing : Crossing := ((0,0),(0,0),(0,0)) +def indexed (x : ℕ × FamilyInput) : Input := + (x.2.1,x.1,(x.2.2.drop x.1).headD zeroCrossing) +def family (x : FamilyInput) : List Bond := + ((List.range x.2.length).map (fun i => block (indexed (i,x)))).flatten +def offset (x : Input) : ℚ := QuantumRoutingCode.coefficients (x.1.2,x.2.2.1) 9 +def familyOffset (x : FamilyInput) : ℚ := (x.2.map (fun c => offset (x.1,0,c))).sum + +noncomputable opaque indexedProgram : Procedure (prodCode unaryCode familyCode) inputCode indexed := by + let i := Procedure.first unaryCode familyCode + let x := Procedure.second unaryCode familyCode + let p := (Procedure.first parametersCode (listCode crossingCode)).comp x + let cs := (Procedure.second parametersCode (listCode crossingCode)).comp x + let c := (Procedure.listGet crossingCode zeroCrossing).comp ((Procedure.unaryToBits.comp i).pair cs) + exact p.pair (i.pair c) +noncomputable opaque familyProgram : Procedure familyCode (listCode bondCode) family := by + let n := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength crossingCode zeroCrossing).comp + (Procedure.second parametersCode (listCode crossingCode)) + let tab := (Procedure.tabulate (f := fun x i => block (indexed (i,x))) [] + (blockProgram.comp indexedProgram)).comp (n.pair (Procedure.identity familyCode)) + exact (QuantumRawExchange.flattenProgram bondCode zeroBond).comp tab +noncomputable opaque offsetProgram : Procedure inputCode ratCode offset := coefficientsProgram 9 +noncomputable opaque familyOffsetProgram : Procedure familyCode ratCode familyOffset := by + let p := Procedure.first parametersCode crossingCode + let c := Procedure.second parametersCode crossingCode + let entry := offsetProgram.comp (p.pair ((Procedure.constant _ unaryCode 0).pair c)) + exact RationalSumProgram.sumProgram.comp + (Procedure.listMapWith (ea := parametersCode) (eb := crossingCode) (ec := ratCode) + (f := fun p c => offset (p,0,c)) zeroCrossing 0 entry) + +theorem family_length (x : FamilyInput) : (family x).length=9*x.2.length := by + simp only [family,List.length_flatten,List.map_map,Function.comp_def,block_length, + List.map_const',List.length_range,List.sum_replicate,nsmul_eq_mul,Nat.mul_comm] + norm_cast + +theorem indexed_mem (x : FamilyInput) (i : ℕ) (hi : i b.2.2),x.2.map Prod.fst)) +def parameters (x : Input) : Parameters := (x.1.2.1,QuantumCrossingScaleProgram.value (scaleInput x)) +def familyInput (x : Input) : FamilyInput := (parameters x,x.2) +def count (x : Input) : ℕ := x.1.2.1+2*x.2.length +def bonds (x : Input) : List Bond := x.1.2.2.1++family (familyInput x) +def constant (x : Input) : ℚ := x.1.2.2.2+familyOffset (familyInput x) +def value (x : Input) : QuantumListPathStep.Output := (count x,bonds x,constant x) + +noncomputable opaque packetProgram : Procedure inputCode QuantumListPathStep.outputCode + (fun x => x.1.2) := + (Procedure.second ratCode QuantumListPathStep.outputCode).comp + (Procedure.first (prodCode ratCode QuantumListPathStep.outputCode) (listCode crossingCode)) +noncomputable opaque nProgram : Procedure inputCode unaryCode (fun x => x.1.2.1) := + (Procedure.first unaryCode (prodCode (listCode bondCode) ratCode)).comp packetProgram +noncomputable opaque oldProgram : Procedure inputCode (prodCode (listCode bondCode) ratCode) + (fun x => x.1.2.2) := + (Procedure.second unaryCode (prodCode (listCode bondCode) ratCode)).comp packetProgram +noncomputable opaque oldBondsProgram : Procedure inputCode (listCode bondCode) + (fun x => x.1.2.2.1) := + (Procedure.first (listCode bondCode) ratCode).comp oldProgram +noncomputable opaque oldConstantProgram : Procedure inputCode ratCode + (fun x => x.1.2.2.2) := + (Procedure.second (listCode bondCode) ratCode).comp oldProgram +noncomputable opaque crossingProgram : Procedure inputCode (listCode crossingCode) Prod.snd := + Procedure.second (prodCode ratCode QuantumListPathStep.outputCode) (listCode crossingCode) +noncomputable opaque scaleInputProgram : + Procedure inputCode QuantumCrossingScaleProgram.inputCode scaleInput := by + let N := (Procedure.first ratCode QuantumListPathStep.outputCode).comp + (Procedure.first (prodCode ratCode QuantumListPathStep.outputCode) (listCode crossingCode)) + let pairs := (Procedure.listMap zeroCrossing (0,0) + (Procedure.first (prodCode ratCode ratCode) sitesCode)).comp crossingProgram + exact (N.pair oldConstantProgram).pair + (((QuantumListPathStep.weightsProgram).comp oldBondsProgram).pair pairs) +noncomputable opaque parametersProgram : Procedure inputCode parametersCode parameters := + nProgram.pair (QuantumCrossingScaleProgram.program.comp scaleInputProgram) +noncomputable opaque familyInputProgram : Procedure inputCode familyCode familyInput := + parametersProgram.pair crossingProgram +noncomputable opaque countProgram : Procedure inputCode unaryCode count := by + let r := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength crossingCode zeroCrossing).comp crossingProgram + exact Procedure.unaryAdd.comp (nProgram.pair + (Procedure.unaryMul.comp ((Procedure.constant inputCode unaryCode 2).pair r))) +noncomputable opaque bondsProgram : Procedure inputCode (listCode bondCode) bonds := + (Procedure.listAppend bondCode zeroBond).comp + (oldBondsProgram.pair (QuantumCrossingListBlock.familyProgram.comp familyInputProgram)) +noncomputable opaque constantProgram : Procedure inputCode ratCode constant := + Procedure.ratAdd.comp (oldConstantProgram.pair + (QuantumCrossingListBlock.familyOffsetProgram.comp familyInputProgram)) +noncomputable opaque program : Procedure inputCode QuantumListPathStep.outputCode value := + countProgram.pair (bondsProgram.pair constantProgram) + +theorem bonds_bounded (x : Input) + (hb : SourceBondLists.bounded x.1.2.1 x.1.2.2.1) + (hs : ∀ c ∈ x.2, ∀ a, site c.2 a < x.1.2.1) : + SourceBondLists.bounded (count x) (bonds x) := by + intro e he + rcases List.mem_append.mp he with he | he + · exact ⟨(hb e he).1.trans_le (Nat.le_add_right _ _), + (hb e he).2.trans_le (Nat.le_add_right _ _)⟩ + · exact family_bounded (familyInput x) hs e he + +theorem bonds_noLoops (x : Input) + (hn : ∀ e ∈ x.1.2.2.1, e.1 ≠ e.2.1) + (hs : ∀ c ∈ x.2, ∀ a, site c.2 a < x.1.2.1) + (hinj : ∀ c ∈ x.2, Function.Injective (site c.2)) : + ∀ e ∈ bonds x, e.1 ≠ e.2.1 := by + intro e he + rcases List.mem_append.mp he with he | he + · exact hn e he + · exact family_noLoops (familyInput x) hs hinj e he + +def graph (x : Input) (hb : SourceBondLists.bounded x.1.2.1 x.1.2.2.1) + (hn : ∀ e ∈ x.1.2.2.1, e.1 ≠ e.2.1) + (hs : ∀ c ∈ x.2, ∀ a, site c.2 a < x.1.2.1) + (hinj : ∀ c ∈ x.2, Function.Injective (site c.2)) : QMARationalExchangeGraph := + QuantumListGraph.ofBonds (count x) (bonds x) (constant x) + (bonds_bounded x hb hs) (bonds_noLoops x hn hs hinj) + +end ContinuumCoulomb.QuantumCrossingListLayer + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..3440b07b269d8689f8c27f2653a8aec5956b480a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListMatrix.lean @@ -0,0 +1,157 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListActual +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathMatrix + +namespace OAI + +/-! Exact full-space matrix semantics for the computed crossing packet. +The nine serialized bonds are the nine physical edges of each crossing. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListLayer +open QuantumCrossingListBlock MediatorGraph +open scoped BigOperators Classical + +def edgeTag {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + (i : Fin r) : Fin 9 → (C.output N).Edge := + ![.inl (.inr (i,0)),.inl (.inr (i,1)),.inl (.inr (i,2)),.inl (.inr (i,3)), + .inr (.inl i),.inr (.inr (i,0)),.inr (.inr (i,1)), + .inr (.inr (i,2)),.inr (.inr (i,3))] + +private theorem fresh_value (n r : ℕ) (i : Fin r) (a : Fin 2) : + (fresh n r i a).val=n+2*i.val+a.val := by + change n+(a.val+2*i.val)=_ + omega + +private theorem old_value (n r : ℕ) (i : Fin n) : (old n r i).val=i.val := rfl + +theorem bond_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + (i : Fin r) (k : Fin 9) : + bond ((C.base.n,C.scale N),i.val,actualCrossing C i) k = + (((C.output N).left (edgeTag C N i k)).val, + ((C.output N).right (edgeTag C N i k)).val, + (C.output N).weight (edgeTag C N i k)) := by + fin_cases k <;> + simp [bond,left,right,coefficient,base,actualCrossing,site,edgeTag, + QMARationalCrossingLayer.output,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaCrossingsBaseLeft,qmaCrossingsBaseRight,qmaCrossingLeft,qmaCrossingRight, + qmaCrossingMember,fresh_value,old_value] + +theorem block_matrix_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + (i : Fin r) : + SourceBondLists.matrix (C.output N).n + (block ((C.base.n,C.scale N),i.val,actualCrossing C i)) = + ∑ k : Fin 9, ((C.output N).weight (edgeTag C N i k):ℂ) • + sourceHeisenbergMatrix (C.output N).n + ((C.output N).left (edgeTag C N i k)) ((C.output N).right (edgeTag C N i k)) := by + simp only [SourceBondLists.matrix,block,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + apply Finset.sum_congr rfl + intro k _ + rw [bond_actual,SourceBondLists.bondMatrix,dite_eq_left + ⟨((C.output N).left (edgeTag C N i k)).isLt, + ((C.output N).right (edgeTag C N i k)).isLt⟩] + +private theorem indexed_ofFn {r : ℕ} (p : Parameters) (f : Fin r → Crossing) + (i : Fin r) : indexed (i.val,(p,List.ofFn f))=(p,i.val,f i) := by + unfold indexed + rw [List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem (by simpa only [List.length_ofFn] using i.isLt)] + simp only [List.getElem_ofFn,Option.getD_some] + +theorem family_ofFn {r : ℕ} (p : Parameters) (f : Fin r → Crossing) : + family (p,List.ofFn f)=(List.ofFn fun i => block (p,i.val,f i)).flatten := by + have hr (g : ℕ → List MediatorListProgram.Bond) : + (List.range r).map g=List.ofFn (fun i : Fin r => g i.val) := by + simpa only [List.length_range,List.getElem_range,Fin.val_cast] using + (List.ofFn_getElem_eq_map (List.range r) g).symm + unfold family + rw [List.length_ofFn,hr] + apply congrArg List.flatten + apply congrArg (fun g : Fin r → List MediatorListProgram.Bond => List.ofFn g) + funext i + rw [indexed_ofFn] + +theorem family_matrix_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) : + SourceBondLists.matrix (C.output N).n + (family ((C.base.n,C.scale N),List.ofFn (actualCrossing C))) = + ∑ i : Fin r, ∑ k : Fin 9, ((C.output N).weight (edgeTag C N i k):ℂ) • + sourceHeisenbergMatrix (C.output N).n + ((C.output N).left (edgeTag C N i k)) ((C.output N).right (edgeTag C N i k)) := by + rw [family_ofFn,QuantumListPathProgram.matrix_flatten] + simp only [List.map_ofFn,List.sum_ofFn,Function.comp_apply] + exact Finset.sum_congr rfl (fun i _ => block_matrix_actual C N i) + +theorem edgeTag_sum {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + {V : Type*} [AddCommMonoid V] (f : (C.output N).Edge → V) (i : Fin r) : + (∑ k : Fin 9, f (edgeTag C N i k)) = + (∑ a : Fin 4, f (.inl (.inr (i,a))))+f (.inr (.inl i))+ + ∑ a : Fin 4, f (.inr (.inr (i,a))) := by + simp [Fin.sum_univ_succ,edgeTag,add_assoc] + +private theorem sum_crossing_edges {α V : Type*} [Fintype α] [AddCommMonoid V] + {r : ℕ} (f : ((α ⊕ (Fin r × Fin 4)) ⊕ (Fin r ⊕ (Fin r × Fin 4))) → V) : + (∑ e, f e) = (∑ e : α, f (.inl (.inl e)))+ + (∑ i : Fin r, ((∑ a : Fin 4, f (.inl (.inr (i,a))))+ + f (.inr (.inl i))+(∑ a : Fin 4, f (.inr (.inr (i,a)))))) := by + simp only [Fintype.sum_sum_type,Fintype.sum_prod_type,Finset.sum_add_distrib] + ac_rfl + +theorem matrix_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + SourceBondLists.matrix (C.output N).n (bonds (actualInput C N labels))+ + ((C.output N).constant:ℂ) • 1 = + qmaExchangeMatrix (C.output N).left (C.output N).right + (fun e => ((C.output N).weight e:ℝ)) (C.output N).constant := by + let f : (C.output N).Edge → + Matrix (SourceSpinBasis (C.output N).n) (SourceSpinBasis (C.output N).n) ℂ := + fun e => ((C.output N).weight e:ℂ) • sourceHeisenbergMatrix (C.output N).n + ((C.output N).left e) ((C.output N).right e) + have hb : SourceBondLists.matrix (C.output N).n (QuantumListGraph.packed C.base labels) = + ∑ e : C.base.Edge, f (.inl (.inl e)) := by + change SourceBondLists.matrix (C.base.n+r*2) + (List.ofFn fun i => ((C.base.left (labels.symm i)).val, + (C.base.right (labels.symm i)).val,C.base.weight (labels.symm i))) = _ + rw [QuantumListPathProgram.retained_matrix] + exact labels.symm.sum_comp (fun e => (C.base.weight e:ℂ) • + sourceHeisenbergMatrix (C.base.n+r*2) + (old C.base.n r (C.base.left e)) (old C.base.n r (C.base.right e))) + have hfamily : familyInput (actualInput C N labels) = + ((C.base.n,C.scale N),List.ofFn (actualCrossing C)) := by + unfold familyInput + rw [parameters_actual] + rfl + unfold bonds + simp only [SourceBondLists.matrix,List.map_append,List.sum_append] + change (SourceBondLists.matrix (C.output N).n (QuantumListGraph.packed C.base labels)+ + SourceBondLists.matrix (C.output N).n (family (familyInput (actualInput C N labels))))+_ = _ + rw [hfamily,hb,family_matrix_actual] + change ((∑ e : C.base.Edge, f (.inl (.inl e)))+ + ∑ i : Fin r, ∑ k : Fin 9, f (edgeTag C N i k))+_ = _ + have ht : (∑ i : Fin r, ∑ k : Fin 9, f (edgeTag C N i k)) = + ∑ i : Fin r, ((∑ a : Fin 4, f (.inl (.inr (i,a))))+ + f (.inr (.inl i))+(∑ a : Fin 4, f (.inr (.inr (i,a))))) := + Finset.sum_congr rfl (fun i _ => edgeTag_sum C N f i) + rw [ht] + have hf : (∑ e, f e) = (∑ e : C.base.Edge, f (.inl (.inl e)))+ + (∑ i : Fin r, ((∑ a : Fin 4, f (.inl (.inr (i,a))))+ + f (.inr (.inl i))+(∑ a : Fin 4, f (.inr (.inr (i,a)))))) := by + exact sum_crossing_edges (α := C.base.Edge) f + simp only [qmaExchangeMatrix,Complex.ofReal_ratCast] + exact congrArg (fun x => x+((C.output N).constant:ℂ) • 1) hf.symm + +theorem energy_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : (actualGraph C N labels).energy=(C.output N).energy := by + unfold actualGraph graph + rw [QuantumListGraph.ofBonds_energy,count_actual,constant_actual] + exact congrArg (sourceMatrixBottom (C.output N).n) (matrix_actual C N labels) + +theorem energy_error {r : ℕ} (C : QMARationalCrossingLayer r) {N : ℚ} (hN : 0 < N) + {m : ℕ} (labels : C.base.Edge ≃ Fin m) : + |(actualGraph C N labels).energy-C.source.energy| ≤ 1/(N:ℝ) := by + rw [energy_actual] + exact C.output_energy_error hN + +end ContinuumCoulomb.QuantumCrossingListLayer + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListSupport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3b9a3ec6f24a181e8bc3501bdaccd36d43b2be5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingListSupport.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListMatrix + +namespace OAI + +/-! The literal nine-bond crossing block has precisely the unordered +endpoint support of the physical crossing graph. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListLayer +open QuantumCrossingListBlock +open scoped Classical + +variable {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + +theorem edge_base_or_tag (e : (C.output N).Edge) : + (∃ a : C.base.Edge, e = Sum.inl (Sum.inl a)) ∨ + ∃ i k, e = edgeTag C N i k := by + rcases e with (a | ⟨i,k⟩) | (i | ⟨i,k⟩) + · exact Or.inl ⟨a,rfl⟩ + · right + fin_cases k + · exact ⟨i,0,rfl⟩ + · exact ⟨i,1,rfl⟩ + · exact ⟨i,2,rfl⟩ + · exact ⟨i,3,rfl⟩ + · exact Or.inr ⟨i,4,rfl⟩ + · right + fin_cases k + · exact ⟨i,5,rfl⟩ + · exact ⟨i,6,rfl⟩ + · exact ⟨i,7,rfl⟩ + · exact ⟨i,8,rfl⟩ + +theorem bond_support_actual {m : ℕ} (labels : C.base.Edge ≃ Fin m) + (p : Sym2 ℕ) : + (∃ b ∈ bonds (actualInput C N labels), s(b.1,b.2.1) = p) ↔ + ∃ e : (C.output N).Edge, + s(((C.output N).left e).val,((C.output N).right e).val) = p := by + have hb (a : C.base.Edge) : + s(((C.output N).left (Sum.inl (Sum.inl a))).val, + ((C.output N).right (Sum.inl (Sum.inl a))).val) = + s((C.base.left a).val,(C.base.right a).val) := rfl + have hmem (i : Fin r) (k : Fin 9) : + bond ((C.base.n,C.scale N),i.val,actualCrossing C i) k ∈ + family ((C.base.n,C.scale N),List.ofFn (actualCrossing C)) := by + rw [family_ofFn] + exact List.mem_flatten.mpr ⟨_,List.mem_ofFn.mpr ⟨i,rfl⟩, + List.mem_ofFn.mpr ⟨k,rfl⟩⟩ + change (∃ b ∈ QuantumListGraph.packed C.base labels ++ + family (parameters (actualInput C N labels),List.ofFn (actualCrossing C)), + s(b.1,b.2.1)=p) ↔ _ + rw [parameters_actual] + constructor + · rintro ⟨b,hbonds,hp⟩ + rcases List.mem_append.mp hbonds with ho | hf + · obtain ⟨i,rfl⟩ := List.mem_ofFn.mp ho + exact ⟨Sum.inl (Sum.inl (labels.symm i)),(hb _).trans hp⟩ + · rw [family_ofFn] at hf + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hf + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hbs + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp hb + exact ⟨edgeTag C N i k,by simpa only [bond_actual] using hp⟩ + · rintro ⟨e,he⟩ + rcases edge_base_or_tag C N e with ⟨a,rfl⟩ | ⟨i,k,rfl⟩ + · refine ⟨((C.base.left a).val,(C.base.right a).val,C.base.weight a), + List.mem_append_left _ (List.mem_ofFn.mpr ⟨labels a,?_⟩),?_⟩ + · simp only [Equiv.symm_apply_apply] + · exact (hb a).symm.trans he + · exact ⟨_,List.mem_append_right _ (hmem i k),by simpa only [bond_actual] using he⟩ + +private theorem fin_pair {n : ℕ} {a b c d : Fin n} + (h : s(a.val,b.val)=s(c.val,d.val)) : s(a,b)=s(c,d) := by + rcases Sym2.eq_iff.mp h with ⟨h1,h2⟩ | ⟨h1,h2⟩ + · exact Sym2.eq_iff.mpr (Or.inl ⟨Fin.ext h1,Fin.ext h2⟩) + · exact Sym2.eq_iff.mpr (Or.inr ⟨Fin.ext h1,Fin.ext h2⟩) + +def actualVertex {m : ℕ} (labels : C.base.Edge ≃ Fin m) : + Fin (actualGraph C N labels).n ≃ Fin (C.output N).n := + finCongr (count_actual C N labels) + +theorem actual_support_source {m : ℕ} (labels : C.base.Edge ≃ Fin m) + (e : (actualGraph C N labels).Edge) : + ∃ f : (C.output N).Edge, + s(actualVertex C N labels ((actualGraph C N labels).left e), + actualVertex C N labels ((actualGraph C N labels).right e)) = + s((C.output N).left f,(C.output N).right f) := by + let xs := bonds (actualInput C N labels) + obtain ⟨f,hf⟩ := (bond_support_actual C N labels + s(((xs.get e).1),((xs.get e).2.1))).mp ⟨xs.get e,List.get_mem xs e,rfl⟩ + refine ⟨f,fin_pair ?_⟩ + exact hf.symm + +theorem actual_support_target {m : ℕ} (labels : C.base.Edge ≃ Fin m) + (f : (C.output N).Edge) : + ∃ e : (actualGraph C N labels).Edge, + s(actualVertex C N labels ((actualGraph C N labels).left e), + actualVertex C N labels ((actualGraph C N labels).right e)) = + s((C.output N).left f,(C.output N).right f) := by + obtain ⟨b,hb,hp⟩ := (bond_support_actual C N labels + s(((C.output N).left f).val,((C.output N).right f).val)).mpr ⟨f,rfl⟩ + obtain ⟨e,he⟩ := List.mem_iff_get.mp hb + refine ⟨e,fin_pair ?_⟩ + change s(((bonds (actualInput C N labels)).get e).1, + ((bonds (actualInput C N labels)).get e).2.1) = _ + rw [he] + exact hp + +end ContinuumCoulomb.QuantumCrossingListLayer + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingMove.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingMove.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7cc09837e254f62e7679841fc8cfc92772d27a0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingMove.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInnerPorts + +namespace OAI + +/-! Moving only crossing-cell ports is injective on all original spin locations. -/ + +namespace ContinuumCoulomb + +def QMAPortPoint (z : ℕ × ℕ) : Prop := + (∃ p, z = qmaExpandedPoint p) ∨ ∃ p a, z = qmaGridPort p a + +theorem qmaCrossingMove_injective (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + {x y : ℕ × ℕ} (hx : QMAPortPoint x) (hy : QMAPortPoint y) + (h : qmaCrossingMove cross x = qmaCrossingMove cross y) : x = y := by + rcases hx with ⟨p,rfl⟩ | ⟨p,a,rfl⟩ <;> rcases hy with ⟨q,rfl⟩ | ⟨q,b,rfl⟩ + · simpa only [qmaCrossingMove_center] using h + · simp only [qmaCrossingMove_center,qmaCrossingMove_port] at h + by_cases hq : cross q + · rw [ite_eq_left hq] at h + exact (qmaInnerPort_ne_center q p b h.symm).elim + · rw [ite_eq_right hq] at h + exact (qmaGridPort_ne_center q p b h.symm).elim + · simp only [qmaCrossingMove_center,qmaCrossingMove_port] at h + by_cases hp : cross p + · rw [ite_eq_left hp] at h + exact (qmaInnerPort_ne_center p q a h).elim + · rw [ite_eq_right hp] at h + exact (qmaGridPort_ne_center p q a h).elim + · simp only [qmaCrossingMove_port] at h + by_cases hp : cross p <;> by_cases hq : cross q + · rw [ite_eq_left hp,ite_eq_left hq] at h + have he : (p,a) = (q,b) := qmaInnerPort_injective h + exact congrArg (fun z : (ℕ × ℕ) × Fin 4 => qmaGridPort z.1 z.2) he + · rw [ite_eq_left hp,ite_eq_right hq] at h + exact (qmaInnerPort_ne_port p q a b h).elim + · rw [ite_eq_right hp,ite_eq_left hq] at h + exact (qmaInnerPort_ne_port q p b a h.symm).elim + · simpa only [ite_eq_right hp,ite_eq_right hq] using h + +theorem qmaGadgetAncilla_ne_moved (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] + (p : ℕ × ℕ) (a : Fin 2) {x : ℕ × ℕ} (hx : QMAPortPoint x) : + qmaGadgetAncilla p a ≠ qmaCrossingMove cross x := by + rcases hx with ⟨q,rfl⟩ | ⟨q,b,rfl⟩ + · rw [qmaCrossingMove_center] + exact qmaGadgetAncilla_ne_center p q a + · rw [qmaCrossingMove_port] + split_ifs + · exact qmaGadgetAncilla_ne_inner p q a b + · exact qmaGadgetAncilla_ne_port p q a b + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingOutputRoutes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingOutputRoutes.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd08bf3c98adf2381caa99fe14c8e8f7e7d11548 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingOutputRoutes.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRetainedRoutes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPatchEdgeCover +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPatchChart + +namespace OAI + +/-! Every edge of the actual simultaneous crossing output has a short permitted +lattice route with the exact physical endpoints. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +abbrev crossingOutput (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) := + (P.portCrossingSelection N hD).layer.output N + +theorem crossingOutput_route_exists (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (e : (P.crossingOutput N hD).Edge) : + ∃ R : QMACellRoute, P.RoutingAllowed R.body ∧ R.Valid ∧ + R.source = P.crossingPosition N D ((P.crossingOutput N hD).left e) ∧ + R.target = P.crossingPosition N D ((P.crossingOutput N hD).right e) := by + rcases qmaCrossingsEdge_cover e with ⟨f,rfl⟩ | ⟨i,k,rfl⟩ + · let R := P.retainedRoute N hD havoid f + have hs := P.retainedRoute_spec N hD havoid f + refine ⟨R,hs.1,hs.2.1,?_,?_⟩ + · change R.source = P.crossingPosition N D + (old (P.finishedGraph N D).n P.crossingCells.card ((P.finishedGraph N D).left f.val)) + rw [P.crossingPosition_old] + exact hs.2.2.1 + · change R.target = P.crossingPosition N D + (old (P.finishedGraph N D).n P.crossingCells.card ((P.finishedGraph N D).right f.val)) + rw [P.crossingPosition_old] + exact hs.2.2.2 + · refine ⟨qmaPatchRoute (P.crossingCell i).val k,?_,trivial,?_,?_⟩ + · exact P.mem_crossingCells.mp (P.crossingCell i).property + · rw [qmaPatchRoute_source] + change _ = P.crossingPosition N D + (qmaParallelGraphLeft (qmaCrossingsBaseLeft (P.portCrossingSelection N hD).retained.left + (P.crossingSiteFin N hD)) (P.crossingSiteFin N hD) (qmaPatchPhysicalEdge i k)) + rw [qmaPatchPhysical_left] + exact (P.crossingPosition_patchVertex N hD i (qmaPatchSource k)).symm + · rw [qmaPatchRoute_target] + change _ = P.crossingPosition N D + (qmaParallelGraphRight (qmaCrossingsBaseRight (P.portCrossingSelection N hD).retained.right + (P.crossingSiteFin N hD)) (fun _ => qmaCrossingMember) (qmaPatchPhysicalEdge i k)) + rw [qmaPatchPhysical_right] + exact (P.crossingPosition_patchVertex N hD i (qmaPatchTarget k)).symm + +def crossingOutputRoute (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (e : (P.crossingOutput N hD).Edge) : QMACellRoute := + Classical.choose (P.crossingOutput_route_exists N hD havoid e) + +theorem crossingOutputRoute_spec (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (e : (P.crossingOutput N hD).Edge) : + P.RoutingAllowed (P.crossingOutputRoute N hD havoid e).body ∧ + (P.crossingOutputRoute N hD havoid e).Valid ∧ + (P.crossingOutputRoute N hD havoid e).source = + P.crossingPosition N D ((P.crossingOutput N hD).left e) ∧ + (P.crossingOutputRoute N hD havoid e).target = + P.crossingPosition N D ((P.crossingOutput N hD).right e) := + Classical.choose_spec (P.crossingOutput_route_exists N hD havoid e) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..23974ccd4a6c5e8a16610aa8a30b6e8b4e63dec6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketBounds.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumComputedCrossingBounds + +namespace OAI + +/-! Coefficient bounds for the actual serialized crossing packet. The +transfer uses the literal nine-bond blocks, including the scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingListLayer +open MediatorListProgram QuantumCrossingListBlock +open scoped Classical + +variable {r m : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) + (labels : C.base.Edge ≃ Fin m) + +theorem actual_bonds_coefficientBound {L : ℝ} + (hc : (C.output N).CoefficientBound L) : + ∀ b ∈ bonds (actualInput C N labels), |(b.2.2 : ℝ)| ≤ L := by + intro b hb + rcases List.mem_append.mp hb with hb | hb + · obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hb + exact hc.2 (.inl (.inl (labels.symm i))) + · have hf : familyInput (actualInput C N labels) = + ((C.base.n,C.scale N),List.ofFn (actualCrossing C)) := by + unfold familyInput + rw [parameters_actual] + rfl + rw [hf,family_ofFn] at hb + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hb + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hbs + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp hb + rw [bond_actual] + exact hc.2 (edgeTag C N i k) + +theorem actualGraph_coefficientBound {L : ℝ} + (hc : (C.output N).CoefficientBound L) : + (actualGraph C N labels).CoefficientBound L := by + constructor + · change |(constant (actualInput C N labels) : ℝ)| ≤ L + rw [constant_actual] + exact hc.1 + · intro e + exact actual_bonds_coefficientBound C N labels hc _ + (List.get_mem (bonds (actualInput C N labels)) e) + +theorem actualGraph_card : + Fintype.card (actualGraph C N labels).Edge = Fintype.card C.base.Edge+9*r := by + change Fintype.card (Fin (bonds (actualInput C N labels)).length) = _ + rw [Fintype.card_fin] + simp only [bonds,List.length_append,family_length,familyInput,actualInput, + QuantumListGraph.packed,List.length_ofFn] + rw [Fintype.card_congr labels,Fintype.card_fin] + +end ContinuumCoulomb.QuantumCrossingListLayer + +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open scoped Classical + +variable {G : QMARationalExchangeGraph} {r k : ℕ} + (S : QMARationalCrossingSelection G r) (labels : G.Edge ≃ Fin k) + +theorem compiled_graph_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card G.Edge : ℝ) ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + (QuantumCrossingListLayer.actualGraph (computedLayer S labels) N (Equiv.refl _)).CoefficientBound + (qmaCrossingCoefficientBound m r ((m+1)*L) T) := + QuantumCrossingListLayer.actualGraph_coefficientBound _ _ _ + (computedLayer_output_coefficientBound S labels hN hm hL hT hc) + +theorem compiled_graph_count {m : ℝ} (hm : (Fintype.card G.Edge : ℝ) ≤ m) (N : ℚ) : + (Fintype.card + (QuantumCrossingListLayer.actualGraph (computedLayer S labels) N (Equiv.refl _)).Edge : ℝ) + ≤ m+9*r := by + rw [QuantumCrossingListLayer.actualGraph_card (computedLayer S labels) N (Equiv.refl _), + Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat] + have h : (Fintype.card (retainedGraph S labels).Edge : ℝ) ≤ (Fintype.card G.Edge : ℝ) := by + exact_mod_cast retainedGraph_count S labels + exact add_le_add (h.trans hm) (le_refl (9*(r : ℝ))) + +theorem compiled_merged_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card G.Edge : ℝ) ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + (QuantumCrossingListLayer.actualGraph (computedLayer S labels) N (Equiv.refl _)).merge.CoefficientBound + ((m+9*r+1)*qmaCrossingCoefficientBound m r ((m+1)*L) T) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have henv : 1 ≤ qmaCrossingCoefficientBound m r ((m+1)*L) T := by + unfold qmaCrossingCoefficientBound + have hp : 0 ≤ (11*(r : ℝ)+2)*(qmaCrossingRadiusBound m r ((m+1)*L) T)^2 := by + positivity + have hb : 0 ≤ (m+1)*L := by positivity + linarith + exact QMARationalExchangeGraph.merge_coefficientBound _ + (compiled_graph_count S labels hm N) henv + (compiled_graph_coefficientBound S labels hN hm hL hT hc) + +theorem compiled_merged_nat {N : ℚ} (hN : 0 ≤ N) {m L T : ℕ} + (hm : Fintype.card G.Edge ≤ m) (hL : 1 ≤ L) (hT : |(N : ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + (QuantumCrossingListLayer.actualGraph (computedLayer S labels) N (Equiv.refl _)).merge.CoefficientBound + ((m+9*r+1)*QuantumCoefficientPrograms.crossingCoefficient m r ((m+1)*L) T) := by + have hm' : (Fintype.card G.Edge : ℝ) ≤ m := by exact_mod_cast hm + have hL' : (1 : ℝ) ≤ L := by exact_mod_cast hL + simpa only [Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat, + QuantumCoefficientPrograms.crossingCoefficient_cast] using + compiled_merged_coefficientBound S labels hN hm' hL' hT hc + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..0949a323af2b836be3b00ec2b13dfd6c3f2ef804 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPacketEnergy.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingCompiled +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectionUnique + +namespace OAI + +/-! Full-space crossing error stated directly for the serialized bond packet. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingPacketEnergy +open QuantumCrossingListBlock MediatorListProgram QuantumCrossingSelectProgram +open scoped Classical + +def energy (x : QuantumListPathStep.Output) : ℝ := + sourceMatrixBottom x.1 (SourceBondLists.matrix x.1 x.2.1+(x.2.2:ℂ) • 1) + +theorem actual_energy {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : + energy (QuantumCrossingListLayer.value (QuantumCrossingListLayer.actualInput C N labels))= + (QuantumCrossingListLayer.actualGraph C N labels).energy := by + symm + unfold QuantumCrossingListLayer.actualGraph QuantumCrossingListLayer.graph + rw [QuantumListGraph.ofBonds_energy] + rfl + +theorem compiled_error {G : QMARationalExchangeGraph} {r m : ℕ} + (S : QMARationalCrossingSelection G r) (labels : G.Edge ≃ Fin m) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + {N : ℚ} (hN : 0 site p.1 p.2)) + {N : ℚ} (hN : 0 hij (congrArg Subtype.val h) + have hca : c ≠ a := fun h => hn.1 (congrArg Subtype.val h) + have hcb : c ≠ b := fun h => hn.2 (congrArg Subtype.val h) + have hs : ({a,b,c} : Finset (P.CellVisits p)).card = 3 := by simp [hab,hca.symm,hcb.symm] + have hc := Finset.card_le_univ ({a,b,c} : Finset (P.CellVisits p)) + have hp := P.cellVisits_card p + omega + +theorem crossing_graph_pair {p : ℕ × ℕ} (hp : P.IsCrossing p) {a b : Fin 4} + (h : P.graph.Adj (qmaGridPort p a) (qmaGridPort p b)) : s(a,b) ∈ qmaCrossPortPairing := by + obtain ⟨i,j,hij,hi,hj,hpair⟩ := hp + obtain ⟨k,hk,hab⟩ := P.graph_inner_pair h + have hki := P.cell_visits_third hij hi hj hk + rw [← hpair] + change s(a,b) ∈ {s(P.port i 0,P.port i 1),s(P.port j 0,P.port j 1)} + rcases hki with rfl | rfl + · rcases hab with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact Finset.mem_insert_self _ _ + · apply Finset.mem_insert.mpr + exact Or.inl Sym2.eq_swap + · rcases hab with ⟨rfl,rfl⟩ | ⟨rfl,rfl⟩ + · exact Finset.mem_insert_of_mem (Finset.mem_singleton_self _) + · apply Finset.mem_insert_of_mem + exact Finset.mem_singleton.mpr Sym2.eq_swap + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingParallel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingParallel.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0acb91a431e57d9a9184738dda9d3a6248a6ca5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingParallel.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSpectrum + +namespace OAI + +/-! Simultaneous crossing elimination, with no mixed error between distinct singlets. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +theorem qmaCrossings_effective {n r : ℕ} (site : Fin r → Fin 4 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (R : ℝ) (hR : R ≠ 0) (J K : Fin r → ℝ) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) : + (C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) - + mediatorCompression n r (qmaRoutingStars n r site (fun _ => qmaCrossingMember) + (fun e => qmaCrossingAmplitude R (J e) (K e)) * liftedMediatorInverse n r (R^2) * + qmaRoutingStars n r site (fun _ => qmaCrossingMember) + (fun e => qmaCrossingAmplitude R (J e) (K e))) = + C + ∑ e, ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 1) (site e 3)) := by + rw [qmaRoutingStars_compression,add_sub_assoc,← Finset.sum_sub_distrib] + congr 1 + apply Finset.sum_congr rfl + intro e _ + exact qmaCrossing_effective e (site e) (hsite e) R (J e) (K e) hR + +theorem qmaCrossings_bottom {n r : ℕ} (site : Fin r → Fin 4 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (R : ℝ) (hR : 0 < R) (J K : Fin r → ℝ) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon ≤ 1/4) + (hbound : ‖spinMatrixOperator ((C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ e, ∑ a, |qmaCrossingAmplitude R (J e) (K e) a| ≤ epsilon * (4*R^2)) : + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)) + (qmaRoutingStars n r site (fun _ => qmaCrossingMember) + (fun e => qmaCrossingAmplitude R (J e) (K e)))) - + sourceMatrixBottom n (C + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 1) (site e 3)))| ≤ + 16*R^2*epsilon^3 := by + have hCW : (C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e)).conjTranspose = + C + ∑ e, qmaCrossingCorrection (site e) (J e) (K e) := by + simp only [Matrix.conjTranspose_add,Matrix.conjTranspose_sum,hC, + qmaCrossingCorrection_star _ (hsite _)] + have h := qmaRoutingStars_bottom n r (sq_pos_of_pos hR) _ hCW site + (fun _ => qmaCrossingMember) (fun e => qmaCrossingAmplitude R (J e) (K e)) + hepsilon hsmall hbound + rw [qmaCrossings_effective site hsite R hR.ne' J K C] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatch.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ee3b9745dd2b4cb170236c1eb17133c2713366c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatch.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumManhattanRoute +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingGraph + +namespace OAI + +/-! A concrete square-grid subdivision of the nine-edge crossing gadget. +Its four terminals lie on the boundary with their outward directions free. -/ + +namespace ContinuumCoulomb +open scoped Classical + +def qmaCrossingPatchVertex : Fin 6 → ℕ × ℕ := ![(0,6),(6,12),(12,6),(6,0),(4,8),(8,4)] +def qmaCrossingPatchLeft : Fin 9 → Fin 6 := ![4,0,1,2,3,0,1,2,3] +def qmaCrossingPatchRight : Fin 9 → Fin 6 := ![5,4,4,5,5,1,2,3,0] +def qmaCrossingPatchPath : Fin 9 → List (ℕ × ℕ) := ![ + [(4,8),(5,8),(6,8),(7,8),(8,8),(8,7),(8,6),(8,5),(8,4)], + [(0,6),(1,6),(2,6),(2,7),(2,8),(3,8),(4,8)], + [(6,12),(6,11),(6,10),(5,10),(4,10),(4,9),(4,8)], + [(12,6),(11,6),(10,6),(10,5),(10,4),(9,4),(8,4)], + [(6,0),(6,1),(6,2),(7,2),(8,2),(8,3),(8,4)], + [(0,6),(0,7),(0,8),(0,9),(0,10),(0,11),(0,12),(1,12),(2,12),(3,12),(4,12),(5,12),(6,12)], + [(6,12),(7,12),(8,12),(9,12),(10,12),(11,12),(12,12),(12,11),(12,10),(12,9),(12,8),(12,7),(12,6)], + [(12,6),(12,5),(12,4),(12,3),(12,2),(12,1),(12,0),(11,0),(10,0),(9,0),(8,0),(7,0),(6,0)], + [(6,0),(5,0),(4,0),(3,0),(2,0),(1,0),(0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6)]] + +theorem qmaCrossingPatch_endpoints (e : Fin 9) : + (qmaCrossingPatchPath e).head? = some (qmaCrossingPatchVertex (qmaCrossingPatchLeft e)) ∧ + (qmaCrossingPatchPath e).getLast? = some (qmaCrossingPatchVertex (qmaCrossingPatchRight e)) := by + fin_cases e <;> decide + +theorem qmaCrossingPatch_chain (e : Fin 9) : + (qmaCrossingPatchPath e).IsChain + (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := by + fin_cases e <;> decide + +theorem qmaCrossingPatch_simple (e : Fin 9) : (qmaCrossingPatchPath e).Nodup := by + fin_cases e <;> decide + +theorem qmaCrossingPatch_bounded (e : Fin 9) : + ∀ p ∈ qmaCrossingPatchPath e, p.1 ≤ 12 ∧ p.2 ≤ 12 := by + fin_cases e <;> decide + +theorem qmaCrossingPatch_length (e : Fin 9) : (qmaCrossingPatchPath e).length ≤ 13 := by + fin_cases e <;> decide + +theorem qmaCrossingPatch_disjoint (e f : Fin 9) (hef : e ≠ f) : + Disjoint ((qmaCrossingPatchPath e).drop 1 |>.dropLast).toFinset + (qmaCrossingPatchPath f).toFinset := by + fin_cases e <;> fin_cases f <;> first | exact (hef rfl).elim | decide + +theorem qmaCrossingPatch_vertices : Function.Injective qmaCrossingPatchVertex := by decide + +def qmaCrossingPatchInt (p : ℕ × ℕ) : ℤ × ℤ := (p.1,p.2) +def qmaCrossingPatchPort : Fin 4 → ℤ × ℤ := ![(-1,6),(6,13),(13,6),(6,-1)] + +theorem qmaCrossingPatch_port_step (a : Fin 4) : + Int.natAbs ((qmaCrossingPatchPort a).1- + (qmaCrossingPatchInt (qmaCrossingPatchVertex (a.castLE (by decide)))).1)+ + Int.natAbs ((qmaCrossingPatchPort a).2- + (qmaCrossingPatchInt (qmaCrossingPatchVertex (a.castLE (by decide)))).2) = 1 := by + fin_cases a <;> decide + +theorem qmaCrossingPatch_port_unused (a : Fin 4) (e : Fin 9) : + qmaCrossingPatchPort a ∉ (qmaCrossingPatchPath e).map qmaCrossingPatchInt := by + fin_cases a <;> fin_cases e <;> decide + +theorem qmaCrossingPatch_interior_fresh (e : Fin 9) : + Disjoint ((qmaCrossingPatchPath e).drop 1 |>.dropLast).toFinset + (Finset.univ.image qmaCrossingPatchVertex) := by + fin_cases e <;> decide + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatchChart.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatchChart.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dea3fb477465900d9e0b8c3db09a4756f9bcdaa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPatchChart.lean @@ -0,0 +1,27 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPlacement +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPatchPhysical + +namespace OAI + +/-! Each selected gadget's six physical spins occupy exactly the six vertices +of the explicit translated planar patch. -/ + +noncomputable section +namespace ContinuumCoulomb +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +theorem crossingPosition_patchVertex (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (i : Fin P.crossingCells.card) (v : Fin 6) : + P.crossingPosition N D (qmaPatchPhysicalVertex (P.crossingSiteFin N hD) i v) = + qmaPatchTranslate (P.crossingCell i).val (qmaCrossingPatchVertex v) := by + fin_cases v <;> simp [qmaPatchPhysicalVertex,P.crossingPosition_old,P.crossingPosition_fresh, + crossingSiteFin,movedPosition_site,freshCrossingPosition,qmaInnerPort,qmaGadgetAncilla, + qmaPatchDirection,qmaPatchTranslate,qmaCrossingPatchVertex,Nat.add_assoc] + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlacement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..02b1146e4e2b2679d5a439eca526a444bc2017a9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlacement.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingMove +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortCrossingSelection + +namespace OAI + +/-! Injective physical placement for every spin after simultaneous crossing removal. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +def movedPosition (N : ℚ) (D : ℕ) (v : Fin (P.finishedGraph N D).n) : ℕ × ℕ := + qmaCrossingMove P.IsCrossing (P.finishedPosition N D v) + +theorem movedPosition_injective (N : ℚ) (D : ℕ) : Function.Injective (P.movedPosition N D) := by + intro v w h + apply (P.toEmbedding.iterate N D).position_injective + exact qmaCrossingMove_injective P.IsCrossing (P.iterate_position_kind N D v) + (P.iterate_position_kind N D w) h + +theorem movedPosition_site (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) (c : P.Crossing) (a : Fin 4) : + P.movedPosition N D (P.crossingSite N hD c a) = qmaInnerPort c.val a := by + unfold movedPosition + rw [P.crossingSite_spec,qmaCrossingMove_port,ite_eq_left (P.mem_crossingCells.mp c.property)] + +def freshCrossingPosition (i : Fin P.crossingCells.card) (b : Fin 2) : ℕ × ℕ := + qmaGadgetAncilla (P.crossingCell i).val b + +theorem freshCrossingPosition_injective : Function.Injective + (fun x : Fin P.crossingCells.card × Fin 2 => P.freshCrossingPosition x.1 x.2) := by + rintro ⟨i,a⟩ ⟨j,b⟩ h + have he : ((P.crossingCell i).val,a) = ((P.crossingCell j).val,b) := qmaGadgetAncilla_injective h + have hc : P.crossingCell i = P.crossingCell j := + Subtype.ext (congrArg (fun z : (ℕ × ℕ) × Fin 2 => z.1) he) + have hij : i = j := P.crossingCells.equivFin.symm.injective hc + have hab : a = b := congrArg (fun z : (ℕ × ℕ) × Fin 2 => z.2) he + exact Prod.ext hij hab + +theorem freshCrossingPosition_ne_old (N : ℚ) (D : ℕ) (i : Fin P.crossingCells.card) (a : Fin 2) + (v : Fin (P.finishedGraph N D).n) : P.freshCrossingPosition i a ≠ P.movedPosition N D v := + qmaGadgetAncilla_ne_moved P.IsCrossing (P.crossingCell i).val a (P.iterate_position_kind N D v) + +def crossingPosition (N : ℚ) (D : ℕ) : + Fin ((P.finishedGraph N D).n+P.crossingCells.card*2) → ℕ × ℕ := + fun v => Sum.elim (P.movedPosition N D) (fun x => P.freshCrossingPosition x.1 x.2) + ((vertexEquiv (P.finishedGraph N D).n P.crossingCells.card).symm v) + +@[simp] theorem crossingPosition_old (N : ℚ) (D : ℕ) (v : Fin (P.finishedGraph N D).n) : + P.crossingPosition N D (old _ _ v) = P.movedPosition N D v := by + simp [crossingPosition,old] + +@[simp] theorem crossingPosition_fresh (N : ℚ) (D : ℕ) (i : Fin P.crossingCells.card) (a : Fin 2) : + P.crossingPosition N D (fresh _ _ i a) = P.freshCrossingPosition i a := by + simp [crossingPosition,fresh] + +theorem crossingPosition_injective (N : ℚ) (D : ℕ) : Function.Injective (P.crossingPosition N D) := by + intro x y h + obtain ⟨x,rfl⟩ := (vertexEquiv (P.finishedGraph N D).n P.crossingCells.card).surjective x + obtain ⟨y,rfl⟩ := (vertexEquiv (P.finishedGraph N D).n P.crossingCells.card).surjective y + simp only [crossingPosition,Equiv.symm_apply_apply] at h + apply (vertexEquiv _ _).congr_arg + cases x with + | inl x => + cases y with + | inl y => exact congrArg Sum.inl (P.movedPosition_injective N D h) + | inr y => exact (P.freshCrossingPosition_ne_old N D y.1 y.2 x h.symm).elim + | inr x => + cases y with + | inl y => exact (P.freshCrossingPosition_ne_old N D x.1 x.2 y h).elim + | inr y => exact congrArg Sum.inr (P.freshCrossingPosition_injective h) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlanarRoutes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlanarRoutes.lean new file mode 100644 index 0000000000000000000000000000000000000000..430a1f29474e393e0f61519aca13868b309b2283 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPlanarRoutes.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPhysicalCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarListData +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarRouteRealization + +namespace OAI + +/-! The actual merged crossing output has a bounded, simple planar route family. +Each route uses at most twenty nearest-neighbor grid steps. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +def crossingPlanarList (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) : + QMAPlanarListData (P.crossingOutput N hD).merge where + position := P.crossingPosition N D + position_injective := P.crossingPosition_injective N D + path e := (P.mergedOutputRoute N hD havoid e).path + length e := (P.mergedOutputRoute N hD havoid e).length_bounds.1 + first e := (P.mergedOutputRoute N hD havoid e).endpoints.1.trans + (congrArg some (P.mergedOutputRoute_spec N hD havoid e).2.2.1) + last e := (P.mergedOutputRoute N hD havoid e).endpoints.2.trans + (congrArg some (P.mergedOutputRoute_spec N hD havoid e).2.2.2) + simple e := (P.mergedOutputRoute N hD havoid e).simple + (P.mergedOutputRoute_spec N hD havoid e).2.1 + step e := (P.mergedOutputRoute N hD havoid e).chain + (P.mergedOutputRoute_spec N hD havoid e).2.1 + positive e z hz := by + have hs := P.mergedOutputRoute_spec N hD havoid e + apply (P.mergedOutputRoute N hD havoid e).path_positive ?_ ?_ hz + · rw [hs.2.2.1] + exact P.crossingPosition_positive hpositive N D _ + · rw [hs.2.2.2] + exact P.crossingPosition_positive hpositive N D _ + avoids e v := P.mergedOutputRoute_avoids N hD havoid e v + disjoint e f hef := P.mergedOutputRoute_disjoint N hD havoid e f hef + +def crossingPlanarRoute (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) := + (P.crossingPlanarList N hD havoid hpositive).toRoute + +theorem crossingPlanarRoute_length (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) + (e : (P.crossingOutput N hD).merge.Edge) : + (P.crossingPlanarRoute N hD havoid hpositive).length e ≤ 20 := by + change (P.mergedOutputRoute N hD havoid e).path.length-1 ≤ 20 + have h := (P.mergedOutputRoute N hD havoid e).length_bounds.2 + omega + +theorem crossingPlanarList_path_bounded (N : ℚ) {D X Y : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hsource : ∀ v, (P.position v).1 < X ∧ (P.position v).2 < Y) + (hpath : ∀ e k, k ≤ P.length e → (P.point e k).1 < X ∧ (P.point e k).2 < Y) + (e : (P.crossingOutput N hD).merge.Edge) {z : ℕ × ℕ} + (hz : z ∈ (P.mergedOutputRoute N hD havoid e).path) : z.1 < 32*X ∧ z.2 < 32*Y := by + have hs := P.mergedOutputRoute_spec N hD havoid e + apply (P.mergedOutputRoute N hD havoid e).path_bounded ?_ ?_ hz + · rw [hs.2.2.1] + exact P.crossingPosition_bounded hsource hpath N D _ + · rw [hs.2.2.2] + exact P.crossingPosition_bounded hsource hpath N D _ + +theorem crossingPlanarRoute_bounded (N : ℚ) {D X Y : ℕ} (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) + (hsource : ∀ v, (P.position v).1 < X ∧ (P.position v).2 < Y) + (hpath : ∀ e k, k ≤ P.length e → (P.point e k).1 < X ∧ (P.point e k).2 < Y) : + (P.crossingPlanarRoute N hD havoid hpositive).Bounded (32*X) (32*Y) := by + refine ⟨P.crossingPosition_bounded hsource hpath N D,?_⟩ + intro e k hk + let L := P.crossingPlanarList N hD havoid hpositive + change (L.point e k).1 < 32*X ∧ (L.point e k).2 < 32*Y + apply P.crossingPlanarList_path_bounded N hD havoid hsource hpath e + have hlen := L.length e + exact L.point_mem e (by change k ≤ (L.path e).length-1 at hk; omega) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fd6c13f24d8437d75f50b900e483a761f17465a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPorts.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedSharedEdge + +namespace OAI + +/-! Every nonvertex meeting has four distinct lattice ports, two on each route. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaPath_interior_ports {u v z : ℕ × ℕ} (P : qmaSquareGrid.Path u v) + (hz : z ∈ P.val.support) (hzu : z ≠ u) (hzv : z ≠ v) : + ∃ a b, a ≠ b ∧ s(z,a) ∈ P.val.edges ∧ s(z,b) ∈ P.val.edges := by + obtain ⟨k,hk,hkle⟩ := SimpleGraph.Walk.mem_support_iff_exists_getVert.mp hz + have hk0 : 0 < k := by + by_contra h + have he : k = 0 := by omega + exact hzu (hk.symm.trans (by simp [he])) + have hkL : k < P.val.length := by + by_contra h + have he : k = P.val.length := by omega + exact hzv (hk.symm.trans (by simp [he])) + refine ⟨P.val.getVert (k-1),P.val.getVert (k+1),?_,?_,?_⟩ + · intro he + have hn := P.property.getVert_injOn (show k-1 ≤ P.val.length by omega) + (show k+1 ≤ P.val.length by omega) he + omega + · apply (P.val.mk_mem_edges_iff_exists).mpr + refine ⟨k-1,by omega,?_⟩ + rw [show k-1+1 = k by omega,hk] + exact Sym2.eq_swap + · apply (P.val.mk_mem_edges_iff_exists).mpr + exact ⟨k,hkL,by rw [hk]⟩ + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem buffered_crossing_ports (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (hv : ∀ v, z ≠ M.placedVertex v) + (he : z ∈ (M.bufferedPath hd e).val.support) + (hf : z ∈ (M.bufferedPath hd f).val.support) : + ∃ port : Fin 4 → ℕ × ℕ, Function.Injective port ∧ + (∀ i, qmaSquareGrid.Adj z (port i)) ∧ + s(z,port 0) ∈ (M.bufferedPath hd e).val.edges ∧ + s(z,port 1) ∈ (M.bufferedPath hd e).val.edges ∧ + s(z,port 2) ∈ (M.bufferedPath hd f).val.edges ∧ + s(z,port 3) ∈ (M.bufferedPath hd f).val.edges := by + obtain ⟨a,b,hab,hea,heb⟩ := qmaPath_interior_ports (M.bufferedPath hd e) he (hv _) (hv _) + obtain ⟨c,d,hcd,hfc,hfd⟩ := qmaPath_interior_ports (M.bufferedPath hd f) hf (hv _) (hv _) + have hac : a ≠ c := by + intro h + exact M.bufferedPath_no_shared_edge hA hd hef hea (h.symm ▸ hfc) + have had : a ≠ d := by + intro h + exact M.bufferedPath_no_shared_edge hA hd hef hea (h.symm ▸ hfd) + have hbc : b ≠ c := by + intro h + exact M.bufferedPath_no_shared_edge hA hd hef heb (h.symm ▸ hfc) + have hbd : b ≠ d := by + intro h + exact M.bufferedPath_no_shared_edge hA hd hef heb (h.symm ▸ hfd) + refine ⟨![a,b,c,d],?_,?_,?_,?_,?_,?_⟩ + · intro i j hij + fin_cases i <;> fin_cases j <;> simp_all + · intro i + fin_cases i + · exact (M.bufferedPath hd e).val.adj_of_mem_edges hea + · exact (M.bufferedPath hd e).val.adj_of_mem_edges heb + · exact (M.bufferedPath hd f).val.adj_of_mem_edges hfc + · exact (M.bufferedPath hd f).val.adj_of_mem_edges hfd + · exact hea + · exact heb + · exact hfc + · exact hfd + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a023c30413f88b76958d4ef5f818a39374b216b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionProgram.lean @@ -0,0 +1,164 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPathProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFiniteMembership +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPlacement +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortChainProgram + +namespace OAI + +/-! Literal physical coordinates after crossing removal. Only ports in the +computed crossing cells move; the two fresh spins use fixed local coordinates. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingPositionProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode +open scoped Classical + +abbrev Input := List Pair × Pair +def inputCode : Input → List Bool := prodCode (listCode pairCode) pairCode +def cell (z : Pair) : Pair := (z.1/32,z.2/32) +def move (x : Input) : Pair := qmaCrossingMove (fun p => p ∈ x.1) x.2 + +noncomputable opaque cellProgram : Procedure pairCode pairCode cell := by + let c := Procedure.constant pairCode Nat.bits 32 + exact (Procedure.binaryDiv.comp ((Procedure.first Nat.bits Nat.bits).pair c)).pair + (Procedure.binaryDiv.comp ((Procedure.second Nat.bits Nat.bits).pair c)) + +noncomputable opaque innerProgram (a : Fin 4) : Procedure pairCode pairCode + (fun p => qmaInnerPort p a) := by + refine ((QuantumCellPathProgram.translateProgram).comp + ((Procedure.identity pairCode).pair + (Procedure.constant pairCode pairCode (qmaInnerPort (0,0) a)))).congrFun ?_ + intro p + fin_cases a <;> simp [qmaCellTranslate,qmaInnerPort] + +noncomputable opaque ancillaProgram (a : Fin 2) : Procedure pairCode pairCode + (fun p => qmaGadgetAncilla p a) := by + refine ((QuantumCellPathProgram.translateProgram).comp + ((Procedure.identity pairCode).pair + (Procedure.constant pairCode pairCode (qmaGadgetAncilla (0,0) a)))).congrFun ?_ + intro p + fin_cases a <;> simp [qmaCellTranslate,qmaGadgetAncilla] + +noncomputable opaque chosenInnerProgram : Procedure pairCode pairCode + (fun z => qmaInnerPort (cell z) (qmaPortIndex z)) := by + let c := Procedure.constant pairCode Nat.bits 32 + let rx := Procedure.binaryMod.comp ((Procedure.first Nat.bits Nat.bits).pair c) + let ry := Procedure.binaryMod.comp ((Procedure.second Nat.bits Nat.bits).pair c) + let eq (p : Procedure pairCode Nat.bits (fun z => z.1%32)) (n : ℕ) := + Procedure.binaryEq.comp (p.pair (Procedure.constant pairCode Nat.bits n)) + let x23 := eq rx 23 + let y23 := Procedure.binaryEq.comp (ry.pair (Procedure.constant pairCode Nat.bits 23)) + let x9 := eq rx 9 + exact (Procedure.conditional x23 ((innerProgram 0).comp cellProgram) + (Procedure.conditional y23 ((innerProgram 1).comp cellProgram) + (Procedure.conditional x9 ((innerProgram 2).comp cellProgram) + ((innerProgram 3).comp cellProgram)))).congrFun (by + intro z + simp only [Function.comp_apply,qmaPortIndex,decide_eq_true_eq] + split_ifs <;> rfl) + +noncomputable opaque moveProgram : Procedure inputCode pairCode move := by + let cs := Procedure.first (listCode pairCode) pairCode + let z := Procedure.second (listCode pairCode) pairCode + let p := cellProgram.comp z + let memp := QuantumFiniteMembership.pairMemberProgram.comp (p.pair cs) + let center := QuantumPortChainProgram.centerProgram.comp p + let isCenter := QuantumFiniteMembership.pairEqProgram.comp (z.pair center) + exact (Procedure.conditional + (Procedure.boolAnd.comp (memp.pair (Procedure.boolNot.comp isCenter))) + (chosenInnerProgram.comp z) z).congrFun (by + intro x + simp only [Function.comp_apply,move,qmaCrossingMove,cell,Bool.and_eq_true,decide_eq_true_eq, + Bool.not_eq_true_eq_eq_false,decide_eq_false_iff_not]) + +def moved (x : List Pair × List Pair) : List Pair := x.2.map (fun z => move (x.1,z)) +def fresh (cs : List Pair) : List Pair := + (cs.map (fun p => [qmaGadgetAncilla p 0,qmaGadgetAncilla p 1])).flatten +def positions (x : List Pair × List Pair) : List Pair := moved x++fresh x.1 + +noncomputable opaque movedProgram : + Procedure (prodCode (listCode pairCode) (listCode pairCode)) (listCode pairCode) moved := + Procedure.listMapWith (f := fun cs z => move (cs,z)) (0,0) (0,0) moveProgram + +noncomputable opaque freshProgram : Procedure (listCode pairCode) (listCode pairCode) fresh := by + let pair := (Procedure.listCons pairCode).comp ((ancillaProgram 0).pair + ((Procedure.listCons pairCode).comp ((ancillaProgram 1).pair + (Procedure.constant pairCode (listCode pairCode) [])))) + exact (QuantumRawExchange.flattenProgram pairCode (0,0)).comp + (Procedure.listMap (0,0) [] pair) + +noncomputable opaque positionsProgram : + Procedure (prodCode (listCode pairCode) (listCode pairCode)) (listCode pairCode) positions := + (Procedure.listAppend pairCode (0,0)).comp (movedProgram.pair + (freshProgram.comp (Procedure.first (listCode pairCode) (listCode pairCode)))) + +theorem move_eq {cs : List Pair} {cross : Pair → Prop} [DecidablePred cross] + (hc : ∀ p, p ∈ cs ↔ cross p) (z : Pair) : + move (cs,z)=qmaCrossingMove cross z := by + simp only [move,qmaCrossingMove,hc] + +theorem moved_ofFn {cs : List Pair} {cross : Pair → Prop} [DecidablePred cross] + (hc : ∀ p, p ∈ cs ↔ cross p) {n : ℕ} (pos : Fin n → Pair) : + moved (cs,List.ofFn pos)=List.ofFn (fun v => qmaCrossingMove cross (pos v)) := by + simp only [moved,List.map_ofFn,Function.comp_def,move_eq hc] + +theorem fresh_length (cs : List Pair) : (fresh cs).length=2*cs.length := by + simp only [fresh,List.length_flatten,List.map_map,Function.comp_def,List.length_cons, + List.length_nil,List.map_const',List.sum_replicate,nsmul_eq_mul,Nat.mul_comm] + norm_cast + +theorem positions_length (x : List Pair × List Pair) : + (positions x).length=x.2.length+2*x.1.length := by + simp only [positions,List.length_append,moved,List.length_map,fresh_length] + +theorem moved_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) (D : ℕ) (cs : List Pair) (hc : ∀ p, p ∈ cs ↔ P.IsCrossing p) : + moved (cs,List.ofFn (P.finishedPosition N D))=List.ofFn (P.movedPosition N D) := + moved_ofFn hc (P.finishedPosition N D) + +theorem fresh_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) : + fresh (List.ofFn (fun i => (P.crossingCell i).val))= + (List.ofFn fun i => [P.freshCrossingPosition i 0,P.freshCrossingPosition i 1]).flatten := by + simp only [fresh,List.map_ofFn,Function.comp_def,QMAPortRouteData.freshCrossingPosition] + +theorem crossingPosition_list {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) (D : ℕ) : + List.ofFn (P.crossingPosition N D) = List.ofFn (P.movedPosition N D)++ + (List.ofFn fun i => [P.freshCrossingPosition i 0,P.freshCrossingPosition i 1]).flatten := by + rw [List.ofFn_add] + apply congrArg₂ (· ++ ·) + · apply congrArg List.ofFn + funext v + exact P.crossingPosition_old N D v + · rw [List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + have hf (a : Fin 2) : + P.crossingPosition N D + ((⟨i.val*2+a.val,by omega⟩ : Fin (P.crossingCells.card*2)).natAdd + (P.finishedGraph N D).n) = P.freshCrossingPosition i a := by + have he : + ((⟨i.val*2+a.val,by omega⟩ : Fin (P.crossingCells.card*2)).natAdd + (P.finishedGraph N D).n) = MediatorGraph.fresh _ _ i a := by + apply Fin.ext + change (P.finishedGraph N D).n+(i.val*2+a.val) = + (P.finishedGraph N D).n+(a.val+2*i.val) + omega + rw [he,P.crossingPosition_fresh] + simpa only [List.ofFn_succ,List.ofFn_zero,List.cons_append,List.nil_append, + Fin.succ_zero_eq_one] using + congrArg List.ofFn (funext hf) + +theorem positions_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) (D : ℕ) (cs : List Pair) + (hcs : cs=List.ofFn (fun i => (P.crossingCell i).val)) + (hc : ∀ p, p ∈ cs ↔ P.IsCrossing p) : + positions (cs,List.ofFn (P.finishedPosition N D))=List.ofFn (P.crossingPosition N D) := by + rw [positions,moved_actual P N D cs hc,hcs,fresh_actual,crossingPosition_list] + +end ContinuumCoulomb.QuantumCrossingPositionProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc6d10939e979cd3ec43247294640a27b08a3560 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingPositionRelabel.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingPositionProgram + +namespace OAI + +/-! Reordering the port vertices or crossing cells reorders the output +positions by a finite equivalence, preserving their injectivity. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingPositionProgram +open MediatorGraph QuantumRouteCode +open scoped Classical + +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) (D : ℕ) {n r : ℕ} + (σ : Fin n ≃ Fin (P.finishedGraph N D).n) + (τ : Fin r ≃ Fin P.crossingCells.card) + +def extend : Fin (n+r*2) ≃ Fin ((P.finishedGraph N D).n+P.crossingCells.card*2) := + ((vertexEquiv n r).symm.trans (Equiv.sumCongr σ + (Equiv.prodCongr τ (Equiv.refl (Fin 2))))).trans (vertexEquiv _ _) + +theorem extend_old (v : Fin n) : extend P N D σ τ (old n r v)=old _ _ (σ v) := by + simp [extend,old] + +theorem extend_fresh (i : Fin r) (a : Fin 2) : + extend P N D σ τ (MediatorGraph.fresh n r i a)=MediatorGraph.fresh _ _ (τ i) a := by + simp [extend,MediatorGraph.fresh] + +theorem reordered_cells_mem (p : Pair) : + p ∈ List.ofFn (fun i => (P.crossingCell (τ i)).val) ↔ P.IsCrossing p := by + rw [List.mem_ofFn] + constructor + · rintro ⟨i,rfl⟩ + exact P.mem_crossingCells.mp (P.crossingCell (τ i)).property + · intro hp + let c : P.Crossing := ⟨p,P.mem_crossingCells.mpr hp⟩ + refine ⟨τ.symm (P.crossingCells.equivFin c),?_⟩ + simp only [Equiv.apply_symm_apply,QMAPortRouteData.crossingCell, + Equiv.symm_apply_apply] + rfl + +theorem positions_reordered : + positions (List.ofFn (fun i => (P.crossingCell (τ i)).val), + List.ofFn (fun v => P.finishedPosition N D (σ v))) = + List.ofFn (fun v => P.crossingPosition N D (extend P N D σ τ v)) := by + rw [positions,moved_ofFn (reordered_cells_mem P τ)] + rw [List.ofFn_add] + apply congrArg₂ (· ++ ·) + · apply congrArg List.ofFn + funext v + change qmaCrossingMove P.IsCrossing (P.finishedPosition N D (σ v))= + P.crossingPosition N D (extend P N D σ τ (old n r v)) + rw [extend_old,P.crossingPosition_old] + rfl + · rw [fresh,List.map_ofFn,List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + have hf (a : Fin 2) : + P.crossingPosition N D (extend P N D σ τ + ((⟨i.val*2+a.val,by omega⟩ : Fin (r*2)).natAdd n)) = + qmaGadgetAncilla (P.crossingCell (τ i)).val a := by + have he : ((⟨i.val*2+a.val,by omega⟩ : Fin (r*2)).natAdd n)=MediatorGraph.fresh n r i a := by + apply Fin.ext + change n+(i.val*2+a.val)=n+(a.val+2*i.val) + omega + rw [he,extend_fresh,P.crossingPosition_fresh] + rfl + simp only [hf,List.ofFn_succ,List.ofFn_zero,Fin.succ_zero_eq_one] + rfl + +theorem output_injective : Function.Injective + (fun v => P.crossingPosition N D (extend P N D σ τ v)) := + (P.crossingPosition_injective N D).comp (extend P N D σ τ).injective + +end ContinuumCoulomb.QuantumCrossingPositionProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingRetention.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..f488825ac9dde1688abaff7a6f503f0ddccf70f9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingRetention.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectCorrectness + +namespace OAI + +/-! Exact retained-edge semantics of the finite crossing scan. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open QuantumCrossingListBlock +open scoped BigOperators Classical + +theorem pairs_ofFn_mem {r : ℕ} (ss : Fin r → Sites) (p : QuantumRouteCode.Pair) : + p ∈ pairs (List.ofFn ss) ↔ ∃ i a, terminalPair a (ss i)=p := by + rw [pairs,List.map_ofFn] + constructor + · intro h + obtain ⟨xs,hxs,hp⟩ := List.mem_flatten.mp h + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hxs + rcases List.mem_cons.mp hp with hp | hp + · exact ⟨i,0,hp.symm⟩ + · exact ⟨i,1,(List.mem_singleton.mp hp).symm⟩ + · rintro ⟨i,a,rfl⟩ + apply List.mem_flatten.mpr + refine ⟨_,List.mem_ofFn.mpr ⟨i,rfl⟩,?_⟩ + fin_cases a <;> simp + +theorem keep_selected {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + (e : G.Edge) : + keep (pairs (List.ofFn (encodedSites S.site)), + ((G.left e).val,(G.right e).val,G.weight e))=decide (S.tag e=none) := by + apply Bool.eq_iff_iff.mpr + rw [decide_eq_true_eq] + change (!(pairs (List.ofFn (encodedSites S.site))).any + (fun p => hits (((G.left e).val,(G.right e).val,G.weight e),p)))=true ↔ _ + rw [Bool.not_eq_true_eq_eq_false,List.any_eq_false] + constructor + · intro h + cases ht : S.tag e with + | none => rfl + | some p => + have hm := (pairs_ofFn_mem (encodedSites S.site) + (terminalPair p.2 (encodedSites S.site p.1))).mpr ⟨p.1,p.2,rfl⟩ + have hn := h _ hm + rw [hits_selected S htag,ht] at hn + exact (hn (by simp)).elim + · intro ht p hp + obtain ⟨i,a,rfl⟩ := (pairs_ofFn_mem (encodedSites S.site) p).mp hp + rw [hits_selected S htag,ht] + simp + +private theorem filter_matrix (n : ℕ) (ps : List QuantumRouteCode.Pair) + (es : List MediatorListProgram.Bond) : + SourceBondLists.matrix n (retained (ps,es)) = + (es.map (fun e => if keep (ps,e) then SourceBondLists.bondMatrix n e else 0)).sum := by + unfold retained + induction es with + | nil => rfl + | cons e es ih => + change (List.map (SourceBondLists.bondMatrix n) + (List.filter (fun e => keep (ps,e)) (e::es))).sum = _ + change (List.map (SourceBondLists.bondMatrix n) + (List.filter (fun e => keep (ps,e)) es)).sum = _ at ih + cases h : keep (ps,e) <;> simp only [List.filter_cons,h,Bool.false_eq_true, + ite_false,ite_true,List.map_cons,List.sum_cons,zero_add] <;> rw [ih] + +theorem retained_matrix {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + {m : ℕ} (labels : G.Edge ≃ Fin m) : + SourceBondLists.matrix G.n + (retained (pairs (List.ofFn (encodedSites S.site)),QuantumListGraph.packed G labels))+ + (G.constant:ℂ) • 1 = + qmaExchangeMatrix S.retained.left S.retained.right + (fun e => (S.retained.weight e:ℝ)) S.retained.constant := by + rw [filter_matrix] + have hb (e : G.Edge) : SourceBondLists.bondMatrix G.n + ((G.left e).val,(G.right e).val,G.weight e)= + (G.weight e:ℂ) • sourceHeisenbergMatrix G.n (G.left e) (G.right e) := by + rw [SourceBondLists.bondMatrix,dite_eq_left ⟨(G.left e).isLt,(G.right e).isLt⟩] + simp only [QuantumListGraph.packed,List.map_ofFn,List.sum_ofFn,Function.comp_apply, + keep_selected S htag,decide_eq_true_eq,hb] + have hs := labels.symm.sum_comp (fun e => if S.tag e=none then + (G.weight e:ℂ) • sourceHeisenbergMatrix G.n (G.left e) (G.right e) else 0) + rw [hs,← qmaSumSubtypePredicate] + rfl + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingScaleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingScaleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa6d3c93a746f591497b9aec626b7d4b08131a5c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingScaleProgram.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalCrossing +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathScaleProgram + +namespace OAI + +/-! Exact rational scale for a simultaneous crossing layer, computed from +its retained coefficients and the two crossing coefficients at each cell. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingScaleProgram +open ExactQuantumFactoring.BitStackProgram +open scoped BigOperators Classical + +abbrev Pair := ℚ × ℚ +def pairCode : Pair → List Bool := prodCode ratCode ratCode +abbrev Input := (ℚ × ℚ) × (List ℚ × List Pair) +def inputCode : Input → List Bool := + prodCode pairCode (prodCode (listCode ratCode) (listCode pairCode)) +def linearCost (p : Pair) : ℚ := 1+|p.1|+|p.2| +def squareCost (p : Pair) : ℚ := (linearCost p)^2 +def base (x : Input) : ℚ := 3*(x.2.1.map abs).sum+|x.1.2| +def active (x : Input) : ℚ := 6*(x.2.2.map linearCost).sum +def correction (x : Input) : ℚ := base x+12*(x.2.2.map squareCost).sum +def value (x : Input) : ℚ := + 16*(active x+correction x+1)^3*x.1.1+4*(active x+correction x+1)+1 + +noncomputable opaque linearProgram : Procedure pairCode ratCode linearCost := + Procedure.ratAdd.comp ((Procedure.ratAdd.comp + ((Procedure.constant pairCode ratCode 1).pair + (MediatorProgram.absoluteProgram.comp (Procedure.first ratCode ratCode)))).pair + (MediatorProgram.absoluteProgram.comp (Procedure.second ratCode ratCode))) +noncomputable opaque squareProgram : Procedure pairCode ratCode squareCost := + QuantumRoutingCode.squareProgram linearProgram +noncomputable def sumMapProgram {f : Pair → ℚ} (p : Procedure pairCode ratCode f) : + Procedure (listCode pairCode) ratCode (fun xs => (xs.map f).sum) := + RationalSumProgram.sumProgram.comp (Procedure.listMap (0,0) 0 p) +noncomputable opaque program : Procedure inputCode ratCode value := by + let params := Procedure.first pairCode (prodCode (listCode ratCode) (listCode pairCode)) + let lists := Procedure.second pairCode (prodCode (listCode ratCode) (listCode pairCode)) + let n := (Procedure.first ratCode ratCode).comp params + let c := (Procedure.second ratCode ratCode).comp params + let retained := (Procedure.first (listCode ratCode) (listCode pairCode)).comp lists + let selected := (Procedure.second (listCode ratCode) (listCode pairCode)).comp lists + let b := Procedure.ratAdd.comp + ((Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 3).pair + ((QuantumPathScaleProgram.sumMapProgram MediatorProgram.absoluteProgram).comp retained))).pair + (MediatorProgram.absoluteProgram.comp c)) + let a := Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 6).pair + ((sumMapProgram linearProgram).comp selected)) + let d := Procedure.ratAdd.comp (b.pair + (Procedure.ratMul.comp ((Procedure.constant inputCode ratCode 12).pair + ((sumMapProgram squareProgram).comp selected)))) + exact QuantumRoutingCode.scaleProgram.comp (a.pair (d.pair n)) + +def actualInput {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : Input := + ((N,C.base.constant),(List.ofFn (fun i => C.base.weight (labels.symm i)), + List.ofFn (fun i => (C.J i,C.K i)))) + +theorem value_actual {r : ℕ} (C : QMARationalCrossingLayer r) (N : ℚ) {m : ℕ} + (labels : C.base.Edge ≃ Fin m) : value (actualInput C N labels)=C.scale N := by + simp only [value,base,active,correction,actualInput,List.map_ofFn,List.sum_ofFn, + Function.comp_apply,linearCost,squareCost,QMARationalCrossingLayer.scale] + rw [labels.symm.sum_comp (fun e => |C.base.weight e|)] + +end ContinuumCoulomb.QuantumCrossingScaleProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6465170449e12b95aa5892f0e15838de41f48fb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectCorrectness.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectionUnique +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListActual + +namespace OAI + +/-! The finite endpoint scans recover the actual selected rational couplings. +No matrix or energy comparison is assumed by this source-data bridge. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open QuantumCrossingListBlock +open scoped BigOperators Classical + +def encodedSites {n r : ℕ} (site : Fin r → Fin 4 → Fin n) (i : Fin r) : Sites := + (((site i 0).val,(site i 1).val),((site i 2).val,(site i 3).val)) + +theorem terminalPair_encoded {n r : ℕ} (site : Fin r → Fin 4 → Fin n) + (i : Fin r) (a : Fin 2) : + terminalPair a (encodedSites site i)= + ((site i (if a=0 then 0 else 1)).val,(site i (if a=0 then 2 else 3)).val) := by + fin_cases a <;> rfl + +theorem hits_selected {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + (e : G.Edge) (i : Fin r) (a : Fin 2) : + hits (((G.left e).val,(G.right e).val,G.weight e),terminalPair a (encodedSites S.site i)) = + decide (S.tag e=some (i,a)) := by + apply Bool.eq_iff_iff.mpr + rw [hits_iff,decide_eq_true_eq,htag,terminalPair_encoded] + simp only [QMARationalExchangeGraph.CrossingMatch,Prod.mk.injEq,Fin.ext_iff] + tauto + +theorem weight_selected {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + {m : ℕ} (labels : G.Edge ≃ Fin m) (i : Fin r) (a : Fin 2) : + weight (QuantumListGraph.packed G labels,terminalPair a (encodedSites S.site i))= + S.weight (i,a) := by + simp only [weight,QuantumListGraph.packed,List.map_ofFn,List.sum_ofFn, + Function.comp_apply,contribution,hits_selected S htag,decide_eq_true_eq] + unfold QMARationalCrossingSelection.weight + rw [qmaSumSubtypePredicate] + exact labels.symm.sum_comp (fun e => if S.tag e=some (i,a) then G.weight e else 0) + +theorem crossings_selected {G : QMARationalExchangeGraph} {r : ℕ} + (S : QMARationalCrossingSelection G r) + (htag : ∀ e i a, S.tag e=some (i,a) ↔ G.CrossingMatch S.site e (i,a)) + {m : ℕ} (labels : G.Edge ≃ Fin m) : + crossings (QuantumListGraph.packed G labels,List.ofFn (encodedSites S.site))= + List.ofFn (QuantumCrossingListLayer.actualCrossing S.layer) := by + simp only [crossings,List.map_ofFn] + apply congrArg List.ofFn + funext i + apply Prod.ext + · exact Prod.ext (weight_selected S htag labels i 0) (weight_selected S htag labels i 1) + · rfl + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectFromSites.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectFromSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fc8541faaf740940fd62d2fe68dea713fa48f6b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectFromSites.lean @@ -0,0 +1,56 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelection + +namespace OAI + +/-! The crossing selector is constructed from physical terminal indices. Every +unselected edge avoids every selected pair; no matrix identity is assumed. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMARationalExchangeGraph +variable (G : QMARationalExchangeGraph) {r : ℕ} (site : Fin r → Fin 4 → Fin G.n) + +def CrossingMatch (e : G.Edge) (p : Fin r × Fin 2) : Prop := + (G.left e = site p.1 (if p.2 = 0 then 0 else 1) ∧ + G.right e = site p.1 (if p.2 = 0 then 2 else 3)) ∨ + (G.left e = site p.1 (if p.2 = 0 then 2 else 3) ∧ + G.right e = site p.1 (if p.2 = 0 then 0 else 1)) + +def crossingTag (e : G.Edge) : Option (Fin r × Fin 2) := + if h : ∃ p, G.CrossingMatch site e p then some (Classical.choose h) else none + +theorem crossingTag_some {e : G.Edge} {p : Fin r × Fin 2} (he : G.crossingTag site e = some p) : + G.CrossingMatch site e p := by + unfold crossingTag at he + split_ifs at he with h + have hp : Classical.choose h = p := Option.some.inj he + exact hp ▸ Classical.choose_spec h + +theorem crossingTag_none {e : G.Edge} : G.crossingTag site e = none ↔ ∀ p, ¬G.CrossingMatch site e p := by + constructor + · intro h p hp + unfold crossingTag at h + split_ifs at h with hx + exact hx ⟨p,hp⟩ + · intro h + have hn : ¬∃ p, G.CrossingMatch site e p := by simpa only [not_exists] using h + simp only [crossingTag,hn,dite_false] + +def crossingSelection (hinj : ∀ i, Function.Injective (site i)) : QMARationalCrossingSelection G r where + site := site + injective := hinj + tag := G.crossingTag site + tagged := fun _ _ _ he => G.crossingTag_some site he + +theorem retained_no_crossing (hinj : ∀ i, Function.Injective (site i)) + (e : (G.crossingSelection site hinj).retained.Edge) (p : Fin r × Fin 2) : + ¬G.CrossingMatch site e.val p := + (G.crossingTag_none site).mp e.property p + +end QMARationalExchangeGraph +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9916bf6e1c9d9bdd7a4a4b9209c731e871d6b6f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectProgram.lean @@ -0,0 +1,166 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingListLayer +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFiniteMembership + +namespace OAI + +/-! Select crossing interactions directly from the finite bond tape. +Both orientations contribute to each rational coupling; every other bond is +retained. All scans are literal polynomial programs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSelectProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram QuantumRouteCode +open QuantumCrossingListBlock + +def hits (x : Bond × Pair) : Bool := + decide ((x.1.1,x.1.2.1)=x.2) || decide ((x.1.2.1,x.1.1)=x.2) +def terminalPair (a : Fin 2) (s : Sites) : Pair := + (site s (if a=0 then 0 else 1),site s (if a=0 then 2 else 3)) +def pairs (ss : List Sites) : List Pair := + (ss.map (fun s => [terminalPair 0 s,terminalPair 1 s])).flatten +def contribution (x : Bond × Pair) : ℚ := if hits x then x.1.2.2 else 0 +def weight (x : List Bond × Pair) : ℚ := (x.1.map (fun e => contribution (e,x.2))).sum +def keep (x : List Pair × Bond) : Bool := !(x.1.any (fun p => hits (x.2,p))) +def retained (x : List Pair × List Bond) : List Bond := x.2.filter (fun e => keep (x.1,e)) +def crossing (x : List Bond × Sites) : Crossing := + ((weight (x.1,terminalPair 0 x.2),weight (x.1,terminalPair 1 x.2)),x.2) +def crossings (x : List Bond × List Sites) : List Crossing := x.2.map (fun s => crossing (x.1,s)) + +noncomputable opaque hitsProgram : Procedure (prodCode bondCode pairCode) Procedure.boolCode hits := by + let e := Procedure.first bondCode pairCode + let p := Procedure.second bondCode pairCode + let l := (Procedure.first Nat.bits (prodCode Nat.bits ratCode)).comp e + let r := (Procedure.first Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp e) + exact Procedure.boolOr.comp + ((QuantumFiniteMembership.pairEqProgram.comp ((l.pair r).pair p)).pair + (QuantumFiniteMembership.pairEqProgram.comp ((r.pair l).pair p))) + +noncomputable opaque terminalProgram (a : Fin 2) : Procedure sitesCode pairCode (terminalPair a) := by + let input : Procedure sitesCode QuantumCrossingListBlock.inputCode + (fun s => ((0,0),0,(0,0),s)) := + (Procedure.constant sitesCode parametersCode (0,0)).pair + ((Procedure.constant sitesCode unaryCode 0).pair + ((Procedure.constant sitesCode (prodCode ratCode ratCode) (0,0)).pair + (Procedure.identity sitesCode))) + exact ((siteProgram (if a=0 then 0 else 1)).comp input).pair + ((siteProgram (if a=0 then 2 else 3)).comp input) + +noncomputable opaque pairsProgram : Procedure (listCode sitesCode) (listCode pairCode) pairs := by + let entry := (Procedure.listCons pairCode).comp ((terminalProgram 0).pair + ((Procedure.listCons pairCode).comp ((terminalProgram 1).pair + (Procedure.constant sitesCode (listCode pairCode) [])))) + exact (QuantumRawExchange.flattenProgram pairCode (0,0)).comp + (Procedure.listMap ((0,0),(0,0)) [] entry) + +noncomputable opaque contributionProgram : + Procedure (prodCode bondCode pairCode) ratCode contribution := by + let e := Procedure.first bondCode pairCode + let w := (Procedure.second Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp e) + exact Procedure.conditional hitsProgram w (Procedure.constant _ ratCode 0) + +noncomputable opaque weightProgram : Procedure (prodCode (listCode bondCode) pairCode) ratCode weight := by + let ctx := Procedure.second (listCode bondCode) pairCode + let es := Procedure.first (listCode bondCode) pairCode + let term : Procedure (prodCode pairCode bondCode) ratCode + (fun x => contribution (x.2,x.1)) := + contributionProgram.comp ((Procedure.second pairCode bondCode).pair + (Procedure.first pairCode bondCode)) + exact RationalSumProgram.sumProgram.comp + ((Procedure.listMapWith (f := fun p e => contribution (e,p)) zeroBond 0 term).comp + (ctx.pair es)) + +noncomputable opaque keepProgram : Procedure (prodCode (listCode pairCode) bondCode) + Procedure.boolCode keep := by + let ps := Procedure.first (listCode pairCode) bondCode + let e := Procedure.second (listCode pairCode) bondCode + exact (Procedure.boolNot.comp (QuantumFiniteMembership.anyProgram.comp + ((Procedure.listMapWith (f := fun e p => hits (e,p)) (0,0) false hitsProgram).comp + (e.pair ps)))).congrFun (by + intro x + simp only [Function.comp_apply,List.any_map,Function.comp_def,id_eq,keep]) + +noncomputable opaque retainedProgram : + Procedure (prodCode (listCode pairCode) (listCode bondCode)) (listCode bondCode) retained := by + let entry := Procedure.conditional keepProgram + ((Procedure.listCons bondCode).comp ((Procedure.second (listCode pairCode) bondCode).pair + (Procedure.constant _ (listCode bondCode) []))) + (Procedure.constant _ (listCode bondCode) []) + refine ((QuantumRawExchange.flattenProgram bondCode zeroBond).comp + (Procedure.listMapWith (f := fun ps e => if keep (ps,e) then [e] else []) + zeroBond [] entry)).congrFun ?_ + intro x + change (x.2.map (fun e => if keep (x.1,e) then [e] else [])).flatten = + x.2.filter (fun e => keep (x.1,e)) + induction x.2 with + | nil => rfl + | cons e es ih => + simp only [List.map_cons,List.flatten_cons,List.filter_cons] at * + cases h : keep (x.1,e) <;> simpa [h] using ih + +noncomputable opaque crossingProgram : Procedure (prodCode (listCode bondCode) sitesCode) + crossingCode crossing := by + let es := Procedure.first (listCode bondCode) sitesCode + let s := Procedure.second (listCode bondCode) sitesCode + exact ((weightProgram.comp (es.pair ((terminalProgram 0).comp s))).pair + (weightProgram.comp (es.pair ((terminalProgram 1).comp s)))).pair s + +noncomputable opaque crossingsProgram : + Procedure (prodCode (listCode bondCode) (listCode sitesCode)) (listCode crossingCode) crossings := + Procedure.listMapWith (f := fun es s => crossing (es,s)) ((0,0),(0,0)) zeroCrossing crossingProgram + +theorem hits_iff (e : Bond) (p : Pair) : + hits (e,p)=true ↔ (e.1,e.2.1)=p ∨ (e.2.1,e.1)=p := by + simp only [hits,Bool.or_eq_true,decide_eq_true_eq] + +theorem keep_iff (ps : List Pair) (e : Bond) : + keep (ps,e)=true ↔ ∀ p ∈ ps, (e.1,e.2.1)≠p ∧ (e.2.1,e.1)≠p := by + simp only [keep,Bool.not_eq_true_eq_eq_false,List.any_eq_false,hits_iff,not_or] + +theorem retained_mem (x : List Pair × List Bond) (e : Bond) : + e ∈ retained x ↔ e ∈ x.2 ∧ ∀ p ∈ x.1, (e.1,e.2.1)≠p ∧ (e.2.1,e.1)≠p := by + simp only [retained,List.mem_filter,keep_iff] + +theorem retained_bounded {n : ℕ} (ps : List Pair) (es : List Bond) + (hb : SourceBondLists.bounded n es) : SourceBondLists.bounded n (retained (ps,es)) := by + intro e he + exact hb e ((retained_mem (ps,es) e).mp he).1 + +theorem retained_noLoops (ps : List Pair) (es : List Bond) + (hn : ∀ e ∈ es, e.1 ≠ e.2.1) : ∀ e ∈ retained (ps,es), e.1 ≠ e.2.1 := by + intro e he + exact hn e ((retained_mem (ps,es) e).mp he).1 + +abbrev Input := ℚ × (QuantumListPathStep.Output × List Sites) +def inputCode : Input → List Bool := + prodCode ratCode (prodCode QuantumListPathStep.outputCode (listCode sitesCode)) +def value (x : Input) : QuantumCrossingListLayer.Input := + ((x.1,x.2.1.1,retained (pairs x.2.2,x.2.1.2.1),x.2.1.2.2), + crossings (x.2.1.2.1,x.2.2)) + +noncomputable opaque precisionProgram : Procedure inputCode ratCode Prod.fst := Procedure.first _ _ +noncomputable opaque packetProgram : + Procedure inputCode QuantumListPathStep.outputCode (fun x => x.2.1) := + (Procedure.first QuantumListPathStep.outputCode (listCode sitesCode)).comp + (Procedure.second ratCode (prodCode QuantumListPathStep.outputCode (listCode sitesCode))) +noncomputable opaque sitesProgram : Procedure inputCode (listCode sitesCode) (fun x => x.2.2) := + (Procedure.second QuantumListPathStep.outputCode (listCode sitesCode)).comp + (Procedure.second ratCode (prodCode QuantumListPathStep.outputCode (listCode sitesCode))) +noncomputable opaque bondsProgram : Procedure inputCode (listCode bondCode) (fun x => x.2.1.2.1) := + (Procedure.first (listCode bondCode) ratCode).comp + ((Procedure.second unaryCode (prodCode (listCode bondCode) ratCode)).comp packetProgram) +noncomputable opaque program : + Procedure inputCode QuantumCrossingListLayer.inputCode value := by + let n := (Procedure.first unaryCode (prodCode (listCode bondCode) ratCode)).comp packetProgram + let c := (Procedure.second (listCode bondCode) ratCode).comp + ((Procedure.second unaryCode (prodCode (listCode bondCode) ratCode)).comp packetProgram) + let es := retainedProgram.comp ((pairsProgram.comp sitesProgram).pair bondsProgram) + let cs := crossingsProgram.comp (bondsProgram.pair sitesProgram) + exact (precisionProgram.pair (n.pair (es.pair c))).pair cs + +end ContinuumCoulomb.QuantumCrossingSelectProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..b57a45813e94af9491fce9d56d84d11ae0cd1a1d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelection.lean @@ -0,0 +1,121 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalCrossing + +namespace OAI + +/-! Group a selected family of physical crossing edges without assuming a matrix +identity. Each source edge is either retained or assigned to one crossing pair. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaSumSubtypePredicate {α M : Type*} [Fintype α] [AddCommMonoid M] + (p : α → Prop) [DecidablePred p] (f : α → M) : + (∑ a : {a // p a}, f a.val) = ∑ a, if p a then f a else 0 := by + rw [← Finset.sum_subtype (Finset.univ.filter p) (by simp) f] + exact Finset.sum_filter _ _ + +theorem qmaOptionFiberSum {α β M : Type*} [Fintype α] [Fintype β] [DecidableEq β] [AddCommMonoid M] + (tag : α → Option β) (f : α → M) : + (∑ a : {a // tag a = none}, f a.val) + + (∑ b : β, ∑ a : {a // tag a = some b}, f a.val) = ∑ a, f a := by + rw [qmaSumSubtypePredicate] + simp_rw [qmaSumSubtypePredicate] + rw [Finset.sum_comm,← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro a _ + cases tag a with + | none => simp + | some b => simp [eq_comm] + +structure QMARationalCrossingSelection (G : QMARationalExchangeGraph) (r : ℕ) where + site : Fin r → Fin 4 → Fin G.n + injective : ∀ i, Function.Injective (site i) + tag : G.Edge → Option (Fin r × Fin 2) + tagged : ∀ e i a, tag e = some (i,a) → + (G.left e = site i (if a = 0 then 0 else 1) ∧ G.right e = site i (if a = 0 then 2 else 3)) ∨ + (G.left e = site i (if a = 0 then 2 else 3) ∧ G.right e = site i (if a = 0 then 0 else 1)) + +namespace QMARationalCrossingSelection +variable {G : QMARationalExchangeGraph} {r : ℕ} (S : QMARationalCrossingSelection G r) + +abbrev retained : QMARationalExchangeGraph where + n := G.n + Edge := {e : G.Edge // S.tag e = none} + left := fun e => G.left e.val + right := fun e => G.right e.val + distinct := fun e => G.distinct e.val + weight := fun e => G.weight e.val + constant := G.constant + +def weight (p : Fin r × Fin 2) : ℚ := ∑ e : {e // S.tag e = some p}, G.weight e.val + +def layer : QMARationalCrossingLayer r where + base := S.retained + site := S.site + injective := S.injective + J := fun i => S.weight (i,0) + K := fun i => S.weight (i,1) + +theorem tagged_matrix (e : G.Edge) (i : Fin r) (a : Fin 2) (he : S.tag e = some (i,a)) : + sourceHeisenbergMatrix G.n (G.left e) (G.right e) = + sourceHeisenbergMatrix G.n (S.site i (if a = 0 then 0 else 1)) + (S.site i (if a = 0 then 2 else 3)) := by + rcases S.tagged e i a he with ⟨hl,hr⟩ | ⟨hl,hr⟩ + · rw [hl,hr] + · rw [hl,hr,qmaHeisenberg_symm] + +theorem weight_matrix (p : Fin r × Fin 2) : + (S.weight p:ℂ) • sourceHeisenbergMatrix G.n (S.site p.1 (if p.2 = 0 then 0 else 1)) + (S.site p.1 (if p.2 = 0 then 2 else 3)) = + ∑ e : {e // S.tag e = some p}, (G.weight e.val:ℂ) • + sourceHeisenbergMatrix G.n (G.left e.val) (G.right e.val) := by + unfold weight + push_cast + rw [Finset.sum_smul] + apply Finset.sum_congr rfl + intro e _ + rw [S.tagged_matrix e.val p.1 p.2 e.property] + +theorem source_matrix : + qmaExchangeMatrix S.layer.source.left S.layer.source.right + (fun e => (S.layer.source.weight e:ℝ)) S.layer.source.constant = + qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant := by + rw [S.layer.source_matrix] + let f := fun e : G.Edge => (G.weight e:ℂ) • sourceHeisenbergMatrix G.n (G.left e) (G.right e) + have hp := qmaOptionFiberSum S.tag f + have hs : (∑ i, ((S.weight (i,0):ℂ) • sourceHeisenbergMatrix G.n (S.site i 0) (S.site i 2) + + (S.weight (i,1):ℂ) • sourceHeisenbergMatrix G.n (S.site i 1) (S.site i 3))) = + ∑ p : Fin r × Fin 2, ∑ e : {e // S.tag e = some p}, f e.val := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro i _ + rw [Fin.sum_univ_two] + simpa only [f,ite_true,ite_false,show (1 : Fin 2) ≠ 0 from by decide] using + congrArg₂ (· + ·) (S.weight_matrix (i,0)) (S.weight_matrix (i,1)) + change ((∑ e : {e // S.tag e = none}, f e.val)+(G.constant:ℂ) • 1)+ + (∑ i, ((S.weight (i,0):ℂ) • sourceHeisenbergMatrix G.n (S.site i 0) (S.site i 2) + + (S.weight (i,1):ℂ) • sourceHeisenbergMatrix G.n (S.site i 1) (S.site i 3))) = + (∑ e, f e)+(G.constant:ℂ) • 1 + rw [hs] + calc + _ = ((∑ e : {e // S.tag e = none}, f e.val)+ + ∑ p : Fin r × Fin 2, ∑ e : {e // S.tag e = some p}, f e.val)+(G.constant:ℂ) • 1 := by abel + _ = _ := congrArg (fun x => x+(G.constant:ℂ) • 1) hp + +theorem source_energy : S.layer.source.energy = G.energy := by + unfold QMARationalExchangeGraph.energy + rw [S.source_matrix] + rfl + +theorem output_energy_error {N : ℚ} (hN : 0 < N) : + |(S.layer.output N).energy-G.energy| ≤ 1/(N:ℝ) := by + rw [← S.source_energy] + exact S.layer.output_energy_error hN + +end QMARationalCrossingSelection +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d0e5d557950b1554794f649ea2460ce1be63fe1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionRelabel.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectionUnique + +namespace OAI + +/-! A relabeling of the old graph and the crossing cells preserves exactly +which edges are retained by the physical crossing selection. -/ + +noncomputable section +namespace ContinuumCoulomb.QMARationalExchangeGraph +open scoped Classical + +variable {G H : QMARationalExchangeGraph} {r t : ℕ} + (vertex : Fin G.n ≃ Fin H.n) (edge : G.Edge ≃ H.Edge) + (left : ∀ e, vertex (G.left e)=H.left (edge e)) + (right : ∀ e, vertex (G.right e)=H.right (edge e)) + (s : Fin r → Fin 4 → Fin G.n) (u : Fin t → Fin 4 → Fin H.n) + (cell : Fin r ≃ Fin t) (site : ∀ i a, vertex (s i a)=u (cell i) a) + +include left right site in +theorem crossingMatch_relabel (e : G.Edge) (i : Fin r) (a : Fin 2) : + G.CrossingMatch s e (i,a) ↔ H.CrossingMatch u (edge e) (cell i,a) := by + have hl (b : Fin 4) : G.left e=s i b ↔ H.left (edge e)=u (cell i) b := by + rw [← left e,← site i b] + exact vertex.injective.eq_iff.symm + have hr (b : Fin 4) : G.right e=s i b ↔ H.right (edge e)=u (cell i) b := by + rw [← right e,← site i b] + exact vertex.injective.eq_iff.symm + simp only [CrossingMatch,hl,hr] + +include left right site in +theorem crossingTag_none_relabel (e : G.Edge) : + G.crossingTag s e=none ↔ H.crossingTag u (edge e)=none := by + rw [G.crossingTag_none,H.crossingTag_none] + constructor + · intro h ⟨i,a⟩ hp + apply h (cell.symm i,a) + apply (crossingMatch_relabel vertex edge left right s u cell site e _ a).mpr + simpa only [Equiv.apply_symm_apply] using hp + · intro h ⟨i,a⟩ hp + exact h (cell i,a) ((crossingMatch_relabel vertex edge left right s u cell site e i a).mp hp) + +variable (hs : ∀ i, Function.Injective (s i)) (hu : ∀ i, Function.Injective (u i)) + +include left right site in +theorem retained_source (e : (G.crossingSelection s hs).retained.Edge) : + ∃ f : (H.crossingSelection u hu).retained.Edge, + vertex (G.left e.val)=H.left f.val ∧ vertex (G.right e.val)=H.right f.val := by + refine ⟨⟨edge e.val,(crossingTag_none_relabel vertex edge left right s u cell site e.val).mp + e.property⟩,left e.val,right e.val⟩ + +include left right site in +theorem retained_target (f : (H.crossingSelection u hu).retained.Edge) : + ∃ e : (G.crossingSelection s hs).retained.Edge, + vertex (G.left e.val)=H.left f.val ∧ vertex (G.right e.val)=H.right f.val := by + have ht : G.crossingTag s (edge.symm f.val)=none := + (crossingTag_none_relabel vertex edge left right s u cell site (edge.symm f.val)).mpr + (by rw [Equiv.apply_symm_apply]; exact f.property) + refine ⟨⟨edge.symm f.val,ht⟩,?_,?_⟩ + · simpa only [Equiv.apply_symm_apply] using left (edge.symm f.val) + · simpa only [Equiv.apply_symm_apply] using right (edge.symm f.val) + +end ContinuumCoulomb.QMARationalExchangeGraph + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionUnique.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionUnique.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf0f1916371ca111c813db16af9f21a9e97048a6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSelectionUnique.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelectFromSites + +namespace OAI + +/-! Disjoint physical terminal sets make crossing-edge assignment unique. +Consequently the finite endpoint test computes the canonical selection. -/ + +noncomputable section +namespace ContinuumCoulomb.QMARationalExchangeGraph +open scoped Classical + +private theorem crossingMatch_left_parity (G : QMARationalExchangeGraph) {r : ℕ} + (site : Fin r → Fin 4 → Fin G.n) (e : G.Edge) (p : Fin r × Fin 2) + (h : G.CrossingMatch site e p) : + ∃ k : Fin 4, site p.1 k=G.left e ∧ k.val%2=p.2.val := by + rcases p with ⟨i,a⟩ + fin_cases a + · rcases h with ⟨hl,_⟩ | ⟨hl,_⟩ + · exact ⟨0,hl.symm,rfl⟩ + · exact ⟨2,hl.symm,rfl⟩ + · rcases h with ⟨hl,_⟩ | ⟨hl,_⟩ + · exact ⟨1,hl.symm,rfl⟩ + · exact ⟨3,hl.symm,rfl⟩ + +theorem crossingMatch_unique (G : QMARationalExchangeGraph) {r : ℕ} + (site : Fin r → Fin 4 → Fin G.n) + (hinj : Function.Injective (fun p : Fin r × Fin 4 => site p.1 p.2)) + {e : G.Edge} {p q : Fin r × Fin 2} + (hp : G.CrossingMatch site e p) (hq : G.CrossingMatch site e q) : p=q := by + obtain ⟨a,ha,hpa⟩ := crossingMatch_left_parity G site e p hp + obtain ⟨b,hb,hqb⟩ := crossingMatch_left_parity G site e q hq + have hi : (p.1,a)=(q.1,b) := hinj (ha.trans hb.symm) + have hab : a=b := congrArg Prod.snd hi + have hindex : p.1=q.1 := congrArg (fun z : Fin r × Fin 4 => z.1) hi + refine Prod.ext hindex (Fin.ext ?_) + rw [← hpa,← hqb,hab] + +theorem crossingTag_some_iff (G : QMARationalExchangeGraph) {r : ℕ} + (site : Fin r → Fin 4 → Fin G.n) + (hinj : Function.Injective (fun p : Fin r × Fin 4 => site p.1 p.2)) + (e : G.Edge) (p : Fin r × Fin 2) : + G.crossingTag site e=some p ↔ G.CrossingMatch site e p := by + constructor + · exact G.crossingTag_some site + · intro hp + cases ht : G.crossingTag site e with + | none => exact ((G.crossingTag_none site).mp ht p hp).elim + | some q => + have hq := G.crossingTag_some site ht + have hqp := G.crossingMatch_unique site hinj hq hp + exact congrArg some hqp + +end ContinuumCoulomb.QMARationalExchangeGraph + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..979d0ba8c0fa8ec70be63d034838b979a457df73 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteProgram.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortSelectionProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFirstUseProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortChainProgram + +namespace OAI + +/-! Locate crossing terminals by scanning the actual physical position tape. +The finite search returns exactly the existing terminal spin indices. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSiteProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode QuantumCrossingListBlock +open scoped Classical + +abbrev Input := List Pair × Pair +def inputCode : Input → List Bool := prodCode (listCode pairCode) pairCode +def flags (x : Input) : List Bool := x.1.map (fun p => decide (p=x.2)) +def index (x : Input) : ℕ := QuantumFirstUseProgram.first (flags x) + +noncomputable opaque flagsProgram : Procedure inputCode (listCode Procedure.boolCode) flags := by + let targets := Procedure.second (listCode pairCode) pairCode + let ps := Procedure.first (listCode pairCode) pairCode + let eq := QuantumFiniteMembership.pairEqProgram.comp + ((Procedure.second pairCode pairCode).pair (Procedure.first pairCode pairCode)) + exact (Procedure.listMapWith (f := fun q p => decide (p=q)) (0,0) false eq).comp + (targets.pair ps) +noncomputable opaque indexProgram : Procedure inputCode unaryCode index := + QuantumFirstUseProgram.firstProgram.comp flagsProgram + +theorem index_eq (x : Input) : index x=x.1.findIdx (fun p => decide (p=x.2)) := by + rw [index,QuantumFirstUseProgram.first_eq_findIdx,flags,List.findIdx_map] + rfl + +theorem index_ofFn {n : ℕ} (pos : Fin n → Pair) (hinj : Function.Injective pos) (v : Fin n) : + index (List.ofFn pos,pos v)=v.val := by + rw [index_eq] + apply (List.findIdx_eq (by simpa only [List.length_ofFn] using v.isLt)).mpr + constructor + · simp only [List.getElem_ofFn,decide_eq_true_eq] + · intro j hj + simp only [List.getElem_ofFn,decide_eq_false_iff_not] + intro h + have hv := congrArg Fin.val (hinj h) + exact (Nat.ne_of_lt hj) hv + +def target (a : Fin 4) (x : Input) : Input := + (x.1,qmaGridPort x.2 (qmaPatchDirection a)) +def terminal (a : Fin 4) (x : Input) : ℕ := index (target a x) +def sites (x : Input) : Sites := ((terminal 0 x,terminal 1 x),(terminal 2 x,terminal 3 x)) + +noncomputable opaque targetProgram (a : Fin 4) : Procedure inputCode inputCode (target a) := by + let p := Procedure.second (listCode pairCode) pairCode + let endpoint := (QuantumPortChainProgram.portProgram.comp + (p.pair (Procedure.constant inputCode Nat.bits (qmaPatchDirection a).val))).congrFun + (by intro x; exact QuantumPortChainProgram.port_fin x.2 (qmaPatchDirection a)) + exact (Procedure.first (listCode pairCode) pairCode).pair endpoint +noncomputable opaque terminalProgram (a : Fin 4) : Procedure inputCode Nat.bits (terminal a) := + Procedure.unaryToBits.comp (indexProgram.comp (targetProgram a)) +noncomputable opaque sitesProgram : Procedure inputCode sitesCode sites := + ((terminalProgram 0).pair (terminalProgram 1)).pair + ((terminalProgram 2).pair (terminalProgram 3)) + +def allSites (x : List Pair × List Pair) : List Sites := x.2.map (fun c => sites (x.1,c)) +noncomputable opaque allSitesProgram : + Procedure (prodCode (listCode pairCode) (listCode pairCode)) (listCode sitesCode) allSites := + Procedure.listMapWith (f := fun ps c => sites (ps,c)) (0,0) ((0,0),(0,0)) sitesProgram + +theorem terminal_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) (i : Fin P.crossingCells.card) (a : Fin 4) : + terminal a (List.ofFn (P.finishedPosition N D),(P.crossingCell i).val)= + (P.crossingSiteFin N hD i a).val := by + unfold terminal target + rw [← P.crossingSite_spec N hD (P.crossingCell i) (qmaPatchDirection a)] + exact index_ofFn (P.finishedPosition N D) (P.toEmbedding.iterate N D).position_injective + (P.crossingSiteFin N hD i a) + +theorem sites_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) (i : Fin P.crossingCells.card) : + sites (List.ofFn (P.finishedPosition N D),(P.crossingCell i).val)= + QuantumCrossingSelectProgram.encodedSites (P.crossingSiteFin N hD) i := by + simp only [sites,terminal_actual P N hD,QuantumCrossingSelectProgram.encodedSites] + +theorem allSites_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) : + allSites (List.ofFn (P.finishedPosition N D),List.ofFn (fun i => (P.crossingCell i).val))= + List.ofFn (QuantumCrossingSelectProgram.encodedSites (P.crossingSiteFin N hD)) := by + simp only [allSites,List.map_ofFn,Function.comp_def,sites_actual P N hD] + +end ContinuumCoulomb.QuantumCrossingSiteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..72a3a4bdae682ecda347fbda41303ab91efd96ec --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSiteRelabel.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSiteProgram + +namespace OAI + +/-! The terminal scan is independent of the finite vertex enumeration. +It returns the actual terminal in the emitted position tape. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCrossingSiteProgram +open QuantumRouteCode QuantumCrossingListBlock +open scoped Classical + +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) {n : ℕ} + (σ : Fin n ≃ Fin (P.finishedGraph N D).n) (pos : Fin n → Pair) + (hpos : ∀ v, P.finishedPosition N D (σ v)=pos v) + +include hpos in +theorem relabeled_injective : Function.Injective pos := by + intro v w h + apply σ.injective + apply (P.toEmbedding.iterate N D).position_injective + change P.finishedPosition N D (σ v)=P.finishedPosition N D (σ w) + rw [hpos,hpos] + exact h + +include hpos in +theorem terminal_relabeled (i : Fin P.crossingCells.card) (a : Fin 4) : + terminal a (List.ofFn pos,(P.crossingCell i).val)= + (σ.symm (P.crossingSiteFin N hD i a)).val := by + have hp : pos (σ.symm (P.crossingSiteFin N hD i a))= + qmaGridPort (P.crossingCell i).val (qmaPatchDirection a) := by + rw [← hpos,Equiv.apply_symm_apply] + exact P.crossingSite_spec N hD (P.crossingCell i) (qmaPatchDirection a) + unfold terminal target + rw [← hp] + exact index_ofFn pos (relabeled_injective P N σ pos hpos) _ + +include hpos in +theorem sites_relabeled (i : Fin P.crossingCells.card) : + sites (List.ofFn pos,(P.crossingCell i).val)= + QuantumCrossingSelectProgram.encodedSites + (fun i a => σ.symm (P.crossingSiteFin N hD i a)) i := by + simp only [sites,terminal_relabeled P N hD σ pos hpos, + QuantumCrossingSelectProgram.encodedSites] + +include hpos in +theorem allSites_relabeled : + allSites (List.ofFn pos,List.ofFn (fun i => (P.crossingCell i).val))= + List.ofFn (QuantumCrossingSelectProgram.encodedSites + (fun i a => σ.symm (P.crossingSiteFin N hD i a))) := by + simp only [allSites,List.map_ofFn,Function.comp_def,sites_relabeled P N hD σ pos hpos] + +theorem relabeled_sites_global : Function.Injective + (fun t : Fin P.crossingCells.card × Fin 4 => σ.symm (P.crossingSiteFin N hD t.1 t.2)) := by + intro x y h + exact P.crossingSiteFin_global N hD (σ.symm.injective h) + +include hpos in +theorem allSites_reordered {r : ℕ} (τ : Fin r ≃ Fin P.crossingCells.card) : + allSites (List.ofFn pos,List.ofFn (fun i => (P.crossingCell (τ i)).val))= + List.ofFn (QuantumCrossingSelectProgram.encodedSites + (fun i a => σ.symm (P.crossingSiteFin N hD (τ i) a))) := by + simp only [allSites,List.map_ofFn,Function.comp_def,sites_relabeled P N hD σ pos hpos] + apply congrArg List.ofFn + funext i + rfl + +theorem reordered_sites_global {r : ℕ} (τ : Fin r ≃ Fin P.crossingCells.card) : + Function.Injective + (fun t : Fin r × Fin 4 => σ.symm (P.crossingSiteFin N hD (τ t.1) t.2)) := by + exact (relabeled_sites_global P N hD σ).comp + (Equiv.prodCongr τ (Equiv.refl (Fin 4))).injective + +end ContinuumCoulomb.QuantumCrossingSiteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSites.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..68decf5a8483637cb0d16a7e9aab7a31ba6ec2f9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSites.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellCrossings +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortSpinCoverage + +namespace OAI + +/-! Every terminal of every selected crossing is an actual spin in the completed +rational port graph. Distinct crossing cells have disjoint terminal sets. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +abbrev Crossing := {p : ℕ × ℕ // p ∈ P.crossingCells} + +abbrev finishedGraph (N : ℚ) (D : ℕ) : QMARationalExchangeGraph := (P.schedule.iterate N D).graph + +def finishedPosition (N : ℚ) (D : ℕ) : Fin (P.finishedGraph N D).n → ℕ × ℕ := + (P.toEmbedding.iterate N D).position + +theorem crossing_terminal_exists (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) + (c : P.Crossing) (a : Fin 4) : + ∃ v, P.finishedPosition N D v = qmaGridPort c.val a := by + obtain ⟨i,j,hij,hi,hj,_⟩ := P.mem_crossingCells.mp c.property + have hc : P.cell i = P.cell j := hi.trans hj.symm + obtain ⟨b,hb⟩ := (P.twoVisitsEquiv hij hc).surjective a + fin_cases b + · change P.port i 0 = a at hb + simpa only [finishedPosition,hi,hb] using P.iterate_covers_port N hD i 0 + · change P.port i 1 = a at hb + simpa only [finishedPosition,hi,hb] using P.iterate_covers_port N hD i 1 + · change P.port j 0 = a at hb + simpa only [finishedPosition,hj,hb] using P.iterate_covers_port N hD j 0 + · change P.port j 1 = a at hb + simpa only [finishedPosition,hj,hb] using P.iterate_covers_port N hD j 1 + +def crossingSite (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) (c : P.Crossing) (a : Fin 4) : + Fin (P.finishedGraph N D).n := Classical.choose (P.crossing_terminal_exists N hD c a) + +theorem crossingSite_spec (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) (c : P.Crossing) (a : Fin 4) : + P.finishedPosition N D (P.crossingSite N hD c a) = qmaGridPort c.val a := + Classical.choose_spec (P.crossing_terminal_exists N hD c a) + +theorem crossingSite_injective (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) : + Function.Injective (fun x : P.Crossing × Fin 4 => P.crossingSite N hD x.1 x.2) := by + rintro ⟨c,a⟩ ⟨d,b⟩ h + have hp := congrArg (P.finishedPosition N D) h + rw [P.crossingSite_spec,P.crossingSite_spec] at hp + have he : (c.val,a) = (d.val,b) := qmaGridPort_injective hp + have hcd : c = d := Subtype.ext (congrArg (fun z : (ℕ × ℕ) × Fin 4 => z.1) he) + have hab : a = b := congrArg (fun z : (ℕ × ℕ) × Fin 4 => z.2) he + exact Prod.ext hcd hab + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSize.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d51a07171b9cc41253c4e1c16f0a65a4cf7c32c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSize.lean @@ -0,0 +1,45 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMergedOutputRoutes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathScheduleSize + +namespace OAI + +/-! The actual crossing output has linear size when the coarse route length is +bounded by a fixed constant. Merging parallel edges can only decrease it. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +theorem finished_size (N : ℚ) (D : ℕ) : + (P.finishedGraph N D).n + Fintype.card (P.finishedGraph N D).Edge ≤ + 5^D*(G.n+Fintype.card G.Edge) := P.schedule.iterate_size N D + +theorem crossingOutput_size (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) : + (P.crossingOutput N hD).n + Fintype.card (P.crossingOutput N hD).Edge ≤ + (5^D+11*D)*(G.n+Fintype.card G.Edge) := by + have hs := P.finished_size N D + have hc := P.crossingCells_card_le hD + have hr : Fintype.card (P.portCrossingSelection N hD).retained.Edge ≤ + Fintype.card (P.finishedGraph N D).Edge := Fintype.card_subtype_le _ + have he := (P.portCrossingSelection N hD).layer.output_edge_count N + change Fintype.card (P.crossingOutput N hD).Edge = + Fintype.card (P.portCrossingSelection N hD).retained.Edge+9*P.crossingCells.card at he + change (P.finishedGraph N D).n+P.crossingCells.card*2+ + Fintype.card (P.crossingOutput N hD).Edge ≤ _ + rw [he] + nlinarith + +theorem mergedOutput_size (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) : + (P.crossingOutput N hD).merge.n + Fintype.card (P.crossingOutput N hD).merge.Edge ≤ + (5^D+11*D)*(G.n+Fintype.card G.Edge) := + (Nat.add_le_add_left (P.crossingOutput N hD).merge_edge_count _).trans + (P.crossingOutput_size N hD) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..58e72194204e5e235a535d9d436be3c02e3f60ea --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSpectrum.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingEffective +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSingletStarSpectrum + +namespace OAI + +/-! The crossing construction compared on the complete spin Hilbert space. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker InnerProductSpace + +theorem qmaCrossingCorrection_star {n : ℕ} (site : Fin 4 → Fin n) + (hsite : Function.Injective site) (J K : ℝ) : + (qmaCrossingCorrection site J K).conjTranspose = qmaCrossingCorrection site J K := by + have hij (a b : Fin 4) (hab : a ≠ b) : site a ≠ site b := fun h => hab (hsite h) + simp only [qmaCrossingCorrection,Matrix.conjTranspose_add,Matrix.conjTranspose_sub, + Matrix.conjTranspose_smul,Matrix.conjTranspose_one, + sourceHeisenbergMatrix_star n _ _ (hij 0 1 (by decide)), + sourceHeisenbergMatrix_star n _ _ (hij 0 3 (by decide)), + sourceHeisenbergMatrix_star n _ _ (hij 1 2 (by decide)), + sourceHeisenbergMatrix_star n _ _ (hij 2 3 (by decide)), + Complex.star_def,Complex.conj_ofReal] + norm_num [starRingEnd_apply,Complex.star_def] + +theorem qmaCrossing_bottom {n r : ℕ} (e : Fin r) (site : Fin 4 → Fin n) + (hsite : Function.Injective site) (R J K : ℝ) (hR : 0 < R) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon ≤ 1 / 4) + (hbound : ‖spinMatrixOperator ((C + qmaCrossingCorrection site J K) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ a, |qmaCrossingAmplitude R J K a| ≤ epsilon * (4 * R^2)) : + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + qmaCrossingCorrection site J K) + (qmaSingletStar n r e site qmaCrossingMember (qmaCrossingAmplitude R J K))) - + sourceMatrixBottom n (C + ((J:ℂ) • sourceHeisenbergMatrix n (site 0) (site 2) + + (K:ℂ) • sourceHeisenbergMatrix n (site 1) (site 3)))| ≤ 16 * R^2 * epsilon^3 := by + have hCW : (C + qmaCrossingCorrection site J K).conjTranspose = + C + qmaCrossingCorrection site J K := by + rw [Matrix.conjTranspose_add,hC,qmaCrossingCorrection_star site hsite] + have h := qmaSingletStar_bottom n r (sq_pos_of_pos hR) _ hCW e site + qmaCrossingMember (qmaCrossingAmplitude R J K) hepsilon hsmall hbound + rw [add_sub_assoc,qmaCrossing_effective e site hsite R J K hR.ne'] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSupportRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSupportRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..146d5f54e3624f70d29422650c94edd8579691b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingSupportRelabel.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalCrossing + +namespace OAI + +/-! A crossing layer preserves unordered edge support under relabeling of +the old vertices and crossing cells. Couplings do not enter this statement. -/ + +noncomputable section +namespace ContinuumCoulomb.QMARationalCrossingLayer +open MediatorGraph +open scoped Classical + +variable {r s : ℕ} (C : QMARationalCrossingLayer r) (E : QMARationalCrossingLayer s) + (vertex : Fin C.base.n ≃ Fin E.base.n) (cell : Fin r ≃ Fin s) + +def vertexRelabel : Fin (C.base.n+r*2) ≃ Fin (E.base.n+s*2) := + ((vertexEquiv C.base.n r).symm.trans + (Equiv.sumCongr vertex (Equiv.prodCongr cell (Equiv.refl (Fin 2))))).trans + (vertexEquiv E.base.n s) + +theorem vertexRelabel_old (v : Fin C.base.n) : + C.vertexRelabel E vertex cell (old C.base.n r v) = old E.base.n s (vertex v) := by + simp [vertexRelabel,old] + +theorem vertexRelabel_fresh (i : Fin r) (a : Fin 2) : + C.vertexRelabel E vertex cell (fresh C.base.n r i a) = + fresh E.base.n s (cell i) a := by + simp [vertexRelabel,fresh] + +variable + (site : ∀ i a, vertex (C.site i a) = E.site (cell i) a) + (forward : ∀ e : C.base.Edge, ∃ f : E.base.Edge, + s(vertex (C.base.left e),vertex (C.base.right e)) = s(E.base.left f,E.base.right f)) + (backward : ∀ f : E.base.Edge, ∃ e : C.base.Edge, + s(vertex (C.base.left e),vertex (C.base.right e)) = s(E.base.left f,E.base.right f)) + +include site forward in +theorem output_edge_source (N M : ℚ) (e : (C.output N).Edge) : + ∃ f : (E.output M).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f) := by + rcases e with (e | ⟨i,a⟩) | (i | ⟨i,a⟩) + · obtain ⟨f,hf⟩ := forward e + refine ⟨.inl (.inl f),?_⟩ + simpa only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaCrossingsBaseLeft,qmaCrossingsBaseRight,Sum.elim_inl,vertexRelabel_old, + Sym2.map_mk] using congrArg (Sym2.map (old E.base.n s)) hf + · refine ⟨.inl (.inr (cell i,a)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaCrossingsBaseLeft,qmaCrossingsBaseRight,Sum.elim_inr,vertexRelabel_old,site] + · refine ⟨.inr (.inl (cell i)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight,vertexRelabel_fresh] + · refine ⟨.inr (.inr (cell i,a)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + vertexRelabel_old,vertexRelabel_fresh,site] + +include site backward in +theorem output_edge_target (N M : ℚ) (f : (E.output M).Edge) : + ∃ e : (C.output N).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f) := by + rcases f with (f | ⟨j,a⟩) | (j | ⟨j,a⟩) + · obtain ⟨e,he⟩ := backward f + refine ⟨.inl (.inl e),?_⟩ + simpa only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaCrossingsBaseLeft,qmaCrossingsBaseRight,Sum.elim_inl,vertexRelabel_old, + Sym2.map_mk] using congrArg (Sym2.map (old E.base.n s)) he + · refine ⟨.inl (.inr (cell.symm j,a)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaCrossingsBaseLeft,qmaCrossingsBaseRight,Sum.elim_inr,vertexRelabel_old,site, + Equiv.apply_symm_apply] + · refine ⟨.inr (.inl (cell.symm j)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight,vertexRelabel_fresh, + Equiv.apply_symm_apply] + · refine ⟨.inr (.inr (cell.symm j,a)),?_⟩ + simp only [output,qmaParallelGraphLeft,qmaParallelGraphRight, + vertexRelabel_old,vertexRelabel_fresh,site,Equiv.apply_symm_apply] + +include site forward backward in +theorem output_support (N M : ℚ) : + (∀ e : (C.output N).Edge, ∃ f : (E.output M).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f)) ∧ + (∀ f : (E.output M).Edge, ∃ e : (C.output N).Edge, + s(C.vertexRelabel E vertex cell ((C.output N).left e), + C.vertexRelabel E vertex cell ((C.output N).right e)) = + s((E.output M).left f,(E.output M).right f)) := + ⟨C.output_edge_source E vertex cell site forward N M, + C.output_edge_target E vertex cell site backward N M⟩ + +end ContinuumCoulomb.QMARationalCrossingLayer + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingsGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingsGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..875b55141e0e80a25b3eef0e67281e4d3c73f62d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumCrossingsGraph.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumParallelGraph +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingCalibration + +namespace OAI + +/-! Ordinary spin edges and polynomial full-space error for a parallel crossing-elimination round. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Kronecker Classical +variable {ν : Type*} [Fintype ν] + +def qmaCrossingsBaseLeft {n r : ℕ} (left : ν → Fin n) (site : Fin r → Fin 4 → Fin n) : + ν ⊕ (Fin r × Fin 4) → Fin n := Sum.elim left (fun p => site p.1 (qmaCrossingLeft p.2)) +def qmaCrossingsBaseRight {n r : ℕ} (right : ν → Fin n) (site : Fin r → Fin 4 → Fin n) : + ν ⊕ (Fin r × Fin 4) → Fin n := Sum.elim right (fun p => site p.1 (qmaCrossingRight p.2)) +def qmaCrossingsBaseWeight {r : ℕ} (weight : ν → ℝ) (J K : Fin r → ℝ) : + ν ⊕ (Fin r × Fin 4) → ℝ := Sum.elim weight (fun p => qmaCrossingWeight (J p.1) (K p.1) p.2) + +omit [Fintype ν] in +theorem qmaCrossingsBase_distinct {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (site : Fin r → Fin 4 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) : + ∀ a, qmaCrossingsBaseLeft left site a ≠ qmaCrossingsBaseRight right site a := by + intro a + cases a with + | inl a => exact hneq a + | inr p => + intro h + have hh := hsite p.1 h + rcases p with ⟨e,a⟩ + fin_cases a <;> norm_num [qmaCrossingLeft,qmaCrossingRight] at hh + +theorem qmaCrossingsBase_matrix {n r : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant : ℝ) (site : Fin r → Fin 4 → Fin n) (J K : Fin r → ℝ) : + qmaExchangeMatrix (qmaCrossingsBaseLeft left site) (qmaCrossingsBaseRight right site) + (qmaCrossingsBaseWeight weight J K) (constant+∑ e, qmaCrossingOffset (J e) (K e)) = + qmaExchangeMatrix left right weight constant + + ∑ e, qmaCrossingCorrection (site e) (J e) (K e) := by + simp only [qmaCrossingCorrection_exchange,qmaExchangeMatrix,Fintype.sum_sum_type, + Fintype.sum_prod_type,qmaCrossingsBaseLeft,qmaCrossingsBaseRight,qmaCrossingsBaseWeight, + Sum.elim_inl,Sum.elim_inr,Complex.ofReal_add,Complex.ofReal_sum,add_smul, + Finset.sum_add_distrib,Finset.sum_smul] + abel + +def qmaCrossingsGraph {n r : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant R : ℝ) (site : Fin r → Fin 4 → Fin n) (J K : Fin r → ℝ) : + Matrix (SourceSpinBasis (n+r*2)) (SourceSpinBasis (n+r*2)) ℂ := + qmaExchangeMatrix + (qmaParallelGraphLeft (qmaCrossingsBaseLeft left site) site) + (qmaParallelGraphRight (qmaCrossingsBaseRight right site) (fun _ => qmaCrossingMember)) + (qmaParallelGraphWeight (qmaCrossingsBaseWeight weight J K) (R^2) + (fun e => qmaCrossingAmplitude R (J e) (K e))) + ((constant+∑ e, qmaCrossingOffset (J e) (K e))+3*r*(R^2)) + +theorem qmaCrossingsGraph_matrix {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant R : ℝ) + (site : Fin r → Fin 4 → Fin n) (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) : + (qmaCrossingsGraph left right weight constant R site J K).submatrix + (basisEquiv n r) (basisEquiv n r) = + qmaPhysicalParallelHamiltonian n r (R^2) + (qmaExchangeMatrix left right weight constant+∑ e, qmaCrossingCorrection (site e) (J e) (K e)) + site (fun _ => qmaCrossingMember) (fun e => qmaCrossingAmplitude R (J e) (K e)) := by + unfold qmaCrossingsGraph + simpa only [qmaCrossingsBase_matrix] using + qmaParallelGraph_matrix _ _ (qmaCrossingsBase_distinct left right hneq site hsite) + (qmaCrossingsBaseWeight weight J K) (constant+∑ e, qmaCrossingOffset (J e) (K e)) (R^2) + site (fun _ => qmaCrossingMember) (fun e => qmaCrossingAmplitude R (J e) (K e)) + +theorem qmaCrossingsGraph_accuracy {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant : ℝ) + (site : Fin r → Fin 4 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (J K : Fin r → ℝ) {N : ℝ} (hN : 0 < N) : + let B := 3*(∑ a, |weight a|)+|constant| + let A := 6*∑ e, (1+|J e|+|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + |sourceMatrixBottom (n+r*2) (qmaCrossingsGraph left right weight constant R site J K) - + sourceMatrixBottom n (qmaExchangeMatrix left right weight constant + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 1) (site e 3)))| ≤ 1/N := by + dsimp only + rw [sourceMatrixBottom_eq_mediator n r,qmaCrossingsGraph_matrix left right hneq weight constant _ site hsite, + qmaPhysicalParallel_bottom] + have hC : (qmaExchangeMatrix left right weight constant).conjTranspose = + qmaExchangeMatrix left right weight constant := by + simp only [qmaExchangeMatrix,Matrix.conjTranspose_add,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,sourceHeisenbergMatrix_star n _ _ (hneq _), + Complex.star_def,Complex.conj_ofReal,Matrix.conjTranspose_one] + exact qmaCrossings_accuracy site hsite J K (by positivity) hN _ hC + (qmaExchangeMatrix_lift_norm left right hneq weight constant) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDefinedRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDefinedRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..4398d8d38064feedbc5c3877b528a6a804e1ecc7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDefinedRealization.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarRouteRealization +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathIteratedBound + +namespace OAI + +/-! The planar realization has a specified finite graph and placement, so its +coefficient and serialization bounds refer to the same physical output. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +namespace QMAPathSchedule + +theorem iterate_vertices_ge (W : QMAPathSchedule) (N : ℚ) (k : ℕ) : + W.graph.n ≤ (W.iterate N k).graph.n := by + induction k with + | zero => exact le_rfl + | succ k ih => + change W.graph.n ≤ (W.iterate N k).graph.n+(W.iterate N k).active.card*2 + omega + +end QMAPathSchedule + +namespace QMAEvenRouteData +variable {G : QMARationalExchangeGraph} (P : QMAEvenRouteData G) + +def output (N : ℚ) (D : ℕ) : QMARationalExchangeGraph := ((P.schedule N).iterate N D).graph + +def outputPosition (N : ℚ) (D : ℕ) := ((P.embedding N).iterate N D).position + +theorem output_vertices_ge (N : ℚ) (D : ℕ) : G.n ≤ (P.output N D).n := by + have h := (P.schedule N).iterate_vertices_ge N D + change G.n+(Finset.univ : Finset G.Edge).card*2 ≤ (P.output N D).n at h + omega + +theorem output_position_injective (N : ℚ) (D : ℕ) : + Function.Injective (P.outputPosition N D) := ((P.embedding N).iterate N D).position_injective + +theorem output_position_bounded (N : ℚ) (D : ℕ) {X Y : ℕ} (hbox : P.Bounded X Y) : + ∀ v, (P.outputPosition N D v).1 < X ∧ (P.outputPosition N D v).2 < Y := + ((P.embedding N).iterate_bounded N (P.embedding_bounded N hbox) D).1 + +theorem output_adjacent (N : ℚ) {D : ℕ} (hD : ∀ e, P.work e ≤ D) + (e : (P.output N D).Edge) : + qmaSquareGrid.Adj (P.outputPosition N D ((P.output N D).left e)) + (P.outputPosition N D ((P.output N D).right e)) := + ((P.embedding N).iterate N D).adjacent_of_complete + ((P.schedule N).iterate_complete N (P.schedule_work_le N hD)) e + +theorem output_degree (N : ℚ) (D : ℕ) {d : ℕ} (h3 : 3 ≤ d) + (hd : ∀ v, qmaGraphDegree G.left G.right v ≤ d) : + ∀ v, qmaGraphDegree (P.output N D).left (P.output N D).right v ≤ d := + (P.schedule N).iterate_degree N h3 (P.schedule_degree N h3 hd) D + +theorem output_size (N : ℚ) (D : ℕ) : + (P.output N D).n+Fintype.card (P.output N D).Edge ≤ + 5^(D+1)*(G.n+Fintype.card G.Edge) := by + have h := (P.schedule N).iterate_size N D + have hs := Nat.mul_le_mul_left (5^D) (P.schedule_size N) + exact h.trans (by simpa [pow_succ,mul_assoc] using hs) + +theorem output_energy_error {N : ℚ} (hN : 0 < N) (D : ℕ) : + |(P.output N D).energy-G.energy| ≤ ((D+1:ℕ):ℝ)/(N:ℝ) := by + have he := (P.schedule N).iterate_energy_error hN D + calc + _ ≤ |(P.output N D).energy-(P.schedule N).graph.energy|+ + |(P.schedule N).graph.energy-G.energy| := abs_sub_le _ _ _ + _ ≤ (D:ℝ)/(N:ℝ)+1/(N:ℝ) := add_le_add he (P.schedule_energy_error hN) + _ = _ := by push_cast; ring + +end QMAEvenRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDegreeReduction.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDegreeReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..0295b4b34d0a5e97a0c62e8eb6b10f6d349f5d5e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDegreeReduction.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitialMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitialSize + +namespace OAI + +/-! The bounded-degree exchange reduction with actual full-space energy and size bounds. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical + +def qmaDegreeReduction {n m : ℕ} (left right : Fin m → Fin n) (J : Fin m → ℝ) + (constant N : ℝ) (D : ℕ) : QMAWeightedForkNetwork n := + let A := 3*∑ e, (1+2*|J e|) + let B := |constant|+4*∑ e, (1+|J e|)^2 + (qmaSubdivisionWeighted left right J constant (qmaRoutingScale A B N)).iterate N D + +theorem qmaDegreeReduction_graph {n m : ℕ} (left right : Fin m → Fin n) (J : Fin m → ℝ) + (constant N : ℝ) (D : ℕ) : + (qmaDegreeReduction left right J constant N D).graph = + (qmaSubdivisionNetwork left right).iterate D := by + unfold qmaDegreeReduction + rw [QMAWeightedForkNetwork.iterate_graph] + rfl + +theorem qmaDegreeReduction_degree {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (J : Fin m → ℝ) (constant N : ℝ) (D : ℕ) + (hD : ∀ i, qmaGraphDegree left right i ≤ D) : + ∀ v, qmaGraphDegree (qmaDegreeReduction left right J constant N D).graph.state.fullLeft + (qmaDegreeReduction left right J constant N D).graph.state.fullRight v ≤ 3 := by + rw [qmaDegreeReduction_graph] + exact qmaSubdivision_degree_three left right hneq D hD + +theorem qmaDegreeReduction_vertices {n m : ℕ} (left right : Fin m → Fin n) (J : Fin m → ℝ) + (constant N : ℝ) (D : ℕ) : + (qmaDegreeReduction left right J constant N D).graph.n ≤ n+2*m+4*D*m := by + rw [qmaDegreeReduction_graph] + exact qmaSubdivision_vertices left right D + +theorem qmaDegreeReduction_edges {n m : ℕ} (left right : Fin m → Fin n) (J : Fin m → ℝ) + (constant N : ℝ) (D : ℕ) : + let G := (qmaDegreeReduction left right J constant N D).graph + Fintype.card (G.Edge ⊕ (Σ i, Fin (G.degree i))) ≤ 3*m+8*D*m := by + dsimp only + rw [qmaDegreeReduction_graph] + exact qmaSubdivision_edges left right D + +theorem qmaDegreeReduction_energy {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (J : Fin m → ℝ) (constant : ℝ) + {N : ℝ} (hN : 0 < N) (D : ℕ) : + |(qmaDegreeReduction left right J constant N D).energy - + sourceMatrixBottom n (qmaExchangeMatrix left right J constant)| ≤ ((D:ℝ)+1)/N := by + let A := 3*∑ e, (1+2*|J e|) + let B := |constant|+4*∑ e, (1+|J e|)^2 + let G := qmaSubdivisionWeighted left right J constant (qmaRoutingScale A B N) + have h0 := qmaSubdivision_energy_error left right hneq J constant hN + have hi := G.iterate_energy_error hN D + change |(G.iterate N D).energy-sourceMatrixBottom n (qmaExchangeMatrix left right J constant)| ≤ _ + calc + _ ≤ |(G.iterate N D).energy-G.energy| + + |G.energy-sourceMatrixBottom n (qmaExchangeMatrix left right J constant)| := abs_sub_le _ _ _ + _ ≤ (D:ℝ)/N+1/N := add_le_add hi h0 + _ = ((D:ℝ)+1)/N := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSiteProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSiteProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdbce6ac9b094b4c077fe617a73fca6c01b63efe --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSiteProgram.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDescriptorSites +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedDescriptorProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSupportDedup + +namespace OAI + +/-! Polynomial programs for the exact numeric support lists of every +time-ordered rebit term and reference edge. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDescriptors +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode + +private noncomputable def oneLabel {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea Nat.bits f) : Procedure ea (listCode Nat.bits) (fun x => [f x]) := + (Procedure.listCons Nat.bits).comp + (p.pair (Procedure.constant ea (listCode Nat.bits) [])) + +private noncomputable def consLabel {α : Type} {ea : α → List Bool} + {f : α → ℕ} {g : α → List ℕ} (p : Procedure ea Nat.bits f) + (q : Procedure ea (listCode Nat.bits) g) : + Procedure ea (listCode Nat.bits) (fun x => f x::g x) := + (Procedure.listCons Nat.bits).comp (p.pair q) + +noncomputable opaque distributedLabelsProgram : Procedure timeCode (listCode Nat.bits) + (fun x => distributedLabels x.1 x.2) := by + let c := Procedure.first circuitCode descriptorCode + let d := Procedure.second circuitCode descriptorCode + let tag := (Procedure.first Nat.bits Nat.bits).comp d + let index := (Procedure.second Nat.bits Nat.bits).comp d + let time := Procedure.unaryToBits.comp (timeProgram.comp c) + let work := Procedure.unaryToBits.comp (workProgram.comp c) + let const (n : ℕ) := Procedure.constant timeCode Nat.bits n + let offset := Procedure.binaryAdd.comp (time.pair (const 2)) + let label := Procedure.binaryAdd.comp (offset.pair index) + let fault := consLabel index (oneLabel (Procedure.successor.comp index)) + let boundary := Procedure.conditional + (Procedure.binaryEq.comp (index.pair (const 0))) (oneLabel (const 0)) + (oneLabel (Procedure.successor.comp time)) + let firstUse := Procedure.unaryToBits.comp + (QuantumFirstUseProgram.program.comp (c.pair index)) + let input := consLabel firstUse + (consLabel (Procedure.successor.comp firstUse) (oneLabel label)) + let output := consLabel time (oneLabel (Procedure.binaryAdd.comp (offset.pair work))) + let prop := QuantumHistorySiteProgram.propagationLabelsProgram.comp (c.pair index) + let test (n : ℕ) := Procedure.binaryEq.comp (tag.pair (const n)) + exact (Procedure.conditional (test 0) fault (Procedure.conditional (test 1) boundary + (Procedure.conditional (test 2) input (Procedure.conditional (test 3) output prop)))).congrFun + (by intro x; simp only [distributedLabels,Function.comp_apply,id_eq, + Nat.succ_eq_add_one,decide_eq_true_eq]) + +noncomputable opaque referenceWorkProgram : Procedure circuitCode Nat.bits referenceWork := by + let time := Procedure.unaryToBits.comp timeProgram + let work := Procedure.unaryToBits.comp workProgram + let twice := Procedure.binaryMul.comp + ((Procedure.constant circuitCode Nat.bits 2).pair time) + exact Procedure.binaryAdd.comp + ((Procedure.binaryAdd.comp (twice.pair work)).pair + (Procedure.constant circuitCode Nat.bits 4)) + +abbrev ReferenceInput := QMACircuit × ℕ +def referenceCode : ReferenceInput → List Bool := prodCode circuitCode Nat.bits + +noncomputable opaque orderedAtProgram : Procedure referenceCode descriptorCode + (fun x => orderedAt x.1 x.2) := + (Procedure.listGet descriptorCode (0,0)).comp + ((Procedure.second circuitCode Nat.bits).pair + (orderedProgram.comp (Procedure.first circuitCode Nat.bits))) + +noncomputable opaque rebitLabelsProgram : Procedure referenceCode (listCode Nat.bits) + (fun x => rebitLabels x.1 x.2) := by + let c := Procedure.first circuitCode Nat.bits + let i := Procedure.second circuitCode Nat.bits + let offset := Procedure.successor.comp (referenceWorkProgram.comp c) + let labels := distributedLabelsProgram.comp (c.pair orderedAtProgram) + let shifted := (Procedure.listMapWith (f := fun a b : ℕ => a+b) 0 0 + Procedure.binaryAdd).comp (offset.pair labels) + exact consLabel i shifted + +noncomputable opaque referenceLabelsProgram : Procedure referenceCode (listCode Nat.bits) + (fun x => referenceLabels x.1 x.2) := by + let c := Procedure.first circuitCode Nat.bits + let i := Procedure.second circuitCode Nat.bits + let cut := Procedure.successor.comp (referenceWorkProgram.comp c) + let edge := Procedure.binarySub.comp (i.pair cut) + let labels := consLabel edge (oneLabel (Procedure.successor.comp edge)) + exact (Procedure.conditional (Procedure.binaryLt.comp (i.pair cut)) rebitLabelsProgram + labels).congrFun (by + intro x + simp only [referenceLabels,Function.comp_apply,decide_eq_true_eq]) + +noncomputable opaque supportLabelsProgram : Procedure referenceCode (listCode Nat.bits) + (fun x => supportLabels x.1 x.2) := QuantumSupportDedup.program.comp referenceLabelsProgram + +noncomputable def supportCertificate : Turing.TM2ComputableInPolyTime referenceCode + (listCode Nat.bits) (fun x => supportLabels x.1 x.2) := supportLabelsProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryDescriptors + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSites.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea68fabaf9241d1337d20fdda4e70284c0bf8878 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDescriptorSites.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedDescriptors +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySiteProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedSourceIndex + +namespace OAI + +/-! The descriptor compiler computes the very same ordered support labels +as the mathematical local-history construction. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDescriptors +open QuantumHistorySiteProgram + +def distributedLabels (c : QMACircuit) (a : Descriptor) : List ℕ := + if a.1=0 then [a.2,a.2+1] else + if a.1=1 then (if a.2=0 then [0] else [c.gates.length+1]) else + if a.1=2 then + let t := QuantumFirstUseProgram.value (c,a.2) + [t,t+1,c.gates.length+2+a.2] else + if a.1=3 then [c.gates.length,c.gates.length+2+c.work] else + propagationLabels (c,a.2) + +theorem distributedLabels_actual (c : QMACircuit) (a : QMACircuitTerm c) : + distributedLabels c (encode c a) = + (QuantumOrderedSupport.distributedSites c (qmaFirstUseTime c) a).map + (distributedNumber c) := by + rcases a with i | (b | (i | (u | t))) + · rfl + · fin_cases b <;> + simp [distributedLabels,encode,QuantumOrderedSupport.distributedSites,distributedNumber] + · simp only [distributedLabels,encode] + norm_num only + rw [QuantumFirstUseProgram.value_eq] + rfl + · cases u + rfl + · simp only [distributedLabels,encode] + norm_num only + exact propagationLabels_actual c t + +def referenceWork (c : QMACircuit) : ℕ := 2*c.gates.length+c.work+4 + +theorem referenceWork_eq (c : QMACircuit) : referenceWork c=qmaHistoryReferenceWork c := rfl + +def orderedAt (c : QMACircuit) (i : ℕ) : Descriptor := + ((ordered c).drop i).headD (0,0) + +theorem orderedAt_actual (c : QMACircuit) (hT : 0 referenceWork c+1+j) + +def referenceLabels (c : QMACircuit) (i : ℕ) : List ℕ := + if i simp [QuantumOrderedSupport.siteNumber,distributedNumber,referenceWork_eq, + Nat.add_assoc] + +theorem rebitLabels_actual (c : QMACircuit) (hT : 0 + change (if i.val + change referenceLabels c (qmaHistoryReferenceWork c+1+i.val) = _ + rw [referenceLabels,ite_eq_right (by rw [referenceWork_eq]; omega)] + simp only [referenceWork_eq,Nat.add_sub_cancel_left,QuantumOrderedSupport.rawSites, + List.map_cons,List.map_nil,QuantumOrderedSupport.siteNumber,Fin.val_castSucc,Fin.val_succ] + +def supportLabels (c : QMACircuit) (i : ℕ) : List ℕ := (referenceLabels c i).dedup + +theorem supportLabels_actual (c : QMACircuit) (hT : 0 (s i).val),List.ofFn (fun i => (t i).val)) + +def table (n : ℕ) (x : TableInput) : Matrix (Fin n → Fin 2) (Fin n → Fin 2) Scalar := + fun s t => if s=t then rat (weight x.1 x.2.1 (tableData n s t x)) else rat 0 + +def tableList (n : ℕ) (x : TableInput) : List Scalar := matrixData (table n x) + +noncomputable opaque tableEntryInputProgram (n : ℕ) (s t : Fin n → Fin 2) : + Procedure tableCode inputCode (fun x => (x.1,x.2.1,tableData n s t x)) := by + let c := Procedure.first circuitCode (prodCode descriptorCode (listCode Nat.bits)) + let rest := Procedure.second circuitCode (prodCode descriptorCode (listCode Nat.bits)) + let a := (Procedure.first descriptorCode (listCode Nat.bits)).comp rest + let labels := (Procedure.second descriptorCode (listCode Nat.bits)).comp rest + let rows := Procedure.constant tableCode (listCode Nat.bits) (List.ofFn (fun i => (s i).val)) + let columns := Procedure.constant tableCode (listCode Nat.bits) (List.ofFn (fun i => (t i).val)) + exact c.pair (a.pair (labels.pair (rows.pair columns))) + +noncomputable def tableEntryProgram (n : ℕ) (s t : Fin n → Fin 2) : + Procedure tableCode scalarCode (fun x => table n x s t) := by + by_cases h : s=t + · exact (weightProgram.comp (tableEntryInputProgram n s t)).congrFun + (by intro x; simp only [table,h,ite_true,Function.comp_apply]) + · exact (Procedure.constant tableCode scalarCode (rat 0)).congrFun + (by intro x; simp only [table,h,ite_false]) + +noncomputable def tableProgram (n : ℕ) : + Procedure tableCode matrixCode (tableList n) := + QuantumFixedMatrix.dataProgram tableCode (table n) (tableEntryProgram n) + +theorem table_actual (c : QMACircuit) (hT : 0 Matrix.diagonal (d i)) = + Matrix.diagonal (fun s => ∏ i, d i (s i)) := by + ext s t + by_cases h : s = t + · subst t + simp [sourceTensor] + · rw [Matrix.diagonal_apply_ne _ h] + obtain ⟨i,hi⟩ := Function.ne_iff.mp h + exact Finset.prod_eq_zero (Finset.mem_univ i) (by simp [hi]) + +def qmaZSign (b : Fin 2) : ℂ := if b = 0 then 1 else -1 + +theorem pauliZ_diagonal : pauliZ = Matrix.diagonal qmaZSign := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [pauliZ,qmaZSign] + +theorem sourceLocalPauli_z_diagonal (n : ℕ) (i : Fin n) : + sourceLocalPauli n i 2 = Matrix.diagonal (fun s => qmaZSign (s i)) := by + have hlocal (k : Fin n) : (if k = i then pauli 2 else (1 : Matrix (Fin 2) (Fin 2) ℂ)) = + Matrix.diagonal (fun b => if k = i then qmaZSign b else 1) := by + by_cases hk : k = i + · simp only [hk,ite_true] + exact pauliZ_diagonal + · simp [hk] + unfold sourceLocalPauli + simp_rw [hlocal] + rw [sourceTensor_diagonal] + congr 1 + funext s + simp + +theorem qmaZSign_wall (a b : Fin 2) : + (1/2 : ℂ)*(1-qmaZSign a*qmaZSign b) = if a = b then 0 else 1 := by + fin_cases a <;> fin_cases b <;> norm_num [qmaZSign] + +def qmaReferenceZPenalty (n : ℕ) : + Matrix (SourceSpinBasis (n+1)) (SourceSpinBasis (n+1)) ℂ := + ∑ i : Fin n, (1/2 : ℂ) • (1-sourceLocalPauli (n+1) i.castSucc 2* + sourceLocalPauli (n+1) i.succ 2) + +theorem qmaReferenceZPenalty_diagonal (n : ℕ) : + qmaReferenceZPenalty n = qmaReferenceWallMatrix n := by + unfold qmaReferenceZPenalty + simp_rw [sourceLocalPauli_z_diagonal,Matrix.diagonal_mul_diagonal] + ext s t + by_cases h : s = t + · subst t + simp only [Matrix.sum_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply, + Matrix.one_apply_eq,Matrix.diagonal_apply_eq,qmaReferenceWallMatrix] + simp_rw [qmaZSign_wall] + simp [qmaReferenceWalls,Finset.card_filter] + · simp [Matrix.sum_apply,Matrix.smul_apply,qmaReferenceWallMatrix,h] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistinctCrossings.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistinctCrossings.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed2bfa15ccd267e0683a2730fa625d6b79c1b38b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistinctCrossings.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPairDedup +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathTable + +namespace OAI + +/-! The actual finite crossing list, with duplicates removed, enumerates +each physical crossing cell exactly once. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumDistinctCrossings +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode +open scoped Classical + +def value (x : QuantumPathTable.Input) : List Pair := + (QuantumPathTable.compile x).2.2.dedup + +noncomputable opaque program : + Procedure QuantumPathTable.inputCode (listCode pairCode) value := + QuantumPairDedup.program.comp + (((Procedure.second (listCode QuantumRoutingTable.visitCode) (listCode pairCode)).comp + (Procedure.second (listCode pairCode) + (prodCode (listCode QuantumRoutingTable.visitCode) (listCode pairCode)))).comp + QuantumPathTable.compileProgram) + +theorem nodup (x : QuantumPathTable.Input) : (value x).Nodup := List.nodup_dedup _ + +theorem mem_actual {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (es : List G.Edge) (hcover : ∀ e, e ∈ es) (p : Pair) : + p ∈ value (List.ofFn P.position,es.map P.routeList) ↔ P.IsCrossing p := by + rw [value,List.mem_dedup] + exact QuantumPathTable.compile_crossings P es hcover p + +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + (es : List G.Edge) (hcover : ∀ e, e ∈ es) + +def cell (i : Fin (value (List.ofFn P.position,es.map P.routeList)).length) : P.Crossing := + ⟨(value (List.ofFn P.position,es.map P.routeList)).get i, + P.mem_crossingCells.mpr ((mem_actual P es hcover _).mp (List.get_mem _ i))⟩ + +theorem cell_bijective : Function.Bijective (cell P es hcover) := by + constructor + · intro i j hij + exact (nodup _).injective_get (congrArg Subtype.val hij) + · intro c + have hc : c.val ∈ value (List.ofFn P.position,es.map P.routeList) := + (mem_actual P es hcover _).mpr (P.mem_crossingCells.mp c.property) + obtain ⟨i,hi⟩ := List.mem_iff_get.mp hc + exact ⟨i,Subtype.ext hi⟩ + +def cellsEquiv : Fin (value (List.ofFn P.position,es.map P.routeList)).length ≃ P.Crossing := + Equiv.ofBijective (cell P es hcover) (cell_bijective P es hcover) + +theorem list_eq : value (List.ofFn P.position,es.map P.routeList)= + List.ofFn (fun i => (cellsEquiv P es hcover i).val) := + (List.ofFn_get _).symm + +end ContinuumCoulomb.QuantumDistinctCrossings + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedClock.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedClock.lean new file mode 100644 index 0000000000000000000000000000000000000000..873ae3e7b1b7877552db5f5da5d48c6373e0b4f5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedClock.lean @@ -0,0 +1,135 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumWireIntertwining +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumUnaryEmbedding + +namespace OAI + +/-! Local initialization checks at arbitrary unary-clock positions. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaClockAt (T : ℕ) (t : Fin (T+1)) (s : SourceSpinBasis (T+2)) : Prop := + s t.castSucc = 1 ∧ s t.succ = 0 + +theorem qmaClockAt_history (T : ℕ) (t u : Fin (T+1)) : + qmaClockAt T t (qmaHistoryClock T u) ↔ u = t := by + simp only [qmaClockAt,qmaHistoryClock,qmaUnaryClock,Fin.val_castSucc,Fin.val_succ] + constructor + · intro ⟨h₁,h₂⟩ + have ha : t.val < u.val+1 := by + by_contra h + simp [h] at h₁ + have hb : ¬t.val+1 < u.val+1 := by + intro h + simp [h] at h₂ + apply Fin.ext + omega + · rintro rfl + simp + +def qmaUnaryDistributedInput (c : QMACircuit) (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (u : QMAUnaryBasis c → ℂ) : ℝ := + ∑ i : Fin (c.work+1), ∑ s : SourceSpinBasis (c.gates.length+2), + if qmaClockAt c.gates.length (τ i) s then + ∑ a : SourceSpinBasis (c.work+1), if qmaInputCheck c i a then + Complex.normSq (u (s,a)) else 0 else 0 + +theorem qmaUnaryDistributedInput_nonneg (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : + 0 ≤ qmaUnaryDistributedInput c τ u := by + unfold qmaUnaryDistributedInput + apply Finset.sum_nonneg + intro i _ + apply Finset.sum_nonneg + intro s _ + split + · apply Finset.sum_nonneg + intro a _ + split + · exact Complex.normSq_nonneg _ + · exact le_rfl + · exact le_rfl + +theorem qmaUnaryDistributedInput_restrict (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : + qmaDistributedInput c (fun i => (τ i).val) + (qmaHistoryFromVector c (qmaUnaryRestrict c u)) ≤ qmaUnaryDistributedInput c τ u := by + unfold qmaDistributedInput qmaUnaryDistributedInput + apply Finset.sum_le_sum + intro i _ + rw [qmaMask_norm_sq] + have h := Finset.single_le_sum + (f := fun s : SourceSpinBasis (c.gates.length+2) => + if qmaClockAt c.gates.length (τ i) s then + ∑ a : SourceSpinBasis (c.work+1), if qmaInputCheck c i a then + Complex.normSq (u (s,a)) else 0 else 0) + (s := Finset.univ) (a := qmaHistoryClock c.gates.length (τ i)) + (by + intro s _ + split + · apply Finset.sum_nonneg + intro a _ + split + · exact Complex.normSq_nonneg _ + · exact le_rfl + · exact le_rfl) (Finset.mem_univ _) + have hs : (∑ a : SourceSpinBasis (c.work+1), + if qmaInputCheck c i a then + ‖qmaHistoryFromVector c (qmaUnaryRestrict c u) (τ i).val a‖^2 else 0) = + ∑ a : SourceSpinBasis (c.work+1), if qmaInputCheck c i a then + Complex.normSq (u (qmaHistoryClock c.gates.length (τ i),a)) else 0 := by + apply Finset.sum_congr rfl + intro a _ + rw [qmaHistoryFromVector_fin] + simp only [qmaUnaryRestrict,Complex.sq_norm] + rw [hs] + simpa only [qmaClockAt_history,ite_true] using h + +def qmaUnaryDistributedEnergy (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : ℝ := + qmaUnaryClockEnergy c u+qmaUnaryOutputEnergy c u+14*qmaUnaryDistributedInput c τ u+ + (14*(c.work+1)+8)*c.gates.length*qmaUnaryPropagationEnergy c u + +theorem qmaUnaryDistributedEnergy_restrict (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : + qmaDistributedHistoryEnergy c (fun i => (τ i).val) + (qmaHistoryFromVector c (qmaUnaryRestrict c u))+qmaUnaryClockEnergy c u ≤ + qmaUnaryDistributedEnergy c τ u := by + have hi := qmaUnaryDistributedInput_restrict c τ u + have ho := qmaUnaryOutputEnergy_valid_le c u + have hp := mul_le_mul_of_nonneg_left (qmaUnaryPropagationEnergy_valid_le c u) + (by positivity : 0 ≤ (14*(c.work+1)+8:ℝ)*c.gates.length) + unfold qmaDistributedHistoryEnergy qmaUnaryDistributedEnergy + linarith + +theorem qmaUnaryDistributedEnergy_sound (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) (u : QMAUnaryBasis c → ℂ) : + 2*qmaUnaryMass c u ≤ 5*(c.gates.length+1:ℝ)*qmaUnaryDistributedEnergy c τ u := by + have hs := qmaDistributedHistoryEnergy_sound_untouched c hc (fun i => (τ i).val) + (fun i => Nat.le_of_lt_succ (τ i).isLt) hi hsound + (qmaHistoryFromVector c (qmaUnaryRestrict c u)) + rw [qmaHistoryFromVector_mass] at hs + simp only [EuclideanSpace.norm_sq_eq,Complex.sq_norm] at hs + have hb := qmaUnaryInvalidMass_le c u + have hn := qmaUnaryInvalidMass_nonneg c u + have hcoef : (2:ℝ) ≤ 5*(c.gates.length+1:ℝ) := by + have h := Nat.cast_nonneg (α := ℝ) c.gates.length + linarith + have hb' : 2*qmaUnaryInvalidMass c u ≤ + 5*(c.gates.length+1:ℝ)*qmaUnaryClockEnergy c u := + (mul_le_mul_of_nonneg_right hcoef hn).trans + (mul_le_mul_of_nonneg_left hb (by positivity)) + have he := mul_le_mul_of_nonneg_left (qmaUnaryDistributedEnergy_restrict c τ u) + (by positivity : 0 ≤ 5*(c.gates.length+1:ℝ)) + rw [qmaUnaryMass_split] + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedFamily.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..c86b7536451f7d5c076228c176f6cc1d8f05e4fb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedFamily.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedSpectrum +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalFamily + +namespace OAI + +/-! A linear-size, five-local term family with distributed initialization checks. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaDistributedQubitHamiltonian (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + Matrix (QMACircuitQubit c → Fin 2) (QMACircuitQubit c → Fin 2) ℂ := + (qmaUnaryDistributedHamiltonian c τ).submatrix (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) + +theorem qmaDistributedQubitHamiltonian_decomposition (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + qmaDistributedQubitHamiltonian c τ = + ((∑ i : Fin (c.gates.length+1), qmaClockFaultTerm c i)+qmaClockLeftTerm c+qmaClockRightTerm c)+ + qmaOutputTerm c+(∑ i : Fin (c.work+1), qmaDistributedInputTerm c τ i)+ + ((14*(c.work+1)+8)*c.gates.length:ℂ) • ∑ t : Fin c.gates.length, + (qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t := by + unfold qmaDistributedQubitHamiltonian qmaUnaryDistributedHamiltonian + simp only [qmaSubmatrix_add] + rw [qmaUnaryClockDiagonal_reindex,qmaUnaryOutputDiagonal_reindex, + qmaUnaryDistributedInput_reindex,qmaSubmatrix_smul,qmaUnaryPropagationGram_reindex] + +def qmaDistributedTermSites (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : QMACircuitTerm c → Finset (QMACircuitQubit c) + | .inr (.inr (.inl i)) => qmaDistributedInputSites c τ i + | t => qmaCircuitTermSites c t + +def qmaDistributedTermMatrix (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : QMACircuitTerm c → + Matrix (QMACircuitQubit c → Fin 2) (QMACircuitQubit c → Fin 2) ℂ + | .inl i => qmaClockFaultTerm c i + | .inr (.inl b) => if b = 0 then qmaClockLeftTerm c else qmaClockRightTerm c + | .inr (.inr (.inl i)) => qmaDistributedInputTerm c τ i + | .inr (.inr (.inr (.inl _))) => qmaOutputTerm c + | .inr (.inr (.inr (.inr t))) => + ((14*(c.work+1)+8)*c.gates.length:ℂ) • + ((qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t) + +theorem qmaDistributedTerm_local (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (t : QMACircuitTerm c) : + QMALocalOn (qmaDistributedTermSites c τ t) (qmaDistributedTermMatrix c τ t) := by + rcases t with i | (b | (i | (u | t))) + · exact qmaClockFaultTerm_local c i + · fin_cases b + · exact qmaClockLeftTerm_local c + · exact qmaClockRightTerm_local c + · exact qmaDistributedInputTerm_local c τ i + · exact qmaOutputTerm_local c + · exact (qmaLocalPropagationGram_local c t).smul _ + +theorem qmaDistributedTerm_support_card (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (t : QMACircuitTerm c) : + (qmaDistributedTermSites c τ t).card ≤ 5 := by + rcases t with i | (b | (i | (u | t))) + · exact qmaCircuitTerm_support_card c (.inl i) + · exact qmaCircuitTerm_support_card c (.inr (.inl b)) + · change (qmaDistributedInputSites c τ i).card ≤ 5 + rw [qmaDistributedInputSites_card] + norm_num + · exact qmaCircuitTerm_support_card c (.inr (.inr (.inr (.inl u)))) + · exact qmaPropagationSites_card c t + +theorem qmaDistributedTerm_hermitian (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (t : QMACircuitTerm c) : + (qmaDistributedTermMatrix c τ t).IsHermitian := by + rcases t with i | (b | (i | (u | t))) + · exact qmaCircuitTerm_hermitian c (.inl i) + · exact qmaCircuitTerm_hermitian c (.inr (.inl b)) + · apply Matrix.isHermitian_diagonal_iff.mpr + intro s + split_ifs <;> simp + · exact qmaCircuitTerm_hermitian c (.inr (.inr (.inr (.inl u)))) + · exact (Matrix.isHermitian_conjTranspose_mul_self _).smul (by simp [isSelfAdjoint_iff]) + +theorem qmaDistributedTerm_sum (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + (∑ t : QMACircuitTerm c, qmaDistributedTermMatrix c τ t) = + qmaDistributedQubitHamiltonian c τ := by + rw [qmaDistributedQubitHamiltonian_decomposition] + have h10 : (1:Fin 2) ≠ 0 := by decide + simp only [Fintype.sum_sum_type,qmaDistributedTermMatrix,Fin.sum_univ_two, + Fin.isValue,ite_true,h10,ite_false,Finset.univ_unique,Finset.sum_singleton, + ←Finset.smul_sum] + ext s t + simp only [Matrix.add_apply,Matrix.smul_apply,smul_eq_mul] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..3afcea66696915f34ac5458fac2edd9acab0a152 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedGap.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumQuadraticReindex + +namespace OAI + +/-! The distributed history bounds transported to the actual tensor-qubit basis. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaDistributedQubit_lower (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : (QMACircuitQubit c → Fin 2) → ℂ) : + (2/(5*(c.gates.length+1:ℝ)))*(∑ i, Complex.normSq (u i)) ≤ + qmaQuadratic (qmaDistributedQubitHamiltonian c τ) u := by + let e := qmaCircuitQubitSplit c + have h := qmaUnaryDistributedHamiltonian_sound c hc τ hi hsound + (WithLp.toLp 2 (u ∘ e.symm)) + simp only [EuclideanSpace.norm_sq_eq,Complex.sq_norm] at h + have hm : (∑ i, Complex.normSq ((u ∘ e.symm) i)) = ∑ i, Complex.normSq (u i) := + qmaMass_reindex e u + rw [hm] at h + unfold qmaDistributedQubitHamiltonian + rw [qmaQuadratic_reindex_equiv] + have hd : 0 < 5*(c.gates.length+1:ℝ) := by positivity + calc + _ = (2*(∑ i, Complex.normSq (u i)))/(5*(c.gates.length+1:ℝ)) := by ring + _ ≤ _ := (div_le_iff₀ hd).mpr (by simpa only [mul_comm] using h) + +theorem qmaDistributedQubit_accepting (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : (QMACircuitQubit c → Fin 2) → ℂ, + (∑ i, Complex.normSq (u i)) = 1 ∧ + 3*(c.gates.length+1:ℝ)*qmaQuadratic (qmaDistributedQubitHamiltonian c τ) u ≤ 1 := by + obtain ⟨v,hv,he⟩ := qmaUnaryDistributedHamiltonian_accepting c hc τ hi psi hpsi hacc + let e := qmaCircuitQubitSplit c + refine ⟨(fun s => v (e s)),?_,?_⟩ + · have hm := e.sum_comp (fun p => Complex.normSq (v p)) + rw [hm] + have hn := congrArg (fun t : ℝ => t^2) hv + simpa only [EuclideanSpace.norm_sq_eq,Complex.sq_norm,one_pow] using hn + · unfold qmaDistributedQubitHamiltonian + rw [qmaQuadratic_reindex_equiv] + have hh : (fun s => v (e s)) ∘ e.symm = fun p => v p := by funext p; simp + rw [hh] + exact he + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb58ce61cbfd00c9d56a117e249419ac5e6b91ca --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedInput.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalInput + +namespace OAI + +/-! Input checks may occur at separate history times before their qubits are changed. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaInputCheck (c : QMACircuit) (i : Fin (c.work+1)) (s : SourceSpinBasis (c.work+1)) : Prop := + c.witness ≤ i.val ∧ s i ≠ 0 + +theorem qmaMask_norm_sq {n : ℕ} (p : SourceSpinBasis n → Prop) + (u : EuclideanSpace ℂ (SourceSpinBasis n)) : + ‖qmaMask p u‖^2 = ∑ s, if p s then ‖u s‖^2 else 0 := by + rw [EuclideanSpace.norm_sq_eq] + apply Finset.sum_congr rfl + intro s _ + by_cases hs : p s <;> simp [qmaMask_apply,hs] + +theorem qmaInputPenalty_le_checks (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaInputPenalty c u ≤ ∑ i : Fin (c.work+1), ‖qmaMask (qmaInputCheck c i) (u 0)‖^2 := by + simp only [qmaInputPenalty,qmaMask_norm_sq] + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro s _ + have h := mul_le_mul_of_nonneg_right (qmaAncillaCount_dominates c s) (sq_nonneg ‖u 0 s‖) + have hs : (∑ i : Fin (c.work+1), if qmaInputCheck c i s then ‖u 0 s‖^2 else 0) = + qmaAncillaCount c s*‖u 0 s‖^2 := by + rw [qmaAncillaCount,Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + by_cases hi : c.witness ≤ i.val ∧ s i ≠ 0 + · simp [qmaInputCheck,hi] + · simp [qmaInputCheck,hi] + rw [hs] + convert h using 1 + by_cases hc : QMAAncillaZero c s <;> simp [hc] + +def qmaDistributedInput (c : QMACircuit) (τ : Fin (c.work+1) → ℕ) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + ∑ i : Fin (c.work+1), ‖qmaMask (qmaInputCheck c i) (u (τ i))‖^2 + +theorem qmaInputPenalty_le_distributed (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → ℕ) (hτ : ∀ i, τ i ≤ c.gates.length) + (hcheck : ∀ (i : Fin (c.work+1)) (v : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))), + ‖qmaMask (qmaInputCheck c i) (qmaApplyMatrix (qmaPrefixMatrix c (τ i)) v)‖ = + ‖qmaMask (qmaInputCheck c i) v‖) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaInputPenalty c u ≤ 2*qmaDistributedInput c τ u+ + 2*(c.work+1:ℝ)*c.gates.length*qmaPropagationEnergy c u := by + apply (qmaInputPenalty_le_checks c u).trans + have h (i : Fin (c.work+1)) : ‖qmaMask (qmaInputCheck c i) (u 0)‖^2 ≤ + 2*‖qmaMask (qmaInputCheck c i) (u (τ i))‖^2+ + 2*c.gates.length*qmaPropagationEnergy c u := by + let v := qmaApplyMatrix (qmaPrefixMatrix c (τ i)) (u 0) + have hd := pow_le_pow_left₀ (norm_nonneg _) + (qmaMask_sub_norm_le (qmaInputCheck c i) v (u (τ i))) 2 + rw [norm_sub_rev v] at hd + have ha := qma_history_anchor_bound c hc u (τ i) (hτ i) + have hs := norm_add_sq_two (qmaMask (qmaInputCheck c i) (u (τ i))) + (qmaMask (qmaInputCheck c i) v-qmaMask (qmaInputCheck c i) (u (τ i))) + rw [add_sub_cancel, hcheck i (u 0)] at hs + dsimp only [v] at hd + linarith + calc + _ ≤ ∑ i : Fin (c.work+1), + (2*‖qmaMask (qmaInputCheck c i) (u (τ i))‖^2+ + 2*c.gates.length*qmaPropagationEnergy c u) := Finset.sum_le_sum (fun i _ => h i) + _ = _ := by + simp only [Finset.sum_add_distrib,← Finset.mul_sum,Finset.sum_const,Finset.card_univ, + Fintype.card_fin,nsmul_eq_mul,qmaDistributedInput] + push_cast + ring + +def qmaDistributedHistoryEnergy (c : QMACircuit) (τ : Fin (c.work+1) → ℕ) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + qmaOutputPenalty c u+14*qmaDistributedInput c τ u+ + (14*(c.work+1)+8)*c.gates.length*qmaPropagationEnergy c u + +theorem qmaDistributedHistoryEnergy_sound (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → ℕ) (hτ : ∀ i, τ i ≤ c.gates.length) + (hcheck : ∀ (i : Fin (c.work+1)) (v : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))), + ‖qmaMask (qmaInputCheck c i) (qmaApplyMatrix (qmaPrefixMatrix c (τ i)) v)‖ = + ‖qmaMask (qmaInputCheck c i) v‖) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + 2*qmaHistoryMass c u ≤ 5*(c.gates.length+1:ℝ)*qmaDistributedHistoryEnergy c τ u := by + have h := qmaInputPenalty_le_distributed c hc τ hτ hcheck u + have he : qmaHistoryEnergy c u ≤ qmaDistributedHistoryEnergy c τ u := by + unfold qmaHistoryEnergy qmaDistributedHistoryEnergy + nlinarith + exact (qma_history_energy_sound c hc hsound u).trans + (mul_le_mul_of_nonneg_left he (by positivity)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..619015e7890ba2166e69501668fc55343c5816b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedMatrix.lean @@ -0,0 +1,120 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedWitness +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalDecomposition + +namespace OAI + +/-! The distributed-input history is an actual Hermitian matrix on all unary strings. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaUnaryDistributedDiagonal (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (p : QMAUnaryBasis c) : ℝ := + ∑ i : Fin (c.work+1), if qmaClockAt c.gates.length (τ i) p.1 ∧ + qmaInputCheck c i p.2 then 1 else 0 + +theorem qmaUnaryDistributedDiagonal_form (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : + qmaQuadratic (Matrix.diagonal (fun p => (qmaUnaryDistributedDiagonal c τ p : ℂ))) u = + qmaUnaryDistributedInput c τ u := by + rw [qmaQuadratic_diagonal_real] + simp only [qmaUnaryDistributedDiagonal,Finset.sum_mul,ite_mul,one_mul,zero_mul] + rw [Finset.sum_comm] + simp only [Fintype.sum_prod_type,ite_and,Finset.sum_ite_irrel,Finset.sum_const_zero, + qmaUnaryDistributedInput] + +def qmaUnaryDistributedHamiltonian (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : Matrix (QMAUnaryBasis c) (QMAUnaryBasis c) ℂ := + Matrix.diagonal (fun p => (qmaUnaryClockDiagonal c p : ℂ))+ + Matrix.diagonal (fun p => (qmaUnaryOutputDiagonal c p : ℂ))+ + (14:ℂ) • Matrix.diagonal (fun p => (qmaUnaryDistributedDiagonal c τ p : ℂ))+ + ((14*(c.work+1)+8)*c.gates.length:ℂ) • + ((qmaUnaryPropagationMatrix c).conjTranspose*qmaUnaryPropagationMatrix c) + +theorem qmaUnaryDistributedHamiltonian_hermitian (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + (qmaUnaryDistributedHamiltonian c τ).IsHermitian := by + have hd (d : QMAUnaryBasis c → ℝ) : (Matrix.diagonal (fun p => (d p : ℂ))).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro p + simp [isSelfAdjoint_iff] + exact (((hd _).add (hd _)).add ((hd _).smul (by simp))).add + ((Matrix.isHermitian_conjTranspose_mul_self (qmaUnaryPropagationMatrix c)).smul + (by simp [isSelfAdjoint_iff])) + +theorem qmaUnaryDistributedHamiltonian_form (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAUnaryBasis c → ℂ) : + qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) u = qmaUnaryDistributedEnergy c τ u := by + unfold qmaUnaryDistributedHamiltonian + rw [qmaQuadratic_add,qmaQuadratic_add,qmaQuadratic_add] + have hs : ((14*(c.work+1)+8)*c.gates.length:ℂ) = + (((14*(c.work+1)+8)*c.gates.length:ℝ):ℂ) := by push_cast; rfl + rw [hs,show (14:ℂ) = ((14:ℝ):ℂ) from rfl,qmaQuadratic_smul,qmaQuadratic_smul, + qmaUnaryDistributedDiagonal_form,qmaQuadratic_diagonal_real, + qmaQuadratic_diagonal_real,qmaUnaryPropagationMatrix_form] + simp only [qmaUnaryDistributedEnergy,qmaUnaryClockEnergy,qmaUnaryOutputEnergy, + qmaUnaryClockDiagonal,qmaUnaryOutputDiagonal,Fintype.sum_prod_type, + ite_mul,one_mul,zero_mul,ite_and,Finset.sum_ite_irrel,Finset.sum_const_zero,Finset.mul_sum] + +def qmaDistributedInputSites (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (i : Fin (c.work+1)) : + Finset (QMACircuitQubit c) := + {Sum.inl (τ i).castSucc,Sum.inl (τ i).succ,Sum.inr i} + +def qmaDistributedInputTerm (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (i : Fin (c.work+1)) : + Matrix (QMACircuitQubit c → Fin 2) (QMACircuitQubit c → Fin 2) ℂ := + Matrix.diagonal (fun s => if qmaClockAt c.gates.length (τ i) (s ∘ Sum.inl) ∧ + qmaInputCheck c i (s ∘ Sum.inr) then 14 else 0) + +theorem qmaDistributedInputTerm_local (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (i : Fin (c.work+1)) : + QMALocalOn (qmaDistributedInputSites c τ i) (qmaDistributedInputTerm c τ i) := by + apply qmaLocalOn_diagonal + intro s r h + have hl := h (Sum.inl (τ i).castSucc) (by simp [qmaDistributedInputSites]) + have hr := h (Sum.inl (τ i).succ) (by simp [qmaDistributedInputSites]) + have hi := h (Sum.inr i) (by simp [qmaDistributedInputSites]) + apply ite_congr + · simp only [qmaClockAt,qmaInputCheck,Function.comp_apply,hl,hr,hi] + · intro _; rfl + · intro _; rfl + +theorem qmaDistributedInputSites_card (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (i : Fin (c.work+1)) : + (qmaDistributedInputSites c τ i).card = 3 := by + have ht : (τ i).castSucc ≠ (τ i).succ := by + intro h + have := congrArg Fin.val h + simp at this + simp [qmaDistributedInputSites,ht] + +theorem qmaUnaryDistributedInput_reindex (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + ((14:ℂ) • Matrix.diagonal (fun p => (qmaUnaryDistributedDiagonal c τ p : ℂ))).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = + ∑ i : Fin (c.work+1), qmaDistributedInputTerm c τ i := by + rw [qmaSubmatrix_smul,Matrix.submatrix_diagonal_equiv] + ext s r + by_cases h : s = r + · subst r + simp only [Matrix.smul_apply,smul_eq_mul,Matrix.sum_apply,qmaDistributedInputTerm, + Matrix.diagonal_apply_eq,qmaUnaryDistributedDiagonal,Complex.ofReal_sum,Function.comp_apply,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + have hs : (qmaCircuitQubitSplit c s).1 = s ∘ Sum.inl := rfl + have hr : (qmaCircuitQubitSplit c s).2 = s ∘ Sum.inr := rfl + rw [hs,hr] + by_cases hp : qmaClockAt c.gates.length (τ i) (s ∘ Sum.inl) ∧ + qmaInputCheck c i (s ∘ Sum.inr) + · simp [hp] + · simp [hp] + · simp [Matrix.smul_apply,h,Matrix.sum_apply,qmaDistributedInputTerm] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedPositive.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..21bcb2a85c0d8a9680f5d3e31d9de5fe85e40003 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedPositive.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumReferenceLower +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedFamily + +namespace OAI + +/-! Every concrete distributed-history term is positive semidefinite. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaDiagonalBranch_nonnegative {α : Type*} [Fintype α] [DecidableEq α] + (p : α → Prop) (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) (u : α → ℂ) : + 0 ≤ qmaQuadratic (Matrix.diagonal (fun s => if p s then (a:ℂ) else (b:ℂ))) u := by + have he : (fun s => if p s then (a:ℂ) else (b:ℂ)) = + (fun s => ((if p s then a else b : ℝ):ℂ)) := by + funext s + split_ifs <;> rfl + rw [he,qmaQuadratic_diagonal_real] + apply Finset.sum_nonneg + intro s _ + apply mul_nonneg _ (Complex.normSq_nonneg _) + split_ifs <;> assumption + +theorem qmaDistributedTerm_nonnegative (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (t : QMACircuitTerm c) + (u : (QMACircuitQubit c → Fin 2) → ℂ) : + 0 ≤ qmaQuadratic (qmaDistributedTermMatrix c τ t) u := by + rcases t with i | (b | (i | (v | t))) + · change 0 ≤ qmaQuadratic (qmaClockFaultTerm c i) u + unfold qmaClockFaultTerm qmaPairDiagonal + simp only [qmaQuadratic,Matrix.mulVec_diagonal,dotProduct,Pi.star_apply,Complex.re_sum] + apply Finset.sum_nonneg + intro s _ + split_ifs <;> simp [Complex.mul_re] + all_goals nlinarith [sq_nonneg (u s).re,sq_nonneg (u s).im] + · fin_cases b + · change 0 ≤ qmaQuadratic (qmaClockLeftTerm c) u + unfold qmaClockLeftTerm qmaBitDiagonal + simp only [qmaQuadratic,Matrix.mulVec_diagonal,dotProduct,Pi.star_apply,Complex.re_sum] + apply Finset.sum_nonneg + intro s _ + split_ifs <;> simp [Complex.mul_re] + all_goals nlinarith [sq_nonneg (u s).re,sq_nonneg (u s).im] + · change 0 ≤ qmaQuadratic (qmaClockRightTerm c) u + unfold qmaClockRightTerm qmaBitDiagonal + simp only [qmaQuadratic,Matrix.mulVec_diagonal,dotProduct,Pi.star_apply,Complex.re_sum] + apply Finset.sum_nonneg + intro s _ + split_ifs <;> simp [Complex.mul_re] + all_goals nlinarith [sq_nonneg (u s).re,sq_nonneg (u s).im] + · change 0 ≤ qmaQuadratic (qmaDistributedInputTerm c τ i) u + unfold qmaDistributedInputTerm + simp only [qmaQuadratic,Matrix.mulVec_diagonal,dotProduct,Pi.star_apply,Complex.re_sum] + apply Finset.sum_nonneg + intro s _ + split_ifs <;> simp [Complex.mul_re] + all_goals nlinarith [sq_nonneg (u s).re,sq_nonneg (u s).im] + · change 0 ≤ qmaQuadratic (qmaOutputTerm c) u + unfold qmaOutputTerm qmaPairDiagonal + simp only [qmaQuadratic,Matrix.mulVec_diagonal,dotProduct,Pi.star_apply,Complex.re_sum] + apply Finset.sum_nonneg + intro s _ + split_ifs <;> simp [Complex.mul_re] + all_goals nlinarith [sq_nonneg (u s).re,sq_nonneg (u s).im] + · change 0 ≤ qmaQuadratic (((14*(c.work+1)+8)*c.gates.length:ℂ) • + ((qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t)) u + have he : ((14*(c.work+1)+8)*c.gates.length:ℂ) = + (((14*(c.work+1)+8)*c.gates.length:ℝ):ℂ) := by push_cast; rfl + rw [he,qmaQuadratic_smul,qmaQuadratic_gram] + exact mul_nonneg (by positivity) (Finset.sum_nonneg (fun _ _ => Complex.normSq_nonneg _)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedRebit.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedRebit.lean new file mode 100644 index 0000000000000000000000000000000000000000..401aa5af4ac0d8987a87324727595c931b4e6f74 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedRebit.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumReferencePenalty + +namespace OAI + +/-! Each complex term uses its own local Y reference; uniform sectors recover it exactly. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Kronecker Classical +variable {α : Type*} [Fintype α] [DecidableEq α] + +def qmaDistributedRebitTerm (n : ℕ) (i : Fin n) (A : Matrix α α ℂ) : + Matrix (SourceSpinBasis n × α) (SourceSpinBasis n × α) ℂ := + (1 : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) ⊗ₖ qmaEntryReal A + + (-Complex.I) • (sourceLocalPauli n i 1 ⊗ₖ qmaEntryImag A) + +def qmaReferenceExtension (n : ℕ) : + Matrix (SourceSpinBasis n × α) (SourceSpinBasis n × α) ℂ := + qmaReferenceTensor n ⊗ₖ (1 : Matrix α α ℂ) + +theorem qmaDistributedRebitTerm_diagonalized (n : ℕ) (i : Fin n) (A : Matrix α α ℂ) : + (qmaReferenceExtension (α := α) n).conjTranspose*qmaDistributedRebitTerm n i A* + qmaReferenceExtension (α := α) n = + (1 : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) ⊗ₖ qmaEntryReal A + + (-Complex.I) • (sourceLocalPauli n i 2 ⊗ₖ qmaEntryImag A) := by + unfold qmaReferenceExtension qmaDistributedRebitTerm + rw [Matrix.conjTranspose_kronecker,Matrix.conjTranspose_one,Matrix.mul_add,Matrix.add_mul, + mul_smul_comm,smul_mul_assoc] + simp only [←Matrix.mul_kronecker_mul,mul_one,one_mul,qmaReferenceTensor_gram, + qmaReferenceTensor_y] + +theorem qmaDistributedRebitTerm_block (n : ℕ) (i : Fin n) (A : Matrix α α ℂ) + (s t : SourceSpinBasis n) (a b : α) : + ((qmaReferenceExtension (α := α) n).conjTranspose*qmaDistributedRebitTerm n i A* + qmaReferenceExtension (α := α) n) (s,a) (t,b) = + if s = t then (if s i = 0 then star (A a b) else A a b) else 0 := by + rw [qmaDistributedRebitTerm_diagonalized,sourceLocalPauli_z_diagonal] + by_cases h : s = t + · subst t + simp only [Matrix.add_apply,Matrix.kronecker_apply,Matrix.one_apply_eq, + Matrix.diagonal_apply_eq,Matrix.smul_apply,smul_eq_mul,one_mul,qmaEntryReal,qmaEntryImag] + simp only [ite_true] + generalize hb : s i = c + fin_cases c <;> apply Complex.ext <;> simp [qmaZSign,Complex.mul_re,Complex.mul_im] + · simp [Matrix.add_apply,h] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedSpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..96c147b8484749b2e8b9313a5078c46e209e8493 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedSpectrum.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedMatrix + +namespace OAI + +/-! The distributed-input Hamiltonian retains the verifier's inverse-polynomial gap. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +theorem qmaDistributedHistoryVector_energy (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaDistributedHistoryEnergy c (fun i => (τ i).val) + (qmaHistoryFromVector c (fun p => qmaHistoryVector c u p)) = + qmaDistributedHistoryEnergy c (fun i => (τ i).val) u := by + unfold qmaDistributedHistoryEnergy qmaOutputPenalty qmaDistributedInput + rw [qmaHistoryVector_propagation,qmaHistoryVector_slice c u c.gates.length le_rfl] + simp_rw [qmaHistoryVector_slice c u (τ _).val (Nat.le_of_lt_succ (τ _).isLt)] + +theorem qmaUnaryDistributedHamiltonian_sound (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : EuclideanSpace ℂ (QMAUnaryBasis c)) : + 2*‖u‖^2 ≤ 5*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => u p) := by + rw [qmaUnaryDistributedHamiltonian_form,←qmaUnaryMass_norm] + exact qmaUnaryDistributedEnergy_sound c hc τ hi hsound (fun p => u p) + +theorem qmaUnaryDistributedHamiltonian_accepting (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : EuclideanSpace ℂ (QMAUnaryBasis c), ‖u‖ = 1 ∧ + 3*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => u p) ≤ 1 := by + let v := qmaHistoryVector c (qmaIdealHistory c hc psi) + let w : EuclideanSpace ℂ (QMAUnaryBasis c) := WithLp.toLp 2 (qmaUnaryExtend c (fun p => v p)) + have hw : ‖w‖^2 = (c.gates.length+1:ℝ) := by + rw [←qmaUnaryMass_norm] + change qmaUnaryMass c (qmaUnaryExtend c (fun p => v p)) = _ + rw [qmaUnaryExtend_mass] + have hv := qmaHistoryVector_norm c (qmaIdealHistory c hc psi) + rw [qmaIdealHistory_mass,hpsi] at hv + simpa only [v,EuclideanSpace.norm_sq_eq,Complex.sq_norm,one_pow,mul_one] using hv + have he : qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => w p) = + ‖qmaRejectVector c hc psi‖^2 := by + rw [qmaUnaryDistributedHamiltonian_form] + change qmaUnaryDistributedEnergy c τ (qmaUnaryExtend c (fun p => v p)) = _ + rw [qmaUnaryExtend_distributed_energy] + change qmaDistributedHistoryEnergy c (fun i => (τ i).val) + (qmaHistoryFromVector c (fun p => qmaHistoryVector c (qmaIdealHistory c hc psi) p)) = _ + rw [qmaDistributedHistoryVector_energy,qmaIdealHistory_distributed_energy c hc τ hi] + have hn : ‖w‖ ≠ 0 := by + intro h + rw [h] at hw + have hp : (0:ℝ) < c.gates.length+1 := by positivity + norm_num at hw + linarith + let u := ((‖w‖⁻¹:ℝ):ℂ) • w + refine ⟨u,by simp [u,norm_smul,hn],?_⟩ + have hq : qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => u p) = + (‖w‖⁻¹)^2*qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => w p) := by + exact qmaQuadratic_vector_smul _ _ _ + have hb : 3*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaUnaryDistributedHamiltonian c τ) (fun p => w p) ≤ ‖w‖^2 := by + rw [he,hw] + have h := mul_le_mul_of_nonneg_left (qmaRejectVector_of_accept c hc psi hpsi hacc) + (by positivity : 0 ≤ 3*(c.gates.length+1:ℝ)) + nlinarith + have h := mul_le_mul_of_nonneg_left hb (sq_nonneg (‖w‖⁻¹)) + have heq : (‖w‖⁻¹)^2*‖w‖^2 = 1 := by field_simp + rw [hq] + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedWitness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..40344196cb09c2cdc339fcd930eb43bd0c280b85 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumDistributedWitness.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedClock +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumUnaryEmbeddingEnergy + +namespace OAI + +/-! Accepting histories retain exactly their output energy under distributed checks. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaUnaryExtend_distributed_input (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAHistoryBasis c → ℂ) : + qmaUnaryDistributedInput c τ (qmaUnaryExtend c u) = + qmaDistributedInput c (fun i => (τ i).val) (qmaHistoryFromVector c u) := by + unfold qmaUnaryDistributedInput qmaDistributedInput + apply Finset.sum_congr rfl + intro i _ + have h := qmaUnaryExtend_weighted_sum c u (fun s a => + if qmaClockAt c.gates.length (τ i) s ∧ qmaInputCheck c i a then 1 else 0) + simp only [ite_mul,one_mul,zero_mul,ite_and,Finset.sum_ite_irrel, + Finset.sum_const_zero,qmaClockAt_history] at h + rw [qmaMask_norm_sq] + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true] at h + rw [h] + apply Finset.sum_congr rfl + intro a _ + rw [qmaHistoryFromVector_fin] + simp only [Complex.sq_norm] + +theorem qmaInputVector_single_check_zero (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (i : Fin (c.work+1)) : + qmaMask (qmaInputCheck c i) (qmaInputVector c hc psi) = 0 := by + ext s + by_cases hi : qmaInputCheck c i s + · have hs : ¬∀ j : Fin (c.work+1), c.witness ≤ j.val → s j = 0 := by + intro h + exact hi.2 (h i hi.1) + simp [hi,qmaInputVector,qmaInitialState,hs] + · simp [hi] + +theorem qmaIdealHistory_distributed_input (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaDistributedInput c (fun i => (τ i).val) (qmaIdealHistory c hc psi) = 0 := by + unfold qmaDistributedInput qmaIdealHistory + apply Finset.sum_eq_zero + intro i _ + rw [qmaInputCheck_prefix_untouched c hc i (τ i).val (hi i), + qmaInputVector_single_check_zero,norm_zero,zero_pow (by decide : 2 ≠ 0)] + +theorem qmaUnaryExtend_distributed_energy (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (u : QMAHistoryBasis c → ℂ) : + qmaUnaryDistributedEnergy c τ (qmaUnaryExtend c u) = + qmaDistributedHistoryEnergy c (fun i => (τ i).val) (qmaHistoryFromVector c u) := by + rw [qmaUnaryDistributedEnergy,qmaUnaryExtend_clock_energy, + qmaUnaryExtend_distributed_input,qmaUnaryExtend_output_energy, + qmaUnaryExtend_propagation_energy,zero_add] + rfl + +theorem qmaIdealHistory_distributed_energy (c : QMACircuit) (hc : c.WellFormed) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (hi : ∀ i, ∀ g ∈ c.gates.take (τ i).val, i ∉ qmaGateSites c.work g) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaDistributedHistoryEnergy c (fun i => (τ i).val) (qmaIdealHistory c hc psi) = + ‖qmaRejectVector c hc psi‖^2 := by + rw [qmaDistributedHistoryEnergy,qmaIdealHistory_distributed_input c hc τ hi, + qmaIdealHistory_propagation] + simp only [mul_zero,add_zero,qmaOutputPenalty,qmaIdealHistory,qmaPrefixMatrix_length, + qmaRejectVector,qmaOutputVector] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEightBasis.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEightBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b25ac25768b077664141aa06c3d2444797b0911 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEightBasis.lean @@ -0,0 +1,117 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCross +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorGraph + +namespace OAI + +/-! The two encoded blocks are eight ordinary physical spins. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaEightBasisEquiv : (Fin 8 → Fin 2) ≃ (Fin 16 × Fin 16) where + toFun s := (qmaFourIndex (fun i => s (Fin.castAdd 4 i)), + qmaFourIndex (fun i => s (Fin.natAdd 4 i))) + invFun p k := Fin.addCases (motive := fun _ : Fin (4+4) => Fin 2) + (qmaFourBits p.1) (qmaFourBits p.2) k + left_inv s := by + funext k + refine Fin.addCases (m := 4) (n := 4) (fun i => ?_) (fun i => ?_) k + · simp only [Fin.addCases_left] + exact congrFun (qmaFourBasisEquiv.symm_apply_apply (fun j => s (Fin.castAdd 4 j))) i + · simp only [Fin.addCases_right] + exact congrFun (qmaFourBasisEquiv.symm_apply_apply (fun j => s (Fin.natAdd 4 j))) i + right_inv p := by + simp only [Fin.addCases_left,Fin.addCases_right] + exact Prod.ext (qmaFourBasisEquiv.apply_symm_apply p.1) (qmaFourBasisEquiv.apply_symm_apply p.2) + +theorem qmaEightTensor_source (M : Fin 8 → Matrix (Fin 2) (Fin 2) ℂ) : + (sourceTensor 8 M).submatrix qmaEightBasisEquiv.symm qmaEightBasisEquiv.symm = + (sourceTensor 4 (fun i => M (Fin.castAdd 4 i))).submatrix qmaFourBits qmaFourBits ⊗ₖ + (sourceTensor 4 (fun i => M (Fin.natAdd 4 i))).submatrix qmaFourBits qmaFourBits := by + ext p q + change (∏ i : Fin (4+4), M i (qmaEightBasisEquiv.symm p i) (qmaEightBasisEquiv.symm q i)) = + (∏ i : Fin 4, M (Fin.castAdd 4 i) (qmaFourBits p.1 i) (qmaFourBits q.1 i))* + ∏ i : Fin 4, M (Fin.natAdd 4 i) (qmaFourBits p.2 i) (qmaFourBits q.2 i) + rw [Fin.prod_univ_add] + simp only [qmaEightBasisEquiv,Equiv.coe_fn_symm_mk,Fin.addCases_left,Fin.addCases_right] + +theorem qmaEightPauli_left (i : Fin 4) (μ : Fin 3) : + (sourceLocalPauli 8 (Fin.castAdd 4 i) μ).submatrix qmaEightBasisEquiv.symm qmaEightBasisEquiv.symm = + qmaFourSpin i μ ⊗ₖ (1 : Matrix (Fin 16) (Fin 16) ℂ) := by + rw [sourceLocalPauli,qmaEightTensor_source] + have hL : (fun k : Fin 4 => if Fin.castAdd 4 k = Fin.castAdd 4 i then pauli μ else 1) = + (fun k => if k = i then pauli μ else 1) := by + funext k + have he : Fin.castAdd 4 k = Fin.castAdd 4 i ↔ k = i := by + simp only [Fin.ext_iff,Fin.val_castAdd] + simp only [he] + have hR : (fun k : Fin 4 => if Fin.natAdd 4 k = Fin.castAdd 4 i then pauli μ else 1) = + (fun _ => 1) := by + funext k + have hne : Fin.natAdd 4 k ≠ Fin.castAdd 4 i := by + intro h + have hv := congrArg Fin.val h + have hi := i.isLt + simp only [Fin.val_natAdd,Fin.val_castAdd] at hv + omega + rw [ite_eq_right hne] + rw [hL,hR,sourceTensor_one] + change (sourceLocalPauli 4 i μ).submatrix qmaFourBits qmaFourBits ⊗ₖ + (1 : Matrix (Fin 4 → Fin 2) (Fin 4 → Fin 2) ℂ).submatrix qmaFourBits qmaFourBits = _ + rw [← qmaFourSpin_source] + congr 1 + ext s t + have he : qmaFourBits s = qmaFourBits t ↔ s = t := qmaFourBasisEquiv.symm.injective.eq_iff + simp only [Matrix.submatrix_apply,Matrix.one_apply,he] + +theorem qmaEightPauli_right (i : Fin 4) (μ : Fin 3) : + (sourceLocalPauli 8 (Fin.natAdd 4 i) μ).submatrix qmaEightBasisEquiv.symm qmaEightBasisEquiv.symm = + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ qmaFourSpin i μ := by + rw [sourceLocalPauli,qmaEightTensor_source] + have hR : (fun k : Fin 4 => if Fin.natAdd 4 k = Fin.natAdd 4 i then pauli μ else 1) = + (fun k => if k = i then pauli μ else 1) := by + funext k + have he : Fin.natAdd 4 k = Fin.natAdd 4 i ↔ k = i := by + simp only [Fin.ext_iff,Fin.val_natAdd,Nat.add_left_cancel_iff] + simp only [he] + have hL : (fun k : Fin 4 => if Fin.castAdd 4 k = Fin.natAdd 4 i then pauli μ else 1) = + (fun _ => 1) := by + funext k + have hne : Fin.castAdd 4 k ≠ Fin.natAdd 4 i := by + intro h + have hv := congrArg Fin.val h + have hk := k.isLt + simp only [Fin.val_natAdd,Fin.val_castAdd] at hv + omega + rw [ite_eq_right hne] + rw [hL,hR,sourceTensor_one] + change (1 : Matrix (Fin 4 → Fin 2) (Fin 4 → Fin 2) ℂ).submatrix qmaFourBits qmaFourBits ⊗ₖ + (sourceLocalPauli 4 i μ).submatrix qmaFourBits qmaFourBits = _ + rw [← qmaFourSpin_source] + congr 1 + ext s t + have he : qmaFourBits s = qmaFourBits t ↔ s = t := qmaFourBasisEquiv.symm.injective.eq_iff + simp only [Matrix.submatrix_apply,Matrix.one_apply,he] + +theorem qmaFourCross_source (i j : Fin 4) : + (sourceHeisenbergMatrix 8 (Fin.castAdd 4 i) (Fin.natAdd 4 j)).submatrix + qmaEightBasisEquiv.symm qmaEightBasisEquiv.symm = qmaFourCross i j := by + have hij : Fin.castAdd 4 i ≠ Fin.natAdd 4 j := by + intro h + have hv := congrArg Fin.val h + have hi := i.isLt + simp only [Fin.val_natAdd,Fin.val_castAdd] at hv + omega + rw [← sourceLocalPauli_sum 8 _ _ hij,MediatorGraph.submatrix_sum] + apply Finset.sum_congr rfl + intro μ _ + rw [← Matrix.submatrix_mul_equiv _ _ _ qmaEightBasisEquiv.symm _,qmaEightPauli_left,qmaEightPauli_right, + ← Matrix.mul_kronecker_mul,Matrix.mul_one,Matrix.one_mul] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpoint.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..c483bd0922210502ea997a2c55e40927443feb6a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpoint.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMask + +namespace OAI + +/-! The verifier acceptance probability is the exact endpoint projection +energy of its normalized zero-ancilla evolution. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +def qmaInputVector (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + WithLp.toLp 2 (qmaInitialState c hc psi) + +def qmaOutputVector (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + qmaApplyMatrix (qmaCircuitMatrix c) (qmaInputVector c hc psi) + +def qmaRejectVector (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + qmaMask (fun s => s (Fin.last c.work) ≠ 1) (qmaOutputVector c hc psi) + +theorem qmaInputVector_norm (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + ‖qmaInputVector c hc psi‖ = ‖psi‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [EuclideanSpace.norm_sq_eq] + simpa only [qmaInputVector,PiLp.toLp_apply,Complex.sq_norm,sourceSpinMass] using + qmaInitialState_mass c hc psi + +theorem qmaOutputVector_norm (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + ‖qmaOutputVector c hc psi‖ = ‖psi‖ := by + rw [qmaOutputVector,qmaApplyMatrix_norm _ (qmaCircuitMatrix_gram c hc),qmaInputVector_norm] + +theorem qmaAcceptance_projection (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaAcceptance c hc psi = + ‖qmaMask (fun s => s (Fin.last c.work) = 1) (qmaOutputVector c hc psi)‖^2 := by + classical + rw [EuclideanSpace.norm_sq_eq] + apply Finset.sum_congr rfl + intro s _ + by_cases hs : s (Fin.last c.work) = 1 <;> + simp [qmaMask_apply,hs,qmaOutputVector,qmaApplyMatrix,qmaInputVector,Complex.sq_norm] + +theorem qmaRejectVector_square (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + ‖qmaRejectVector c hc psi‖^2 = ‖psi‖^2-qmaAcceptance c hc psi := by + have h := qmaMask_complement_square (fun s => s (Fin.last c.work) = 1) + (qmaOutputVector c hc psi) + rw [←qmaAcceptance_projection,qmaOutputVector_norm] at h + change qmaAcceptance c hc psi+‖qmaRejectVector c hc psi‖^2 = ‖psi‖^2 at h + linarith + +theorem qmaRejectVector_of_accept (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : ‖qmaRejectVector c hc psi‖^2 ≤ 1/3 := by + rw [qmaRejectVector_square,hpsi] + linarith + +theorem qmaRejectVector_of_sound (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : qmaAcceptance c hc psi ≤ 1/3) : 2/3 ≤ ‖qmaRejectVector c hc psi‖^2 := by + rw [qmaRejectVector_square,hpsi] + linarith + +theorem qmaApplyMatrix_smul {n : ℕ} + (M : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) + (a : ℂ) (u : EuclideanSpace ℂ (SourceSpinBasis n)) : + qmaApplyMatrix M (a • u) = a • qmaApplyMatrix M u := by + ext s + change (M.mulVec (a • (fun s => u s))) s = (a • M.mulVec (fun s => u s)) s + rw [Matrix.mulVec_smul] + +theorem qmaInputVector_smul (c : QMACircuit) (hc : c.WellFormed) + (a : ℂ) (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaInputVector c hc (a • psi) = a • qmaInputVector c hc psi := by + classical + ext s + by_cases hs : ∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 + · simp [qmaInputVector,qmaInitialState] + · simp [qmaInputVector,qmaInitialState,hs] + +theorem qmaRejectVector_smul (c : QMACircuit) (hc : c.WellFormed) + (a : ℂ) (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaRejectVector c hc (a • psi) = a • qmaRejectVector c hc psi := by + rw [qmaRejectVector,qmaOutputVector,qmaInputVector_smul,qmaApplyMatrix_smul,map_smul] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointListProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointListProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..81963ebe823073c3d939c9e316b5442f23700bc8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointListProgram.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedArmProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumWalkSupport +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! The endpoint arm list is computed from its ordinal port, lane color and +coarse vertex. All three quantities are supplied by the explicit slot and +incident-rank programs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEndpointListProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +abbrev ArmInput := ℕ × ℕ +def armCode : ArmInput → List Bool := prodCode unaryCode unaryCode + +def armList (x : ArmInput) : List Pair := + if x.1=0 then (List.range (QuantumBufferedArmProgram.length 0 x.2+1)).map + (QuantumBufferedArmProgram.point 0 x.2) + else if x.1=1 then (List.range (QuantumBufferedArmProgram.length 1 x.2+1)).map + (QuantumBufferedArmProgram.point 1 x.2) + else (List.range (QuantumBufferedArmProgram.length 2 x.2+1)).map + (QuantumBufferedArmProgram.point 2 x.2) + +theorem armList_fin (a : Fin 3) (color : ℕ) : + armList (a.val,color) = (List.range (QuantumBufferedArmProgram.length a color+1)).map + (QuantumBufferedArmProgram.point a color) := by + fin_cases a <;> simp [armList] + +noncomputable def armProgram : Procedure armCode (listCode pairCode) armList := by + let a := Procedure.unaryToBits.comp (Procedure.first unaryCode unaryCode) + let color := Procedure.second unaryCode unaryCode + let is (k : ℕ) := Procedure.binaryEq.comp (a.pair (Procedure.constant armCode Nat.bits k)) + let branch (k : Fin 3) := (QuantumBufferedArmProgram.listProgram k).comp color + exact (Procedure.conditional (is 0) (branch 0) + (Procedure.conditional (is 1) (branch 1) (branch 2))).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,armList,id_eq]) + +def translate (B : ℕ) (p z : Pair) : Pair := qmaBufferedCellPoint (9*B+3) p z + +noncomputable def translateProgram (B : ℕ) : Procedure (prodCode pairCode pairCode) pairCode + (fun x => translate B x.1 x.2) := by + let p := Procedure.first pairCode pairCode + let z := Procedure.second pairCode pairCode + let coord (take : Procedure pairCode Nat.bits Prod.fst) := + Procedure.binaryAdd.comp + ((Procedure.binaryMul.comp ((Procedure.constant _ Nat.bits (8*(9*B+3+6))).pair + (take.comp p))).pair (take.comp z)) + let y := Procedure.binaryAdd.comp + ((Procedure.binaryMul.comp ((Procedure.constant _ Nat.bits (8*(9*B+3+6))).pair + ((Procedure.second Nat.bits Nat.bits).comp p))).pair + ((Procedure.second Nat.bits Nat.bits).comp z)) + exact (coord (Procedure.first Nat.bits Nat.bits)).pair y + +abbrev Input := Pair × ArmInput +def inputCode : Input → List Bool := prodCode pairCode armCode +def value (B : ℕ) (x : Input) : List Pair := (armList x.2).map (translate B x.1) + +noncomputable def program (B : ℕ) : Procedure inputCode (listCode pairCode) (value B) := + (Procedure.listMapWith (f := translate B) (0,0) (0,0) (translateProgram B)).comp + ((Procedure.first pairCode armCode).pair + (armProgram.comp (Procedure.second pairCode armCode))) + +theorem value_actual {A B : ℕ} (M : QMASpatialExchangeModel A B) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (v : Fin M.n) (e : M.Incident v) : + value B (M.routeVertex v,((M.endpointPorts hd v).assign e).val,(M.laneColor e.val).val) = + M.endpointArmList hd v e := by + unfold value + rw [armList_fin,List.map_map] + rw [← M.endpointColors_assigned hd v e] + simp only [QMASpatialExchangeModel.endpointArmList,QMASpatialExchangeModel.endpointArmLength, + QuantumBufferedArmProgram.length_eq,translate,Function.comp_def] + rfl + +end ContinuumCoulomb.QuantumEndpointListProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ff4b0c5abba0476af646ec87f400111000673b2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointPorts.lean @@ -0,0 +1,123 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumExchangeLanes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGraphDegree +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBufferedCells +import Mathlib.Data.Finset.Sort + +namespace OAI + +/-! The at-most-three incident edges are assigned distinct, ordered buffered ports. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +structure QMASortedPorts {κ : Type} (C : ℕ) (color : κ → Fin C) where + slot : Fin 3 → Fin (C+3) + increasing : StrictMono slot + assign : κ → Fin 3 + aligned : ∀ e, slot (assign e) = (color e).castAdd 3 + +theorem qmaSortedPorts_exists {κ : Type} [Fintype κ] {C : ℕ} (color : κ → Fin C) + (hc : Fintype.card κ ≤ 3) : Nonempty (QMASortedPorts C color) := by + let f := fun e => (color e).castAdd 3 + let s := Finset.univ.image f + have hs : s.card ≤ 3 := (Finset.card_image_le).trans (by simpa using hc) + obtain ⟨t,hst,_,ht⟩ := Finset.exists_subsuperset_card_eq + (show s ⊆ Finset.univ from Finset.subset_univ _) hs + (show 3 ≤ (Finset.univ : Finset (Fin (C+3))).card by simp) + let iso := t.orderIsoOfFin ht + let assign := fun e => iso.symm ⟨f e,hst (Finset.mem_image.mpr ⟨e,Finset.mem_univ _,rfl⟩)⟩ + refine ⟨⟨t.orderEmbOfFin ht,(t.orderEmbOfFin ht).strictMono,assign,?_⟩⟩ + intro e + exact congrArg Subtype.val (iso.apply_symm_apply _) + +def qmaPaddedPortSlot {C : ℕ} (s : Finset (Fin C)) (a : Fin 3) : Fin (C+3) := + if h : a.val < s.card then (s.orderEmbOfFin rfl ⟨a.val,h⟩).castAdd 3 + else ⟨C+(a.val-s.card),by have := a.isLt; omega⟩ + +theorem qmaPaddedPortSlot_increasing {C : ℕ} (s : Finset (Fin C)) : + StrictMono (qmaPaddedPortSlot s) := by + intro a b hab + have hab' : a.val < b.val := hab + by_cases ha : a.val < s.card <;> by_cases hb : b.val < s.card + · change (qmaPaddedPortSlot s a).val < (qmaPaddedPortSlot s b).val + simp only [qmaPaddedPortSlot,dite_eq_left ha,dite_eq_left hb,Fin.val_castAdd] + exact (s.orderEmbOfFin rfl).strictMono hab' + · change (qmaPaddedPortSlot s a).val < (qmaPaddedPortSlot s b).val + simp only [qmaPaddedPortSlot,dite_eq_left ha,dite_eq_right hb,Fin.val_castAdd] + have hu := (s.orderEmbOfFin rfl ⟨a.val,ha⟩).isLt + omega + · omega + · change (qmaPaddedPortSlot s a).val < (qmaPaddedPortSlot s b).val + simp only [qmaPaddedPortSlot,dite_eq_right ha,dite_eq_right hb] + omega + +def qmaCanonicalSortedPorts {κ : Type} [Fintype κ] {C : ℕ} (color : κ → Fin C) + (hc : Fintype.card κ ≤ 3) : QMASortedPorts C color := by + let s := Finset.univ.image color + have hs : s.card ≤ 3 := (Finset.card_image_le).trans (by simpa using hc) + let iso := s.orderIsoOfFin rfl + let rank := fun e => iso.symm ⟨color e,Finset.mem_image.mpr ⟨e,Finset.mem_univ _,rfl⟩⟩ + let assign := fun e => (⟨(rank e).val,lt_of_lt_of_le (rank e).isLt hs⟩ : Fin 3) + refine ⟨qmaPaddedPortSlot s,qmaPaddedPortSlot_increasing s,assign,?_⟩ + intro e + have hi : (assign e).val < s.card := (rank e).isLt + simp only [qmaPaddedPortSlot,dite_eq_left hi] + apply congrArg (Fin.castAdd 3) + exact congrArg Subtype.val (iso.apply_symm_apply _) + + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +abbrev Incident (v : Fin M.n) := {e : M.Term // M.left e = v ∨ M.right e = v} + +theorem incident_card (v : Fin M.n) : + Fintype.card (M.Incident v) = qmaGraphDegree M.left M.right v := by + rw [Fintype.card_subtype] + symm + exact Finset.sum_boole _ _ + +theorem incident_lane_support (v : Fin M.n) (e : M.Incident v) : + M.laneSupport e.val (qmaLanePoint (M.laneColor e.val) + (qmaFineGridNat (M.qubitSlots.site v))) := by + rcases e.property with h | h + · left + dsimp [laneSupport,qmaLaneSupport,routeLeft,routeRight] + rw [h] + exact ⟨rfl,min_le_left _ _,le_max_left _ _⟩ + · right + dsimp [laneSupport,qmaLaneSupport,routeLeft,routeRight] + rw [h] + exact ⟨rfl,min_le_right _ _,le_max_right _ _⟩ + +theorem incident_color_injective (hA : 0 < A) (v : Fin M.n) : + Function.Injective (fun e : M.Incident v => M.laneColor e.val) := by + intro e f hef + change M.laneColor e.val = M.laneColor f.val at hef + by_contra h + have hval : e.val ≠ f.val := fun hh => h (Subtype.ext hh) + have he := M.incident_lane_support v e + have hf := M.incident_lane_support v f + rw [← hef] at hf + exact Set.disjoint_left.mp (M.lane_color_disjoint hA hval hef) he hf + +def endpointPorts (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (v : Fin M.n) : + QMASortedPorts (9*B) (fun e : M.Incident v => M.laneColor e.val) := + qmaCanonicalSortedPorts _ ((M.incident_card v).trans_le (hd v)) + +theorem endpointPorts_assign_injective (hA : 0 < A) + (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) (v : Fin M.n) : + Function.Injective (M.endpointPorts hd v).assign := by + intro e f hef + apply M.incident_color_injective hA v + apply Fin.ext + have hh := congrArg Fin.val (congrArg (M.endpointPorts hd v).slot hef) + simpa only [(M.endpointPorts hd v).aligned,Fin.val_castAdd] using hh + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..516e85986f35a2e1efbf82f516d4b776380b4c66 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEndpointRelabel.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeSource + +namespace OAI + +/-! The unordered endpoint support determines the edge permutation of a +simple graph, including the possible reversal of each edge. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEndpointRelabel +open scoped Classical + +variable {G H : QMARationalExchangeGraph} (vertex : Fin H.n ≃ Fin G.n) + (hH : H.Simple) (hG : G.Simple) + (source : ∀ e : H.Edge, ∃ f : G.Edge, + s(vertex (H.left e),vertex (H.right e))=s(G.left f,G.right f)) + (target : ∀ f : G.Edge, ∃ e : H.Edge, + s(vertex (H.left e),vertex (H.right e))=s(G.left f,G.right f)) + +def chooseEdge (e : H.Edge) : G.Edge := Classical.choose (source e) + +theorem chooseEdge_spec (e : H.Edge) : + s(vertex (H.left e),vertex (H.right e))= + s(G.left (chooseEdge vertex source e),G.right (chooseEdge vertex source e)) := + Classical.choose_spec (source e) + +include hH in +theorem chooseEdge_injective : Function.Injective (chooseEdge vertex source) := by + intro e f hef + by_contra hne + have hp := (chooseEdge_spec vertex source e).trans + ((congrArg (fun k => s(G.left k,G.right k)) hef).trans + (chooseEdge_spec vertex source f).symm) + rcases Sym2.eq_iff.mp hp with ⟨hl,hr⟩ | ⟨hl,hr⟩ + · exact (hH e f hne).1 ⟨vertex.injective hl,vertex.injective hr⟩ + · exact (hH e f hne).2 ⟨vertex.injective hl,vertex.injective hr⟩ + +include hG in +theorem endpoint_injective : Function.Injective (fun e : G.Edge => s(G.left e,G.right e)) := by + intro e f hef + by_contra hne + rcases Sym2.eq_iff.mp hef with h | h + · exact (hG e f hne).1 h + · exact (hG e f hne).2 h + +include hG target in +theorem chooseEdge_surjective : Function.Surjective (chooseEdge vertex source) := by + intro f + obtain ⟨e,he⟩ := target f + refine ⟨e,endpoint_injective hG ?_⟩ + exact (chooseEdge_spec vertex source e).symm.trans he + +def edge : H.Edge ≃ G.Edge := Equiv.ofBijective (chooseEdge vertex source) + ⟨chooseEdge_injective vertex hH source,chooseEdge_surjective vertex hG source target⟩ + +def flip (e : H.Edge) : Bool := decide (vertex (H.left e)≠G.left (edge vertex hH hG source target e)) + +theorem left (e : H.Edge) : vertex (H.left e)= + if flip vertex hH hG source target e then G.right (edge vertex hH hG source target e) + else G.left (edge vertex hH hG source target e) := by + have h := chooseEdge_spec vertex source e + change s(vertex (H.left e),vertex (H.right e))= + s(G.left (edge vertex hH hG source target e),G.right (edge vertex hH hG source target e)) at h + rcases Sym2.eq_iff.mp h with ⟨hl,_⟩ | ⟨hl,_⟩ + · simp only [flip,hl,ne_eq,not_true_eq_false,decide_false,Bool.false_eq_true,ite_false] + · have hn : vertex (H.left e)≠G.left (edge vertex hH hG source target e) := by + rw [hl] + exact (G.distinct _).symm + have hf : flip vertex hH hG source target e = true := decide_eq_true hn + simp only [hf,ite_true] + exact hl + +theorem right (e : H.Edge) : vertex (H.right e)= + if flip vertex hH hG source target e then G.left (edge vertex hH hG source target e) + else G.right (edge vertex hH hG source target e) := by + have h := chooseEdge_spec vertex source e + change s(vertex (H.left e),vertex (H.right e))= + s(G.left (edge vertex hH hG source target e),G.right (edge vertex hH hG source target e)) at h + rcases Sym2.eq_iff.mp h with ⟨hl,hr⟩ | ⟨hl,hr⟩ + · simp only [flip,hl,ne_eq,not_true_eq_false,decide_false,Bool.false_eq_true,ite_false] + exact hr + · have hn : vertex (H.left e)≠G.left (edge vertex hH hG source target e) := by + rw [hl] + exact (G.distinct _).symm + have hf : flip vertex hH hG source target e = true := decide_eq_true hn + simp only [hf,ite_true] + exact hr + +end ContinuumCoulomb.QuantumEndpointRelabel + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEntryParity.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEntryParity.lean new file mode 100644 index 0000000000000000000000000000000000000000..41b7fc2ab250d176f26fe9ee87b1ba0f0e632b02 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEntryParity.lean @@ -0,0 +1,119 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliSplit +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QubitPhaseLocal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumThirdCounterterm + +namespace OAI + +/-! Real and purely imaginary entry parities determine the mediator phase. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +variable {σ : Type*} + +def QMAEntryParity (p : Bool) (M : Matrix σ σ ℂ) : Prop := + if p = true then ∀ s t, (M s t).re = 0 else ∀ s t, (M s t).im = 0 + +theorem QMAEntryParity.add {p : Bool} {M N : Matrix σ σ ℂ} + (hM : QMAEntryParity p M) (hN : QMAEntryParity p N) : QMAEntryParity p (M+N) := by + cases p <;> simp only [QMAEntryParity,Bool.false_eq_true,ite_false,ite_true] at * + · intro s t + simp [hM s t,hN s t] + · intro s t + simp [hM s t,hN s t] + +theorem QMAEntryParity.real_smul {p : Bool} {M : Matrix σ σ ℂ} + (hM : QMAEntryParity p M) (r : ℝ) : QMAEntryParity p (r • M) := by + cases p <;> simp only [QMAEntryParity,Bool.false_eq_true,ite_false,ite_true] at * + · intro s t + simp [hM s t] + · intro s t + simp [hM s t] + +theorem QMAEntryParity.pair {p : Bool} {M N : Matrix σ σ ℂ} + (hM : QMAEntryParity p M) (hN : QMAEntryParity p N) (j : ℝ) : + QMAEntryParity p (qmaThirdSeriesPair M N j) := by + have he : qmaThirdSeriesPair M N j = M+(j/2:ℝ) • N := by + change M+((j:ℂ)/2) • N = M+((j/2:ℝ):ℂ) • N + push_cast + rfl + rw [he] + exact hM.add (hN.real_smul (j/2)) + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [DecidableEq ι] in +theorem qmaPauliWord_real_of_even (w : ι → Fin 4) (h : Even (qmaPauliYCount w)) : + QMAEntryParity false (qmaPauliWord w) := by + intro s t + have hc := congrArg Complex.im (qmaPauliWord_conjugate w s t) + rw [h.neg_one_pow] at hc + simp only [Complex.star_def,Complex.conj_im,one_mul] at hc + linarith + +omit [DecidableEq ι] in +theorem qmaPauliWord_imaginary_of_odd (w : ι → Fin 4) (h : Odd (qmaPauliYCount w)) : + QMAEntryParity true (qmaPauliWord w) := by + intro s t + have hc := congrArg Complex.re (qmaPauliWord_conjugate w s t) + rw [h.neg_one_pow] at hc + simp only [Complex.star_def,Complex.conj_re,neg_one_mul,Complex.neg_re] at hc + linarith + +omit [DecidableEq ι] in +theorem qmaPauliWord_entryParity (w : ι → Fin 4) : + QMAEntryParity (decide (Odd (qmaPauliYCount w))) (qmaPauliWord w) := by + by_cases h : Odd (qmaPauliYCount w) + · simpa only [h,decide_true] using qmaPauliWord_imaginary_of_odd w h + · have he : Even (qmaPauliYCount w) := (Nat.even_or_odd _).resolve_right h + simpa only [h,decide_false] using qmaPauliWord_real_of_even w he + +theorem qmaPauliYCount_restrict (S : Finset ι) (w : ι → Fin 4) : + qmaPauliYCount (qmaPauliRestrict S w) = (S.filter (fun i => w i = 2)).card := by + unfold qmaPauliYCount + apply congrArg Finset.card + ext i + simp only [Finset.mem_filter,Finset.mem_univ,true_and] + by_cases hi : i ∈ S <;> simp [qmaPauliRestrict,hi] + +theorem qmaPauliYCount_split (S T : Finset ι) (w : ι → Fin 4) + (hST : Disjoint S T) (hcover : qmaPauliSupport w ⊆ S ∪ T) : + qmaPauliYCount (qmaPauliRestrict S w)+qmaPauliYCount (qmaPauliRestrict T w) = + qmaPauliYCount w := by + rw [qmaPauliYCount_restrict,qmaPauliYCount_restrict] + have hd : Disjoint (S.filter (fun i => w i = 2)) (T.filter (fun i => w i = 2)) := + hST.mono (Finset.filter_subset _ _) (Finset.filter_subset _ _) + rw [← Finset.card_union_of_disjoint hd] + unfold qmaPauliYCount + congr 1 + ext i + constructor + · intro hi + rcases Finset.mem_union.mp hi with hi | hi <;> simpa using (Finset.mem_filter.mp hi).2 + · intro hi + have hw := (Finset.mem_filter.mp hi).2 + have hs : i ∈ qmaPauliSupport w := by simp [qmaPauliSupport,hw] + rcases Finset.mem_union.mp (hcover hs) with hi | hi + · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨hi,hw⟩) + · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hi,hw⟩) + +theorem qmaPauliRestrict_same_parity (S T : Finset ι) (w : ι → Fin 4) + (hST : Disjoint S T) (hcover : qmaPauliSupport w ⊆ S ∪ T) + (hw : Even (qmaPauliYCount w)) : + decide (Odd (qmaPauliYCount (qmaPauliRestrict S w))) = + decide (Odd (qmaPauliYCount (qmaPauliRestrict T w))) := by + have hsum := qmaPauliYCount_split S T w hST hcover + simp only [Nat.even_iff] at hw + have he : Odd (qmaPauliYCount (qmaPauliRestrict S w)) ↔ + Odd (qmaPauliYCount (qmaPauliRestrict T w)) := by + simp only [Nat.odd_iff] + omega + simp only [he] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenListPieces.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenListPieces.lean new file mode 100644 index 0000000000000000000000000000000000000000..78ccfd344fa0512a08ef28e15db0f89f8c8121b2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenListPieces.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInflatedListProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarRouteData + +namespace OAI + +/-! Literal reserved-leaf and tail arrays for an even route subdivision. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEvenListPieces +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +def leaf (xs : List Pair) : Pair := qmaRouteLeaf + (QuantumForkGridProgram.lookup xs 0) + (qmaGridNeighborIndex (QuantumForkGridProgram.lookup xs 0) + (QuantumForkGridProgram.lookup xs 1)) +def fresh (xs : List Pair) : List Pair := + [QuantumInflatedListProgram.point (1,xs),leaf xs] +def paths (xs : List Pair) : List (List Pair) := + [fresh xs,[QuantumInflatedListProgram.point (0,xs), + QuantumInflatedListProgram.point (1,xs)], + ((QuantumInflatedListProgram.value xs).drop 1).reverse] + +noncomputable opaque leafProgram : Procedure (listCode pairCode) pairCode leaf := by + let get (k : ℕ) := (Procedure.listGet pairCode (0,0)).comp + ((Procedure.constant (listCode pairCode) Nat.bits k).pair + (Procedure.identity (listCode pairCode))) + exact QuantumRouteLeafCode.selectedLeafProgram.comp ((get 0).pair (get 1)) + +noncomputable def pointProgram (k : ℕ) : Procedure (listCode pairCode) pairCode + (fun xs => QuantumInflatedListProgram.point (k,xs)) := + QuantumInflatedListProgram.pointProgram.comp + ((Procedure.constant (listCode pairCode) Nat.bits k).pair + (Procedure.identity (listCode pairCode))) + +private noncomputable def pairList {α : Type} (ea : α → List Bool) + {f g : α → Pair} (p : Procedure ea pairCode f) (q : Procedure ea pairCode g) : + Procedure ea (listCode pairCode) (fun x => [f x,g x]) := + (Procedure.listCons pairCode).comp (p.pair + ((Procedure.listCons pairCode).comp (q.pair (Procedure.constant ea (listCode pairCode) [])))) + +noncomputable opaque freshProgram : Procedure (listCode pairCode) (listCode pairCode) fresh := + pairList (listCode pairCode) (pointProgram 1) leafProgram + +noncomputable opaque pathsProgram : Procedure (listCode pairCode) + (listCode (listCode pairCode)) paths := by + let second := pairList (listCode pairCode) (pointProgram 0) (pointProgram 1) + let third := (Procedure.listReverse pairCode (0,0)).comp + ((Procedure.listDrop pairCode).comp + ((Procedure.constant (listCode pairCode) Nat.bits 1).pair + QuantumInflatedListProgram.program)) + exact (Procedure.listCons (listCode pairCode)).comp (freshProgram.pair + ((Procedure.listCons (listCode pairCode)).comp (second.pair + ((Procedure.listCons (listCode pairCode)).comp + (third.pair (Procedure.constant (listCode pairCode) (listCode (listCode pairCode)) [])))))) + +theorem tail_reverse (p : ℕ → Pair) (n : ℕ) : + (((List.range (n+1)).map p).drop 1).reverse= + (List.range n).map (fun k => p (n-k)) := by + apply List.ext_getElem + · simp only [List.length_reverse,List.length_drop,List.length_map,List.length_range] + omega + · intro i hi hj + have hi' : i qmaInflatedPoint p (8*L-k))] := by + unfold paths + rw [fresh_range p L hL,QuantumInflatedListProgram.point_range p L 0 (by omega), + QuantumInflatedListProgram.point_range p L 1 (by omega), + QuantumInflatedListProgram.value_range,tail_reverse] + +end ContinuumCoulomb.QuantumEvenListPieces + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteData.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteData.lean new file mode 100644 index 0000000000000000000000000000000000000000..18f28aa6e5d0f9e4a11a60a56288f772b66dc9d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteData.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutedSubdivision + +namespace OAI + +/-! Even route lengths use one singlet leaf. The leaf sits beside the first +interior route point and outside all routed edges. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical + +structure QMAEvenRouteData (G : QMARationalExchangeGraph) where + work : G.Edge → ℕ + position : Fin G.n → ℕ × ℕ + position_injective : Function.Injective position + point : G.Edge → ℕ → ℕ × ℕ + first : ∀ e, point e 0 = position (G.left e) + last : ∀ e, point e (2*work e+2) = position (G.right e) + simple : ∀ e i j, i ≤ 2*work e+2 → j ≤ 2*work e+2 → point e i = point e j → i = j + step : ∀ e i, i < 2*work e+2 → qmaSquareGrid.Adj (point e i) (point e (i+1)) + avoids : ∀ e i v, 0 < i → i < 2*work e+2 → point e i ≠ position v + disjoint : ∀ e f i j, e ≠ f → 0 < i → i < 2*work e+2 → j ≤ 2*work f+2 → + point e i ≠ point f j + leaf : G.Edge → ℕ × ℕ + leaf_injective : Function.Injective leaf + leaf_step : ∀ e, qmaSquareGrid.Adj (point e 1) (leaf e) + leaf_avoids : ∀ e f k, k ≤ 2*work f+2 → leaf e ≠ point f k + leaf_old : ∀ e v, leaf e ≠ position v + +namespace QMAEvenRouteData +variable {G : QMARationalExchangeGraph} (P : QMAEvenRouteData G) + +def selected (i : Fin (Finset.univ : Finset G.Edge).card) : G.Edge := + qmaSelectedIndex Finset.univ i + +theorem selected_injective : Function.Injective (selected (G := G)) := by + intro i j h + apply (Finset.univ : Finset G.Edge).equivFin.symm.injective + exact Subtype.ext h + +def freshPosition (i : Fin (Finset.univ : Finset G.Edge).card) (b : Fin 2) : ℕ × ℕ := + if b = 0 then P.point (selected i) 1 else P.leaf (selected i) + +theorem freshPosition_ne_old (i : Fin (Finset.univ : Finset G.Edge).card) (b : Fin 2) + (v : Fin G.n) : P.freshPosition i b ≠ P.position v := by + fin_cases b + · exact P.avoids _ 1 v (by omega) (by omega) + · exact P.leaf_old _ v + +theorem freshPosition_injective : Function.Injective + (fun x : Fin (Finset.univ : Finset G.Edge).card × Fin 2 => P.freshPosition x.1 x.2) := by + rintro ⟨i,a⟩ ⟨j,b⟩ h + change P.freshPosition i a = P.freshPosition j b at h + fin_cases a <;> fin_cases b + · have he : selected i = selected j := by + by_contra hn + exact P.disjoint _ _ 1 1 hn (by omega) (by omega) (by omega) h + have hij := selected_injective he + subst j + rfl + · exact (P.leaf_avoids (selected j) (selected i) 1 (by omega) h.symm).elim + · exact (P.leaf_avoids (selected i) (selected j) 1 (by omega) h).elim + · have he := P.leaf_injective h + have hij := selected_injective he + subst j + rfl + +def nextPosition (v : Fin (G.n+(Finset.univ : Finset G.Edge).card*2)) : ℕ × ℕ := + Sum.elim P.position (fun p => P.freshPosition p.1 p.2) ((vertexEquiv _ _).symm v) + +@[simp] theorem nextPosition_old (v : Fin G.n) : P.nextPosition (old _ _ v) = P.position v := by + simp only [nextPosition,old,Equiv.symm_apply_apply,Sum.elim_inl] + +@[simp] theorem nextPosition_fresh (i : Fin (Finset.univ : Finset G.Edge).card) (b : Fin 2) : + P.nextPosition (fresh _ _ i b) = P.freshPosition i b := by + simp only [nextPosition,fresh,Equiv.symm_apply_apply,Sum.elim_inr] + +theorem nextPosition_injective : Function.Injective P.nextPosition := by + intro x y h + obtain ⟨x,rfl⟩ := (vertexEquiv G.n (Finset.univ : Finset G.Edge).card).surjective x + obtain ⟨y,rfl⟩ := (vertexEquiv G.n (Finset.univ : Finset G.Edge).card).surjective y + simp only [nextPosition,Equiv.symm_apply_apply] at h + apply (vertexEquiv _ _).congr_arg + cases x with + | inl x => + cases y with + | inl y => exact congrArg Sum.inl (P.position_injective h) + | inr y => exact (P.freshPosition_ne_old y.1 y.2 x h.symm).elim + | inr x => + cases y with + | inl y => exact (P.freshPosition_ne_old x.1 x.2 y h).elim + | inr y => exact congrArg Sum.inr (P.freshPosition_injective h) + +def nextWork : QMAPartialPathsEdge (Finset.univ : Finset G.Edge) → ℕ + | .inl _ => 0 + | .inr (.inl _) => 0 + | .inr (.inr (i,a)) => if a = 1 then P.work (selected i) else 0 + +def schedule (N : ℚ) : QMAPathSchedule where + graph := G.subdivide Finset.univ (fun _ => true) N + work := P.nextWork + +theorem schedule_work_le (N : ℚ) {D : ℕ} (hD : ∀ e, P.work e ≤ D) : + ∀ e, (P.schedule N).work e ≤ D := by + intro e + rcases e with e | (i | ⟨i,a⟩) + · exact Nat.zero_le _ + · exact Nat.zero_le _ + · change (if a = 1 then P.work (selected i) else 0) ≤ D + split + · exact hD _ + · exact Nat.zero_le _ + +theorem schedule_energy_error {N : ℚ} (hN : 0 < N) : + |(P.schedule N).graph.energy-G.energy| ≤ 1/(N:ℝ) := + G.subdivide_energy_error Finset.univ (fun _ => true) hN + +end QMAEvenRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteLabels.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..7669ff195a9ac1bb7ebf84a73d4390b7fa0827c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteLabels.lean @@ -0,0 +1,190 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenListPieces +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenTapeOrder + +namespace OAI + +/-! Explicit vertex and edge labels for the even subdivision of a planar route family. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEvenRouteLabels +open MediatorGraph QuantumRouteCode +open scoped Classical + +variable {G : QMARationalExchangeGraph} (P : QMAPlanarRouteData G) + {m : ℕ} (labels : G.Edge ≃ Fin m) + +def selectedEquiv (G : QMARationalExchangeGraph) : + Fin (Finset.univ : Finset G.Edge).card ≃ G.Edge where + toFun := QMAEvenRouteData.selected + invFun e := (Finset.univ : Finset G.Edge).equivFin ⟨e,Finset.mem_univ e⟩ + left_inv i := by + change (Finset.univ : Finset G.Edge).equivFin + ⟨((Finset.univ : Finset G.Edge).equivFin.symm i).val,_⟩=i + exact (Finset.univ : Finset G.Edge).equivFin.apply_symm_apply i + right_inv e := by + change ((Finset.univ : Finset G.Edge).equivFin.symm + ((Finset.univ : Finset G.Edge).equivFin ⟨e,Finset.mem_univ e⟩)).val=e + rw [Equiv.symm_apply_apply] + +def activeIndex : Fin m ≃ Fin (Finset.univ : Finset G.Edge).card := + labels.symm.trans (selectedEquiv G).symm + +theorem selected_index (i : Fin m) : + QMAEvenRouteData.selected (activeIndex labels i)=labels.symm i := by + exact (selectedEquiv G).apply_symm_apply (labels.symm i) + +def vertex : Fin (G.n+m*2) ≃ Fin (G.n+(Finset.univ : Finset G.Edge).card*2) := + ((vertexEquiv G.n m).symm.trans + (Equiv.sumCongr (Equiv.refl _) (Equiv.prodCongr (activeIndex labels) (Equiv.refl _)))).trans + (vertexEquiv _ _) + +@[simp] theorem vertex_old (v : Fin G.n) : vertex labels (old G.n m v)=old _ _ v := by + simp only [vertex,old,Equiv.trans_apply,Equiv.symm_apply_apply,Equiv.sumCongr_apply, + Sum.map_inl,Equiv.refl_apply] + +@[simp] theorem vertex_fresh (i : Fin m) (a : Fin 2) : + vertex labels (fresh G.n m i a)=fresh _ _ (activeIndex labels i) a := by + simp only [vertex,fresh,Equiv.trans_apply,Equiv.symm_apply_apply,Equiv.sumCongr_apply, + Sum.map_inr,Equiv.prodCongr_apply] + rfl + +def edge (t : Fin m × Fin 3) : QMAPartialPathsEdge (Finset.univ : Finset G.Edge) := + if h : t.2=0 then .inr (.inl (activeIndex labels t.1)) + else .inr (.inr (activeIndex labels t.1,⟨t.2.val-1,by omega⟩)) + +def unedge : QMAPartialPathsEdge (Finset.univ : Finset G.Edge) → Fin m × Fin 3 + | .inl e => (e.property (Finset.mem_univ _)).elim + | .inr (.inl i) => ((activeIndex labels).symm i,0) + | .inr (.inr (i,a)) => ((activeIndex labels).symm i,a.succ) + +def edgeEquiv : (Fin m × Fin 3) ≃ QMAPartialPathsEdge (Finset.univ : Finset G.Edge) where + toFun := edge labels + invFun := unedge labels + left_inv := by + rintro ⟨i,k⟩ + fin_cases k + all_goals + change ((activeIndex labels).symm (activeIndex labels i),_)=(i,_) + rw [Equiv.symm_apply_apply] + rfl + right_inv := by + rintro (e | (i | ⟨i,a⟩)) + · exact (e.property (Finset.mem_univ _)).elim + · change Sum.inr (Sum.inl (activeIndex labels ((activeIndex labels).symm i)))=Sum.inr (Sum.inl i) + rw [Equiv.apply_symm_apply] + · fin_cases a + all_goals + change Sum.inr (Sum.inr (activeIndex labels ((activeIndex labels).symm i),_))=Sum.inr (Sum.inr (i,_)) + rw [Equiv.apply_symm_apply] + rfl + +def work (t : Fin m × Fin 3) : ℕ := if t.2=2 then 4*P.length (labels.symm t.1)-1 else 0 + +theorem work_eq (t : Fin m × Fin 3) : + P.toEven.nextWork (edge labels t)=work P labels t := by + rcases t with ⟨i,k⟩ + fin_cases k + · rfl + · rfl + · change 4*P.length (QMAEvenRouteData.selected (activeIndex labels i))-1= + 4*P.length (labels.symm i)-1 + rw [selected_index labels i] + +def originalPath (i : Fin m) : List Pair := + (List.range (P.length (labels.symm i)+1)).map (P.point (labels.symm i)) + +theorem fresh_eq (i : Fin m) : QuantumEvenListPieces.fresh (originalPath P labels i)= + [P.toEven.freshPosition (activeIndex labels i) 0, + P.toEven.freshPosition (activeIndex labels i) 1] := by + rw [originalPath,QuantumEvenListPieces.fresh_range _ _ (P.length_pos _)] + simp only [QMAEvenRouteData.freshPosition,ite_true,show (1:Fin 2)≠0 from by decide,ite_false, + selected_index labels i,QMAPlanarRouteData.toEven,QMAPlanarRouteData.leaf,QMAPlanarRouteData.direction] + +theorem paths_eq (i : Fin m) : QuantumEvenListPieces.paths (originalPath P labels i)= + List.ofFn (fun k : Fin 3 => (List.range (2*work P labels (i,k)+2)).map + (P.toEven.nextPoint (edge labels (i,k)))) := by + rw [originalPath,QuantumEvenListPieces.paths_range _ _ (P.length_pos _)] + have he : 2*(4*P.length (labels.symm i)-1)+2=8*P.length (labels.symm i) := + P.even_length _ + have h0 : (List.range (2*work P labels (i,0)+2)).map + (P.toEven.nextPoint (edge labels (i,0)))= + [qmaInflatedPoint (P.point (labels.symm i)) 1, + qmaRouteLeaf (P.point (labels.symm i) 0) + (qmaGridNeighborIndex (P.point (labels.symm i) 0) (P.point (labels.symm i) 1))] := by + change (List.range 2).map (fun k => if k=0 then + qmaInflatedPoint (P.point (QMAEvenRouteData.selected (activeIndex labels i))) 1 else + qmaRouteLeaf (P.point (QMAEvenRouteData.selected (activeIndex labels i)) 0) + (qmaGridNeighborIndex (P.point (QMAEvenRouteData.selected (activeIndex labels i)) 0) + (P.point (QMAEvenRouteData.selected (activeIndex labels i)) 1)))=_ + rw [selected_index labels i] + rfl + have h1 : (List.range (2*work P labels (i,1)+2)).map + (P.toEven.nextPoint (edge labels (i,1)))= + [qmaInflatedPoint (P.point (labels.symm i)) 0,qmaInflatedPoint (P.point (labels.symm i)) 1] := by + change (List.range 2).map (qmaInflatedPoint + (P.point (QMAEvenRouteData.selected (activeIndex labels i))))=_ + rw [selected_index labels i] + rfl + have h2 : (List.range (2*work P labels (i,2)+2)).map + (P.toEven.nextPoint (edge labels (i,2)))= + (List.range (8*P.length (labels.symm i))).map + (fun k => qmaInflatedPoint (P.point (labels.symm i)) (8*P.length (labels.symm i)-k)) := by + change (List.range (2*(4*P.length (labels.symm i)-1)+2)).map + (fun k => qmaInflatedPoint (P.point (QMAEvenRouteData.selected (activeIndex labels i))) + (2*(4*P.length (QMAEvenRouteData.selected (activeIndex labels i))-1)+2-k))=_ + rw [selected_index labels i,he] + change _=[_,_,_] + exact congrArg₂ List.cons h0.symm + (congrArg₂ List.cons h1.symm (congrArg₂ List.cons h2.symm rfl)) + +theorem positions_eq : + (List.ofFn (fun v => qmaLeafCenter (P.position v)))++ + ((List.ofFn (originalPath P labels)).map QuantumEvenListPieces.fresh).flatten= + List.ofFn (fun v => P.toEven.nextPosition (vertex labels v)) := by + rw [List.ofFn_add] + apply congrArg₂ (· ++ ·) + · apply congrArg List.ofFn + funext v + change qmaLeafCenter (P.position v)=P.toEven.nextPosition (vertex labels (old G.n m v)) + rw [vertex_old,QMAEvenRouteData.nextPosition_old] + rfl + · rw [List.map_ofFn,List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + dsimp only [Function.comp_apply] + rw [fresh_eq] + have hf (a : Fin 2) : P.toEven.nextPosition (vertex labels + ((⟨i.val*2+a.val,by omega⟩ : Fin (m*2)).natAdd G.n))= + P.toEven.freshPosition (activeIndex labels i) a := by + have he : ((⟨i.val*2+a.val,by omega⟩ : Fin (m*2)).natAdd G.n)=fresh G.n m i a := by + apply Fin.ext + change G.n+(i.val*2+a.val)=G.n+(a.val+2*i.val) + omega + rw [he,vertex_fresh,QMAEvenRouteData.nextPosition_fresh] + simp only [hf,List.ofFn_succ,List.ofFn_zero,Fin.succ_zero_eq_one] + +theorem allPaths_eq : + ((List.ofFn (originalPath P labels)).map QuantumEvenListPieces.paths).flatten= + List.ofFn (fun k : Fin (m*3) => + (List.range (2*work P labels (finProdFinEquiv.symm k)+2)).map + (P.toEven.nextPoint (edge labels (finProdFinEquiv.symm k)))) := by + rw [List.map_ofFn,List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + dsimp only [Function.comp_apply] + rw [paths_eq] + apply congrArg List.ofFn + funext k + have he : (⟨i.val*3+k.val,by omega⟩ : Fin (m*3))=finProdFinEquiv (i,k) := by + apply Fin.ext + change i.val*3+k.val=k.val+3*i.val + omega + rw [he,Equiv.symm_apply_apply] + +end ContinuumCoulomb.QuantumEvenRouteLabels + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRoutePlacement.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRoutePlacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e09033f4d4a70f459df596e13df50f161af39a5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRoutePlacement.lean @@ -0,0 +1,193 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenRouteData + +namespace OAI + +/-! The even gadget places its interacting vertex at route point one and its +second singlet spin at the reserved leaf. The remaining routes have odd length. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical +namespace QMAEvenRouteData +variable {G : QMARationalExchangeGraph} (P : QMAEvenRouteData G) + +def nextPoint (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) (k : ℕ) : ℕ × ℕ := + match e with + | .inl e => P.point e.val k + | .inr (.inl i) => if k = 0 then P.point (selected i) 1 else P.leaf (selected i) + | .inr (.inr (i,a)) => if a = 0 then P.point (selected i) k + else P.point (selected i) (2*P.work (selected i)+2-k) + +theorem nextPoint_first (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) : + P.nextPoint e 0 = P.nextPosition (qmaPartialPathsLeft G.left G.right Finset.univ e) := by + rcases e with e | (i | ⟨i,a⟩) + · exact (e.property (Finset.mem_univ _)).elim + · change P.point (selected i) 1 = P.nextPosition (fresh _ _ i 0) + rw [nextPosition_fresh] + rfl + · fin_cases a + · change P.point (selected i) 0 = P.nextPosition (old _ _ (G.left (selected i))) + rw [nextPosition_old] + exact P.first _ + · change P.point (selected i) (2*P.work (selected i)+2) = + P.nextPosition (old _ _ (G.right (selected i))) + rw [nextPosition_old] + exact P.last _ + +theorem nextPoint_last (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) : + P.nextPoint e (2*P.nextWork e+1) = + P.nextPosition (qmaPartialPathsRight G.right Finset.univ (fun _ => true) e) := by + rcases e with e | (i | ⟨i,a⟩) + · exact (e.property (Finset.mem_univ _)).elim + · change P.leaf (selected i) = P.nextPosition (fresh _ _ i 1) + rw [nextPosition_fresh] + rfl + · fin_cases a + · change P.point (selected i) 1 = P.nextPosition (fresh _ _ i 0) + rw [nextPosition_fresh] + rfl + · change P.point (selected i) (2*P.work (selected i)+2-(2*P.work (selected i)+1)) = + P.nextPosition (fresh _ _ i 0) + rw [nextPosition_fresh] + change P.point (selected i) _ = P.point (selected i) 1 + congr 1 + omega + +theorem nextPoint_simple (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) (i j : ℕ) + (hi : i ≤ 2*P.nextWork e+1) (hj : j ≤ 2*P.nextWork e+1) + (h : P.nextPoint e i = P.nextPoint e j) : i = j := by + rcases e with e | (a | ⟨a,b⟩) + · exact (e.property (Finset.mem_univ _)).elim + · simp only [nextWork,Nat.mul_zero,Nat.zero_add] at hi hj + by_cases hi0 : i = 0 <;> by_cases hj0 : j = 0 + · omega + · have hj1 : j = 1 := by omega + subst i + subst j + exact (P.leaf_avoids (selected a) (selected a) 1 (by omega) h.symm).elim + · have hi1 : i = 1 := by omega + subst i + subst j + exact (P.leaf_avoids (selected a) (selected a) 1 (by omega) h).elim + · omega + · fin_cases b + · simp [nextWork] at hi hj + exact P.simple (selected a) i j (by omega) (by omega) h + · simp [nextWork] at hi hj + change P.point (selected a) (2*P.work (selected a)+2-i) = + P.point (selected a) (2*P.work (selected a)+2-j) at h + have he := P.simple (selected a) _ _ (Nat.sub_le _ _) (Nat.sub_le _ _) h + omega + +theorem nextPoint_step (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) (i : ℕ) + (hi : i < 2*P.nextWork e+1) : qmaSquareGrid.Adj (P.nextPoint e i) (P.nextPoint e (i+1)) := by + rcases e with e | (a | ⟨a,b⟩) + · exact (e.property (Finset.mem_univ _)).elim + · have hi0 : i = 0 := by simp [nextWork] at hi; omega + subst i + exact P.leaf_step (selected a) + · fin_cases b + · have hi0 : i = 0 := by simp [nextWork] at hi; omega + subst i + exact P.step (selected a) 0 (by omega) + · simp [nextWork] at hi + have hk : 2*P.work (selected a)+2-(i+1) < 2*P.work (selected a)+2 := by omega + have he : 2*P.work (selected a)+2-i = (2*P.work (selected a)+2-(i+1))+1 := by omega + change qmaSquareGrid.Adj (P.point (selected a) (2*P.work (selected a)+2-i)) + (P.point (selected a) (2*P.work (selected a)+2-(i+1))) + rw [he] + exact (P.step (selected a) _ hk).symm + +theorem nextPoint_avoids (e : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) (i : ℕ) + (v : Fin (G.n+(Finset.univ : Finset G.Edge).card*2)) + (hi0 : 0 < i) (hi : i < 2*P.nextWork e+1) : P.nextPoint e i ≠ P.nextPosition v := by + rcases e with e | (a | ⟨a,b⟩) + · exact (e.property (Finset.mem_univ _)).elim + · simp [nextWork] at hi + omega + · fin_cases b + · simp [nextWork] at hi + omega + simp [nextWork] at hi + have hidx0 : 1 < 2*P.work (selected a)+2-i := by omega + have hidx : 2*P.work (selected a)+2-i < 2*P.work (selected a)+2 := by omega + obtain ⟨v,rfl⟩ := (vertexEquiv G.n (Finset.univ : Finset G.Edge).card).surjective v + rcases v with v | ⟨c,d⟩ + · change P.point (selected a) (2*P.work (selected a)+2-i) ≠ P.nextPosition (old _ _ v) + rw [nextPosition_old] + exact P.avoids _ _ v (by omega) hidx + · change P.point (selected a) (2*P.work (selected a)+2-i) ≠ P.nextPosition (fresh _ _ c d) + rw [nextPosition_fresh] + fin_cases d + · intro h + by_cases he : selected a = selected c + · change P.point (selected a) _ = P.point (selected c) 1 at h + rw [← he] at h + have hx := P.simple (selected a) _ 1 (Nat.sub_le _ _) (by omega) h + omega + · exact P.disjoint _ _ _ 1 he (by omega) hidx (by omega) h + · intro h + exact P.leaf_avoids (selected c) (selected a) _ (Nat.sub_le _ _) h.symm + +theorem nextPoint_disjoint (e f : QMAPartialPathsEdge (Finset.univ : Finset G.Edge)) (i j : ℕ) + (hef : e ≠ f) (hi0 : 0 < i) (hi : i < 2*P.nextWork e+1) (hj : j ≤ 2*P.nextWork f+1) : + P.nextPoint e i ≠ P.nextPoint f j := by + rcases e with e | (a | ⟨a,b⟩) + · exact (e.property (Finset.mem_univ _)).elim + · simp [nextWork] at hi + omega + · fin_cases b + · simp [nextWork] at hi + omega + simp [nextWork] at hi + have hidx0 : 1 < 2*P.work (selected a)+2-i := by omega + have hidx : 2*P.work (selected a)+2-i < 2*P.work (selected a)+2 := by omega + intro h + rcases f with f | (c | ⟨c,d⟩) + · exact (f.property (Finset.mem_univ _)).elim + · by_cases hj0 : j = 0 + · change P.point (selected a) _ = (if j = 0 then P.point (selected c) 1 else _) at h + simp only [hj0,ite_true] at h + by_cases he : selected a = selected c + · rw [← he] at h + have hx := P.simple (selected a) _ 1 (Nat.sub_le _ _) (by omega) h + omega + · exact P.disjoint _ _ _ 1 he (by omega) hidx (by omega) h + · change P.point (selected a) _ = (if j = 0 then _ else P.leaf (selected c)) at h + simp only [hj0,ite_false] at h + exact P.leaf_avoids (selected c) (selected a) _ (Nat.sub_le _ _) h.symm + · fin_cases d + · simp [nextWork] at hj + change P.point (selected a) _ = P.point (selected c) j at h + by_cases he : selected a = selected c + · rw [← he] at h + have hx := P.simple (selected a) _ j (Nat.sub_le _ _) (by omega) h + omega + · exact P.disjoint _ _ _ j he (by omega) hidx (by omega) h + · simp [nextWork] at hj + change P.point (selected a) _ = P.point (selected c) (2*P.work (selected c)+2-j) at h + have he : selected a = selected c := by + by_contra hn + exact P.disjoint _ _ _ _ hn (by omega) hidx (Nat.sub_le _ _) h + have hac := selected_injective he + subst c + exact hef rfl + +def embedding (N : ℚ) : QMAPathEmbedding (P.schedule N) where + position := P.nextPosition + position_injective := P.nextPosition_injective + point := P.nextPoint + first := P.nextPoint_first + last := P.nextPoint_last + simple := P.nextPoint_simple + step := P.nextPoint_step + avoids := P.nextPoint_avoids + disjoint := P.nextPoint_disjoint + +end QMAEvenRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..89912c04b3bb1ac9b5633607beaa30b7dacd7180 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenRouteRealization.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenRoutePlacement + +namespace OAI + +/-! Full even-route realization from the reserved-leaf placement. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical +namespace QMAEvenRouteData +variable {G : QMARationalExchangeGraph} (P : QMAEvenRouteData G) + +def Bounded (X Y : ℕ) : Prop := + (∀ v, (P.position v).1 < X ∧ (P.position v).2 < Y) ∧ + (∀ e k, k ≤ 2*P.work e+2 → (P.point e k).1 < X ∧ (P.point e k).2 < Y) ∧ + ∀ e, (P.leaf e).1 < X ∧ (P.leaf e).2 < Y + +theorem embedding_bounded (N : ℚ) {X Y : ℕ} (h : P.Bounded X Y) : + (P.embedding N).Bounded X Y := by + constructor + · change ∀ v : Fin (G.n+(Finset.univ : Finset G.Edge).card*2), + (P.nextPosition v).1 < X ∧ (P.nextPosition v).2 < Y + intro v + obtain ⟨v,rfl⟩ := (vertexEquiv G.n (Finset.univ : Finset G.Edge).card).surjective v + rcases v with v | ⟨i,b⟩ + · change (P.nextPosition (old _ _ v)).1 < X ∧ (P.nextPosition (old _ _ v)).2 < Y + simpa only [nextPosition_old] using h.1 v + · change (P.nextPosition (fresh _ _ i b)).1 < X ∧ (P.nextPosition (fresh _ _ i b)).2 < Y + rw [nextPosition_fresh] + fin_cases b + · exact h.2.1 (selected i) 1 (by omega) + · exact h.2.2 (selected i) + · intro e k hk + change (P.nextPoint e k).1 < X ∧ (P.nextPoint e k).2 < Y + rcases e with e | (i | ⟨i,a⟩) + · exact (e.property (Finset.mem_univ _)).elim + · change (if k = 0 then P.point (selected i) 1 else P.leaf (selected i)).1 < X ∧ + (if k = 0 then P.point (selected i) 1 else P.leaf (selected i)).2 < Y + split + · exact h.2.1 (selected i) 1 (by omega) + · exact h.2.2 (selected i) + · fin_cases a + · have hk' : k ≤ 1 := hk + exact h.2.1 (selected i) k (by omega) + · exact h.2.1 (selected i) (2*P.work (selected i)+2-k) (Nat.sub_le _ _) + +theorem schedule_degree (N : ℚ) {d : ℕ} (h3 : 3 ≤ d) + (hd : ∀ v, qmaGraphDegree G.left G.right v ≤ d) : + ∀ v, qmaGraphDegree (P.schedule N).graph.left (P.schedule N).graph.right v ≤ d := by + intro v + obtain ⟨v,rfl⟩ := (vertexEquiv G.n (Finset.univ : Finset G.Edge).card).surjective v + rcases v with v | ⟨i,b⟩ + · change qmaGraphDegree (qmaPartialPathsLeft G.left G.right Finset.univ) + (qmaPartialPathsRight G.right Finset.univ (fun _ => true)) (old _ _ v) ≤ d + rw [qmaPartialPaths_old_degree _ _ G.distinct] + exact hd v + · change qmaGraphDegree (qmaPartialPathsLeft G.left G.right Finset.univ) + (qmaPartialPathsRight G.right Finset.univ (fun _ => true)) (fresh _ _ i b) ≤ d + exact (qmaPartialPaths_fresh_degree _ _ _ _ i b).trans h3 + +theorem schedule_size (N : ℚ) : + (P.schedule N).graph.n+Fintype.card (P.schedule N).graph.Edge ≤ + 5*(G.n+Fintype.card G.Edge) := by + change G.n+(Finset.univ : Finset G.Edge).card*2+ + Fintype.card (G.subdivide Finset.univ (fun _ => true) N).Edge ≤ _ + rw [QMARationalExchangeGraph.subdivide_edge_count] + simp only [Finset.card_univ] + omega + +theorem realize {N : ℚ} (hN : 0 < N) {D X Y d : ℕ} (h3 : 3 ≤ d) + (hD : ∀ e, P.work e ≤ D) (hbox : P.Bounded X Y) + (hd : ∀ v, qmaGraphDegree G.left G.right v ≤ d) : + ∃ (H : QMARationalExchangeGraph) (position : Fin H.n → ℕ × ℕ), + Function.Injective position ∧ + (∀ v, (position v).1 < X ∧ (position v).2 < Y) ∧ + (∀ e, qmaSquareGrid.Adj (position (H.left e)) (position (H.right e))) ∧ + (∀ v, qmaGraphDegree H.left H.right v ≤ d) ∧ + H.n+Fintype.card H.Edge ≤ 5^(D+1)*(G.n+Fintype.card G.Edge) ∧ + |H.energy-G.energy| ≤ ((D+1:ℕ):ℝ)/(N:ℝ) := by + obtain ⟨H,p,hp,hbox',ha,hd',hs,he⟩ := (P.embedding N).realize hN h3 + (P.schedule_work_le N hD) (P.embedding_bounded N hbox) (P.schedule_degree N h3 hd) + refine ⟨H,p,hp,hbox',ha,hd',?_,?_⟩ + · exact hs.trans (by simpa [pow_succ,mul_assoc] using + Nat.mul_le_mul_left (5^D) (P.schedule_size N)) + · calc + _ ≤ |H.energy-(P.schedule N).graph.energy|+|(P.schedule N).graph.energy-G.energy| := + abs_sub_le _ _ _ + _ ≤ (D:ℝ)/(N:ℝ)+1/(N:ℝ) := add_le_add he (P.schedule_energy_error hN) + _ = ((D+1:ℕ):ℝ)/(N:ℝ) := by push_cast; ring + +end QMAEvenRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb579b3ebfee667813b5b91ebfd234221af27b8a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeGeometry.lean @@ -0,0 +1,247 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenRouteLabels +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPackedSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarRouteRealization +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFinalRoutingProgram + +namespace OAI + +/-! The literal even tape has the canonical reserved-leaf geometry, up to +its explicit vertex and triple-edge ordering. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEvenTapeGeometry +open QuantumRouteCode QuantumListSchedule MediatorGraph +open scoped Classical + +variable {G : QMARationalExchangeGraph} (P : QMAPlanarRouteData G) + {m : ℕ} (labels : G.Edge ≃ Fin m) (N : ℚ) + +def input : QuantumEvenTapeProgram.Input := + (N,((G.n,QuantumListGraph.packed G labels,G.constant), + List.ofFn P.position,List.ofFn (QuantumEvenRouteLabels.originalPath P labels))) + +theorem input_valid : Valid (QuantumEvenTapeProgram.value (input P labels N)).1 := + QuantumEvenTapeProgram.value_valid _ (QuantumListGraph.packed_bounded G labels) + +theorem count_eq : (QuantumEvenTapeProgram.value (input P labels N)).1.1=G.n+m*2 := by + change G.n+(QuantumListGraph.packed G labels).length*2=G.n+m*2 + simp only [QuantumListGraph.packed,List.length_ofFn] + +theorem bonds_length : (input P labels N).2.1.2.1.length=m := by + exact List.length_ofFn + +def tripleEquiv : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length ≃ + Fin m × Fin 3 := + (QuantumEvenTapeProgram.tagEquiv (input P labels N)).trans + (Equiv.prodCongr (finCongr (bonds_length P labels N)) (Equiv.refl _)) + +def vertex : Fin (QuantumEvenTapeProgram.value (input P labels N)).1.1 ≃ + Fin (P.toEven.schedule N).graph.n := + (finCongr (count_eq P labels N)).trans (QuantumEvenRouteLabels.vertex labels) + +def edge : (schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).graph.Edge ≃ (P.toEven.schedule N).graph.Edge := + (tripleEquiv P labels N).trans (QuantumEvenRouteLabels.edgeEquiv labels) + +theorem route_eq (i : Fin m) : QuantumEvenTapeProgram.route (input P labels N) i.val= + QuantumEvenRouteLabels.originalPath P labels i := by + unfold QuantumEvenTapeProgram.route input + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_ofFn] + simp only [dite_eq_left i.isLt,Option.getD_some] + +theorem source_eq (i : Fin m) : + QuantumListSchedule.blockBondInput + (QuantumEvenTapeProgram.blockInput (i.val,input P labels N))= + (QuantumListPathStep.parameters (QuantumEvenTapeProgram.stepInput (input P labels N)), + i.val,(G.left (labels.symm i)).val,(G.right (labels.symm i)).val,G.weight (labels.symm i)) := by + unfold blockBondInput QuantumEvenTapeProgram.blockInput input QuantumListGraph.packed + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_ofFn] + simp only [dite_eq_left i.isLt,Option.getD_some] + +def tagLeft (t : Fin m × Fin 3) : Fin (G.n+m*2) := + ![fresh G.n m t.1 0,old G.n m (G.left (labels.symm t.1)), + old G.n m (G.right (labels.symm t.1))] t.2 +def tagRight (t : Fin m × Fin 3) : Fin (G.n+m*2) := + ![fresh G.n m t.1 1,fresh G.n m t.1 0,fresh G.n m t.1 0] t.2 + +private theorem fresh_val (i : Fin m) (a : Fin 2) : + (fresh G.n m i a).val=G.n+2*i.val+a.val := by + change G.n+(a.val+2*i.val)=_ + omega + +private theorem old_val (v : Fin G.n) : (old G.n m v).val=v.val := rfl + +theorem tag_left (t : Fin m × Fin 3) : + QuantumEvenRouteLabels.vertex labels (tagLeft labels t)= + (P.toEven.schedule N).graph.left (QuantumEvenRouteLabels.edge labels t) := by + rcases t with ⟨i,k⟩ + fin_cases k + · exact QuantumEvenRouteLabels.vertex_fresh labels i 0 + · change QuantumEvenRouteLabels.vertex labels (old G.n m (G.left (labels.symm i)))= + old _ _ (G.left (QMAEvenRouteData.selected (QuantumEvenRouteLabels.activeIndex labels i))) + rw [QuantumEvenRouteLabels.selected_index,QuantumEvenRouteLabels.vertex_old] + · change QuantumEvenRouteLabels.vertex labels (old G.n m (G.right (labels.symm i)))= + old _ _ (G.right (QMAEvenRouteData.selected (QuantumEvenRouteLabels.activeIndex labels i))) + rw [QuantumEvenRouteLabels.selected_index,QuantumEvenRouteLabels.vertex_old] + +theorem tag_right (t : Fin m × Fin 3) : + QuantumEvenRouteLabels.vertex labels (tagRight (G := G) t)= + (P.toEven.schedule N).graph.right (QuantumEvenRouteLabels.edge labels t) := by + rcases t with ⟨i,k⟩ + fin_cases k + · exact QuantumEvenRouteLabels.vertex_fresh labels i 1 + · exact QuantumEvenRouteLabels.vertex_fresh labels i 0 + · exact QuantumEvenRouteLabels.vertex_fresh labels i 0 + +theorem entry_tag (e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + (QuantumEvenTapeProgram.entries (input P labels N)).get e= + (blockWork (QuantumEvenTapeProgram.blockInput + ((tripleEquiv P labels N e).1.val,input P labels N)) (tripleEquiv P labels N e).2, + QuantumListPathProgram.bond (blockBondInput (QuantumEvenTapeProgram.blockInput + ((tripleEquiv P labels N e).1.val,input P labels N))) (tripleEquiv P labels N e).2) := + QuantumEvenTapeProgram.tagEquiv_get _ e + +theorem literal_left (e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + finCongr (count_eq P labels N) + ((schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).graph.left e)=tagLeft labels (tripleEquiv P labels N e) := by + apply Fin.ext + change ((QuantumEvenTapeProgram.entries (input P labels N)).get e).2.1=_ + rw [entry_tag] + generalize tripleEquiv P labels N e=t + rcases t with ⟨i,k⟩ + rw [source_eq] + fin_cases k <;> simp [QuantumListPathProgram.bond,QuantumListPathProgram.left,tagLeft, + QuantumListPathStep.parameters,QuantumEvenTapeProgram.stepInput,input,old_val,fresh_val] + +theorem literal_right (e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + finCongr (count_eq P labels N) + ((schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).graph.right e)=tagRight (G := G) (tripleEquiv P labels N e) := by + apply Fin.ext + change ((QuantumEvenTapeProgram.entries (input P labels N)).get e).2.2.1=_ + rw [entry_tag] + generalize tripleEquiv P labels N e=t + rcases t with ⟨i,k⟩ + rw [source_eq] + fin_cases k <;> simp [QuantumListPathProgram.bond,QuantumListPathProgram.right,tagRight, + QuantumListPathStep.parameters,QuantumEvenTapeProgram.stepInput,input,fresh_val] + +theorem literal_work (e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + (schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).work e= + QuantumEvenRouteLabels.work P labels (tripleEquiv P labels N e) := by + change ((QuantumEvenTapeProgram.entries (input P labels N)).get e).1=_ + rw [entry_tag] + generalize tripleEquiv P labels N e=t + rcases t with ⟨i,k⟩ + change (if k=2 then 4*((QuantumEvenTapeProgram.route (input P labels N) i.val).length-1)-1 + else 0)=_ + rw [route_eq] + simp only [QuantumEvenRouteLabels.originalPath,List.length_map,List.length_range, + Nat.add_sub_cancel,QuantumEvenRouteLabels.work] + +def relabel : QMAPathRelabeling + (schedule (QuantumEvenTapeProgram.value (input P labels N)).1 (input_valid P labels N)) + (P.toEven.schedule N) where + vertex := vertex P labels N + edge := edge P labels N + left e := (congrArg (QuantumEvenRouteLabels.vertex labels) + (literal_left P labels N e)).trans (tag_left P labels N _) + right e := (congrArg (QuantumEvenRouteLabels.vertex labels) + (literal_right P labels N e)).trans (tag_right P labels N _) + work e := (literal_work P labels N e).trans + (QuantumEvenRouteLabels.work_eq P labels _).symm + +def embedding : QMAPathEmbedding + (schedule (QuantumEvenTapeProgram.value (input P labels N)).1 (input_valid P labels N)) := + (relabel P labels N).symm.transport (P.toEven.embedding N) + +private theorem ofFn_cast {α : Type} {a b : ℕ} (h : a=b) (f : Fin b → α) : + List.ofFn (fun i => f (finCongr h i))=List.ofFn f := by + subst b + rfl + +theorem entry_count : (QuantumEvenTapeProgram.entries (input P labels N)).length=m*3 := by + rw [QuantumEvenTapeProgram.entries_length,bonds_length] + +theorem triple_cast (i : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + tripleEquiv P labels N i=finProdFinEquiv.symm (finCongr (entry_count P labels N) i) := by + apply Prod.ext <;> apply Fin.ext <;> rfl + +theorem represents : QuantumListRouteProgram.Represents + (QuantumEvenTapeProgram.value (input P labels N)) (input_valid P labels N) + (embedding P labels N) := by + constructor + · change QuantumEvenTapeProgram.positions (input P labels N)= + List.ofFn (fun i => P.toEven.nextPosition + (QuantumEvenRouteLabels.vertex labels (finCongr (count_eq P labels N) i))) + have hp : QuantumEvenTapeProgram.positions (input P labels N)= + List.ofFn (fun i => P.toEven.nextPosition (QuantumEvenRouteLabels.vertex labels i)) := by + simpa only [QuantumEvenTapeProgram.positions,input,List.map_ofFn,Function.comp_def] using + QuantumEvenRouteLabels.positions_eq P labels + exact hp.trans (ofFn_cast (count_eq P labels N) + (fun i => P.toEven.nextPosition (QuantumEvenRouteLabels.vertex labels i))).symm + · change QuantumEvenTapeProgram.paths (input P labels N)= + List.ofFn (fun e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length => + (List.range (2*(schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).work e+2)).map + (P.toEven.nextPoint (QuantumEvenRouteLabels.edge labels (tripleEquiv P labels N e)))) + simp_rw [literal_work,triple_cast] + have hp : QuantumEvenTapeProgram.paths (input P labels N)= + List.ofFn (fun k : Fin (m*3) => + (List.range (2*QuantumEvenRouteLabels.work P labels (finProdFinEquiv.symm k)+2)).map + (P.toEven.nextPoint (QuantumEvenRouteLabels.edge labels (finProdFinEquiv.symm k)))) := + QuantumEvenRouteLabels.allPaths_eq P labels + exact hp.trans (ofFn_cast (entry_count P labels N) + (fun k : Fin (m*3) => + (List.range (2*QuantumEvenRouteLabels.work P labels (finProdFinEquiv.symm k)+2)).map + (P.toEven.nextPoint (QuantumEvenRouteLabels.edge labels (finProdFinEquiv.symm k))))).symm + +theorem work_le (hL : ∀ e, P.length e≤20) : + ∀ e ∈ (QuantumEvenTapeProgram.value (input P labels N)).1.2.2, e.1≤80 := by + intro e he + obtain ⟨i,rfl⟩ := List.mem_iff_get.mp he + let j : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length := ⟨i.val,i.isLt⟩ + change (schedule (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).work j≤80 + rw [literal_work P labels N j] + unfold QuantumEvenRouteLabels.work + split + · have h := hL (labels.symm (tripleEquiv P labels N j).1) + omega + · omega + +theorem embedding_bounded {X Y : ℕ} (hbox : P.Bounded X Y) : + (embedding P labels N).Bounded (8*X) (8*Y) := + (relabel P labels N).symm.transport_bounded (P.toEven.embedding N) + (P.toEven.embedding_bounded N (P.toEven_bounded hbox)) + +theorem realizes (hN : 0 block (blockInput (i.val,x)))).flatten := by + apply congrArg List.flatten + simpa only [List.length_range,List.getElem_range,Fin.val_cast] using + (List.ofFn_getElem_eq_map (List.range x.2.1.2.1.length) + (fun i => block (blockInput (i,x)))).symm + +private theorem ofFn_triples {m : ℕ} (f : Fin m × Fin 3 → Entry) : + List.ofFn (fun k : Fin (m*3) => f (finProdFinEquiv.symm k))= + (List.ofFn (fun i : Fin m => List.ofFn (fun k : Fin 3 => f (i,k)))).flatten := by + rw [List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext i + apply congrArg List.ofFn + funext k + have he : (⟨i.val*3+k.val,by omega⟩ : Fin (m*3))=finProdFinEquiv (i,k) := by + apply Fin.ext + change i.val*3+k.val=k.val+3*i.val + omega + rw [he,Equiv.symm_apply_apply] + +theorem entries_ofFn (x : Input) : entries x= + List.ofFn (fun i : Fin (x.2.1.2.1.length*3) => tagValue x (finProdFinEquiv.symm i)) := by + rw [ofFn_triples,entries_nested] + rfl + +theorem entries_length (x : Input) : (entries x).length=x.2.1.2.1.length*3 := by + rw [entries_ofFn,List.length_ofFn] + +def tagEquiv (x : Input) : Fin (entries x).length ≃ Tags x := + (finCongr (entries_length x)).trans finProdFinEquiv.symm + +theorem tagEquiv_get (x : Input) (i : Fin (entries x).length) : + (entries x).get i=tagValue x (tagEquiv x i) := by + have hi : i.val xs[i.val]?) (entries_ofFn x) + have hc : Fin.cast (entries_length x) i=⟨i.val,hi⟩ := Fin.ext rfl + change (entries x).get i=tagValue x (finProdFinEquiv.symm (Fin.cast (entries_length x) i)) + rw [hc] + simpa only [List.getElem?_eq_getElem i.isLt,List.getElem?_ofFn,dite_eq_left hi, + Option.some.injEq,List.get_eq_getElem] using h + +end ContinuumCoulomb.QuantumEvenTapeProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeOutputBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeOutputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..d98a8fcdce44e6b2fdbbe570719e825956fcd343 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeOutputBounds.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenTapeWeights +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteOutputBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientPrograms + +namespace OAI + +/-! A uniform source promise for the literal even tape followed by the +fixed final routing rounds, with a common numerical envelope for the +spatial compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEvenTapeGeometry +open QuantumListSchedule QuantumCoefficientPrograms +open scoped Classical + +variable {G : QMARationalExchangeGraph} (P : QMAPlanarRouteData G) + {r : ℕ} (labels : G.Edge ≃ Fin r) {N : ℚ} + +theorem output_polynomialPromise (hN : 0 < N) (hpath : ∀ e, P.length e ≤ 20) + {X Y m L T n k : ℕ} (hbox : P.Bounded X Y) (hn : 0 < G.n) + (hm : Fintype.card G.Edge ≤ m) (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) + (hc : G.CoefficientBound L) (hsize : n ≤ G.n) + (a b : ℚ) (hab : a < b) + (hx : (8*X:ℕ) ≤ (n+1:ℝ)^k) (hy : (8*Y:ℕ) ≤ (n+1:ℝ)^k) + (hw : ((3^81*m+1)*iterated (3*m) (pathCoefficient m L T) T 80:ℕ) ≤ (n+1:ℝ)^k) + (hgap : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (QuantumListRouteProgram.latticeOutput + (QuantumListRouteProgram.iterate N QuantumFinalRoutingProgram.rounds + (QuantumEvenTapeProgram.value (input P labels N))) a b).PolynomialPromise k := by + have hr : r ≤ m := by + have he : Fintype.card G.Edge=r := (Fintype.card_congr labels).trans (Fintype.card_fin r) + omega + have hm' : (Fintype.card G.Edge:ℝ) ≤ m := by exact_mod_cast hm + have hc' := coefficientBound P labels N hN.le hm' (by exact_mod_cast hL) hT hc + have hn' : G.n ≤ (QuantumEvenTapeProgram.value (input P labels N)).1.1 := by + rw [count_eq] + exact Nat.le_add_right _ _ + have hcount : ((QuantumEvenTapeProgram.value (input P labels N)).1.2.2.length:ℝ) ≤ 3*(m:ℝ) := by + have he := entry_count P labels N + have hh : (QuantumEvenTapeProgram.value (input P labels N)).1.2.2.length ≤ 3*m := by + change (QuantumEvenTapeProgram.entries (input P labels N)).length ≤ _ + rw [he] + omega + exact_mod_cast hh + have hC1 : (1:ℝ) ≤ qmaPathCoefficientBound m L T := + qmaPathCoefficientBound_one (Nat.cast_nonneg _) (by exact_mod_cast hL) + apply QuantumListRouteProgram.compiled_polynomialPromise hN + (QuantumEvenTapeProgram.value (input P labels N)) (input_valid P labels N) + (embedding P labels N) (represents P labels N) + (by rw [QuantumFinalRoutingProgram.rounds_eq]; exact work_le P labels N hpath) + (embedding_bounded P labels N hbox) (hn.trans_le hn') a b hab n k (hsize.trans hn') + hx hy hcount hC1 hT hc' ?_ hgap + have hC0 : (0:ℝ) ≤ iterated (3*m) (pathCoefficient m L T) T 80 := Nat.cast_nonneg _ + calc + (3^QuantumFinalRoutingProgram.rounds*(3*(m:ℝ)))* + qmaPathIteratedBound (3*(m:ℝ)) (qmaPathCoefficientBound m L T) T + QuantumFinalRoutingProgram.rounds = + (3^81*(m:ℝ))*(iterated (3*m) (pathCoefficient m L T) T 80:ℝ) := by + rw [QuantumFinalRoutingProgram.rounds_eq] + rw [← pathCoefficient_cast] + have he := iterated_cast (3*m) (pathCoefficient m L T) T 80 + simp only [Nat.cast_mul,Nat.cast_ofNat] at he + rw [← he] + ring + _ ≤ ((3^81*m+1)*iterated (3*m) (pathCoefficient m L T) T 80:ℕ) := by + push_cast + nlinarith + _ ≤ _ := hw + +end ContinuumCoulomb.QuantumEvenTapeGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ea3a496351cb7ef3725ddb5117fc285d5f3a508 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvenTapeProgram.lean @@ -0,0 +1,150 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPlanarTapeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenListPieces +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListSchedule + +namespace OAI + +/-! One literal even subdivision, with its reserved leaf and odd route tails. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumEvenTapeProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode MediatorListProgram + +abbrev Input := ℚ × QuantumPlanarTapeProgram.Output +def inputCode : Input → List Bool := prodCode ratCode QuantumPlanarTapeProgram.outputCode +def stepInput (x : Input) : QuantumListPathStep.Input := + ((x.2.1.1,true,x.1,x.2.1.2.2),([],x.2.1.2.1)) +def route (x : Input) (i : ℕ) : List Pair := (x.2.2.2.drop i).headD [] +def blockInput (x : ℕ × Input) : QuantumListSchedule.BlockInput := + (QuantumListPathStep.parameters (stepInput x.2),x.1, + 4*((route x.2 x.1).length-1),(x.2.2.1.2.1.drop x.1).headD zeroBond) +def entries (x : Input) : List QuantumListSchedule.Entry := + ((List.range x.2.1.2.1.length).map (fun i => QuantumListSchedule.block (blockInput (i,x)))).flatten +def positions (x : Input) : List Pair := + x.2.2.1.map qmaLeafCenter++(x.2.2.2.map QuantumEvenListPieces.fresh).flatten +def paths (x : Input) : List (List Pair) := (x.2.2.2.map QuantumEvenListPieces.paths).flatten +def value (x : Input) : QuantumListRouteProgram.State := + ((QuantumListPathStep.count (stepInput x),QuantumListPathStep.constant (stepInput x),entries x), + positions x,paths x) + +noncomputable opaque precisionProgram : Procedure inputCode ratCode Prod.fst := Procedure.first _ _ +noncomputable opaque dataProgram : Procedure inputCode QuantumPlanarTapeProgram.outputCode Prod.snd := + Procedure.second _ _ +noncomputable opaque packetProgram : Procedure inputCode QuantumListPathStep.outputCode + (fun x => x.2.1) := (Procedure.first _ _).comp dataProgram +noncomputable opaque geometryProgram : Procedure inputCode + (prodCode (listCode pairCode) (listCode (listCode pairCode))) (fun x => x.2.2) := + (Procedure.second _ _).comp dataProgram +noncomputable opaque countProgram : Procedure inputCode unaryCode (fun x => x.2.1.1) := + (Procedure.first _ _).comp packetProgram +noncomputable opaque bondsProgram : Procedure inputCode (listCode bondCode) (fun x => x.2.1.2.1) := + ((Procedure.first (listCode bondCode) ratCode).comp + (Procedure.second unaryCode (prodCode (listCode bondCode) ratCode))).comp packetProgram +noncomputable opaque constantProgram : Procedure inputCode ratCode (fun x => x.2.1.2.2) := + ((Procedure.second (listCode bondCode) ratCode).comp + (Procedure.second unaryCode (prodCode (listCode bondCode) ratCode))).comp packetProgram +noncomputable opaque oldPositionsProgram : Procedure inputCode (listCode pairCode) + (fun x => x.2.2.1) := (Procedure.first _ _).comp geometryProgram +noncomputable opaque oldPathsProgram : Procedure inputCode (listCode (listCode pairCode)) + (fun x => x.2.2.2) := (Procedure.second _ _).comp geometryProgram +noncomputable opaque stepInputProgram : Procedure inputCode QuantumListPathStep.inputCode stepInput := + (countProgram.pair ((Procedure.constant inputCode Procedure.boolCode true).pair + (precisionProgram.pair constantProgram))).pair + ((Procedure.constant inputCode (listCode bondCode) []).pair bondsProgram) + +noncomputable opaque routeProgram : Procedure (prodCode unaryCode inputCode) (listCode pairCode) + (fun x => route x.2 x.1) := + (Procedure.listGet (listCode pairCode) []).comp + ((Procedure.unaryToBits.comp (Procedure.first unaryCode inputCode)).pair + (oldPathsProgram.comp (Procedure.second unaryCode inputCode))) +noncomputable opaque workProgram : Procedure (prodCode unaryCode inputCode) unaryCode + (fun x => 4*((route x.2 x.1).length-1)) := + Procedure.unaryMul.comp ((Procedure.constant _ unaryCode 4).pair + (Procedure.unaryPred.comp + ((ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength pairCode (0,0)).comp routeProgram))) +noncomputable opaque blockInputProgram : Procedure (prodCode unaryCode inputCode) + QuantumListSchedule.blockInputCode blockInput := by + let i := Procedure.first unaryCode inputCode + let x := Procedure.second unaryCode inputCode + let b := (Procedure.listGet bondCode zeroBond).comp + ((Procedure.unaryToBits.comp i).pair (bondsProgram.comp x)) + let p := (QuantumListPathStep.parametersProgram.comp stepInputProgram).comp x + exact p.pair (i.pair (workProgram.pair b)) +noncomputable opaque blockProgram : Procedure (prodCode unaryCode inputCode) + (listCode QuantumListSchedule.entryCode) + (fun x => QuantumListSchedule.block (blockInput x)) := + QuantumListSchedule.blockProgram.comp blockInputProgram +noncomputable opaque entriesTabProgram : Procedure (prodCode unaryCode inputCode) + (listCode (listCode QuantumListSchedule.entryCode)) + (fun x => (List.range x.1).map (fun i => QuantumListSchedule.block (blockInput (i,x.2)))) := + Procedure.tabulate (f := fun x i => QuantumListSchedule.block (blockInput (i,x))) [] blockProgram +noncomputable opaque bondCountProgram : Procedure inputCode unaryCode + (fun x => x.2.1.2.1.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp bondsProgram +noncomputable opaque entriesNestedProgram : Procedure inputCode + (listCode (listCode QuantumListSchedule.entryCode)) + (fun x => (List.range x.2.1.2.1.length).map + (fun i => QuantumListSchedule.block (blockInput (i,x)))) := + (entriesTabProgram.comp (bondCountProgram.pair (Procedure.identity inputCode))).congrFun + (by intro x; rfl) +noncomputable opaque entriesProgram : Procedure inputCode + (listCode QuantumListSchedule.entryCode) entries := + ((QuantumRawExchange.flattenProgram QuantumListSchedule.entryCode QuantumListSchedule.zeroEntry).comp + entriesNestedProgram).congrFun (by intro x; rfl) + +noncomputable opaque positionsProgram : Procedure inputCode (listCode pairCode) positions := + (Procedure.listAppend pairCode (0,0)).comp + (((Procedure.listMap (0,0) (0,0) QuantumRouteLeafCode.centerProgram).comp oldPositionsProgram).pair + ((QuantumRawExchange.flattenProgram pairCode (0,0)).comp + ((Procedure.listMap [] [] QuantumEvenListPieces.freshProgram).comp oldPathsProgram))) +noncomputable opaque pathsProgram : Procedure inputCode (listCode (listCode pairCode)) paths := + (QuantumRawExchange.flattenProgram (listCode pairCode) []).comp + ((Procedure.listMap [] [] QuantumEvenListPieces.pathsProgram).comp oldPathsProgram) +noncomputable opaque program : Procedure inputCode QuantumListRouteProgram.stateCode value := + (((QuantumListPathStep.countProgram.comp stepInputProgram).pair + ((QuantumListPathStep.constantProgram.comp stepInputProgram).pair entriesProgram)).pair + (positionsProgram.pair pathsProgram)) + +theorem erase_entries (x : Input) : + QuantumListSchedule.erase (entries x)=QuantumListPathStep.bonds (stepInput x) := by + unfold entries + simp only [QuantumListSchedule.erase,List.map_flatten,List.map_map] + change ((List.range x.2.1.2.1.length).map (fun i => + QuantumListSchedule.erase (QuantumListSchedule.block (blockInput (i,x))))).flatten=_ + simp_rw [QuantumListSchedule.erase_block] + rfl + +theorem value_valid (x : Input) + (hb : SourceBondLists.bounded x.2.1.1 x.2.1.2.1) : QuantumListSchedule.Valid (value x).1 := by + have hk : SourceBondLists.bounded x.2.1.1 ([] : List Bond) := by simp [SourceBondLists.bounded] + have hkn : ∀ e ∈ ([] : List Bond), e.1≠e.2.1 := by simp + constructor + · change SourceBondLists.bounded (QuantumListPathStep.count (stepInput x)) + (QuantumListSchedule.erase (entries x)) + rw [erase_entries] + exact QuantumListPathStep.bonds_bounded (stepInput x) hk hb + · change ∀ e ∈ QuantumListSchedule.erase (entries x), e.1≠e.2.1 + rw [erase_entries] + exact QuantumListPathStep.bonds_noLoops (stepInput x) hkn hb + +theorem value_energy_error (x : Input) + (hb : SourceBondLists.bounded x.2.1.1 x.2.1.2.1) + (hn : ∀ e ∈ x.2.1.2.1, e.1≠e.2.1) (hN : 0 f e.2.2)).sum = + ∑ i : Fin (Finset.univ : Finset G.Edge).card, + f (G.weight (QMAEvenRouteData.selected i)) := by + simp only [QuantumListGraph.packed,List.map_ofFn,List.sum_ofFn,Function.comp_def] + have h := (QuantumEvenRouteLabels.activeIndex labels).sum_comp + (fun i => f (G.weight (QMAEvenRouteData.selected i))) + simpa only [QuantumEvenRouteLabels.selected_index] using h + +theorem scale_eq : + (QuantumListPathStep.parameters (QuantumEvenTapeProgram.stepInput (input P labels N))).2.2 = + G.pathScale Finset.univ N := by + let p := QuantumListPathStep.scaleInput (QuantumEvenTapeProgram.stepInput (input P labels N)) + have ha : QuantumPathScaleProgram.active p = + 3*(∑ i : Fin (Finset.univ : Finset G.Edge).card, + (1+2*|G.weight (QMAEvenRouteData.selected i)|)) := by + change 3*(((QuantumListGraph.packed G labels).map (fun e => e.2.2)).map + QuantumPathScaleProgram.linearCost).sum = _ + rw [List.map_map] + exact congrArg (fun z : ℚ => 3*z) (packed_sum labels (fun q => 1+2*|q|)) + have hb : QuantumPathScaleProgram.base p = |G.constant| := by + change 3*(([] : List ℚ).map abs).sum+|G.constant| = _ + simp + have hs : (p.2.2.map QuantumPathScaleProgram.squareCost).sum = + ∑ i : Fin (Finset.univ : Finset G.Edge).card, + (1+|G.weight (QMAEvenRouteData.selected i)|)^2 := by + change (((QuantumListGraph.packed G labels).map (fun e => e.2.2)).map + QuantumPathScaleProgram.squareCost).sum = _ + rw [List.map_map] + exact packed_sum labels (fun q => (1+|q|)^2) + change QuantumPathScaleProgram.value p = _ + unfold QuantumPathScaleProgram.value QuantumPathScaleProgram.correction + rw [ha,hb,hs] + simp only [QMARationalExchangeGraph.pathScale] + have hz : (∑ e : {e : G.Edge // e ∉ (Finset.univ : Finset G.Edge)}, + |G.weight e.val|) = 0 := by + apply Finset.sum_eq_zero + intro e _ + exact (e.property (Finset.mem_univ _)).elim + rw [hz] + simp only [mul_zero,zero_add] + rfl + +theorem literal_weight (e : Fin (QuantumEvenTapeProgram.entries (input P labels N)).length) : + (QuantumListSchedule.graph (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).weight e = + (P.toEven.schedule N).graph.weight (edge P labels N e) := by + change ((QuantumEvenTapeProgram.entries (input P labels N)).get e).2.2.2 = _ + rw [entry_tag] + change _ = (P.toEven.schedule N).graph.weight + (QuantumEvenRouteLabels.edge labels (tripleEquiv P labels N e)) + generalize tripleEquiv P labels N e=t + rcases t with ⟨i,k⟩ + change QuantumListPathProgram.coefficient + (QuantumListSchedule.blockBondInput (QuantumEvenTapeProgram.blockInput + (i.val,input P labels N))) k.castSucc = _ + rw [source_eq] + unfold QuantumListPathProgram.coefficient + rw [scale_eq] + fin_cases k + · rfl + · rfl + · change QuantumPathCode.coefficients (true,G.pathScale Finset.univ N,G.weight (labels.symm i)) 2 = + QuantumPathCode.coefficients (true,G.pathScale Finset.univ N, + G.weight (QMAEvenRouteData.selected (QuantumEvenRouteLabels.activeIndex labels i))) 2 + rw [QuantumEvenRouteLabels.selected_index] + +theorem literal_constant : + (QuantumListSchedule.graph (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).constant = (P.toEven.schedule N).graph.constant := by + change G.constant+QuantumListPathProgram.familyOffset + (QuantumListPathStep.parameters (QuantumEvenTapeProgram.stepInput (input P labels N)), + QuantumListGraph.packed G labels) = _ + unfold QuantumListPathProgram.familyOffset QuantumListPathProgram.offset + QuantumListPathProgram.coefficient + change G.constant+((QuantumListGraph.packed G labels).map + (fun e => (3/4:ℚ)+3*e.2.2^2+3*(QuantumListPathStep.parameters + (QuantumEvenTapeProgram.stepInput (input P labels N))).2.2^2)).sum = _ + rw [scale_eq] + rw [packed_sum labels (fun q => (3/4:ℚ)+3*q^2+3*(G.pathScale Finset.univ N)^2), + Finset.sum_add_distrib] + simp only [Finset.sum_const,nsmul_eq_mul] + have hcard : (Finset.univ : Finset (Fin (Finset.univ : Finset G.Edge).card)).card = + (Finset.univ : Finset G.Edge).card := + (Finset.card_univ).trans (Fintype.card_fin _) + rw [hcard] + change G.constant+((∑ i : Fin (Finset.univ : Finset G.Edge).card, + ((3/4:ℚ)+3*(G.weight (QMAEvenRouteData.selected i))^2))+ + (Finset.univ : Finset G.Edge).card*(3*(G.pathScale Finset.univ N)^2)) = _ + change _ = (G.constant+∑ i : Fin (Finset.univ : Finset G.Edge).card, + ((3/4:ℚ)+3*(G.weight (QMAEvenRouteData.selected i))^2))+ + 3*(Finset.univ : Finset G.Edge).card*(G.pathScale Finset.univ N)^2 + ring + +theorem coefficientBound (hN : 0 ≤ N) {M L T : ℝ} + (hm : (Fintype.card G.Edge:ℝ) ≤ M) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : G.CoefficientBound L) : + (QuantumListSchedule.graph (QuantumEvenTapeProgram.value (input P labels N)).1 + (input_valid P labels N)).CoefficientBound (qmaPathCoefficientBound M L T) := by + have h := G.subdivide_coefficientBound Finset.univ (fun _ => true) hN hm hL hT hc + exact ⟨(congrArg (fun q : ℚ => |(q:ℝ)|) (literal_constant P labels N)).le.trans h.1, + fun e => (congrArg (fun q : ℚ => |(q:ℝ)|) (literal_weight P labels N e)).le.trans (h.2 _)⟩ + +end ContinuumCoulomb.QuantumEvenTapeGeometry + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvolution.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..a28169c1acf16b1769bb0b71a218bde5dd473797 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumEvolution.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateUnitary + +namespace OAI + +/-! Norm preservation for the actual verifier evolution. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators + +theorem qma_matrix_mass_preserved {n : ℕ} + (M : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) + (hM : M.conjTranspose*M = 1) (u : SourceSpinVector n) : + sourceSpinMass (M.mulVec u) = sourceSpinMass u := by + have hinner : star (M.mulVec u) ⬝ᵥ M.mulVec u = star u ⬝ᵥ u := by + rw [Matrix.star_mulVec,←Matrix.dotProduct_mulVec,Matrix.mulVec_mulVec,hM,Matrix.one_mulVec] + have hreal := congrArg Complex.re hinner + have hre (z : ℂ) : (star z*z).re = Complex.normSq z := by + simp [Complex.mul_re,Complex.normSq_apply] + simpa only [dotProduct,Pi.star_apply,Complex.re_sum,hre,sourceSpinMass] using hreal + +def qmaApplyMatrix {n : ℕ} + (M : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) + (u : EuclideanSpace ℂ (SourceSpinBasis n)) : EuclideanSpace ℂ (SourceSpinBasis n) := + WithLp.toLp 2 (M.mulVec (fun s => u s)) + +theorem qmaApplyMatrix_norm {n : ℕ} + (M : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) + (hM : M.conjTranspose*M = 1) (u : EuclideanSpace ℂ (SourceSpinBasis n)) : + ‖qmaApplyMatrix M u‖ = ‖u‖ := by + apply (sq_eq_sq₀ (norm_nonneg _) (norm_nonneg _)).mp + rw [EuclideanSpace.norm_sq_eq,EuclideanSpace.norm_sq_eq] + simpa only [qmaApplyMatrix,PiLp.toLp_apply,Complex.sq_norm,sourceSpinMass] using + qma_matrix_mass_preserved M hM (fun s => u s) + +theorem qmaCircuit_mass_preserved (c : QMACircuit) (hc : c.WellFormed) + (u : SourceSpinVector (c.work+1)) : + sourceSpinMass ((qmaCircuitMatrix c).mulVec u) = sourceSpinMass u := + qma_matrix_mass_preserved _ (qmaCircuitMatrix_gram c hc) u + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeCrossings.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeCrossings.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a01a49553829b523338255b45bf629723915965 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeCrossings.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumExchangeLanes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPatchSeparation + +namespace OAI + +/-! Polynomially many isolated crossings, with a constant bound along each route. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +theorem lane_color_at_point (hA : 0 < A) {e f : M.Term} {z : ℕ × ℕ} + (he : M.laneSupport e z) (hf : M.laneSupport f z) + (hcolor : M.laneColor e = M.laneColor f) : e = f := by + by_contra hne + exact Set.disjoint_left.mp (M.lane_color_disjoint hA hne hcolor) he hf + +theorem lane_crossing_unique (hA : 0 < A) {e f g : M.Term} (hef : e ≠ f) {z : ℕ × ℕ} + (he : M.laneSupport e z) (hf : M.laneSupport f z) (hg : M.laneSupport g z) : g = e ∨ g = f := by + have hg' := hg + have hcolor := M.lane_intersection_colors hA hef he hf + rcases qmaLaneSupport_transverse hcolor he hf with ⟨eh,fv⟩ | ⟨ev,fh⟩ + · rcases hg' with ⟨gh,_⟩ | ⟨gv,_⟩ + · exact Or.inl (M.lane_color_at_point hA hg he + (qmaHorizontalLane_color gh eh)) + · exact Or.inr (M.lane_color_at_point hA hg hf + (qmaVerticalLane_color gv fv)) + · rcases hg' with ⟨gh,_⟩ | ⟨gv,_⟩ + · exact Or.inr (M.lane_color_at_point hA hg hf + (qmaHorizontalLane_color gh fh)) + · exact Or.inl (M.lane_color_at_point hA hg he + (qmaVerticalLane_color gv ev)) + +def crossingCandidates (e f : M.Term) : Finset (ℕ × ℕ) := + { (9*B*(qmaFineGridNat (M.routeRight f)).1+(M.laneColor f).val, + 9*B*(qmaFineGridNat (M.routeLeft e)).2+(M.laneColor e).val), + (9*B*(qmaFineGridNat (M.routeRight e)).1+(M.laneColor e).val, + 9*B*(qmaFineGridNat (M.routeLeft f)).2+(M.laneColor f).val) } + +def crossings : Finset (ℕ × ℕ) := Finset.univ.biUnion fun p : M.Term × M.Term => + (M.crossingCandidates p.1 p.2).filter (fun z => p.1 ≠ p.2 ∧ M.laneSupport p.1 z ∧ M.laneSupport p.2 z) + +theorem mem_crossings (hA : 0 < A) (z : ℕ × ℕ) : + z ∈ M.crossings ↔ ∃ e f, e ≠ f ∧ M.laneSupport e z ∧ M.laneSupport f z := by + constructor + · intro hz + obtain ⟨p,_,hp⟩ := Finset.mem_biUnion.mp hz + exact ⟨p.1,p.2,(Finset.mem_filter.mp hp).2⟩ + · rintro ⟨e,f,hef,he,hf⟩ + refine Finset.mem_biUnion.mpr ⟨(e,f),Finset.mem_univ _,Finset.mem_filter.mpr ⟨?_,hef,he,hf⟩⟩ + have h := qmaLaneSupport_two_crossings (M.lane_intersection_colors hA hef he hf) he hf + simpa only [crossingCandidates,Finset.mem_insert,Finset.mem_singleton] using h + +theorem crossings_card : M.crossings.card ≤ 2*(Fintype.card M.Term)^2 := by + unfold crossings + refine Finset.card_biUnion_le.trans ?_ + calc + _ ≤ ∑ _p : M.Term × M.Term, 2 := Finset.sum_le_sum (fun p _ => + (Finset.card_filter_le _ _).trans (Finset.card_le_two)) + _ = _ := by simp [pow_two,Nat.mul_comm] + +def routeCrossings (e : M.Term) : Finset (ℕ × ℕ) := M.crossings.filter (M.laneSupport e) + +theorem routeCrossings_card (e : M.Term) : (M.routeCrossings e).card ≤ 9*B*(3*A+2)+1 := by + let p := qmaLanePoint (M.laneColor e) (qmaFineGridNat (M.routeLeft e)) + let q := qmaLanePoint (M.laneColor e) (qmaFineGridNat (M.routeRight e)) + have hsub : M.routeCrossings e ⊆ Finset.univ.image (qmaManhattanRoute p q) := by + intro z hz + have hs := (Finset.mem_filter.mp hz).2 + obtain ⟨k,hk⟩ := (qmaManhattanRoute_range p q z).mpr hs + exact Finset.mem_image.mpr ⟨k,Finset.mem_univ _,hk⟩ + calc + _ ≤ (Finset.univ.image (qmaManhattanRoute p q)).card := Finset.card_le_card hsub + _ ≤ (Finset.univ : Finset (Fin (qmaManhattanLength p q+1))).card := Finset.card_image_le + _ = qmaManhattanLength p q+1 := by simp + _ ≤ _ := Nat.add_le_add_right (M.lane_length e) 1 + +theorem crossing_not_vertex (hA : 0 < A) {z : ℕ × ℕ} (hz : z ∈ M.crossings) + (e : M.Term) (p : ℕ × ℕ) : z ≠ qmaLanePoint (M.laneColor e) p := by + obtain ⟨f,g,hfg,hf,hg⟩ := (M.mem_crossings hA z).mp hz + exact M.lane_intersection_not_vertex hA hfg hf hg e p + +theorem crossing_boxes_disjoint {p q : ℕ × ℕ} (_hp : p ∈ M.crossings) (_hq : q ∈ M.crossings) + (hpq : p ≠ q) : Disjoint (qmaPatchBox p) (qmaPatchBox q) := qmaPatchBox_disjoint hpq + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeLanes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeLanes.lean new file mode 100644 index 0000000000000000000000000000000000000000..190b6a049176e04fc910c397c53de3172793f47c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeLanes.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLaneSupport +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumExchangeRoutes + +namespace OAI + +/-! Separated lanes for the actual spatial exchange family. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaGridColorEquiv (B : ℕ) : (Fin 3 × Fin 3 × Fin B) ≃ Fin (9*B) := + ((Equiv.prodCongr (Equiv.refl _) finProdFinEquiv).trans finProdFinEquiv).trans + (finCongr (by omega)) + +theorem qmaFineGridNat_injective {rows width A : ℕ} : + Function.Injective (@qmaFineGridNat rows width A) := by + intro p q h + apply Prod.ext <;> apply Fin.ext + · exact congrArg Prod.fst h + · exact congrArg Prod.snd h + +theorem qmaFineRouteSites_nat {rows width A : ℕ} (p q : QMAFineGrid rows width A) (z : ℕ × ℕ) : + qmaManhattanSupport (qmaFineGridNat p) (qmaFineGridNat q) z ↔ + ∃ w ∈ qmaFineRouteSites p q, qmaFineGridNat w = z := by + constructor + · intro hz + obtain ⟨k,hk,he⟩ := qmaManhattanSupport_point hz + refine ⟨qmaFineRoute p q ⟨k,by omega⟩,?_,?_⟩ + · exact Finset.mem_image.mpr ⟨⟨k,by omega⟩,Finset.mem_univ _,rfl⟩ + · exact he + · rintro ⟨w,hw,rfl⟩ + obtain ⟨k,_,rfl⟩ := Finset.mem_image.mp hw + exact qmaManhattanPoint_support _ _ k.val (by omega) + +theorem qmaLane_length {C : ℕ} (c : Fin C) (p q : ℕ × ℕ) : + qmaManhattanLength (qmaLanePoint c p) (qmaLanePoint c q) = C*qmaManhattanLength p q := by + simp only [qmaManhattanLength,qmaLanePoint,Nat.dist_add_add_right,Nat.dist_mul_left,Nat.mul_add] + +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def laneColor (e : M.Term) : Fin (9*B) := qmaGridColorEquiv B (M.termSlots.color e) +def laneSupport (e : M.Term) (z : ℕ × ℕ) : Prop := + qmaLaneSupport (M.laneColor e) (qmaFineGridNat (M.routeLeft e)) (qmaFineGridNat (M.routeRight e)) z + +theorem lane_length (e : M.Term) : + qmaManhattanLength (qmaLanePoint (M.laneColor e) (qmaFineGridNat (M.routeLeft e))) + (qmaLanePoint (M.laneColor e) (qmaFineGridNat (M.routeRight e))) ≤ 9*B*(3*A+2) := by + rw [qmaLane_length] + exact Nat.mul_le_mul_left _ (M.routeLength_bound e) + +theorem lane_color_disjoint (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + (hcolor : M.laneColor e = M.laneColor f) : + Disjoint {z | M.laneSupport e z} {z | M.laneSupport f z} := by + have hc : M.termSlots.color e = M.termSlots.color f := + (qmaGridColorEquiv B).injective hcolor + have hd := M.routes_of_color_disjoint hA hef hc + have hsupport : Disjoint + {z | qmaManhattanSupport (qmaFineGridNat (M.routeLeft e)) (qmaFineGridNat (M.routeRight e)) z} + {z | qmaManhattanSupport (qmaFineGridNat (M.routeLeft f)) (qmaFineGridNat (M.routeRight f)) z} := by + apply Set.disjoint_left.mpr + intro z he hf + obtain ⟨u,hu,huz⟩ := (qmaFineRouteSites_nat _ _ z).mp he + obtain ⟨v,hv,hvz⟩ := (qmaFineRouteSites_nat _ _ z).mp hf + have huv := qmaFineGridNat_injective (huz.trans hvz.symm) + subst v + exact Finset.disjoint_left.mp hd hu hv + change Disjoint {z | qmaLaneSupport (M.laneColor e) _ _ z} + {z | qmaLaneSupport (M.laneColor f) _ _ z} + rw [← hcolor] + exact qmaLaneSupport_disjoint _ hsupport + +theorem lane_intersection_colors (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (he : M.laneSupport e z) (hf : M.laneSupport f z) : M.laneColor e ≠ M.laneColor f := + fun hc => Set.disjoint_left.mp (M.lane_color_disjoint hA hef hc) he hf + +theorem lane_intersection_not_vertex (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + {z : ℕ × ℕ} (he : M.laneSupport e z) (hf : M.laneSupport f z) + (g : M.Term) (p : ℕ × ℕ) : z ≠ qmaLanePoint (M.laneColor g) p := + qmaLaneSupport_crossing_not_vertex (M.lane_intersection_colors hA hef he hf) he hf _ p + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRounding.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca4d2a120244511ee8bdef2128f99bc3603cdef6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRounding.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockEdges +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGroundComparison + +namespace OAI + +/-! Rational coefficient rounding controls the full physical ground energy. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ : Type*} [Fintype κ] + +def qmaExchangeMatrix (left right : κ → Fin n) (J : κ → ℝ) (constant : ℝ) : + Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ := + (∑ e, (J e:ℂ) • sourceHeisenbergMatrix n (left e) (right e))+(constant:ℂ) • 1 + +theorem qmaExchangeMatrix_sub (left right : κ → Fin n) (J K : κ → ℝ) (s u : ℝ) : + qmaExchangeMatrix left right J s-qmaExchangeMatrix left right K u = + qmaExchangeMatrix left right (fun e => J e-K e) (s-u) := by + simp only [qmaExchangeMatrix,Complex.ofReal_sub,sub_smul,Finset.sum_sub_distrib] + abel + +theorem qmaExchangeMatrix_norm (left right : κ → Fin n) (hne : ∀ e, left e ≠ right e) + (J : κ → ℝ) (constant : ℝ) : + ‖spinMatrixOperator (qmaExchangeMatrix left right J constant)‖ ≤ + 3*(∑ e, |J e|)+|constant| := by + have hI : ‖spinMatrixOperator (1 : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ)‖ ≤ 1 := by + apply spinMatrixOperator_unitary_norm + simp + have hs : ‖spinMatrixOperator ((∑ e, (J e:ℂ) • sourceHeisenbergMatrix n (left e) (right e)))‖ ≤ + 3*(∑ e, |J e|) := by + rw [spinMatrixOperator_sum,Finset.mul_sum] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro e _ + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs,mul_comm] + exact mul_le_mul_of_nonneg_right (sourceHeisenbergMatrix_operator_norm n _ _ (hne e)) (abs_nonneg _) + rw [qmaExchangeMatrix,spinMatrixOperator_add] + apply (norm_add_le _ _).trans + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs] + have hc := mul_le_mul_of_nonneg_left hI (abs_nonneg constant) + linarith + +theorem qmaExchangeMatrix_ground_error (left right : κ → Fin n) + (hne : ∀ e, left e ≠ right e) (J K : κ → ℝ) (s u : ℝ) : + |MediatorGraph.normalizedBottom (qmaExchangeMatrix left right J s)- + MediatorGraph.normalizedBottom (qmaExchangeMatrix left right K u)| ≤ + 3*(∑ e, |J e-K e|)+|s-u| := by + apply qmaNormalizedBottom_norm_error _ _ (EuclideanSpace.single (fun _ => 0) 1) (by simp [PiLp.norm_single]) + rw [qmaExchangeMatrix_sub] + exact qmaExchangeMatrix_norm left right hne _ _ + +def qmaRationalRound (m : ℕ) (x : ℝ) : ℚ := (⌊(m:ℝ)*x⌋:ℚ)/(m:ℚ) + +theorem qmaRationalRound_error (m : ℕ) (hm : 0 < m) (x : ℝ) : + |x-(qmaRationalRound m x:ℝ)| ≤ 1/(m:ℝ) := by + have hmR : (0:ℝ) < m := by exact_mod_cast hm + have ha : 0 ≤ (m:ℝ)*x-(⌊(m:ℝ)*x⌋:ℝ) := sub_nonneg.mpr (Int.floor_le _) + have hb : (m:ℝ)*x-(⌊(m:ℝ)*x⌋:ℝ) ≤ 1 := by + have h := Int.lt_floor_add_one ((m:ℝ)*x) + linarith + have he : x-(qmaRationalRound m x:ℝ) = ((m:ℝ)*x-(⌊(m:ℝ)*x⌋:ℝ))/(m:ℝ) := by + simp only [qmaRationalRound,Rat.cast_div,Rat.cast_intCast,Rat.cast_natCast] + field_simp + rw [he,abs_of_nonneg (div_nonneg ha hmR.le)] + exact div_le_div_of_nonneg_right hb hmR.le + +theorem qmaRationalRound_abs (m : ℕ) (hm : 0 < m) (x : ℝ) : + |(qmaRationalRound m x:ℝ)| ≤ |x|+1/(m:ℝ) := by + have h := qmaRationalRound_error m hm x + calc + _ = |x+((qmaRationalRound m x:ℝ)-x)| := by congr 1; ring + _ ≤ |x|+|(qmaRationalRound m x:ℝ)-x| := abs_add_le _ _ + _ = |x|+|x-(qmaRationalRound m x:ℝ)| := by rw [abs_sub_comm] + _ ≤ _ := add_le_add le_rfl h + +theorem qmaExchangeMatrix_round_error (left right : κ → Fin n) (hne : ∀ e, left e ≠ right e) + (J : κ → ℝ) (constant : ℝ) (m : ℕ) (hm : 0 < m) : + |MediatorGraph.normalizedBottom (qmaExchangeMatrix left right J constant)- + MediatorGraph.normalizedBottom (qmaExchangeMatrix left right + (fun e => (qmaRationalRound m (J e):ℝ)) (qmaRationalRound m constant:ℝ))| ≤ + (3*(Fintype.card κ:ℝ)+1)/(m:ℝ) := by + apply (qmaExchangeMatrix_ground_error left right hne _ _ _ _).trans + have hs : (∑ e, |J e-(qmaRationalRound m (J e):ℝ)|) ≤ (Fintype.card κ:ℝ)/(m:ℝ) := by + calc + _ ≤ ∑ _e : κ, 1/(m:ℝ) := Finset.sum_le_sum (fun e _ => qmaRationalRound_error m hm (J e)) + _ = _ := by simp [div_eq_mul_inv] + have hc := qmaRationalRound_error m hm constant + calc + _ ≤ 3*((Fintype.card κ:ℝ)/(m:ℝ))+1/(m:ℝ) := by linarith + _ = _ := by ring + +theorem qmaExchangeMatrix_round_accuracy (left right : κ → Fin n) (hne : ∀ e, left e ≠ right e) + (J : κ → ℝ) (constant : ℝ) (N : ℕ) (hN : 0 < N) : + let m := (3*Fintype.card κ+1)*N + |MediatorGraph.normalizedBottom (qmaExchangeMatrix left right J constant)- + MediatorGraph.normalizedBottom (qmaExchangeMatrix left right + (fun e => (qmaRationalRound m (J e):ℝ)) (qmaRationalRound m constant:ℝ))| ≤ 1/(N:ℝ) := by + dsimp only + have hm : 0 < (3*Fintype.card κ+1)*N := Nat.mul_pos (by omega) hN + have h := qmaExchangeMatrix_round_error left right hne J constant _ hm + have hden : (3*(Fintype.card κ:ℝ)+1) ≠ 0 := by positivity + have hNR : (N:ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hN + convert h using 1 + push_cast + field_simp + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRoutes.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRoutes.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a799840f44fd5e6ec3e06ad61bb853288478155 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeRoutes.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialExchange +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteCongestion + +namespace OAI + +/-! Explicit constant-length routes for the actual bounded-density exchange model. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMASpatialExchangeModel +variable {A B : ℕ} (M : QMASpatialExchangeModel A B) + +def routeLeft (e : M.Term) : QMAFineGrid M.rows M.width A := M.qubitSlots.site (M.left e) +def routeRight (e : M.Term) : QMAFineGrid M.rows M.width A := M.qubitSlots.site (M.right e) +def routeLength (e : M.Term) : ℕ := qmaManhattanLength (qmaFineGridNat (M.routeLeft e)) (qmaFineGridNat (M.routeRight e)) +def routeSites (e : M.Term) : Finset (QMAFineGrid M.rows M.width A) := qmaFineRouteSites (M.routeLeft e) (M.routeRight e) + +theorem routeLength_bound (e : M.Term) : M.routeLength e ≤ 3*A+2 := + M.qubitSlots.route_length _ _ (M.anchor e) (M.geometry e).1 (M.geometry e).2 + +theorem route_local (hA : 0 < A) (e : M.Term) : + QMAGridCellsNear (qmaFineGridCell hA (M.routeLeft e)) (M.anchor e) ∧ + QMAGridCellsNear (qmaFineGridCell hA (M.routeRight e)) (M.anchor e) := by + simpa only [routeLeft,routeRight,QMACellSlots.site_cell] using M.geometry e + +theorem route_congestion (hA : 0 < A) (z : QMAFineGrid M.rows M.width A) : + (Finset.univ.filter (fun e => z ∈ M.routeSites e)).card ≤ 9*B := + qmaFineRoutes_congestion hA M.routeLeft M.routeRight M.anchor (M.route_local hA) M.termDensity z + +theorem routes_of_color_disjoint (hA : 0 < A) {e f : M.Term} (hef : e ≠ f) + (hcolor : M.termSlots.color e = M.termSlots.color f) : + Disjoint (M.routeSites e) (M.routeSites f) := + by + apply M.termSlots.color_disjoint (qmaFineGridCell hA) M.routeSites _ hef hcolor + intro e z hz + exact qmaFineRouteSites_local hA _ _ _ (M.route_local hA e).1 (M.route_local hA e).2 z hz + +end QMASpatialExchangeModel +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..933d65d90079b99ec5b55857bde770f0ff2a3dc7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSample.lean @@ -0,0 +1,133 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSampleAccuracy +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOffsetProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockBudget + +namespace OAI + +/-! Certified rational values for every edge of the actual physical exchange family. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open Matrix +open scoped Classical BigOperators + +def stencil (a : Fin 2) (s : Bool) : Fin 4 → ℚ := + if a = 0 then if s then ![11,-1,-13,3] else ![11,-1,3,-13] + else if s then ![1,-1,0,0] else ![1,1,0,0] + +theorem stencil_cast (a : Fin 2) (s : Bool) (p : Fin 4) : + (stencil a s p:ℝ) = qmaFourAxisWeights a s p := by + fin_cases a <;> cases s <;> fin_cases p <;> + norm_num [stencil,qmaFourAxisWeights,qmaFourXWeights,qmaFourZWeights] + +def crossValue (k : ℕ) (r : ℚ) (a b : Fin 2) (t : ℚ) (p q : Fin 4) : ℚ := + r*calibrated a b (k,t)*(stencil a true p*stencil b (decide (t ≤ 0)) q) + +theorem crossValue_error (k : ℕ) (r : ℚ) (a b : Fin 2) (t : ℚ) (p q : Fin 4) : + |(crossValue k r a b t p q:ℝ)-(r:ℝ)*qmaFourCouplingSize a b (t:ℝ)* + (qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q)| ≤ + 1568*|(r:ℝ)| *(1+|(t:ℝ)|)*(2:ℝ)⁻¹^k := by + have hw : |qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q| ≤ 784 := by + rw [abs_mul] + exact (mul_le_mul (qmaFourAxisWeights_pointwise a true p) + (qmaFourAxisWeights_pointwise b (qmaFourCouplingSign (t:ℝ)) q) + (abs_nonneg _) (by norm_num)).trans_eq (by norm_num) + simp only [crossValue,Rat.cast_mul,stencil_cast,sign_cast] + calc + _ = |(r:ℝ)| *|(calibrated a b (k,t):ℝ)-qmaFourCouplingSize a b (t:ℝ)| * + |qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q| := by + rw [show (r:ℝ)*(calibrated a b (k,t):ℝ)*(qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q)- + (r:ℝ)*qmaFourCouplingSize a b (t:ℝ)*(qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q) = + ((r:ℝ)*((calibrated a b (k,t):ℝ)-qmaFourCouplingSize a b (t:ℝ)))* + (qmaFourAxisWeights a true p*qmaFourAxisWeights b (qmaFourCouplingSign (t:ℝ)) q) by ring, + abs_mul,abs_mul] + _ ≤ (|(r:ℝ)| *(2*(1+|(t:ℝ)|)*(2:ℝ)⁻¹^k))*784 := mul_le_mul + (mul_le_mul_of_nonneg_left (calibrated_error a b k t) (abs_nonneg _)) hw + (abs_nonneg _) (by positivity) + _ = _ := by ring + +variable {n : ℕ} {κ τ : Type*} + +def weightValue (k : ℕ) (r : ℚ) (a b : κ → Fin 2) (t : κ → ℚ) + (axis : τ → Fin 2) (weight : τ → ℚ) : QMAFourExchangeIndex n κ τ → ℚ + | .inl _ => r^2 + | .inr (.inl (e,p,q)) => crossValue k r (a e) (b e) (t e) p q + | .inr (.inr (.inl (e,s,j))) => if s = 0 then + fieldValue k (a e) (counterA k (a e) (b e) (t e)) j else + fieldValue k (b e) (counterB k (a e) (b e) (t e)) j + | .inr (.inr (.inr (e,j))) => fieldValue k (axis e) (weight e) j + +def weightErrorBudget (r B : ℝ) : ℝ := 1568*|r| *(1+B)+26064*B + +theorem weightValue_error (k : ℕ) (r : ℚ) (a b : κ → Fin 2) (t : κ → ℚ) + (axis : τ → Fin 2) (weight : τ → ℚ) (B : ℝ) (hB : 0 ≤ B) + (ht : ∀ e, |(t e:ℝ)| ≤ B) (hw : ∀ e, |(weight e:ℝ)| ≤ B) + (x : QMAFourExchangeIndex n κ τ) : + |(weightValue k r a b t axis weight x:ℝ)- + qmaFourExchangeWeight (r:ℝ) a b (fun e => (t e:ℝ)) axis (fun e => (weight e:ℝ)) x| ≤ + weightErrorBudget (r:ℝ) B*(2:ℝ)⁻¹^k := by + have heps : 0 ≤ (2:ℝ)⁻¹^k := by positivity + have hcross : 0 ≤ 1568*|(r:ℝ)| *(1+B)*(2:ℝ)⁻¹^k := by positivity + cases x with + | inl x => + simp only [weightValue,qmaFourExchangeWeight,Rat.cast_pow,sub_self,abs_zero,weightErrorBudget] + positivity + | inr x => + cases x with + | inl x => + simp only [weightValue,qmaFourExchangeWeight] + have h := crossValue_error k r (a x.1) (b x.1) (t x.1) x.2.1 x.2.2 + have hm := mul_le_mul_of_nonneg_right (ht x.1) + (by positivity : 0 ≤ 1568*|(r:ℝ)| *(2:ℝ)⁻¹^k) + unfold weightErrorBudget + nlinarith + | inr x => + cases x with + | inl x => + simp only [weightValue,qmaFourExchangeWeight] + split_ifs + · have h := counterFieldA_error k (a x.1) (b x.1) (t x.1) x.2.2 + have hm := mul_le_mul_of_nonneg_right (ht x.1) heps + unfold weightErrorBudget + nlinarith + · have h := counterFieldB_error k (a x.1) (b x.1) (t x.1) x.2.2 + have hm := mul_le_mul_of_nonneg_right (ht x.1) heps + unfold weightErrorBudget + nlinarith + | inr x => + simp only [weightValue,qmaFourExchangeWeight] + have h := fieldValue_error k (axis x.1) (weight x.1) x.2 + have hm := mul_le_mul_of_nonneg_right (hw x.1) heps + unfold weightErrorBudget + nlinarith + +variable [Fintype κ] [Fintype τ] + +theorem weightValue_ground_error (k : ℕ) (r : ℚ) (left right : κ → Fin n) + (hne : ∀ e, left e ≠ right e) (a b : κ → Fin 2) (t : κ → ℚ) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℚ) + (s : ℚ) (c B D : ℝ) (hB : 0 ≤ B) + (ht : ∀ e, |(t e:ℝ)| ≤ B) (hw : ∀ e, |(weight e:ℝ)| ≤ B) + (hs : |(s:ℝ)-qmaFourExchangeScalar n (r:ℝ) axis (fun e => (weight e:ℝ)) c| ≤ D*(2:ℝ)⁻¹^k) : + |MediatorGraph.normalizedBottom (qmaExchangeMatrix (qmaFourExchangeLeft left right site) + (qmaFourExchangeRight left right site) (fun x => (weightValue k r a b t axis weight x:ℝ)) (s:ℝ))- + MediatorGraph.normalizedBottom (qmaBlockSourceFull (r:ℝ) left right a b (fun e => (t e:ℝ)) + site axis (fun e => (weight e:ℝ)) c)| ≤ + (3*(Fintype.card (QMAFourExchangeIndex n κ τ):ℝ)*weightErrorBudget (r:ℝ) B+D)*(2:ℝ)⁻¹^k := by + rw [qmaBlockSourceFull_exchange] + apply (qmaExchangeMatrix_ground_error _ _ (qmaFourExchange_distinct left right site hne) _ _ _ _).trans + have hsum : (∑ x : QMAFourExchangeIndex n κ τ, + |(weightValue k r a b t axis weight x:ℝ)- + qmaFourExchangeWeight (r:ℝ) a b (fun e => (t e:ℝ)) axis (fun e => (weight e:ℝ)) x|) ≤ + (Fintype.card (QMAFourExchangeIndex n κ τ):ℝ)*weightErrorBudget (r:ℝ) B*(2:ℝ)⁻¹^k := by + calc + _ ≤ ∑ _x : QMAFourExchangeIndex n κ τ, weightErrorBudget (r:ℝ) B*(2:ℝ)⁻¹^k := + Finset.sum_le_sum (fun x _ => weightValue_error k r a b t axis weight B hB ht hw x) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]; ring + nlinarith + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSampleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSampleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd6fbd382d99e6a486b55219c1383c03e03c8de2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumExchangeSampleProgram.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumExchangeSample + +namespace OAI + +/-! Literal evaluation of each cross-block physical exchange coefficient. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open ExactQuantumFactoring.BitStackProgram + +noncomputable opaque stencilProgram (a : Fin 2) (p : Fin 4) : Procedure ratCode ratCode + (fun t => stencil a (decide (t ≤ 0)) p) := by + exact (Procedure.conditional positiveProgram (Procedure.constant ratCode ratCode (stencil a false p)) + (Procedure.constant ratCode ratCode (stencil a true p))).congrFun (by + intro t + by_cases ht : 0 < t + · simp [ht,not_le_of_gt ht] + · simp [ht,le_of_not_gt ht]) + +abbrev CrossInput := (ℕ × ℚ) × ℚ +def crossCode : CrossInput → List Bool := prodCode (prodCode unaryCode ratCode) ratCode + +noncomputable opaque crossParametersProgram : Procedure crossCode (prodCode unaryCode ratCode) Prod.fst := + Procedure.first _ _ + +noncomputable opaque crossPrecisionProgram : Procedure crossCode unaryCode (fun x => x.1.1) := + (Procedure.first unaryCode ratCode).comp crossParametersProgram + +noncomputable opaque crossScaleProgram : Procedure crossCode ratCode (fun x => x.1.2) := + (Procedure.second unaryCode ratCode).comp crossParametersProgram + +noncomputable opaque crossCoefficientProgram : Procedure crossCode ratCode Prod.snd := + Procedure.second _ _ + +noncomputable opaque crossCouplingProgram (a b : Fin 2) : Procedure crossCode ratCode + (fun x => calibrated a b (x.1.1,x.2)) := + (calibratedProgram a b).comp (crossPrecisionProgram.pair crossCoefficientProgram) + +noncomputable opaque crossBaseProgram (a b : Fin 2) : Procedure crossCode ratCode + (fun x => x.1.2*calibrated a b (x.1.1,x.2)) := + Procedure.ratMul.comp (crossScaleProgram.pair (crossCouplingProgram a b)) + +noncomputable opaque crossStencilProgram (a b : Fin 2) (p q : Fin 4) : Procedure crossCode ratCode + (fun x => stencil a true p*stencil b (decide (x.2 ≤ 0)) q) := + Procedure.ratMul.comp ((Procedure.constant crossCode ratCode (stencil a true p)).pair + ((stencilProgram b q).comp crossCoefficientProgram)) + +noncomputable opaque crossValueProgram (a b : Fin 2) (p q : Fin 4) : Procedure crossCode ratCode + (fun x => crossValue x.1.1 x.1.2 a b x.2 p q) := + (Procedure.ratMul.comp ((crossBaseProgram a b).pair (crossStencilProgram a b p q))).congrFun + (by intro x; rfl) + +noncomputable def crossValueCertificate (a b : Fin 2) (p q : Fin 4) : + Turing.TM2ComputableInPolyTime crossCode ratCode (fun x => crossValue x.1.1 x.1.2 a b x.2 p q) := + (crossValueProgram a b p q).toTM2 + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPaths.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..651134ead2644ba3c702d9a5a46af1f39badb268 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPaths.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFanoutPorts + +namespace OAI + +/-! Explicit simple unit-step paths for the three endpoint arms. -/ + +namespace ContinuumCoulomb + +def qmaFanoutLength (c : Fin 3 → ℕ) : Fin 3 → ℕ := ![2*c 0+2,2*c 1+2,2*c 2+6] + +def qmaFanoutPoint (c : Fin 3 → ℕ) (a : Fin 3) (k : ℕ) : ℕ × ℕ := + if a = 0 then + if k ≤ c 0+1 then (2+k,2) else (c 0+3,2+(k-(c 0+1))) + else if a = 1 then + if k ≤ c 1+1 then (2,2+k) else (2+(k-(c 1+1)),c 1+3) + else if k = 0 then (2,2) + else if k ≤ c 2+3 then (1,k+1) + else if k ≤ 2*c 2+5 then (k-(c 2+3)+1,c 2+4) + else (c 2+3,c 2+3) + +theorem qmaFanoutPoint_zero (c : Fin 3 → ℕ) (a : Fin 3) : qmaFanoutPoint c a 0 = (2,2) := by + fin_cases a <;> simp [qmaFanoutPoint] + +theorem qmaFanoutPoint_last (c : Fin 3 → ℕ) (a : Fin 3) : + qmaFanoutPoint c a (qmaFanoutLength c a) = qmaFanoutPort c a := by + fin_cases a + · change (if 2*c 0+2 ≤ c 0+1 then (2+(2*c 0+2),2) + else (c 0+3,2+((2*c 0+2)-(c 0+1)))) = (c 0+3,c 0+3) + rw [ite_eq_right (by omega)] + apply Prod.ext + · rfl + · dsimp; omega + · change (if 2*c 1+2 ≤ c 1+1 then (2,2+(2*c 1+2)) + else (2+((2*c 1+2)-(c 1+1)),c 1+3)) = (c 1+3,c 1+3) + rw [ite_eq_right (by omega)] + apply Prod.ext + · dsimp; omega + · rfl + · change (if 2*c 2+6 = 0 then (2,2) else if 2*c 2+6 ≤ c 2+3 then (1,2*c 2+6+1) + else if 2*c 2+6 ≤ 2*c 2+5 then (2*c 2+6-(c 2+3)+1,c 2+4) + else (c 2+3,c 2+3)) = (c 2+3,c 2+3) + rw [ite_eq_right (by omega),ite_eq_right (by omega),ite_eq_right (by omega)] + +theorem qmaFanoutPoint_support (c : Fin 3 → ℕ) (a : Fin 3) (k : ℕ) + (hk : k ≤ qmaFanoutLength c a) : qmaFanoutSupport c a (qmaFanoutPoint c a k) := by + fin_cases a <;> simp only [qmaFanoutPoint,qmaFanoutLength,qmaFanoutSupport] at * + all_goals split_ifs <;> simp_all <;> omega + +theorem qmaFanoutPoint_step (c : Fin 3 → ℕ) (a : Fin 3) (k : ℕ) + (hk : k < qmaFanoutLength c a) : + Nat.dist (qmaFanoutPoint c a k).1 (qmaFanoutPoint c a (k+1)).1+ + Nat.dist (qmaFanoutPoint c a k).2 (qmaFanoutPoint c a (k+1)).2 = 1 := by + fin_cases a <;> simp only [qmaFanoutPoint,qmaFanoutLength] at * + all_goals split_ifs <;> simp_all [Nat.dist] <;> omega + +theorem qmaFanoutPoint_injective (c : Fin 3 → ℕ) (a : Fin 3) : + Function.Injective (fun k : Fin (qmaFanoutLength c a+1) => qmaFanoutPoint c a k.val) := by + intro k j h + have hk := k.isLt + have hj := j.isLt + apply Fin.ext + fin_cases a <;> simp only [qmaFanoutPoint,qmaFanoutLength] at * + all_goals split_ifs at h <;> simp_all <;> omega + +theorem qmaFanout_length_bound (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + {C : ℕ} (hC : c 2 ≤ C) (a : Fin 3) : qmaFanoutLength c a ≤ 2*C+6 := by + fin_cases a <;> simp [qmaFanoutLength] <;> omega + +theorem qmaFanout_paths_meet (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + {a b : Fin 3} (hab : a ≠ b) + (k : Fin (qmaFanoutLength c a+1)) (j : Fin (qmaFanoutLength c b+1)) + (h : qmaFanoutPoint c a k.val = qmaFanoutPoint c b j.val) : k.val = 0 ∧ j.val = 0 := by + have hm := qmaFanout_only_center c h01 h12 hab + (qmaFanoutPoint_support c a k.val (by omega)) + (h.symm ▸ qmaFanoutPoint_support c b j.val (by omega)) + have hk : k = ⟨0,by omega⟩ := qmaFanoutPoint_injective c a (by simpa [qmaFanoutPoint_zero] using hm) + have hj : j = ⟨0,by omega⟩ := qmaFanoutPoint_injective c b (by simpa [qmaFanoutPoint_zero] using h.symm.trans hm) + simp [hk,hj] + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb754b9309d75f4126a6b8574f86790c41730617 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFanoutPorts.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumManhattanSupport + +namespace OAI + +/-! Three disjoint local arms joining a degree-three vertex to ordered lane ports. -/ + +namespace ContinuumCoulomb + +def qmaFanoutSupport (c : Fin 3 → ℕ) (a : Fin 3) (p : ℕ × ℕ) : Prop := + if a = 0 then + (p.2 = 2 ∧ 2 ≤ p.1 ∧ p.1 ≤ c 0+3) ∨ + (p.1 = c 0+3 ∧ 2 ≤ p.2 ∧ p.2 ≤ c 0+3) + else if a = 1 then + (p.1 = 2 ∧ 2 ≤ p.2 ∧ p.2 ≤ c 1+3) ∨ + (p.2 = c 1+3 ∧ 2 ≤ p.1 ∧ p.1 ≤ c 1+3) + else + (p.2 = 2 ∧ 1 ≤ p.1 ∧ p.1 ≤ 2) ∨ + (p.1 = 1 ∧ 2 ≤ p.2 ∧ p.2 ≤ c 2+4) ∨ + (p.2 = c 2+4 ∧ 1 ≤ p.1 ∧ p.1 ≤ c 2+3) ∨ + (p.1 = c 2+3 ∧ c 2+3 ≤ p.2 ∧ p.2 ≤ c 2+4) + +def qmaFanoutPort (c : Fin 3 → ℕ) (a : Fin 3) : ℕ × ℕ := (c a+3,c a+3) + +theorem qmaFanout_center (c : Fin 3 → ℕ) (a : Fin 3) : qmaFanoutSupport c a (2,2) := by + fin_cases a <;> simp [qmaFanoutSupport] + +theorem qmaFanout_port (c : Fin 3 → ℕ) (a : Fin 3) : qmaFanoutSupport c a (qmaFanoutPort c a) := by + fin_cases a <;> simp [qmaFanoutSupport,qmaFanoutPort] + +theorem qmaFanout_only_center (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + {a b : Fin 3} (hab : a ≠ b) {p : ℕ × ℕ} + (ha : qmaFanoutSupport c a p) (hb : qmaFanoutSupport c b p) : p = (2,2) := by + rcases p with ⟨x,y⟩ + fin_cases a <;> fin_cases b <;> simp [qmaFanoutSupport] at ha hb hab ⊢ <;> omega + +theorem qmaFanout_bounded (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + (a : Fin 3) {p : ℕ × ℕ} (hp : qmaFanoutSupport c a p) : + 1 ≤ p.1 ∧ p.1 ≤ c 2+4 ∧ 2 ≤ p.2 ∧ p.2 ≤ c 2+4 := by + fin_cases a <;> simp [qmaFanoutSupport] at hp <;> omega + +theorem qmaFanout_other_port (c : Fin 3 → ℕ) (h01 : c 0 < c 1) (h12 : c 1 < c 2) + {a b : Fin 3} (hab : a ≠ b) : ¬qmaFanoutSupport c a (qmaFanoutPort c b) := by + intro h + have he := qmaFanout_only_center c h01 h12 hab h (qmaFanout_port c b) + have hx := congrArg Prod.fst he + dsimp [qmaFanoutPort] at hx + omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFieldSample.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFieldSample.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5ed3d1772cfa46ceff849fef02eafbe799e04f6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFieldSample.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAxisSampleProgram + +namespace OAI + +/-! Certified rational evaluation of each internal physical field coefficient. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAxisSample +open ExactQuantumFactoring.BitStackProgram +open Matrix + +def fieldX (k : ℕ) (t : ℚ) : ℚ := 64*t*value k 0 + +def fieldValue (k : ℕ) (a : Fin 2) (t : ℚ) (e : Fin 3) : ℚ := + if a = 0 then ![fieldX k t,-fieldX k t,0] e else ![0,0,-t/2] e + +theorem inverseScale_field : 64*inverseScale 0 = 1/(2*Real.sqrt 3) := by + have hs : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.mpr (by norm_num)) + have hs2 : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + norm_num only [inverseScale,ite_true] + field_simp + nlinarith + +theorem fieldX_error (k : ℕ) (t : ℚ) : + |(fieldX k t:ℝ)-(t:ℝ)/(2*Real.sqrt 3)| ≤ 64*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + have he : (t:ℝ)/(2*Real.sqrt 3) = 64*(t:ℝ)*inverseScale 0 := by + rw [mul_comm 64 (t:ℝ),mul_assoc,inverseScale_field] + ring + rw [he] + simp only [fieldX,Rat.cast_mul,Rat.cast_ofNat] + calc + _ = 64*|(t:ℝ)| *|(value k 0:ℝ)-inverseScale 0| := by + rw [show 64*(t:ℝ)*(value k 0:ℝ)-64*(t:ℝ)*inverseScale 0 = + (64*(t:ℝ))*((value k 0:ℝ)-inverseScale 0) by ring,abs_mul,abs_mul] + norm_num + _ ≤ _ := mul_le_mul_of_nonneg_left (value_error k 0) (by positivity) + +theorem fieldValue_error (k : ℕ) (a : Fin 2) (t : ℚ) (e : Fin 3) : + |(fieldValue k a t e:ℝ)-qmaFieldEdgeWeight a (t:ℝ) e| ≤ 64*|(t:ℝ)| *(2:ℝ)⁻¹^k := by + by_cases ha : a = 0 + · fin_cases e + · simpa [fieldValue,qmaFieldEdgeWeight,ha] using fieldX_error k t + · simpa [fieldValue,qmaFieldEdgeWeight,ha,neg_div,neg_add_eq_sub,abs_sub_comm] using fieldX_error k t + · simp [fieldValue,qmaFieldEdgeWeight,ha] + · fin_cases e <;> simp [fieldValue,qmaFieldEdgeWeight,ha,Rat.cast_div] + +theorem fieldWeight_lipschitz (a : Fin 2) (x y : ℝ) (e : Fin 3) : + |qmaFieldEdgeWeight a x e-qmaFieldEdgeWeight a y e| ≤ |x-y| := by + have he : qmaFieldEdgeWeight a (x-y) e = qmaFieldEdgeWeight a x e-qmaFieldEdgeWeight a y e := by + fin_cases a <;> fin_cases e <;> norm_num [qmaFieldEdgeWeight] <;> ring + rw [← he] + exact qmaFieldEdgeWeight_bound a (x-y) e + +noncomputable opaque fieldXProgram : Procedure radialCode ratCode (fun x => fieldX x.1 x.2) := by + let scalar := Procedure.ratMul.comp ((Procedure.constant radialCode ratCode 64).pair inputCoefficientProgram) + let v := (valueProgram 0).comp inputPrecisionProgram + exact (Procedure.ratMul.comp (scalar.pair v)).congrFun (by intro x; rfl) + +noncomputable opaque fieldValueProgram (a : Fin 2) (e : Fin 3) : Procedure radialCode ratCode + (fun x => fieldValue x.1 a x.2 e) := by + by_cases ha : a = 0 + · by_cases he0 : e = 0 + · subst e + exact fieldXProgram.congrFun (by intro x; simp [fieldValue,ha]) + · by_cases he1 : e = 1 + · subst e + exact (Procedure.ratNeg.comp fieldXProgram).congrFun (by intro x; simp [fieldValue,ha]) + · have he2 : e = 2 := by omega + subst e + exact (Procedure.constant radialCode ratCode 0).congrFun (by intro x; simp [fieldValue,ha]) + · by_cases he2 : e = 2 + · subst e + exact (Procedure.ratMul.comp (inputCoefficientProgram.pair + (Procedure.constant radialCode ratCode (-1/2)))).congrFun (by + intro x + simp [fieldValue,ha,Function.comp_apply] + ring) + · by_cases he0 : e = 0 + · subst e + exact (Procedure.constant radialCode ratCode 0).congrFun (by intro x; simp [fieldValue,ha]) + · have he1 : e = 1 := by omega + subst e + exact (Procedure.constant radialCode ratCode 0).congrFun (by intro x; simp [fieldValue,ha]) + +noncomputable def fieldValueCertificate (a : Fin 2) (e : Fin 3) : Turing.TM2ComputableInPolyTime + radialCode ratCode (fun x => fieldValue x.1 a x.2 e) := (fieldValueProgram a e).toTM2 + +end ContinuumCoulomb.QuantumAxisSample + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalPrecision.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalPrecision.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5431cdf1ec177ba4481722829b1bc8d2316ae14 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalPrecision.lean @@ -0,0 +1,105 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryXZPromise +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteOutputBounds + +namespace OAI + +/-! Precision for all nine early simulation errors and the subsequent +routing errors, retaining the exact final inverse-polynomial promise gap. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open ExactQuantumFactoring.BitStackProgram + +def finalPrecision (rounds : ℕ) (c : QMACircuit) : ℕ := + 60*(rounds+9)*(c.gates.length+1) + +theorem finalPrecision_pos (rounds : ℕ) (c : QMACircuit) : + 0 < finalPrecision rounds c := by + unfold finalPrecision + positivity + +theorem final_error_budget (rounds : ℕ) (c : QMACircuit) : + ((rounds:ℝ)+9)/(finalPrecision rounds c:ℝ) = + 1/(60*(c.gates.length+1:ℝ)) := by + have hr : (rounds:ℝ)+9 ≠ 0 := by positivity + have ht : (c.gates.length+1:ℝ) ≠ 0 := by positivity + simp only [finalPrecision,Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat] + field_simp + +theorem final_yes_budget (rounds : ℕ) (c : QMACircuit) : + 1/(3*(c.gates.length+1:ℝ))+((rounds:ℝ)+9)/(finalPrecision rounds c:ℝ) = + (xzYesThreshold c:ℝ) := by + rw [final_error_budget] + have ht : (c.gates.length+1:ℝ) ≠ 0 := by positivity + simp only [xzYesThreshold,Rat.cast_div,Rat.cast_mul,Rat.cast_add,Rat.cast_natCast, + Rat.cast_one,Rat.cast_ofNat] + field_simp + ring + +theorem final_no_budget (rounds : ℕ) (c : QMACircuit) : + 2/(5*(c.gates.length+1:ℝ))-((rounds:ℝ)+9)/(finalPrecision rounds c:ℝ) = + (xzNoThreshold c:ℝ) := by + rw [final_error_budget] + have ht : (c.gates.length+1:ℝ) ≠ 0 := by positivity + simp only [xzNoThreshold,Rat.cast_div,Rat.cast_mul,Rat.cast_add,Rat.cast_natCast, + Rat.cast_one,Rat.cast_ofNat] + field_simp + ring + +theorem final_accepting (rounds : ℕ) (c : QMACircuit) (hT : 0 < c.gates.length) + (hc : c.WellFormed) {E : ℝ} + (herr : |E-(qmaOrderedHistoryModel c hT).energy| ≤ + ((rounds:ℝ)+9)/(finalPrecision rounds c:ℝ)) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : E ≤ (xzYesThreshold c:ℝ) := by + have he := (abs_le.mp herr).2 + have hh := qmaOrderedHistoryModel_yes c hT hc psi hpsi hacc + rw [← final_yes_budget rounds c] + linarith + +theorem final_rejecting (rounds : ℕ) (c : QMACircuit) (hT : 0 < c.gates.length) + (hc : c.WellFormed) {E : ℝ} + (herr : |E-(qmaOrderedHistoryModel c hT).energy| ≤ + ((rounds:ℝ)+9)/(finalPrecision rounds c:ℝ)) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) : (xzNoThreshold c:ℝ) ≤ E := by + have he := (abs_le.mp herr).1 + have hh := qmaOrderedHistoryModel_no c hT hc hsound + rw [← final_no_budget rounds c] + linarith + +theorem final_threshold_gap_bound (c : QMACircuit) {n k : ℕ} + (hn : 0 < n) (hT : c.gates.length ≤ n) (hk : 6 ≤ k) : + ((n+1:ℝ)^k)⁻¹ ≤ (xzNoThreshold c:ℝ)-xzYesThreshold c := by + have hbase : (2:ℝ) ≤ n+1 := by exact_mod_cast (show 2 ≤ n+1 by omega) + have ht : (c.gates.length+1:ℝ) ≤ n+1 := by exact_mod_cast Nat.add_le_add_right hT 1 + have hp : (32:ℝ) ≤ (n+1:ℝ)^5 := by + simpa only [show (2:ℝ)^5=32 by norm_num] using + pow_le_pow_left₀ (by norm_num : (0:ℝ) ≤ 2) hbase 5 + have hd : 30*(c.gates.length+1:ℝ) ≤ (n+1:ℝ)^k := by + calc + _ ≤ 32*(n+1:ℝ) := by nlinarith + _ ≤ (n+1:ℝ)^5*(n+1) := mul_le_mul_of_nonneg_right hp (by positivity) + _ = (n+1:ℝ)^6 := (pow_succ _ 5).symm + _ ≤ _ := pow_le_pow_right₀ (by linarith : (1:ℝ) ≤ n+1) hk + have hg : (xzNoThreshold c:ℝ)-xzYesThreshold c = 1/(30*(c.gates.length+1:ℝ)) := by + have h := congrArg (fun q : ℚ => (q:ℝ)) (xz_threshold_gap c) + simpa only [Rat.cast_sub,Rat.cast_div,Rat.cast_mul,Rat.cast_add,Rat.cast_natCast, + Rat.cast_one,Rat.cast_ofNat] using h + rw [hg,one_div] + exact inv_anti₀ (by positivity) hd + +noncomputable def finalPrecisionProgram (rounds : ℕ) : + Procedure unaryCode unaryCode (fun t => 60*(rounds+9)*(t+1)) := + Procedure.unaryMul.comp ((Procedure.constant unaryCode unaryCode (60*(rounds+9))).pair + Procedure.unarySuccessor) + +noncomputable def finalRationalPrecisionProgram (rounds : ℕ) : + Procedure unaryCode ratCode (fun t => (60*(rounds+9)*(t+1):ℕ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp (finalPrecisionProgram rounds)) + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalRoutingProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalRoutingProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..394dfb317d3401596dbf012faf45ae5b6b48f587 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFinalRoutingProgram.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEvenTapeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMergeMatrix + +namespace OAI + +/-! Literal fixed-round routing to the serialized square-lattice source. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFinalRoutingProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode MediatorListProgram + +abbrev Input := QuantumSpatialPortProgram.Input × (ℚ × ℚ) +def inputCode : Input → List Bool := prodCode QuantumSpatialPortProgram.inputCode + (prodCode ratCode ratCode) +def planar (A D : ℕ) (x : Input) : QuantumPlanarTapeProgram.Output := + QuantumPlanarTapeProgram.value (QuantumSpatialCrossingProgram.value A D x.1) +def even (A D : ℕ) (x : Input) : QuantumListRouteProgram.State := + QuantumEvenTapeProgram.value (x.1.1,planar A D x) +private opaque roundsValue : {k : ℕ // k=80} := ⟨80,rfl⟩ +def rounds : ℕ := roundsValue.val +theorem rounds_eq : rounds=80 := roundsValue.property +def routed (A D : ℕ) (x : Input) : QuantumListRouteProgram.State := + QuantumListRouteProgram.iterate x.1.1 rounds (even A D x) +def value (A D : ℕ) (x : Input) : BinaryHeisenberg := + QuantumListRouteProgram.latticeOutput (routed A D x) x.2.1 x.2.2 + +noncomputable opaque spatialInputProgram : Procedure inputCode + QuantumSpatialPortProgram.inputCode Prod.fst := Procedure.first _ _ +noncomputable opaque thresholdsProgram : Procedure inputCode (prodCode ratCode ratCode) Prod.snd := + Procedure.second _ _ +noncomputable opaque precisionProgram : Procedure inputCode ratCode (fun x => x.1.1) := + (Procedure.first ratCode QuantumForkGridProgram.preparedCode).comp spatialInputProgram +noncomputable opaque planarProgram (A D : ℕ) : Procedure inputCode + QuantumPlanarTapeProgram.outputCode (planar A D) := + QuantumPlanarTapeProgram.program.comp + ((QuantumSpatialCrossingProgram.program A D).comp spatialInputProgram) +noncomputable opaque evenProgram (A D : ℕ) : Procedure inputCode + QuantumListRouteProgram.stateCode (even A D) := + QuantumEvenTapeProgram.program.comp (precisionProgram.pair (planarProgram A D)) +noncomputable opaque routedProgram (A D : ℕ) : Procedure inputCode + QuantumListRouteProgram.stateCode (routed A D) := + (QuantumListRouteProgram.iterateProgram rounds).comp (precisionProgram.pair (evenProgram A D)) +noncomputable opaque program (A D : ℕ) : Procedure inputCode binaryHeisenbergCodec.encode + (value A D) := + QuantumListRouteProgram.latticeOutputProgram.comp ((routedProgram A D).pair thresholdsProgram) + +private theorem planar_value_bounded (x : QuantumPlanarTapeProgram.Input) : + SourceBondLists.bounded (QuantumPlanarTapeProgram.value x).1.1 + (QuantumPlanarTapeProgram.value x).1.2.1 := + QuantumListMerge.bounded _ _ + +theorem planar_bounded (A D : ℕ) (x : Input) : + SourceBondLists.bounded (planar A D x).1.1 (planar A D x).1.2.1 := + planar_value_bounded (QuantumSpatialCrossingProgram.value A D x.1) + +theorem even_valid (A D : ℕ) (x : Input) : + QuantumListSchedule.Valid (even A D x).1 := + QuantumEvenTapeProgram.value_valid _ (planar_bounded A D x) + +theorem routed_valid (A D : ℕ) (x : Input) : + QuantumListSchedule.Valid (routed A D x).1 := by + rw [routed,QuantumListRouteProgram.iterate_state] + exact QuantumListSchedule.iterate_valid x.1.1 _ (even_valid A D x) rounds + +theorem energy_error (A D : ℕ) (x : Input) (hN : 0 cell q = p)).card ≤ A) (hA : 0 < A) (q : Q) : + qmaFineGridCell hA (qmaFineGridSite cell h q) = cell q := by + apply Prod.ext + · apply Fin.ext + change ((qmaGridSlot cell h q).val+A*(cell q).1.val)/A = (cell q).1.val + rw [Nat.add_mul_div_left _ _ hA,Nat.div_eq_of_lt (qmaGridSlot cell h q).isLt,zero_add] + · rfl + +def qmaFineGridNat {rows width A : ℕ} (p : QMAFineGrid rows width A) : ℕ × ℕ := + (p.1.val,p.2.val) + +def qmaFineRoute {rows width A : ℕ} (p q : QMAFineGrid rows width A) + (k : Fin (qmaManhattanLength (qmaFineGridNat p) (qmaFineGridNat q)+1)) : + QMAFineGrid rows width A := + let z := qmaManhattanPoint (qmaFineGridNat p) (qmaFineGridNat q) k.val + let hb := qmaManhattanPoint_bounds (qmaFineGridNat p) (qmaFineGridNat q) k.val (by omega) + (⟨z.1,lt_of_le_of_lt hb.2.1 (max_lt p.1.isLt q.1.isLt)⟩, + ⟨z.2,lt_of_le_of_lt hb.2.2.2 (max_lt p.2.isLt q.2.isLt)⟩) + +@[simp] theorem qmaFineRoute_nat {rows width A : ℕ} (p q : QMAFineGrid rows width A) + (k : Fin (qmaManhattanLength (qmaFineGridNat p) (qmaFineGridNat q)+1)) : + qmaFineGridNat (qmaFineRoute p q k) = qmaManhattanPoint (qmaFineGridNat p) (qmaFineGridNat q) k.val := rfl + +theorem qmaFineRoute_injective {rows width A : ℕ} (p q : QMAFineGrid rows width A) : + Function.Injective (qmaFineRoute p q) := by + intro a b hab + exact qmaManhattanRoute_injective (qmaFineGridNat p) (qmaFineGridNat q) + (congrArg qmaFineGridNat hab) + +@[simp] theorem qmaFineRoute_zero {rows width A : ℕ} (p q : QMAFineGrid rows width A) : + qmaFineRoute p q ⟨0,by omega⟩ = p := by + apply Prod.ext <;> apply Fin.ext + · exact congrArg Prod.fst (qmaManhattanPoint_zero (qmaFineGridNat p) (qmaFineGridNat q)) + · exact congrArg Prod.snd (qmaManhattanPoint_zero (qmaFineGridNat p) (qmaFineGridNat q)) + +@[simp] theorem qmaFineRoute_last {rows width A : ℕ} (p q : QMAFineGrid rows width A) : + qmaFineRoute p q (Fin.last (qmaManhattanLength (qmaFineGridNat p) (qmaFineGridNat q))) = q := by + apply Prod.ext <;> apply Fin.ext + · exact congrArg Prod.fst (qmaManhattanPoint_last (qmaFineGridNat p) (qmaFineGridNat q)) + · exact congrArg Prod.snd (qmaManhattanPoint_last (qmaFineGridNat p) (qmaFineGridNat q)) + +theorem qmaFineRoute_step {rows width A : ℕ} (p q : QMAFineGrid rows width A) + (k : Fin (qmaManhattanLength (qmaFineGridNat p) (qmaFineGridNat q))) : + Nat.dist (qmaFineRoute p q k.castSucc).1.val (qmaFineRoute p q k.succ).1.val+ + Nat.dist (qmaFineRoute p q k.castSucc).2.val (qmaFineRoute p q k.succ).2.val = 1 := + qmaManhattanPoint_step (qmaFineGridNat p) (qmaFineGridNat q) k.val k.isLt + +theorem qmaQuotient_bounds (p q x A : ℕ) (hl : min p q ≤ x) (hu : x ≤ max p q) : + min (p/A) (q/A) ≤ x/A ∧ x/A ≤ max (p/A) (q/A) := by + by_cases hpq : p ≤ q + · have hd := Nat.div_le_div_right (c := A) hpq + rw [min_eq_left hpq] at hl + rw [max_eq_right hpq] at hu + rw [min_eq_left hd,max_eq_right hd] + exact ⟨Nat.div_le_div_right hl,Nat.div_le_div_right hu⟩ + · have hqp : q ≤ p := by omega + have hd := Nat.div_le_div_right (c := A) hqp + rw [min_eq_right hqp] at hl + rw [max_eq_left hqp] at hu + rw [min_eq_right hd,max_eq_left hd] + exact ⟨Nat.div_le_div_right hl,Nat.div_le_div_right hu⟩ + +theorem qmaFineRoute_local {rows width A : ℕ} (hA : 0 < A) + (p q : QMAFineGrid rows width A) (a : QMAGridCell rows width) + (hp : QMAGridCellsNear (qmaFineGridCell hA p) a) + (hq : QMAGridCellsNear (qmaFineGridCell hA q) a) + (k : Fin (qmaManhattanLength (qmaFineGridNat p) (qmaFineGridNat q)+1)) : + QMAGridCellsNear (qmaFineGridCell hA (qmaFineRoute p q k)) a := by + have hb := qmaManhattanPoint_bounds (qmaFineGridNat p) (qmaFineGridNat q) k.val (by omega) + have hd := qmaQuotient_bounds p.1.val q.1.val + (qmaManhattanPoint (qmaFineGridNat p) (qmaFineGridNat q) k.val).1 A hb.1 hb.2.1 + dsimp [QMAGridCellsNear,qmaFineGridCell] at hp hq ⊢ + change _/A ≤ _ ∧ _ ≤ _/A+1 ∧ _ ≤ _ ∧ _ ≤ _ + dsimp only [qmaFineRoute] + dsimp [qmaFineGridNat] at hb hd ⊢ + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteHistory.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..708989d0b8fe71b8cdc8c2273a30cb9270ef172b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteHistory.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumQuadratic + +namespace OAI + +/-! Finite clock coordinates and their exact Euclidean mass. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +abbrev QMAHistoryBasis (c : QMACircuit) := + Fin (c.gates.length+1) × SourceSpinBasis (c.work+1) + +def qmaClockIndex (c : QMACircuit) (t : ℕ) : Fin (c.gates.length+1) := + ⟨min t c.gates.length,Nat.lt_succ_of_le (Nat.min_le_right _ _)⟩ + +def qmaHistoryFromVector (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) + (t : ℕ) : EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + WithLp.toLp 2 (fun s => u (qmaClockIndex c t,s)) + +@[simp] theorem qmaClockIndex_fin (c : QMACircuit) (t : Fin (c.gates.length+1)) : + qmaClockIndex c t.val = t := by + apply Fin.ext + exact Nat.min_eq_left (Nat.le_of_lt_succ t.isLt) + +@[simp] theorem qmaHistoryFromVector_fin (c : QMACircuit) + (u : QMAHistoryBasis c → ℂ) (t : Fin (c.gates.length+1)) (s : SourceSpinBasis (c.work+1)) : + qmaHistoryFromVector c u t.val s = u (t,s) := by + simp [qmaHistoryFromVector] + +theorem qmaHistoryFromVector_mass (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaHistoryMass c (qmaHistoryFromVector c u) = ‖WithLp.toLp 2 u‖^2 := by + unfold qmaHistoryMass + rw [←Fin.sum_univ_eq_sum_range] + simp only [EuclideanSpace.norm_sq_eq,qmaHistoryFromVector_fin] + rw [Fintype.sum_prod_type] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteMembership.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteMembership.lean new file mode 100644 index 0000000000000000000000000000000000000000..34e52060cc22eb0f1e02eba5968c6b70ec086837 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteMembership.lean @@ -0,0 +1,55 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteProgram +import OAI.Computability.QuantumFactoring.BitStackOptions +import OAI.Computability.QuantumFactoring.BitStackListFold +import OAI.Computability.QuantumFactoring.BitStackListMapWith + +namespace OAI + +/-! Literal membership tests for the finite geometry tables used by the +140-candidate planar route selector. The Boolean fold has constant-size state. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFiniteMembership +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +private theorem fold_or (xs : List Bool) (b : Bool) : + xs.foldl (fun c a => a || c) b = (xs.any id || b) := by + induction xs generalizing b with + | nil => simp + | cons a xs ih => + simp only [List.foldl_cons,List.any_cons] + rw [ih] + cases a <;> cases b <;> simp + +noncomputable opaque anyProgram : Procedure (listCode Procedure.boolCode) Procedure.boolCode + (fun xs => xs.any id) := by + let p := Procedure.foldList false Procedure.boolOr (Polynomial.C 1) (by + intro xs b i + simp only [Procedure.boolCode,List.length_singleton,Polynomial.eval_C] + exact le_rfl) + exact (p.comp ((Procedure.identity _).pair (Procedure.constant _ _ false))).congrFun (by + intro xs + simp only [Function.comp_apply,fold_or,Bool.or_false,id_eq]) + +noncomputable def memberProgram {α : Type} [DecidableEq α] [BEq α] [LawfulBEq α] + (ea : α → List Bool) + (d : α) (eqp : Procedure (prodCode ea ea) Procedure.boolCode (fun x => decide (x.1=x.2))) : + Procedure (prodCode ea (listCode ea)) Procedure.boolCode + (fun x => decide (x.1 ∈ x.2)) := + (anyProgram.comp (Procedure.listMapWith (f := fun a b => decide (a=b)) d false eqp)).congrFun (by + intro x + apply Bool.eq_iff_iff.mpr + simp) + +noncomputable opaque pairEqProgram : Procedure (prodCode pairCode pairCode) Procedure.boolCode + (fun x => decide (x.1=x.2)) := Procedure.prodEq Procedure.binaryEq Procedure.binaryEq + +noncomputable opaque pairMemberProgram : + Procedure (prodCode pairCode (listCode pairCode)) Procedure.boolCode + (fun x => decide (x.1 ∈ x.2)) := memberProgram pairCode (0,0) pairEqProgram + +end ContinuumCoulomb.QuantumFiniteMembership + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteRouteSearch.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteRouteSearch.lean new file mode 100644 index 0000000000000000000000000000000000000000..39af377363d1e54353912e1637cd24dee526ce89 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFiniteRouteSearch.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteCandidates +import OAI.Computability.QuantumFactoring.BitStackListOps +import OAI.Computability.QuantumFactoring.BitStackListIndex +import OAI.Computability.QuantumFactoring.BitStackAdder + +namespace OAI + +/-! The 140-candidate route search uses a literal fixed-size scan. Its input +predicate can be supplied by the finite physical geometry table. -/ + +namespace ContinuumCoulomb.QuantumFiniteRouteSearch +open ExactQuantumFactoring.BitStackProgram + +def firstTrue : ℕ → List Bool → ℕ + | 0, _ => 0 + | k+1, bs => if bs.headD false then 0 else 1+firstTrue k bs.tail + +theorem firstTrue_le (k : ℕ) (bs : List Bool) : firstTrue k bs ≤ k := by + induction k generalizing bs with + | zero => rfl + | succ k ih => + simp only [firstTrue] + split + · omega + · have h := ih bs.tail + omega + +theorem firstTrue_eq_findIdx {k : ℕ} {bs : List Bool} (h : bs.length = k) : + firstTrue k bs = bs.findIdx id := by + induction bs generalizing k with + | nil => subst k; rfl + | cons b bs ih => + have hk : k ≠ 0 := by simp only [List.length_cons] at h; omega + obtain ⟨k,rfl⟩ := Nat.exists_eq_succ_of_ne_zero hk + have ht : bs.length = k := by simpa using h + cases b <;> simp [firstTrue,List.findIdx_cons,ih ht,Nat.add_comm] + +theorem drop_findIdx_headD {α : Type} (xs : List α) (p : α → Bool) (default : α) : + (xs.drop (xs.findIdx p)).headD default = (xs.find? p).getD default := by + induction xs with + | nil => rfl + | cons a xs ih => + by_cases h : p a + · simp [List.findIdx_cons,h] + · simpa [List.findIdx_cons,List.find?_cons,h,Nat.add_comm] using ih + +def selectValue {α : Type} (default : α) (p : α → Bool) (xs : List α) : α := + (xs.drop (firstTrue 140 (xs.map p))).headD default + +theorem selectValue_eq_find {α : Type} (default : α) (p : α → Bool) (xs : List α) + (hlen : xs.length = 140) : selectValue default p xs = (xs.find? p).getD default := by + have hi : firstTrue 140 (xs.map p) = xs.findIdx p := by + rw [firstTrue_eq_findIdx (by simpa using hlen),List.findIdx_map] + rfl + rw [selectValue,hi,drop_findIdx_headD] + +theorem selectValue_eq_of_find {α : Type} (default : α) (p : α → Bool) (xs : List α) + (hlen : xs.length = 140) {v : α} (hv : xs.find? p = some v) : + selectValue default p xs = v := by + rw [selectValue_eq_find default p xs hlen,hv] + rfl + +noncomputable section + +noncomputable def indexProgram (k : ℕ) : + Procedure (listCode Procedure.boolCode) Nat.bits (firstTrue k) := by + induction k with + | zero => exact Procedure.constant _ _ 0 + | succ k ih => + let head := Procedure.listHead Procedure.boolCode false + let tail := Procedure.listTail Procedure.boolCode + let next := Procedure.binaryAdd.comp + ((Procedure.constant (listCode Procedure.boolCode) Nat.bits 1).pair (ih.comp tail)) + exact (Procedure.conditional head (Procedure.constant _ _ 0) next).congrFun (by intro bs; rfl) + +noncomputable def indexCertificate : Turing.TM2ComputableInPolyTime + (listCode Procedure.boolCode) Nat.bits (firstTrue 140) := (indexProgram 140).toTM2 + +noncomputable def predicateIndexProgram {α : Type} (ea : α → List Bool) (default : α) + {p : α → Bool} (test : Procedure ea Procedure.boolCode p) : + Procedure (listCode ea) Nat.bits (fun xs => firstTrue 140 (xs.map p)) := + (indexProgram 140).comp (Procedure.listMap default false test) + +noncomputable def selectProgram {α : Type} (ea : α → List Bool) (default : α) + {p : α → Bool} (test : Procedure ea Procedure.boolCode p) : + Procedure (listCode ea) ea + (fun xs => (xs.drop (firstTrue 140 (xs.map p))).headD default) := + (Procedure.listGet ea default).comp + ((predicateIndexProgram ea default test).pair (Procedure.identity _)) + +end +end ContinuumCoulomb.QuantumFiniteRouteSearch + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUse.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUse.lean new file mode 100644 index 0000000000000000000000000000000000000000..81925d30853b5a5c1b61c67d6769b014a44dd4d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUse.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTransferSweep + +namespace OAI + +/-! A concrete schedule of initialization checks, one at each qubit's first use. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaFirstUse (c : QMACircuit) (i : Fin (c.work+1)) : ℕ := + c.gates.findIdx (fun g => decide (i ∈ qmaGateSites c.work g)) + +theorem qmaFirstUse_le (c : QMACircuit) (i : Fin (c.work+1)) : + qmaFirstUse c i ≤ c.gates.length := List.findIdx_le_length + +theorem qmaFirstUse_untouched (c : QMACircuit) (i : Fin (c.work+1)) : + ∀ g ∈ c.gates.take (qmaFirstUse c i), i ∉ qmaGateSites c.work g := by + intro g hg + have h := List.false_of_mem_take_findIdx hg + exact of_decide_eq_false h + +theorem qmaFirstUse_input_preserved (c : QMACircuit) (hc : c.WellFormed) + (i : Fin (c.work+1)) (u : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + ‖qmaMask (qmaInputCheck c i) (qmaApplyMatrix (qmaPrefixMatrix c (qmaFirstUse c i)) u)‖ = + ‖qmaMask (qmaInputCheck c i) u‖ := + qmaInputCheck_prefix_untouched c hc i (qmaFirstUse c i) (qmaFirstUse_untouched c i) u + +theorem qmaFirstUse_history_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + 2*qmaHistoryMass c u ≤ + 5*(c.gates.length+1:ℝ)*qmaDistributedHistoryEnergy c (qmaFirstUse c) u := + qmaDistributedHistoryEnergy_sound_untouched c hc (qmaFirstUse c) + (qmaFirstUse_le c) (qmaFirstUse_untouched c) hsound u + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..48b335107ad9c560af27d66688af425fe851d7c9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseProgram.lean @@ -0,0 +1,161 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateCode +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFirstUse +import OAI.Computability.QuantumFactoring.BitStackListFold +import OAI.Computability.QuantumFactoring.BitStackListOps +import OAI.Computability.QuantumFactoring.BitStackListMapWith +import OAI.Computability.QuantumFactoring.BitStackTabulate + +namespace OAI + +/-! Literal first-use indices for the actual circuit gates. The fold stores a +unary index bounded by the gate-list length, including the no-use case. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFirstUseProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode + +abbrev TouchInput := ℕ × (ℕ × QMAGate) +def touchCode : TouchInput → List Bool := + prodCode Nat.bits (prodCode Nat.bits gateCode) + +def touches (x : TouchInput) : Bool := + decide (gateLeft x.2.2 % (x.1+1)=x.2.1) || + decide (gateRight x.2.2 % (x.1+1)=x.2.1) + +theorem touches_spec (c : QMACircuit) (i : Fin (c.work+1)) (g : QMAGate) : + touches (c.work,i.val,g)=decide (i ∈ qmaGateSites c.work g) := by + apply Bool.eq_iff_iff.mpr + have ht (x : TouchInput) : touches x = true ↔ + gateLeft x.2.2 % (x.1+1)=x.2.1 ∨ gateRight x.2.2 % (x.1+1)=x.2.1 := by + unfold touches + rw [Bool.or_eq_true,decide_eq_true_eq,decide_eq_true_eq] + rw [ht,decide_eq_true_eq] + cases g <;> + simp only [gateLeft,gateRight,qmaGateSites,Finset.mem_singleton, + Finset.mem_insert,Fin.ext_iff,qmaQubit] <;> + omega + +noncomputable def touchesProgram : Procedure touchCode Procedure.boolCode touches := by + let work := Procedure.first Nat.bits (prodCode Nat.bits gateCode) + let rest := Procedure.second Nat.bits (prodCode Nat.bits gateCode) + let site := (Procedure.first Nat.bits gateCode).comp rest + let gate := (Procedure.second Nat.bits gateCode).comp rest + let modulus := Procedure.successor.comp work + let left := Procedure.binaryMod.comp ((gateLeftProgram.comp gate).pair modulus) + let right := Procedure.binaryMod.comp ((gateRightProgram.comp gate).pair modulus) + exact Procedure.boolOr.comp + ((Procedure.binaryEq.comp (left.pair site)).pair + (Procedure.binaryEq.comp (right.pair site))) + +def step (x : Bool × ℕ) : ℕ := if x.1 then 0 else x.2+1 + +theorem step_le (b : Bool) (n : ℕ) : step (b,n) ≤ n+1 := by + cases b <;> simp [step] + +theorem fold_le (xs : List Bool) (n : ℕ) : + xs.foldl (fun k b => step (b,k)) n ≤ xs.length+n := by + induction xs generalizing n with + | nil => simp + | cons b xs ih => + have h := ih (step (b,n)) + have hs := step_le b n + simp only [List.foldl_cons,List.length_cons] + omega + +def first (xs : List Bool) : ℕ := xs.foldr (fun b n => step (b,n)) 0 + +theorem first_eq_findIdx (xs : List Bool) : first xs=xs.findIdx id := by + induction xs with + | nil => rfl + | cons b xs ih => + cases b <;> simp [first,step,List.findIdx_cons,← ih,Nat.add_comm] + +noncomputable def stepProgram : + Procedure (prodCode Procedure.boolCode unaryCode) unaryCode step := + (Procedure.conditional (Procedure.first Procedure.boolCode unaryCode) + (Procedure.constant _ unaryCode 0) + (Procedure.unarySuccessor.comp (Procedure.second Procedure.boolCode unaryCode))).congrFun + (by intro x; rfl) + +noncomputable def foldProgram : + Procedure (prodCode (listCode Procedure.boolCode) unaryCode) unaryCode + (fun x => x.1.foldl (fun n b => step (b,n)) x.2) := + Procedure.foldList false stepProgram Polynomial.X (by + intro xs n i + have h := fold_le (xs.take i) n + have ht := List.length_take_le' i xs + have hs := list_length_le_code Procedure.boolCode xs + simp only [unaryCode,List.length_replicate,Polynomial.eval_X] + omega) + +noncomputable def firstProgram : + Procedure (listCode Procedure.boolCode) unaryCode first := + (foldProgram.comp ((Procedure.listReverse Procedure.boolCode false).pair + (Procedure.constant _ unaryCode 0))).congrFun (by + intro xs + simp only [Function.comp_apply,List.foldl_reverse,first]) + +abbrev Input := QMACircuit × ℕ +def inputCode : Input → List Bool := prodCode circuitCode Nat.bits + +def touchList (x : Input) : List Bool := + x.1.gates.map (fun g => touches (x.1.work,x.2,g)) + +def value : Input → ℕ := first ∘ touchList + +noncomputable def touchListProgram : Procedure inputCode + (listCode Procedure.boolCode) touchList := by + let circuit := Procedure.first circuitCode Nat.bits + let site := Procedure.second circuitCode Nat.bits + let work := Procedure.unaryToBits.comp (workProgram.comp circuit) + let env := work.pair site + let test : Procedure (prodCode (prodCode Nat.bits Nat.bits) gateCode) + Procedure.boolCode (fun x => touches (x.1.1,x.1.2,x.2)) := by + let context := Procedure.first (prodCode Nat.bits Nat.bits) gateCode + exact touchesProgram.comp + (((Procedure.first Nat.bits Nat.bits).comp context).pair + (((Procedure.second Nat.bits Nat.bits).comp context).pair + (Procedure.second (prodCode Nat.bits Nat.bits) gateCode))) + exact (Procedure.listMapWith (f := fun e g => touches (e.1,e.2,g)) + (.hadamard 0) false test).comp (env.pair (gatesProgram.comp circuit)) + +noncomputable def program : Procedure inputCode unaryCode value := + firstProgram.comp touchListProgram + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode unaryCode value := + program.toTM2 + +theorem value_eq (c : QMACircuit) (i : Fin (c.work+1)) : + value (c,i.val)=qmaFirstUse c i := by + unfold value touchList + simp only [Function.comp_apply] + rw [first_eq_findIdx,List.findIdx_map] + unfold qmaFirstUse + congr 1 + funext g + exact touches_spec c i g + +def allValues (c : QMACircuit) : List ℕ := + (List.range (c.work+1)).map (fun i => value (c,i)) + +noncomputable def allProgram : Procedure circuitCode (listCode unaryCode) allValues := by + let entry : Procedure (prodCode unaryCode circuitCode) unaryCode + (fun x => value (x.2,x.1)) := + program.comp ((Procedure.second unaryCode circuitCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode circuitCode))) + exact (Procedure.tabulate (f := fun c i => value (c,i)) 0 entry).comp + ((Procedure.unarySuccessor.comp workProgram).pair (Procedure.identity circuitCode)) + +theorem allValues_eq (c : QMACircuit) : + allValues c=List.ofFn (fun i : Fin (c.work+1) => qmaFirstUse c i) := by + apply List.ext_getElem + · simp only [allValues,List.length_map,List.length_range,List.length_ofFn] + · intro i hi hj + simp only [allValues,List.getElem_map,List.getElem_range,List.getElem_ofFn] + exact value_eq c ⟨i,by simpa only [List.length_ofFn] using hj⟩ + +end ContinuumCoulomb.QuantumFirstUseProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseSites.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2afdbdd67a36ef195c31df13f4661854f8ffef9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFirstUseSites.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSweepCoverage + +namespace OAI + +/-! First-use initialization contributes at most two qubits at each gate time. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaFirstUseSites (c : QMACircuit) (t : Fin c.gates.length) : Finset (Fin (c.work+1)) := + Finset.univ.filter (fun i => qmaFirstUse c i = t.val) + +theorem qmaFirstUseSites_subset (c : QMACircuit) (t : Fin c.gates.length) : + qmaFirstUseSites c t ⊆ qmaGateSites c.work c.gates[t.val] := by + intro i hi + have he := (Finset.mem_filter.mp hi).2 + have ht : qmaFirstUse c i < c.gates.length := he.symm ▸ t.isLt + have hh := List.findIdx_getElem (p := fun g => decide (i ∈ qmaGateSites c.work g)) + (xs := c.gates) (w := ht) + change decide (i ∈ qmaGateSites c.work c.gates[qmaFirstUse c i]) = true at hh + simpa only [he,decide_eq_true_eq] using hh + +theorem qmaFirstUseSites_card (c : QMACircuit) (t : Fin c.gates.length) : + (qmaFirstUseSites c t).card ≤ 2 := + (Finset.card_le_card (qmaFirstUseSites_subset c t)).trans (qmaGateSites_card _ _) + +theorem qmaFirstUse_lt_of_touched (c : QMACircuit) (i : Fin (c.work+1)) + (h : ∃ g ∈ c.gates, i ∈ qmaGateSites c.work g) : qmaFirstUse c i < c.gates.length := by + apply List.findIdx_lt_length_of_exists + simpa only [decide_eq_true_eq] using h + +theorem qmaSweepFirstUse_lt (c : QMACircuit) (hne : c.gates ≠ []) + (i : Fin ((qmaSweepCircuit c).work+1)) : + qmaFirstUse (qmaSweepCircuit c) i < (qmaSweepCircuit c).gates.length := + qmaFirstUse_lt_of_touched _ _ (qmaSweepCircuit_touches c hne i) + +theorem qmaList_filter_index_card {α : Type*} (xs : List α) (p : α → Bool) : + (Finset.univ.filter (fun i : Fin xs.length => p xs[i.val])).card = (xs.filter p).length := by + rw [Finset.card_filter] + induction xs with + | nil => simp + | cons a xs ih => + change (∑ i : Fin (xs.length+1), if p (a::xs)[i.val] = true then 1 else 0) = _ + rw [Fin.sum_univ_succ] + change (if p a = true then 1 else 0)+ + (∑ i : Fin xs.length, if p xs[i.val] = true then 1 else 0) = _ + rw [ih] + by_cases ha : p a = true + · simp [ha,Nat.add_comm] + · have hf : p a = false := Bool.eq_false_iff.mpr ha + simp [hf] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedMatrixProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedMatrixProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..edac6c7a604235bdf4ac8ae3d556784022acc791 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedMatrixProgram.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFixedPauliProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedCoefficient + +namespace OAI + +/-! Literal arithmetic on a fixed local matrix table. These templates implement +the adjoint-product and realification used in the actual history cores; their +matrix dimensions are fixed before the program receives its rational registers. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFixedMatrix +open QuantumFixedPauli QuantumAlgebraicScalar QuantumAlgebraicHistory +open ExactQuantumFactoring.BitStackProgram +open scoped Classical + +noncomputable def dataProgram {α β : Type} [Fintype β] (ea : α → List Bool) + (A : α → Matrix β β Scalar) + (p : ∀ s t, Procedure ea scalarCode (fun x => A x s t)) : + Procedure ea matrixCode (fun x => matrixData (A x)) := + (QuantumRawExchange.fixedListProgram ea scalarCode (Fintype.card (β×β)) + (fun i x => A x ((Fintype.equivFin (β×β)).symm i).1 + ((Fintype.equivFin (β×β)).symm i).2) + (fun i => p _ _)).congrFun (by + intro x + simp only [matrixData,enumerate,List.map_ofFn,Function.comp_def]) + +def gramData {β : Type} [Fintype β] (xs : List Scalar) : List Scalar := + matrixData (matMul (adjoint (fun s t : β => entry xs s t)) (fun s t : β => entry xs s t)) + +noncomputable opaque gramCellProgram {β : Type} [Fintype β] (s t u : β) : + Procedure matrixCode scalarCode (fun xs => mul (conj (entry xs u s)) (entry xs u t)) := + mulProgram.comp ((conjProgram.comp (entryProgram u s)).pair (entryProgram u t)) + +noncomputable opaque gramEntryProgram {β : Type} [Fintype β] (s t : β) : + Procedure matrixCode scalarCode + (fun xs => matMul (adjoint (fun a b : β => entry xs a b)) + (fun a b : β => entry xs a b) s t) := + finiteSumProgram matrixCode _ (fun u => gramCellProgram s t u) + +noncomputable def gramProgram (β : Type) [Fintype β] : + Procedure matrixCode matrixCode (gramData (β := β)) := + dataProgram matrixCode _ gramEntryProgram + +theorem gramData_matrixData {β : Type} [Fintype β] (A : Matrix β β Scalar) : + gramData (β := β) (matrixData A) = matrixData (matMul (adjoint A) A) := by + have h : (fun s t : β => entry (matrixData A) s t) = A := by + funext s t + exact entry_matrixData A s t + simp only [gramData,h] + +theorem propagationData (c : QMACircuit) (t : Fin c.gates.length) : + gramData (β := QMASupportBasis (qmaPropagationSites c t)) (matrixData (deltaCore c t)) = + matrixData (propagationCore c t) := gramData_matrixData _ + +def rebitData (n : ℕ) (xs : List Scalar) : List Scalar := + matrixData (rebit 1 0 (fun s t : Fin n → Fin 2 => entry xs s t)) + +noncomputable opaque rebitEntryProgram (n : ℕ) + (s t : Fin 1 ⊕ Fin n → Fin 2) : Procedure matrixCode scalarCode + (fun xs => rebit 1 0 (fun a b : Fin n → Fin 2 => entry xs a b) s t) := by + let pa := entryProgram (s ∘ Sum.inr) (t ∘ Sum.inr) + let pr := realPartProgram.comp pa + let pi := imagPartProgram.comp pa + let cr := identity (s ∘ Sum.inl) (t ∘ Sum.inl) + let ci := localY 1 0 (s ∘ Sum.inl) (t ∘ Sum.inl) + exact (addProgram.comp + ((mulProgram.comp ((Procedure.constant matrixCode scalarCode cr).pair pr)).pair + (mulProgram.comp ((Procedure.constant matrixCode scalarCode (neg imaginary)).pair + (mulProgram.comp ((Procedure.constant matrixCode scalarCode ci).pair pi)))))).congrFun (by + intro xs + simp only [rebit,cr,ci,Function.comp_apply] + ) + +noncomputable def rebitProgram (n : ℕ) : Procedure matrixCode matrixCode (rebitData n) := + dataProgram matrixCode _ (rebitEntryProgram n) + +theorem rebitData_matrixData (n : ℕ) (A : Matrix (Fin n → Fin 2) (Fin n → Fin 2) Scalar) : + rebitData n (matrixData A) = matrixData (rebit 1 0 A) := by + have h : (fun s t : Fin n → Fin 2 => entry (matrixData A) s t) = A := by + funext s t + exact entry_matrixData A s t + simp only [rebitData,h] + +end ContinuumCoulomb.QuantumFixedMatrix + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauli.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauli.lean new file mode 100644 index 0000000000000000000000000000000000000000..e17cf84ce44fcbf979cec7a962580972f9c08515 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauli.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicScalar +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliReal + +namespace OAI + +/-! Fixed-arity Pauli traces evaluated entirely in rational registers. +The interpretation is the actual complex Pauli coefficient, not an +assumed list of Hamiltonian coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFixedPauli +open QuantumAlgebraicScalar Matrix +open scoped BigOperators Classical + +def enumerate (α : Type) [Fintype α] : List α := + List.ofFn (Fintype.equivFin α).symm + +def finiteSum {α : Type} [Fintype α] (f : α → Scalar) : Scalar := + QuantumAlgebraicScalar.sum ((enumerate α).map f) + +def finiteProduct {α : Type} [Fintype α] (f : α → Scalar) : Scalar := + QuantumAlgebraicScalar.product ((enumerate α).map f) + +theorem value_finiteSum {α : Type} [Fintype α] (f : α → Scalar) : + value (finiteSum f) = ∑ a, value (f a) := by + simp only [finiteSum,value_sum,enumerate,List.map_ofFn,List.sum_ofFn] + exact (Fintype.equivFin α).symm.sum_comp (fun a => value (f a)) + +theorem value_finiteProduct {α : Type} [Fintype α] (f : α → Scalar) : + value (finiteProduct f) = ∏ a, value (f a) := by + simp only [finiteProduct,value_product,enumerate,List.map_ofFn,List.prod_ofFn] + exact (Fintype.equivFin α).symm.prod_comp (fun a => value (f a)) + +def pauli (μ : Fin 4) : Matrix (Fin 2) (Fin 2) Scalar := + ![!![rat 1,rat 0;rat 0,rat 1], + !![rat 0,rat 1;rat 1,rat 0], + !![rat 0,neg imaginary;imaginary,rat 0], + !![rat 1,rat 0;rat 0,rat (-1)]] μ + +theorem value_pauli (μ : Fin 4) (a b : Fin 2) : + value (pauli μ a b) = qmaPauli μ a b := by + fin_cases μ <;> fin_cases a <;> fin_cases b <;> + norm_num [pauli,qmaPauli,pauliX,pauliY,pauliZ] + +def word {ι : Type} [Fintype ι] (w : ι → Fin 4) (s t : ι → Fin 2) : Scalar := + finiteProduct (fun i => pauli (w i) (s i) (t i)) + +theorem value_word {ι : Type} [Fintype ι] [DecidableEq ι] + (w : ι → Fin 4) (s t : ι → Fin 2) : + value (word w s t) = qmaPauliWord w s t := by + rw [word,value_finiteProduct] + simp only [value_pauli,qmaPauliWord] + +def coefficient {ι : Type} [Fintype ι] (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) + (w : ι → Fin 4) : Scalar := + mul (rat ((2:ℚ)^Fintype.card ι)⁻¹) + (finiteSum (fun s => finiteSum (fun t => mul (A s t) (word w t s)))) + +theorem value_coefficient {ι : Type} [Fintype ι] [DecidableEq ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) : + value (coefficient A w) = qmaPauliCoefficient (fun s t => value (A s t)) w := by + simp only [coefficient,value_mul,value_rat,value_finiteSum,value_word, + qmaPauliCoefficient,Rat.cast_inv,Rat.cast_pow,Rat.cast_ofNat] + norm_num + apply Finset.sum_congr (by ext; simp) + intro s _ + apply Finset.sum_congr (by ext; simp) + intro t _ + rfl + +def realCoefficient {ι : Type} [Fintype ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) : RealScalar := + (coefficient A w).1 + +theorem realCoefficient_eq {ι : Type} [Fintype ι] [DecidableEq ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) : + realValue (realCoefficient A w) = + (qmaPauliCoefficient (fun s t => value (A s t)) w).re := by + rw [← value_coefficient] + exact (value_re _).symm + +theorem realCoefficient_expansion {ι : Type} [Fintype ι] [DecidableEq ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) + (hA : Matrix.IsHermitian (fun s t => value (A s t))) : + (∑ w : ι → Fin 4, (realValue (realCoefficient A w):ℂ) • qmaPauliWord w) = + (fun s t => value (A s t)) := by + simp only [realCoefficient_eq] + exact qmaPauli_real_expansion _ hA + +/-- This entrywise attachment applies to the actual local core of an +ordered history term once its six-site table has been constructed. -/ +theorem coefficient_of_entries {ι : Type} [Fintype ι] [DecidableEq ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) + (H : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) + (hA : ∀ s t, value (A s t) = H s t) (w : ι → Fin 4) : + realValue (realCoefficient A w) = (qmaPauliCoefficient H w).re := by + rw [realCoefficient_eq] + have he : (fun s t => value (A s t)) = H := funext (fun s => funext (hA s)) + rw [he] + +theorem sample_error {ι : Type} [Fintype ι] [DecidableEq ι] + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (w : ι → Fin 4) (k : ℕ) : + |(QuantumAlgebraicScalar.sample k (realCoefficient A w):ℝ)- + (qmaPauliCoefficient (fun s t => value (A s t)) w).re| ≤ + |((realCoefficient A w).2:ℝ)| * (2:ℝ)⁻¹^k := by + rw [← realCoefficient_eq] + exact QuantumAlgebraicScalar.sample_error k _ + +end ContinuumCoulomb.QuantumFixedPauli + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauliProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauliProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe967d73ea125e2b5ed288be8115e45fee81d2c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFixedPauliProgram.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFixedPauli +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicScalarProgram + +namespace OAI + +/-! A literal polynomial evaluator for every coefficient of a fixed +local core. Six is the largest arity used by the history construction; +the finite loops below are part of the fixed program, not the input. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumFixedPauli +open QuantumAlgebraicScalar ExactQuantumFactoring.BitStackProgram +open scoped Classical + +-- Match the domain decision used inside the generic coefficient definition; +-- otherwise two propositionally equal Pi enumerations force proof reduction. +local instance finDecision (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _ + +noncomputable def finiteSumProgram {α β : Type} [Fintype β] + (ea : α → List Bool) (f : β → α → Scalar) + (p : ∀ i, Procedure ea scalarCode (f i)) : + Procedure ea scalarCode (fun x => finiteSum (fun i => f i x)) := + (fixedSumProgram ea (Fintype.card β) + (fun i => f ((Fintype.equivFin β).symm i)) + (fun i => p ((Fintype.equivFin β).symm i))).congrFun (by + intro x + simp only [finiteSum,enumerate,List.map_ofFn,Function.comp_def]) + +noncomputable def finiteProductProgram {α β : Type} [Fintype β] + (ea : α → List Bool) (f : β → α → Scalar) + (p : ∀ i, Procedure ea scalarCode (f i)) : + Procedure ea scalarCode (fun x => finiteProduct (fun i => f i x)) := + (fixedProductProgram ea (Fintype.card β) + (fun i => f ((Fintype.equivFin β).symm i)) + (fun i => p ((Fintype.equivFin β).symm i))).congrFun (by + intro x + simp only [finiteProduct,enumerate,List.map_ofFn,Function.comp_def]) + +def matrixData {β : Type} [Fintype β] (A : Matrix β β Scalar) : List Scalar := + (enumerate (β×β)).map (fun p => A p.1 p.2) + +def entry {β : Type} [Fintype β] (xs : List Scalar) (s t : β) : Scalar := + (xs.drop ((Fintype.equivFin (β×β)) (s,t)).val).headD (rat 0) + +theorem entry_matrixData {β : Type} [Fintype β] + (A : Matrix β β Scalar) (s t : β) : entry (matrixData A) s t = A s t := by + simp only [entry,matrixData,enumerate,List.map_ofFn,List.headD_eq_head?_getD, + List.head?_drop,List.getElem?_ofFn,Fin.isLt,↓reduceDIte,Option.getD_some, + Function.comp_apply,Fin.eta,Equiv.symm_apply_apply] + +def matrixCode : List Scalar → List Bool := listCode scalarCode + +noncomputable def entryProgram {β : Type} [Fintype β] (s t : β) : + Procedure matrixCode scalarCode (fun xs => entry xs s t) := + (Procedure.listGet scalarCode (rat 0)).comp + ((Procedure.constant matrixCode Nat.bits ((Fintype.equivFin (β×β)) (s,t)).val).pair + (Procedure.identity matrixCode)) + +noncomputable opaque coefficientCellProgram (n : ℕ) (w : Fin n → Fin 4) + (s t : Fin n → Fin 2) : Procedure matrixCode scalarCode + (fun xs => mul (entry xs s t) (word w t s)) := + mulProgram.comp + ((entryProgram s t).pair (Procedure.constant matrixCode scalarCode (word w t s))) + +noncomputable opaque coefficientRowProgram (n : ℕ) (w : Fin n → Fin 4) + (s : Fin n → Fin 2) : Procedure matrixCode scalarCode + (fun xs => finiteSum (fun t => mul (entry xs s t) (word w t s))) := + finiteSumProgram matrixCode _ (coefficientCellProgram n w s) + +noncomputable opaque coefficientTotalProgram (n : ℕ) (w : Fin n → Fin 4) : + Procedure matrixCode scalarCode + (fun xs => finiteSum (fun s : Fin n → Fin 2 => + finiteSum (fun t => mul (entry xs s t) (word w t s)))) := + finiteSumProgram matrixCode _ (coefficientRowProgram n w) + +noncomputable opaque coefficientProgram (n : ℕ) (w : Fin n → Fin 4) : + Procedure matrixCode scalarCode + (fun xs => coefficient (fun s t : Fin n → Fin 2 => entry xs s t) w) := by + let c : Scalar := rat (((2:ℚ)^Fintype.card (Fin n))⁻¹) + let pc : Procedure matrixCode scalarCode (fun _ => c) := + Procedure.constant matrixCode scalarCode c + let pt := coefficientTotalProgram n w + let pp : Procedure matrixCode (prodCode scalarCode scalarCode) + (fun xs => (c,finiteSum (fun s : Fin n → Fin 2 => + finiteSum (fun t => mul (entry xs s t) (word w t s))))) := pc.pair pt + exact (mulProgram.comp pp).congrFun (by intro xs; rfl) + +noncomputable def realCoefficientProgram (n : ℕ) (w : Fin n → Fin 4) : + Procedure matrixCode realCode + (fun xs => realCoefficient (fun s t : Fin n → Fin 2 => entry xs s t) w) := + (Procedure.first realCode realCode).comp (coefficientProgram n w) + +def coefficients (n : ℕ) (xs : List Scalar) : List RealScalar := + (enumerate (Fin n → Fin 4)).map + (fun w => realCoefficient (fun s t : Fin n → Fin 2 => entry xs s t) w) + +noncomputable def coefficientsProgram (n : ℕ) : + Procedure matrixCode (listCode realCode) (coefficients n) := + (QuantumRawExchange.fixedListProgram matrixCode realCode + (Fintype.card (Fin n → Fin 4)) + (fun i xs => realCoefficient (fun s t : Fin n → Fin 2 => entry xs s t) + ((Fintype.equivFin (Fin n → Fin 4)).symm i)) + (fun i => realCoefficientProgram n ((Fintype.equivFin (Fin n → Fin 4)).symm i))).congrFun + (by intro xs; simp only [coefficients,enumerate,List.map_ofFn,Function.comp_def]) + +theorem coefficient_matrixData (n : ℕ) + (A : Matrix (Fin n → Fin 2) (Fin n → Fin 2) Scalar) (w : Fin n → Fin 4) : + realValue (realCoefficient (fun s t => entry (matrixData A) s t) w) = + (qmaPauliCoefficient (fun s t => value (A s t)) w).re := by + have he : (fun s t => entry (matrixData A) s t) = A := by + funext s t + exact entry_matrixData A s t + rw [he] + exact realCoefficient_eq A w + +noncomputable def certificate (n : ℕ) : + Turing.TM2ComputableInPolyTime matrixCode (listCode realCode) (coefficients n) := + (coefficientsProgram n).toTM2 + +end ContinuumCoulomb.QuantumFixedPauli + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBackground.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBackground.lean new file mode 100644 index 0000000000000000000000000000000000000000..32c137454f8bd1e7e7c6d6c601300fff6cfce944 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBackground.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkPorts + +namespace OAI + +/-! The part of a fork layer left after its new active center edges are removed. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +variable {ν : Type*} [Fintype ν] + +def qmaForkBackgroundLeft {n r : ℕ} (left : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) := + qmaParallelGraphLeft (qmaForksBaseLeft left site) + (fun e b => qmaForkOuter site (e,b)) + +def qmaForkBackgroundRight {n r : ℕ} (right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) := + qmaParallelGraphRight (qmaForksBaseRight right site) + (fun (_ : Fin r) (_ : Fin 2) => (1 : Fin 2)) + +theorem qmaForkBackground_old_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (v : Fin n) : + qmaGraphDegree (qmaForkBackgroundLeft left site) (qmaForkBackgroundRight right site) + (old n r v) = qmaGraphDegree left right v + + 2 * ∑ e, ((if site e 1 = v then 1 else 0)+(if site e 2 = v then 1 else 0)) := by + unfold qmaForkBackgroundLeft qmaForkBackgroundRight + rw [qmaParallelGraph_old_degree] + simp only [qmaForksBaseLeft,qmaForksBaseRight] + rw [qmaGraphDegree_sum] + have hc : qmaGraphDegree (fun e => site e 1) (fun e => site e 2) v = + ∑ e, ((if site e 1 = v then 1 else 0)+(if site e 2 = v then 1 else 0)) := by + apply Finset.sum_congr rfl + intro e _ + have hne : site e 1 ≠ site e 2 := fun h => (by decide : (1:Fin 3) ≠ 2) (hsite e h) + by_cases h1 : site e 1 = v <;> by_cases h2 : site e 2 = v <;> simp_all + change qmaGraphDegree left right v + qmaGraphDegree (fun e => site e 1) (fun e => site e 2) v + _ = _ + rw [hc] + simp only [Fin.sum_univ_two,qmaForkOuter,ite_true] + norm_num only [show (1 : Fin 2) ≠ 0 by decide] + simp only [ite_false] + omega + +theorem qmaForkBackground_new_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (e : Fin r) (b : Fin 2) : + qmaGraphDegree (qmaForkBackgroundLeft left site) (qmaForkBackgroundRight right site) + (fresh n r e b) = if b = 0 then 1 else 3 := by + unfold qmaForkBackgroundLeft qmaForkBackgroundRight + rw [qmaParallelGraph_new_degree] + simp only [Fin.sum_univ_two] + fin_cases b <;> norm_num + +theorem qmaForkBackground_away_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (v : Fin n) (hv : ∀ e, site e 1 ≠ v ∧ site e 2 ≠ v) : + qmaGraphDegree (qmaForkBackgroundLeft left site) (qmaForkBackgroundRight right site) + (old n r v) = qmaGraphDegree left right v := by + rw [qmaForkBackground_old_degree left right site hsite] + simp [hv] + +theorem qmaForkBackground_degree_le_three {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (houter : Function.Injective (qmaForkOuter site)) + (hbase : ∀ v, qmaGraphDegree left right v ≤ 3) + (hport : ∀ e b, qmaGraphDegree left right (qmaForkOuter site (e,b)) ≤ 1) + (v : Fin (n+r*2)) : + qmaGraphDegree (qmaForkBackgroundLeft left site) (qmaForkBackgroundRight right site) v ≤ 3 := by + obtain ⟨v,rfl⟩ := (vertexEquiv n r).surjective v + rcases v with v | ⟨e,b⟩ + · change qmaGraphDegree (qmaForkBackgroundLeft left site) + (qmaForkBackgroundRight right site) (old n r v) ≤ 3 + by_cases hp : ∃ e b, qmaForkOuter site (e,b) = v + · obtain ⟨e,b,rfl⟩ := hp + rw [qmaForkBackground_old_degree left right site hsite] + have hc := qmaForkOuter_count site houter (qmaForkOuter site (e,b)) + have hb := hport e b + omega + · have hv : ∀ e, site e 1 ≠ v ∧ site e 2 ≠ v := by + intro e + constructor + · intro h + exact hp ⟨e,0,by simpa [qmaForkOuter] using h⟩ + · intro h + exact hp ⟨e,1,by simpa [qmaForkOuter] using h⟩ + rw [qmaForkBackground_away_degree left right site hsite v hv] + exact hbase v + · change qmaGraphDegree (qmaForkBackgroundLeft left site) + (qmaForkBackgroundRight right site) (fresh n r e b) ≤ 3 + rw [qmaForkBackground_new_degree] + split <;> omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e4909b1c79db7d65c362072a83c0493bafb8b22 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkBounds.lean @@ -0,0 +1,43 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkSpectrum +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingGraph + +namespace OAI + +/-! Polynomial coefficient and operator bounds for parallel degree reduction. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaForkOffset (J K : ℝ) : ℝ := 3/4+3*J^2+3*K^2 + +theorem qmaForkCorrection_exchange {n : ℕ} (site : Fin 3 → Fin n) (J K : ℝ) : + qmaForkCorrection site J K = + qmaExchangeMatrix (fun _ : Fin 1 => site 1) + (fun _ : Fin 1 => site 2) (fun _ => 2*J*K) (qmaForkOffset J K) := by + simp [qmaForkCorrection,qmaExchangeMatrix,qmaForkOffset,add_comm] + +theorem qmaForkCorrection_lift_norm {n r : ℕ} (site : Fin 3 → Fin n) + (hsite : Function.Injective site) (J K : ℝ) : + ‖spinMatrixOperator (qmaForkCorrection site J K ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ 12*(1+|J|+|K|)^2 := by + have hneq (_a : Fin 1) : site 1 ≠ site 2 := + fun h => (by decide : (1 : Fin 3) ≠ 2) (hsite h) + rw [qmaForkCorrection_exchange] + apply (qmaExchangeMatrix_lift_norm _ _ hneq _ _).trans + have hoff : 0 ≤ qmaForkOffset J K := by unfold qmaForkOffset; positivity + rw [abs_of_nonneg hoff] + simp [qmaForkOffset,abs_mul] + nlinarith [sq_abs J,sq_abs K,abs_nonneg J,abs_nonneg K,mul_nonneg (abs_nonneg J) (abs_nonneg K)] + +theorem qmaForkAmplitude_norm (R J K : ℝ) (hR : 0 ≤ R) : + 3*(∑ a, |qmaForkAmplitude R J K a|) = 3*R*(1+2*|J|+2*|K|) := by + simp [qmaForkAmplitude,Fin.sum_univ_succ,abs_mul,abs_of_nonneg hR] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..72cc58076985a893a049ffd5eb20788becc65e54 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCalibration.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkParallel +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingScale + +namespace OAI + +/-! Explicit polynomial calibration for a simultaneous fork stage. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +theorem qmaForks_correction_norm {n r : ℕ} (site : Fin r → Fin 3 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) : + ‖spinMatrixOperator ((∑ e, qmaForkCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ + 12*∑ e, (1+|J e|+|K e|)^2 := by + rw [MediatorGraph.sum_kronecker,spinMatrixOperator_sum,Finset.mul_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun e _ => + qmaForkCorrection_lift_norm (site e) (hsite e) (J e) (K e))) + +theorem qmaForks_amplitude (r : ℕ) (R : ℝ) (hR : 0 ≤ R) (J K : Fin r → ℝ) : + 3*(∑ e, ∑ a, |qmaForkAmplitude R (J e) (K e) a|) = + (3*∑ e, (1+2*|J e|+2*|K e|))*R := by + rw [Finset.mul_sum] + simp_rw [qmaForkAmplitude_norm R _ _ hR] + rw [← Finset.mul_sum] + ring + +theorem qmaForks_accuracy {n r : ℕ} (site : Fin r → Fin 3 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) + {B N : ℝ} (hB : 0 ≤ B) (hN : 0 < N) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + (hCn : ‖spinMatrixOperator (C ⊗ₖ (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ B) : + let A := 3*∑ e, (1+2*|J e|+2*|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) + (qmaRoutingStars n r site (fun _ => qmaForkMember) + (fun e => qmaForkAmplitude R (J e) (K e)))) - + sourceMatrixBottom n (C + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 1) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2)))| ≤ 1/N := by + let A := 3*∑ e, (1+2*|J e|+2*|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + have hA : 0 ≤ A := by dsimp [A]; positivity + have hD : 0 ≤ D := by dsimp [D]; positivity + obtain ⟨hR,he,hes,hbound,herr⟩ := qmaRoutingScale_bounds hA hD hN + have hCC : ‖spinMatrixOperator ((C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ ≤ D := by + rw [Matrix.add_kronecker,spinMatrixOperator_add] + exact (norm_add_le _ _).trans (add_le_add hCn (qmaForks_correction_norm site hsite J K)) + have hb : ‖spinMatrixOperator ((C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ e, ∑ a, |qmaForkAmplitude R (J e) (K e) a| ≤ ((A+D+1)/R)*(4*R^2) := by + rw [qmaForks_amplitude r R hR.le J K] + exact (add_le_add hCC (le_refl (A*R))).trans hbound + exact (qmaForks_bottom site hsite R hR J K C hC he hes hb).trans herr + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..273310301935373eef10a80d994a93b3c90d2e0c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkCells.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkState + +namespace OAI + +/-! A fork round keeps each new pair in the coarse cell of its active center. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +variable {n c : ℕ} {d : Fin c → ℕ} {β : Type*} + +def qmaForkCellNext (P : QMAForkPorts n c d) (cell : Fin n → β) : + Fin (n+P.pairCount*2) → β := + Sum.elim cell (fun p : Fin P.pairCount × Fin 2 => cell (P.center (P.pairEquiv.symm p.1).1)) ∘ + (vertexEquiv n P.pairCount).symm + +@[simp] theorem qmaForkCellNext_old (P : QMAForkPorts n c d) (cell : Fin n → β) (v : Fin n) : + qmaForkCellNext P cell (old n P.pairCount v) = cell v := by + simp [qmaForkCellNext,old] + +@[simp] theorem qmaForkCellNext_fresh (P : QMAForkPorts n c d) (cell : Fin n → β) + (e : Fin P.pairCount) (b : Fin 2) : + qmaForkCellNext P cell (fresh n P.pairCount e b) = cell (P.center (P.pairEquiv.symm e).1) := by + simp [qmaForkCellNext,fresh] + +def QMAForkCellAligned (P : QMAForkPorts n c d) (cell : Fin n → β) : Prop := + ∀ p, cell (P.port p) = cell (P.center p.1) + +theorem qmaForkCellNext_aligned (P : QMAForkPorts n c d) (cell : Fin n → β) + (h : QMAForkCellAligned P cell) : QMAForkCellAligned P.next (qmaForkCellNext P cell) := by + intro p + obtain ⟨p,rfl⟩ := P.nextPortEquiv.symm.surjective p + rcases p with p | p + · simp only [QMAForkPorts.next,Function.comp_apply,Equiv.apply_symm_apply, + QMAForkPorts.nextPortAux,qmaForkCellNext_old,qmaForkCellNext_fresh,Equiv.symm_apply_apply] + rfl + · simp only [QMAForkPorts.next,Function.comp_apply,Equiv.apply_symm_apply, + QMAForkPorts.nextPortAux,qmaForkCellNext_old] + exact h (qmaForkRemainingPort d p) + +def qmaCellMass {V : Type*} [Fintype V] [DecidableEq β] (cell : V → β) (x : β) : ℕ := + ∑ v, if cell v = x then 1 else 0 + +theorem qmaForkCellNext_mass [DecidableEq β] (P : QMAForkPorts n c d) + (cell : Fin n → β) (x : β) : + qmaCellMass (qmaForkCellNext P cell) x = qmaCellMass cell x + + 2*∑ e : Fin P.pairCount, if cell (P.center (P.pairEquiv.symm e).1) = x then 1 else 0 := by + unfold qmaCellMass + rw [← (vertexEquiv n P.pairCount).sum_comp] + simp only [Fintype.sum_sum_type,Fintype.sum_prod_type,Fin.sum_univ_two] + simp only [qmaForkCellNext,Function.comp_apply,Equiv.symm_apply_apply,Sum.elim_inl,Sum.elim_inr] + change (∑ v : Fin n, if cell v = x then 1 else 0) + + (∑ e : Fin P.pairCount, ((if cell (P.center (P.pairEquiv.symm e).1) = x then 1 else 0) + + (if cell (P.center (P.pairEquiv.symm e).1) = x then 1 else 0))) = _ + rw [Finset.sum_add_distrib] + omega + +theorem qmaForkCell_pair_mass_le [DecidableEq β] (P : QMAForkPorts n c d) + (cell : Fin n → β) (D : ℕ) (hd : ∀ i, d i ≤ D) (x : β) : + (∑ e : Fin P.pairCount, if cell (P.center (P.pairEquiv.symm e).1) = x then 1 else 0 : ℕ) ≤ + D*qmaCellMass (cell ∘ P.center) x := by + have he := P.pairEquiv.symm.sum_comp (fun p : QMAForkPair d => + if cell (P.center p.1) = x then (1:ℕ) else 0) + rw [he] + simp only [Fintype.sum_sigma,qmaCellMass,Function.comp_apply,Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + by_cases hx : cell (P.center i) = x + · simp only [hx,ite_true,Finset.sum_const,Finset.card_univ,Fintype.card_fin, + smul_eq_mul,Nat.mul_one] + exact (Nat.div_le_self _ _).trans (hd i) + · simp [hx] + +theorem qmaForkCellNext_mass_le [DecidableEq β] (P : QMAForkPorts n c d) + (cell : Fin n → β) (D : ℕ) (hd : ∀ i, d i ≤ D) (x : β) : + qmaCellMass (qmaForkCellNext P cell) x ≤ qmaCellMass cell x + + 2*D*qmaCellMass (cell ∘ P.center) x := by + rw [qmaForkCellNext_mass] + have h := qmaForkCell_pair_mass_le P cell D hd x + calc + _ ≤ qmaCellMass cell x+2*(D*qmaCellMass (cell ∘ P.center) x) := + Nat.add_le_add_left (Nat.mul_le_mul_left 2 h) _ + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegreeBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegreeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a1162cc615a83cb8c5ab6da861ebbc7d0350754 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegreeBound.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGraphDegree +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkGraph + +namespace OAI + +/-! Degree control for many fork centers sharing a retained background graph. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +variable {ν : Type*} [Fintype ν] + +theorem qmaGraphDegree_sum {n : ℕ} {κ : Type*} [Fintype κ] + (left right : ν → Fin n) (left' right' : κ → Fin n) (v : Fin n) : + qmaGraphDegree (Sum.elim left left') (Sum.elim right right') v = + qmaGraphDegree left right v+qmaGraphDegree left' right' v := by + simp only [qmaGraphDegree,Fintype.sum_sum_type,Sum.elim_inl,Sum.elim_inr] + rfl + +theorem qmaCount_eq_le_one {α β : Type*} [Fintype α] [DecidableEq β] + (f : α → β) (hf : Function.Injective f) (v : β) : + (∑ a, if f a = v then 1 else 0 : ℕ) ≤ 1 := by + simp only [Finset.sum_boole] + apply Finset.card_le_one.mpr + intro a ha b hb + exact hf ((Finset.mem_filter.mp ha).2.trans (Finset.mem_filter.mp hb).2.symm) + +def qmaForkOuter {n r : ℕ} (site : Fin r → Fin 3 → Fin n) (p : Fin r × Fin 2) : Fin n := + site p.1 (if p.2 = 0 then 1 else 2) + +theorem qmaForkOuter_count {n r : ℕ} (site : Fin r → Fin 3 → Fin n) + (houter : Function.Injective (qmaForkOuter site)) (v : Fin n) : + (∑ e, ((if site e 1 = v then 1 else 0)+(if site e 2 = v then 1 else 0) : ℕ)) ≤ 1 := by + have h := qmaCount_eq_le_one (qmaForkOuter site) houter v + simpa [qmaForkOuter,Fintype.sum_prod_type,Fin.sum_univ_two] using h + +theorem qmaForks_old_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (v : Fin n) : + qmaGraphDegree (qmaParallelGraphLeft (qmaForksBaseLeft left site) site) + (qmaParallelGraphRight (qmaForksBaseRight right site) (fun _ => qmaForkMember)) (old n r v) = + qmaGraphDegree left right v+ + (∑ e, if site e 1 = v ∨ site e 2 = v then 1 else 0)+ + ∑ e, ((if site e 0 = v then 1 else 0)+(if site e 1 = v then 1 else 0)+ + (if site e 2 = v then 1 else 0)) := by + rw [qmaParallelGraph_old_degree] + simp only [qmaGraphDegree,Fintype.sum_sum_type,qmaForksBaseLeft,qmaForksBaseRight, + Sum.elim_inl,Sum.elim_inr,Fin.sum_univ_three] + rfl + +theorem qmaForks_noncenter_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (houter : Function.Injective (qmaForkOuter site)) + (v : Fin n) (hcenter : ∀ e, site e 0 ≠ v) (hbase : qmaGraphDegree left right v ≤ 1) : + qmaGraphDegree (qmaParallelGraphLeft (qmaForksBaseLeft left site) site) + (qmaParallelGraphRight (qmaForksBaseRight right site) (fun _ => qmaForkMember)) (old n r v) ≤ 3 := by + have hp := qmaForkOuter_count site houter v + have hc : (∑ e, if site e 1 = v ∨ site e 2 = v then 1 else 0 : ℕ) ≤ + ∑ e, ((if site e 1 = v then 1 else 0)+(if site e 2 = v then 1 else 0) : ℕ) := by + apply Finset.sum_le_sum + intro e _ + split_ifs <;> omega + rw [qmaForks_old_degree] + simp only [hcenter,ite_false,zero_add] + omega + +theorem qmaForks_center_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (v : Fin n) + (houter : ∀ e, site e 1 ≠ v ∧ site e 2 ≠ v) : + qmaGraphDegree (qmaParallelGraphLeft (qmaForksBaseLeft left site) site) + (qmaParallelGraphRight (qmaForksBaseRight right site) (fun _ => qmaForkMember)) (old n r v) = + qmaGraphDegree left right v+∑ e, if site e 0 = v then 1 else 0 := by + rw [qmaForks_old_degree] + simp [houter] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegrees.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..23234a64a6d97278a6d751b58d5f53213ac4b472 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkDegrees.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkSpectrum + +namespace OAI + +/-! The parallel fork graph halves the degree of its center. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaForkPortEquiv (d : ℕ) : (Fin (d/2) × Fin 2) ⊕ Fin (d%2) ≃ Fin d := + ((Equiv.sumCongr finProdFinEquiv (Equiv.refl _)).trans finSumFinEquiv).trans + (finCongr (by omega)) + +abbrev QMAForkStarVertex (d : ℕ) := Unit ⊕ (Fin d ⊕ (Fin (d/2) × Fin 2)) +abbrev QMAForkStarEdge (d : ℕ) := + Fin (d/2) ⊕ (Fin (d/2) ⊕ ((Fin (d/2) × Fin 2) ⊕ (Fin (d/2) ⊕ Fin (d%2)))) + +def qmaForkStarLeft (d : ℕ) : QMAForkStarEdge d → QMAForkStarVertex d + | .inl i => .inr (.inr (i,0)) + | .inr (.inl _) => .inl () + | .inr (.inr (.inl p)) => .inr (.inl (qmaForkPortEquiv d (.inl p))) + | .inr (.inr (.inr (.inl i))) => .inr (.inl (qmaForkPortEquiv d (.inl (i,0)))) + | .inr (.inr (.inr (.inr _))) => .inl () + +def qmaForkStarRight (d : ℕ) : QMAForkStarEdge d → QMAForkStarVertex d + | .inl i => .inr (.inr (i,1)) + | .inr (.inl i) => .inr (.inr (i,0)) + | .inr (.inr (.inl p)) => .inr (.inr (p.1,1)) + | .inr (.inr (.inr (.inl i))) => .inr (.inl (qmaForkPortEquiv d (.inl (i,1)))) + | .inr (.inr (.inr (.inr k))) => .inr (.inl (qmaForkPortEquiv d (.inr k))) + +def qmaForkStarDegree (d : ℕ) (v : QMAForkStarVertex d) : ℕ := + ∑ e, if qmaForkStarLeft d e = v ∨ qmaForkStarRight d e = v then 1 else 0 + +theorem qmaForkStar_center_degree (d : ℕ) : qmaForkStarDegree d (.inl ()) = d/2+d%2 := by + simp [qmaForkStarDegree,qmaForkStarLeft,qmaForkStarRight,Fintype.sum_sum_type] + +theorem qmaForkStar_center_decreases (d : ℕ) (hd : 2 ≤ d) : + qmaForkStarDegree d (.inl ()) < d := by + rw [qmaForkStar_center_degree] + omega + +theorem qmaForkStar_no_loops (d : ℕ) (e : QMAForkStarEdge d) : + qmaForkStarLeft d e ≠ qmaForkStarRight d e := by + rcases e with i | e + · simp [qmaForkStarLeft,qmaForkStarRight] + rcases e with i | e + · simp [qmaForkStarLeft,qmaForkStarRight] + rcases e with p | e + · simp [qmaForkStarLeft,qmaForkStarRight] + rcases e with i | k + · intro h + have hp := (qmaForkPortEquiv d).injective (Sum.inl.inj (Sum.inr.inj h)) + have hbit := congrArg Prod.snd (Sum.inl.inj hp) + norm_num at hbit + · simp [qmaForkStarLeft,qmaForkStarRight] + +theorem qmaForkStar_new_degree (d : ℕ) (i : Fin (d/2)) (b : Fin 2) : + qmaForkStarDegree d (.inr (.inr (i,b))) = if b = 0 then 2 else 3 := by + simp only [qmaForkStarDegree,Fintype.sum_sum_type,Fintype.sum_prod_type, + qmaForkStarLeft,qmaForkStarRight] + fin_cases b <;> simp + +theorem qmaForkStar_paired_degree (d : ℕ) (i : Fin (d/2)) (b : Fin 2) : + qmaForkStarDegree d (.inr (.inl (qmaForkPortEquiv d (.inl (i,b))))) = 2 := by + fin_cases b <;> + simp [qmaForkStarDegree,qmaForkStarLeft,qmaForkStarRight,Fintype.sum_sum_type] + +theorem qmaForkStar_leftover_degree (d : ℕ) (i : Fin (d%2)) : + qmaForkStarDegree d (.inr (.inl (qmaForkPortEquiv d (.inr i)))) = 1 := by + simp [qmaForkStarDegree,qmaForkStarLeft,qmaForkStarRight,Fintype.sum_sum_type] + +theorem qmaForkStar_noncenter_degree (d : ℕ) (v : QMAForkStarVertex d) + (hv : v ≠ .inl ()) : qmaForkStarDegree d v ≤ 3 := by + rcases v with u | v + · cases u; exact (hv rfl).elim + rcases v with j | p + · obtain ⟨q,hq⟩ := (qmaForkPortEquiv d).surjective j + subst j + rcases q with p | k + · rw [qmaForkStar_paired_degree]; omega + · rw [qmaForkStar_leftover_degree]; omega + · rw [qmaForkStar_new_degree] + split <;> omega + +theorem qmaForkStar_vertex_count (d : ℕ) : + Fintype.card (QMAForkStarVertex d) = 1+d+2*(d/2) := by + simp [QMAForkStarVertex,Fintype.card_sum,Fintype.card_prod] + omega + +theorem qmaForkStar_edge_count (d : ℕ) : + Fintype.card (QMAForkStarEdge d) = 5*(d/2)+d%2 := by + simp [QMAForkStarEdge,Fintype.card_sum,Fintype.card_prod] + omega + +/-- A constant degree bound permits a constant number of fork rounds. -/ +def qmaForkDegreeAfter (d : ℕ) : ℕ → ℕ + | 0 => d + | k+1 => qmaForkDegreeAfter d k / 2 + qmaForkDegreeAfter d k % 2 + +theorem qmaForkDegreeAfter_bound (d k : ℕ) : + qmaForkDegreeAfter d k ≤ max 1 (d-k) := by + induction k with + | zero => simp [qmaForkDegreeAfter] + | succ k ih => + simp only [qmaForkDegreeAfter] + by_cases h : qmaForkDegreeAfter d k ≤ 1 + · have hf : qmaForkDegreeAfter d k / 2 + qmaForkDegreeAfter d k % 2 ≤ 1 := by omega + exact hf.trans (le_max_left _ _) + · have hf : qmaForkDegreeAfter d k / 2 + qmaForkDegreeAfter d k % 2 < + qmaForkDegreeAfter d k := by omega + omega + +theorem qmaForkDegreeAfter_constant (d D : ℕ) (hd : d ≤ D) : + qmaForkDegreeAfter d D ≤ 1 := by + have h := qmaForkDegreeAfter_bound d D + simpa [Nat.sub_eq_zero_of_le hd] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkEffective.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkEffective.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b48b49b0b58de0c42d683af3c02a492eb5890fb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkEffective.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSingletStarSpectrum + +namespace OAI + +/-! Rational asymmetric fork gadget for reducing the degree of an old spin. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaForkMember : Fin 3 → Fin 2 := ![0,1,1] +def qmaForkAmplitude (R J K : ℝ) : Fin 3 → ℝ := ![R,2*R*J,2*R*K] + +def qmaForkCorrection {n : ℕ} (site : Fin 3 → Fin n) (J K : ℝ) : + Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ := + ((3/4+3*J^2+3*K^2:ℝ):ℂ) • 1 + + ((2*J*K:ℝ):ℂ) • sourceHeisenbergMatrix n (site 1) (site 2) + +theorem qmaFork_effective {n r : ℕ} (e : Fin r) (site : Fin 3 → Fin n) + (hsite : Function.Injective site) (R J K : ℝ) (hR : R ≠ 0) : + qmaForkCorrection site J K - mediatorCompression n r + (qmaSingletStar n r e site qmaForkMember (qmaForkAmplitude R J K) * + liftedMediatorInverse n r (R^2) * + qmaSingletStar n r e site qmaForkMember (qmaForkAmplitude R J K)) = + (J:ℂ) • sourceHeisenbergMatrix n (site 0) (site 1) + + (K:ℂ) • sourceHeisenbergMatrix n (site 0) (site 2) := by + have hk (a b : Fin 3) : qmaPauliKernel n (site a) (site b) = + if a = b then (3:ℂ) • 1 else sourceHeisenbergMatrix n (site a) (site b) := by + by_cases hab : a = b + · subst b + simp only [ite_true,qmaPauliKernel_self] + · rw [ite_eq_right hab] + exact qmaPauliKernel_eq n _ _ (fun h => hab (hsite h)) + rw [qmaSingletStar_compression] + simp only [hk,qmaForkCorrection] + simp [qmaForkMember,qmaForkAmplitude,Fin.sum_univ_succ] + rw [qmaHeisenberg_symm n (site 1) (site 0),qmaHeisenberg_symm n (site 2) (site 0), + qmaHeisenberg_symm n (site 2) (site 1)] + ext s t + simp only [Matrix.add_apply,Matrix.sub_apply,Matrix.neg_apply,Matrix.smul_apply, + smul_eq_mul,RCLike.real_smul_eq_coe_smul (K := ℂ),RCLike.ofReal_eq_complex_ofReal] + have hRC : (R:ℂ) ≠ 0 := by exact_mod_cast hR + field_simp [hRC] + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e26b0463f0918c5507e659ce59b0d3724b5aba2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGraph.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumParallelGraph + +namespace OAI + +/-! Ordinary spin edges and polynomial full-space error for a parallel fork round. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Kronecker Classical +variable {ν : Type*} [Fintype ν] + +def qmaForksBaseLeft {n r : ℕ} (left : ν → Fin n) (site : Fin r → Fin 3 → Fin n) : + ν ⊕ Fin r → Fin n := Sum.elim left (fun e => site e 1) +def qmaForksBaseRight {n r : ℕ} (right : ν → Fin n) (site : Fin r → Fin 3 → Fin n) : + ν ⊕ Fin r → Fin n := Sum.elim right (fun e => site e 2) +def qmaForksBaseWeight {r : ℕ} (weight : ν → ℝ) (J K : Fin r → ℝ) : + ν ⊕ Fin r → ℝ := Sum.elim weight (fun e => 2*J e*K e) + +omit [Fintype ν] in +theorem qmaForksBase_distinct {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (site : Fin r → Fin 3 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) : + ∀ a, qmaForksBaseLeft left site a ≠ qmaForksBaseRight right site a := by + intro a + cases a with + | inl a => exact hneq a + | inr e => exact fun h => (by decide : (1 : Fin 3) ≠ 2) (hsite e h) + +theorem qmaForksBase_matrix {n r : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant : ℝ) (site : Fin r → Fin 3 → Fin n) (J K : Fin r → ℝ) : + qmaExchangeMatrix (qmaForksBaseLeft left site) (qmaForksBaseRight right site) + (qmaForksBaseWeight weight J K) (constant+∑ e, qmaForkOffset (J e) (K e)) = + qmaExchangeMatrix left right weight constant + + ∑ e, qmaForkCorrection (site e) (J e) (K e) := by + simp only [qmaExchangeMatrix,Fintype.sum_sum_type,qmaForksBaseLeft,qmaForksBaseRight, + qmaForksBaseWeight,Sum.elim_inl,Sum.elim_inr,qmaForkCorrection,qmaForkOffset, + Complex.ofReal_add,Complex.ofReal_sum,add_smul,Finset.sum_add_distrib,Finset.sum_smul] + abel + +def qmaForksGraph {n r : ℕ} (left right : ν → Fin n) (weight : ν → ℝ) + (constant R : ℝ) (site : Fin r → Fin 3 → Fin n) (J K : Fin r → ℝ) : + Matrix (SourceSpinBasis (n+r*2)) (SourceSpinBasis (n+r*2)) ℂ := + qmaExchangeMatrix + (qmaParallelGraphLeft (qmaForksBaseLeft left site) site) + (qmaParallelGraphRight (qmaForksBaseRight right site) (fun _ => qmaForkMember)) + (qmaParallelGraphWeight (qmaForksBaseWeight weight J K) (R^2) + (fun e => qmaForkAmplitude R (J e) (K e))) + ((constant+∑ e, qmaForkOffset (J e) (K e))+3*r*(R^2)) + +theorem qmaForksGraph_matrix {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant R : ℝ) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) (J K : Fin r → ℝ) : + (qmaForksGraph left right weight constant R site J K).submatrix + (basisEquiv n r) (basisEquiv n r) = + qmaPhysicalParallelHamiltonian n r (R^2) + (qmaExchangeMatrix left right weight constant+∑ e, qmaForkCorrection (site e) (J e) (K e)) + site (fun _ => qmaForkMember) (fun e => qmaForkAmplitude R (J e) (K e)) := by + unfold qmaForksGraph + simpa only [qmaForksBase_matrix] using + qmaParallelGraph_matrix _ _ (qmaForksBase_distinct left right hneq site hsite) + (qmaForksBaseWeight weight J K) (constant+∑ e, qmaForkOffset (J e) (K e)) (R^2) + site (fun _ => qmaForkMember) (fun e => qmaForkAmplitude R (J e) (K e)) + +theorem qmaForksGraph_accuracy {n r : ℕ} (left right : ν → Fin n) + (hneq : ∀ a, left a ≠ right a) (weight : ν → ℝ) (constant : ℝ) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (J K : Fin r → ℝ) {N : ℝ} (hN : 0 < N) : + let B := 3*(∑ a, |weight a|)+|constant| + let A := 3*∑ e, (1+2*|J e|+2*|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + let R := qmaRoutingScale A D N + |sourceMatrixBottom (n+r*2) (qmaForksGraph left right weight constant R site J K) - + sourceMatrixBottom n (qmaExchangeMatrix left right weight constant + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 1) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2)))| ≤ 1/N := by + dsimp only + rw [sourceMatrixBottom_eq_mediator n r,qmaForksGraph_matrix left right hneq weight constant _ site hsite, + qmaPhysicalParallel_bottom] + have hC : (qmaExchangeMatrix left right weight constant).conjTranspose = + qmaExchangeMatrix left right weight constant := by + simp only [qmaExchangeMatrix,Matrix.conjTranspose_add,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,sourceHeisenbergMatrix_star n _ _ (hneq _), + Complex.star_def,Complex.conj_ofReal,Matrix.conjTranspose_one] + exact qmaForks_accuracy site hsite J K (by positivity) hN _ hC + (qmaExchangeMatrix_lift_norm left right hneq weight constant) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGridInitial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGridInitial.lean new file mode 100644 index 0000000000000000000000000000000000000000..f50fcb18a329cc5961295b7fcdca15a8253cf31c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkGridInitial.lean @@ -0,0 +1,112 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkGridProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCells + +namespace OAI + +/-! The initial subdivision computes its row/column array from the actual +endpoint list, before the same fixed-round grid program is applied. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkGridProgram +open QuantumForkList MediatorListProgram ExactQuantumFactoring.BitStackProgram + +abbrev InitialCells := ℕ × (List Bond × List QuantumRouteCode.Pair) +def initialCellsCode : InitialCells → List Bool := + prodCode unaryCode (prodCode (listCode bondCode) (listCode QuantumRouteCode.pairCode)) +def initialQueryCode : (ℕ × InitialCells) → List Bool := prodCode Nat.bits initialCellsCode + +noncomputable def initialCellProgram : Procedure initialQueryCode QuantumRouteCode.pairCode + (fun x => initialCell x.2.1 x.2.2.1 (lookup x.2.2.2) x.1) := by + let v := Procedure.first Nat.bits initialCellsCode + let env := Procedure.second Nat.bits initialCellsCode + let n := Procedure.unaryToBits.comp ((Procedure.first unaryCode + (prodCode (listCode bondCode) (listCode QuantumRouteCode.pairCode))).comp env) + let tail := (Procedure.second unaryCode + (prodCode (listCode bondCode) (listCode QuantumRouteCode.pairCode))).comp env + let bs := (Procedure.first (listCode bondCode) (listCode QuantumRouteCode.pairCode)).comp tail + let cells := (Procedure.second (listCode bondCode) (listCode QuantumRouteCode.pairCode)).comp tail + let endpoint := initialEndpointProgram.comp ((Procedure.binarySub.comp (v.pair n)).pair bs) + let target := Procedure.conditional (Procedure.binaryLt.comp (v.pair n)) v endpoint + exact ((Procedure.listGet QuantumRouteCode.pairCode (0,0)).comp (target.pair cells)).congrFun (by + intro x + change lookup x.2.2.2 (if decide (x.1 simp [h]) + +def initialCells (x : InitialCells) : List QuantumRouteCode.Pair := + (List.range (x.1+2*x.2.1.length)).map (initialCell x.1 x.2.1 (lookup x.2.2)) + +noncomputable def initialCellsProgram : + Procedure initialCellsCode (listCode QuantumRouteCode.pairCode) initialCells := by + let n := Procedure.first unaryCode + (prodCode (listCode bondCode) (listCode QuantumRouteCode.pairCode)) + let bs := (Procedure.first (listCode bondCode) (listCode QuantumRouteCode.pairCode)).comp + (Procedure.second unaryCode (prodCode (listCode bondCode) (listCode QuantumRouteCode.pairCode))) + let len := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode (0,0,0)).comp bs + let count := Procedure.unaryAdd.comp (n.pair (Procedure.unaryAdd.comp (len.pair len))) + let query : Procedure (prodCode unaryCode initialCellsCode) initialQueryCode + (fun x => (x.1,x.2)) := + (Procedure.unaryToBits.comp (Procedure.first unaryCode initialCellsCode)).pair + (Procedure.second unaryCode initialCellsCode) + exact ((Procedure.tabulate (f := fun x i => initialCell x.1 x.2.1 (lookup x.2.2) i) + (0,0) (initialCellProgram.comp query)).comp + (count.pair (Procedure.identity initialCellsCode))).congrFun (by + intro x + change (List.range (x.1+(x.2.1.length+x.2.1.length))).map _=initialCells x + simp only [initialCells,two_mul,id_eq]) + +theorem lookup_initialCells (x : InitialCells) (v : ℕ) (hv : v nextCell x.2.1 (lookup x.2.2) x.1) := by + let v := Procedure.first Nat.bits cellsCode + let env := Procedure.second Nat.bits cellsCode + let s := (Procedure.first QuantumForkList.stateCode (listCode QuantumRouteCode.pairCode)).comp env + let xs := (Procedure.second QuantumForkList.stateCode (listCode QuantumRouteCode.pairCode)).comp env + let n := Procedure.unaryToBits.comp (countProgram.comp s) + let before := Procedure.binaryLt.comp (v.pair n) + let pair := Procedure.binaryDiv.comp + ((Procedure.binarySub.comp (v.pair n)).pair (Procedure.constant queryCode Nat.bits 2)) + let ps := catalogProgram.comp (groupsProgram.comp s) + let center := (Procedure.first Nat.bits QuantumForkList.pairCode).comp + ((Procedure.listGet taggedCode (0,((0,0),(0,0)))).comp (pair.pair ps)) + let target := Procedure.conditional before v center + exact ((Procedure.listGet QuantumRouteCode.pairCode (0,0)).comp (target.pair xs)).congrFun (by + intro x + change lookup x.2.2 (if decide (x.1 simp [h]) + +def nextCells (x : Cells) : List QuantumRouteCode.Pair := + (List.range (x.1.1+2*pairCount x.1.2.2.2)).map (nextCell x.1 (lookup x.2)) + +noncomputable def nextCellsProgram : Procedure cellsCode (listCode QuantumRouteCode.pairCode) nextCells := by + let s := Procedure.first QuantumForkList.stateCode (listCode QuantumRouteCode.pairCode) + let n := countProgram.comp s + let pairs := pairCountProgram.comp (groupsProgram.comp s) + let count := Procedure.unaryAdd.comp (n.pair (Procedure.unaryAdd.comp (pairs.pair pairs))) + let query : Procedure (prodCode unaryCode cellsCode) queryCode (fun x => (x.1,x.2)) := + (Procedure.unaryToBits.comp (Procedure.first unaryCode cellsCode)).pair + (Procedure.second unaryCode cellsCode) + let entry := nextCellProgram.comp query + exact ((Procedure.tabulate (f := fun x i => nextCell x.1 (lookup x.2) i) (0,0) entry).comp + (count.pair (Procedure.identity cellsCode))).congrFun (by + intro x + change (List.range (x.1.1+(pairCount x.1.2.2.2+pairCount x.1.2.2.2))).map _=nextCells x + simp only [nextCells,two_mul,id_eq]) + +abbrev Input := ℚ × Cells +def inputCode : Input → List Bool := prodCode ratCode cellsCode +def step (x : Input) : Cells := (next x.1 x.2.1,nextCells x.2) + +noncomputable def stepProgram : Procedure inputCode cellsCode step := by + let scale := Procedure.first ratCode cellsCode + let env := Procedure.second ratCode cellsCode + let s := (Procedure.first QuantumForkList.stateCode (listCode QuantumRouteCode.pairCode)).comp env + exact (nextProgram.comp (scale.pair s)).pair (nextCellsProgram.comp env) + +def run : ℕ → Input → Cells + | 0,x => x.2 + | k+1,x => step (x.1,run k x) + +noncomputable def runProgram : (k : ℕ) → Procedure inputCode cellsCode (run k) + | 0 => Procedure.second ratCode cellsCode + | k+1 => stepProgram.comp ((Procedure.first ratCode cellsCode).pair (runProgram k)) + +theorem run_state (k : ℕ) (x : Input) : (run k x).1=iterate x.1 k x.2.1 := by + induction k with + | zero => rfl + | succ k ih => change next x.1 (run k x).1=next x.1 (iterate x.1 k x.2.1); rw [ih] + +theorem run_length (k : ℕ) (x : Input) (h : x.2.2.length=x.2.1.1) : + (run k x).2.length=(run k x).1.1 := by + cases k with + | zero => exact h + | succ k => simp only [run,step,nextCells,List.length_map,List.length_range,next] + +def Represents (x : Cells) (cell : ℕ → QuantumRouteCode.Pair) : Prop := + ∀ v, v exact h + | succ k ih => + have hi : ValidPorts (run k x).1.1 (run k x).1.2.2.2 := by + rw [run_state] + exact iterate_validPorts x.1 x.2.1 hs k + have hn := step_represents (x.1,run k x) hi _ ih + simpa only [run_state,run,iterateCell] using hn + +end ContinuumCoulomb.QuantumForkGridProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitial.lean new file mode 100644 index 0000000000000000000000000000000000000000..1173fe215af7f9edaf137432aa24f1f897f5a972 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitial.lean @@ -0,0 +1,115 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkRounds + +namespace OAI + +/-! Odd subdivision gives every original incidence its own private fork port. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical + +def qmaOriginalEndpoint {n m : ℕ} (left right : Fin m → Fin n) (p : Fin m × Fin 2) : Fin n := + if p.2 = 0 then left p.1 else right p.1 + +def qmaOriginalPortCount {n m : ℕ} (left right : Fin m → Fin n) (i : Fin n) : ℕ := + Fintype.card {p : Fin m × Fin 2 // qmaOriginalEndpoint left right p = i} + +def qmaOriginalPortEquiv {n m : ℕ} (left right : Fin m → Fin n) : + (Σ i, Fin (qmaOriginalPortCount left right i)) ≃ Fin m × Fin 2 := + (Equiv.sigmaCongrRight (fun i => (Fintype.equivFin + {p : Fin m × Fin 2 // qmaOriginalEndpoint left right p = i}).symm)).trans + (Equiv.sigmaFiberEquiv (qmaOriginalEndpoint left right)) + +theorem qmaOriginalPortCount_eq_degree {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (i : Fin n) : + qmaOriginalPortCount left right i = qmaGraphDegree left right i := by + unfold qmaOriginalPortCount + rw [Fintype.card_subtype] + have hc : (∑ p : Fin m × Fin 2, if qmaOriginalEndpoint left right p = i then 1 else 0 : ℕ) = + (Finset.univ.filter (fun p => qmaOriginalEndpoint left right p = i)).card := by simp + rw [← hc] + simp only [Fintype.sum_prod_type,Fin.sum_univ_two,qmaOriginalEndpoint] + apply Finset.sum_congr rfl + intro e _ + have h := hneq e + by_cases hl : left e = i <;> by_cases hr : right e = i <;> simp_all + +def qmaSubdivisionPorts {n m : ℕ} (left right : Fin m → Fin n) : + QMAForkPorts (n+m*2) n (qmaOriginalPortCount left right) where + center := old n m + port := fun p => fresh n m (qmaOriginalPortEquiv left right p).1 + (qmaOriginalPortEquiv left right p).2 + center_injective := old_injective n m + port_injective := (fresh_injective n m).comp (qmaOriginalPortEquiv left right).injective + center_ne_port := fun _ _ => old_ne_fresh n m _ _ _ + +def qmaSubdivisionLeft (n m : ℕ) (e : Fin m) : Fin (n+m*2) := fresh n m e 0 +def qmaSubdivisionRight (n m : ℕ) (e : Fin m) : Fin (n+m*2) := fresh n m e 1 + +theorem qmaSubdivision_distinct (n m : ℕ) (e : Fin m) : + qmaSubdivisionLeft n m e ≠ qmaSubdivisionRight n m e := by + intro h + have hh := fresh_injective n m (a₁ := (e,0)) (a₂ := (e,1)) h + have := congrArg Prod.snd hh + norm_num at this + +theorem qmaSubdivision_old_degree (n m : ℕ) (v : Fin n) : + qmaGraphDegree (qmaSubdivisionLeft n m) (qmaSubdivisionRight n m) (old n m v) = 0 := by + have h (e : Fin m) (b : Fin 2) : fresh n m e b ≠ old n m v := (old_ne_fresh n m v e b).symm + simp [qmaGraphDegree,qmaSubdivisionLeft,qmaSubdivisionRight,h] + +theorem qmaSubdivision_fresh_degree (n m : ℕ) (e : Fin m) (b : Fin 2) : + qmaGraphDegree (qmaSubdivisionLeft n m) (qmaSubdivisionRight n m) (fresh n m e b) = 1 := by + have hh (f : Fin m) (a : Fin 2) : fresh n m f a = fresh n m e b ↔ f = e ∧ a = b := by + constructor + · intro h + exact Prod.mk.inj (fresh_injective n m (a₁ := (f,a)) (a₂ := (e,b)) h) + · rintro ⟨rfl,rfl⟩ + rfl + simp only [qmaGraphDegree,qmaSubdivisionLeft,qmaSubdivisionRight,hh] + fin_cases b <;> simp + +def qmaSubdivisionState {n m : ℕ} (left right : Fin m → Fin n) : + QMAForkState (n+m*2) n (qmaOriginalPortCount left right) (Fin m) where + ports := qmaSubdivisionPorts left right + left := qmaSubdivisionLeft n m + right := qmaSubdivisionRight n m + distinct := qmaSubdivision_distinct n m + degree_le := by + intro v + obtain ⟨v,rfl⟩ := (vertexEquiv n m).surjective v + rcases v with v | ⟨e,b⟩ + · rw [show vertexEquiv n m (.inl v) = old n m v from rfl,qmaSubdivision_old_degree] + omega + · rw [show vertexEquiv n m (.inr (e,b)) = fresh n m e b from rfl, + qmaSubdivision_fresh_degree] + omega + center_degree := qmaSubdivision_old_degree n m + port_degree := by + intro p + change qmaGraphDegree _ _ (fresh n m (qmaOriginalPortEquiv left right p).1 + (qmaOriginalPortEquiv left right p).2) ≤ 1 + rw [qmaSubdivision_fresh_degree] + +def qmaSubdivisionNetwork {n m : ℕ} (left right : Fin m → Fin n) : QMAForkNetwork n where + n := n+m*2 + degree := qmaOriginalPortCount left right + Edge := Fin m + state := qmaSubdivisionState left right + +theorem qmaSubdivision_degree_three {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (D : ℕ) + (hD : ∀ i, qmaGraphDegree left right i ≤ D) + (v : Fin ((qmaSubdivisionNetwork left right).iterate D).n) : + qmaGraphDegree ((qmaSubdivisionNetwork left right).iterate D).state.fullLeft + ((qmaSubdivisionNetwork left right).iterate D).state.fullRight v ≤ 3 := by + apply QMAForkNetwork.constant_round_degree + intro i + exact (qmaOriginalPortCount_eq_degree left right hneq i).le.trans (hD i) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3d9650ebf2c4b6bda4d0ea227ff190287c61042 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialCells.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkPlaced +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitial + +namespace OAI + +/-! Initial private ports and all subsequent fork vertices retain bounded cell density. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +variable {n m : ℕ} {β : Type*} + +theorem qmaOriginalPortEquiv_endpoint (left right : Fin m → Fin n) + (p : Σ i, Fin (qmaOriginalPortCount left right i)) : + qmaOriginalEndpoint left right (qmaOriginalPortEquiv left right p) = p.1 := + ((Fintype.equivFin {q : Fin m × Fin 2 // qmaOriginalEndpoint left right q = p.1}).symm p.2).property + +def qmaSubdivisionCell (left right : Fin m → Fin n) (cell : Fin n → β) : Fin (n+m*2) → β := + Sum.elim cell (fun p => cell (qmaOriginalEndpoint left right p)) ∘ (vertexEquiv n m).symm + +@[simp] theorem qmaSubdivisionCell_old (left right : Fin m → Fin n) (cell : Fin n → β) + (i : Fin n) : qmaSubdivisionCell left right cell (old n m i) = cell i := by + simp [qmaSubdivisionCell,old] + +@[simp] theorem qmaSubdivisionCell_fresh (left right : Fin m → Fin n) (cell : Fin n → β) + (e : Fin m) (b : Fin 2) : + qmaSubdivisionCell left right cell (fresh n m e b) = cell (qmaOriginalEndpoint left right (e,b)) := by + simp [qmaSubdivisionCell,fresh] + +theorem qmaSubdivisionCell_aligned (left right : Fin m → Fin n) (cell : Fin n → β) : + QMAForkCellAligned (qmaSubdivisionPorts left right) (qmaSubdivisionCell left right cell) := by + intro p + change qmaSubdivisionCell left right cell (fresh n m (qmaOriginalPortEquiv left right p).1 + (qmaOriginalPortEquiv left right p).2) = qmaSubdivisionCell left right cell (old n m p.1) + rw [qmaSubdivisionCell_fresh,qmaSubdivisionCell_old] + exact congrArg cell (qmaOriginalPortEquiv_endpoint left right p) + +theorem qmaSubdivisionCell_mass [DecidableEq β] (left right : Fin m → Fin n) + (cell : Fin n → β) (x : β) : + qmaCellMass (qmaSubdivisionCell left right cell) x = qmaCellMass cell x + + ∑ p : Fin m × Fin 2, if cell (qmaOriginalEndpoint left right p) = x then 1 else 0 := by + unfold qmaCellMass + rw [← (vertexEquiv n m).sum_comp,Fintype.sum_sum_type] + simp only [qmaSubdivisionCell,Function.comp_apply,Equiv.symm_apply_apply,Sum.elim_inl,Sum.elim_inr] + +theorem qmaSubdivisionCell_mass_le [DecidableEq β] (left right : Fin m → Fin n) + (cell : Fin n → β) (D : ℕ) (hd : ∀ i, qmaOriginalPortCount left right i ≤ D) (x : β) : + qmaCellMass (qmaSubdivisionCell left right cell) x ≤ (D+1)*qmaCellMass cell x := by + rw [qmaSubdivisionCell_mass] + have hs := (qmaOriginalPortEquiv left right).sum_comp + (fun p => if cell (qmaOriginalEndpoint left right p) = x then (1:ℕ) else 0) + simp only [qmaOriginalPortEquiv_endpoint,Fintype.sum_sigma] at hs + have hb : (∑ i : Fin n, ∑ _j : Fin (qmaOriginalPortCount left right i), + if cell i = x then (1:ℕ) else 0) ≤ D*qmaCellMass cell x := by + unfold qmaCellMass + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + by_cases hx : cell i = x + · simpa only [hx,ite_true,Finset.sum_const,Finset.card_univ,Fintype.card_fin, + smul_eq_mul,Nat.mul_one] using hd i + · simp [hx] + rw [← hs] + calc + _ ≤ qmaCellMass cell x+D*qmaCellMass cell x := Nat.add_le_add_left hb _ + _ = _ := by ring + +def qmaSubdivisionPlaced (left right : Fin m → Fin n) (cell : Fin n → β) : + QMAPlacedForkNetwork β n where + graph := qmaSubdivisionNetwork left right + cell := qmaSubdivisionCell left right cell + aligned := qmaSubdivisionCell_aligned left right cell + +theorem qmaSubdivisionPlaced_centerCell (left right : Fin m → Fin n) (cell : Fin n → β) : + (qmaSubdivisionPlaced left right cell).centerCell = cell := by + funext i + exact qmaSubdivisionCell_old left right cell i + +theorem qmaSubdivisionPlaced_density [DecidableEq β] (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (cell : Fin n → β) (D : ℕ) + (hd : ∀ i, qmaGraphDegree left right i ≤ D) (x : β) : + qmaCellMass ((qmaSubdivisionPlaced left right cell).iterate D).cell x ≤ + (1+D+2*D^2)*qmaCellMass cell x := by + have hc : ∀ i, qmaOriginalPortCount left right i ≤ D := fun i => + (qmaOriginalPortCount_eq_degree left right hneq i).le.trans (hd i) + have hi := (qmaSubdivisionPlaced left right cell).iterate_cell_mass D hc D x + rw [qmaSubdivisionPlaced_centerCell] at hi + have h0 := qmaSubdivisionCell_mass_le left right cell D hc x + calc + _ ≤ qmaCellMass (qmaSubdivisionCell left right cell) x+2*D*D*qmaCellMass cell x := hi + _ ≤ (D+1)*qmaCellMass cell x+2*D*D*qmaCellMass cell x := Nat.add_le_add_right h0 _ + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialLocality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..28cf97288aaf0fcfd9467fbd8255a6e43a6c0372 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialLocality.lean @@ -0,0 +1,37 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkLocality +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitialCells + +namespace OAI + +/-! The initial subdivision preserves the original edge locality relation. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical + +theorem qmaSubdivisionPlaced_backgroundLocal {n m : ℕ} {β : Type*} + (left right : Fin m → Fin n) (cell : Fin n → β) (R : β → β → Prop) + (h : ∀ e, R (cell (left e)) (cell (right e))) : + (qmaSubdivisionPlaced left right cell).BackgroundLocal R := by + intro e + change Fin m at e + change R (qmaSubdivisionCell left right cell (fresh n m e 0)) + (qmaSubdivisionCell left right cell (fresh n m e 1)) + rw [qmaSubdivisionCell_fresh,qmaSubdivisionCell_fresh] + simpa [qmaOriginalEndpoint] using h e + +theorem qmaSubdivisionPlaced_full_local {n m : ℕ} {β : Type*} + (left right : Fin m → Fin n) (cell : Fin n → β) (R : β → β → Prop) + (hr : ∀ x, R x x) (h : ∀ e, R (cell (left e)) (cell (right e))) (k : ℕ) : + let G := (qmaSubdivisionPlaced left right cell).iterate k + ∀ e, R (G.cell (G.graph.state.fullLeft e)) (G.cell (G.graph.state.fullRight e)) := by + intro G + exact G.full_local R hr ((qmaSubdivisionPlaced left right cell).iterate_backgroundLocal R hr + (qmaSubdivisionPlaced_backgroundLocal left right cell R h) k) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..f599a108a41400d010502f2eddf3497e9f3421ab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialMatrix.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitial +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkIteration +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathsGraph + +namespace OAI + +/-! The private-port initial state is the physical odd-subdivision Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Classical + +def qmaSubdivisionWeighted {n m : ℕ} (left right : Fin m → Fin n) + (J : Fin m → ℝ) (constant R : ℝ) : QMAWeightedForkNetwork n where + graph := qmaSubdivisionNetwork left right + weight := fun _ => R^2 + active := fun p => qmaPathAmplitude false R (J (qmaOriginalPortEquiv left right p).1) + (qmaOriginalPortEquiv left right p).2 + constant := (constant+∑ e, qmaPathOffset (J e))+3*(m:ℝ)*R^2 + +def qmaOriginalSite {n m : ℕ} (left right : Fin m → Fin n) (e : Fin m) : Fin 2 → Fin n := + ![left e,right e] + +theorem qmaOriginalSite_injective {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (e : Fin m) : Function.Injective (qmaOriginalSite left right e) := by + intro a b h + fin_cases a <;> fin_cases b <;> simp [qmaOriginalSite] at h ⊢ + · exact (hneq e h).elim + · exact (hneq e h.symm).elim + +theorem qmaSubdivision_weighted_matrix {n m : ℕ} (left right : Fin m → Fin n) + (J : Fin m → ℝ) (constant R : ℝ) : + let G := qmaSubdivisionWeighted left right J constant R + G.graph.state.matrix G.weight G.active G.constant = + qmaPathsGraph (fun a : Fin 0 => Fin.elim0 a) (fun a : Fin 0 => Fin.elim0 a) + (fun _ => 0) constant R (qmaOriginalSite left right) (fun _ => false) J := by + dsimp only + rw [QMAForkState.matrix_expand] + have hs := (qmaOriginalPortEquiv left right).symm.sum_comp + (fun p => (qmaPathAmplitude false R (J (qmaOriginalPortEquiv left right p).1) + (qmaOriginalPortEquiv left right p).2 : ℂ) • + sourceHeisenbergMatrix (n+m*2) (old n m p.1) + (fresh n m (qmaOriginalPortEquiv left right p).1 (qmaOriginalPortEquiv left right p).2)) + simp only [Equiv.apply_symm_apply,Fintype.sum_prod_type] at hs + change (∑ e, ((R^2:ℝ):ℂ) • sourceHeisenbergMatrix (n+m*2) + (fresh n m e 0) (fresh n m e 1)) + + (∑ p, (qmaPathAmplitude false R (J (qmaOriginalPortEquiv left right p).1) + (qmaOriginalPortEquiv left right p).2 : ℂ) • sourceHeisenbergMatrix (n+m*2) + (old n m p.1) (fresh n m (qmaOriginalPortEquiv left right p).1 + (qmaOriginalPortEquiv left right p).2)) + + (((constant+∑ e, qmaPathOffset (J e))+3*(m:ℝ)*R^2:ℝ):ℂ) • 1 = _ + rw [← hs] + simp only [qmaPathsGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + Fin.sum_univ_two,qmaParallelGraphLeft,qmaParallelGraphRight,qmaParallelGraphWeight, + qmaOriginalSite,qmaPathAmplitude,qmaPathMember,Finset.univ_eq_empty,Finset.sum_empty,zero_add] + ac_rfl + +theorem qmaSubdivision_energy_error {n m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ e, left e ≠ right e) (J : Fin m → ℝ) (constant : ℝ) + {N : ℝ} (hN : 0 < N) : + let A := 3*∑ e, (1+2*|J e|) + let B := |constant|+4*∑ e, (1+|J e|)^2 + let R := qmaRoutingScale A B N + |(qmaSubdivisionWeighted left right J constant R).energy - + sourceMatrixBottom n (qmaExchangeMatrix left right J constant)| ≤ 1/N := by + dsimp only + unfold QMAWeightedForkNetwork.energy + rw [qmaSubdivision_weighted_matrix] + dsimp only [qmaSubdivisionWeighted,qmaSubdivisionNetwork] + have h := qmaPathsGraph_accuracy (fun a : Fin 0 => Fin.elim0 a) + (fun a : Fin 0 => Fin.elim0 a) (fun a => Fin.elim0 a) (fun _ => 0) constant + (qmaOriginalSite left right) (qmaOriginalSite_injective left right hneq) (fun _ => false) J hN + simpa [qmaExchangeMatrix,qmaOriginalSite,add_comm] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialSize.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..df392bd824d8f7a0772df7483e98083b4de52208 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkInitialSize.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitial + +namespace OAI + +/-! Explicit linear-size bounds for the constant-round degree reduction. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaOriginalPortCount_sum {n m : ℕ} (left right : Fin m → Fin n) : + (∑ i, qmaOriginalPortCount left right i) = 2*m := by + calc + _ = Fintype.card (Σ i, Fin (qmaOriginalPortCount left right i)) := by + simp only [Fintype.card_sigma,Fintype.card_fin] + _ = Fintype.card (Fin m × Fin 2) := Fintype.card_congr (qmaOriginalPortEquiv left right) + _ = 2*m := by simp only [Fintype.card_prod,Fintype.card_fin]; omega + +theorem qmaSubdivision_vertices {n m : ℕ} (left right : Fin m → Fin n) (D : ℕ) : + ((qmaSubdivisionNetwork left right).iterate D).n ≤ n+2*m+4*D*m := by + have h := (qmaSubdivisionNetwork left right).iterate_vertices D + change ((qmaSubdivisionNetwork left right).iterate D).n ≤ + n+m*2+2*D*(∑ i, qmaOriginalPortCount left right i) at h + rw [qmaOriginalPortCount_sum] at h + convert h using 1; ring + +theorem qmaSubdivision_edges {n m : ℕ} (left right : Fin m → Fin n) (D : ℕ) : + Fintype.card (((qmaSubdivisionNetwork left right).iterate D).Edge ⊕ + (Σ i, Fin (((qmaSubdivisionNetwork left right).iterate D).degree i))) ≤ 3*m+8*D*m := by + let G := qmaSubdivisionNetwork left right + have hb := G.iterate_background_edges D + have hm := G.iterate_mass_le D + have hs : (∑ i, G.degree i) = 2*m := qmaOriginalPortCount_sum left right + have he : Fintype.card G.Edge = m := Fintype.card_fin m + rw [hs,he] at hb + rw [hs] at hm + change Fintype.card ((G.iterate D).Edge ⊕ (Σ i, Fin ((G.iterate D).degree i))) ≤ _ + simp only [Fintype.card_sum,Fintype.card_sigma,Fintype.card_fin] + calc + _ ≤ (m+4*D*(2*m))+2*m := Nat.add_le_add hb hm + _ = 3*m+8*D*m := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkIteration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..66792cfcb4c393f068de317731a37a05867372b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkIteration.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateAccuracy +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkRounds + +namespace OAI + +/-! Iterating the actual weighted graph keeps a proved full-space energy error. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical + +structure QMAWeightedForkNetwork (c : ℕ) where + graph : QMAForkNetwork c + weight : graph.Edge → ℝ + active : (Σ i, Fin (graph.degree i)) → ℝ + constant : ℝ + +namespace QMAWeightedForkNetwork +variable {c : ℕ} + +def energy (G : QMAWeightedForkNetwork c) : ℝ := + sourceMatrixBottom G.graph.n (G.graph.state.matrix G.weight G.active G.constant) + +def scale (G : QMAWeightedForkNetwork c) (N : ℝ) : ℝ := + let P := G.graph.state + let B := 3*(∑ a, |P.retainedWeight G.weight G.active a|)+|G.constant| + let A := 3*∑ e, (1+2*|P.pairWeight G.active 0 e|+2*|P.pairWeight G.active 1 e|) + let D := B+12*∑ e, (1+|P.pairWeight G.active 0 e|+|P.pairWeight G.active 1 e|)^2 + qmaRoutingScale A D N + +def next (G : QMAWeightedForkNetwork c) (N : ℝ) : QMAWeightedForkNetwork c where + graph := G.graph.next + weight := G.graph.state.nextWeight (G.scale N) G.weight G.active + active := G.graph.state.nextActive (G.scale N) G.active + constant := G.graph.state.nextConstant (G.scale N) G.constant G.active + +theorem next_energy_error (G : QMAWeightedForkNetwork c) {N : ℝ} (hN : 0 < N) : + |(G.next N).energy-G.energy| ≤ 1/N := by + exact G.graph.state.next_accuracy G.weight G.active G.constant hN + +def iterate (G : QMAWeightedForkNetwork c) (N : ℝ) : ℕ → QMAWeightedForkNetwork c + | 0 => G + | k+1 => (G.iterate N k).next N + +theorem iterate_graph (G : QMAWeightedForkNetwork c) (N : ℝ) (k : ℕ) : + (G.iterate N k).graph = G.graph.iterate k := by + induction k with + | zero => rfl + | succ k ih => + change (G.iterate N k).graph.next = (G.graph.iterate k).next + rw [ih] + +theorem iterate_energy_error (G : QMAWeightedForkNetwork c) {N : ℝ} (hN : 0 < N) (k : ℕ) : + |(G.iterate N k).energy-G.energy| ≤ (k:ℝ)/N := by + induction k with + | zero => simp [iterate] + | succ k ih => + change |((G.iterate N k).next N).energy-G.energy| ≤ ((k+1:ℕ):ℝ)/N + calc + _ ≤ |((G.iterate N k).next N).energy-(G.iterate N k).energy| + + |(G.iterate N k).energy-G.energy| := abs_sub_le _ _ _ + _ ≤ 1/N+(k:ℝ)/N := add_le_add ((G.iterate N k).next_energy_error hN) ih + _ = ((k+1:ℕ):ℝ)/N := by push_cast; ring + +end QMAWeightedForkNetwork +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..639ec16e542f5cbc6381e828d6b0c83ef4256bc5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListAccuracy.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListRealization + +namespace OAI + +/-! Full-space error for one actual literal fork round. Both sides are the +matrices defined by the emitted bond/port lists, with their scalar offsets. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample +open scoped BigOperators Classical + +theorem catalog_index_sum {M : Type} [AddCommMonoid M] (gs : Groups) + (f : TaggedPair → M) : ((catalog gs).map f).sum = + ∑ e : Fin (pairCount gs), f (((catalog gs).drop e.val).headD (0,((0,0),(0,0)))) := by + rw [← ExactQuantumFactoring.BitStackProgram.map_range_getD (catalog gs) + (0,((0,0),(0,0))) f,catalog_length,range_sum] + +theorem rawBondMatrix_fin {n : ℕ} (a b : Fin n) (J : ℚ) : + rawBondMatrix n (a.val,b.val,J)=(J:ℂ) • sourceHeisenbergMatrix n a b := + rawBondMatrix_erase (a,b,J) + +theorem paired_matrix {n : ℕ} {gs : Groups} (hs : ValidPorts n gs) : + ((pairedBonds gs).map (rawBondMatrix n)).sum = + ∑ e : Fin (pairCount gs), + ((actualJ gs e:ℂ) • sourceHeisenbergMatrix n (actualSite hs e 0) (actualSite hs e 1) + + (actualK gs e:ℂ) • sourceHeisenbergMatrix n (actualSite hs e 0) (actualSite hs e 2)) := by + simp only [pairedBonds,List.flatMap_def,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def,List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero] + rw [catalog_index_sum] + apply Finset.sum_congr rfl + intro e _ + rw [catalog_actualSite hs e] + simp only [rawBondMatrix_fin] + +theorem input_matrix_graph (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) : + matrix s = qmaExchangeMatrix (n := s.1) (backgroundGraph s hb hn).left (backgroundGraph s hb hn).right + (fun e => ((backgroundGraph s hb hn).weight e:ℝ)) (s.2.2.1:ℝ) + + ∑ e : Fin (pairCount s.2.2.2), + ((actualJ s.2.2.2 e:ℂ) • sourceHeisenbergMatrix s.1 (actualSite hs e 0) (actualSite hs e 1) + + (actualK s.2.2.2 e:ℂ) • sourceHeisenbergMatrix s.1 (actualSite hs e 0) (actualSite hs e 2)) := by + have h := matrix_pairing s + change matrix s=rawMatrix s.1 (background s,s.2.2.1)+_ at h + rw [← background_matrix s hb hn,paired_matrix hs] at h + exact h + +theorem next_accuracy (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) (hN : 0 < N) : + |normalizedBottom (matrix (next N s))-normalizedBottom (matrix s)| ≤ 1/(N:ℝ) := by + let left : Fin (background s).length → Fin s.1 := (backgroundGraph s hb hn).left + let right : Fin (background s).length → Fin s.1 := (backgroundGraph s hb hn).right + let w : Fin (background s).length → ℚ := (backgroundGraph s hb hn).weight + have hneq : ∀ a, left a ≠ right a := (backgroundGraph s hb hn).distinct + have h := graph_accuracy left right hneq w + (actualSite hs) (actualSite_injective hs) (actualJ s.2.2.2) (actualK s.2.2.2) s.2.2.1 N hN + dsimp only at h + have hscale : graphScale w (actualJ s.2.2.2) (actualK s.2.2.2) s.2.2.1 N=scale N s := + (scale_eq_graphScale s hb hn N).symm + rw [graph_matrix,hscale] at h + change |normalizedBottom _-normalizedBottom _| ≤ 1/(N:ℝ) at h + have hout : normalizedBottom (matrix (next N s)) = + normalizedBottom (qmaForksGraph left right (fun e => (w e:ℝ)) (s.2.2.1:ℝ) + (scale N s:ℝ) (actualSite hs) (fun e => (actualJ s.2.2.2 e:ℝ)) + (fun e => (actualK s.2.2.2 e:ℝ))) := next_bottom_graph s hs hb hn N + have hin : matrix s = qmaExchangeMatrix left right (fun e => (w e:ℝ)) (s.2.2.1:ℝ)+ + ∑ e, ((actualJ s.2.2.2 e:ℂ) • sourceHeisenbergMatrix s.1 (actualSite hs e 0) (actualSite hs e 1)+ + (actualK s.2.2.2 e:ℂ) • sourceHeisenbergMatrix s.1 (actualSite hs e 0) (actualSite hs e 2)) := + input_matrix_graph s hs hb hn + rw [← hout,← hin] at h + exact h + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListActive.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListActive.lean new file mode 100644 index 0000000000000000000000000000000000000000..f06a21650a34d4eb270439f166f0eb385e6f908e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListActive.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListPartition +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListMatrix + +namespace OAI + +/-! Exact active-star matrices of the ordered compiler state. The pairing +identity applies to every matrix entry, including the retained odd port. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram QuantumRawExchange + +def starBonds (i : ℕ) (ps : List Port) : List Bond := + ps.map (fun p => (i,p.1,p.2)) + +def activeBonds (gs : Groups) : List Bond := + ((List.range gs.length).map (fun i => starBonds i (groupAt gs i))).flatten + +def unpairedBonds (gs : Groups) : List Bond := + ((List.range gs.length).map (fun i => starBonds i (unpaired (groupAt gs i)))).flatten + +def pairedBonds (gs : Groups) : List Bond := + (catalog gs).flatMap (fun p => [(p.1,p.2.1.1,p.2.1.2),(p.1,p.2.2.1,p.2.2.2)]) + +theorem catalog_sum {M : Type*} [AddCommMonoid M] (gs : Groups) (f : TaggedPair → M) : + ((catalog gs).map f).sum = + ((List.range gs.length).map (fun i => + ((pairs (groupAt gs i)).map (fun p => f (i,p))).sum)).sum := by + simp only [catalog,List.map_flatten,List.sum_flatten,List.map_map,Function.comp_def] + +theorem active_pairing {M : Type*} [AddCommMonoid M] (gs : Groups) (f : Bond → M) : + ((activeBonds gs).map f).sum = + ((pairedBonds gs).map f).sum+((unpairedBonds gs).map f).sum := by + have hp : ((List.range gs.length).map (fun i => + ((groupAt gs i).map (fun p => f (i,p.1,p.2))).sum)) = + (List.range gs.length).map (fun i => + ((pairs (groupAt gs i)).map (fun p => f (i,p.1.1,p.1.2)+f (i,p.2.1,p.2.2))).sum+ + ((unpaired (groupAt gs i)).map (fun p => f (i,p.1,p.2))).sum) := by + apply List.map_congr_left + intro i _ + exact paired_sum (fun p => f (i,p.1,p.2)) (groupAt gs i) + simp only [activeBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def] + rw [hp,List.sum_map_add] + congr 1 + · symm + simp only [pairedBonds,List.flatMap_def,List.map_flatten,List.sum_flatten, + List.map_map,Function.comp_def,List.map_cons,List.map_nil,List.sum_cons, + List.sum_nil,add_zero] + exact catalog_sum gs (fun p => f (p.1,p.2.1.1,p.2.1.2)+f (p.1,p.2.2.1,p.2.2.2)) + · simp only [unpairedBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def] + +def matrix (s : State) := rawMatrix s.1 (s.2.1++activeBonds s.2.2.2,s.2.2.1) + +theorem matrix_pairing (s : State) : matrix s = + rawMatrix s.1 (s.2.1++unpairedBonds s.2.2.2,s.2.2.1)+ + ((pairedBonds s.2.2.2).map (rawBondMatrix s.1)).sum := by + simp only [matrix,rawMatrix,List.map_append,List.sum_append, + active_pairing s.2.2.2 (rawBondMatrix s.1)] + abel + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBackground.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBackground.lean new file mode 100644 index 0000000000000000000000000000000000000000..189ae93f8bdd21849fc5a9d026ceb3cde8f15d14 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBackground.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListActive +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListGraph + +namespace OAI + +/-! The retained part of a literal fork state has exactly the coefficient +budget and finite exchange matrix used by the parallel-fork estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram QuantumRawExchange +open scoped BigOperators Classical + +def background (s : State) : List Bond := s.2.1++unpairedBonds s.2.2.2 + +theorem background_weights (s : State) : (background s).map (fun b => b.2.2)=retained s := by + simp only [background,retained,List.map_append] + congr 1 + simp only [unpairedBonds,starBonds,List.map_flatten,List.map_map,Function.comp_def] + have h := ExactQuantumFactoring.BitStackProgram.map_range_getD s.2.2.2 [] + (fun ps => (unpaired ps).map Prod.snd) + simpa only [groupAt,List.map_flatten,List.map_map,Function.comp_def] using + congrArg List.flatten h + +theorem rawBondMatrix_eq_bondMatrix (n : ℕ) (b : Bond) : + rawBondMatrix n b=SourceBondLists.bondMatrix n b := by + by_cases hi : b.1 by_cases hj : b.2.1 + simp [rawBondMatrix,SourceBondLists.bondMatrix,hi,hj] + +theorem rawMatrix_eq_matrix (n : ℕ) (bs : List Bond) (c : ℚ) : + rawMatrix n (bs,c)=SourceBondLists.matrix n bs+(c:ℂ) • 1 := by + have h : rawBondMatrix n=SourceBondLists.bondMatrix n := + funext (rawBondMatrix_eq_bondMatrix n) + simp only [rawMatrix,h,SourceBondLists.matrix,Rat.cast_smul_eq_qsmul] + +def backgroundGraph (s : State) (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) : QMARationalExchangeGraph := + QuantumListGraph.ofBonds s.1 (background s) s.2.2.1 hb hn + +theorem background_matrix (s : State) (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) : + qmaExchangeMatrix (backgroundGraph s hb hn).left (backgroundGraph s hb hn).right + (fun e => ((backgroundGraph s hb hn).weight e:ℝ)) s.2.2.1 = + rawMatrix s.1 (background s,s.2.2.1) := by + rw [rawMatrix_eq_matrix] + exact QuantumListGraph.ofBonds_matrix s.1 (background s) s.2.2.1 hb hn + +theorem background_sum (s : State) (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (f : ℚ → ℚ) : + (∑ e, f ((backgroundGraph s hb hn).weight e))=((retained s).map f).sum := by + change (∑ e : Fin (background s).length, f ((background s).get e).2.2)=_ + rw [← List.sum_ofFn] + have hl := List.ofFn_getElem_eq_map (background s) (fun b => f b.2.2) + simp only [List.get_eq_getElem] at hl ⊢ + rw [hl] + simpa only [List.map_map,Function.comp_def] using + congrArg (fun xs => (xs.map f).sum) (background_weights s) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBoundProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBoundProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..36aea8aee8478a09e22b89e6a1cf0513fd1843d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListBoundProgram.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListOutputBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientPrograms + +namespace OAI + +/-! Literal unary programs compute the coefficient envelopes. For each fixed +number of rounds, the complete numerical envelope is polynomial in its inputs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +def budgetNat (M L : ℕ) : ℕ := 3*M*L+L+3*M*(1+4*L)+12*M*(1+2*L)^2+1 +def radiusNat (M L T : ℕ) : ℕ := L+16*(budgetNat M L)^3*T+4*budgetNat M L+1 +def coefficientNat (M L T : ℕ) : ℕ := 1+L+(10*M+2)*(radiusNat M L T)^2 +def envelopeNat (M L T : ℕ) : ℕ → ℕ + | 0 => L + | k+1 => coefficientNat M (envelopeNat M L T k) T + +@[simp] theorem budgetNat_cast (M L : ℕ) : (budgetNat M L:ℝ)=forkBudget M L := by + simp [budgetNat,forkBudget] +@[simp] theorem radiusNat_cast (M L T : ℕ) : (radiusNat M L T:ℝ)=forkRadius M L T := by + simp [radiusNat,forkRadius] +@[simp] theorem coefficientNat_cast (M L T : ℕ) : + (coefficientNat M L T:ℝ)=forkCoefficient M L T := by + simp [coefficientNat,forkCoefficient] +@[simp] theorem envelopeNat_cast (M L T k : ℕ) : + (envelopeNat M L T k:ℝ)=coefficientEnvelope M L T k := by + induction k with + | zero => rfl + | succ k ih => simp only [envelopeNat,coefficientNat_cast,ih,coefficientEnvelope] + +private noncomputable def add {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x+g x) := Procedure.unaryAdd.comp (p.pair q) +private noncomputable def mul {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x*g x) := Procedure.unaryMul.comp (p.pair q) +private noncomputable def konst {α : Type} (ea : α → List Bool) (n : ℕ) : + Procedure ea unaryCode (fun _ => n) := Procedure.constant ea unaryCode n +private noncomputable def sq {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^2) := + (mul p p).congrFun (by intro x; simp only [pow_two]) +private noncomputable def cube {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea unaryCode f) : Procedure ea unaryCode (fun x => f x^3) := + (mul (mul p p) p).congrFun (by intro x; simp only [pow_succ,pow_zero,one_mul]) + +noncomputable def budgetNatProgram {α : Type} {ea : α → List Bool} {M L : α → ℕ} + (pm : Procedure ea unaryCode M) (pl : Procedure ea unaryCode L) : + Procedure ea unaryCode (fun x => budgetNat (M x) (L x)) := by + let c := konst ea + exact (add (add (add (add (mul (mul (c 3) pm) pl) pl) + (mul (mul (c 3) pm) (add (c 1) (mul (c 4) pl)))) + (mul (mul (c 12) pm) (sq (add (c 1) (mul (c 2) pl))))) (c 1)).congrFun + (by intro x; rfl) + +noncomputable def radiusNatProgram {α : Type} {ea : α → List Bool} {M L T : α → ℕ} + (pm : Procedure ea unaryCode M) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => radiusNat (M x) (L x) (T x)) := by + let c := konst ea + let pb := budgetNatProgram pm pl + exact (add (add (add pl (mul (mul (c 16) (cube pb)) pt)) (mul (c 4) pb)) (c 1)).congrFun + (by intro x; rfl) + +noncomputable def coefficientNatProgram {α : Type} {ea : α → List Bool} {M L T : α → ℕ} + (pm : Procedure ea unaryCode M) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => coefficientNat (M x) (L x) (T x)) := by + let c := konst ea + exact (add (add (c 1) pl) (mul (add (mul (c 10) pm) (c 2)) + (sq (radiusNatProgram pm pl pt)))).congrFun (by intro x; rfl) + +noncomputable def envelopeNatProgram (k : ℕ) {α : Type} {ea : α → List Bool} {M L T : α → ℕ} + (pm : Procedure ea unaryCode M) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) : + Procedure ea unaryCode (fun x => envelopeNat (M x) (L x) (T x) k) := by + induction k with + | zero => exact pl + | succ k ih => exact coefficientNatProgram pm ih pt + +theorem envelopeNat_power (k : ℕ) : ∃ a : ℕ, ∀ x : QuantumCoefficientPrograms.Input, + envelopeNat x.1 x.2.1 x.2.2 k ≤ ((QuantumCoefficientPrograms.inputCode x).length+2)^a := + unaryProcedure_power_bound (envelopeNatProgram k QuantumCoefficientPrograms.mProgram + QuantumCoefficientPrograms.lProgram QuantumCoefficientPrograms.tProgram) + +def outputCoefficientNat (m D L T : ℕ) : ℕ := + let M := (8*D+3)*m + envelopeNat M (coefficientNat M L T) T D + +@[simp] theorem outputCoefficientNat_cast (m D L T : ℕ) : + (outputCoefficientNat m D L T:ℝ)=outputCoefficient m D L T := by + simp only [outputCoefficientNat,envelopeNat_cast,coefficientNat_cast,outputCoefficient] + +noncomputable def outputCoefficientNatProgram (D : ℕ) : + Procedure QuantumCoefficientPrograms.inputCode unaryCode + (fun x => outputCoefficientNat x.1 D x.2.1 x.2.2) := by + let pm := mul (konst QuantumCoefficientPrograms.inputCode (8*D+3)) + QuantumCoefficientPrograms.mProgram + let pl := coefficientNatProgram pm QuantumCoefficientPrograms.lProgram QuantumCoefficientPrograms.tProgram + exact envelopeNatProgram D pm pl QuantumCoefficientPrograms.tProgram + +theorem outputCoefficientNat_power (D : ℕ) : ∃ a : ℕ, ∀ x : QuantumCoefficientPrograms.Input, + outputCoefficientNat x.1 D x.2.1 x.2.2 ≤ ((QuantumCoefficientPrograms.inputCode x).length+2)^a := + unaryProcedure_power_bound (outputCoefficientNatProgram D) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..af861217bccc5ccd2f66ce4834256ae2a7206b3e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCalibration.lean @@ -0,0 +1,50 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListSites +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListSum +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListBackground + +namespace OAI + +/-! The literal rational scale is exactly the scale appearing in the checked +parallel-fork theorem, including all retained odd-port coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open scoped BigOperators Classical + +theorem catalog_weights_sum (gs : Groups) (f : ℚ → ℚ → ℚ) : + (((catalog gs).map Prod.snd).map (fun p => f p.1.2 p.2.2)).sum = + ∑ e : Fin (pairCount gs), f (actualJ gs e) (actualK gs e) := by + rw [List.map_map] + change ((catalog gs).map (fun p => f p.2.1.2 p.2.2.2)).sum=_ + rw [← ExactQuantumFactoring.BitStackProgram.map_range_getD (catalog gs) + (0,((0,0),(0,0))) (fun p => f p.2.1.2 p.2.2.2),catalog_length,range_sum] + apply Finset.sum_congr rfl + intro e _ + have hc := catalog_pairEquiv gs (localPair gs e) + rw [show pairEquiv gs (localPair gs e)=e from (pairEquiv gs).apply_symm_apply e] at hc + rw [hc] + rfl + +theorem scale_eq_graphScale (s : State) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) : + scale N s = graphScale (backgroundGraph s hb hn).weight + (actualJ s.2.2.2) (actualK s.2.2.2) s.2.2.1 N := by + have hL : (((catalog s.2.2.2).map Prod.snd).map pairLinear).sum = + ∑ e, (1+2*|actualJ s.2.2.2 e|+2*|actualK s.2.2.2 e|) := + catalog_weights_sum s.2.2.2 (fun J K => 1+2*|J|+2*|K|) + have hS : (((catalog s.2.2.2).map Prod.snd).map pairSquare).sum = + ∑ e, (1+|actualJ s.2.2.2 e|+|actualK s.2.2.2 e|)^2 := + catalog_weights_sum s.2.2.2 (fun J K => (1+|J|+|K|)^2) + have hw : (∑ e : Fin (background s).length, |((background s).get e).2.2|) = + ((retained s).map abs).sum := background_sum s hb hn abs + change scale N s = graphScale (fun e : Fin (background s).length => ((background s).get e).2.2) + (actualJ s.2.2.2) (actualK s.2.2.2) s.2.2.1 N + dsimp only [scale,graphScale] + rw [hL,hS,hw] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellIteration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccdf2439be24c60906b78d2fd8fa4935cf3a92fd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellIteration.lean @@ -0,0 +1,85 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCellProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCellLocality +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListNext + +namespace OAI + +/-! The finite label array computed by each literal round represents the +geometric cell map at every emitted spin. Fixed-round iteration is polynomial. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +def RepresentsCells (s : State) (xs : List ℕ) (cell : ℕ → ℕ) : Prop := + ∀ v, v x + | k+1,x => cellStep N (cellIterate N k x) + +noncomputable def cellIterateProgram (N : ℚ) : + (k : ℕ) → Procedure cellInputCode cellInputCode (cellIterate N k) + | 0 => Procedure.identity cellInputCode + | k+1 => (cellStepProgram N).comp (cellIterateProgram N k) + +theorem cellIterate_state (N : ℚ) (k : ℕ) (x : CellInput) : + (cellIterate N k x).1=iterate N k x.1 := by + induction k with + | zero => rfl + | succ k ih => change next N (cellIterate N k x).1=next N (iterate N k x.1); rw [ih] + +theorem cellIterate_represents (N : ℚ) (k : ℕ) (x : CellInput) + (hs : ValidPorts x.1.1 x.1.2.2.2) (cell : ℕ → ℕ) + (h : RepresentsCells x.1 x.2 cell) : + RepresentsCells (iterate N k x.1) (cellIterate N k x).2 (iterateCell N k x.1 cell) := by + induction k with + | zero => exact h + | succ k ih => + have hi : ValidPorts (cellIterate N k x).1.1 (cellIterate N k x).1.2.2.2 := by + rw [cellIterate_state] + exact iterate_validPorts N x.1 hs k + have hr : RepresentsCells (cellIterate N k x).1 (cellIterate N k x).2 + (iterateCell N k x.1 cell) := by simpa only [cellIterate_state] using ih + have hn := next_representsCells N (cellIterate N k x) hi _ hr + simpa only [cellIterate_state,cellIterate,cellStep,iterate,iterateCell] using hn + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellLocality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..badd7b5905a8974c8c1caf0a068969a69b8899af --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellLocality.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCells + +namespace OAI + +/-! Every new ordinary bond remains within its original coarse cell. Old +ordinary bonds retain their cells, so arbitrary reflexive locality relations +are preserved by the actual list transformation. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped Classical + +def BondLocal {β : Type*} (bs : List Bond) (cell : ℕ → β) (R : β → β → Prop) : Prop := + ∀ b ∈ bs, R (cell b.1) (cell b.2.1) + +theorem addedBonds_cellLocal {β : Type*} (s : State) (hs : ValidPorts s.1 s.2.2.2) + (cell : ℕ → β) (ha : CellAligned s cell) (R : β → β → Prop) + (hr : ∀ x, R x x) (scale : ℚ) : BondLocal (addedBonds s scale) (nextCell s cell) R := by + intro b hb + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hb + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' : i + simpa only [hc,hf0,hf1] using hr (cell (actualSite hs e 0).val) + +theorem next_cellLocal {β : Type*} (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (cell : ℕ → β) (ha : CellAligned s cell) + (R : β → β → Prop) (hr : ∀ x, R x x) (hl : BondLocal s.2.1 cell R) : + BondLocal (next N s).2.1 (nextCell s cell) R := by + intro b hm + change b ∈ s.2.1++addedBonds s (scale N s) at hm + rcases List.mem_append.mp hm with ho | hn + · rw [nextCell_old s cell _ (hb b ho).1,nextCell_old s cell _ (hb b ho).2] + exact hl b ho + · exact addedBonds_cellLocal s hs cell ha R hr (scale N s) b hn + +def iterateCell {β : Type*} (N : ℚ) : ℕ → State → (ℕ → β) → ℕ → β + | 0,_,cell => cell + | k+1,s,cell => nextCell (iterate N k s) (iterateCell N k s cell) + +theorem iterate_cellAligned {β : Type*} (N : ℚ) (s : State) + (hs : ValidPorts s.1 s.2.2.2) (cell : ℕ → β) (ha : CellAligned s cell) (k : ℕ) : + CellAligned (iterate N k s) (iterateCell N k s cell) := by + induction k with + | zero => exact ha + | succ k ih => exact next_cellAligned N _ (iterate_validPorts N s hs k) _ ih + +theorem iterate_cellLocal {β : Type*} (N : ℚ) (s : State) + (hs : ValidPorts s.1 s.2.2.2) (hb : SourceBondLists.bounded s.1 s.2.1) + (cell : ℕ → β) (ha : CellAligned s cell) (R : β → β → Prop) + (hr : ∀ x, R x x) (hl : BondLocal s.2.1 cell R) (k : ℕ) : + BondLocal (iterate N k s).2.1 (iterateCell N k s cell) R := by + induction k with + | zero => exact hl + | succ k ih => + exact next_cellLocal N _ (iterate_validPorts N s hs k) + (iterate_ordinary_bounded N s hs hb k) _ (iterate_cellAligned N s hs cell ha k) R hr ih + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellMass.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c85d4b11f55e50bdd22ca94e327598779423f32 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellMass.lean @@ -0,0 +1,122 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCellLocality +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkCells + +namespace OAI + +/-! A literal fork round has bounded density in the original coarse cells. +The proof counts its actual fresh indices through the ordered pair catalog. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph +open scoped BigOperators Classical +variable {β : Type*} [DecidableEq β] + +theorem next_cell_mass (s : State) (hs : ValidPorts s.1 s.2.2.2) + (N : ℚ) (cell : ℕ → β) (p : β) : + qmaCellMass (fun v : Fin (next N s).1 => nextCell s cell v.val) p = + qmaCellMass (fun v : Fin s.1 => cell v.val) p+ + 2*∑ e : Fin (pairCount s.2.2.2), if cell (localPair s.2.2.2 e).1.val=p then 1 else 0 := by + unfold qmaCellMass + change (∑ v : Fin (s.1+2*pairCount s.2.2.2), if nextCell s cell v.val=p then 1 else 0)=_ + rw [show s.1+2*pairCount s.2.2.2=s.1+pairCount s.2.2.2*2 by omega] + rw [← (vertexEquiv s.1 (pairCount s.2.2.2)).sum_comp] + simp only [Fintype.sum_sum_type,Fintype.sum_prod_type,Fin.sum_univ_two] + have ho (v : Fin s.1) : + nextCell s cell (vertexEquiv s.1 (pairCount s.2.2.2) (Sum.inl v)).val=cell v.val := by + change nextCell s cell (old s.1 (pairCount s.2.2.2) v).val=cell v.val + simpa only [MediatorIteration.old_val] using nextCell_old s cell v.val v.isLt + have hf (e : Fin (pairCount s.2.2.2)) (b : Fin 2) : + nextCell s cell (vertexEquiv s.1 (pairCount s.2.2.2) (Sum.inr (e,b))).val= + cell (localPair s.2.2.2 e).1.val := by + change nextCell s cell (fresh s.1 (pairCount s.2.2.2) e b).val=_ + simpa only [MediatorIteration.fresh_val,Nat.mul_comm,actualSite,Matrix.cons_val_zero] using + nextCell_fresh s hs cell e b + simp_rw [ho,hf] + rw [Finset.sum_add_distrib] + omega + +theorem pair_cell_mass_le (s : State) (cell : ℕ → β) (D : ℕ) + (hd : ∀ i : Fin s.2.2.2.length, (groupAt s.2.2.2 i.val).length ≤ D) (p : β) : + (∑ e : Fin (pairCount s.2.2.2), if cell (localPair s.2.2.2 e).1.val=p then 1 else 0) ≤ + D*qmaCellMass (fun i : Fin s.2.2.2.length => cell i.val) p := by + have he := (pairEquiv s.2.2.2).symm.sum_comp + (fun q : LocalPair s.2.2.2 => if cell q.1.val=p then (1:ℕ) else 0) + change (∑ e : Fin (pairCount s.2.2.2), + (fun q : LocalPair s.2.2.2 => if cell q.1.val=p then (1:ℕ) else 0) + ((pairEquiv s.2.2.2).symm e)) ≤ _ + rw [he] + simp only [LocalPair,Fintype.sum_sigma,qmaCellMass,Finset.mul_sum] + apply Finset.sum_le_sum + intro i _ + by_cases hi : cell i.val=p + · simp only [hi,ite_true,Finset.sum_const,Finset.card_univ,Fintype.card_fin,smul_eq_mul,Nat.mul_one] + exact (Nat.div_le_self _ _).trans (hd i) + · simp [hi] + +theorem prefix_cell_mass_le (m n : ℕ) (h : m ≤ n) (cell : ℕ → β) (p : β) : + qmaCellMass (fun i : Fin m => cell i.val) p ≤ + qmaCellMass (fun i : Fin n => cell i.val) p := by + unfold qmaCellMass + change (∑ i : Fin m, if cell i.val=p then 1 else 0) ≤ + ∑ i : Fin n, if cell i.val=p then 1 else 0 + calc + _ = ∑ i ∈ Finset.range m, if cell i=p then 1 else 0 := + Fin.sum_univ_eq_sum_range (fun i => if cell i=p then 1 else 0) m + _ ≤ ∑ i ∈ Finset.range n, if cell i=p then 1 else 0 := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono h) (fun i _ _ => Nat.zero_le _) + _ = _ := (Fin.sum_univ_eq_sum_range (fun i => if cell i=p then 1 else 0) n).symm + +theorem next_cell_mass_le (s : State) (hs : ValidPorts s.1 s.2.2.2) + (N : ℚ) (cell : ℕ → β) (D : ℕ) + (hd : ∀ i : Fin s.2.2.2.length, (groupAt s.2.2.2 i.val).length ≤ D) (p : β) : + qmaCellMass (fun v : Fin (next N s).1 => nextCell s cell v.val) p ≤ + (1+2*D)*qmaCellMass (fun v : Fin s.1 => cell v.val) p := by + rw [next_cell_mass s hs N cell p] + have hp := pair_cell_mass_le s cell D hd p + have hc := prefix_cell_mass_le s.2.2.2.length s.1 hs.centers cell p + calc + _ ≤ qmaCellMass (fun v : Fin s.1 => cell v.val) p+ + 2*(D*qmaCellMass (fun i : Fin s.2.2.2.length => cell i.val) p) := by omega + _ ≤ qmaCellMass (fun v : Fin s.1 => cell v.val) p+ + 2*(D*qmaCellMass (fun i : Fin s.1 => cell i.val) p) := by gcongr + _ = _ := by ring + +theorem iterate_group_le (s : State) (N : ℚ) (k i : ℕ) (hi : i exact le_rfl + | succ k ih => + rw [iterate,next_group_length N (iterate N k s) i (by rwa [iterate_centers])] + omega + +theorem iterate_cell_mass_le (s : State) (hs : ValidPorts s.1 s.2.2.2) + (N : ℚ) (cell : ℕ → β) (D : ℕ) + (hd : ∀ i : Fin s.2.2.2.length, (groupAt s.2.2.2 i.val).length ≤ D) + (k : ℕ) (p : β) : + qmaCellMass (fun v : Fin (iterate N k s).1 => iterateCell N k s cell v.val) p ≤ + (1+2*D)^k*qmaCellMass (fun v : Fin s.1 => cell v.val) p := by + induction k with + | zero => simp only [iterate,iterateCell,pow_zero,one_mul,le_refl] + | succ k ih => + have hd' : ∀ i : Fin (iterate N k s).2.2.2.length, + (groupAt (iterate N k s).2.2.2 i.val).length ≤ D := by + intro i + have hi : i.val + nextCell (iterate N k s) (iterateCell N k s cell) v.val) p ≤ _ + calc + _ ≤ (1+2*D)*qmaCellMass (fun v : Fin (iterate N k s).1 => + iterateCell N k s cell v.val) p := hn + _ ≤ (1+2*D)*((1+2*D)^k*qmaCellMass (fun v : Fin s.1 => cell v.val) p) := + Nat.mul_le_mul_left _ ih + _ = _ := by ring + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..bafb8f600497d6ae8589595b3713d1335cedcd23 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCellProgram.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListScale + +namespace OAI + +/-! The coarse-cell labels are emitted by literal polynomial finite-list +programs, using the same ordered pair catalog as the physical fork compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +abbrev CellInput := State × List ℕ +def cellInputCode : CellInput → List Bool := prodCode stateCode (listCode Nat.bits) +def cellQueryCode : (ℕ × CellInput) → List Bool := prodCode Nat.bits cellInputCode + +def cellAt (xs : List ℕ) (i : ℕ) : ℕ := (xs.drop i).headD 0 + +noncomputable def nextCellProgram : Procedure cellQueryCode Nat.bits + (fun x => nextCell x.2.1 (cellAt x.2.2) x.1) := by + let v := Procedure.first Nat.bits cellInputCode + let env := Procedure.second Nat.bits cellInputCode + let s := (Procedure.first stateCode (listCode Nat.bits)).comp env + let xs := (Procedure.second stateCode (listCode Nat.bits)).comp env + let n := Procedure.unaryToBits.comp (countProgram.comp s) + let before := Procedure.binaryLt.comp (v.pair n) + let pair := Procedure.binaryDiv.comp + ((Procedure.binarySub.comp (v.pair n)).pair (Procedure.constant cellQueryCode Nat.bits 2)) + let ps := catalogProgram.comp (groupsProgram.comp s) + let center := (Procedure.first Nat.bits pairCode).comp + ((Procedure.listGet taggedCode (0,((0,0),(0,0)))).comp (pair.pair ps)) + let target := Procedure.conditional before v center + exact ((Procedure.listGet Nat.bits 0).comp (target.pair xs)).congrFun (by + intro x + change cellAt x.2.2 (if decide (x.1 simp [h]) + +def nextCells (x : CellInput) : List ℕ := + (List.range (x.1.1+2*pairCount x.1.2.2.2)).map (nextCell x.1 (cellAt x.2)) + +noncomputable def nextCellsProgram : Procedure cellInputCode (listCode Nat.bits) nextCells := by + let s := Procedure.first stateCode (listCode Nat.bits) + let n := countProgram.comp s + let pairs := pairCountProgram.comp (groupsProgram.comp s) + let count := Procedure.unaryAdd.comp (n.pair (Procedure.unaryAdd.comp (pairs.pair pairs))) + let query : Procedure (prodCode unaryCode cellInputCode) cellQueryCode + (fun x => (x.1,x.2)) := + (Procedure.unaryToBits.comp (Procedure.first unaryCode cellInputCode)).pair + (Procedure.second unaryCode cellInputCode) + let entry := nextCellProgram.comp query + exact ((Procedure.tabulate (f := fun x i => nextCell x.1 (cellAt x.2) i) 0 entry).comp + (count.pair (Procedure.identity cellInputCode))).congrFun (by + intro x + change (List.range (x.1.1+(pairCount x.1.2.2.2+pairCount x.1.2.2.2))).map _=nextCells x + simp only [nextCells,two_mul,id_eq]) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..741c7b78885d264fccf0672501c7e077f7476765 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListCells.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListFinalDegree + +namespace OAI + +/-! Coarse-cell labels for the actual ordered fork output. Both members of a +fresh mediator pair stay in their actual active center's cell. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open scoped Classical + +def CellAligned {β : Type*} (s : State) (cell : ℕ → β) : Prop := + ∀ (i : Fin s.2.2.2.length) (j : Fin (groupAt s.2.2.2 i.val).length), + cell (portAt (groupAt s.2.2.2 i.val) j.val).1=cell i.val + +def nextCell {β : Type*} (s : State) (cell : ℕ → β) (v : ℕ) : β := + if v (portAt ps (2*i),portAt ps (2*i+1))) + +def unpaired (ps : List Port) : List Port := ps.drop (2*(ps.length/2)) + +def catalog (gs : Groups) : List TaggedPair := + ((List.range gs.length).map (fun i => (pairs (groupAt gs i)).map (fun p => (i,p)))).flatten + +def pairCount (gs : Groups) : ℕ := (gs.map (fun ps => ps.length/2)).sum +def pairStart (gs : Groups) (i : ℕ) : ℕ := pairCount (gs.take i) + +def pairLinear (p : Pair) : ℚ := 1+2*|p.1.2|+2*|p.2.2| +def pairSquare (p : Pair) : ℚ := (1+|p.1.2|+|p.2.2|)^2 +def pairOffset (p : Pair) : ℚ := 3/4+3*p.1.2^2+3*p.2.2^2 + +def retained (s : State) : List ℚ := + s.2.1.map (fun b => b.2.2) ++ ((s.2.2.2.map unpaired).flatten.map Prod.snd) + +def scale (N : ℚ) (s : State) : ℚ := + let ps := (catalog s.2.2.2).map Prod.snd + let B := 3*(retained s |>.map abs).sum+|s.2.2.1| + let A := 3*(ps.map pairLinear).sum + let D := B+12*(ps.map pairSquare).sum + 16*(A+D+1)^3*N+4*(A+D+1)+1 + +def pairBonds (n i : ℕ) (R : ℚ) (p : Pair) : List Bond := + [(p.1.1,p.2.1,2*p.1.2*p.2.2), + (n+2*i,n+2*i+1,R^2), + (p.1.1,n+2*i+1,2*R*p.1.2), + (p.2.1,n+2*i+1,2*R*p.2.2)] + +def addedBonds (s : State) (R : ℚ) : List Bond := + let ps := catalog s.2.2.2 + ((List.range ps.length).map (fun i => pairBonds s.1 i R + ((ps.drop i).headD (0,((0,0),(0,0)))).2)).flatten + +def nextGroup (n : ℕ) (R : ℚ) (gs : Groups) (i : ℕ) : List Port := + let ps := groupAt gs i + (List.range (ps.length/2)).map (fun j => (n+2*(pairStart gs i+j),R)) ++ unpaired ps + +def next (N : ℚ) (s : State) : State := + let R := scale N s + let ps := (catalog s.2.2.2).map Prod.snd + (s.1+2*pairCount s.2.2.2, + s.2.1++addedBonds s R, + s.2.2.1+(ps.map pairOffset).sum+3*(pairCount s.2.2.2:ℚ)*R^2, + (List.range s.2.2.2.length).map (nextGroup s.1 R s.2.2.2)) + +def iterate (N : ℚ) : ℕ → State → State + | 0,s => s + | k+1,s => next N (iterate N k s) + +theorem pairs_length (ps : List Port) : (pairs ps).length=ps.length/2 := by + simp [pairs] + +theorem unpaired_length (ps : List Port) : (unpaired ps).length=ps.length%2 := by + simp only [unpaired,List.length_drop] + omega + +theorem unpaired_length_le (ps : List Port) : (unpaired ps).length ≤ 1 := by + rw [unpaired_length] + omega + +theorem pairCount_cons (ps : List Port) (gs : Groups) : + pairCount (ps::gs)=ps.length/2+pairCount gs := rfl + +theorem groupAt_cons_zero (ps : List Port) (gs : Groups) : groupAt (ps::gs) 0=ps := rfl + +theorem groupAt_cons_succ (ps : List Port) (gs : Groups) (i : ℕ) : + groupAt (ps::gs) (i+1)=groupAt gs i := by + simp [groupAt,List.drop_succ_cons] + +theorem catalog_length (gs : Groups) : (catalog gs).length=pairCount gs := by + unfold catalog + rw [List.length_flatten,List.map_map] + simp only [Function.comp_def,List.length_map,pairs_length] + change ((List.range gs.length).map (fun i => ((gs.drop i).headD []).length/2)).sum = _ + rw [ExactQuantumFactoring.BitStackProgram.map_range_getD gs [] (fun ps => ps.length/2)] + rfl + +theorem pairBonds_length (n i : ℕ) (R : ℚ) (p : Pair) : + (pairBonds n i R p).length=4 := rfl + +theorem nextGroup_length (n : ℕ) (R : ℚ) (gs : Groups) (i : ℕ) : + (nextGroup n R gs i).length=(groupAt gs i).length/2+(groupAt gs i).length%2 := by + simp [nextGroup,unpaired_length] + +theorem next_centers (N : ℚ) (s : State) : (next N s).2.2.2.length=s.2.2.2.length := by + simp [next] + +theorem next_count (N : ℚ) (s : State) : (next N s).1=s.1+2*pairCount s.2.2.2 := rfl + +theorem iterate_centers (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).2.2.2.length=s.2.2.2.length := by + induction k with + | zero => rfl + | succ k ih => exact (next_centers N (iterate N k s)).trans ih + +theorem next_group_length (N : ℚ) (s : State) (i : ℕ) (hi : i < s.2.2.2.length) : + (groupAt (next N s).2.2.2 i).length= + (groupAt s.2.2.2 i).length/2+(groupAt s.2.2.2 i).length%2 := by + change (groupAt ((List.range s.2.2.2.length).map + (nextGroup s.1 (scale N s) s.2.2.2)) i).length=_ + rw [groupAt,List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem (by simpa using hi)] + simp only [Option.getD_some,List.getElem_map,List.getElem_range,nextGroup_length] + +theorem iterate_group_length (N : ℚ) (s : State) (k i : ℕ) (hi : i < s.2.2.2.length) : + (groupAt (iterate N k s).2.2.2 i).length= + qmaForkDegreeAfter (groupAt s.2.2.2 i).length k := by + induction k with + | zero => rfl + | succ k ih => + rw [iterate,next_group_length N (iterate N k s) i (by rwa [iterate_centers]),ih] + rfl + +theorem addedBonds_length (s : State) (R : ℚ) : + (addedBonds s R).length=4*pairCount s.2.2.2 := by + unfold addedBonds + rw [List.length_flatten,List.map_map] + simp only [Function.comp_def,pairBonds_length,List.map_const',List.length_range, + List.sum_replicate,smul_eq_mul,catalog_length] + omega + +theorem next_bonds_length (N : ℚ) (s : State) : + (next N s).2.1.length=s.2.1.length+4*pairCount s.2.2.2 := by + change (s.2.1++addedBonds s (scale N s)).length=_ + rw [List.length_append,addedBonds_length] + +theorem iterate_group_bound (N : ℚ) (s : State) (D i : ℕ) + (hi : i < s.2.2.2.length) (hD : (groupAt s.2.2.2 i).length ≤ D) : + (groupAt (iterate N D s).2.2.2 i).length ≤ 1 := by + rw [iterate_group_length N s D i hi] + exact qmaForkDegreeAfter_constant _ D hD + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..14c2091af5098a7792d5bdadf9027ac05cc8f52c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegree.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkBackground + +namespace OAI + +/-! Incidence counts for the literal ordinary-bond list. The four newly emitted +bonds have exactly the graph used by the physical fork degree estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph MediatorListProgram +open scoped BigOperators Classical + +def incident (v a b : ℕ) : ℕ := if a=v ∨ b=v then 1 else 0 + +def degree (bs : List Bond) (v : ℕ) : ℕ := + (bs.map (fun b => incident v b.1 b.2.1)).sum + +theorem graph_degree_incident {ν : Type*} [Fintype ν] {n : ℕ} + (left right : ν → Fin n) (v : Fin n) : + qmaGraphDegree left right v=∑ e, incident v.val (left e).val (right e).val := by + unfold qmaGraphDegree + apply Finset.sum_congr rfl + intro e _ + simp only [incident,Fin.ext_iff] + +theorem degree_append (bs cs : List Bond) (v : ℕ) : + degree (bs++cs) v=degree bs v+degree cs v := by + simp only [degree,List.map_append,List.sum_append] + +theorem degree_eq_graph (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (v : Fin n) : + degree bs v.val=qmaGraphDegree (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right v := by + unfold degree + rw [initial_list_sum] + rw [graph_degree_incident] + rfl + +theorem added_sum {M : Type*} [AddCommMonoid M] (s : State) + (hs : ValidPorts s.1 s.2.2.2) (R : ℚ) (f : Bond → M) : + ((addedBonds s R).map f).sum = ∑ e : Fin (pairCount s.2.2.2), + (f ((actualSite hs e 1).val,(actualSite hs e 2).val, + 2*actualJ s.2.2.2 e*actualK s.2.2.2 e)+ + f (s.1+2*e.val,s.1+2*e.val+1,R^2)+ + f ((actualSite hs e 1).val,s.1+2*e.val+1,2*R*actualJ s.2.2.2 e)+ + f ((actualSite hs e 2).val,s.1+2*e.val+1,2*R*actualK s.2.2.2 e)) := by + simp only [addedBonds,List.map_flatten,List.sum_flatten,List.map_map,Function.comp_def, + catalog_length,range_sum] + apply Finset.sum_congr rfl + intro e _ + rw [catalog_actualSite hs e] + simp only [pairBonds,List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero] + ac_rfl + +theorem next_ordinary_degree (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) + (v : Fin (s.1+pairCount s.2.2.2*2)) : + degree (next N s).2.1 v.val = + qmaGraphDegree + (qmaForkBackgroundLeft (SourceBondLists.bonds s.1 s.2.1 hb).left (actualSite hs)) + (qmaForkBackgroundRight (SourceBondLists.bonds s.1 s.2.1 hb).right (actualSite hs)) v := by + change degree (s.2.1++addedBonds s (scale N s)) v.val=_ + rw [degree_append] + unfold degree + rw [initial_list_sum,added_sum s hs] + rw [graph_degree_incident] + simp only [qmaForkBackgroundLeft,qmaForkBackgroundRight, + Fintype.sum_sum_type,Fintype.sum_prod_type,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaForksBaseLeft,qmaForksBaseRight,Sum.elim_inl,Sum.elim_inr, + qmaForkOuter,Fin.sum_univ_two,ite_true,show (1:Fin 2) ≠ 0 by decide,ite_false, + SourceBondLists.bonds,MediatorIteration.old_val,MediatorIteration.fresh_val, + Fin.val_zero,Fin.val_one,Nat.add_zero,Finset.sum_add_distrib] + simp only [Nat.mul_comm] + omega + +structure DegreeBounds (s : State) : Prop where + ordinary : ∀ v : Fin s.1, degree s.2.1 v.val ≤ 3 + center : ∀ i, i < s.2.2.2.length → degree s.2.1 i=0 + port : ∀ (i : Fin s.2.2.2.length) (j : Fin (groupAt s.2.2.2 i.val).length), + degree s.2.1 (portAt (groupAt s.2.2.2 i.val) j.val).1 ≤ 1 + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegreeIteration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegreeIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..b626aace4faebcfb9d796136d1cdccb2d9472f6c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListDegreeIteration.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListNextDegree +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialDegree + +namespace OAI + +/-! Persistent degree bounds along the actual list iteration. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram + +theorem next_ordinary_bounded (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) : + SourceBondLists.bounded (next N s).1 (next N s).2.1 := by + intro b hm + change b ∈ s.2.1++addedBonds s (scale N s) at hm + rcases List.mem_append.mp hm with ho | ha + · have h := hb b ho + change b.1 exact hb + | succ k ih => exact next_ordinary_bounded N _ (iterate_validPorts N s hs k) ih + +theorem iterate_degreeBounds (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hd : DegreeBounds s) (k : ℕ) : + DegreeBounds (iterate N k s) := by + induction k with + | zero => exact hd + | succ k ih => + exact next_degreeBounds N _ (iterate_validPorts N s hs k) + (iterate_ordinary_bounded N s hs hb k) ih + +theorem initial_ordinary_bounded (n : ℕ) (bs : List Bond) (c N : ℚ) : + SourceBondLists.bounded (initial n bs c N).1 (initial n bs c N).2.1 := by + intro b hb + obtain ⟨e,he,rfl⟩ := List.mem_map.mp hb + have he' := List.mem_range.mp he + change n+2*e omega + +theorem initial_iterate_degreeBounds (n : ℕ) (bs : List Bond) (c N : ℚ) (k : ℕ) : + DegreeBounds (iterate N k (initial n bs c N)) := + iterate_degreeBounds N _ (initial_validPorts n bs c N) + (initial_ordinary_bounded n bs c N) (initial_degreeBounds n bs c N) k + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListEnvelope.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfb59983a158be461bc00f8dbdb0a4bc76b19dee --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListEnvelope.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListGraph + +namespace OAI + +/-! Polynomial coefficient envelopes for the parallel fork used by the literal +compiler. Both retained bonds and active pairs fit the same size bound. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open scoped BigOperators Classical + +def forkBudget (M L : ℝ) : ℝ := + 3*M*L+L+3*M*(1+4*L)+12*M*(1+2*L)^2+1 + +def forkRadius (M L T : ℝ) : ℝ := + L+16*(forkBudget M L)^3*T+4*forkBudget M L+1 + +def forkCoefficient (M L T : ℝ) : ℝ := + 1+L+(10*M+2)*(forkRadius M L T)^2 + +theorem graphScale_abs_bound {m r : ℕ} (w : Fin m → ℚ) (J K : Fin r → ℚ) + (c N : ℚ) (hN : 0 ≤ N) {M L T : ℝ} (hm : (m:ℝ) ≤ M) (hr : (r:ℝ) ≤ M) + (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) (hc : |(c:ℝ)| ≤ L) + (hw : ∀ e, |(w e:ℝ)| ≤ L) (hJ : ∀ e, |(J e:ℝ)| ≤ L) + (hK : ∀ e, |(K e:ℝ)| ≤ L) : + |(graphScale w J K c N:ℝ)| ≤ forkRadius M L T := by + have hM : 0 ≤ M := (Nat.cast_nonneg m).trans hm + have hL0 : 0 ≤ L := by linarith + have hn0 : 0 ≤ (N:ℝ) := by exact_mod_cast hN + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hret : (∑ e, |(w e:ℝ)|) ≤ M*L := by + calc + _ ≤ ∑ _e : Fin m, L := Finset.sum_le_sum (fun e _ => hw e) + _ = (m:ℝ)*L := by simp + _ ≤ M*L := mul_le_mul_of_nonneg_right hm hL0 + have hlin : (∑ e, (1+2*|(J e:ℝ)|+2*|(K e:ℝ)|)) ≤ M*(1+4*L) := by + calc + _ ≤ ∑ _e : Fin r, (1+4*L) := Finset.sum_le_sum (fun e _ => by linarith [hJ e,hK e]) + _ = (r:ℝ)*(1+4*L) := by simp [mul_add] + _ ≤ M*(1+4*L) := mul_le_mul_of_nonneg_right hr (by positivity) + have hsq : (∑ e, (1+|(J e:ℝ)|+|(K e:ℝ)|)^2) ≤ M*(1+2*L)^2 := by + calc + _ ≤ ∑ _e : Fin r, (1+2*L)^2 := Finset.sum_le_sum (fun e _ => + pow_le_pow_left₀ (by positivity) (by linarith [hJ e,hK e]) 2) + _ = (r:ℝ)*(1+2*L)^2 := by simp + _ ≤ M*(1+2*L)^2 := mul_le_mul_of_nonneg_right hr (sq_nonneg _) + let A : ℝ := 3*∑ e, (1+2*|(J e:ℝ)|+2*|(K e:ℝ)|) + let D : ℝ := 3*(∑ e, |(w e:ℝ)|)+|(c:ℝ)|+12*∑ e, (1+|(J e:ℝ)|+|(K e:ℝ)|)^2 + have hAD0 : 0 ≤ A+D+1 := by dsimp [A,D]; positivity + have hAD : A+D+1 ≤ forkBudget M L := by dsimp [A,D,forkBudget]; linarith + have hcube := pow_le_pow_left₀ hAD0 hAD 3 + rw [graphScale_cast] + change |16*(A+D+1)^3*(N:ℝ)+4*(A+D+1)+1| ≤ _ + rw [abs_of_nonneg (by positivity)] + have hnT : (N:ℝ) ≤ T := by simpa only [abs_of_nonneg hn0] using hT + have hprod := mul_le_mul hcube hnT hn0 (pow_nonneg (hAD0.trans hAD) 3) + dsimp only [forkRadius] + nlinarith + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFinalDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFinalDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..cde515f44861ebb7fcf57ef4b1dccdd2d5fcfc8a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFinalDegree.lean @@ -0,0 +1,99 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListFullDegree + +namespace OAI + +/-! Bounded initial star lengths suffice for degree three after a fixed number +of literal fork rounds. This statement concerns the actual emitted bond list. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem next_ordinary_noLoops (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) : + ∀ b ∈ (next N s).2.1, b.1 ≠ b.2.1 := by + intro b hm + change b ∈ s.2.1++addedBonds s (scale N s) at hm + rcases List.mem_append.mp hm with ho | ha + · exact hn b ho + · exact (addedBonds_valid s hs (scale N s) b ha).2.2 + +theorem iterate_ordinary_noLoops (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) (k : ℕ) : + ∀ b ∈ (iterate N k s).2.1, b.1 ≠ b.2.1 := by + induction k with + | zero => exact hn + | succ k ih => exact next_ordinary_noLoops N _ (iterate_validPorts N s hs k) ih + +theorem iterate_full_degree_le_three (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) (hd : DegreeBounds s) + (D : ℕ) (hD : ∀ i : Fin s.2.2.2.length, (groupAt s.2.2.2 i.val).length ≤ D) + (v : Fin (iterate N D s).1) : + degree ((iterate N D s).2.1++activeBonds (iterate N D s).2.2.2) v.val ≤ 3 := by + apply full_degree_le_three _ (iterate_validPorts N s hs D) + (iterate_ordinary_bounded N s hs hb D) (iterate_ordinary_noLoops N s hs hn D) + (iterate_degreeBounds N s hs hb hd D) _ v + intro i + have hi : i.val (1:ℕ))).sum=xs.length := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [List.map_cons,List.sum_cons,List.length_cons,ih] + omega + rw [← hone (initialIndices bs i),initialIndices_sum,initial_evenodd_sum] + simp only [initialEndpoint_even,initialEndpoint_odd] + unfold degree + rw [initial_list_sum] + unfold incident + apply Finset.sum_congr rfl + intro e _ + have he := hn (bs.get e) (List.get_mem bs e) + simp only [List.get_eq_getElem] at he ⊢ + split_ifs <;> omega + +theorem initial_iterate_full_degree_of_bound (n : ℕ) (bs : List Bond) + (hn : ∀ b ∈ bs, b.1 ≠ b.2.1) (c N : ℚ) (D : ℕ) + (hD : ∀ i : Fin n, degree bs i.val ≤ D) + (v : Fin (iterate N D (initial n bs c N)).1) : + degree ((iterate N D (initial n bs c N)).2.1++ + activeBonds (iterate N D (initial n bs c N)).2.2.2) v.val ≤ 3 := by + apply initial_iterate_full_degree_le_three n bs c N D _ v + intro i + rw [initialIndices_length_eq_degree bs hn] + exact hD i + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFullCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFullCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..477c534a1eb037a6e982152dbd66978565b56bd0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListFullCells.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCellMass + +namespace OAI + +/-! The full emitted bond list, including active ports, keeps the original +common-cell locality relation through initial subdivision and all fork rounds. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped Classical + +theorem activeBonds_mem {gs : Groups} {b : Bond} (hb : b ∈ activeBonds gs) : + ∃ (i : Fin gs.length) (j : Fin (groupAt gs i.val).length), + b=(i.val,(portAt (groupAt gs i.val) j.val).1, + (portAt (groupAt gs i.val) j.val).2) := by + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hb + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + obtain ⟨p,hp,rfl⟩ := List.mem_map.mp hb + obtain ⟨j,hj⟩ := List.get_of_mem hp + refine ⟨⟨i,List.mem_range.mp hi⟩,j,?_⟩ + have he : portAt (groupAt gs i) j.val=p := by + rw [portAt_eq_getElem _ _ j.isLt] + exact hj + rw [he] + +theorem activeBonds_valid {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (b : Bond) (hb : b ∈ activeBonds gs) : + b.1 (groupAt gs i.val).length) he.1)).2 he.2 + +def asForkPorts {n : ℕ} {gs : Groups} (h : ValidPorts n gs) : + QMAForkPorts n gs.length (fun i => (groupAt gs i.val).length) where + center i := ⟨i.val,lt_of_lt_of_le i.isLt h.centers⟩ + port := portSite h + center_injective := by + intro i j he + exact Fin.ext (congrArg (fun v : Fin n => v.val) he) + port_injective := portSite_injective h + center_ne_port := fun i p he => h.disjoint i p.1 p.2 (congrArg Fin.val he) + +def asForkState (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) (hd : DegreeBounds s) : + QMAForkState s.1 s.2.2.2.length (fun i => (groupAt s.2.2.2 i.val).length) + (Fin s.2.1.length) where + ports := asForkPorts hs + left := (SourceBondLists.bonds s.1 s.2.1 hb).left + right := (SourceBondLists.bonds s.1 s.2.1 hb).right + distinct e := fun he => hn (s.2.1.get e) (List.get_mem _ e) (congrArg Fin.val he) + degree_le := fun v => (degree_eq_graph s.1 s.2.1 hb v) ▸ hd.ordinary v + center_degree := by + intro i + rw [← degree_eq_graph] + exact hd.center i.val i.isLt + port_degree := by + intro p + rw [← degree_eq_graph] + exact hd.port p.1 p.2 + +theorem active_index_sum {M : Type*} [AddCommMonoid M] (gs : Groups) (f : Bond → M) : + ((activeBonds gs).map f).sum = + ∑ p : PortIndex gs, f (p.1.val,(portAt (groupAt gs p.1.val) p.2.val).1, + (portAt (groupAt gs p.1.val) p.2.val).2) := by + simp only [activeBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def,range_sum,PortIndex,Fintype.sum_sigma] + apply Finset.sum_congr rfl + intro i _ + have hp (j : Fin (groupAt gs i.val).length) : + portAt (groupAt gs i.val) j.val=(groupAt gs i.val).get j := by + simpa only [List.get_eq_getElem] using portAt_eq_getElem _ _ j.isLt + simp only [hp] + rw [← List.sum_ofFn] + simpa only [List.get_eq_getElem] using congrArg List.sum + (List.ofFn_getElem_eq_map (groupAt gs i.val) (fun p => f (i.val,p.1,p.2))).symm + +theorem full_degree_eq (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) (hd : DegreeBounds s) (v : Fin s.1) : + degree (s.2.1++activeBonds s.2.2.2) v.val = + qmaGraphDegree (asForkState s hs hb hn hd).fullLeft + (asForkState s hs hb hn hd).fullRight v := by + rw [degree_append] + rw [graph_degree_incident] + simp only [degree,active_index_sum,QMAForkState.fullLeft,QMAForkState.fullRight,Fintype.sum_sum_type,Sum.elim_inl,Sum.elim_inr, + asForkState,asForkPorts,portSite,SourceBondLists.bonds] + rw [initial_list_sum] + +theorem full_degree_le_three (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1 ≠ b.2.1) (hd : DegreeBounds s) + (hl : ∀ i : Fin s.2.2.2.length, (groupAt s.2.2.2 i.val).length ≤ 3) (v : Fin s.1) : + degree (s.2.1++activeBonds s.2.2.2) v.val ≤ 3 := by + rw [full_degree_eq s hs hb hn hd] + exact (asForkState s hs hb hn hd).full_degree_le_three hl v + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..547e5ee5a6dfd1041bc4ca9803851519ebf5a252 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListGraph.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListMatrix + +namespace OAI + +/-! The finite bond packet emitted for parallel forks has the exact full-space +Hamiltonian used in the calibrated perturbation estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample +open scoped BigOperators Classical + +def packetBonds {n r : ℕ} (e : Fin r) (site : Fin 3 → Fin n) (J K R : ℚ) : + List MediatorListProgram.Bond := + pairBonds n e.val R ((site 1 |>.val,J),(site 2 |>.val,K)) ++ + [((site 0).val,n+2*e.val,R)] + +theorem packetBonds_matrix {n r : ℕ} (e : Fin r) (site : Fin 3 → Fin n) (J K R : ℚ) : + ((packetBonds e site J K R).map (rawBondMatrix (n+r*2))).sum = + ((2*J*K:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r (site 1)) (old n r (site 2)) + + (((R^2:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (fresh n r e 0) (fresh n r e 1) + + (((2*R*J:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r (site 1)) (fresh n r e 1) + + ((2*R*K:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r (site 2)) (fresh n r e 1))) + + (R:ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r (site 0)) (fresh n r e 0) := by + have h : ((site 0).val,n+2*e.val,R) = + erase (old n r (site 0),fresh n r e 0,R) := by + simp [erase,MediatorIteration.old_val,MediatorIteration.fresh_val] + simp only [packetBonds,List.map_append,List.sum_append,pairBonds_matrix, + List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero,h, + rawBondMatrix_erase,typedBondMatrix] + +def graphBonds {n r m : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 3 → Fin n) (J K : Fin r → ℚ) (R : ℚ) : + List MediatorListProgram.Bond := + List.ofFn (fun a => erase (old n r (left a),old n r (right a),w a)) ++ + (List.ofFn (fun e => packetBonds e (site e) (J e) (K e) R)).flatten + +def graphConstant {r : ℕ} (c R : ℚ) (J K : Fin r → ℚ) : ℚ := + (c+∑ e, (3/4+3*(J e)^2+3*(K e)^2))+3*r*R^2 + +theorem graph_matrix {n r m : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 3 → Fin n) (J K : Fin r → ℚ) (c R : ℚ) : + rawMatrix (n+r*2) (graphBonds left right w site J K R,graphConstant c R J K) = + qmaForksGraph left right (fun a => (w a:ℝ)) (c:ℝ) (R:ℝ) site + (fun e => (J e:ℝ)) (fun e => (K e:ℝ)) := by + simp only [rawMatrix,← Rat.cast_smul_eq_qsmul ℂ,graphBonds,List.map_append,List.sum_append,List.map_ofFn, + List.sum_ofFn,List.map_flatten,List.sum_flatten,Function.comp_def, + rawBondMatrix_erase,typedBondMatrix,packetBonds_matrix] + simp only [qmaForksGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + Fin.sum_univ_three,qmaParallelGraphLeft,qmaParallelGraphRight, + qmaParallelGraphWeight,qmaForksBaseLeft,qmaForksBaseRight,qmaForksBaseWeight, + Sum.elim_inl,Sum.elim_inr,qmaForkAmplitude,qmaForkMember,qmaForkOffset, + graphConstant] + push_cast + simp only [Finset.sum_add_distrib] + abel + +def graphScale {r m : ℕ} (w : Fin m → ℚ) (J K : Fin r → ℚ) (c N : ℚ) : ℚ := + let B := 3*(∑ a, |w a|)+|c| + let A := 3*∑ e, (1+2*|J e|+2*|K e|) + let D := B+12*∑ e, (1+|J e|+|K e|)^2 + 16*(A+D+1)^3*N+4*(A+D+1)+1 + +theorem graphScale_cast {r m : ℕ} (w : Fin m → ℚ) (J K : Fin r → ℚ) (c N : ℚ) : + (graphScale w J K c N : ℝ) = + qmaRoutingScale (3*∑ e, (1+2*|(J e:ℝ)|+2*|(K e:ℝ)|)) + (3*(∑ a, |(w a:ℝ)|)+|(c:ℝ)|+ + 12*∑ e, (1+|(J e:ℝ)|+|(K e:ℝ)|)^2) (N:ℝ) := by + unfold graphScale qmaRoutingScale + push_cast + rfl + +theorem graph_accuracy {n r m : ℕ} (left right : Fin m → Fin n) + (hneq : ∀ a, left a ≠ right a) (w : Fin m → ℚ) + (site : Fin r → Fin 3 → Fin n) (hsite : ∀ e, Function.Injective (site e)) + (J K : Fin r → ℚ) (c N : ℚ) (hN : 0 < N) : + let R := graphScale w J K c N + |sourceMatrixBottom (n+r*2) + (rawMatrix (n+r*2) (graphBonds left right w site J K R,graphConstant c R J K)) - + sourceMatrixBottom n (qmaExchangeMatrix left right (fun a => (w a:ℝ)) (c:ℝ) + + ∑ e, ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 1) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2)))| ≤ 1/(N:ℝ) := by + dsimp only + rw [graph_matrix,graphScale_cast] + have hJ : ∀ e, ((J e:ℝ):ℂ)=(J e:ℂ) := by intro e; norm_cast + have hK : ∀ e, ((K e:ℝ):ℂ)=(K e:ℂ) := by intro e; norm_cast + have h := qmaForksGraph_accuracy left right hneq (fun a => (w a:ℝ)) (c:ℝ) + site hsite (fun e => (J e:ℝ)) (fun e => (K e:ℝ)) (show (0:ℝ) < N by exact_mod_cast hN) + dsimp only at h + simpa only [hJ,hK] using h + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIndex.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccf18f74cd0e9c6411453f2e324c44ce2287310b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIndex.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListPartition + +namespace OAI + +/-! The compiler's prefix sums enumerate precisely the actual pairs. The +result fixes which two fresh spins belong to each center and local pair. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList + +theorem pairStart_zero (gs : Groups) : pairStart gs 0=0 := rfl + +theorem pairStart_cons_succ (ps : List Port) (gs : Groups) (i : ℕ) : + pairStart (ps::gs) (i+1)=ps.length/2+pairStart gs i := by + simp only [pairStart,List.take_succ_cons,pairCount_cons] + +theorem pairStart_bound (gs : Groups) (i : ℕ) (hi : i < gs.length) : + pairStart gs i+(groupAt gs i).length/2 ≤ pairCount gs := by + induction gs generalizing i with + | nil => simp at hi + | cons ps gs ih => + cases i with + | zero => simp only [pairStart_zero,zero_add,groupAt_cons_zero,pairCount_cons]; omega + | succ i => + have hi' : i < gs.length := by simpa using hi + rw [pairStart_cons_succ,groupAt_cons_succ,pairCount_cons] + have := ih i hi' + omega + +theorem pair_index_lt (gs : Groups) (i j : ℕ) (hi : i < gs.length) + (hj : j < (groupAt gs i).length/2) : pairStart gs i+j < pairCount gs := by + have := pairStart_bound gs i hi + omega + +theorem pairs_getElem? (ps : List Port) (j : ℕ) (hj : j < ps.length/2) : + (pairs ps)[j]?=some (portAt ps (2*j),portAt ps (2*j+1)) := by + rw [List.getElem?_eq_getElem (by simpa only [pairs_length] using hj)] + simp only [pairs,List.getElem_map,List.getElem_range] + +theorem catalog_getElem? (gs : Groups) (i j : ℕ) (hi : i < gs.length) + (hj : j < (groupAt gs i).length/2) : + (catalog gs)[pairStart gs i+j]? = + some (i,(portAt (groupAt gs i) (2*j),portAt (groupAt gs i) (2*j+1))) := by + induction gs generalizing i with + | nil => simp at hi + | cons ps gs ih => + cases i with + | zero => + rw [catalog_cons,pairStart_zero,zero_add, + List.getElem?_append_left (by simpa only [List.length_map,pairs_length, + groupAt_cons_zero] using hj),List.getElem?_map] + rw [groupAt_cons_zero] at hj ⊢ + rw [pairs_getElem? ps j hj] + rfl + | succ i => + have hi' : i < gs.length := by simpa using hi + rw [groupAt_cons_succ] at hj ⊢ + rw [catalog_cons,pairStart_cons_succ, + List.getElem?_append_right (by simp only [List.length_map,pairs_length]; omega), + List.length_map,pairs_length] + have he : ps.length/2+pairStart gs i+j-ps.length/2=pairStart gs i+j := by omega + rw [he,List.getElem?_map,ih i hi' hj] + rfl + +theorem catalog_headD (gs : Groups) (i j : ℕ) (hi : i < gs.length) + (hj : j < (groupAt gs i).length/2) : + ((catalog gs).drop (pairStart gs i+j)).headD (0,((0,0),(0,0))) = + (i,(portAt (groupAt gs i) (2*j),portAt (groupAt gs i) (2*j+1))) := by + rw [List.headD_eq_head?_getD,List.head?_drop,catalog_getElem? gs i j hi hj] + rfl + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitial.lean new file mode 100644 index 0000000000000000000000000000000000000000..58198a5fcee6fa62bf12eac51136603c5ab5afdf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitial.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListIteration + +namespace OAI + +/-! The literal odd subdivision that initializes the bounded-degree compiler. +Each edge owns two consecutive mediator sites, and each original vertex keeps +the increasing list of its incident mediator ports. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram + +def initialBond (bs : List Bond) (j : ℕ) : Bond := + (bs.drop (j/2)).headD (0,0,0) + +def initialEndpoint (bs : List Bond) (j : ℕ) : ℕ := + if j%2=0 then (initialBond bs j).1 else (initialBond bs j).2.1 + +def initialWeight (bs : List Bond) (R : ℚ) (j : ℕ) : ℚ := + if j%2=0 then R else 2*R*(initialBond bs j).2.2 + +def initialIndices (bs : List Bond) (i : ℕ) : List ℕ := + (List.range (2*bs.length)).filter (fun j => decide (initialEndpoint bs j=i)) + +def initialGroup (n : ℕ) (bs : List Bond) (R : ℚ) (i : ℕ) : List Port := + (initialIndices bs i).map (fun j => (n+j,initialWeight bs R j)) + +def initialScale (N : ℚ) (bs : List Bond) (c : ℚ) : ℚ := + let A := 3*(bs.map (fun b => 1+2*|b.2.2|)).sum + let B := |c|+4*(bs.map (fun b => (1+|b.2.2|)^2)).sum + 16*(A+B+1)^3*N+4*(A+B+1)+1 + +def initial (n : ℕ) (bs : List Bond) (c N : ℚ) : State := + let R := initialScale N bs c + (n+2*bs.length, + (List.range bs.length).map (fun e => (n+2*e,n+2*e+1,R^2)), + c+(bs.map (fun b => 3/4+3*b.2.2^2)).sum+3*(bs.length:ℚ)*R^2, + (List.range n).map (initialGroup n bs R)) + +theorem initialGroup_portAt (n : ℕ) (bs : List Bond) (R : ℚ) (i j : ℕ) + (hj : j < (initialIndices bs i).length) : + portAt (initialGroup n bs R i) j= + (n+(initialIndices bs i)[j],initialWeight bs R (initialIndices bs i)[j]) := by + rw [portAt_eq_getElem _ _ (by simpa only [initialGroup,List.length_map] using hj)] + simp only [initialGroup,List.getElem_map] + +theorem initialIndices_mem (bs : List Bond) (i j : ℕ) (hj : j ∈ initialIndices bs i) : + j < 2*bs.length ∧ initialEndpoint bs j=i := by + simpa only [initialIndices,List.mem_filter,List.mem_range,decide_eq_true_eq] using hj + +theorem initialIndices_nodup (bs : List Bond) (i : ℕ) : (initialIndices bs i).Nodup := + (List.nodup_range : (List.range (2*bs.length)).Nodup).filter _ + +theorem initialGroup_bounded (n : ℕ) (bs : List Bond) (R : ℚ) (i j : ℕ) + (hj : j < (initialGroup n bs R i).length) : + (portAt (initialGroup n bs R i) j).1 < n+2*bs.length := by + have hj' : j < (initialIndices bs i).length := by + simpa only [initialGroup,List.length_map] using hj + rw [initialGroup_portAt n bs R i j hj'] + have hm := initialIndices_mem bs i _ (List.getElem_mem hj') + dsimp only + omega + +theorem initialGroup_disjoint (n : ℕ) (bs : List Bond) (R : ℚ) (k i j : ℕ) + (hk : k < n) (hj : j < (initialGroup n bs R i).length) : + k ≠ (portAt (initialGroup n bs R i) j).1 := by + have hj' : j < (initialIndices bs i).length := by + simpa only [initialGroup,List.length_map] using hj + rw [initialGroup_portAt n bs R i j hj'] + dsimp only + omega + +theorem initialGroup_injective (n : ℕ) (bs : List Bond) (R : ℚ) (i k j l : ℕ) + (hj : j < (initialGroup n bs R i).length) + (hl : l < (initialGroup n bs R k).length) + (he : (portAt (initialGroup n bs R i) j).1= + (portAt (initialGroup n bs R k) l).1) : i=k ∧ j=l := by + have hj' : j < (initialIndices bs i).length := by + simpa only [initialGroup,List.length_map] using hj + have hl' : l < (initialIndices bs k).length := by + simpa only [initialGroup,List.length_map] using hl + rw [initialGroup_portAt n bs R i j hj',initialGroup_portAt n bs R k l hl'] at he + have he' : (initialIndices bs i)[j]=(initialIndices bs k)[l] := by + dsimp only at he + omega + have hmj := (initialIndices_mem bs i _ (List.getElem_mem hj')).2 + have hml := (initialIndices_mem bs k _ (List.getElem_mem hl')).2 + have hik : i=k := by rw [he',hml] at hmj; exact hmj.symm + refine ⟨hik,?_⟩ + subst k + exact (initialIndices_nodup bs i).eq_of_getElem_eq hj' hl' he' + +theorem initial_validPorts (n : ℕ) (bs : List Bond) (c N : ℚ) : + ValidPorts (initial n bs c N).1 (initial n bs c N).2.2.2 := by + have hg (i : ℕ) (hi : i < n) : + groupAt (initial n bs c N).2.2.2 i=initialGroup n bs (initialScale N bs c) i := by + change groupAt ((List.range n).map (initialGroup n bs (initialScale N bs c))) i=_ + rw [groupAt,List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem (by simpa using hi)] + simp only [Option.getD_some,List.getElem_map,List.getElem_range] + have hlen : (initial n bs c N).2.2.2.length=n := by simp only [initial,List.length_map,List.length_range] + constructor + · rw [hlen] + exact Nat.le_add_right _ _ + · intro i j + have hi : i.val < n := by simpa only [hlen] using i.isLt + have hj : j.val < (initialGroup n bs (initialScale N bs c) i.val).length := by + simpa only [hg i.val hi] using j.isLt + change (portAt (groupAt (initial n bs c N).2.2.2 i.val) j.val).1 < n+2*bs.length + simpa only [hg i.val hi] using initialGroup_bounded n bs _ i.val j.val hj + · intro i k j + have hi : i.val < n := by simpa only [hlen] using i.isLt + have hk : k.val < n := by simpa only [hlen] using k.isLt + have hj : j.val < (initialGroup n bs (initialScale N bs c) k.val).length := by + simpa only [hg k.val hk] using j.isLt + simpa only [hg k.val hk] using initialGroup_disjoint n bs _ i.val k.val j.val hi hj + · intro i k j l he + have hi : i.val < n := by simpa only [hlen] using i.isLt + have hk : k.val < n := by simpa only [hlen] using k.isLt + have hj : j.val < (initialGroup n bs (initialScale N bs c) i.val).length := by + simpa only [hg i.val hi] using j.isLt + have hl : l.val < (initialGroup n bs (initialScale N bs c) k.val).length := by + simpa only [hg k.val hk] using l.isLt + have he' : (portAt (initialGroup n bs (initialScale N bs c) i.val) j.val).1= + (portAt (initialGroup n bs (initialScale N bs c) k.val) l.val).1 := by + simpa only [hg i.val hi,hg k.val hk] using he + obtain ⟨hik,hjl⟩ := initialGroup_injective n bs _ i.val k.val j.val l.val hj hl he' + exact ⟨Fin.ext hik,hjl⟩ + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a4e5bdba2f19aece22b60781af712561d8ad346 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialAccuracy.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCalibration + +namespace OAI + +/-! The actual initial odd subdivision changes the full-space ground energy +by at most 1/N. Together with the literal fork iteration this is (k+1)/N. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample MediatorListProgram +open scoped BigOperators Classical + +theorem initial_accuracy (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (hn : ∀ b ∈ bs, b.1 ≠ b.2.1) (c N : ℚ) (hN : 0 < N) : + |normalizedBottom (matrix (initial n bs c N))-normalizedBottom (rawMatrix n (bs,c))| ≤ + 1/(N:ℝ) := by + let left : Fin bs.length → Fin n := (SourceBondLists.bonds n bs hb).left + let right : Fin bs.length → Fin n := (SourceBondLists.bonds n bs hb).right + let J : Fin bs.length → ℚ := fun e => (bs.get e).2.2 + have hneq : ∀ e, left e ≠ right e := SourceBondLists.bonds_noLoops n bs hb hn + have h := qmaPathsGraph_accuracy (fun a : Fin 0 => Fin.elim0 a) + (fun a : Fin 0 => Fin.elim0 a) (fun a => Fin.elim0 a) (fun _ => 0) (c:ℝ) + (qmaOriginalSite left right) (qmaOriginalSite_injective left right hneq) + (fun _ => false) (fun e => (J e:ℝ)) (show (0:ℝ) < N by exact_mod_cast hN) + dsimp only at h + have hscale : (initialScale N bs c:ℝ)= + qmaRoutingScale (3*∑ e, (1+2*|(J e:ℝ)|)) + (|(c:ℝ)|+4*∑ e, (1+|(J e:ℝ)|)^2) (N:ℝ) := initialScale_cast N bs c + simp only [Finset.univ_eq_empty,Finset.sum_empty,mul_zero,zero_add] at h + rw [← hscale] at h + have hout : normalizedBottom (matrix (initial n bs c N))= + normalizedBottom (qmaPathsGraph (fun a : Fin 0 => Fin.elim0 a) + (fun a : Fin 0 => Fin.elim0 a) (fun _ => 0) (c:ℝ) (initialScale N bs c:ℝ) + (qmaOriginalSite left right) (fun _ => false) (fun e => (J e:ℝ))) := by + rw [initial_bottom_physical n bs hb c N] + unfold rawBottom + exact congrArg normalizedBottom (initialPhysical_matrix left right J c (initialScale N bs c)) + have hin : rawMatrix n (bs,c)=qmaExchangeMatrix left right (fun e => (J e:ℝ)) (c:ℝ) := by + rw [rawMatrix_eq_matrix] + exact (QuantumListGraph.ofBonds_matrix n bs c hb hn).symm + have hJ : ∀ e, ((J e:ℝ):ℂ)=(J e:ℂ) := by intro e; norm_cast + have hc : ((c:ℝ):ℂ)=(c:ℂ) := by norm_cast + simp only [qmaExchangeMatrix,Finset.univ_eq_empty,Finset.sum_empty,zero_add] at h + have hin' : rawMatrix n (bs,c)= + ∑ e, (J e:ℂ) • sourceHeisenbergMatrix n (left e) (right e)+(c:ℂ) • 1 := by + simpa only [qmaExchangeMatrix,hJ,hc] using hin + change |normalizedBottom _-normalizedBottom _| ≤ 1/(N:ℝ) at h + rw [← hout] at h + have heq : (c:ℂ) • (1 : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ)+ + ∑ e, (J e:ℂ) • sourceHeisenbergMatrix n (left e) (right e)=rawMatrix n (bs,c) := by + rw [hin'] + exact add_comm _ _ + simpa only [qmaOriginalSite,Matrix.cons_val_zero,Matrix.cons_val_one,hJ,hc,heq] using h + +theorem initial_iterated_accuracy (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (hn : ∀ b ∈ bs, b.1 ≠ b.2.1) (c N : ℚ) (hN : 0 < N) (k : ℕ) : + |normalizedBottom (matrix (iterate N k (initial n bs c N)))- + normalizedBottom (rawMatrix n (bs,c))| ≤ ((k:ℝ)+1)/(N:ℝ) := by + calc + _ ≤ |normalizedBottom (matrix (iterate N k (initial n bs c N)))- + normalizedBottom (matrix (initial n bs c N))|+ + |normalizedBottom (matrix (initial n bs c N))-normalizedBottom (rawMatrix n (bs,c))| := + abs_sub_le _ _ _ + _ ≤ (k:ℝ)/(N:ℝ)+1/(N:ℝ) := + add_le_add (initial_iterate_accuracy n bs c N hN k) (initial_accuracy n bs hb hn c N hN) + _ = ((k:ℝ)+1)/(N:ℝ) := by ring + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..413af07caae2be05242e2ff74b5b69b8a11b80c5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialBounds.lean @@ -0,0 +1,37 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitial + +namespace OAI + +/-! The literal odd subdivision satisfies all hypotheses needed to iterate +the full-space fork estimate. Its fresh singlets have distinct endpoints. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram + +theorem initial_background_valid (n : ℕ) (bs : List Bond) (c N : ℚ) : + SourceBondLists.bounded (initial n bs c N).1 (background (initial n bs c N)) ∧ + ∀ b ∈ background (initial n bs c N), b.1 ≠ b.2.1 := by + have hv : ∀ b ∈ background (initial n bs c N), + b.1 < (initial n bs c N).1 ∧ b.2.1 < (initial n bs c N).1 ∧ b.1 ≠ b.2.1 := by + intro b hb + rcases List.mem_append.mp hb with hs | hp + · obtain ⟨e,he,rfl⟩ := List.mem_map.mp hs + have he' := List.mem_range.mp he + dsimp only [initial] + omega + · exact unpairedBonds_valid (initial_validPorts n bs c N) b hp + exact ⟨fun b hm => ⟨(hv b hm).1,(hv b hm).2.1⟩,fun b hm => (hv b hm).2.2⟩ + +theorem initial_iterate_accuracy (n : ℕ) (bs : List Bond) (c N : ℚ) (hN : 0 < N) + (k : ℕ) : + |MediatorGraph.normalizedBottom (matrix (iterate N k (initial n bs c N)))- + MediatorGraph.normalizedBottom (matrix (initial n bs c N))| ≤ (k:ℝ)/(N:ℝ) := by + have h := initial_background_valid n bs c N + exact iterate_accuracy _ (initial_validPorts n bs c N) h.1 h.2 N hN k + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCalibration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCalibration.lean new file mode 100644 index 0000000000000000000000000000000000000000..61515dbba4af2cf8268dcbdffccf6471c4a84241 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCalibration.lean @@ -0,0 +1,33 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialRealization + +namespace OAI + +/-! The literal initial scale has exactly the coefficient budget used in +the rational simultaneous path estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem initial_list_sum {M : Type*} [AddCommMonoid M] (bs : List Bond) (f : Bond → M) : + (bs.map f).sum=∑ e : Fin bs.length, f (bs.get e) := by + rw [← List.sum_ofFn] + exact congrArg List.sum (List.ofFn_getElem_eq_map bs f).symm + +theorem initialScale_eq (N : ℚ) (bs : List Bond) (c : ℚ) : + initialScale N bs c=qmaRationalInitialScale (fun e : Fin bs.length => (bs.get e).2.2) c N := by + unfold initialScale qmaRationalInitialScale + rw [initial_list_sum,initial_list_sum] + +theorem initialScale_cast (N : ℚ) (bs : List Bond) (c : ℚ) : + (initialScale N bs c:ℝ)= + qmaRoutingScale (3*∑ e : Fin bs.length, (1+2*|((bs.get e).2.2:ℝ)|)) + (|(c:ℝ)|+4*∑ e : Fin bs.length, (1+|((bs.get e).2.2:ℝ)|)^2) (N:ℝ) := by + rw [initialScale_eq,qmaRationalInitialScale_cast] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCellMass.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCellMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..8959316be880e008aee20ea3956a5fa6faf22d8e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCellMass.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCellMass +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkInitialCells + +namespace OAI + +/-! The literal initial cell array has the original endpoint multiplicities. +Together with fixed fork rounds this gives a constant coarse-cell density. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph MediatorListProgram +open scoped BigOperators Classical +variable {β : Type*} [DecidableEq β] + +omit [DecidableEq β] in +theorem initialCell_eq_subdivision (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (cell : ℕ → β) (v : Fin (n+bs.length*2)) : + initialCell n bs cell v.val= + qmaSubdivisionCell (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun i => cell i.val) v := by + obtain ⟨v,rfl⟩ := (vertexEquiv n bs.length).surjective v + rcases v with i | ⟨e,b⟩ + · change initialCell n bs cell (old n bs.length i).val=_ + rw [MediatorIteration.old_val,initialCell_old n bs cell i.val i.isLt] + exact (qmaSubdivisionCell_old (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun j => cell j.val) i).symm + · change initialCell n bs cell (fresh n bs.length e b).val=_ + refine Eq.trans ?_ (qmaSubdivisionCell_fresh + (SourceBondLists.bonds n bs hb).left (SourceBondLists.bonds n bs hb).right + (fun j => cell j.val) e b).symm + rw [MediatorIteration.fresh_val] + fin_cases b + · simp only [Nat.add_zero] + rw [initialCell_new,initialEndpoint_even] + rfl + · rw [Nat.add_assoc,initialCell_new,initialEndpoint_odd] + rfl + +theorem initial_cell_mass_le (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (hn : ∀ b ∈ bs, b.1 ≠ b.2.1) + (c N : ℚ) (cell : ℕ → β) (D : ℕ) (hd : ∀ i : Fin n, degree bs i.val ≤ D) (p : β) : + qmaCellMass (fun v : Fin (initial n bs c N).1 => initialCell n bs cell v.val) p ≤ + (D+1)*qmaCellMass (fun v : Fin n => cell v.val) p := by + change qmaCellMass (fun v : Fin (n+2*bs.length) => initialCell n bs cell v.val) p ≤ _ + rw [show n+2*bs.length=n+bs.length*2 by omega] + have he : (fun v : Fin (n+bs.length*2) => initialCell n bs cell v.val)= + qmaSubdivisionCell (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun v => cell v.val) := + funext (initialCell_eq_subdivision n bs hb cell) + rw [he] + apply qmaSubdivisionCell_mass_le + intro i + rw [qmaOriginalPortCount_eq_degree _ _ (SourceBondLists.bonds_noLoops n bs hb hn), + ← degree_eq_graph] + exact hd i + +theorem initial_iterate_cell_mass_le (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (hn : ∀ b ∈ bs, b.1 ≠ b.2.1) + (c N : ℚ) (cell : ℕ → β) (D : ℕ) (hd : ∀ i : Fin n, degree bs i.val ≤ D) + (k : ℕ) (p : β) : + qmaCellMass (fun v : Fin (iterate N k (initial n bs c N)).1 => + iterateCell N k (initial n bs c N) (initialCell n bs cell) v.val) p ≤ + ((1+2*D)^k*(D+1))*qmaCellMass (fun v : Fin n => cell v.val) p := by + have hg : ∀ i : Fin (initial n bs c N).2.2.2.length, + (groupAt (initial n bs c N).2.2.2 i.val).length ≤ D := by + intro i + have hi : i.val initialCell n bs cell v.val) p := h + _ ≤ (1+2*D)^k*((D+1)*qmaCellMass (fun v : Fin n => cell v.val) p) := + Nat.mul_le_mul_left _ (initial_cell_mass_le n bs hb hn c N cell D hd p) + _ = _ := by ring + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..73437e39094ae26812e19a771153293b9cf8d9d5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialCells.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCellLocality + +namespace OAI + +/-! The initial subdivision assigns its two new spins to the original +endpoints. Its singlet bonds therefore have exactly the original cell locality. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped Classical + +def initialCell {β : Type*} (n : ℕ) (bs : List Bond) (cell : ℕ → β) (v : ℕ) : β := + if v (n+2*e,n+2*e+1,R^2)) + +theorem singlet_degree_le_one (n m : ℕ) (R : ℚ) (v : ℕ) : + degree (singletBonds n m R) v ≤ 1 := by + have hinj : Function.Injective (fun p : Fin m × Fin 2 => n+2*p.1.val+p.2.val) := by + rintro ⟨e,b⟩ ⟨f,c⟩ h + change n+2*e.val+b.val=n+2*f.val+c.val at h + have hb := b.isLt + have hc := c.isLt + apply Prod.ext + · apply Fin.ext + change e.val=f.val + omega + · apply Fin.ext + change b.val=c.val + omega + have hh := qmaCount_eq_le_one _ hinj v + have he : degree (singletBonds n m R) v= + ∑ p : Fin m × Fin 2, if n+2*p.1.val+p.2.val=v then 1 else 0 := by + simp only [degree,incident,singletBonds,List.map_map,Function.comp_def,range_sum, + Fintype.sum_prod_type,Fin.sum_univ_two,Nat.add_zero,Fin.val_zero,Fin.val_one] + apply Finset.sum_congr rfl + intro e _ + split_ifs <;> omega + rw [he] + exact hh + +theorem singlet_degree_center (n m : ℕ) (R : ℚ) (v : ℕ) (hv : v + ((groupAt ((List.range n).map (initialGroup n bs R)) i).map + (fun p => f (i,p.1,p.2))).sum) = + (List.range n).map (fun i => ((initialGroup n bs R i).map + (fun p => f (i,p.1,p.2))).sum) := by + apply List.map_congr_left + intro i hi + rw [initial_groupAt n bs R i (List.mem_range.mp hi)] + simp only [activeBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def,List.length_map,List.length_range] + rw [hg] + exact initial_group_pair_sum n bs hb R (fun i p => f (i,p.1,p.2)) + +theorem initial_matrix_sum (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (c N : ℚ) : + matrix (initial n bs c N) = + ((List.range bs.length).map (fun e => rawBondMatrix (n+2*bs.length) + (n+2*e,n+2*e+1,(initialScale N bs c)^2))).sum+ + (∑ e : Fin bs.length, + (rawBondMatrix (n+2*bs.length) (bs[e.val].1,n+2*e.val,initialScale N bs c)+ + rawBondMatrix (n+2*bs.length) + (bs[e.val].2.1,n+(2*e.val+1),2*(initialScale N bs c)*bs[e.val].2.2)))+ + (initial n bs c N).2.2.1 • + (1 : Matrix (SourceSpinBasis (n+2*bs.length)) (SourceSpinBasis (n+2*bs.length)) ℂ) := by + change rawMatrix (n+2*bs.length) + ((List.range bs.length).map (fun e => (n+2*e,n+2*e+1,(initialScale N bs c)^2))++ + activeBonds ((List.range n).map (initialGroup n bs (initialScale N bs c))), + (initial n bs c N).2.2.1)=_ + rw [rawMatrix,List.map_append,List.sum_append] + simp only [List.map_map,Function.comp_def,initial_active_sum n bs hb] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPairs.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPairs.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b99fb977f265daa52af6dd0cbfbd0f99bb0311e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPairs.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialSum + +namespace OAI + +/-! The even and odd entries in the initial endpoint table are precisely +the two couplings belonging to each physical singlet. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +def initialIndexEquiv (m : ℕ) : Fin m × Fin 2 ≃ Fin (2*m) := + finProdFinEquiv.trans (finCongr (Nat.mul_comm m 2)) + +theorem initialIndexEquiv_val (m : ℕ) (e : Fin m) (b : Fin 2) : + (initialIndexEquiv m (e,b)).val=2*e.val+b.val := by + change b.val+2*e.val=2*e.val+b.val + omega + +theorem initial_evenodd_sum {M : Type*} [AddCommMonoid M] (m : ℕ) (f : ℕ → M) : + ((List.range (2*m)).map f).sum=∑ e : Fin m, (f (2*e.val)+f (2*e.val+1)) := by + rw [range_sum] + have h := (initialIndexEquiv m).sum_comp (fun j => f j.val) + simpa only [Fintype.sum_prod_type,Fin.sum_univ_two,initialIndexEquiv_val, + Fin.val_zero,Fin.val_one,add_zero] using h.symm + +theorem initialBond_pair (bs : List Bond) (e : Fin bs.length) (b : Fin 2) : + initialBond bs (2*e.val+b.val)=bs[e.val] := by + have hd : (2*e.val+b.val)/2=e.val := by have := b.isLt; omega + simp only [initialBond,hd,List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem e.isLt,Option.getD_some] + +theorem initialEndpoint_even (bs : List Bond) (e : Fin bs.length) : + initialEndpoint bs (2*e.val)=bs[e.val].1 := by + have hm : (2*e.val)%2=0 := by omega + simp only [initialEndpoint,hm,ite_true] + simpa only [Fin.val_zero,add_zero] using + congrArg Prod.fst (initialBond_pair bs e 0) + +theorem initialEndpoint_odd (bs : List Bond) (e : Fin bs.length) : + initialEndpoint bs (2*e.val+1)=bs[e.val].2.1 := by + have hm : (2*e.val+1)%2≠0 := by omega + simp only [initialEndpoint,hm,ite_false] + exact congrArg (fun p : Bond => p.2.1) (initialBond_pair bs e 1) + +theorem initialWeight_even (bs : List Bond) (R : ℚ) (e : Fin bs.length) : + initialWeight bs R (2*e.val)=R := by + have hm : (2*e.val)%2=0 := by omega + simp only [initialWeight,hm,ite_true] + +theorem initialWeight_odd (bs : List Bond) (R : ℚ) (e : Fin bs.length) : + initialWeight bs R (2*e.val+1)=2*R*bs[e.val].2.2 := by + have hm : (2*e.val+1)%2≠0 := by omega + simp only [initialWeight,hm,ite_false] + simpa only [Fin.val_one] using + congrArg (fun b : Bond => 2*R*b.2.2) (initialBond_pair bs e 1) + +theorem initial_group_pair_sum {M : Type*} [AddCommMonoid M] (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (R : ℚ) (f : ℕ → Port → M) : + ((List.range n).map (fun i => ((initialGroup n bs R i).map (f i)).sum)).sum = + ∑ e : Fin bs.length, + (f bs[e.val].1 (n+2*e.val,R)+ + f bs[e.val].2.1 (n+(2*e.val+1),2*R*bs[e.val].2.2)) := by + rw [initial_group_sum n bs hb,initial_evenodd_sum] + simp only [initialEndpoint_even,initialEndpoint_odd,initialWeight_even,initialWeight_odd] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPhysical.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPhysical.lean new file mode 100644 index 0000000000000000000000000000000000000000..679ea7e710e3fadd8f7c145ed0259261c3bcea32 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialPhysical.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialMatrix + +namespace OAI + +/-! The initial emitted couplings are the simultaneous odd-path singlet +Hamiltonian used by the already proved full-space perturbation estimate. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample +open scoped BigOperators Classical + +def initialPhysicalBonds {n m : ℕ} (left right : Fin m → Fin n) (J : Fin m → ℚ) + (R : ℚ) : List MediatorListProgram.Bond := + (List.ofFn (fun e => erase (fresh n m e 0,fresh n m e 1,R^2)))++ + (List.ofFn (fun e => [erase (old n m (left e),fresh n m e 0,R), + erase (old n m (right e),fresh n m e 1,2*R*J e)])).flatten + +def initialConstant {m : ℕ} (J : Fin m → ℚ) (c R : ℚ) : ℚ := + (c+∑ e, (3/4+3*(J e)^2))+3*m*R^2 + +theorem initialPhysical_matrix {n m : ℕ} (left right : Fin m → Fin n) + (J : Fin m → ℚ) (c R : ℚ) : + rawMatrix (n+m*2) (initialPhysicalBonds left right J R,initialConstant J c R) = + qmaPathsGraph (fun a : Fin 0 => Fin.elim0 a) (fun a : Fin 0 => Fin.elim0 a) + (fun _ => 0) (c:ℝ) (R:ℝ) (qmaOriginalSite left right) (fun _ => false) + (fun e => (J e:ℝ)) := by + simp only [rawMatrix,← Rat.cast_smul_eq_qsmul ℂ,initialPhysicalBonds,List.map_append, + List.sum_append,List.map_ofFn,List.sum_ofFn,List.map_flatten,List.sum_flatten, + Function.comp_def,List.map_cons,List.map_nil,List.sum_cons,List.sum_nil,add_zero, + rawBondMatrix_erase,typedBondMatrix] + simp only [qmaPathsGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + Fin.sum_univ_two,qmaParallelGraphLeft,qmaParallelGraphRight,qmaParallelGraphWeight, + qmaPathAmplitude,qmaPathMember,qmaOriginalSite,qmaPathOffset, + Finset.univ_eq_empty,Finset.sum_empty,zero_add, + initialConstant] + push_cast + simp only [Finset.sum_add_distrib] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea4a6b62f846f66a7b32f14e46866dab2713a9cc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialProgram.lean @@ -0,0 +1,145 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialCalibration +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListNext + +namespace OAI + +/-! Literal lookup, parity and rational coefficient programs for the +initial odd subdivision. Endpoint queries read the actual input bond list. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +def initialLookupCode : (ℕ × List Bond) → List Bool := + prodCode Nat.bits (listCode bondCode) + +noncomputable def initialBondProgram : Procedure initialLookupCode bondCode + (fun x => initialBond x.2 x.1) := by + let j := Procedure.first Nat.bits (listCode bondCode) + let bs := Procedure.second Nat.bits (listCode bondCode) + let i := Procedure.binaryDiv.comp (j.pair (Procedure.constant initialLookupCode Nat.bits 2)) + exact (Procedure.listGet bondCode (0,0,0)).comp (i.pair bs) + +noncomputable def initialParityProgram : Procedure Nat.bits Procedure.boolCode + (fun j => decide (j%2=0)) := + Procedure.binaryZero.comp (Procedure.binaryMod.comp + ((Procedure.identity Nat.bits).pair (Procedure.constant Nat.bits Nat.bits 2))) + +noncomputable def initialEndpointProgram : Procedure initialLookupCode Nat.bits + (fun x => initialEndpoint x.2 x.1) := by + let p := initialParityProgram.comp (Procedure.first Nat.bits (listCode bondCode)) + let b := initialBondProgram + let left := (Procedure.first Nat.bits (prodCode Nat.bits ratCode)).comp b + let right := (Procedure.first Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp b) + exact (Procedure.conditional p left right).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,initialEndpoint]) + +def initialWeightCode : (ℕ × (ℚ × List Bond)) → List Bool := + prodCode Nat.bits (prodCode ratCode (listCode bondCode)) + +noncomputable def initialWeightProgram : Procedure initialWeightCode ratCode + (fun x => initialWeight x.2.2 x.2.1 x.1) := by + let j := Procedure.first Nat.bits (prodCode ratCode (listCode bondCode)) + let tail := Procedure.second Nat.bits (prodCode ratCode (listCode bondCode)) + let r := (Procedure.first ratCode (listCode bondCode)).comp tail + let bs := (Procedure.second ratCode (listCode bondCode)).comp tail + let b := initialBondProgram.comp (j.pair bs) + let w := (Procedure.second Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp b) + let twice := Procedure.ratMul.comp ((Procedure.constant initialWeightCode ratCode 2).pair r) + let odd := Procedure.ratMul.comp (twice.pair w) + exact (Procedure.conditional (initialParityProgram.comp j) r odd).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,initialWeight]) + +def initialMatch (x : ℕ × (ℕ × List Bond)) : List ℕ := + if initialEndpoint x.2.2 x.1=x.2.1 then [x.1] else [] + +noncomputable def initialMatchProgram : + Procedure (prodCode unaryCode initialLookupCode) (listCode Nat.bits) initialMatch := by + let j := Procedure.unaryToBits.comp (Procedure.first unaryCode initialLookupCode) + let env := Procedure.second unaryCode initialLookupCode + let i := (Procedure.first Nat.bits (listCode bondCode)).comp env + let bs := (Procedure.second Nat.bits (listCode bondCode)).comp env + let endpoint := initialEndpointProgram.comp (j.pair bs) + let same := Procedure.binaryEq.comp (endpoint.pair i) + let one := (Procedure.listCons Nat.bits).comp + (j.pair (Procedure.constant _ (listCode Nat.bits) [])) + exact (Procedure.conditional same one (Procedure.constant _ (listCode Nat.bits) [])).congrFun + (by intro x; simp only [Function.comp_apply,decide_eq_true_eq,initialMatch,id_eq]) + +noncomputable def initialIndicesProgram : Procedure initialLookupCode (listCode Nat.bits) + (fun x => initialIndices x.2 x.1) := by + let bs := Procedure.second Nat.bits (listCode bondCode) + let len := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode (0,0,0)).comp bs + let count := Procedure.unaryAdd.comp (len.pair len) + let tab := (Procedure.tabulate (f := fun env j => initialMatch (j,env)) [] + initialMatchProgram).comp (count.pair (Procedure.identity initialLookupCode)) + refine ((QuantumRawExchange.flattenProgram Nat.bits 0).comp tab).congrFun ?_ + intro x + change ((List.range (x.2.length+x.2.length)).map (fun j => initialMatch (j,x))).flatten= + initialIndices x.2 x.1 + rw [show x.2.length+x.2.length=2*x.2.length by omega] + unfold initialIndices + generalize List.range (2*x.2.length)=js + induction js with + | nil => rfl + | cons j js ih => + simp only [initialMatch] at ih + by_cases h : initialEndpoint x.2 j=x.1 <;> simp [initialMatch,h,ih] + +noncomputable def initialPointProgram : + Procedure (prodCode initialWeightCode Nat.bits) portCode + (fun x => (x.1.1+x.2,initialWeight x.1.2.2 x.1.2.1 x.2)) := by + let env := Procedure.first initialWeightCode Nat.bits + let j := Procedure.second initialWeightCode Nat.bits + let n := (Procedure.first Nat.bits (prodCode ratCode (listCode bondCode))).comp env + let tail := (Procedure.second Nat.bits (prodCode ratCode (listCode bondCode))).comp env + exact (Procedure.binaryAdd.comp (n.pair j)).pair (initialWeightProgram.comp (j.pair tail)) + +def initialGroupInputCode : (ℕ × (ℚ × (ℕ × List Bond))) → List Bool := + prodCode Nat.bits (prodCode ratCode initialLookupCode) + +noncomputable def initialGroupProgram : Procedure initialGroupInputCode (listCode portCode) + (fun x => initialGroup x.1 x.2.2.2 x.2.1 x.2.2.1) := by + let n := Procedure.first Nat.bits (prodCode ratCode initialLookupCode) + let tail := Procedure.second Nat.bits (prodCode ratCode initialLookupCode) + let r := (Procedure.first ratCode initialLookupCode).comp tail + let lookup := (Procedure.second ratCode initialLookupCode).comp tail + let bs := (Procedure.second Nat.bits (listCode bondCode)).comp lookup + let env := n.pair (r.pair bs) + let js := initialIndicesProgram.comp lookup + exact ((Procedure.listMapWith + (f := fun (y : ℕ × (ℚ × List Bond)) (j : ℕ) => + (y.1+j,initialWeight y.2.2 y.2.1 j)) 0 (0,0) initialPointProgram).comp + (env.pair js)).congrFun (by intro x; rfl) + +def initialGroupsCode : (ℕ × (ℚ × List Bond)) → List Bool := + prodCode unaryCode (prodCode ratCode (listCode bondCode)) + +noncomputable def initialGroupAtProgram : + Procedure (prodCode unaryCode initialGroupsCode) (listCode portCode) + (fun x => initialGroup x.2.1 x.2.2.2 x.2.2.1 x.1) := by + let i := Procedure.unaryToBits.comp (Procedure.first unaryCode initialGroupsCode) + let env := Procedure.second unaryCode initialGroupsCode + let n := Procedure.unaryToBits.comp + ((Procedure.first unaryCode (prodCode ratCode (listCode bondCode))).comp env) + let tail := (Procedure.second unaryCode (prodCode ratCode (listCode bondCode))).comp env + let r := (Procedure.first ratCode (listCode bondCode)).comp tail + let bs := (Procedure.second ratCode (listCode bondCode)).comp tail + exact initialGroupProgram.comp (n.pair (r.pair (i.pair bs))) + +noncomputable def initialGroupsProgram : Procedure initialGroupsCode groupsCode + (fun x => (List.range x.1).map (initialGroup x.1 x.2.2 x.2.1)) := by + let n := Procedure.first unaryCode (prodCode ratCode (listCode bondCode)) + exact (Procedure.tabulate + (f := fun (x : ℕ × (ℚ × List Bond)) i => initialGroup x.1 x.2.2 x.2.1 i) + [] initialGroupAtProgram).comp (n.pair (Procedure.identity initialGroupsCode)) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bb255785d93eea027d2d1aa6a169aa8f64e0463 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialRealization.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialPhysical + +namespace OAI + +/-! Reordering the actual initial bond list gives exactly the typed physical +singlet Hamiltonian, including its scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample MediatorListProgram +open scoped BigOperators Classical + +def initialSourceBonds (n : ℕ) (bs : List Bond) (R : ℚ) : List Bond := + (List.range bs.length).map (fun e => (n+2*e,n+2*e+1,R^2))++ + activeBonds ((List.range n).map (initialGroup n bs R)) + +theorem initialPhysical_sum {M : Type*} [AddCommMonoid M] {n m : ℕ} + (left right : Fin m → Fin n) (J : Fin m → ℚ) (R : ℚ) (f : Bond → M) : + ((initialPhysicalBonds left right J R).map f).sum = + (∑ e : Fin m, f (n+2*e.val,n+2*e.val+1,R^2))+ + ∑ e : Fin m, + (f ((left e).val,n+2*e.val,R)+f ((right e).val,n+2*e.val+1,2*R*J e)) := by + simp only [initialPhysicalBonds,List.map_append,List.sum_append,List.map_ofFn, + List.sum_ofFn,List.map_flatten,List.sum_flatten,Function.comp_def,List.map_cons, + List.map_nil,List.sum_cons,List.sum_nil,add_zero,erase,MediatorIteration.old_val, + MediatorIteration.fresh_val,Fin.val_zero,Fin.val_one] + +theorem initialSource_sum {M : Type*} [AddCommMonoid M] (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (R : ℚ) (f : Bond → M) : + ((initialSourceBonds n bs R).map f).sum = + ((initialPhysicalBonds (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun e => (bs.get e).2.2) R).map f).sum := by + simp only [initialSourceBonds,List.map_append,List.sum_append,List.map_map, + Function.comp_def,range_sum,initial_active_sum n bs hb,initialPhysical_sum, + SourceBondLists.bonds,List.get_eq_getElem] + congr 1 + +theorem initial_constant_eq (n : ℕ) (bs : List Bond) (c N : ℚ) : + (initial n bs c N).2.2.1 = + initialConstant (fun e : Fin bs.length => (bs.get e).2.2) c (initialScale N bs c) := by + have hh : (bs.map (fun b => (3/4+3*b.2.2^2:ℚ))).sum = + ∑ e : Fin bs.length, (3/4+3*(bs.get e).2.2^2) := by + rw [← List.sum_ofFn] + exact congrArg List.sum (List.ofFn_getElem_eq_map bs + (fun b => (3/4+3*b.2.2^2:ℚ))).symm + change c+(bs.map (fun b => (3/4+3*b.2.2^2:ℚ))).sum+ + 3*(bs.length:ℚ)*(initialScale N bs c)^2 = _ + rw [hh] + rfl + +theorem initial_bottom_physical (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (c N : ℚ) : + normalizedBottom (matrix (initial n bs c N)) = + rawBottom (n+bs.length*2) + (initialPhysicalBonds (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun e => (bs.get e).2.2) (initialScale N bs c), + initialConstant (fun e : Fin bs.length => (bs.get e).2.2) c (initialScale N bs c)) := by + have hh : rawMatrix (n+2*bs.length) + (initialSourceBonds n bs (initialScale N bs c),(initial n bs c N).2.2.1) = + rawMatrix (n+2*bs.length) + (initialPhysicalBonds (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun e => (bs.get e).2.2) (initialScale N bs c), + initialConstant (fun e : Fin bs.length => (bs.get e).2.2) c (initialScale N bs c)) := by + unfold rawMatrix + rw [initialSource_sum n bs hb,initial_constant_eq] + change rawBottom (n+2*bs.length) + (initialSourceBonds n bs (initialScale N bs c),(initial n bs c N).2.2.1)=_ + calc + _ = rawBottom (n+2*bs.length) + (initialPhysicalBonds (SourceBondLists.bonds n bs hb).left + (SourceBondLists.bonds n bs hb).right (fun e => (bs.get e).2.2) (initialScale N bs c), + initialConstant (fun e : Fin bs.length => (bs.get e).2.2) c (initialScale N bs c)) := + congrArg normalizedBottom hh + _ = _ := by rw [Nat.mul_comm 2 bs.length] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSpatial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSpatial.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf4311ccd2933a60ef4d088effc506f7518fbfea --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSpatial.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListSpatialPackage +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrdinalSpatial + +namespace OAI + +/-! A bounded-density local input list yields the actual degree-three +spatial output, with its full Hamiltonian and fixed density constant. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped Classical + +def spatialDensity (A D : ℕ) : ℕ := ((1+2*D)^D*(D+1))*A + +structure SpatialInput (rows width A D : ℕ) where + n : ℕ + bonds : List Bond + constant : ℚ + precision : ℚ + cell : ℕ → QMAGridCell rows width + bounded : SourceBondLists.bounded n bonds + noLoops : ∀ b ∈ bonds, b.1≠b.2.1 + degree : ∀ v : Fin n, QuantumForkList.degree bonds v.val ≤ D + density : ∀ p, qmaCellMass (fun v : Fin n => cell v.val) p ≤ A + locality : BondLocal bonds cell CommonCell + +namespace SpatialInput +variable {rows width A D : ℕ} (I : SpatialInput rows width A D) + +def state : State := iterate I.precision D (initial I.n I.bonds I.constant I.precision) + +def cells : ℕ → QMAGridCell rows width := + iterateCell I.precision D (initial I.n I.bonds I.constant I.precision) + (initialCell I.n I.bonds I.cell) + +theorem validPorts : ValidPorts I.state.1 I.state.2.2.2 := + iterate_validPorts _ _ (initial_validPorts _ _ _ _) _ + +theorem state_bounded : SourceBondLists.bounded I.state.1 I.state.2.1 := + iterate_ordinary_bounded _ _ (initial_validPorts _ _ _ _) (initial_ordinary_bounded _ _ _ _) _ + +theorem state_noLoops : ∀ b ∈ I.state.2.1, b.1≠b.2.1 := + iterate_ordinary_noLoops _ _ (initial_validPorts _ _ _ _) (initial_ordinary_noLoops _ _ _ _) _ + +theorem state_density (p : QMAGridCell rows width) : + qmaCellMass (fun v : Fin I.state.1 => I.cells v.val) p ≤ spatialDensity A D := by + have h := initial_iterate_cell_mass_le I.n I.bonds I.bounded I.noLoops + I.constant I.precision I.cell D I.degree D p + exact h.trans (Nat.mul_le_mul_left _ (I.density p)) + +theorem state_degree (v : Fin I.state.1) : QuantumForkList.degree (fullList I.state) v.val ≤ 3 := + initial_iterate_full_degree_of_bound I.n I.bonds I.noLoops I.constant I.precision D I.degree v + +theorem state_locality : BondLocal (fullList I.state) I.cells CommonCell := + initial_iterate_full_cellLocal I.n I.bonds I.constant I.precision I.cell CommonCell + commonCell_refl I.locality D + +def model : QMASpatialExchangeModel (spatialDensity A D) (27*spatialDensity A D) := + (spatialModel I.state I.validPorts I.state_bounded I.state_noLoops I.cells (spatialDensity A D) + I.state_density I.state_degree I.state_locality).withOrdinalSlots (Equiv.refl _) + +theorem model_n : I.model.n=I.state.1 := rfl + +theorem model_rows : I.model.rows=rows := rfl + +theorem model_width : I.model.width=width := rfl + +theorem model_ordinal : I.model.withOrdinalSlots (Equiv.refl _) = I.model := rfl + +theorem model_energy : I.model.energy=MediatorGraph.normalizedBottom (matrix I.state) := + congrArg MediatorGraph.normalizedBottom + (spatialModel_matrix I.state I.validPorts I.state_bounded I.state_noLoops I.cells + (spatialDensity A D) I.state_density I.state_degree I.state_locality) + +theorem model_degree (v : Fin I.model.n) : + qmaGraphDegree I.model.left I.model.right v ≤ 3 := by + exact (degree_eq_graph I.state.1 (fullList I.state) + (fullList_bounded I.state I.validPorts I.state_bounded) v) ▸ I.state_degree v + +end SpatialInput +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialStateProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialStateProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e60fef9a05173f68bff564cc63602c513d7e6760 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialStateProgram.lean @@ -0,0 +1,93 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialProgram + +namespace OAI + +/-! A literal polynomial program emits the complete initial odd-subdivision +state, with its rational scale, singlet bonds and scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev InitialInput := ℚ × (ℕ × (List Bond × ℚ)) +def initialInputCode : InitialInput → List Bool := + prodCode ratCode (prodCode unaryCode (prodCode (listCode bondCode) ratCode)) + +noncomputable def initialInputCount : Procedure initialInputCode unaryCode (fun x => x.2.1) := + (Procedure.first unaryCode (prodCode (listCode bondCode) ratCode)).comp + (Procedure.second ratCode (prodCode unaryCode (prodCode (listCode bondCode) ratCode))) + +noncomputable def initialInputBonds : Procedure initialInputCode (listCode bondCode) + (fun x => x.2.2.1) := + (Procedure.first (listCode bondCode) ratCode).comp + ((Procedure.second unaryCode (prodCode (listCode bondCode) ratCode)).comp + (Procedure.second ratCode (prodCode unaryCode (prodCode (listCode bondCode) ratCode)))) + +noncomputable def initialInputConstant : Procedure initialInputCode ratCode (fun x => x.2.2.2) := + (Procedure.second (listCode bondCode) ratCode).comp + ((Procedure.second unaryCode (prodCode (listCode bondCode) ratCode)).comp + (Procedure.second ratCode (prodCode unaryCode (prodCode (listCode bondCode) ratCode)))) + +noncomputable def initialBondWeight : Procedure bondCode ratCode (fun b => b.2.2) := + (Procedure.second Nat.bits ratCode).comp (Procedure.second Nat.bits (prodCode Nat.bits ratCode)) + +noncomputable def initialScaleProgram : Procedure initialInputCode ratCode + (fun x => initialScale x.1 x.2.2.1 x.2.2.2) := by + let n := Procedure.first ratCode (prodCode unaryCode (prodCode (listCode bondCode) ratCode)) + let ws := (Procedure.listMap (0,0,0) 0 initialBondWeight).comp initialInputBonds + let input := (n.pair initialInputConstant).pair + ((Procedure.constant initialInputCode (listCode ratCode) []).pair ws) + exact (QuantumPathScaleProgram.program.comp input).congrFun (by + intro x + simp only [Function.comp_apply,QuantumPathScaleProgram.value,QuantumPathScaleProgram.active, + QuantumPathScaleProgram.correction,QuantumPathScaleProgram.base,List.map_nil,List.sum_nil, + mul_zero,zero_add,List.map_map,Function.comp_def,QuantumPathScaleProgram.linearCost, + QuantumPathScaleProgram.squareCost,initialScale]) + +noncomputable def initialOffsetProgram : Procedure bondCode ratCode + (fun b => 3/4+3*b.2.2^2) := + Procedure.ratAdd.comp ((Procedure.constant bondCode ratCode (3/4)).pair + (Procedure.ratMul.comp ((Procedure.constant bondCode ratCode 3).pair + (QuantumRoutingCode.squareProgram initialBondWeight)))) + +noncomputable def initialSingletProgram : + Procedure (prodCode unaryCode portCode) bondCode + (fun x => (x.2.1+2*x.1,x.2.1+2*x.1+1,x.2.2^2)) := by + let i := Procedure.unaryToBits.comp (Procedure.first unaryCode portCode) + let env := Procedure.second unaryCode portCode + let n := (Procedure.first Nat.bits ratCode).comp env + let r := (Procedure.second Nat.bits ratCode).comp env + let a := Procedure.binaryAdd.comp (n.pair (Procedure.binaryMul.comp + ((Procedure.constant (prodCode unaryCode portCode) Nat.bits 2).pair i))) + exact a.pair ((Procedure.successor.comp a).pair (QuantumRoutingCode.squareProgram r)) + +noncomputable def initialStateProgram : Procedure initialInputCode stateCode + (fun x => initial x.2.1 x.2.2.1 x.2.2.2 x.1) := by + let n := initialInputCount + let bs := initialInputBonds + let c := initialInputConstant + let r := initialScaleProgram + let count := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode (0,0,0)).comp bs + let size := Procedure.unaryAdd.comp (n.pair (Procedure.unaryAdd.comp (count.pair count))) + let singlets := (Procedure.tabulate + (f := fun (p : Port) i => (p.1+2*i,p.1+2*i+1,p.2^2)) (0,0,0) + initialSingletProgram).comp (count.pair ((Procedure.unaryToBits.comp n).pair r)) + let offset := RationalSumProgram.sumProgram.comp + ((Procedure.listMap (0,0,0) 0 initialOffsetProgram).comp bs) + let countRat := Procedure.natToRat.comp (Procedure.unaryToBits.comp count) + let penalty := Procedure.ratMul.comp + ((Procedure.ratMul.comp ((Procedure.constant initialInputCode ratCode 3).pair countRat)).pair + (QuantumRoutingCode.squareProgram r)) + let scalar := Procedure.ratAdd.comp ((Procedure.ratAdd.comp (c.pair offset)).pair penalty) + let groups := initialGroupsProgram.comp (n.pair (r.pair bs)) + exact (size.pair (singlets.pair (scalar.pair groups))).congrFun (by + intro x + dsimp only [Function.comp_apply,initial] + rw [two_mul] + rfl) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..91b768a8a4521cb7b70f9266a95945a3282a3954 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialSum.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialBounds + +namespace OAI + +/-! Regrouping the literal initial ports recovers the two physical end +couplings of each input edge. The regrouping uses its actual endpoint table. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem initialBond_mem (bs : List Bond) (j : ℕ) (hj : j < 2*bs.length) : + initialBond bs j ∈ bs := by + have hi : j/2 < bs.length := by omega + simp only [initialBond,List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem hi,Option.getD_some] + exact List.getElem_mem hi + +theorem initialEndpoint_bound (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (j : ℕ) (hj : j < 2*bs.length) : initialEndpoint bs j < n := by + have h := hb _ (initialBond_mem bs j hj) + unfold initialEndpoint + split + · exact h.1 + · exact h.2 + +theorem initialIndices_sum {M : Type*} [AddCommMonoid M] (bs : List Bond) (i : ℕ) + (f : ℕ → M) : ((initialIndices bs i).map f).sum = + ((List.range (2*bs.length)).map (fun j => + if initialEndpoint bs j=i then f j else 0)).sum := by + unfold initialIndices + generalize List.range (2*bs.length)=xs + induction xs with + | nil => rfl + | cons j xs ih => + by_cases h : initialEndpoint bs j=i <;> simp [h,ih] + +theorem initial_center_sum {M : Type*} [AddCommMonoid M] (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (j : Fin (2*bs.length)) (f : ℕ → ℕ → M) : + (∑ i : Fin n, if initialEndpoint bs j.val=i.val then f i.val j.val else 0) = + f (initialEndpoint bs j.val) j.val := by + let e : Fin n := ⟨initialEndpoint bs j.val,initialEndpoint_bound n bs hb j.val j.isLt⟩ + rw [Finset.sum_eq_single e] + · simp only [e,ite_true] + · intro i _ hi + exact ite_eq_right (fun h => hi (Fin.ext h.symm)) + · intro h + exact (h (Finset.mem_univ e)).elim + +theorem initial_group_sum {M : Type*} [AddCommMonoid M] (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (R : ℚ) (f : ℕ → Port → M) : + ((List.range n).map (fun i => ((initialGroup n bs R i).map (f i)).sum)).sum = + ((List.range (2*bs.length)).map (fun j => + f (initialEndpoint bs j) (n+j,initialWeight bs R j))).sum := by + simp only [initialGroup,List.map_map,Function.comp_def,initialIndices_sum,range_sum] + rw [Finset.sum_comm] + exact Finset.sum_congr rfl (fun j _ => + initial_center_sum n bs hb j (fun i k => f i (n+k,initialWeight bs R k))) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialWeights.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..6315092798c72cd20236ad666cec2393ee7ed932 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListInitialWeights.lean @@ -0,0 +1,131 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListIterateWeights +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathWeightBounds + +namespace OAI + +/-! The first odd subdivision satisfies the same polynomial envelope as +the subsequent fork rounds, with its actual rational coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem initialScale_abs_bound (bs : List Bond) (c N : ℚ) (hN : 0 ≤ N) + {M L T : ℝ} (hm : (bs.length:ℝ) ≤ M) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : |(c:ℝ)| ≤ L) + (hw : ∀ b ∈ bs, |(b.2.2:ℝ)| ≤ L) : + |(initialScale N bs c:ℝ)| ≤ forkRadius M L T := by + have hM : 0 ≤ M := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hn0 : 0 ≤ (N:ℝ) := by exact_mod_cast hN + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hlin : (∑ e : Fin bs.length, (1+2*|((bs.get e).2.2:ℝ)|)) ≤ M*(1+4*L) := by + calc + _ ≤ ∑ _e : Fin bs.length, (1+4*L) := + Finset.sum_le_sum (fun e _ => by linarith [hw (bs.get e) (List.get_mem bs e)]) + _ = (bs.length:ℝ)*(1+4*L) := by simp [mul_add] + _ ≤ M*(1+4*L) := mul_le_mul_of_nonneg_right hm (by positivity) + have hsq : (∑ e : Fin bs.length, (1+|((bs.get e).2.2:ℝ)|)^2) ≤ M*(1+2*L)^2 := by + calc + _ ≤ ∑ _e : Fin bs.length, (1+2*L)^2 := + Finset.sum_le_sum (fun e _ => pow_le_pow_left₀ (by positivity) + (by linarith [hw (bs.get e) (List.get_mem bs e)]) 2) + _ = (bs.length:ℝ)*(1+2*L)^2 := by simp + _ ≤ M*(1+2*L)^2 := mul_le_mul_of_nonneg_right hm (sq_nonneg _) + let A := 3*∑ e : Fin bs.length, (1+2*|((bs.get e).2.2:ℝ)|) + let D := |(c:ℝ)|+4*∑ e : Fin bs.length, (1+|((bs.get e).2.2:ℝ)|)^2 + have hAD0 : 0 ≤ A+D+1 := by dsimp [A,D]; positivity + have hextra : 0 ≤ 3*M*L+8*M*(1+2*L)^2 := by positivity + have hAD : A+D+1 ≤ forkBudget M L := by + dsimp only [A,D,forkBudget] + linarith + have hcube := pow_le_pow_left₀ hAD0 hAD 3 + rw [initialScale_cast] + change |16*(A+D+1)^3*(N:ℝ)+4*(A+D+1)+1| ≤ _ + rw [abs_of_nonneg (by positivity)] + have hnT : (N:ℝ) ≤ T := by simpa only [abs_of_nonneg hn0] using hT + have hprod := mul_le_mul hcube hnT hn0 (pow_nonneg (hAD0.trans hAD) 3) + dsimp only [forkRadius] + nlinarith + +theorem initial_coefficientBound (n : ℕ) (bs : List Bond) (c N : ℚ) (hN : 0 ≤ N) + {M L T : ℝ} (hm : (bs.length:ℝ) ≤ M) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : |(c:ℝ)| ≤ L) + (hw : ∀ b ∈ bs, |(b.2.2:ℝ)| ≤ L) : + CoefficientBound (initial n bs c N) (forkCoefficient M L T) := by + let P := forkRadius M L T + have hM : 0 ≤ M := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hB0 : 0 ≤ forkBudget M L := by unfold forkBudget; positivity + have hLP : L ≤ P := by + have hx : 0 ≤ 16*(forkBudget M L)^3*T := by positivity + dsimp [P,forkRadius] + linarith + have hP : 1 ≤ P := hL.trans hLP + have hP0 : 0 ≤ P := by linarith + have hR : |(initialScale N bs c:ℝ)| ≤ P := initialScale_abs_bound bs c N hN hm hL hT hc hw + have hR2 : (initialScale N bs c:ℝ)^2 ≤ P^2 := by + nlinarith [mul_self_le_mul_self (abs_nonneg _) hR,sq_abs (initialScale N bs c:ℝ)] + have hlarge : 2*P^2 ≤ forkCoefficient M L T := by + dsimp [forkCoefficient] + nlinarith [mul_nonneg hM (sq_nonneg P)] + have hPP : P ≤ 2*P^2 := by nlinarith + have hoff : (((bs.map (fun b => 3/4+3*b.2.2^2)).sum:ℚ):ℝ)= + ∑ e : Fin bs.length, qmaPathOffset ((bs.get e).2.2:ℝ) := by + rw [initial_list_sum] + push_cast + rfl + have hsum : |∑ e : Fin bs.length, qmaPathOffset ((bs.get e).2.2:ℝ)| ≤ + (bs.length:ℝ)*(4*P^2) := by + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _e : Fin bs.length, 4*P^2 := Finset.sum_le_sum (fun e _ => + qmaPathOffset_abs_le hP ((hw _ (List.get_mem _ _)).trans hLP)) + _ = _ := by simp + constructor + · have heq : ((initial n bs c N).2.2.1:ℝ)=(c:ℝ)+ + (∑ e : Fin bs.length, qmaPathOffset ((bs.get e).2.2:ℝ))+ + 3*(bs.length:ℝ)*(initialScale N bs c:ℝ)^2 := by + change ((c+(bs.map (fun b => 3/4+3*b.2.2^2)).sum+ + 3*(bs.length:ℚ)*(initialScale N bs c)^2:ℚ):ℝ)=_ + rw [Rat.cast_add,Rat.cast_add,hoff] + push_cast + rfl + rw [heq] + have ha := abs_add_le (c:ℝ) (∑ e : Fin bs.length, qmaPathOffset ((bs.get e).2.2:ℝ)) + have hb := abs_add_le ((c:ℝ)+(∑ e : Fin bs.length, qmaPathOffset ((bs.get e).2.2:ℝ))) + (3*(bs.length:ℝ)*(initialScale N bs c:ℝ)^2) + rw [abs_of_nonneg (by positivity : 0 ≤ 3*(bs.length:ℝ)*(initialScale N bs c:ℝ)^2)] at hb + have hprod := mul_le_mul_of_nonneg_left hR2 (Nat.cast_nonneg bs.length) + have hmprod := mul_le_mul_of_nonneg_right hm (sq_nonneg P) + dsimp only [forkCoefficient] + nlinarith [sq_nonneg P] + · intro b hb + obtain ⟨e,he,rfl⟩ := List.mem_map.mp hb + change |(((initialScale N bs c)^2:ℚ):ℝ)| ≤ _ + push_cast + rw [abs_of_nonneg (sq_nonneg _)] + exact hR2.trans ((by nlinarith [sq_nonneg P] : P^2 ≤ 2*P^2).trans hlarge) + · intro ps hps p hp + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hps + obtain ⟨j,hj,rfl⟩ := List.mem_map.mp hp + have hj' := (initialIndices_mem bs i j hj).1 + have hmem : initialBond bs j ∈ bs := by + have hq : j/2 L + | k+1 => forkCoefficient M (coefficientEnvelope M L T k) T + +theorem forkCoefficient_one_le {M L T : ℝ} (hM : 0 ≤ M) (hL : 1 ≤ L) : + 1 ≤ forkCoefficient M L T := by + have h : 0 ≤ (10*M+2)*(forkRadius M L T)^2 := by positivity + unfold forkCoefficient + linarith + +theorem coefficientEnvelope_one_le {M L T : ℝ} (hM : 0 ≤ M) (hL : 1 ≤ L) (k : ℕ) : + 1 ≤ coefficientEnvelope M L T k := by + induction k with + | zero => exact hL + | succ k ih => exact forkCoefficient_one_le hM ih + +theorem iterate_mass_le (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).2.1.length+portMass (iterate N k s).2.2.2 ≤ + s.2.1.length+(4*k+1)*portMass s.2.2.2 := by + have hb := iterate_bonds_le N s k + have hp := iterate_portMass_le N s k + calc + _ ≤ s.2.1.length+4*k*portMass s.2.2.2+portMass s.2.2.2 := Nat.add_le_add hb hp + _ = _ := by ring + +theorem iterate_coefficientBound (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) + (N : ℚ) (hN : 0 ≤ N) {M L T : ℝ} (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : CoefficientBound s L) (k : ℕ) + (hm : ((s.2.1.length+(4*k+1)*portMass s.2.2.2:ℕ):ℝ) ≤ M) : + CoefficientBound (iterate N k s) (coefficientEnvelope M L T k) := by + induction k with + | zero => exact hc + | succ k ih => + have hkle : s.2.1.length+(4*k+1)*portMass s.2.2.2 ≤ + s.2.1.length+(4*(k+1)+1)*portMass s.2.2.2 := by + exact Nat.add_le_add_left (Nat.mul_le_mul_right _ (by omega)) _ + have hcast : ((s.2.1.length+(4*k+1)*portMass s.2.2.2:ℕ):ℝ) ≤ + ((s.2.1.length+(4*(k+1)+1)*portMass s.2.2.2:ℕ):ℝ) := by exact_mod_cast hkle + have hm' := hcast.trans hm + have hM0 : 0 ≤ M := (Nat.cast_nonneg _).trans hm' + have hp := iterate_background_valid s hs hb hn N k + have hmass : (((iterate N k s).2.1.length+ + portMass (iterate N k s).2.2.2:ℕ):ℝ) ≤ + ((s.2.1.length+(4*k+1)*portMass s.2.2.2:ℕ):ℝ) := by + exact_mod_cast iterate_mass_le N s k + exact next_coefficientBound (iterate N k s) (iterate_validPorts N s hs k) N + hp.1 hp.2 hN (hmass.trans hm') + (coefficientEnvelope_one_le hM0 hL k) hT (ih hm') + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIteration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd5ec6cc95dc3c269fe42f044e65d0d475aa7ec7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListIteration.lean @@ -0,0 +1,38 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListNextBackground + +namespace OAI + +/-! Full-space accuracy of the repeated literal fork compiler. All port and +ordinary-bond hypotheses are propagated from its actual input lists. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumAxisSample +open scoped Classical + +theorem iterate_accuracy (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) (hN : 0 < N) (k : ℕ) : + |normalizedBottom (matrix (iterate N k s))-normalizedBottom (matrix s)| ≤ + (k:ℝ)/(N:ℝ) := by + induction k with + | zero => + rw [iterate] + rw [sub_self,abs_zero,Nat.cast_zero,zero_div] + | succ k ih => + have hv := iterate_background_valid s hs hb hn N k + have he := next_accuracy (iterate N k s) (iterate_validPorts N s hs k) + hv.1 hv.2 N hN + calc + _ ≤ |normalizedBottom (matrix (next N (iterate N k s)))- + normalizedBottom (matrix (iterate N k s))|+ + |normalizedBottom (matrix (iterate N k s))-normalizedBottom (matrix s)| := + abs_sub_le _ _ _ + _ ≤ 1/(N:ℝ)+(k:ℝ)/(N:ℝ) := add_le_add he ih + _ = ((k+1:ℕ):ℝ)/(N:ℝ) := by push_cast; ring + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..3eddb3febf95d947f09d3b3aecf8439b13c6cffc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListMatrix.lean @@ -0,0 +1,40 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListData +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorListCorrectness + +namespace OAI + +/-! The four literal bonds emitted for one port pair are exactly its +correction, singlet penalty and two outer couplings in the fork Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumRawExchange QuantumAxisSample + +def typedPairBonds (n r : ℕ) (e : Fin r) (a b : Fin n) (J K R : ℚ) : + List (TypedBond (n+r*2)) := + [(old n r a,old n r b,2*J*K), + (fresh n r e 0,fresh n r e 1,R^2), + (old n r a,fresh n r e 1,2*R*J), + (old n r b,fresh n r e 1,2*R*K)] + +theorem pairBonds_eq (n r : ℕ) (e : Fin r) (a b : Fin n) (J K R : ℚ) : + pairBonds n e.val R ((a.val,J),(b.val,K))= + (typedPairBonds n r e a b J K R).map erase := by + simp [pairBonds,typedPairBonds,erase,MediatorIteration.old_val, + MediatorIteration.fresh_val] + +theorem pairBonds_matrix (n r : ℕ) (e : Fin r) (a b : Fin n) (J K R : ℚ) : + ((pairBonds n e.val R ((a.val,J),(b.val,K))).map (rawBondMatrix (n+r*2))).sum = + ((2*J*K:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r a) (old n r b) + + (((R^2:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (fresh n r e 0) (fresh n r e 1) + + (((2*R*J:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r a) (fresh n r e 1) + + ((2*R*K:ℚ):ℂ) • sourceHeisenbergMatrix (n+r*2) (old n r b) (fresh n r e 1))) := by + rw [pairBonds_eq,List.map_map] + simp only [Function.comp_def,rawBondMatrix_erase,typedPairBonds,List.map_cons, + List.map_nil,List.sum_cons,List.sum_nil,typedBondMatrix,add_zero] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNext.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNext.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc9228f8f68ff27ddfe1c2bbba030ae60dd6f695 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNext.lean @@ -0,0 +1,118 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListPoints + +namespace OAI + +/-! A complete literal rational fork round, including all four background +bonds, the scalar offset and the remaining active ports. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +abbrev BondInput := ℕ × (ℕ × (ℚ × Pair)) +def bondInputCode : BondInput → List Bool := + prodCode Nat.bits (prodCode Nat.bits (prodCode ratCode pairCode)) +def bond (x : BondInput) (k : Fin 4) : MediatorListProgram.Bond := + ![(x.2.2.2.1.1,x.2.2.2.2.1,2*x.2.2.2.1.2*x.2.2.2.2.2), + (x.1+2*x.2.1,x.1+2*x.2.1+1,x.2.2.1^2), + (x.2.2.2.1.1,x.1+2*x.2.1+1,2*x.2.2.1*x.2.2.2.1.2), + (x.2.2.2.2.1,x.1+2*x.2.1+1,2*x.2.2.1*x.2.2.2.2.2)] k + +noncomputable def bondProgram (k : Fin 4) : + Procedure bondInputCode MediatorListProgram.bondCode (fun x => bond x k) := by + let n := Procedure.first Nat.bits (prodCode Nat.bits (prodCode ratCode pairCode)) + let tail := Procedure.second Nat.bits (prodCode Nat.bits (prodCode ratCode pairCode)) + let i := (Procedure.first Nat.bits (prodCode ratCode pairCode)).comp tail + let rest := (Procedure.second Nat.bits (prodCode ratCode pairCode)).comp tail + let r := (Procedure.first ratCode pairCode).comp rest + let p := (Procedure.second ratCode pairCode).comp rest + let a := (Procedure.first Nat.bits ratCode).comp ((Procedure.first portCode portCode).comp p) + let b := (Procedure.first Nat.bits ratCode).comp ((Procedure.second portCode portCode).comp p) + let j := leftWeight.comp p + let q := rightWeight.comp p + let two := Procedure.constant bondInputCode ratCode 2 + let twiceI := Procedure.binaryMul.comp ((Procedure.constant bondInputCode Nat.bits 2).pair i) + let first := Procedure.binaryAdd.comp (n.pair twiceI) + let second := Procedure.successor.comp first + refine Fin.cases ?_ (fun k => ?_) k + · exact a.pair (b.pair (Procedure.ratMul.comp ((Procedure.ratMul.comp (two.pair j)).pair q))) + · refine Fin.cases ?_ (fun k => ?_) k + · exact first.pair (second.pair (QuantumRoutingCode.squareProgram r)) + · refine Fin.cases ?_ (fun k => ?_) k + · exact a.pair (second.pair (Procedure.ratMul.comp ((Procedure.ratMul.comp (two.pair r)).pair j))) + · refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact b.pair (second.pair (Procedure.ratMul.comp ((Procedure.ratMul.comp (two.pair r)).pair q))) + +noncomputable def pairBondsProgram : Procedure bondInputCode (listCode MediatorListProgram.bondCode) + (fun x => pairBonds x.1 x.2.1 x.2.2.1 x.2.2.2) := + (QuantumRawExchange.fixedListProgram bondInputCode MediatorListProgram.bondCode 4 + (fun k x => bond x k) bondProgram).congrFun (by + intro x + simp [bond,pairBonds,List.ofFn_succ]) + +noncomputable def addedBondInputProgram : + Procedure (prodCode unaryCode scaleCode) bondInputCode + (fun x => (x.2.2.1,x.1,x.2.1, + (((catalog x.2.2.2.2.2).drop x.1).headD (0,((0,0),(0,0)))).2)) := by + let i := Procedure.unaryToBits.comp (Procedure.first unaryCode scaleCode) + let env := Procedure.second unaryCode scaleCode + let r := (Procedure.first ratCode stateCode).comp env + let s := (Procedure.second ratCode stateCode).comp env + let n := Procedure.unaryToBits.comp (countProgram.comp s) + let ps := catalogProgram.comp (groupsProgram.comp s) + let selected := (Procedure.second Nat.bits pairCode).comp + ((Procedure.listGet taggedCode (0,((0,0),(0,0)))).comp (i.pair ps)) + exact n.pair (i.pair (r.pair selected)) + +noncomputable def addedBondsProgram : Procedure scaleCode (listCode MediatorListProgram.bondCode) + (fun x => addedBonds x.2 x.1) := by + let s := Procedure.second ratCode stateCode + let count := pairCountProgram.comp (groupsProgram.comp s) + let block := pairBondsProgram.comp addedBondInputProgram + let tab := Procedure.tabulate (f := fun (x : ScaleInput) i => pairBonds x.2.1 i x.1 + (((catalog x.2.2.2.2).drop i).headD (0,((0,0),(0,0)))).2) [] block + exact ((QuantumRawExchange.flattenProgram MediatorListProgram.bondCode (0,0,0)).comp + (tab.comp (count.pair (Procedure.identity scaleCode)))).congrFun (by + intro x + simp only [Function.comp_apply,addedBonds,catalog_length] + rfl) + +noncomputable def nextProgram : Procedure scaleCode stateCode (fun x => next x.1 x.2) := by + let s := Procedure.second ratCode stateCode + let n := countProgram.comp s + let gs := groupsProgram.comp s + let count := pairCountProgram.comp gs + let r := scaleProgram + let nextCount := Procedure.unaryAdd.comp (n.pair (Procedure.unaryAdd.comp (count.pair count))) + let nextBonds := (Procedure.listAppend MediatorListProgram.bondCode (0,0,0)).comp + ((bondsProgram.comp s).pair (addedBondsProgram.comp (r.pair s))) + let pairs := (Procedure.listMap (0,((0,0),(0,0))) ((0,0),(0,0)) + (Procedure.second Nat.bits pairCode)).comp (catalogProgram.comp gs) + let offsets := RationalSumProgram.sumProgram.comp + ((Procedure.listMap ((0,0),(0,0)) 0 pairOffsetProgram).comp pairs) + let countRat := Procedure.natToRat.comp (Procedure.unaryToBits.comp count) + let singlets := Procedure.ratMul.comp + ((Procedure.ratMul.comp ((Procedure.constant scaleCode ratCode 3).pair countRat)).pair + (QuantumRoutingCode.squareProgram r)) + let nextScalar := Procedure.ratAdd.comp + ((Procedure.ratAdd.comp ((scalarProgram.comp s).pair offsets)).pair singlets) + let nextGroups := nextGroupsProgram.comp ((Procedure.unaryToBits.comp n).pair (r.pair gs)) + exact (nextCount.pair (nextBonds.pair (nextScalar.pair nextGroups))).congrFun (by + intro x + dsimp only [Function.comp_apply,next] + rw [two_mul] + rfl) + +noncomputable def iterateProgram : (D : ℕ) → + Procedure scaleCode stateCode (fun x => iterate x.1 D x.2) + | 0 => Procedure.second ratCode stateCode + | D+1 => (nextProgram.comp + ((Procedure.first ratCode stateCode).pair (iterateProgram D))).congrFun (by + intro x + rfl) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextBackground.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextBackground.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cbc2f5ad08199706bd180aacef7a37bdfdc55ed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextBackground.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListNextValid + +namespace OAI + +/-! Bounded, loop-free ordinary bonds survive the actual list transformation. +Together with port separation this supplies every hypothesis of the next +full-space fork comparison. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram + +theorem unpairedBonds_valid {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (b : Bond) (hb : b ∈ unpairedBonds gs) : b.1 < n ∧ b.2.1 < n ∧ b.1 ≠ b.2.1 := by + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hb + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' := List.mem_range.mp hi + obtain ⟨p,hp,rfl⟩ := List.mem_map.mp hb + have hp' : p ∈ groupAt gs i := List.mem_of_mem_drop hp + obtain ⟨j,hj,hp⟩ := List.getElem_of_mem hp' + have he : portAt (groupAt gs i) j=p := (portAt_eq_getElem _ _ hj).trans hp + have hbound := h.bounded ⟨i,hi'⟩ ⟨j,hj⟩ + have hne := h.disjoint ⟨i,hi'⟩ ⟨i,hi'⟩ ⟨j,hj⟩ + rw [he] at hbound hne + exact ⟨lt_of_lt_of_le hi' h.centers,hbound,hne⟩ + +theorem pairBonds_valid (n r i a b : ℕ) (R J K : ℚ) + (hi : i < r) (ha : a < n) (hb : b < n) (hab : a ≠ b) + (e : Bond) (he : e ∈ pairBonds n i R ((a,J),(b,K))) : + e.1 < n+2*r ∧ e.2.1 < n+2*r ∧ e.1 ≠ e.2.1 := by + simp only [pairBonds,List.mem_cons,List.not_mem_nil,or_false] at he + rcases he with rfl | rfl | rfl | rfl <;> dsimp only <;> omega + +theorem addedBonds_valid (s : State) (h : ValidPorts s.1 s.2.2.2) (R : ℚ) + (b : Bond) (hb : b ∈ addedBonds s R) : + b.1 < s.1+2*pairCount s.2.2.2 ∧ b.2.1 < s.1+2*pairCount s.2.2.2 ∧ + b.1 ≠ b.2.1 := by + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hb + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' : i < pairCount s.2.2.2 := by + simpa only [catalog_length] using List.mem_range.mp hi + rw [catalog_actualSite h ⟨i,hi'⟩] at hb + have hne : actualSite h ⟨i,hi'⟩ 1 ≠ actualSite h ⟨i,hi'⟩ 2 := by + intro he + have := actualSite_injective h ⟨i,hi'⟩ he + norm_num at this + exact pairBonds_valid s.1 (pairCount s.2.2.2) i _ _ R _ _ hi' + (actualSite h ⟨i,hi'⟩ 1).isLt (actualSite h ⟨i,hi'⟩ 2).isLt + (fun he => hne (Fin.ext he)) b hb + +theorem next_background_valid (s : State) (h : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) : + SourceBondLists.bounded (next N s).1 (background (next N s)) ∧ + ∀ b ∈ background (next N s), b.1 ≠ b.2.1 := by + have hv : ∀ b ∈ background (next N s), + b.1 < (next N s).1 ∧ b.2.1 < (next N s).1 ∧ b.1 ≠ b.2.1 := by + intro b hmem + change b ∈ (s.2.1++addedBonds s (scale N s))++unpairedBonds (next N s).2.2.2 at hmem + rcases List.mem_append.mp hmem with hold | hport + · rcases List.mem_append.mp hold with hold | hnew + · have hm : b ∈ background s := List.mem_append_left _ hold + have hbb := hb b hm + have hnn := hn b hm + rw [next_count] + exact ⟨lt_of_lt_of_le hbb.1 (Nat.le_add_right _ _), + lt_of_lt_of_le hbb.2 (Nat.le_add_right _ _),hnn⟩ + · exact addedBonds_valid s h (scale N s) b hnew + · exact unpairedBonds_valid (next_validPorts N s h) b hport + exact ⟨fun b hm => ⟨(hv b hm).1,(hv b hm).2.1⟩,fun b hm => (hv b hm).2.2⟩ + +theorem iterate_background_valid (s : State) (h : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) (k : ℕ) : + SourceBondLists.bounded (iterate N k s).1 (background (iterate N k s)) ∧ + ∀ b ∈ background (iterate N k s), b.1 ≠ b.2.1 := by + induction k with + | zero => exact ⟨hb,hn⟩ + | succ k ih => + exact next_background_valid _ (iterate_validPorts N s h k) ih.1 ih.2 N + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..6159f15d28e4aa2039601b6f3944a0ce86eefd2b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextDegree.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListOuter + +namespace OAI + +/-! The literal fork transformation preserves the ordinary degree bound, +isolated centers, and degree-one active ports. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph +open scoped Classical + +theorem next_degreeBounds (N : ℚ) (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hd : DegreeBounds s) : + DegreeBounds (next N s) := by + let left := (SourceBondLists.bonds s.1 s.2.1 hb).left + let right := (SourceBondLists.bonds s.1 s.2.1 hb).right + have hbase (v : Fin s.1) : qmaGraphDegree left right v ≤ 3 := by + rw [← degree_eq_graph] + exact hd.ordinary v + have hport (e : Fin (pairCount s.2.2.2)) (b : Fin 2) : + qmaGraphDegree left right (qmaForkOuter (actualSite hs) (e,b)) ≤ 1 := by + rw [← degree_eq_graph,actual_outer_eq] + exact hd.port (outerPort s.2.2.2 (e,b)).1 (outerPort s.2.2.2 (e,b)).2 + refine ⟨?_,?_,?_⟩ + · intro v + have hv : v.val < s.1+pairCount s.2.2.2*2 := by have := v.isLt; change _ (p.1.val,p.2.val)) + (pairIndex_injective gs hp) + exact Prod.mk.inj hv + · have ho := retained_index_lt (groupAt gs k).length l hl (by omega) + rw [nextGroup_portAt_retained n R gs k l (by omega)] at he + have hb := h.bounded ⟨k,hk⟩ ⟨_,ho⟩ + dsimp only at he hb + omega + · have ho := retained_index_lt (groupAt gs i).length j hj (by omega) + rw [nextGroup_portAt_retained n R gs i j (by omega)] at he + by_cases hg : l < (groupAt gs k).length/2 + · rw [nextGroup_portAt_fresh n R gs k l hg] at he + have hb := h.bounded ⟨i,hi⟩ ⟨_,ho⟩ + dsimp only at he hb + omega + · have hp := retained_index_lt (groupAt gs k).length l hl (by omega) + rw [nextGroup_portAt_retained n R gs k l (by omega)] at he + have hh := h.injective ⟨i,hi⟩ ⟨k,hk⟩ ⟨_,ho⟩ ⟨_,hp⟩ he + have hik : i=k := congrArg Fin.val hh.1 + refine ⟨hik,?_⟩ + subst k + dsimp only at hh + omega + +theorem next_validPorts (N : ℚ) (s : State) (h : ValidPorts s.1 s.2.2.2) : + ValidPorts (next N s).1 (next N s).2.2.2 := by + constructor + · rw [next_centers,next_count] + exact le_trans h.centers (Nat.le_add_right _ _) + · intro i j + have hi : i.val < s.2.2.2.length := by simpa only [next_centers] using i.isLt + have hj : j.val < (nextGroup s.1 (scale N s) s.2.2.2 i.val).length := by + simpa only [next,next_groupAt _ _ _ _ hi] using j.isLt + change (portAt (groupAt ((List.range s.2.2.2.length).map + (nextGroup s.1 (scale N s) s.2.2.2)) i.val) j.val).1 < _ + rw [next_groupAt _ _ _ _ hi] + exact nextGroup_bounded h (scale N s) i.val j.val hi hj + · intro i k j + have hi : i.val < s.2.2.2.length := by simpa only [next_centers] using i.isLt + have hk : k.val < s.2.2.2.length := by simpa only [next_centers] using k.isLt + have hj : j.val < (nextGroup s.1 (scale N s) s.2.2.2 k.val).length := by + simpa only [next,next_groupAt _ _ _ _ hk] using j.isLt + change i.val ≠ (portAt (groupAt ((List.range s.2.2.2.length).map + (nextGroup s.1 (scale N s) s.2.2.2)) k.val) j.val).1 + rw [next_groupAt _ _ _ _ hk] + exact nextGroup_disjoint h (scale N s) i.val k.val j.val hi hk hj + · intro i k j l he + have hi : i.val < s.2.2.2.length := by simpa only [next_centers] using i.isLt + have hk : k.val < s.2.2.2.length := by simpa only [next_centers] using k.isLt + have hj : j.val < (nextGroup s.1 (scale N s) s.2.2.2 i.val).length := by + simpa only [next,next_groupAt _ _ _ _ hi] using j.isLt + have hl : l.val < (nextGroup s.1 (scale N s) s.2.2.2 k.val).length := by + simpa only [next,next_groupAt _ _ _ _ hk] using l.isLt + change (portAt (groupAt ((List.range s.2.2.2.length).map + (nextGroup s.1 (scale N s) s.2.2.2)) i.val) j.val).1= + (portAt (groupAt ((List.range s.2.2.2.length).map + (nextGroup s.1 (scale N s) s.2.2.2)) k.val) l.val).1 at he + rw [next_groupAt _ _ _ _ hi,next_groupAt _ _ _ _ hk] at he + obtain ⟨hik,hjl⟩ := nextGroup_injective h (scale N s) i.val k.val j.val l.val + hi hk hj hl he + exact ⟨Fin.ext hik,hjl⟩ + +theorem iterate_validPorts (N : ℚ) (s : State) (h : ValidPorts s.1 s.2.2.2) + (k : ℕ) : ValidPorts (iterate N k s).1 (iterate N k s).2.2.2 := by + induction k with + | zero => exact h + | succ k ih => exact next_validPorts N _ ih + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextWeights.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..48f31f9110147dff05516bf661dc37913eb3d818 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListNextWeights.lean @@ -0,0 +1,140 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListWeights +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkWeightBounds + +namespace OAI + +/-! The emitted ordinary bonds, active ports and constant have one explicit +polynomial envelope. The bound applies to the literal rational transition. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem two_mul_abs_le {a b P : ℝ} (hP : 0 ≤ P) (ha : |a| ≤ P) (hb : |b| ≤ P) : + |2*a*b| ≤ 2*P^2 := by + rw [abs_mul,abs_mul,abs_of_nonneg (by norm_num : (0:ℝ) ≤ 2)] + have h := mul_le_mul ha hb (abs_nonneg b) hP + nlinarith + +theorem pairBonds_abs_le (n i : ℕ) (R : ℚ) (p : Pair) {P : ℝ} + (hP : 0 ≤ P) (hR : |(R:ℝ)| ≤ P) + (hJ : |(p.1.2:ℝ)| ≤ P) (hK : |(p.2.2:ℝ)| ≤ P) + (b : Bond) (hb : b ∈ pairBonds n i R p) : |(b.2.2:ℝ)| ≤ 2*P^2 := by + simp only [pairBonds,List.mem_cons,List.not_mem_nil,or_false] at hb + rcases hb with rfl | rfl | rfl | rfl + · push_cast + exact two_mul_abs_le hP hJ hK + · push_cast + rw [abs_of_nonneg (sq_nonneg _)] + have h := mul_self_le_mul_self (abs_nonneg (R:ℝ)) hR + nlinarith [sq_abs (R:ℝ)] + · push_cast + exact two_mul_abs_le hP hR hJ + · push_cast + exact two_mul_abs_le hP hR hK + +theorem next_scalar_abs_le (s : State) (N : ℚ) {L P : ℝ} + (hc : CoefficientBound s L) (hP : 1 ≤ P) (hLP : L ≤ P) + (hR : |(scale N s:ℝ)| ≤ P) : + |((next N s).2.2.1:ℝ)| ≤ L+10*(pairCount s.2.2.2:ℝ)*P^2 := by + have hP0 : 0 ≤ P := by linarith + have hoff : ((((catalog s.2.2.2).map Prod.snd).map pairOffset).sum:ℝ) = + ∑ e : Fin (pairCount s.2.2.2), + qmaForkOffset (actualJ s.2.2.2 e:ℝ) (actualK s.2.2.2 e:ℝ) := by + change (((((catalog s.2.2.2).map Prod.snd).map + (fun p => 3/4+3*p.1.2^2+3*p.2.2^2)).sum:ℚ):ℝ)=_ + rw [catalog_weights_sum s.2.2.2 (fun J K => 3/4+3*J^2+3*K^2)] + push_cast + rfl + have hsum : |∑ e : Fin (pairCount s.2.2.2), + qmaForkOffset (actualJ s.2.2.2 e:ℝ) (actualK s.2.2.2 e:ℝ)| ≤ + (pairCount s.2.2.2:ℝ)*(7*P^2) := by + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _e : Fin (pairCount s.2.2.2), 7*P^2 := + Finset.sum_le_sum (fun e _ => qmaForkOffset_abs_le hP + ((hc.actualJ s e).trans hLP) ((hc.actualK s e).trans hLP)) + _ = _ := by simp + have hR2 : (scale N s:ℝ)^2 ≤ P^2 := by + nlinarith [mul_self_le_mul_self (abs_nonneg (scale N s:ℝ)) hR,sq_abs (scale N s:ℝ)] + have heq : ((next N s).2.2.1:ℝ)=(s.2.2.1:ℝ)+ + (∑ e : Fin (pairCount s.2.2.2), + qmaForkOffset (actualJ s.2.2.2 e:ℝ) (actualK s.2.2.2 e:ℝ))+ + 3*(pairCount s.2.2.2:ℝ)*(scale N s:ℝ)^2 := by + change ((s.2.2.1+(((catalog s.2.2.2).map Prod.snd).map pairOffset).sum+ + 3*(pairCount s.2.2.2:ℚ)*(scale N s)^2:ℚ):ℝ)=_ + rw [Rat.cast_add,Rat.cast_add,hoff] + push_cast + rfl + rw [heq] + have ha := abs_add_le (s.2.2.1:ℝ) (∑ e : Fin (pairCount s.2.2.2), + qmaForkOffset (actualJ s.2.2.2 e:ℝ) (actualK s.2.2.2 e:ℝ)) + have hb := abs_add_le ((s.2.2.1:ℝ)+(∑ e : Fin (pairCount s.2.2.2), + qmaForkOffset (actualJ s.2.2.2 e:ℝ) (actualK s.2.2.2 e:ℝ))) + (3*(pairCount s.2.2.2:ℝ)*(scale N s:ℝ)^2) + rw [abs_of_nonneg (by positivity : 0 ≤ 3*(pairCount s.2.2.2:ℝ)*(scale N s:ℝ)^2)] at hb + nlinarith [hc.scalar,mul_le_mul_of_nonneg_left hR2 + (by positivity : 0 ≤ (pairCount s.2.2.2:ℝ))] + +theorem next_coefficientBound (s : State) (hs : ValidPorts s.1 s.2.2.2) (N : ℚ) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (hN : 0 ≤ N) + {M L T : ℝ} (hM : ((s.2.1.length+portMass s.2.2.2:ℕ):ℝ) ≤ M) + (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) (hc : CoefficientBound s L) : + CoefficientBound (next N s) (forkCoefficient M L T) := by + let P := forkRadius M L T + have hM0 : 0 ≤ M := (Nat.cast_nonneg _).trans hM + have hL0 : 0 ≤ L := by linarith + have hT0 : 0 ≤ T := (abs_nonneg _).trans hT + have hB0 : 0 ≤ forkBudget M L := by unfold forkBudget; positivity + have hLP : L ≤ P := by + have hx : 0 ≤ 16*(forkBudget M L)^3*T := by positivity + dsimp [P,forkRadius] + linarith + have hP : 1 ≤ P := hL.trans hLP + have hP0 : 0 ≤ P := by linarith + have hR : |(scale N s:ℝ)| ≤ P := scale_abs_bound s hb hn N hN hM hL hT hc + have hp : (pairCount s.2.2.2:ℝ) ≤ M := by + refine le_trans ?_ hM + exact_mod_cast (show pairCount s.2.2.2 ≤ s.2.1.length+portMass s.2.2.2 by + have := pairCount_le_portMass s.2.2.2 + omega) + have hlarge : 2*P^2 ≤ forkCoefficient M L T := by + dsimp [forkCoefficient] + nlinarith [mul_nonneg hM0 (sq_nonneg P)] + have hPL : P ≤ forkCoefficient M L T := by + have hPP : P ≤ P^2 := by nlinarith + calc + P ≤ P^2 := hPP + _ ≤ 2*P^2 := by nlinarith [sq_nonneg P] + _ ≤ _ := hlarge + constructor + · have h := next_scalar_abs_le s N hc hP hLP hR + have hm := mul_le_mul_of_nonneg_right hp (sq_nonneg P) + dsimp [forkCoefficient] + nlinarith [sq_nonneg P] + · intro b hmem + change b ∈ s.2.1++addedBonds s (scale N s) at hmem + rcases List.mem_append.mp hmem with hold | hnew + · exact (hc.ordinary b hold).trans (hLP.trans hPL) + obtain ⟨bs,hbs,hnew⟩ := List.mem_flatten.mp hnew + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' : i < pairCount s.2.2.2 := by + simpa only [catalog_length] using List.mem_range.mp hi + rw [catalog_actualSite hs ⟨i,hi'⟩] at hnew + exact (pairBonds_abs_le s.1 i (scale N s) _ hP0 hR + ((hc.actualJ s _).trans hLP) ((hc.actualK s _).trans hLP) b hnew).trans hlarge + · intro ps hps p hp + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hps + rcases List.mem_append.mp hp with hfresh | hold + · obtain ⟨j,hj,rfl⟩ := List.mem_map.mp hfresh + exact hR.trans hPL + · exact (hc.active _ (groupAt_mem _ _ (List.mem_range.mp hi)) _ + (List.mem_of_mem_drop hold)).trans (hLP.trans hPL) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOrdinal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOrdinal.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a36e9f63cb6d45c1dbc40c2318295581fa8e3b1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOrdinal.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListIndex + +namespace OAI + +/-! The explicit prefix index is a bijection between center-local pairs and +the consecutive mediator numbers used by the literal compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open scoped BigOperators Classical + +abbrev LocalPair (gs : Groups) := Σ i : Fin gs.length, Fin ((groupAt gs i.val).length/2) + +def pairIndex (gs : Groups) (p : LocalPair gs) : Fin (pairCount gs) := + ⟨pairStart gs p.1.val+p.2.val,pair_index_lt gs p.1.val p.2.val p.1.isLt p.2.isLt⟩ + +theorem pairIndex_injective (gs : Groups) : Function.Injective (pairIndex gs) := by + intro p q h + have hp := catalog_getElem? gs p.1.val p.2.val p.1.isLt p.2.isLt + have hq := catalog_getElem? gs q.1.val q.2.val q.1.isLt q.2.isLt + have hn : pairStart gs p.1.val+p.2.val=pairStart gs q.1.val+q.2.val := congrArg Fin.val h + rw [hn,hq] at hp + have hc : p.1=q.1 := Fin.ext (congrArg Prod.fst (Option.some.inj hp)).symm + rcases p with ⟨i,j⟩ + rcases q with ⟨k,l⟩ + dsimp only at hc + subst k + have hj : j=l := Fin.ext (by dsimp only at hn; omega) + subst l + rfl + +theorem localPair_card (gs : Groups) : Fintype.card (LocalPair gs)=pairCount gs := by + simp only [LocalPair,Fintype.card_sigma,Fintype.card_fin] + have hlist : List.ofFn (fun i : Fin gs.length => (groupAt gs i.val).length/2) = + gs.map (fun ps => ps.length/2) := by + apply List.ext_getElem + · simp + · intro i hi hj + have hi' : i < gs.length := by simpa only [List.length_ofFn] using hi + simp only [List.getElem_ofFn,List.getElem_map,groupAt,List.headD_eq_head?_getD, + List.head?_drop,List.getElem?_eq_getElem hi',Option.getD_some] + rw [← List.sum_ofFn,hlist] + rfl + +def pairEquiv (gs : Groups) : LocalPair gs ≃ Fin (pairCount gs) := + Equiv.ofBijective (pairIndex gs) ((Fintype.bijective_iff_injective_and_card _).2 + ⟨pairIndex_injective gs,by rw [Fintype.card_fin,localPair_card]⟩) + +theorem pairEquiv_val (gs : Groups) (p : LocalPair gs) : + (pairEquiv gs p).val=pairStart gs p.1.val+p.2.val := rfl + +theorem catalog_pairEquiv (gs : Groups) (p : LocalPair gs) : + ((catalog gs).drop (pairEquiv gs p).val).headD (0,((0,0),(0,0))) = + (p.1.val,(portAt (groupAt gs p.1.val) (2*p.2.val), + portAt (groupAt gs p.1.val) (2*p.2.val+1))) := + catalog_headD gs p.1.val p.2.val p.1.isLt p.2.isLt + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOuter.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOuter.lean new file mode 100644 index 0000000000000000000000000000000000000000..a19f448086fbeb88ae7f83d360b9c9a20a4932a4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOuter.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListDegree + +namespace OAI + +/-! Paired outer ports form an injective family. The explicit local-pair +numbering therefore meets the simultaneous-fork degree hypotheses. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open scoped Classical + +def outerPort (gs : Groups) (p : Fin (pairCount gs) × Fin 2) : + Σ i : Fin gs.length, Fin (groupAt gs i.val).length := + ⟨(localPair gs p.1).1, + ⟨2*(localPair gs p.1).2.val+p.2.val,by + have := (localPair gs p.1).2.isLt + have := p.2.isLt + omega⟩⟩ + +theorem outerPort_injective (gs : Groups) : Function.Injective (outerPort gs) := by + rintro ⟨e,b⟩ ⟨f,c⟩ h + have hi : (localPair gs e).1=(localPair gs f).1 := congrArg (fun q : (Σ i : Fin gs.length, Fin (groupAt gs i.val).length) => q.1) h + have hj : 2*(localPair gs e).2.val+b.val=2*(localPair gs f).2.val+c.val := + congrArg (fun p => p.2.val) h + have hb := b.isLt + have hc := c.isLt + have heq : localPair gs e=localPair gs f := by + apply Sigma.ext hi + exact (Fin.heq_ext_iff (congrArg (fun i : Fin gs.length => (groupAt gs i.val).length/2) hi)).2 (by omega) + have hef : e=f := (pairEquiv gs).symm.injective heq + have hbc : b=c := Fin.ext (by omega) + exact Prod.ext hef hbc + +theorem actual_outer_eq {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (p : Fin (pairCount gs) × Fin 2) : + (qmaForkOuter (actualSite h) p).val= + (portAt (groupAt gs (outerPort gs p).1.val) (outerPort gs p).2.val).1 := by + rcases p with ⟨e,b⟩ + fin_cases b <;> rfl + +theorem actual_outer_injective {n : ℕ} {gs : Groups} (h : ValidPorts n gs) : + Function.Injective (qmaForkOuter (actualSite h)) := by + intro p q hpq + have hv := congrArg Fin.val hpq + rw [actual_outer_eq,actual_outer_eq] at hv + have he := h.injective (outerPort gs p).1 (outerPort gs q).1 + (outerPort gs p).2 (outerPort gs q).2 hv + apply outerPort_injective gs + apply Sigma.ext he.1 + exact (Fin.heq_ext_iff (congrArg (fun i : Fin gs.length => (groupAt gs i.val).length) he.1)).2 he.2 + +theorem outerPort_index_lt (gs : Groups) (p : Fin (pairCount gs) × Fin 2) : + (outerPort gs p).2.val < 2*((groupAt gs (outerPort gs p).1.val).length/2) := by + have hp := (localPair gs p.1).2.isLt + have hb := p.2.isLt + dsimp only [outerPort] + omega + +theorem actual_outer_away_retained {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (i : Fin gs.length) (j : Fin (groupAt gs i.val).length) + (hj : 2*((groupAt gs i.val).length/2) ≤ j.val) + (p : Fin (pairCount gs) × Fin 2) : + qmaForkOuter (actualSite h) p ≠ + ⟨(portAt (groupAt gs i.val) j.val).1,h.bounded i j⟩ := by + intro he + have hv := congrArg Fin.val he + rw [actual_outer_eq] at hv + have hh := h.injective (outerPort gs p).1 i (outerPort gs p).2 j hv + have hl := outerPort_index_lt gs p + have hlen := congrArg (fun i : Fin gs.length => 2*((groupAt gs i.val).length/2)) hh.1 + rw [hlen] at hl + omega + +theorem actual_outer_away_center {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (i : Fin gs.length) (e : Fin (pairCount gs)) : + actualSite h e 1 ≠ ⟨i.val,lt_of_lt_of_le i.isLt h.centers⟩ ∧ + actualSite h e 2 ≠ ⟨i.val,lt_of_lt_of_le i.isLt h.centers⟩ := by + constructor + · intro he + exact h.disjoint i (localPair gs e).1 (localFirst gs e) (congrArg Fin.val he).symm + · intro he + exact h.disjoint i (localPair gs e).1 (localSecond gs e) (congrArg Fin.val he).symm + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOutputBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOutputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..29a1f1dbebbd0e5f53f60c2f46755f77fc5f9bfb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListOutputBounds.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialWeights + +namespace OAI + +/-! A single explicit coefficient envelope for every edge in the actual +output, including the retained active-star edges, and for its scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram + +theorem CoefficientBound.full (s : State) {L : ℝ} (h : CoefficientBound s L) + (b : Bond) (hb : b ∈ s.2.1++activeBonds s.2.2.2) : |(b.2.2:ℝ)| ≤ L := by + rcases List.mem_append.mp hb with hold | hnew + · exact h.ordinary b hold + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hnew + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + obtain ⟨p,hp,rfl⟩ := List.mem_map.mp hb + exact h.active _ (groupAt_mem _ _ (List.mem_range.mp hi)) _ hp + +def outputCoefficient (m D : ℕ) (L T : ℝ) : ℝ := + let M : ℝ := ((8*D+3)*m:ℕ) + coefficientEnvelope M (forkCoefficient M L T) T D + +theorem initial_iterate_coefficientBound (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (c N : ℚ) (hN : 0 ≤ N) + {L T : ℝ} (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) + (hc : |(c:ℝ)| ≤ L) (hw : ∀ b ∈ bs, |(b.2.2:ℝ)| ≤ L) (D : ℕ) : + CoefficientBound (iterate N D (initial n bs c N)) (outputCoefficient bs.length D L T) := by + let M : ℝ := ((8*D+3)*bs.length:ℕ) + have hM0 : 0 ≤ M := Nat.cast_nonneg _ + have hm : (bs.length:ℝ) ≤ M := by + have hn : bs.length ≤ (8*D+3)*bs.length := by + simpa only [one_mul] using + (Nat.mul_le_mul_right bs.length (by omega : 1 ≤ 8*D+3)) + dsimp only [M] + exact_mod_cast hn + have hi := initial_coefficientBound n bs c N hN hm hL hT hc hw + have hv := initial_background_valid n bs c N + have hmass : ((((initial n bs c N).2.1.length+ + (4*D+1)*portMass (initial n bs c N).2.2.2):ℕ):ℝ) ≤ M := by + rw [initial_portMass n bs hb c N] + have hlen : (initial n bs c N).2.1.length=bs.length := by + simp only [initial,List.length_map,List.length_range] + rw [hlen] + dsimp only [M] + exact_mod_cast (show bs.length+(4*D+1)*(2*bs.length) ≤ (8*D+3)*bs.length from + le_of_eq (by ring)) + exact iterate_coefficientBound _ (initial_validPorts n bs c N) hv.1 hv.2 N hN + (forkCoefficient_one_le hM0 hL) hT hi D hmass + +theorem initial_iterate_full_weight (n : ℕ) (bs : List Bond) + (hb : SourceBondLists.bounded n bs) (c N : ℚ) (hN : 0 ≤ N) + {L T : ℝ} (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) + (hc : |(c:ℝ)| ≤ L) (hw : ∀ b ∈ bs, |(b.2.2:ℝ)| ≤ L) (D : ℕ) + (b : Bond) (hmem : b ∈ (iterate N D (initial n bs c N)).2.1++ + activeBonds (iterate N D (initial n bs c N)).2.2.2) : + |(b.2.2:ℝ)| ≤ outputCoefficient bs.length D L T := + (initial_iterate_coefficientBound n bs hb c N hN hL hT hc hw D).full _ b hmem + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPartition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..9593c6c9324f37484171ddd166b904fc2f4e5bc5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPartition.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListData + +namespace OAI + +/-! Adjacent pairing partitions the actual port lists without reordering or +dropping the odd final port. These identities connect the list compiler to the +full active-star Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList + +theorem pairs_nil : pairs [] = [] := rfl +theorem pairs_singleton (a : Port) : pairs [a] = [] := by simp [pairs] + +theorem pairs_cons_cons (a b : Port) (ps : List Port) : + pairs (a::b::ps) = (a,b)::pairs ps := by + have hl : (a::b::ps).length/2=ps.length/2+1 := by simp only [List.length_cons]; omega + unfold pairs + rw [hl,List.range_succ_eq_map,List.map_cons,List.map_map] + congr 1 + +theorem unpaired_cons_cons (a b : Port) (ps : List Port) : + unpaired (a::b::ps)=unpaired ps := by + have hl : (a::b::ps).length/2=ps.length/2+1 := by simp only [List.length_cons]; omega + unfold unpaired + rw [hl] + have he : 2*(ps.length/2+1)=2*(ps.length/2)+2 := by omega + rw [he] + rfl + +theorem pairs_partition (ps : List Port) : + (pairs ps).flatMap (fun p => [p.1,p.2]) ++ unpaired ps=ps := by + induction ps using List.twoStepInduction with + | nil => rfl + | singleton a => simp [pairs,unpaired] + | cons_cons a b ps ih _ => + rw [pairs_cons_cons,unpaired_cons_cons] + simpa only [List.flatMap_cons,List.append_assoc,List.cons_append,List.nil_append] using + congrArg (fun xs => a::b::xs) ih + +theorem paired_sum {M : Type*} [AddCommMonoid M] (f : Port → M) (ps : List Port) : + (ps.map f).sum = ((pairs ps).map (fun p => f p.1+f p.2)).sum + + ((unpaired ps).map f).sum := by + conv_lhs => rw [← pairs_partition ps] + simp only [List.map_append,List.sum_append,List.flatMap_def,List.map_flatten, + List.sum_flatten,List.map_map,Function.comp_def,List.map_cons,List.map_nil, + List.sum_cons,List.sum_nil,add_zero] + +theorem catalog_cons (ps : List Port) (gs : Groups) : + catalog (ps::gs) = (pairs ps).map (fun p => (0,p)) ++ + (catalog gs).map (fun p => (p.1+1,p.2)) := by + unfold catalog + simp only [List.length_cons,List.range_succ_eq_map,List.map_cons,List.map_map, + List.flatten_cons,groupAt_cons_zero,Function.comp_def,groupAt_cons_succ] + rw [List.map_flatten,List.map_map] + simp only [List.map_map,Function.comp_def] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPoints.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbca188d0f3b8ef328a5a72ac6238295e6afc4a7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListPoints.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListScale + +namespace OAI + +/-! Literal numbering of the new active ports. A prefix sum of pair counts +gives each center its contiguous block of fresh mediator indices. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +noncomputable def takeGroupsProgram : Procedure (prodCode Nat.bits groupsCode) groupsCode + (fun x => x.2.take x.1) := by + let n := Procedure.first Nat.bits groupsCode + let gs := Procedure.second Nat.bits groupsCode + let len := (Procedure.listLength (listCode portCode) []).comp gs + let count := Procedure.binarySub.comp (len.pair n) + let reverse := (Procedure.listReverse (listCode portCode) []).comp gs + exact ((Procedure.listReverse (listCode portCode) []).comp + ((Procedure.listDrop (listCode portCode)).comp (count.pair reverse))).congrFun (by + intro x + simp only [Function.comp_apply,← List.reverse_take,List.reverse_reverse]) + +noncomputable def pairStartProgram : Procedure (prodCode Nat.bits groupsCode) unaryCode + (fun x => pairStart x.2 x.1) := pairCountProgram.comp takeGroupsProgram + +abbrev PointInput := (ℕ × ℕ) × ℚ +def pointCode : PointInput → List Bool := prodCode (prodCode Nat.bits Nat.bits) ratCode + +def freshPoint (x : PointInput) (j : ℕ) : Port := (x.1.1+2*(x.1.2+j),x.2) + +noncomputable def freshPointProgram : + Procedure (prodCode unaryCode pointCode) portCode (fun x => freshPoint x.2 x.1) := by + let j := Procedure.unaryToBits.comp (Procedure.first unaryCode pointCode) + let env := Procedure.second unaryCode pointCode + let ns := (Procedure.first (prodCode Nat.bits Nat.bits) ratCode).comp env + let n := (Procedure.first Nat.bits Nat.bits).comp ns + let start := (Procedure.second Nat.bits Nat.bits).comp ns + let r := (Procedure.second (prodCode Nat.bits Nat.bits) ratCode).comp env + let offset := Procedure.binaryMul.comp + ((Procedure.constant (prodCode unaryCode pointCode) Nat.bits 2).pair + (Procedure.binaryAdd.comp (start.pair j))) + exact (Procedure.binaryAdd.comp (n.pair offset)).pair r + +abbrev GroupInput := ℕ × (ℚ × Groups) +def groupCode : GroupInput → List Bool := prodCode Nat.bits (prodCode ratCode groupsCode) + +noncomputable def nextGroupProgram : Procedure (prodCode unaryCode groupCode) (listCode portCode) + (fun x => nextGroup x.2.1 x.2.2.1 x.2.2.2 x.1) := by + let i := Procedure.first unaryCode groupCode + let env := Procedure.second unaryCode groupCode + let n := (Procedure.first Nat.bits (prodCode ratCode groupsCode)).comp env + let tail := (Procedure.second Nat.bits (prodCode ratCode groupsCode)).comp env + let r := (Procedure.first ratCode groupsCode).comp tail + let gs := (Procedure.second ratCode groupsCode).comp tail + let ps := groupAtProgram.comp (i.pair gs) + let count := halfProgram.comp + ((ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength portCode (0,0)).comp ps) + let start := Procedure.unaryToBits.comp + (pairStartProgram.comp ((Procedure.unaryToBits.comp i).pair gs)) + let points := (Procedure.tabulate (0,0) freshPointProgram).comp + (count.pair ((n.pair start).pair r)) + exact (Procedure.listAppend portCode (0,0)).comp (points.pair (unpairedProgram.comp ps)) + +noncomputable def nextGroupsProgram : Procedure groupCode groupsCode + (fun x => (List.range x.2.2.length).map (nextGroup x.1 x.2.1 x.2.2)) := by + let gs := (Procedure.second ratCode groupsCode).comp + (Procedure.second Nat.bits (prodCode ratCode groupsCode)) + let count := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength (listCode portCode) []).comp gs + exact (Procedure.tabulate (f := fun x i => nextGroup x.1 x.2.1 x.2.2 i) + [] nextGroupProgram).comp (count.pair (Procedure.identity groupCode)) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8e586b91fd5331e54f6376074fa4e5249dce53d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListProgram.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListData +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawFamilyProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingProgram + +namespace OAI + +/-! Literal finite-list programs for the active-port pairs in a fork round. +Only the finite input lists are enumerated; spin Hilbert-space bases are absent. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +def portCode : Port → List Bool := prodCode Nat.bits ratCode +def pairCode : Pair → List Bool := prodCode portCode portCode +def groupsCode : Groups → List Bool := listCode (listCode portCode) +def taggedCode : TaggedPair → List Bool := prodCode Nat.bits pairCode +def stateCode : State → List Bool := + prodCode unaryCode (prodCode (listCode MediatorListProgram.bondCode) + (prodCode ratCode groupsCode)) + +noncomputable def halfProgram : Procedure unaryCode unaryCode (fun n => n/2) := by + let n := Procedure.identity unaryCode + let half := Procedure.binaryDiv.comp + (Procedure.unaryToBits.pair (Procedure.constant unaryCode Nat.bits 2)) + exact (Procedure.clippedUnary.comp (n.pair half)).congrFun (by + intro n + exact Nat.min_eq_right (Nat.div_le_self n 2)) + +noncomputable def portAtProgram : + Procedure (prodCode unaryCode (listCode portCode)) portCode + (fun x => portAt x.2 x.1) := + (Procedure.listGet portCode (0,0)).comp + ((Procedure.unaryToBits.comp (Procedure.first unaryCode (listCode portCode))).pair + (Procedure.second unaryCode (listCode portCode))) + +noncomputable def pairAtProgram : + Procedure (prodCode unaryCode (listCode portCode)) pairCode + (fun x => (portAt x.2 (2*x.1),portAt x.2 (2*x.1+1))) := by + let i := Procedure.first unaryCode (listCode portCode) + let xs := Procedure.second unaryCode (listCode portCode) + let twice := (Procedure.unaryAdd.comp (i.pair i)).congrFun (by intro x; change x.1+x.1=2*x.1; omega) + exact (portAtProgram.comp (twice.pair xs)).pair + (portAtProgram.comp ((Procedure.unarySuccessor.comp twice).pair xs)) + +noncomputable def pairsProgram : Procedure (listCode portCode) (listCode pairCode) pairs := by + let count := halfProgram.comp (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength portCode (0,0)) + exact (Procedure.tabulate (f := fun ps i => (portAt ps (2*i),portAt ps (2*i+1))) + ((0,0),(0,0)) pairAtProgram).comp (count.pair (Procedure.identity (listCode portCode))) + +noncomputable def unpairedProgram : Procedure (listCode portCode) (listCode portCode) unpaired := by + let count := halfProgram.comp (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength portCode (0,0)) + let cut := Procedure.unaryToBits.comp (Procedure.unaryAdd.comp (count.pair count)) + exact ((Procedure.listDrop portCode).comp (cut.pair (Procedure.identity (listCode portCode)))).congrFun + (by intro ps; change ps.drop (ps.length/2+ps.length/2)=ps.drop (2*(ps.length/2)); rw [two_mul]) + +noncomputable def groupAtProgram : Procedure (prodCode unaryCode groupsCode) (listCode portCode) + (fun x => groupAt x.2 x.1) := + (Procedure.listGet (listCode portCode) []).comp + ((Procedure.unaryToBits.comp (Procedure.first unaryCode groupsCode)).pair + (Procedure.second unaryCode groupsCode)) + +noncomputable def taggedPairsProgram : + Procedure (prodCode unaryCode groupsCode) (listCode taggedCode) + (fun x => (pairs (groupAt x.2 x.1)).map (fun p => (x.1,p))) := by + let i := Procedure.first unaryCode groupsCode + let ps := pairsProgram.comp groupAtProgram + let step : Procedure (prodCode Nat.bits pairCode) taggedCode (fun x : ℕ × Pair => (x.1,x.2)) := + Procedure.identity taggedCode + exact (Procedure.listMapWith (f := fun (i : ℕ) (p : Pair) => (i,p)) + ((0,0),(0,0)) (0,((0,0),(0,0))) step).comp + ((Procedure.unaryToBits.comp i).pair ps) + +noncomputable def catalogProgram : Procedure groupsCode (listCode taggedCode) catalog := by + let count := ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength (listCode portCode) [] + let blocks := (Procedure.tabulate (f := fun gs i => + (pairs (groupAt gs i)).map (fun p => (i,p))) [] taggedPairsProgram).comp + (count.pair (Procedure.identity groupsCode)) + exact (QuantumRawExchange.flattenProgram taggedCode (0,((0,0),(0,0)))).comp blocks + +noncomputable def pairCountProgram : Procedure groupsCode unaryCode pairCount := + ((ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength taggedCode (0,((0,0),(0,0)))).comp + catalogProgram).congrFun catalog_length + +noncomputable def retainedProgram : Procedure stateCode (listCode ratCode) retained := by + let tail := Procedure.second unaryCode + (prodCode (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)) + let bs := (Procedure.first (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)).comp tail + let gs := (Procedure.second ratCode groupsCode).comp + ((Procedure.second (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)).comp tail) + let weights := (Procedure.listMap (0,0,0) 0 + ((Procedure.second Nat.bits ratCode).comp + (Procedure.second Nat.bits (prodCode Nat.bits ratCode)))).comp bs + let leftovers := (QuantumRawExchange.flattenProgram portCode (0,0)).comp + ((Procedure.listMap [] [] unpairedProgram).comp gs) + let leftoverWeights := (Procedure.listMap (0,0) 0 (Procedure.second Nat.bits ratCode)).comp leftovers + exact (Procedure.listAppend ratCode 0).comp (weights.pair leftoverWeights) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a37b06ddd86446b0c7ce7902dfc2ef1e37412fe --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRealization.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListRound + +namespace OAI + +/-! Exact correspondence between the emitted ordered state and the finite +parallel-fork Hamiltonian. The mediator numbering is the proved prefix index. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorGraph QuantumAxisSample QuantumRawExchange +open scoped BigOperators Classical + +theorem retained_graph_list (s : State) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) : + List.ofFn (fun a => erase + (old s.1 (pairCount s.2.2.2) ((backgroundGraph s hb hn).left a), + old s.1 (pairCount s.2.2.2) ((backgroundGraph s hb hn).right a), + (backgroundGraph s hb hn).weight a)) = background s := by + simpa only [backgroundGraph,QuantumListGraph.ofBonds,SourceBondLists.bonds, + erase,MediatorIteration.old_val] using List.ofFn_get (background s) + +theorem packet_graph_list (s : State) (hs : ValidPorts s.1 s.2.2.2) (R : ℚ) : + (List.ofFn (fun e => packetBonds e (actualSite hs e) + (actualJ s.2.2.2 e) (actualK s.2.2.2 e) R)).flatten=packets s R := by + unfold packets + congr 1 + apply List.ext_getElem + · simp + · intro i hi hj + have hi' : i < pairCount s.2.2.2 := by simpa only [List.length_ofFn] using hi + simp only [List.getElem_ofFn,List.getElem_map,List.getElem_range] + rw [catalog_actualSite hs ⟨i,hi'⟩] + rfl + +theorem graph_bonds_eq (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (R : ℚ) : + graphBonds (backgroundGraph s hb hn).left (backgroundGraph s hb hn).right + (backgroundGraph s hb hn).weight (actualSite hs) (actualJ s.2.2.2) + (actualK s.2.2.2) R = background s++packets s R := by + unfold graphBonds + exact congrArg₂ List.append (retained_graph_list s hb hn) (packet_graph_list s hs R) + +theorem next_constant (s : State) (N : ℚ) : + (next N s).2.2.1 = graphConstant s.2.2.1 (scale N s) + (actualJ s.2.2.2) (actualK s.2.2.2) := by + have h : (((catalog s.2.2.2).map Prod.snd).map pairOffset).sum = + ∑ e, (3/4+3*(actualJ s.2.2.2 e)^2+3*(actualK s.2.2.2 e)^2) := + catalog_weights_sum s.2.2.2 (fun J K => 3/4+3*J^2+3*K^2) + dsimp only [next,graphConstant] + rw [h] + +def rawBottom (n : ℕ) (out : List MediatorListProgram.Bond × ℚ) : ℝ := + normalizedBottom (rawMatrix n out) + +theorem next_bottom_graph (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) : + normalizedBottom (matrix (next N s)) = + normalizedBottom (qmaForksGraph (backgroundGraph s hb hn).left (backgroundGraph s hb hn).right + (fun e => ((backgroundGraph s hb hn).weight e:ℝ)) (s.2.2.1:ℝ) (scale N s:ℝ) + (actualSite hs) (fun e => (actualJ s.2.2.2 e:ℝ)) (fun e => (actualK s.2.2.2 e:ℝ))) := by + rw [next_matrix_packets,next_constant] + change rawBottom (s.1+2*pairCount s.2.2.2) + (background s++packets s (scale N s), + graphConstant s.2.2.1 (scale N s) (actualJ s.2.2.2) (actualK s.2.2.2)) = _ + rw [show s.1+2*pairCount s.2.2.2=s.1+pairCount s.2.2.2*2 by omega] + unfold rawBottom + rw [← graph_bonds_eq s hs hb hn] + exact congrArg normalizedBottom (graph_matrix _ _ _ _ _ _ _ _) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRound.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4c47b04385b38e7d711ba352f950927f74a2def --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListRound.lean @@ -0,0 +1,41 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListCalibration + +namespace OAI + +/-! The complete literal round is the retained matrix plus the calibrated +five-bond packets, including the newly active center-to-mediator edges. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram QuantumRawExchange + +def freshBonds (s : State) (R : ℚ) : List Bond := + (List.range (pairCount s.2.2.2)).map (fun e => + ((((catalog s.2.2.2).drop e).headD (0,((0,0),(0,0)))).1,s.1+2*e,R)) + +def packets (s : State) (R : ℚ) : List Bond := + ((List.range (pairCount s.2.2.2)).map (fun e => + pairBonds s.1 e R (((catalog s.2.2.2).drop e).headD (0,((0,0),(0,0)))).2 ++ + [((((catalog s.2.2.2).drop e).headD (0,((0,0),(0,0)))).1,s.1+2*e,R)])).flatten + +theorem packets_sum {M : Type*} [AddCommMonoid M] (s : State) (R : ℚ) (f : Bond → M) : + ((packets s R).map f).sum = + ((addedBonds s R).map f).sum+((freshBonds s R).map f).sum := by + simp only [packets,addedBonds,freshBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def,List.map_append,List.sum_append,List.map_cons,List.map_nil, + List.sum_cons,List.sum_nil,add_zero,catalog_length,List.sum_map_add] + +theorem next_matrix_packets (N : ℚ) (s : State) : + matrix (next N s) = + rawMatrix (s.1+2*pairCount s.2.2.2) + (background s++packets s (scale N s),(next N s).2.2.1) := by + dsimp only [matrix,next] + simp only [rawMatrix,List.map_append,List.sum_append, + next_active_sum,background,packets_sum,freshBonds,List.map_map,Function.comp_def] + abel + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..340ab703fd1ac548e628f2b8635f18d030a8cf41 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListScale.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathScaleProgram + +namespace OAI + +/-! Exact rational calibration for the ordered fork list. The perturbation +scale includes the unpaired active ports in its retained-energy bound. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open ExactQuantumFactoring.BitStackProgram + +noncomputable def countProgram : Procedure stateCode unaryCode Prod.fst := Procedure.first _ _ + +noncomputable def bondsProgram : Procedure stateCode (listCode MediatorListProgram.bondCode) + (fun s => s.2.1) := + (Procedure.first (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)).comp + (Procedure.second unaryCode + (prodCode (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode))) + +noncomputable def scalarProgram : Procedure stateCode ratCode (fun s => s.2.2.1) := + (Procedure.first ratCode groupsCode).comp + ((Procedure.second (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)).comp + (Procedure.second unaryCode + (prodCode (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)))) + +noncomputable def groupsProgram : Procedure stateCode groupsCode (fun s => s.2.2.2) := + (Procedure.second ratCode groupsCode).comp + ((Procedure.second (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)).comp + (Procedure.second unaryCode + (prodCode (listCode MediatorListProgram.bondCode) (prodCode ratCode groupsCode)))) + +noncomputable def leftWeight : Procedure pairCode ratCode (fun p => p.1.2) := + (Procedure.second Nat.bits ratCode).comp (Procedure.first portCode portCode) +noncomputable def rightWeight : Procedure pairCode ratCode (fun p => p.2.2) := + (Procedure.second Nat.bits ratCode).comp (Procedure.second portCode portCode) + +noncomputable def pairLinearProgram : Procedure pairCode ratCode pairLinear := by + let a := MediatorProgram.absoluteProgram.comp leftWeight + let b := MediatorProgram.absoluteProgram.comp rightWeight + let two := Procedure.constant pairCode ratCode 2 + exact Procedure.ratAdd.comp + ((Procedure.ratAdd.comp ((Procedure.constant pairCode ratCode 1).pair + (Procedure.ratMul.comp (two.pair a)))).pair (Procedure.ratMul.comp (two.pair b))) + +noncomputable def pairSquareProgram : Procedure pairCode ratCode pairSquare := by + let a := MediatorProgram.absoluteProgram.comp leftWeight + let b := MediatorProgram.absoluteProgram.comp rightWeight + exact QuantumRoutingCode.squareProgram (Procedure.ratAdd.comp + ((Procedure.ratAdd.comp ((Procedure.constant pairCode ratCode 1).pair a)).pair b)) + +noncomputable def pairOffsetProgram : Procedure pairCode ratCode pairOffset := by + let a := QuantumRoutingCode.squareProgram leftWeight + let b := QuantumRoutingCode.squareProgram rightWeight + let three := Procedure.constant pairCode ratCode 3 + exact Procedure.ratAdd.comp + ((Procedure.ratAdd.comp ((Procedure.constant pairCode ratCode (3/4)).pair + (Procedure.ratMul.comp (three.pair a)))).pair (Procedure.ratMul.comp (three.pair b))) + +abbrev ScaleInput := ℚ × State +def scaleCode : ScaleInput → List Bool := prodCode ratCode stateCode + +noncomputable def scaleProgram : Procedure scaleCode ratCode (fun x => scale x.1 x.2) := by + let n := Procedure.first ratCode stateCode + let s := Procedure.second ratCode stateCode + let c := scalarProgram.comp s + let gs := groupsProgram.comp s + let ps := (Procedure.listMap (0,((0,0),(0,0))) ((0,0),(0,0)) + (Procedure.second Nat.bits pairCode)).comp (catalogProgram.comp gs) + let sumPairs (f : Pair → ℚ) (p : Procedure pairCode ratCode f) := + RationalSumProgram.sumProgram.comp ((Procedure.listMap ((0,0),(0,0)) 0 p).comp ps) + let absRetained := (QuantumPathScaleProgram.sumMapProgram MediatorProgram.absoluteProgram).comp + (retainedProgram.comp s) + let b := Procedure.ratAdd.comp + ((Procedure.ratMul.comp ((Procedure.constant scaleCode ratCode 3).pair absRetained)).pair + (MediatorProgram.absoluteProgram.comp c)) + let a := Procedure.ratMul.comp ((Procedure.constant scaleCode ratCode 3).pair + (sumPairs pairLinear pairLinearProgram)) + let d := Procedure.ratAdd.comp (b.pair + (Procedure.ratMul.comp ((Procedure.constant scaleCode ratCode 12).pair (sumPairs pairSquare pairSquareProgram)))) + exact QuantumRoutingCode.scaleProgram.comp (a.pair (d.pair n)) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSites.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSites.lean new file mode 100644 index 0000000000000000000000000000000000000000..74b5dcb5b866531828dc7f39559011e85a2c93bb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSites.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListOrdinal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListGraph + +namespace OAI + +/-! Actual fork sites obtained from the ordered port arrays. Their bounds and +injectivity are the geometric hypotheses of the parallel perturbation theorem. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList + +structure ValidPorts (n : ℕ) (gs : Groups) : Prop where + centers : gs.length ≤ n + bounded : ∀ (i : Fin gs.length) (j : Fin (groupAt gs i.val).length), + (portAt (groupAt gs i.val) j.val).1 < n + disjoint : ∀ (i k : Fin gs.length) (j : Fin (groupAt gs k.val).length), + i.val ≠ (portAt (groupAt gs k.val) j.val).1 + injective : ∀ (i k : Fin gs.length) (j : Fin (groupAt gs i.val).length) + (l : Fin (groupAt gs k.val).length), + (portAt (groupAt gs i.val) j.val).1=(portAt (groupAt gs k.val) l.val).1 → + i=k ∧ j.val=l.val + +def localPair (gs : Groups) (e : Fin (pairCount gs)) : LocalPair gs := + (pairEquiv gs).symm e + +def localFirst (gs : Groups) (e : Fin (pairCount gs)) : + Fin (groupAt gs (localPair gs e).1.val).length := + ⟨2*(localPair gs e).2.val,by have := (localPair gs e).2.isLt; omega⟩ + +def localSecond (gs : Groups) (e : Fin (pairCount gs)) : + Fin (groupAt gs (localPair gs e).1.val).length := + ⟨2*(localPair gs e).2.val+1,by have := (localPair gs e).2.isLt; omega⟩ + +def actualSite {n : ℕ} {gs : Groups} (h : ValidPorts n gs) (e : Fin (pairCount gs)) : + Fin 3 → Fin n := + ![⟨(localPair gs e).1.val,lt_of_lt_of_le (localPair gs e).1.isLt h.centers⟩, + ⟨(portAt (groupAt gs (localPair gs e).1.val) (localFirst gs e).val).1, + h.bounded (localPair gs e).1 (localFirst gs e)⟩, + ⟨(portAt (groupAt gs (localPair gs e).1.val) (localSecond gs e).val).1, + h.bounded (localPair gs e).1 (localSecond gs e)⟩] + +def actualJ (gs : Groups) (e : Fin (pairCount gs)) : ℚ := + (portAt (groupAt gs (localPair gs e).1.val) (localFirst gs e).val).2 + +def actualK (gs : Groups) (e : Fin (pairCount gs)) : ℚ := + (portAt (groupAt gs (localPair gs e).1.val) (localSecond gs e).val).2 + +theorem actualSite_injective {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (e : Fin (pairCount gs)) : Function.Injective (actualSite h e) := by + intro a b hab + have hh := congrArg Fin.val hab + fin_cases a <;> fin_cases b <;> simp only [actualSite] at hh ⊢ + · exact (h.disjoint (localPair gs e).1 (localPair gs e).1 (localFirst gs e) hh).elim + · exact (h.disjoint (localPair gs e).1 (localPair gs e).1 (localSecond gs e) hh).elim + · exact (h.disjoint (localPair gs e).1 (localPair gs e).1 (localFirst gs e) hh.symm).elim + · have hp := (h.injective (localPair gs e).1 (localPair gs e).1 + (localFirst gs e) (localSecond gs e) hh).2 + simp only [localFirst,localSecond] at hp + omega + · exact (h.disjoint (localPair gs e).1 (localPair gs e).1 (localSecond gs e) hh.symm).elim + · have hp := (h.injective (localPair gs e).1 (localPair gs e).1 + (localSecond gs e) (localFirst gs e) hh).2 + simp only [localFirst,localSecond] at hp + omega + +theorem catalog_actualSite {n : ℕ} {gs : Groups} (h : ValidPorts n gs) + (e : Fin (pairCount gs)) : + ((catalog gs).drop e.val).headD (0,((0,0),(0,0))) = + ((actualSite h e 0).val,((actualSite h e 1).val,actualJ gs e), + ((actualSite h e 2).val,actualK gs e)) := by + have hc := catalog_pairEquiv gs (localPair gs e) + rw [show pairEquiv gs (localPair gs e)=e from (pairEquiv gs).apply_symm_apply e] at hc + exact hc + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSize.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a04b63d9e84c4cd0edf3208c6432b75db92b3cc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSize.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListFinalDegree + +namespace OAI + +/-! Polynomial size bounds for the actual finite lists. A fixed number of +rounds grows the spin and bond counts linearly in the initial active-port mass. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +def portMass (gs : Groups) : ℕ := (gs.map List.length).sum + +theorem portMass_sum (gs : Groups) : + portMass gs=∑ i : Fin gs.length, (groupAt gs i.val).length := by + have h := congrArg List.sum + (ExactQuantumFactoring.BitStackProgram.map_range_getD gs [] List.length) + simpa only [portMass,groupAt,range_sum] using h.symm + +theorem pairCount_le_portMass (gs : Groups) : pairCount gs ≤ portMass gs := by + have he : pairCount gs=∑ i : Fin gs.length, (groupAt gs i.val).length/2 := by + simpa only [LocalPair,Fintype.card_sigma,Fintype.card_fin] using (localPair_card gs).symm + rw [he,portMass_sum] + exact Finset.sum_le_sum (fun i _ => Nat.div_le_self _ _) + +theorem next_portMass_le (N : ℚ) (s : State) : portMass (next N s).2.2.2 ≤ portMass s.2.2.2 := by + change (((List.range s.2.2.2.length).map (nextGroup s.1 (scale N s) s.2.2.2)).map List.length).sum ≤ _ + simp only [List.map_map,Function.comp_def,nextGroup_length,range_sum] + rw [portMass_sum] + exact Finset.sum_le_sum (fun i _ => by omega) + +theorem iterate_portMass_le (N : ℚ) (s : State) (k : ℕ) : + portMass (iterate N k s).2.2.2 ≤ portMass s.2.2.2 := by + induction k with + | zero => exact le_rfl + | succ k ih => exact (next_portMass_le N (iterate N k s)).trans ih + +theorem iterate_count_le (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).1 ≤ s.1+2*k*portMass s.2.2.2 := by + induction k with + | zero => simp [iterate] + | succ k ih => + have hp := (pairCount_le_portMass (iterate N k s).2.2.2).trans (iterate_portMass_le N s k) + change (iterate N k s).1+2*pairCount (iterate N k s).2.2.2 ≤ _ + calc + _ ≤ (s.1+2*k*portMass s.2.2.2)+2*portMass s.2.2.2 := by omega + _ = s.1+2*(k+1)*portMass s.2.2.2 := by ring + +theorem iterate_bonds_le (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).2.1.length ≤ s.2.1.length+4*k*portMass s.2.2.2 := by + induction k with + | zero => simp [iterate] + | succ k ih => + have hp := (pairCount_le_portMass (iterate N k s).2.2.2).trans (iterate_portMass_le N s k) + rw [iterate,next_bonds_length] + calc + _ ≤ (s.2.1.length+4*k*portMass s.2.2.2)+4*portMass s.2.2.2 := by omega + _ = s.2.1.length+4*(k+1)*portMass s.2.2.2 := by ring + +theorem sum_ones {α : Type*} (xs : List α) : (xs.map (fun _ => (1:ℕ))).sum=xs.length := by + induction xs with + | nil => rfl + | cons x xs ih => + simp only [List.map_cons,List.sum_cons,List.length_cons,ih] + omega + +theorem activeBonds_length (gs : Groups) : (activeBonds gs).length=portMass gs := by + simp only [activeBonds,List.length_flatten,List.map_map,Function.comp_def,starBonds,List.length_map, + range_sum,portMass_sum] + +theorem initial_portMass (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (c N : ℚ) : portMass (initial n bs c N).2.2.2=2*bs.length := by + have h := initial_group_sum n bs hb (initialScale N bs c) (fun _ _ => (1:ℕ)) + simp only [sum_ones,List.length_range] at h + change (((List.range n).map (initialGroup n bs (initialScale N bs c))).map List.length).sum = _ + simpa only [List.map_map,Function.comp_def] using h + +theorem initial_iterate_count_le (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (c N : ℚ) (k : ℕ) : + (iterate N k (initial n bs c N)).1 ≤ n+2*bs.length+4*k*bs.length := by + have h := iterate_count_le N (initial n bs c N) k + rw [initial_portMass n bs hb c N] at h + change (iterate N k (initial n bs c N)).1 ≤ n+2*bs.length+2*k*(2*bs.length) at h + convert h using 1 + ring + +theorem initial_iterate_bonds_le (n : ℕ) (bs : List Bond) (hb : SourceBondLists.bounded n bs) + (c N : ℚ) (k : ℕ) : + ((iterate N k (initial n bs c N)).2.1++ + activeBonds (iterate N k (initial n bs c N)).2.2.2).length ≤ + 3*bs.length+8*k*bs.length := by + have h := iterate_bonds_le N (initial n bs c N) k + rw [initial_portMass n bs hb c N] at h + have hm := iterate_portMass_le N (initial n bs c N) k + rw [initial_portMass n bs hb c N] at hm + have hi : (initial n bs c N).2.1.length=bs.length := by + simp only [initial,List.length_map,List.length_range] + rw [hi] at h + rw [List.length_append,activeBonds_length] + calc + _ ≤ (bs.length+4*k*(2*bs.length))+2*bs.length := Nat.add_le_add h hm + _ = _ := by ring + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSpatialPackage.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSpatialPackage.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc7c153aee5fd18342c153aa343c145033f889d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSpatialPackage.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListFullCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridMidpoint +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalSpatialPackage + +namespace OAI + +/-! Package the literal full fork graph with deterministic midpoint anchors. +The package keeps its actual spin indices, coefficients and scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped Classical + +def fullList (s : State) : List Bond := s.2.1++activeBonds s.2.2.2 + +theorem fullList_bounded (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) : SourceBondLists.bounded s.1 (fullList s) := by + intro b hm + rcases List.mem_append.mp hm with hm | hm + · exact hb b hm + · exact ⟨(activeBonds_valid hs b hm).1,(activeBonds_valid hs b hm).2.1⟩ + +theorem fullList_noLoops (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) : ∀ b ∈ fullList s, b.1≠b.2.1 := by + intro b hm + rcases List.mem_append.mp hm with hm | hm + · exact hn b hm + · exact (activeBonds_valid hs b hm).2.2 + +def fullGraph (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) := + QuantumListGraph.ofBonds s.1 (fullList s) s.2.2.1 + (fullList_bounded s hs hb) (fullList_noLoops s hs hn) + +theorem fullGraph_matrix (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) : + qmaExchangeMatrix (fullGraph s hs hb hn).left (fullGraph s hs hb hn).right + (fun e => ((fullGraph s hs hb hn).weight e:ℝ)) s.2.2.1 = matrix s := by + change _ = QuantumRawExchange.rawMatrix s.1 (fullList s,s.2.2.1) + rw [rawMatrix_eq_matrix] + exact QuantumListGraph.ofBonds_matrix _ _ _ _ _ + +def CommonCell {rows width : ℕ} (p q : QMAGridCell rows width) : Prop := + ∃ a, QMAGridCellsNear p a ∧ QMAGridCellsNear q a + +theorem commonCell_refl {rows width : ℕ} (p : QMAGridCell rows width) : CommonCell p p := + ⟨p,qmaGridCellsNear_refl p,qmaGridCellsNear_refl p⟩ + +def spatialModel {rows width : ℕ} (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) + (cell : ℕ → QMAGridCell rows width) (A : ℕ) + (hc : ∀ p, qmaCellMass (fun v : Fin s.1 => cell v.val) p ≤ A) + (hd : ∀ v : Fin s.1, degree (fullList s) v.val ≤ 3) + (hl : BondLocal (fullList s) cell CommonCell) : QMASpatialExchangeModel A (27*A) := by + let G := fullGraph s hs hb hn + let cells : Fin s.1 → QMAGridCell rows width := fun v => cell v.val + let anchors := fun e => qmaGridMidpoint (cells (G.left e)) (cells (G.right e)) + have hg : ∀ e, QMAGridCellsNear (cells (G.left e)) (anchors e) ∧ + QMAGridCellsNear (cells (G.right e)) (anchors e) := by + intro e + obtain ⟨a,ha,hb⟩ := hl ((fullList s).get e) (List.get_mem _ e) + exact qmaGridMidpoint_near _ _ a ha hb + have hc' : ∀ p, (Finset.univ.filter (fun v => cells v=p)).card ≤ A := by + intro p + simpa only [qmaCellMass,Finset.card_filter] using hc p + have hd' : ∀ v : Fin s.1, qmaGraphDegree G.left G.right v ≤ 3 := by + intro v + change qmaGraphDegree (SourceBondLists.bonds s.1 (fullList s) + (fullList_bounded s hs hb)).left (SourceBondLists.bonds s.1 (fullList s) + (fullList_bounded s hs hb)).right v ≤ 3 + exact (degree_eq_graph s.1 (fullList s) (fullList_bounded s hs hb) v) ▸ hd v + exact qmaDegreeThreeSpatialModel G.left G.right G.distinct G.weight s.2.2.1 + cells anchors hc' hd' hg + +theorem spatialModel_matrix {rows width : ℕ} (s : State) (hs : ValidPorts s.1 s.2.2.2) + (hb : SourceBondLists.bounded s.1 s.2.1) (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) + (cell : ℕ → QMAGridCell rows width) (A : ℕ) + (hc : ∀ p, qmaCellMass (fun v : Fin s.1 => cell v.val) p ≤ A) + (hd : ∀ v : Fin s.1, degree (fullList s) v.val ≤ 3) + (hl : BondLocal (fullList s) cell CommonCell) : + let M := spatialModel s hs hb hn cell A hc hd hl + qmaExchangeMatrix M.left M.right (fun e => (M.weight e:ℝ)) M.constant = matrix s := + fullGraph_matrix s hs hb hn + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..557fef5092fe5e2e9401cb4f4e45904c6176a479 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListSum.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListOrdinal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListActive + +namespace OAI + +/-! Reindexing the actual fresh-port list by its consecutive mediator number. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +theorem range_sum {M : Type*} [AddCommMonoid M] (f : ℕ → M) (n : ℕ) : + ((List.range n).map f).sum=∑ i : Fin n, f i.val := by + have h : List.ofFn (fun i : Fin n => f i.val)=(List.range n).map f := by + apply List.ext_getElem + · simp + · intro i hi hj + simp only [List.getElem_ofFn,List.getElem_map,List.getElem_range] + rw [← h,List.sum_ofFn] + +theorem fresh_sum {M : Type*} [AddCommMonoid M] (gs : Groups) (f : ℕ → ℕ → M) : + ((List.range gs.length).map (fun i => + ((List.range ((groupAt gs i).length/2)).map (fun j => + f i (pairStart gs i+j))).sum)).sum = + ∑ e : Fin (pairCount gs), + f (((catalog gs).drop e.val).headD (0,((0,0),(0,0)))).1 e.val := by + simp only [range_sum] + have h := (pairEquiv gs).sum_comp (fun e => + f (((catalog gs).drop e.val).headD (0,((0,0),(0,0)))).1 e.val) + simp only [catalog_pairEquiv] at h + simpa only [LocalPair,Fintype.sum_sigma,pairEquiv_val] using h + +theorem next_groupAt (n : ℕ) (R : ℚ) (gs : Groups) (i : ℕ) (hi : i < gs.length) : + groupAt ((List.range gs.length).map (nextGroup n R gs)) i=nextGroup n R gs i := by + rw [groupAt,List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem (by simpa using hi)] + simp only [Option.getD_some,List.getElem_map,List.getElem_range] + +theorem next_active_sum {M : Type*} [AddCommMonoid M] (n : ℕ) (R : ℚ) + (gs : Groups) (f : Bond → M) : + ((activeBonds ((List.range gs.length).map (nextGroup n R gs))).map f).sum = + ((List.range (pairCount gs)).map (fun e => + f ((((catalog gs).drop e).headD (0,((0,0),(0,0)))).1,n+2*e,R))).sum+ + ((unpairedBonds gs).map f).sum := by + have h : ((List.range gs.length).map (fun i => + ((groupAt ((List.range gs.length).map (nextGroup n R gs)) i).map + (fun p => f (i,p.1,p.2))).sum)) = + (List.range gs.length).map (fun i => + ((List.range ((groupAt gs i).length/2)).map (fun j => + f (i,n+2*(pairStart gs i+j),R))).sum+ + ((unpaired (groupAt gs i)).map (fun p => f (i,p.1,p.2))).sum) := by + apply List.map_congr_left + intro i hi + rw [next_groupAt n R gs i (List.mem_range.mp hi)] + simp only [nextGroup,List.map_append,List.sum_append,List.map_map,Function.comp_def] + simp only [activeBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def,List.length_map,List.length_range] + rw [h,List.sum_map_add] + congr 1 + · simpa only [range_sum] using fresh_sum gs (fun i e => f (i,n+2*e,R)) + · simp only [unpairedBonds,starBonds,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def] + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListWeights.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2bc75a39fb40f5d5e95568f8bfe15b03a86feb1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkListWeights.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListEnvelope +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListSize + +namespace OAI + +/-! Coefficient bounds for the actual ordered lists, including every active +port and the scalar offset. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkList +open MediatorListProgram +open scoped BigOperators Classical + +structure CoefficientBound (s : State) (L : ℝ) : Prop where + scalar : |(s.2.2.1:ℝ)| ≤ L + ordinary : ∀ b ∈ s.2.1, |(b.2.2:ℝ)| ≤ L + active : ∀ ps ∈ s.2.2.2, ∀ p ∈ ps, |(p.2:ℝ)| ≤ L + +theorem groupAt_mem (gs : Groups) (i : ℕ) (hi : i Nat.mod_le _ _) + +theorem CoefficientBound.background (s : State) {L : ℝ} (h : CoefficientBound s L) + (b : Bond) (hb : b ∈ background s) : |(b.2.2:ℝ)| ≤ L := by + rcases List.mem_append.mp hb with hold | hnew + · exact h.ordinary b hold + obtain ⟨bs,hbs,hb⟩ := List.mem_flatten.mp hnew + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + obtain ⟨p,hp,rfl⟩ := List.mem_map.mp hb + exact h.active _ (groupAt_mem _ _ (List.mem_range.mp hi)) _ (List.mem_of_mem_drop hp) + +theorem scale_abs_bound (s : State) + (hb : SourceBondLists.bounded s.1 (background s)) + (hn : ∀ b ∈ background s, b.1 ≠ b.2.1) (N : ℚ) (hN : 0 ≤ N) + {M L T : ℝ} (hM : (s.2.1.length+portMass s.2.2.2:ℕ) ≤ M) + (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) (hc : CoefficientBound s L) : + |(scale N s:ℝ)| ≤ forkRadius M L T := by + have hm : ((background s).length:ℝ) ≤ M := by + refine le_trans ?_ hM + exact_mod_cast (show (background s).length ≤ s.2.1.length+portMass s.2.2.2 by + simpa only [background,List.length_append] using + Nat.add_le_add_left (unpairedBonds_length_le s.2.2.2) s.2.1.length) + have hr : (pairCount s.2.2.2:ℝ) ≤ M := by + refine le_trans ?_ hM + exact_mod_cast (show pairCount s.2.2.2 ≤ s.2.1.length+portMass s.2.2.2 by + have := pairCount_le_portMass s.2.2.2 + omega) + rw [scale_eq_graphScale s hb hn N] + exact graphScale_abs_bound _ _ _ _ _ hN hm hr hL hT hc.scalar + (fun e => hc.background s _ (List.get_mem _ _)) (hc.actualJ s) (hc.actualK s) + +end ContinuumCoulomb.QuantumForkList + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkLocality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..1020e309fdf18b6a5ccb1168d1393771e9d1a0ba --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkLocality.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkPlaced + +namespace OAI + +/-! Fork corrections and new mediator edges are local to one original coarse cell. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped Classical + +theorem qmaForkCellAligned_site {n c : ℕ} {d : Fin c → ℕ} {β : Type*} + (P : QMAForkPorts n c d) (cell : Fin n → β) (h : QMAForkCellAligned P cell) + (e : Fin P.pairCount) (a : Fin 3) : + cell (P.site e a) = cell (P.center (P.pairEquiv.symm e).1) := by + fin_cases a + · rfl + · exact h (qmaForkPairedPort d (P.pairEquiv.symm e,0)) + · exact h (qmaForkPairedPort d (P.pairEquiv.symm e,1)) + +namespace QMAPlacedForkNetwork +variable {β : Type*} {c : ℕ} + +def BackgroundLocal (G : QMAPlacedForkNetwork β c) (R : β → β → Prop) : Prop := + ∀ e, R (G.cell (G.graph.state.left e)) (G.cell (G.graph.state.right e)) + +theorem next_backgroundLocal (G : QMAPlacedForkNetwork β c) (R : β → β → Prop) + (hr : ∀ x, R x x) (h : G.BackgroundLocal R) : G.next.BackgroundLocal R := by + intro e + change R (qmaForkCellNext G.graph.state.ports G.cell + (qmaForkBackgroundLeft G.graph.state.left G.graph.state.ports.site e)) + (qmaForkCellNext G.graph.state.ports G.cell + (qmaForkBackgroundRight G.graph.state.right G.graph.state.ports.site e)) + rcases e with (e | e) | (e | ⟨e,b⟩) + · simpa only [qmaForkBackgroundLeft,qmaForkBackgroundRight,qmaParallelGraphLeft, + qmaParallelGraphRight,qmaForksBaseLeft,qmaForksBaseRight,Sum.elim_inl, + qmaForkCellNext_old] using h e + · simp only [qmaForkBackgroundLeft,qmaForkBackgroundRight,qmaParallelGraphLeft, + qmaParallelGraphRight,qmaForksBaseLeft,qmaForksBaseRight,Sum.elim_inr, + qmaForkCellNext_old,qmaForkCellAligned_site _ _ G.aligned] + exact hr _ + · simp only [qmaForkBackgroundLeft,qmaForkBackgroundRight,qmaParallelGraphLeft, + qmaParallelGraphRight,qmaForkCellNext_fresh] + exact hr _ + · simp only [qmaForkBackgroundLeft,qmaForkBackgroundRight,qmaParallelGraphLeft, + qmaParallelGraphRight,qmaForkCellNext_old,qmaForkCellNext_fresh,qmaForkOuter, + qmaForkCellAligned_site _ _ G.aligned] + exact hr _ + +theorem iterate_backgroundLocal (G : QMAPlacedForkNetwork β c) (R : β → β → Prop) + (hr : ∀ x, R x x) (h : G.BackgroundLocal R) (k : ℕ) : (G.iterate k).BackgroundLocal R := by + induction k with + | zero => exact h + | succ k ih => exact (G.iterate k).next_backgroundLocal R hr ih + +theorem full_local (G : QMAPlacedForkNetwork β c) (R : β → β → Prop) + (hr : ∀ x, R x x) (h : G.BackgroundLocal R) + (e : G.graph.Edge ⊕ (Σ i, Fin (G.graph.degree i))) : + R (G.cell (G.graph.state.fullLeft e)) (G.cell (G.graph.state.fullRight e)) := by + rcases e with e | p + · exact h e + · change R (G.cell (G.graph.state.ports.center p.1)) (G.cell (G.graph.state.ports.port p)) + rw [G.aligned p] + exact hr _ + +end QMAPlacedForkNetwork +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkParallel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkParallel.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d7f2f3eae1a4ef073dde412d34e9c4c5e0c1d99 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkParallel.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkSpectrum + +namespace OAI + +/-! Simultaneous fork elimination, with no mixed error between distinct singlets. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +theorem qmaForks_effective {n r : ℕ} (site : Fin r → Fin 3 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (R : ℝ) (hR : R ≠ 0) (J K : Fin r → ℝ) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) : + (C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) - + mediatorCompression n r (qmaRoutingStars n r site (fun _ => qmaForkMember) + (fun e => qmaForkAmplitude R (J e) (K e)) * liftedMediatorInverse n r (R^2) * + qmaRoutingStars n r site (fun _ => qmaForkMember) + (fun e => qmaForkAmplitude R (J e) (K e))) = + C + ∑ e, ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 1) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2)) := by + rw [qmaRoutingStars_compression,add_sub_assoc,← Finset.sum_sub_distrib] + congr 1 + apply Finset.sum_congr rfl + intro e _ + exact qmaFork_effective e (site e) (hsite e) R (J e) (K e) hR + +theorem qmaForks_bottom {n r : ℕ} (site : Fin r → Fin 3 → Fin n) + (hsite : ∀ e, Function.Injective (site e)) (R : ℝ) (hR : 0 < R) (J K : Fin r → ℝ) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon ≤ 1/4) + (hbound : ‖spinMatrixOperator ((C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ e, ∑ a, |qmaForkAmplitude R (J e) (K e) a| ≤ epsilon * (4*R^2)) : + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + ∑ e, qmaForkCorrection (site e) (J e) (K e)) + (qmaRoutingStars n r site (fun _ => qmaForkMember) + (fun e => qmaForkAmplitude R (J e) (K e)))) - + sourceMatrixBottom n (C + ∑ e, + ((J e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 1) + + (K e:ℂ) • sourceHeisenbergMatrix n (site e 0) (site e 2)))| ≤ + 16*R^2*epsilon^3 := by + have hCW : (C + ∑ e, qmaForkCorrection (site e) (J e) (K e)).conjTranspose = + C + ∑ e, qmaForkCorrection (site e) (J e) (K e) := by + simp only [Matrix.conjTranspose_add,Matrix.conjTranspose_sum,hC, + qmaForkCorrection_star _ (hsite _)] + have h := qmaRoutingStars_bottom n r (sq_pos_of_pos hR) _ hCW site + (fun _ => qmaForkMember) (fun e => qmaForkAmplitude R (J e) (K e)) + hepsilon hsmall hbound + rw [qmaForks_effective site hsite R hR.ne' J K C] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPatch.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPatch.lean new file mode 100644 index 0000000000000000000000000000000000000000..914b54cabf863805e48ea341840470cf3320bd41 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPatch.lean @@ -0,0 +1,47 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumManhattanRoute +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkSpectrum + +namespace OAI + +/-! A concrete planar lattice subdivision of the rational fork gadget. -/ + +namespace ContinuumCoulomb +open scoped Classical + +def qmaForkPatchVertex : Fin 5 → ℕ × ℕ := ![(0,6),(8,12),(8,0),(3,6),(6,6)] +def qmaForkPatchLeft : Fin 5 → Fin 5 := ![3,0,1,2,1] +def qmaForkPatchRight : Fin 5 → Fin 5 := ![4,3,4,4,2] +def qmaForkPatchPath : Fin 5 → List (ℕ × ℕ) := ![ + [(3,6),(4,6),(5,6),(6,6)], + [(0,6),(1,6),(2,6),(3,6)], + [(8,12),(8,11),(8,10),(7,10),(6,10),(6,9),(6,8),(6,7),(6,6)], + [(8,0),(8,1),(8,2),(7,2),(6,2),(6,3),(6,4),(6,5),(6,6)], + [(8,12),(9,12),(10,12),(11,12),(12,12),(12,11),(12,10),(12,9),(12,8),(12,7),(12,6),(12,5),(12,4),(12,3),(12,2),(12,1),(12,0),(11,0),(10,0),(9,0),(8,0)]] + +theorem qmaForkPatch_endpoints (e : Fin 5) : + (qmaForkPatchPath e).head? = some (qmaForkPatchVertex (qmaForkPatchLeft e)) ∧ + (qmaForkPatchPath e).getLast? = some (qmaForkPatchVertex (qmaForkPatchRight e)) := by + fin_cases e <;> decide + +theorem qmaForkPatch_chain (e : Fin 5) : + (qmaForkPatchPath e).IsChain (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := by + fin_cases e <;> decide + +theorem qmaForkPatch_simple (e : Fin 5) : (qmaForkPatchPath e).Nodup := by + fin_cases e <;> decide + +theorem qmaForkPatch_bounded (e : Fin 5) : ∀ p ∈ qmaForkPatchPath e, p.1 ≤ 12 ∧ p.2 ≤ 12 := by + fin_cases e <;> decide + +theorem qmaForkPatch_length (e : Fin 5) : (qmaForkPatchPath e).length ≤ 21 := by + fin_cases e <;> decide + +theorem qmaForkPatch_disjoint (e f : Fin 5) (hef : e ≠ f) : + Disjoint ((qmaForkPatchPath e).drop 1 |>.dropLast).toFinset (qmaForkPatchPath f).toFinset := by + fin_cases e <;> fin_cases f <;> first | exact (hef rfl).elim | decide + +theorem qmaForkPatch_vertices : Function.Injective qmaForkPatchVertex := by decide + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPlaced.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPlaced.lean new file mode 100644 index 0000000000000000000000000000000000000000..439b41d17e1f1d8d287c1053765f918766350a62 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPlaced.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkRounds + +namespace OAI + +/-! Repeated degree reduction retains the coarse cells of all active centers. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +structure QMAPlacedForkNetwork (β : Type*) (c : ℕ) where + graph : QMAForkNetwork c + cell : Fin graph.n → β + aligned : QMAForkCellAligned graph.state.ports cell + +namespace QMAPlacedForkNetwork +variable {β : Type*} {c : ℕ} + +def centerCell (G : QMAPlacedForkNetwork β c) : Fin c → β := G.cell ∘ G.graph.state.ports.center + +def next (G : QMAPlacedForkNetwork β c) : QMAPlacedForkNetwork β c where + graph := G.graph.next + cell := qmaForkCellNext G.graph.state.ports G.cell + aligned := qmaForkCellNext_aligned G.graph.state.ports G.cell G.aligned + +theorem next_centerCell (G : QMAPlacedForkNetwork β c) : G.next.centerCell = G.centerCell := by + funext i + exact qmaForkCellNext_old G.graph.state.ports G.cell (G.graph.state.ports.center i) + +def iterate (G : QMAPlacedForkNetwork β c) : ℕ → QMAPlacedForkNetwork β c + | 0 => G + | k+1 => (G.iterate k).next + +theorem iterate_graph (G : QMAPlacedForkNetwork β c) (k : ℕ) : + (G.iterate k).graph = G.graph.iterate k := by + induction k with + | zero => rfl + | succ k ih => + change (G.iterate k).graph.next = (G.graph.iterate k).next + rw [ih] + +theorem iterate_centerCell (G : QMAPlacedForkNetwork β c) (k : ℕ) : + (G.iterate k).centerCell = G.centerCell := by + induction k with + | zero => rfl + | succ k ih => exact (G.iterate k).next_centerCell.trans ih + +theorem next_cell_mass [DecidableEq β] (G : QMAPlacedForkNetwork β c) (D : ℕ) + (hd : ∀ i, G.graph.degree i ≤ D) (x : β) : + qmaCellMass G.next.cell x ≤ qmaCellMass G.cell x+2*D*qmaCellMass G.centerCell x := + qmaForkCellNext_mass_le G.graph.state.ports G.cell D hd x + +theorem iterate_cell_mass [DecidableEq β] (G : QMAPlacedForkNetwork β c) (D : ℕ) + (hd : ∀ i, G.graph.degree i ≤ D) (k : ℕ) (x : β) : + qmaCellMass (G.iterate k).cell x ≤ qmaCellMass G.cell x+2*k*D*qmaCellMass G.centerCell x := by + induction k with + | zero => simp [iterate] + | succ k ih => + have hd' : ∀ i, (G.iterate k).graph.degree i ≤ D := by + rw [G.iterate_graph] + intro i + exact ((G.graph).iterate_degree_le k i).trans (hd i) + have hs := (G.iterate k).next_cell_mass D hd' x + rw [G.iterate_centerCell] at hs + change qmaCellMass (G.iterate k).next.cell x ≤ _ + calc + _ ≤ qmaCellMass (G.iterate k).cell x+2*D*qmaCellMass G.centerCell x := hs + _ ≤ (qmaCellMass G.cell x+2*k*D*qmaCellMass G.centerCell x)+ + 2*D*qmaCellMass G.centerCell x := Nat.add_le_add_right ih _ + _ = _ := by ring + +end QMAPlacedForkNetwork +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPortSums.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPortSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b7ce303e07bf7a4ab3913d56015a6ffe1ee99a6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPortSums.lean @@ -0,0 +1,38 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkPorts + +namespace OAI + +/-! Finite-sum identities for the paired and unpaired edges of a fork layer. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +namespace QMAForkPorts +variable {n c : ℕ} {d : Fin c → ℕ} (P : QMAForkPorts n c d) +variable {M : Type*} [AddCommMonoid M] + +theorem all_port_sum (f : (Σ i, Fin (d i)) → M) : + (∑ p, f p) = + (∑ e : Fin P.pairCount, ∑ b : Fin 2, + f (qmaForkPairedPort d (P.pairEquiv.symm e,b))) + + ∑ p : QMAForkRemainder d, f (qmaForkRemainingPort d p) := by + rw [← (qmaForkAllPortEquiv d).sum_comp f,Fintype.sum_sum_type] + congr 1 + rw [← (Equiv.sigmaProdDistrib (fun i => Fin (d i / 2)) (Fin 2)).sum_comp] + change (∑ p : QMAForkPair d × Fin 2, f (qmaForkPairedPort d p)) = _ + rw [Fintype.sum_prod_type,← P.pairEquiv.symm.sum_comp] + +theorem next_port_sum (f : (Σ i, Fin (d i / 2 + d i % 2)) → M) : + (∑ p, f p) = + (∑ e : Fin P.pairCount, f (P.nextPortEquiv.symm (.inl (P.pairEquiv.symm e)))) + + ∑ p : QMAForkRemainder d, f (P.nextPortEquiv.symm (.inr p)) := by + rw [← P.nextPortEquiv.symm.sum_comp f,Fintype.sum_sum_type] + congr 1 + exact (P.pairEquiv.symm.sum_comp _).symm + +end QMAForkPorts +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a2b56dab544c1eafd4e729314312ea82dc15be1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkPorts.lean @@ -0,0 +1,131 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkDegreeBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkDegrees + +namespace OAI + +/-! Private active ports remain private after a simultaneous fork round. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical + +abbrev QMAForkPair {c : ℕ} (d : Fin c → ℕ) := Σ i, Fin (d i / 2) +abbrev QMAForkRemainder {c : ℕ} (d : Fin c → ℕ) := Σ i, Fin (d i % 2) + +def qmaForkAllPortEquiv {c : ℕ} (d : Fin c → ℕ) : + ((Σ i, Fin (d i / 2) × Fin 2) ⊕ QMAForkRemainder d) ≃ (Σ i, Fin (d i)) := + (Equiv.sigmaSumDistrib (fun i => Fin (d i / 2) × Fin 2) + (fun i => Fin (d i % 2))).symm.trans + (Equiv.sigmaCongrRight (fun i => qmaForkPortEquiv (d i))) + +def qmaForkPairedPort {c : ℕ} (d : Fin c → ℕ) (p : QMAForkPair d × Fin 2) : + Σ i, Fin (d i) := + qmaForkAllPortEquiv d (.inl (Equiv.sigmaProdDistrib (fun i => Fin (d i / 2)) (Fin 2) p)) + +def qmaForkRemainingPort {c : ℕ} (d : Fin c → ℕ) (p : QMAForkRemainder d) : + Σ i, Fin (d i) := qmaForkAllPortEquiv d (.inr p) + +theorem qmaForkPairedPort_injective {c : ℕ} (d : Fin c → ℕ) : + Function.Injective (qmaForkPairedPort d) := + (qmaForkAllPortEquiv d).injective.comp + (Sum.inl_injective.comp (Equiv.sigmaProdDistrib _ _).injective) + +theorem qmaForkRemainingPort_injective {c : ℕ} (d : Fin c → ℕ) : + Function.Injective (qmaForkRemainingPort d) := + (qmaForkAllPortEquiv d).injective.comp Sum.inr_injective + +theorem qmaForkPairedPort_ne_remaining {c : ℕ} (d : Fin c → ℕ) + (p : QMAForkPair d × Fin 2) (q : QMAForkRemainder d) : + qmaForkPairedPort d p ≠ qmaForkRemainingPort d q := by + intro h + have := (qmaForkAllPortEquiv d).injective h + cases this + +structure QMAForkPorts (n c : ℕ) (d : Fin c → ℕ) where + center : Fin c → Fin n + port : (Σ i, Fin (d i)) → Fin n + center_injective : Function.Injective center + port_injective : Function.Injective port + center_ne_port : ∀ i p, center i ≠ port p + +namespace QMAForkPorts +variable {n c : ℕ} {d : Fin c → ℕ} (P : QMAForkPorts n c d) + +abbrev pairCount (_P : QMAForkPorts n c d) := Fintype.card (QMAForkPair d) +def pairEquiv : QMAForkPair d ≃ Fin (P.pairCount) := Fintype.equivFin _ + +def site (e : Fin P.pairCount) : Fin 3 → Fin n := + ![P.center (P.pairEquiv.symm e).1, + P.port (qmaForkPairedPort d (P.pairEquiv.symm e,0)), + P.port (qmaForkPairedPort d (P.pairEquiv.symm e,1))] + +theorem site_injective (e : Fin P.pairCount) : Function.Injective (P.site e) := by + intro a b h + fin_cases a <;> fin_cases b <;> simp [site] at h ⊢ + · exact (P.center_ne_port _ _ h).elim + · exact (P.center_ne_port _ _ h).elim + · exact (P.center_ne_port _ _ h.symm).elim + · have hh := qmaForkPairedPort_injective d (P.port_injective h) + have := congrArg Prod.snd hh + norm_num at this + · exact (P.center_ne_port _ _ h.symm).elim + · have hh := qmaForkPairedPort_injective d (P.port_injective h) + have := congrArg Prod.snd hh + norm_num at this + +theorem outer_injective : Function.Injective (qmaForkOuter P.site) := by + have hf : qmaForkOuter P.site = fun p => + P.port (qmaForkPairedPort d (P.pairEquiv.symm p.1,p.2)) := by + funext p + rcases p with ⟨e,b⟩ + fin_cases b <;> simp [qmaForkOuter,site] + rw [hf] + exact P.port_injective.comp ((qmaForkPairedPort_injective d).comp + (Equiv.prodCongr P.pairEquiv.symm (Equiv.refl _)).injective) + +def nextPortEquiv (_P : QMAForkPorts n c d) : (Σ i, Fin (d i / 2 + d i % 2)) ≃ + QMAForkPair d ⊕ QMAForkRemainder d := + (Equiv.sigmaCongrRight (fun _ => finSumFinEquiv.symm)).trans + (Equiv.sigmaSumDistrib _ _) + +def nextPortAux : QMAForkPair d ⊕ QMAForkRemainder d → Fin (n + P.pairCount*2) + | .inl p => fresh n P.pairCount (P.pairEquiv p) 0 + | .inr p => old n P.pairCount (P.port (qmaForkRemainingPort d p)) + +theorem nextPortAux_injective : Function.Injective P.nextPortAux := by + intro p q h + rcases p with p | p <;> rcases q with q | q + · apply congrArg Sum.inl + apply P.pairEquiv.injective + exact congrArg Prod.fst (fresh_injective n P.pairCount + (a₁ := (P.pairEquiv p,0)) (a₂ := (P.pairEquiv q,0)) h) + · exact ((old_ne_fresh n P.pairCount _ _ _) h.symm).elim + · exact ((old_ne_fresh n P.pairCount _ _ _) h).elim + · apply congrArg Sum.inr + exact qmaForkRemainingPort_injective d (P.port_injective (old_injective n P.pairCount h)) + +def next : QMAForkPorts (n + P.pairCount*2) c (fun i => d i / 2 + d i % 2) where + center := fun i => old n P.pairCount (P.center i) + port := P.nextPortAux ∘ P.nextPortEquiv + center_injective := (old_injective n P.pairCount).comp P.center_injective + port_injective := P.nextPortAux_injective.comp P.nextPortEquiv.injective + center_ne_port := by + intro i p + change old n P.pairCount (P.center i) ≠ P.nextPortAux (P.nextPortEquiv p) + rcases P.nextPortEquiv p with q | q + · exact old_ne_fresh n P.pairCount _ _ _ + · intro h + exact P.center_ne_port _ _ (old_injective n P.pairCount h) + +theorem pairCount_bound : P.pairCount ≤ ∑ i, d i := by + change Fintype.card (QMAForkPair d) ≤ _ + simp only [QMAForkPair,Fintype.card_sigma,Fintype.card_fin] + exact Finset.sum_le_sum (fun i _ => Nat.div_le_self _ _) + +end QMAForkPorts +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdd3c4219afaeb99e47ed2f712db4e57dd7e2b20 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkProgram.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkBounds + +namespace OAI + +/-! Literal rational coefficient program for the degree-reducing fork. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkCode +open ExactQuantumFactoring.BitStackProgram QuantumRoutingCode + +noncomputable opaque offsetProgram : Procedure tripleCode ratCode + (fun x => 3/4+3*x.2.1^2+3*x.2.2^2) := by + let j := Procedure.ratMul.comp ((Procedure.constant tripleCode ratCode 3).pair (squareProgram secondProgram)) + let k := Procedure.ratMul.comp ((Procedure.constant tripleCode ratCode 3).pair (squareProgram thirdProgram)) + exact Procedure.ratAdd.comp ((Procedure.ratAdd.comp + ((Procedure.constant tripleCode ratCode (3/4)).pair j)).pair k) + +def coefficients (x : Triple) : Fin 6 → ℚ := + ![x.1^2,x.1,2*x.1*x.2.1,2*x.1*x.2.2,2*x.2.1*x.2.2, + 3/4+3*x.2.1^2+3*x.2.2^2+3*x.1^2] + +noncomputable opaque coefficientProgram (k : Fin 6) : + Procedure tripleCode ratCode (fun x => coefficients x k) := by + by_cases h0 : k = 0 + · subst k + exact (squareProgram firstProgram).congrFun (by intro x; rfl) + by_cases h1 : k = 1 + · subst k + exact firstProgram.congrFun (by intro x; rfl) + by_cases h2 : k = 2 + · subst k + exact (twiceProductProgram firstProgram secondProgram).congrFun (by intro x; rfl) + by_cases h3 : k = 3 + · subst k + exact (twiceProductProgram firstProgram thirdProgram).congrFun (by intro x; rfl) + by_cases h4 : k = 4 + · subst k + exact (twiceProductProgram secondProgram thirdProgram).congrFun (by intro x; rfl) + have h5 : k = 5 := by omega + subst k + exact (Procedure.ratAdd.comp (offsetProgram.pair + (Procedure.ratMul.comp ((Procedure.constant tripleCode ratCode 3).pair + (squareProgram firstProgram))))).congrFun (by intro x; rfl) + +noncomputable opaque coefficientListProgram : Procedure tripleCode (listCode ratCode) + (fun x => List.ofFn (coefficients x)) := + QuantumRawExchange.fixedListProgram tripleCode ratCode 6 (fun k x => coefficients x k) coefficientProgram + +noncomputable def coefficientListCertificate : Turing.TM2ComputableInPolyTime + tripleCode (listCode ratCode) (fun x => List.ofFn (coefficients x)) := coefficientListProgram.toTM2 + +theorem coefficients_spoke (x : Triple) (a : Fin 3) : + (coefficients x ⟨a.val+1,by omega⟩ : ℝ) = + qmaForkAmplitude (x.1:ℝ) (x.2.1:ℝ) (x.2.2:ℝ) a := by + fin_cases a <;> simp [coefficients,qmaForkAmplitude] + +theorem coefficients_correction (x : Triple) : + (coefficients x 4 : ℝ) = 2*(x.2.1:ℝ)*(x.2.2:ℝ) := by + simp [coefficients] + +theorem coefficients_offset (x : Triple) : + (coefficients x 5 : ℝ) = qmaForkOffset (x.2.1:ℝ) (x.2.2:ℝ)+3*(x.1:ℝ)^2 := by + simp [coefficients,qmaForkOffset] + +end ContinuumCoulomb.QuantumForkCode + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8895fcd61842ff34eac935edd353a3a0c4adc69 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRounds.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateDegree + +namespace OAI + +/-! Constantly many actual fork rounds give a degree-three graph of linear size. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +structure QMAForkNetwork (c : ℕ) where + n : ℕ + degree : Fin c → ℕ + Edge : Type + [edgeFinite : Fintype Edge] + state : QMAForkState n c degree Edge + +attribute [instance] QMAForkNetwork.edgeFinite + +namespace QMAForkNetwork +variable {c : ℕ} + +def next (G : QMAForkNetwork c) : QMAForkNetwork c where + n := G.n + G.state.ports.pairCount*2 + degree := fun i => G.degree i / 2 + G.degree i % 2 + Edge := G.state.NextEdge + state := G.state.next + +def iterate (G : QMAForkNetwork c) : ℕ → QMAForkNetwork c + | 0 => G + | k+1 => (G.iterate k).next + +theorem iterate_degree (G : QMAForkNetwork c) (k : ℕ) (i : Fin c) : + (G.iterate k).degree i = qmaForkDegreeAfter (G.degree i) k := by + induction k with + | zero => rfl + | succ k ih => + change (G.iterate k).degree i / 2 + (G.iterate k).degree i % 2 = _ + rw [ih] + rfl + +theorem next_degree_le (G : QMAForkNetwork c) (i : Fin c) : + G.next.degree i ≤ G.degree i := by + change G.degree i / 2 + G.degree i % 2 ≤ G.degree i + omega + +theorem iterate_degree_le (G : QMAForkNetwork c) (k : ℕ) (i : Fin c) : + (G.iterate k).degree i ≤ G.degree i := by + induction k with + | zero => exact le_rfl + | succ k ih => exact ((G.iterate k).next_degree_le i).trans ih + +theorem iterate_mass_le (G : QMAForkNetwork c) (k : ℕ) : + (∑ i, (G.iterate k).degree i) ≤ ∑ i, G.degree i := + Finset.sum_le_sum (fun i _ => G.iterate_degree_le k i) + +theorem iterate_vertices (G : QMAForkNetwork c) (k : ℕ) : + (G.iterate k).n ≤ G.n + 2*k*(∑ i, G.degree i) := by + induction k with + | zero => simp [iterate] + | succ k ih => + have hp := (G.iterate k).state.ports.pairCount_bound + have hm := G.iterate_mass_le k + change (G.iterate k).n + (G.iterate k).state.ports.pairCount*2 ≤ _ + calc + _ ≤ (G.n + 2*k*(∑ i, G.degree i)) + 2*(∑ i, G.degree i) := by omega + _ = G.n + 2*(k+1)*(∑ i, G.degree i) := by ring + +theorem iterate_background_edges (G : QMAForkNetwork c) (k : ℕ) : + Fintype.card (G.iterate k).Edge ≤ Fintype.card G.Edge + 4*k*(∑ i, G.degree i) := by + induction k with + | zero => + simp only [iterate,Nat.mul_zero,zero_mul,add_zero] + exact (Fintype.card_congr (Equiv.refl G.Edge)).le + | succ k ih => + have hp := (G.iterate k).state.ports.pairCount_bound + have hm := G.iterate_mass_le k + change Fintype.card (G.iterate k).state.NextEdge ≤ _ + rw [(G.iterate k).state.next_edge_count] + calc + _ ≤ (Fintype.card G.Edge + 4*k*(∑ i, G.degree i)) + 4*(∑ i, G.degree i) := by omega + _ = Fintype.card G.Edge + 4*(k+1)*(∑ i, G.degree i) := by ring + +theorem constant_round_degree (G : QMAForkNetwork c) (D : ℕ) + (hD : ∀ i, G.degree i ≤ D) (v : Fin (G.iterate D).n) : + qmaGraphDegree (G.iterate D).state.fullLeft (G.iterate D).state.fullRight v ≤ 3 := by + apply (G.iterate D).state.full_degree_le_three + intro i + rw [G.iterate_degree] + exact (qmaForkDegreeAfter_constant _ D (hD i)).trans (by decide) + +end QMAForkNetwork +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingData.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingData.lean new file mode 100644 index 0000000000000000000000000000000000000000..177fed8b762b2bc664b6a674e891ed866a62c274 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingData.lean @@ -0,0 +1,118 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkGridInitial +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListSpatialPackage +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingInputActual + +namespace OAI + +/-! A literal routing-input tape from the full fork state. Active-star bonds +are retained, and each anchor is the integer midpoint of its endpoint cells. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkRoutingData +open ExactQuantumFactoring.BitStackProgram QuantumForkList MediatorListProgram + +def star (x : ℕ × Port) : Bond := (x.1,x.2.1,x.2.2) + +noncomputable def starProgram : Procedure (prodCode Nat.bits portCode) bondCode star := + Procedure.identity bondCode + +noncomputable def starBondsProgram : + Procedure (prodCode unaryCode groupsCode) (listCode bondCode) + (fun x => starBonds x.1 (groupAt x.2 x.1)) := by + let i := Procedure.unaryToBits.comp (Procedure.first unaryCode groupsCode) + let ps := groupAtProgram + exact ((Procedure.listMapWith (f := fun i p => star (i,p)) (0,0) (0,0,0) starProgram).comp + (i.pair ps)).congrFun (by intro x; rfl) + +noncomputable def activeProgram : Procedure groupsCode (listCode bondCode) activeBonds := by + let count := ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength (listCode portCode) [] + let blocks := (Procedure.tabulate (f := fun gs i => starBonds i (groupAt gs i)) [] + starBondsProgram).comp (count.pair (Procedure.identity groupsCode)) + exact (QuantumRawExchange.flattenProgram bondCode (0,0,0)).comp blocks + +noncomputable def fullProgram : Procedure stateCode (listCode bondCode) fullList := + (Procedure.listAppend bondCode (0,0,0)).comp + (bondsProgram.pair (activeProgram.comp groupsProgram)) + +def endpoint (b : Bond) : QuantumRouteCode.Pair := (b.1,b.2.1) + +noncomputable def endpointProgram : Procedure bondCode QuantumRouteCode.pairCode endpoint := + (Procedure.first Nat.bits (prodCode Nat.bits ratCode)).pair + ((Procedure.first Nat.bits ratCode).comp (Procedure.second Nat.bits (prodCode Nat.bits ratCode))) + +abbrev Query := Bond × List QuantumRouteCode.Pair +def queryCode : Query → List Bool := prodCode bondCode (listCode QuantumRouteCode.pairCode) + +def anchor (x : Query) : QuantumRouteCode.Pair := QuantumGridMidpoint.value + (QuantumForkGridProgram.lookup x.2 x.1.1,QuantumForkGridProgram.lookup x.2 x.1.2.1) + +noncomputable def anchorProgram : Procedure queryCode QuantumRouteCode.pairCode anchor := by + let b := Procedure.first bondCode (listCode QuantumRouteCode.pairCode) + let cells := Procedure.second bondCode (listCode QuantumRouteCode.pairCode) + let ends := endpointProgram.comp b + let left := (Procedure.first Nat.bits Nat.bits).comp ends + let right := (Procedure.second Nat.bits Nat.bits).comp ends + let get := Procedure.listGet QuantumRouteCode.pairCode (0,0) + exact QuantumGridMidpoint.program.comp + ((get.comp (left.pair cells)).pair (get.comp (right.pair cells))) + +def value (x : QuantumForkGridProgram.Cells) : QuantumRoutingInputProgram.Data := + ((x.2,(fullList x.1).map (fun b => anchor (b,x.2))), + (fullList x.1).map endpoint) + +noncomputable def program : Procedure QuantumForkGridProgram.cellsCode + QuantumRoutingInputProgram.dataCode value := by + let state := Procedure.first stateCode (listCode QuantumRouteCode.pairCode) + let cells := Procedure.second stateCode (listCode QuantumRouteCode.pairCode) + let bonds := fullProgram.comp state + let anchorWith := anchorProgram.comp + ((Procedure.second (listCode QuantumRouteCode.pairCode) bondCode).pair + (Procedure.first (listCode QuantumRouteCode.pairCode) bondCode)) + let anchors := (Procedure.listMapWith + (f := fun cells b => anchor (b,cells)) (0,0,0) (0,0) anchorWith).comp (cells.pair bonds) + let ends := (Procedure.listMap (0,0,0) (0,0) endpointProgram).comp bonds + exact (cells.pair anchors).pair ends + +private theorem lookup_ofFn {n : ℕ} (f : Fin n → QuantumRouteCode.Pair) (i : Fin n) : + QuantumForkGridProgram.lookup (List.ofFn f) i.val=f i := + QuantumOrdinalProgram.lookup_ofFn f i + +theorem value_spatialModel {rows width : ℕ} (s : State) + (hs : ValidPorts s.1 s.2.2.2) (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) (cell : ℕ → QMAGridCell rows width) (A : ℕ) + (hc : ∀ p, qmaCellMass (fun v : Fin s.1 => cell v.val) p ≤ A) + (hd : ∀ v : Fin s.1, degree (fullList s) v.val ≤ 3) + (hl : BondLocal (fullList s) cell CommonCell) : + value (s,List.ofFn (fun v : Fin s.1 => ((cell v.val).1.val,(cell v.val).2.val))) = + QuantumRoutingInputProgram.actualData (spatialModel s hs hb hn cell A hc hd hl) + (Equiv.refl _) := by + let G := fullGraph s hs hb hn + let cells : Fin s.1 → QuantumRouteCode.Pair := + fun v => ((cell v.val).1.val,(cell v.val).2.val) + have endpoints : (fullList s).map endpoint = + List.ofFn (fun i : Fin (fullList s).length => endpoint ((fullList s).get i)) := by + simpa only [List.get_eq_getElem] using + (List.ofFn_getElem_eq_map (fullList s) endpoint).symm + have anchors : (fullList s).map (fun b => anchor (b,List.ofFn cells)) = + List.ofFn (fun i : Fin (fullList s).length => + QuantumGridMidpoint.value (cells (G.left i),cells (G.right i))) := by + rw [← List.ofFn_getElem_eq_map (fullList s) (fun b => anchor (b,List.ofFn cells))] + apply congrArg List.ofFn + funext i + change QuantumGridMidpoint.value + (QuantumForkGridProgram.lookup (List.ofFn cells) (G.left i).val, + QuantumForkGridProgram.lookup (List.ofFn cells) (G.right i).val) = _ + dsimp only [G,fullGraph,QuantumListGraph.ofBonds] + rw [lookup_ofFn,lookup_ofFn] + unfold value QuantumRoutingInputProgram.actualData + apply congrArg₂ Prod.mk + · apply congrArg₂ Prod.mk + · rfl + · exact anchors + · exact endpoints + +end ContinuumCoulomb.QuantumForkRoutingData + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingPaths.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd742bed2e4607583933150f3caa365c263cd437 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkRoutingPaths.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkRoutingData +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPortChainActual + +namespace OAI + +/-! The full fork-state tape computes the physical port chains used by the +ordinal spatial model, without an oracle for cells or intermediate routes. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumForkRoutingPaths +open QuantumForkList ExactQuantumFactoring.BitStackProgram + +abbrev Input := ℕ × QuantumForkGridProgram.Cells +def inputCode : Input → List Bool := prodCode unaryCode QuantumForkGridProgram.cellsCode + +def value (A B : ℕ) (x : Input) : List QuantumRouteCode.Pair := + QuantumPortChainProgram.routed A B (x.1,QuantumForkRoutingData.value x.2) + +noncomputable def program (A B : ℕ) : Procedure inputCode + (listCode QuantumRouteCode.pairCode) (value A B) := + (QuantumPortChainProgram.routedProgram A B).comp + ((Procedure.first unaryCode QuantumForkGridProgram.cellsCode).pair + (QuantumForkRoutingData.program.comp (Procedure.second unaryCode QuantumForkGridProgram.cellsCode))) + +theorem value_spatialModel {rows width : ℕ} (s : State) + (hs : ValidPorts s.1 s.2.2.2) (hb : SourceBondLists.bounded s.1 s.2.1) + (hn : ∀ b ∈ s.2.1, b.1≠b.2.1) (cell : ℕ → QMAGridCell rows width) (A : ℕ) + (hc : ∀ p, qmaCellMass (fun v : Fin s.1 => cell v.val) p ≤ A) + (hd : ∀ v : Fin s.1, degree (fullList s) v.val ≤ 3) + (hl : BondLocal (fullList s) cell CommonCell) (hA : 0 < A) + (hg : ∀ v, qmaGraphDegree (spatialModel s hs hb hn cell A hc hd hl).left + (spatialModel s hs hb hn cell A hc hd hl).right v ≤ 3) + (e : Fin (fullList s).length) : + let M := (spatialModel s hs hb hn cell A hc hd hl).withOrdinalSlots (Equiv.refl _) + value A (27*A) (e.val,(s,List.ofFn + (fun v : Fin s.1 => ((cell v.val).1.val,(cell v.val).2.val)))) = + (List.range (2*M.coarseLength hg e+2)).map + (qmaPortChain (M.coarseRoute hg e) (M.coarseLength hg e)) := by + dsimp only + unfold value + rw [QuantumForkRoutingData.value_spatialModel s hs hb hn cell A hc hd hl] + exact QuantumPortChainProgram.routed_actual + (spatialModel s hs hb hn cell A hc hd hl) (Equiv.refl _) hA hg e + +end ContinuumCoulomb.QuantumForkRoutingPaths + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkSpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkSpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..509e6bc8f1f6b141f03445803740b45dbc956636 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkSpectrum.lean @@ -0,0 +1,45 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkEffective +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingPhysical + +namespace OAI + +/-! Full-space energy comparison for the rational fork gadget. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker + +theorem qmaForkCorrection_star {n : ℕ} (site : Fin 3 → Fin n) + (hsite : Function.Injective site) (J K : ℝ) : + (qmaForkCorrection site J K).conjTranspose = qmaForkCorrection site J K := by + have hne : site 1 ≠ site 2 := fun h => (by decide : (1:Fin 3) ≠ 2) (hsite h) + simp only [qmaForkCorrection,Matrix.conjTranspose_add,Matrix.conjTranspose_smul, + Matrix.conjTranspose_one,sourceHeisenbergMatrix_star n _ _ hne, + Complex.star_def,Complex.conj_ofReal] + +theorem qmaFork_bottom {n r : ℕ} (e : Fin r) (site : Fin 3 → Fin n) + (hsite : Function.Injective site) (R J K : ℝ) (hR : 0 < R) + (C : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) (hC : C.conjTranspose = C) + {epsilon : ℝ} (hepsilon : 0 ≤ epsilon) (hsmall : epsilon ≤ 1/4) + (hbound : ‖spinMatrixOperator ((C + qmaForkCorrection site J K) ⊗ₖ + (1 : Matrix (MediatorBasis r) (MediatorBasis r) ℂ))‖ + + 3*∑ a, |qmaForkAmplitude R J K a| ≤ epsilon * (4*R^2)) : + |mediatorFullBottom n r (routingHamiltonian n r (R^2) + (C + qmaForkCorrection site J K) + (qmaSingletStar n r e site qmaForkMember (qmaForkAmplitude R J K))) - + sourceMatrixBottom n (C + ((J:ℂ) • sourceHeisenbergMatrix n (site 0) (site 1) + + (K:ℂ) • sourceHeisenbergMatrix n (site 0) (site 2)))| ≤ 16*R^2*epsilon^3 := by + have hCW : (C + qmaForkCorrection site J K).conjTranspose = + C + qmaForkCorrection site J K := by + rw [Matrix.conjTranspose_add,hC,qmaForkCorrection_star site hsite] + have h := qmaSingletStar_bottom n r (sq_pos_of_pos hR) _ hCW e site + qmaForkMember (qmaForkAmplitude R J K) hepsilon hsmall hbound + rw [add_sub_assoc,qmaFork_effective e site hsite R J K hR.ne'] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarGround.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarGround.lean new file mode 100644 index 0000000000000000000000000000000000000000..06952984d0948a339aa200e575447cb99412b637 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarGround.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStarIndex + +namespace OAI + +/-! Full-space degree reduction for a star with an arbitrary number of ports. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Kronecker Classical + +theorem qmaForkStar_target (d : ℕ) (constant : ℝ) (J : Fin d → ℝ) : + qmaExchangeMatrix (fun _ : Fin (d%2) => qmaForkCenter d) + (fun k => qmaForkPort d (qmaForkPortEquiv d (.inr k))) + (fun k => J (qmaForkPortEquiv d (.inr k))) constant + + ∑ i, ((J (qmaForkPortEquiv d (.inl (i,0))):ℂ) • + sourceHeisenbergMatrix (1+d) (qmaForkStarSite d i 0) (qmaForkStarSite d i 1) + + (J (qmaForkPortEquiv d (.inl (i,1))):ℂ) • + sourceHeisenbergMatrix (1+d) (qmaForkStarSite d i 0) (qmaForkStarSite d i 2)) = + qmaExchangeMatrix (fun _ : Fin d => qmaForkCenter d) (qmaForkPort d) J constant := by + have hs := (qmaForkPortEquiv d).sum_comp (fun j => (J j:ℂ) • + sourceHeisenbergMatrix (1+d) (qmaForkCenter d) (qmaForkPort d j)) + rw [Fintype.sum_sum_type,Fintype.sum_prod_type] at hs + simp only [Fin.sum_univ_two] at hs + simp only [qmaExchangeMatrix,qmaForkStarSite,Matrix.cons_val_zero] + rw [← hs] + abel + +theorem qmaForkStar_accuracy (d : ℕ) (constant : ℝ) (J : Fin d → ℝ) {N : ℝ} (hN : 0 < N) : + let B := 3*(∑ k : Fin (d%2), |J (qmaForkPortEquiv d (.inr k))|)+|constant| + let A := 3*∑ i, (1+2*|J (qmaForkPortEquiv d (.inl (i,0)))|+ + 2*|J (qmaForkPortEquiv d (.inl (i,1)))|) + let D := B+12*∑ i, (1+|J (qmaForkPortEquiv d (.inl (i,0)))|+ + |J (qmaForkPortEquiv d (.inl (i,1)))|)^2 + let R := qmaRoutingScale A D N + |sourceMatrixBottom ((1+d)+(d/2)*2) + (qmaExchangeMatrix (fun e => qmaForkStarEmbedding d (qmaForkStarLeft d e)) + (fun e => qmaForkStarEmbedding d (qmaForkStarRight d e)) (qmaForkStarWeight d R J) + (qmaForkStarOffset d constant R J)) - + sourceMatrixBottom (1+d) + (qmaExchangeMatrix (fun _ : Fin d => qmaForkCenter d) (qmaForkPort d) J constant)| ≤ 1/N := by + have hneq (k : Fin (d%2)) : qmaForkCenter d ≠ qmaForkPort d (qmaForkPortEquiv d (.inr k)) := by + simp [qmaForkCenter,qmaForkPort] + have h := qmaForksGraph_accuracy + (fun _ : Fin (d%2) => qmaForkCenter d) + (fun k => qmaForkPort d (qmaForkPortEquiv d (.inr k))) hneq + (fun k => J (qmaForkPortEquiv d (.inr k))) constant + (qmaForkStarSite d) (qmaForkStarSite_injective d) + (fun i => J (qmaForkPortEquiv d (.inl (i,0)))) + (fun i => J (qmaForkPortEquiv d (.inl (i,1)))) hN + dsimp only at h ⊢ + rw [← qmaForkStar_matrix,qmaForkStar_target] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarIndex.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ef24bccf670d85e6ffb9b29b2d56ed3d61e11c4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStarIndex.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkDegrees +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkGraph + +namespace OAI + +/-! The degree-counted fork star is the actual ordinary-spin gadget graph. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Kronecker Classical + +def qmaForkOldEquiv (d : ℕ) : Unit ⊕ Fin d ≃ Fin (1+d) := + (Equiv.sumCongr (Equiv.ofUnique Unit (Fin 1)) (Equiv.refl _)).trans finSumFinEquiv + +def qmaForkCenter (d : ℕ) : Fin (1+d) := qmaForkOldEquiv d (.inl ()) +def qmaForkPort (d : ℕ) (j : Fin d) : Fin (1+d) := qmaForkOldEquiv d (.inr j) + +def qmaForkStarEmbedding (d : ℕ) : QMAForkStarVertex d ≃ Fin ((1+d)+(d/2)*2) := + (((Equiv.sumAssoc Unit (Fin d) (Fin (d/2) × Fin 2)).symm).trans + (Equiv.sumCongr (qmaForkOldEquiv d) (Equiv.refl _))).trans (vertexEquiv (1+d) (d/2)) + +@[simp] theorem qmaForkStarEmbedding_center (d : ℕ) : + qmaForkStarEmbedding d (.inl ()) = old (1+d) (d/2) (qmaForkCenter d) := rfl +@[simp] theorem qmaForkStarEmbedding_port (d : ℕ) (j : Fin d) : + qmaForkStarEmbedding d (.inr (.inl j)) = old (1+d) (d/2) (qmaForkPort d j) := rfl +@[simp] theorem qmaForkStarEmbedding_new (d : ℕ) (i : Fin (d/2)) (b : Fin 2) : + qmaForkStarEmbedding d (.inr (.inr (i,b))) = fresh (1+d) (d/2) i b := rfl + +def qmaForkStarSite (d : ℕ) (i : Fin (d/2)) : Fin 3 → Fin (1+d) := + ![qmaForkCenter d,qmaForkPort d (qmaForkPortEquiv d (.inl (i,0))), + qmaForkPort d (qmaForkPortEquiv d (.inl (i,1)))] + +theorem qmaForkStarSite_injective (d : ℕ) (i : Fin (d/2)) : + Function.Injective (qmaForkStarSite d i) := by + intro a b h + fin_cases a <;> fin_cases b <;> + simp [qmaForkStarSite,qmaForkCenter,qmaForkPort] at h ⊢ + +theorem qmaForkStar_degree_transport (d : ℕ) (v : QMAForkStarVertex d) : + (∑ e, if qmaForkStarEmbedding d (qmaForkStarLeft d e) = qmaForkStarEmbedding d v ∨ + qmaForkStarEmbedding d (qmaForkStarRight d e) = qmaForkStarEmbedding d v then 1 else 0) = + qmaForkStarDegree d v := by + simp only [Equiv.apply_eq_iff_eq,qmaForkStarDegree] + +def qmaForkStarWeight (d : ℕ) (R : ℝ) (J : Fin d → ℝ) : QMAForkStarEdge d → ℝ + | .inl _ => R^2 + | .inr (.inl _) => R + | .inr (.inr (.inl p)) => 2*R*J (qmaForkPortEquiv d (.inl p)) + | .inr (.inr (.inr (.inl i))) => + 2*J (qmaForkPortEquiv d (.inl (i,0)))*J (qmaForkPortEquiv d (.inl (i,1))) + | .inr (.inr (.inr (.inr k))) => J (qmaForkPortEquiv d (.inr k)) + +def qmaForkStarOffset (d : ℕ) (constant R : ℝ) (J : Fin d → ℝ) : ℝ := + (constant+∑ i, qmaForkOffset (J (qmaForkPortEquiv d (.inl (i,0)))) + (J (qmaForkPortEquiv d (.inl (i,1)))))+3*((d/2:ℕ):ℝ)*(R^2) + +theorem qmaForkStar_matrix (d : ℕ) (constant R : ℝ) (J : Fin d → ℝ) : + qmaExchangeMatrix (fun e => qmaForkStarEmbedding d (qmaForkStarLeft d e)) + (fun e => qmaForkStarEmbedding d (qmaForkStarRight d e)) (qmaForkStarWeight d R J) + (qmaForkStarOffset d constant R J) = + qmaForksGraph (fun _ : Fin (d%2) => qmaForkCenter d) + (fun k => qmaForkPort d (qmaForkPortEquiv d (.inr k))) + (fun k => J (qmaForkPortEquiv d (.inr k))) constant R (qmaForkStarSite d) + (fun i => J (qmaForkPortEquiv d (.inl (i,0)))) + (fun i => J (qmaForkPortEquiv d (.inl (i,1)))) := by + simp only [qmaForksGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + Fin.sum_univ_two,Fin.sum_univ_three,qmaForkStarLeft,qmaForkStarRight,qmaForkStarWeight,qmaForkStarOffset, + qmaParallelGraphLeft,qmaParallelGraphRight,qmaParallelGraphWeight,qmaForksBaseLeft, + qmaForksBaseRight,qmaForksBaseWeight,Sum.elim_inl,Sum.elim_inr,qmaForkMember,qmaForkAmplitude, + qmaForkStarSite,Matrix.cons_val_zero, + qmaForkStarEmbedding_center,qmaForkStarEmbedding_port,qmaForkStarEmbedding_new, + Complex.ofReal_mul,Complex.ofReal_ofNat,Complex.ofReal_pow,Finset.sum_add_distrib] + simp only [Complex.ofReal_mul,Complex.ofReal_ofNat, + Complex.ofReal_pow,Complex.ofReal_add,add_smul] + push_cast + abel + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkState.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkState.lean new file mode 100644 index 0000000000000000000000000000000000000000..37e2c397e17a4976da0a300a9a0057046a75f5c7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkState.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkBackground + +namespace OAI + +/-! A repeatable fork stage: only active stars may have large degree. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical + +structure QMAForkState (n c : ℕ) (d : Fin c → ℕ) (ν : Type*) [Fintype ν] where + ports : QMAForkPorts n c d + left : ν → Fin n + right : ν → Fin n + distinct : ∀ e, left e ≠ right e + degree_le : ∀ v, qmaGraphDegree left right v ≤ 3 + center_degree : ∀ i, qmaGraphDegree left right (ports.center i) = 0 + port_degree : ∀ p, qmaGraphDegree left right (ports.port p) ≤ 1 + +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +abbrev NextEdge := (ν ⊕ Fin G.ports.pairCount) ⊕ + (Fin G.ports.pairCount ⊕ (Fin G.ports.pairCount × Fin 2)) + +theorem site_away_center (i : Fin c) (e : Fin G.ports.pairCount) : + G.ports.site e 1 ≠ G.ports.center i ∧ G.ports.site e 2 ≠ G.ports.center i := by + constructor <;> exact fun h => G.ports.center_ne_port _ _ h.symm + +theorem site_away_remaining (p : QMAForkRemainder d) (e : Fin G.ports.pairCount) : + G.ports.site e 1 ≠ G.ports.port (qmaForkRemainingPort d p) ∧ + G.ports.site e 2 ≠ G.ports.port (qmaForkRemainingPort d p) := by + constructor <;> intro h + · exact qmaForkPairedPort_ne_remaining d _ p (G.ports.port_injective h) + · exact qmaForkPairedPort_ne_remaining d _ p (G.ports.port_injective h) + +def next : QMAForkState (n + G.ports.pairCount*2) c + (fun i => d i / 2 + d i % 2) G.NextEdge where + ports := G.ports.next + left := qmaForkBackgroundLeft G.left G.ports.site + right := qmaForkBackgroundRight G.right G.ports.site + distinct := qmaParallelGraph_distinct _ _ + (qmaForksBase_distinct G.left G.right G.distinct G.ports.site G.ports.site_injective) + (fun e b => qmaForkOuter G.ports.site (e,b)) (fun _ _ => 1) + degree_le := qmaForkBackground_degree_le_three G.left G.right G.ports.site + G.ports.site_injective G.ports.outer_injective G.degree_le (by + intro e b + fin_cases b <;> exact G.port_degree _) + center_degree := by + intro i + change qmaGraphDegree _ _ (old n G.ports.pairCount (G.ports.center i)) = 0 + rw [qmaForkBackground_away_degree G.left G.right G.ports.site + G.ports.site_injective _ (G.site_away_center i)] + exact G.center_degree i + port_degree := by + intro p + change qmaGraphDegree _ _ (G.ports.nextPortAux (G.ports.nextPortEquiv p)) ≤ 1 + rcases G.ports.nextPortEquiv p with p | p + · change qmaGraphDegree _ _ (fresh n G.ports.pairCount (G.ports.pairEquiv p) 0) ≤ 1 + rw [qmaForkBackground_new_degree] + norm_num + · change qmaGraphDegree _ _ (old n G.ports.pairCount + (G.ports.port (qmaForkRemainingPort d p))) ≤ 1 + rw [qmaForkBackground_away_degree G.left G.right G.ports.site + G.ports.site_injective _ (G.site_away_remaining p)] + exact G.port_degree _ + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..014b1dc8472d46c1ef3f4888fa0158001300a83e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateAccuracy.lean @@ -0,0 +1,35 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateNextMatrix + +namespace OAI + +/-! Full-space spectral error of the repeatable active-star transition. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +theorem next_accuracy (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) + (constant : ℝ) {N : ℝ} (hN : 0 < N) : + let B := 3*(∑ a, |G.retainedWeight w J a|)+|constant| + let A := 3*∑ e, (1+2*|G.pairWeight J 0 e|+2*|G.pairWeight J 1 e|) + let D := B+12*∑ e, (1+|G.pairWeight J 0 e|+|G.pairWeight J 1 e|)^2 + let R := qmaRoutingScale A D N + |sourceMatrixBottom (n+G.ports.pairCount*2) + (G.next.matrix (G.nextWeight R w J) (G.nextActive R J) (G.nextConstant R constant J)) - + sourceMatrixBottom n (G.matrix w J constant)| ≤ 1/N := by + dsimp only + rw [G.next_matrix_is_forks,G.matrix_pair_split] + exact qmaForksGraph_accuracy G.retainedLeft G.retainedRight G.retained_distinct + (G.retainedWeight w J) constant G.ports.site G.ports.site_injective + (G.pairWeight J 0) (G.pairWeight J 1) hN + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..caaccf8e856684e839725732f1e31463f71b2288 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateDegree.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkState + +namespace OAI + +/-! Degree and size of the entire graph represented by active stars and background edges. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +def fullLeft : ν ⊕ (Σ i, Fin (d i)) → Fin n := + Sum.elim G.left (fun p => G.ports.center p.1) +def fullRight : ν ⊕ (Σ i, Fin (d i)) → Fin n := + Sum.elim G.right G.ports.port + +theorem full_distinct (e : ν ⊕ (Σ i, Fin (d i))) : G.fullLeft e ≠ G.fullRight e := by + rcases e with e | p + · exact G.distinct e + · exact G.ports.center_ne_port p.1 p + +theorem full_center_degree (i : Fin c) : + qmaGraphDegree G.fullLeft G.fullRight (G.ports.center i) = d i := by + rw [fullLeft,fullRight,qmaGraphDegree_sum,G.center_degree,zero_add] + have hp (p : Σ i, Fin (d i)) : G.ports.port p ≠ G.ports.center i := + (G.ports.center_ne_port i p).symm + simp only [qmaGraphDegree,hp,or_false,G.ports.center_injective.eq_iff,Fintype.sum_sigma] + rw [Finset.sum_eq_single i] + · simp + · intro j _ hj + simp [hj] + · simp + +theorem full_noncenter_degree (v : Fin n) (hv : ∀ i, G.ports.center i ≠ v) : + qmaGraphDegree G.fullLeft G.fullRight v ≤ 3 := by + rw [fullLeft,fullRight,qmaGraphDegree_sum] + have hc : qmaGraphDegree (fun p : Σ i, Fin (d i) => G.ports.center p.1) G.ports.port v = + ∑ p, if G.ports.port p = v then 1 else 0 := by + simp only [qmaGraphDegree,hv,false_or] + rw [hc] + by_cases hp : ∃ p, G.ports.port p = v + · obtain ⟨p,rfl⟩ := hp + have hb := G.port_degree p + have hs := qmaCount_eq_le_one G.ports.port G.ports.port_injective (G.ports.port p) + omega + · have hn (p : Σ i, Fin (d i)) : G.ports.port p ≠ v := fun h => hp ⟨p,h⟩ + simpa [hn] using G.degree_le v + +theorem full_degree_le_three (hd : ∀ i, d i ≤ 3) (v : Fin n) : + qmaGraphDegree G.fullLeft G.fullRight v ≤ 3 := by + by_cases h : ∃ i, G.ports.center i = v + · obtain ⟨i,rfl⟩ := h + rw [G.full_center_degree] + exact hd i + · exact G.full_noncenter_degree v (by simpa using h) + +theorem full_edge_count : Fintype.card (ν ⊕ (Σ i, Fin (d i))) = + Fintype.card ν + ∑ i, d i := by + simp [Fintype.card_sigma] + +theorem next_edge_count : Fintype.card G.NextEdge = + Fintype.card ν + 4*G.ports.pairCount := by + simp only [NextEdge,Fintype.card_sum,Fintype.card_prod,Fintype.card_fin] + omega + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c96739e1a36861ef3438619f7194d2d1a40dc70 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateMatrix.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateDegree +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkPortSums + +namespace OAI + +/-! The repeated fork state carries the original ordinary-spin Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Classical +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +def matrix (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) (constant : ℝ) := + qmaExchangeMatrix G.fullLeft G.fullRight (Sum.elim w J) constant + +def retainedLeft : ν ⊕ QMAForkRemainder d → Fin n := + Sum.elim G.left (fun p => G.ports.center p.1) +def retainedRight : ν ⊕ QMAForkRemainder d → Fin n := + Sum.elim G.right (fun p => G.ports.port (qmaForkRemainingPort d p)) +def retainedWeight (_G : QMAForkState n c d ν) (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) : + ν ⊕ QMAForkRemainder d → ℝ := + Sum.elim w (fun p => J (qmaForkRemainingPort d p)) + +def pairWeight (J : (Σ i, Fin (d i)) → ℝ) (b : Fin 2) (e : Fin G.ports.pairCount) : ℝ := + J (qmaForkPairedPort d (G.ports.pairEquiv.symm e,b)) + +theorem retained_distinct (e : ν ⊕ QMAForkRemainder d) : + G.retainedLeft e ≠ G.retainedRight e := by + rcases e with e | p + · exact G.distinct e + · exact G.ports.center_ne_port p.1 _ + +theorem matrix_pair_split (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) (constant : ℝ) : + G.matrix w J constant = + qmaExchangeMatrix G.retainedLeft G.retainedRight (G.retainedWeight w J) constant + + ∑ e, (((G.pairWeight J 0 e : ℝ):ℂ) • + sourceHeisenbergMatrix n (G.ports.site e 0) (G.ports.site e 1) + + ((G.pairWeight J 1 e : ℝ):ℂ) • + sourceHeisenbergMatrix n (G.ports.site e 0) (G.ports.site e 2)) := by + have hs := G.ports.all_port_sum (fun p => (J p : ℂ) • + sourceHeisenbergMatrix n (G.ports.center p.1) (G.ports.port p)) + simp only [Fin.sum_univ_two] at hs + change (∑ p, (J p : ℂ) • sourceHeisenbergMatrix n (G.ports.center p.1) (G.ports.port p)) = + (∑ e, (((G.pairWeight J 0 e : ℝ):ℂ) • + sourceHeisenbergMatrix n (G.ports.site e 0) (G.ports.site e 1) + + ((G.pairWeight J 1 e : ℝ):ℂ) • + sourceHeisenbergMatrix n (G.ports.site e 0) (G.ports.site e 2))) + + ∑ p, (J (qmaForkRemainingPort d p) : ℂ) • sourceHeisenbergMatrix n + (G.ports.center p.1) (G.ports.port (qmaForkRemainingPort d p)) at hs + simp only [matrix,qmaExchangeMatrix,fullLeft,fullRight,retainedLeft,retainedRight, + retainedWeight,Fintype.sum_sum_type,Sum.elim_inl,Sum.elim_inr] + rw [hs] + abel + +def nextWeight (R : ℝ) (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) : G.NextEdge → ℝ + | .inl (.inl e) => w e + | .inl (.inr e) => 2*G.pairWeight J 0 e*G.pairWeight J 1 e + | .inr (.inl _) => R^2 + | .inr (.inr (e,b)) => 2*R*G.pairWeight J b e + +def nextActive (R : ℝ) (J : (Σ i, Fin (d i)) → ℝ) + (p : Σ i, Fin (d i / 2 + d i % 2)) : ℝ := + match G.ports.nextPortEquiv p with + | .inl _ => R + | .inr p => J (qmaForkRemainingPort d p) + +def nextConstant (R constant : ℝ) (J : (Σ i, Fin (d i)) → ℝ) : ℝ := + (constant + ∑ e, qmaForkOffset (G.pairWeight J 0 e) (G.pairWeight J 1 e)) + + 3*(G.ports.pairCount : ℝ)*R^2 + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateNextMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateNextMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce086d5fd03e52079d8b5c4cfba3b9ddfa0a7ad7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkStateNextMatrix.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateMatrix + +namespace OAI + +/-! The active-star transition is exactly the calibrated parallel fork Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix MediatorGraph +open scoped BigOperators Classical +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +theorem matrix_expand (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) (constant : ℝ) : + G.matrix w J constant = + ((∑ e, (w e:ℂ) • sourceHeisenbergMatrix n (G.left e) (G.right e)) + + ∑ p, (J p:ℂ) • sourceHeisenbergMatrix n (G.ports.center p.1) (G.ports.port p)) + + (constant:ℂ) • 1 := by + simp only [matrix,qmaExchangeMatrix,fullLeft,fullRight,Fintype.sum_sum_type, + Sum.elim_inl,Sum.elim_inr] + +theorem next_active_sum (R : ℝ) (J : (Σ i, Fin (d i)) → ℝ) : + (∑ p, (G.nextActive R J p:ℂ) • sourceHeisenbergMatrix (n+G.ports.pairCount*2) + (G.next.ports.center p.1) (G.next.ports.port p)) = + (∑ e, (R:ℂ) • sourceHeisenbergMatrix (n+G.ports.pairCount*2) + (old n G.ports.pairCount (G.ports.site e 0)) (fresh n G.ports.pairCount e 0)) + + ∑ p : QMAForkRemainder d, (J (qmaForkRemainingPort d p):ℂ) • + sourceHeisenbergMatrix (n+G.ports.pairCount*2) + (old n G.ports.pairCount (G.ports.center p.1)) + (old n G.ports.pairCount (G.ports.port (qmaForkRemainingPort d p))) := by + rw [G.ports.next_port_sum] + congr 1 + · apply Finset.sum_congr rfl + intro e _ + simp only [nextActive,next,QMAForkPorts.next,Function.comp_apply, + Equiv.apply_symm_apply,QMAForkPorts.nextPortAux] + rfl + · apply Finset.sum_congr rfl + intro p _ + simp only [nextActive,next,QMAForkPorts.next,Function.comp_apply, + Equiv.apply_symm_apply,QMAForkPorts.nextPortAux] + rfl + +theorem next_matrix_is_forks (R : ℝ) (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) + (constant : ℝ) : + G.next.matrix (G.nextWeight R w J) (G.nextActive R J) (G.nextConstant R constant J) = + qmaForksGraph G.retainedLeft G.retainedRight (G.retainedWeight w J) constant R + G.ports.site (G.pairWeight J 0) (G.pairWeight J 1) := by + rw [matrix_expand,G.next_active_sum] + simp only [qmaForksGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + Fin.sum_univ_two,Fin.sum_univ_three,next,qmaForkBackgroundLeft,qmaForkBackgroundRight, + qmaParallelGraphLeft,qmaParallelGraphRight,qmaParallelGraphWeight, + qmaForksBaseLeft,qmaForksBaseRight,qmaForksBaseWeight,nextWeight,nextConstant, + retainedLeft,retainedRight,retainedWeight,Sum.elim_inl,Sum.elim_inr, + qmaForkAmplitude,qmaForkMember,qmaForkOuter] + simp only [ite_true,Finset.sum_add_distrib] + ac_rfl + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkWeightBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkWeightBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..48d2b61c20b65e65b10ecc7664cac2e7715a7be5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumForkWeightBounds.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkStateMatrix + +namespace OAI + +/-! Coefficient growth of the repeatable fork stage is polynomial. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +theorem qmaForkOffset_abs_le {J K L : ℝ} (hL : 1 ≤ L) (hJ : |J| ≤ L) (hK : |K| ≤ L) : + |qmaForkOffset J K| ≤ 7*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hJ2 : J^2 ≤ L^2 := by nlinarith [sq_abs J,mul_self_le_mul_self (abs_nonneg J) hJ] + have hK2 : K^2 ≤ L^2 := by nlinarith [sq_abs K,mul_self_le_mul_self (abs_nonneg K) hK] + have hL2 : 1 ≤ L^2 := one_le_pow₀ hL + rw [abs_of_nonneg (by unfold qmaForkOffset; positivity)] + unfold qmaForkOffset + nlinarith + +namespace QMAForkState +variable {n c : ℕ} {d : Fin c → ℕ} {ν : Type*} [Fintype ν] +variable (G : QMAForkState n c d ν) + +theorem nextWeight_abs_le (R : ℝ) (w : ν → ℝ) (J : (Σ i, Fin (d i)) → ℝ) + {L : ℝ} (hL : 1 ≤ L) (hR : |R| ≤ L) (hw : ∀ e, |w e| ≤ L) + (hJ : ∀ p, |J p| ≤ L) (e : G.NextEdge) : |G.nextWeight R w J e| ≤ 2*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hL2 : L ≤ L^2 := by nlinarith + rcases e with (e | e) | (e | ⟨e,b⟩) + · exact (hw e).trans (by nlinarith) + · change |2*G.pairWeight J 0 e*G.pairWeight J 1 e| ≤ _ + rw [abs_mul,abs_mul,abs_of_nonneg (by norm_num : (0:ℝ) ≤ 2)] + have hp := mul_le_mul (hJ (qmaForkPairedPort d (G.ports.pairEquiv.symm e,0))) + (hJ (qmaForkPairedPort d (G.ports.pairEquiv.symm e,1))) + (abs_nonneg _) hL0 + dsimp [pairWeight] at * + nlinarith + · change |R^2| ≤ _ + rw [abs_of_nonneg (sq_nonneg R)] + nlinarith [mul_self_le_mul_self (abs_nonneg R) hR,sq_abs R] + · change |2*R*G.pairWeight J b e| ≤ _ + rw [abs_mul,abs_mul,abs_of_nonneg (by norm_num : (0:ℝ) ≤ 2)] + have hp := mul_le_mul hR (hJ (qmaForkPairedPort d (G.ports.pairEquiv.symm e,b))) + (abs_nonneg _) hL0 + dsimp [pairWeight] at * + nlinarith + +theorem nextActive_abs_le (R : ℝ) (J : (Σ i, Fin (d i)) → ℝ) {L : ℝ} + (hR : |R| ≤ L) (hJ : ∀ p, |J p| ≤ L) (p : Σ i, Fin (d i / 2 + d i % 2)) : + |G.nextActive R J p| ≤ L := by + unfold nextActive + split + · exact hR + · exact hJ _ + +theorem nextConstant_abs_le (R constant : ℝ) (J : (Σ i, Fin (d i)) → ℝ) + {L : ℝ} (hL : 1 ≤ L) (hR : |R| ≤ L) (hJ : ∀ p, |J p| ≤ L) : + |G.nextConstant R constant J| ≤ |constant|+10*(G.ports.pairCount:ℝ)*L^2 := by + have hL0 : 0 ≤ L := by linarith + have hR2 : R^2 ≤ L^2 := by nlinarith [mul_self_le_mul_self (abs_nonneg R) hR,sq_abs R] + have hs : |∑ e, qmaForkOffset (G.pairWeight J 0 e) (G.pairWeight J 1 e)| ≤ + (G.ports.pairCount:ℝ)*(7*L^2) := by + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _e : Fin G.ports.pairCount, 7*L^2 := Finset.sum_le_sum (fun e _ => + qmaForkOffset_abs_le hL (hJ _) (hJ _)) + _ = _ := by simp + unfold nextConstant + have hb := abs_add_le (constant+∑ e, qmaForkOffset (G.pairWeight J 0 e) (G.pairWeight J 1 e)) + (3*(G.ports.pairCount:ℝ)*R^2) + have hc := abs_add_le constant (∑ e, qmaForkOffset (G.pairWeight J 0 e) (G.pairWeight J 1 e)) + rw [abs_of_nonneg (by positivity : 0 ≤ 3*(G.ports.pairCount:ℝ)*R^2)] at hb + nlinarith [mul_le_mul_of_nonneg_left hR2 (by positivity : 0 ≤ (G.ports.pairCount:ℝ))] + +end QMAForkState +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourAxis.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourAxis.lean new file mode 100644 index 0000000000000000000000000000000000000000..0960f7cda3d4eadf9f9c30a506a40b28c95166ba --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourAxis.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourStencils +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourFields + +namespace OAI + +/-! A common interface for the fixed X and Z exchange encodings. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourAxis (a : Fin 2) : Matrix (Fin 2) (Fin 2) ℂ := if a = 0 then pauliX else pauliZ +def qmaFourAxisWeights (a : Fin 2) (p : Bool) : Fin 4 → ℝ := + if a = 0 then qmaFourXWeights p else qmaFourZWeights p +def qmaFourAxisShift (a : Fin 2) (p : Bool) : ℝ := + if a = 0 then 400 else if p then 8/3 else 4/3 +def qmaFourAxisScale (a : Fin 2) : ℝ := if a = 0 then 128*Real.sqrt 3 else 4/3 +def qmaFourAxisSign (p : Bool) : ℝ := if p then 1 else -1 + +theorem qmaFourAxisScale_pos (a : Fin 2) : 0 < qmaFourAxisScale a := by + fin_cases a <;> simp only [qmaFourAxisScale,Fin.zero_eta,ite_true,Fin.isValue,Fin.mk_one, + Fin.reduceEq,ite_false] + · positivity + · norm_num + +theorem qmaFourAxisWeights_correlation (a : Fin 2) (p : Bool) : + qmaFourWeightedCorrelation (qmaFourAxisWeights a p) = + (qmaFourAxisShift a p:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + ((qmaFourAxisSign p*qmaFourAxisScale a:ℝ):ℂ) • qmaFourAxis a := by + fin_cases a <;> cases p <;> + simp [qmaFourAxisWeights,qmaFourAxisShift,qmaFourAxisSign,qmaFourAxisScale,qmaFourAxis, + qmaFourXWeights_true,qmaFourXWeights_false,qmaFourZWeights_true,qmaFourZWeights_false,neg_div,neg_smul] + +def qmaFourAxisField (a : Fin 2) (t : ℝ) : Matrix (Fin 16) (Fin 16) ℂ := + if a = 0 then qmaFourField t 0 else qmaFourField 0 t + +def qmaFourAxisFieldShift (a : Fin 2) (t : ℝ) : ℝ := if a = 0 then 0 else t/2 + +theorem qmaFourAxisField_compression (a : Fin 2) (t : ℝ) : + qmaFourEncoding.conjTranspose*qmaFourAxisField a t*qmaFourEncoding = + (t:ℂ) • qmaFourAxis a+(qmaFourAxisFieldShift a t:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ) := by + fin_cases a <;> simp [qmaFourAxisField,qmaFourAxis,qmaFourAxisFieldShift,qmaFourField_compression] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourBasis.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..d68ea6c0fead8c53ae99b566c9a39f7c00647818 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourBasis.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourcePauli +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRectangularOperator + +namespace OAI + +/-! Fixed four-spin coordinates for the exchange-only encoding. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourBits (n : Fin 16) : Fin 4 → Fin 2 := + ![⟨n.val/8,by have hn := n.isLt; omega⟩, + ⟨n.val/4%2,by omega⟩,⟨n.val/2%2,by omega⟩,⟨n.val%2,by omega⟩] + +def qmaFourIndex (s : Fin 4 → Fin 2) : Fin 16 := + ⟨8*(s 0).val+4*(s 1).val+2*(s 2).val+(s 3).val,by + have h0 := (s 0).isLt + have h1 := (s 1).isLt + have h2 := (s 2).isLt + have h3 := (s 3).isLt + omega⟩ + +def qmaFourBasisEquiv : (Fin 4 → Fin 2) ≃ Fin 16 where + toFun := qmaFourIndex + invFun := qmaFourBits + left_inv s := by + funext i + have h0 := (s 0).isLt + have h1 := (s 1).isLt + have h2 := (s 2).isLt + have h3 := (s 3).isLt + fin_cases i <;> apply Fin.ext <;> simp [qmaFourBits,qmaFourIndex] <;> omega + right_inv n := by + apply Fin.ext + have hn := n.isLt + simp [qmaFourBits,qmaFourIndex] + omega + +def qmaFourExchangeRational (i j : Fin 4) : Matrix (Fin 16) (Fin 16) ℚ := + fun s t => 2*(if qmaFourIndex (sourceSpinSwap i j (qmaFourBits s)) = t then 1 else 0)- + (if s = t then 1 else 0) + +def qmaFourExchange (i j : Fin 4) : Matrix (Fin 16) (Fin 16) ℂ := + fun s t => qmaFourExchangeRational i j s t + +theorem qmaFourExchange_source (i j : Fin 4) : qmaFourExchange i j = + (sourceHeisenbergMatrix 4 i j).submatrix qmaFourBits qmaFourBits := by + have hs (s t : Fin 16) : qmaFourIndex (sourceSpinSwap i j (qmaFourBits s)) = t ↔ + sourceSpinSwap i j (qmaFourBits s) = qmaFourBits t := by + exact (qmaFourBasisEquiv.eq_symm_apply).symm + have he (s t : Fin 16) : s = t ↔ qmaFourBits s = qmaFourBits t := + qmaFourBasisEquiv.symm.injective.eq_iff.symm + ext s t + simp only [qmaFourExchange,qmaFourExchangeRational,sourceHeisenbergMatrix,Matrix.submatrix_apply] + simp only [hs,he] + split_ifs <;> norm_num + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d6f91d86cab9c97e715ff2cefeb259836520a25 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelation.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCorrelationCertificate +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourSpinTransition + +namespace OAI + +/-! Isotropic physical-spin correlations in the normalized singlet code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourCorrelation (i j : Fin 4) : Matrix (Fin 2) (Fin 2) ℂ := + if i = j then 1 else (1/3:ℂ) • qmaFourLogical (min i j) (max i j) + +theorem qmaFourCorrelation_comm (i j : Fin 4) : qmaFourCorrelation i j = qmaFourCorrelation j i := by + simp only [qmaFourCorrelation,eq_comm,min_comm,max_comm] + +theorem qmaFourNormalization_gram : + qmaFourNormalization.conjTranspose* + (Matrix.diagonal ![(4:ℚ),12]).map (Rat.castHom ℂ)*qmaFourNormalization = 1 := by + have he := qmaFourEncoding_gram + rw [qmaFourEncoding,Matrix.conjTranspose_mul,qmaFourRawComplex_adjoint, + qmaFourRawComplex] at he + calc + _ = qmaFourNormalization.conjTranspose* + ((qmaFourRawEncoding.transpose*qmaFourRawEncoding).map (Rat.castHom ℂ))* + qmaFourNormalization := by rw [qmaFourRawEncoding_gram] + _ = 1 := by rw [Matrix.map_mul]; simpa only [Matrix.mul_assoc] using he + +theorem qmaFourRawCorrelation_normalized (i j : Fin 4) : + qmaFourNormalization.conjTranspose*(qmaFourRawCorrelation i j).map (Rat.castHom ℂ)* + qmaFourNormalization = qmaFourCorrelation i j := by + by_cases hij : i = j + · simp only [qmaFourRawCorrelation,qmaFourCorrelation,hij,ite_true] + exact qmaFourNormalization_gram + · simp only [qmaFourRawCorrelation,qmaFourCorrelation,hij,ite_false] + have hmap : ((1/3:ℚ) • (Matrix.diagonal ![(4:ℚ),12]* + qmaFourRawLogical (min i j) (max i j))).map (Rat.castHom ℂ) = + (1/3:ℂ) • ((Matrix.diagonal ![(4:ℚ),12]).map (Rat.castHom ℂ)* + (qmaFourRawLogical (min i j) (max i j)).map (Rat.castHom ℂ)) := by + calc + _ = (1/3:ℂ) • ((Matrix.diagonal ![(4:ℚ),12]* + qmaFourRawLogical (min i j) (max i j)).map (Rat.castHom ℂ)) := by + ext a b + simp + _ = _ := by rw [Matrix.map_mul] + rw [hmap,Matrix.mul_smul,Matrix.smul_mul] + congr 1 + calc + _ = qmaFourNormalization.conjTranspose* + (Matrix.diagonal ![(4:ℚ),12]).map (Rat.castHom ℂ)* + ((qmaFourRawLogical (min i j) (max i j)).map (Rat.castHom ℂ)* + qmaFourNormalization) := by simp only [Matrix.mul_assoc] + _ = qmaFourNormalization.conjTranspose* + (Matrix.diagonal ![(4:ℚ),12]).map (Rat.castHom ℂ)* + (qmaFourNormalization*qmaFourLogical (min i j) (max i j)) := by + rw [qmaFourLogical_normalize] + _ = _ := by rw [← Matrix.mul_assoc,qmaFourNormalization_gram,Matrix.one_mul] + +theorem qmaFourPauliPhase_norm (μ : Fin 3) : + star (qmaPauliPhase μ)*qmaPauliPhase μ = 1 := by + fin_cases μ <;> norm_num [qmaPauliPhase,Complex.star_def] + +theorem qmaFourSpin_correlation (i j : Fin 4) (μ ν : Fin 3) : + (qmaFourSpin i μ*qmaFourEncoding).conjTranspose*(qmaFourSpin j ν*qmaFourEncoding) = + if μ = ν then qmaFourCorrelation i j else 0 := by + rw [qmaFourSpin_encoding,qmaFourSpin_encoding,Matrix.conjTranspose_smul, + Matrix.conjTranspose_mul,qmaRatMatrix_adjoint,Matrix.smul_mul,Matrix.mul_smul,smul_smul] + have he : (qmaFourNormalization.conjTranspose* + (qmaFourSpinRawAction i μ).transpose.map (Rat.castHom ℂ))* + ((qmaFourSpinRawAction j ν).map (Rat.castHom ℂ)*qmaFourNormalization) = + qmaFourNormalization.conjTranspose* + ((qmaFourSpinRawAction i μ).transpose*qmaFourSpinRawAction j ν).map (Rat.castHom ℂ)* + qmaFourNormalization := by + rw [Matrix.map_mul] + simp only [Matrix.mul_assoc] + rw [he,qmaFourRawCorrelation_eq] + by_cases h : μ = ν + · subst ν + rw [ite_eq_left (rfl : μ = μ),qmaFourRawCorrelation_normalized, + ite_eq_left (rfl : μ = μ),qmaFourPauliPhase_norm,one_smul] + · simp [h] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelationCertificate.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelationCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a524a36ea64aa87f1dbc053a6c5c6949b0353519 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCorrelationCertificate.lean @@ -0,0 +1,573 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourSpinTable + +namespace OAI + +/-! Exact rational spin correlations in the two-column singlet code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourRawCorrelation (i j : Fin 4) : Matrix (Fin 2) (Fin 2) ℚ := + if i = j then Matrix.diagonal ![4,12] + else (1/3:ℚ) • (Matrix.diagonal ![4,12]*qmaFourRawLogical (min i j) (max i j)) + +theorem qmaFourRawCorrelation_000 (ν : Fin 3) : + (qmaFourSpinRawAction 0 0).transpose*qmaFourSpinRawAction 0 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 0 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_001 (ν : Fin 3) : + (qmaFourSpinRawAction 0 1).transpose*qmaFourSpinRawAction 0 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 0 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_002 (ν : Fin 3) : + (qmaFourSpinRawAction 0 2).transpose*qmaFourSpinRawAction 0 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 0 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_010 (ν : Fin 3) : + (qmaFourSpinRawAction 0 0).transpose*qmaFourSpinRawAction 1 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 0 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_011 (ν : Fin 3) : + (qmaFourSpinRawAction 0 1).transpose*qmaFourSpinRawAction 1 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 0 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_012 (ν : Fin 3) : + (qmaFourSpinRawAction 0 2).transpose*qmaFourSpinRawAction 1 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 0 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_020 (ν : Fin 3) : + (qmaFourSpinRawAction 0 0).transpose*qmaFourSpinRawAction 2 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 0 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_021 (ν : Fin 3) : + (qmaFourSpinRawAction 0 1).transpose*qmaFourSpinRawAction 2 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 0 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_022 (ν : Fin 3) : + (qmaFourSpinRawAction 0 2).transpose*qmaFourSpinRawAction 2 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 0 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_030 (ν : Fin 3) : + (qmaFourSpinRawAction 0 0).transpose*qmaFourSpinRawAction 3 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 0 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_031 (ν : Fin 3) : + (qmaFourSpinRawAction 0 1).transpose*qmaFourSpinRawAction 3 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 0 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_032 (ν : Fin 3) : + (qmaFourSpinRawAction 0 2).transpose*qmaFourSpinRawAction 3 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 0 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_100 (ν : Fin 3) : + (qmaFourSpinRawAction 1 0).transpose*qmaFourSpinRawAction 0 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 1 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_101 (ν : Fin 3) : + (qmaFourSpinRawAction 1 1).transpose*qmaFourSpinRawAction 0 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 1 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_102 (ν : Fin 3) : + (qmaFourSpinRawAction 1 2).transpose*qmaFourSpinRawAction 0 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 1 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_110 (ν : Fin 3) : + (qmaFourSpinRawAction 1 0).transpose*qmaFourSpinRawAction 1 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 1 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_111 (ν : Fin 3) : + (qmaFourSpinRawAction 1 1).transpose*qmaFourSpinRawAction 1 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 1 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_112 (ν : Fin 3) : + (qmaFourSpinRawAction 1 2).transpose*qmaFourSpinRawAction 1 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 1 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_120 (ν : Fin 3) : + (qmaFourSpinRawAction 1 0).transpose*qmaFourSpinRawAction 2 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 1 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_121 (ν : Fin 3) : + (qmaFourSpinRawAction 1 1).transpose*qmaFourSpinRawAction 2 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 1 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_122 (ν : Fin 3) : + (qmaFourSpinRawAction 1 2).transpose*qmaFourSpinRawAction 2 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 1 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_130 (ν : Fin 3) : + (qmaFourSpinRawAction 1 0).transpose*qmaFourSpinRawAction 3 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 1 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_131 (ν : Fin 3) : + (qmaFourSpinRawAction 1 1).transpose*qmaFourSpinRawAction 3 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 1 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_132 (ν : Fin 3) : + (qmaFourSpinRawAction 1 2).transpose*qmaFourSpinRawAction 3 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 1 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_200 (ν : Fin 3) : + (qmaFourSpinRawAction 2 0).transpose*qmaFourSpinRawAction 0 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 2 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_201 (ν : Fin 3) : + (qmaFourSpinRawAction 2 1).transpose*qmaFourSpinRawAction 0 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 2 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_202 (ν : Fin 3) : + (qmaFourSpinRawAction 2 2).transpose*qmaFourSpinRawAction 0 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 2 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_210 (ν : Fin 3) : + (qmaFourSpinRawAction 2 0).transpose*qmaFourSpinRawAction 1 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 2 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_211 (ν : Fin 3) : + (qmaFourSpinRawAction 2 1).transpose*qmaFourSpinRawAction 1 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 2 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_212 (ν : Fin 3) : + (qmaFourSpinRawAction 2 2).transpose*qmaFourSpinRawAction 1 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 2 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_220 (ν : Fin 3) : + (qmaFourSpinRawAction 2 0).transpose*qmaFourSpinRawAction 2 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 2 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_221 (ν : Fin 3) : + (qmaFourSpinRawAction 2 1).transpose*qmaFourSpinRawAction 2 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 2 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_222 (ν : Fin 3) : + (qmaFourSpinRawAction 2 2).transpose*qmaFourSpinRawAction 2 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 2 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_230 (ν : Fin 3) : + (qmaFourSpinRawAction 2 0).transpose*qmaFourSpinRawAction 3 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 2 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_231 (ν : Fin 3) : + (qmaFourSpinRawAction 2 1).transpose*qmaFourSpinRawAction 3 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 2 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_232 (ν : Fin 3) : + (qmaFourSpinRawAction 2 2).transpose*qmaFourSpinRawAction 3 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 2 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_300 (ν : Fin 3) : + (qmaFourSpinRawAction 3 0).transpose*qmaFourSpinRawAction 0 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 3 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_301 (ν : Fin 3) : + (qmaFourSpinRawAction 3 1).transpose*qmaFourSpinRawAction 0 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 3 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_302 (ν : Fin 3) : + (qmaFourSpinRawAction 3 2).transpose*qmaFourSpinRawAction 0 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 3 0 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_310 (ν : Fin 3) : + (qmaFourSpinRawAction 3 0).transpose*qmaFourSpinRawAction 1 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 3 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_311 (ν : Fin 3) : + (qmaFourSpinRawAction 3 1).transpose*qmaFourSpinRawAction 1 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 3 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_312 (ν : Fin 3) : + (qmaFourSpinRawAction 3 2).transpose*qmaFourSpinRawAction 1 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 3 1 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_320 (ν : Fin 3) : + (qmaFourSpinRawAction 3 0).transpose*qmaFourSpinRawAction 2 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 3 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_321 (ν : Fin 3) : + (qmaFourSpinRawAction 3 1).transpose*qmaFourSpinRawAction 2 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 3 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_322 (ν : Fin 3) : + (qmaFourSpinRawAction 3 2).transpose*qmaFourSpinRawAction 2 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 3 2 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_330 (ν : Fin 3) : + (qmaFourSpinRawAction 3 0).transpose*qmaFourSpinRawAction 3 ν = + if (0:Fin 3) = ν then qmaFourRawCorrelation 3 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_331 (ν : Fin 3) : + (qmaFourSpinRawAction 3 1).transpose*qmaFourSpinRawAction 3 ν = + if (1:Fin 3) = ν then qmaFourRawCorrelation 3 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_332 (ν : Fin 3) : + (qmaFourSpinRawAction 3 2).transpose*qmaFourSpinRawAction 3 ν = + if (2:Fin 3) = ν then qmaFourRawCorrelation 3 3 else 0 := by + rw [qmaFourSpinRawAction_table,qmaFourSpinRawAction_table] + ext a b + fin_cases ν <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawCorrelation,qmaFourRawLogical,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ, + qmaFourSpinTable,qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02,qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12,qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22,qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32] + +theorem qmaFourRawCorrelation_eq (i j : Fin 4) (μ ν : Fin 3) : + (qmaFourSpinRawAction i μ).transpose*qmaFourSpinRawAction j ν = + if μ = ν then qmaFourRawCorrelation i j else 0 := by + fin_cases i + · fin_cases j + · fin_cases μ + · exact qmaFourRawCorrelation_000 ν + · exact qmaFourRawCorrelation_001 ν + · exact qmaFourRawCorrelation_002 ν + · fin_cases μ + · exact qmaFourRawCorrelation_010 ν + · exact qmaFourRawCorrelation_011 ν + · exact qmaFourRawCorrelation_012 ν + · fin_cases μ + · exact qmaFourRawCorrelation_020 ν + · exact qmaFourRawCorrelation_021 ν + · exact qmaFourRawCorrelation_022 ν + · fin_cases μ + · exact qmaFourRawCorrelation_030 ν + · exact qmaFourRawCorrelation_031 ν + · exact qmaFourRawCorrelation_032 ν + · fin_cases j + · fin_cases μ + · exact qmaFourRawCorrelation_100 ν + · exact qmaFourRawCorrelation_101 ν + · exact qmaFourRawCorrelation_102 ν + · fin_cases μ + · exact qmaFourRawCorrelation_110 ν + · exact qmaFourRawCorrelation_111 ν + · exact qmaFourRawCorrelation_112 ν + · fin_cases μ + · exact qmaFourRawCorrelation_120 ν + · exact qmaFourRawCorrelation_121 ν + · exact qmaFourRawCorrelation_122 ν + · fin_cases μ + · exact qmaFourRawCorrelation_130 ν + · exact qmaFourRawCorrelation_131 ν + · exact qmaFourRawCorrelation_132 ν + · fin_cases j + · fin_cases μ + · exact qmaFourRawCorrelation_200 ν + · exact qmaFourRawCorrelation_201 ν + · exact qmaFourRawCorrelation_202 ν + · fin_cases μ + · exact qmaFourRawCorrelation_210 ν + · exact qmaFourRawCorrelation_211 ν + · exact qmaFourRawCorrelation_212 ν + · fin_cases μ + · exact qmaFourRawCorrelation_220 ν + · exact qmaFourRawCorrelation_221 ν + · exact qmaFourRawCorrelation_222 ν + · fin_cases μ + · exact qmaFourRawCorrelation_230 ν + · exact qmaFourRawCorrelation_231 ν + · exact qmaFourRawCorrelation_232 ν + · fin_cases j + · fin_cases μ + · exact qmaFourRawCorrelation_300 ν + · exact qmaFourRawCorrelation_301 ν + · exact qmaFourRawCorrelation_302 ν + · fin_cases μ + · exact qmaFourRawCorrelation_310 ν + · exact qmaFourRawCorrelation_311 ν + · exact qmaFourRawCorrelation_312 ν + · fin_cases μ + · exact qmaFourRawCorrelation_320 ν + · exact qmaFourRawCorrelation_321 ν + · exact qmaFourRawCorrelation_322 ν + · fin_cases μ + · exact qmaFourRawCorrelation_330 ν + · exact qmaFourRawCorrelation_331 ν + · exact qmaFourRawCorrelation_332 ν + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCounterterm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCounterterm.lean new file mode 100644 index 0000000000000000000000000000000000000000..354872c008ea78989ceae7d2121e8f2afa8b33f3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCounterterm.lean @@ -0,0 +1,53 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourEffective + +namespace OAI + +/-! Internal exchanges cancel the unwanted one-body terms of the simulator. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaFourCounterA (a b : Fin 2) (j : ℝ) : ℝ := + qmaFourCouplingFactor a b j*qmaFourAxisScale a*qmaFourAxisShift b (qmaFourCouplingSign j) + +def qmaFourCounterB (a b : Fin 2) (j : ℝ) : ℝ := + qmaFourCouplingFactor a b j*qmaFourAxisShift a true* + (qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b) + +def qmaFourCounterterm (a b : Fin 2) (j : ℝ) : Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ := + qmaFourAxisField a (qmaFourCounterA a b j) ⊗ₖ (1 : Matrix (Fin 16) (Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ qmaFourAxisField b (qmaFourCounterB a b j) + +def qmaFourEnergyOffset (a b : Fin 2) (j : ℝ) : ℝ := + qmaFourAxisFieldShift a (qmaFourCounterA a b j)+ + qmaFourAxisFieldShift b (qmaFourCounterB a b j)- + qmaFourCouplingFactor a b j*qmaFourAxisShift a true*qmaFourAxisShift b (qmaFourCouplingSign j) + +theorem qmaFourDouble_local_compression (A B : Matrix (Fin 16) (Fin 16) ℂ) : + qmaFourDoubleEncoding.conjTranspose* + (A ⊗ₖ (1 : Matrix (Fin 16) (Fin 16) ℂ)+(1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ B)* + qmaFourDoubleEncoding = + (qmaFourEncoding.conjTranspose*A*qmaFourEncoding) ⊗ₖ (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + (1 : Matrix (Fin 2) (Fin 2) ℂ) ⊗ₖ (qmaFourEncoding.conjTranspose*B*qmaFourEncoding) := by + simp only [qmaFourDoubleEncoding,Matrix.conjTranspose_kronecker,Matrix.mul_add,Matrix.add_mul, + ← Matrix.mul_kronecker_mul,Matrix.mul_one,qmaFourEncoding_gram] + +theorem qmaFourCounterterm_effective (a b : Fin 2) (j : ℝ) : + qmaFourDoubleEncoding.conjTranspose*qmaFourCounterterm a b j*qmaFourDoubleEncoding+ + qmaFourCouplingEffective a b j = + (j:ℂ) • (qmaFourAxis a ⊗ₖ qmaFourAxis b)+ + (qmaFourEnergyOffset a b j:ℂ) • (1 : Matrix (Fin 2 × Fin 2) (Fin 2 × Fin 2) ℂ) := by + rw [qmaFourCounterterm,qmaFourDouble_local_compression,qmaFourAxisField_compression, + qmaFourAxisField_compression,qmaFourCouplingEffective_expansion] + simp only [Matrix.add_kronecker,Matrix.kronecker_add,Matrix.smul_kronecker, + Matrix.kronecker_smul,Matrix.one_kronecker_one,qmaFourEnergyOffset,qmaFourCounterA,qmaFourCounterB] + push_cast + module + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbfd195e764087a66061b8112de26ecf06b91971 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingBounds.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourNorm +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourEffective + +namespace OAI + +/-! Polynomial bounds for the physically calibrated inter-block interaction. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFourAxisScale_bounds (a : Fin 2) : 1 ≤ qmaFourAxisScale a ∧ qmaFourAxisScale a ≤ 256 := by + have hs0 : 0 ≤ Real.sqrt 3 := Real.sqrt_nonneg _ + have hs2 : (Real.sqrt 3)^2 = 3 := Real.sq_sqrt (by norm_num) + fin_cases a + · norm_num [qmaFourAxisScale] + constructor <;> nlinarith + · norm_num [qmaFourAxisScale] + +theorem qmaFourCouplingSize_bound (a b : Fin 2) (j : ℝ) : + qmaFourCouplingSize a b j ≤ 3*(1+|j|) := by + have ha := (qmaFourAxisScale_bounds a).1 + have hb := (qmaFourAxisScale_bounds b).1 + have hp : 1 ≤ qmaFourAxisScale a*qmaFourAxisScale b := by nlinarith + have hr := qmaFourCouplingSize_nonneg a b j + have he := qmaFourCouplingSize_square a b j + have hm := mul_le_mul_of_nonneg_left hp (sq_nonneg (qmaFourCouplingSize a b j)) + have hsq : (qmaFourCouplingSize a b j)^2 ≤ (8/3)*|j| := by nlinarith + have hj := abs_nonneg j + nlinarith [sq_nonneg |j|] + +theorem qmaFourCoupling_norm (a b : Fin 2) (j : ℝ) : + ‖spinMatrixOperator (qmaFourCoupling a b j)‖ ≤ 7056*(1+|j|) := by + rw [qmaFourCoupling,spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg (qmaFourCouplingSize_nonneg a b j)] + have hn := qmaFourAxisCross_norm a b true (qmaFourCouplingSign j) + have hs := qmaFourCouplingSize_bound a b j + have hnon := qmaFourCouplingSize_nonneg a b j + calc + _ ≤ qmaFourCouplingSize a b j*2352 := mul_le_mul_of_nonneg_left hn hnon + _ ≤ _ := by nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4f535a0b1859b02abecf9575b10ae45a4586a7b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCouplingScale.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourAxis + +namespace OAI + +/-! Calibration of the physical inter-block strength for either coupling sign. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourCouplingSign (j : ℝ) : Bool := decide (j ≤ 0) + +def qmaFourCouplingSize (a b : Fin 2) (j : ℝ) : ℝ := + Real.sqrt (8*|j|/(3*qmaFourAxisScale a*qmaFourAxisScale b)) + +theorem qmaFourCouplingSize_nonneg (a b : Fin 2) (j : ℝ) : 0 ≤ qmaFourCouplingSize a b j := + Real.sqrt_nonneg _ + +theorem qmaFourCouplingSize_square (a b : Fin 2) (j : ℝ) : + (3/8:ℝ)*(qmaFourCouplingSize a b j)^2*qmaFourAxisScale a*qmaFourAxisScale b = |j| := by + have ha := qmaFourAxisScale_pos a + have hb := qmaFourAxisScale_pos b + have hane : qmaFourAxisScale a ≠ 0 := ne_of_gt ha + have hbne : qmaFourAxisScale b ≠ 0 := ne_of_gt hb + have hden : 0 < 3*qmaFourAxisScale a*qmaFourAxisScale b := by positivity + have hnon : 0 ≤ 8*|j|/(3*qmaFourAxisScale a*qmaFourAxisScale b) := by positivity + rw [qmaFourCouplingSize,Real.sq_sqrt hnon] + field_simp + +theorem qmaFourCouplingSign_calibration (a b : Fin 2) (j : ℝ) : + -(3/8:ℝ)*(qmaFourCouplingSize a b j)^2*qmaFourAxisScale a* + (qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b) = j := by + have he := qmaFourCouplingSize_square a b j + calc + _ = -((3/8:ℝ)*(qmaFourCouplingSize a b j)^2*qmaFourAxisScale a*qmaFourAxisScale b)* + qmaFourAxisSign (qmaFourCouplingSign j) := by ring + _ = -|j| *qmaFourAxisSign (qmaFourCouplingSign j) := by rw [he] + _ = j := by + by_cases hj : j ≤ 0 + · simp [qmaFourAxisSign,qmaFourCouplingSign,hj,abs_of_nonpos hj] + · simp [qmaFourAxisSign,qmaFourCouplingSign,hj,abs_of_pos (lt_of_not_ge hj)] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCross.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCross.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f010fd2928a19aae16cd8128a3b1138048bfad1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourCross.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCorrelation + +namespace OAI + +/-! Exact second-order columns for a Heisenberg edge between two encoded blocks. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaFourDoubleEncoding : Matrix (Fin 16 × Fin 16) (Fin 2 × Fin 2) ℂ := + qmaFourEncoding ⊗ₖ qmaFourEncoding + +def qmaFourDoublePenalty : Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ := + qmaFourPenalty ⊗ₖ (1 : Matrix (Fin 16) (Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ qmaFourPenalty + +def qmaFourCross (i j : Fin 4) : Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ := + ∑ μ : Fin 3, qmaFourSpin i μ ⊗ₖ qmaFourSpin j μ + +theorem qmaFourDoubleEncoding_gram : + qmaFourDoubleEncoding.conjTranspose*qmaFourDoubleEncoding = 1 := by + rw [qmaFourDoubleEncoding,Matrix.conjTranspose_kronecker,← Matrix.mul_kronecker_mul, + qmaFourEncoding_gram,Matrix.one_kronecker_one] + +theorem qmaFourCross_column (i j : Fin 4) : + qmaFourCross i j*qmaFourDoubleEncoding = + ∑ μ : Fin 3, (qmaFourSpin i μ*qmaFourEncoding) ⊗ₖ (qmaFourSpin j μ*qmaFourEncoding) := by + simp only [qmaFourCross,qmaFourDoubleEncoding,Matrix.sum_mul,← Matrix.mul_kronecker_mul] + +theorem qmaFourCross_orthogonal (i j : Fin 4) : + qmaFourDoubleEncoding.conjTranspose*qmaFourCross i j*qmaFourDoubleEncoding = 0 := by + rw [Matrix.mul_assoc,qmaFourCross_column,qmaFourDoubleEncoding,Matrix.conjTranspose_kronecker] + simp only [Matrix.mul_sum,← Matrix.mul_kronecker_mul,← Matrix.mul_assoc, + qmaFourSpin_orthogonal,Matrix.zero_kronecker,Finset.sum_const_zero] + +theorem qmaFourCross_excitation (i j : Fin 4) : + qmaFourDoublePenalty*(qmaFourCross i j*qmaFourDoubleEncoding) = + (8:ℂ) • (qmaFourCross i j*qmaFourDoubleEncoding) := by + rw [qmaFourCross_column] + simp only [qmaFourDoublePenalty,Matrix.mul_sum,Matrix.add_mul, + ← Matrix.mul_kronecker_mul,Matrix.one_mul,qmaFourSpin_excitation, + Matrix.smul_kronecker,Matrix.kronecker_smul,← add_smul] + simp only [show (4:ℂ)+4 = 8 by norm_num,Finset.smul_sum] + +theorem qmaFourCross_gram (i j k l : Fin 4) : + (qmaFourCross i j*qmaFourDoubleEncoding).conjTranspose* + (qmaFourCross k l*qmaFourDoubleEncoding) = + (3:ℂ) • (qmaFourCorrelation i k ⊗ₖ qmaFourCorrelation j l) := by + rw [qmaFourCross_column,qmaFourCross_column] + simp only [Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.mul_sum, + Matrix.conjTranspose_kronecker,← Matrix.mul_kronecker_mul,qmaFourSpin_correlation] + have he (μ ν : Fin 3) : + (if μ = ν then qmaFourCorrelation i k else 0) ⊗ₖ + (if μ = ν then qmaFourCorrelation j l else 0) = + if μ = ν then qmaFourCorrelation i k ⊗ₖ qmaFourCorrelation j l else 0 := by + by_cases h : μ = ν <;> simp [h] + simp only [he] + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true,Finset.sum_const] + norm_cast + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourDoubleGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourDoubleGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5fc02d6e1223b0be16484b45e9ac447acc3d5b7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourDoubleGap.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCross +import Mathlib.Analysis.Matrix.Order + +namespace OAI + +/-! The full two-block penalty has a gap above its four-dimensional code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker InnerProductSpace Classical ComplexOrder + +theorem qmaFourGap_posSemidef : + (qmaFourPenalty-(4:ℂ) • (1-qmaFourProjection)).PosSemidef := by + rw [qmaFourGap_complex,qmaFourSymmetricComplex_factor] + apply Matrix.PosSemidef.mul_mul_conjTranspose_same + apply Matrix.PosSemidef.diagonal + intro k + apply Complex.zero_le_real.mpr + fin_cases k <;> norm_num [qmaFourSymmetricWeights] + +theorem qmaFourComplement_posSemidef : + (1-qmaFourProjection).PosSemidef := by + have hP : qmaFourProjection*qmaFourProjection = qmaFourProjection := by + rw [← qmaFourEncoding_projector] + calc + _ = qmaFourEncoding*(qmaFourEncoding.conjTranspose*qmaFourEncoding)* + qmaFourEncoding.conjTranspose := by simp only [Matrix.mul_assoc] + _ = _ := by rw [qmaFourEncoding_gram,Matrix.mul_one] + have hstar : qmaFourProjection.conjTranspose = qmaFourProjection := by + rw [← qmaFourEncoding_projector,Matrix.conjTranspose_mul,Matrix.conjTranspose_conjTranspose] + have he : (1-qmaFourProjection).conjTranspose*(1-qmaFourProjection) = + 1-qmaFourProjection := by + simp only [Matrix.conjTranspose_sub,Matrix.conjTranspose_one,hstar] + noncomm_ring [hP] + rw [← he] + exact Matrix.posSemidef_conjTranspose_mul_self _ + +theorem qmaFourDouble_projector : + qmaFourDoubleEncoding*qmaFourDoubleEncoding.conjTranspose = + qmaFourProjection ⊗ₖ qmaFourProjection := by + rw [qmaFourDoubleEncoding,Matrix.conjTranspose_kronecker,← Matrix.mul_kronecker_mul, + qmaFourEncoding_projector] + +theorem qmaFourDoubleGap_posSemidef : + (qmaFourDoublePenalty-(4:ℂ) • (1-qmaFourProjection ⊗ₖ qmaFourProjection)).PosSemidef := by + have he : qmaFourDoublePenalty-(4:ℂ) • (1-qmaFourProjection ⊗ₖ qmaFourProjection) = + (qmaFourPenalty-(4:ℂ) • (1-qmaFourProjection)) ⊗ₖ (1 : Matrix (Fin 16) (Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ (qmaFourPenalty-(4:ℂ) • (1-qmaFourProjection))+ + (4:ℂ) • ((1-qmaFourProjection) ⊗ₖ (1-qmaFourProjection)) := by + ext s t + rcases s with ⟨s₁,s₂⟩ + rcases t with ⟨t₁,t₂⟩ + by_cases h₁ : s₁ = t₁ <;> by_cases h₂ : s₂ = t₂ <;> + simp [qmaFourDoublePenalty,Matrix.kroneckerMap_apply,h₁,h₂,Prod.ext_iff] <;> ring + rw [he] + exact ((qmaFourGap_posSemidef.kronecker Matrix.PosSemidef.one).add + (Matrix.PosSemidef.one.kronecker qmaFourGap_posSemidef)).add + ((qmaFourComplement_posSemidef.kronecker qmaFourComplement_posSemidef).smul (by norm_num)) + +theorem qmaFourDouble_complement_gap (x : EuclideanSpace ℂ (Fin 16 × Fin 16)) + (hx : qmaFourDoubleEncoding.conjTranspose *ᵥ (fun i => x i) = 0) : + 4*‖x‖^2 ≤ qmaQuadratic qmaFourDoublePenalty (fun i => x i) := by + have hp : (qmaFourProjection ⊗ₖ qmaFourProjection) *ᵥ (fun i => x i) = 0 := by + rw [← qmaFourDouble_projector,← Matrix.mulVec_mulVec,hx,Matrix.mulVec_zero] + have hzero : qmaQuadratic (qmaFourProjection ⊗ₖ qmaFourProjection) (fun i => x i) = 0 := by + simp [qmaQuadratic,hp] + have hone : qmaQuadratic (1 : Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ) + (fun i => x i) = ‖x‖^2 := by + rw [qmaQuadratic_operator,qmaMatrixOperator_square,spinMatrixOperator_one,one_apply_eq_self, + real_inner_self_eq_norm_sq] + have h := (Complex.nonneg_iff.mp + (qmaFourDoubleGap_posSemidef.dotProduct_mulVec_nonneg (fun i => x i))).1 + change 0 ≤ qmaQuadratic _ (fun i => x i) at h + rw [qmaQuadratic_sub] at h + have hs : qmaQuadratic ((4:ℂ) • (1-qmaFourProjection ⊗ₖ qmaFourProjection)) (fun i => x i) = + 4*qmaQuadratic (1-qmaFourProjection ⊗ₖ qmaFourProjection) (fun i => x i) := by + simpa only [Complex.ofReal_ofNat] using + qmaQuadratic_smul (1-qmaFourProjection ⊗ₖ qmaFourProjection) (4:ℝ) (fun i => x i) + rw [hs,qmaQuadratic_sub,hzero,hone] at h + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEffective.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEffective.lean new file mode 100644 index 0000000000000000000000000000000000000000..67f99413ea3e6bb8e41ec8693ecaedad1177c5a8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEffective.lean @@ -0,0 +1,66 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCouplingScale + +namespace OAI + +/-! The actual inter-block coupling has the desired second-order X/Z term. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaFourCoupling (a b : Fin 2) (j : ℝ) : Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ := + (qmaFourCouplingSize a b j:ℂ) • qmaFourWeightedCross + (qmaFourAxisWeights a true) (qmaFourAxisWeights b (qmaFourCouplingSign j)) + +def qmaFourCouplingFactor (a b : Fin 2) (j : ℝ) : ℝ := (3/8)*(qmaFourCouplingSize a b j)^2 + +def qmaFourCouplingEffective (a b : Fin 2) (j : ℝ) : Matrix (Fin 2 × Fin 2) (Fin 2 × Fin 2) ℂ := + (-1/8:ℂ) • ((qmaFourCoupling a b j*qmaFourDoubleEncoding).conjTranspose* + (qmaFourCoupling a b j*qmaFourDoubleEncoding)) + +theorem qmaFourCouplingEffective_tensor (a b : Fin 2) (j : ℝ) : + qmaFourCouplingEffective a b j = (-qmaFourCouplingFactor a b j:ℂ) • + (((qmaFourAxisShift a true:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + (qmaFourAxisScale a:ℂ) • qmaFourAxis a) ⊗ₖ + ((qmaFourAxisShift b (qmaFourCouplingSign j):ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + ((qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b:ℝ):ℂ) • qmaFourAxis b)) := by + rw [qmaFourCouplingEffective,qmaFourCoupling,Matrix.smul_mul,Matrix.conjTranspose_smul, + Matrix.smul_mul,Matrix.mul_smul,smul_smul,smul_smul] + rw [qmaFourWeightedCross_gram,qmaFourAxisWeights_correlation,qmaFourAxisWeights_correlation] + simp only [qmaFourAxisSign,ite_true,one_mul,Complex.star_def,Complex.conj_ofReal, + smul_smul,qmaFourCouplingFactor] + push_cast + congr 1 + ring + +theorem qmaFourCouplingEffective_expansion (a b : Fin 2) (j : ℝ) : + qmaFourCouplingEffective a b j = + (-qmaFourCouplingFactor a b j*qmaFourAxisShift a true* + qmaFourAxisShift b (qmaFourCouplingSign j):ℂ) • (1 : Matrix (Fin 2 × Fin 2) (Fin 2 × Fin 2) ℂ)+ + (-qmaFourCouplingFactor a b j*qmaFourAxisScale a* + qmaFourAxisShift b (qmaFourCouplingSign j):ℂ) • + (qmaFourAxis a ⊗ₖ (1 : Matrix (Fin 2) (Fin 2) ℂ))+ + (-qmaFourCouplingFactor a b j*qmaFourAxisShift a true* + (qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b):ℂ) • + ((1 : Matrix (Fin 2) (Fin 2) ℂ) ⊗ₖ qmaFourAxis b)+ + (j:ℂ) • (qmaFourAxis a ⊗ₖ qmaFourAxis b) := by + have hc : (-qmaFourCouplingFactor a b j*qmaFourAxisScale a* + (qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b):ℂ) = j := by + have h := qmaFourCouplingSign_calibration a b j + have he : -qmaFourCouplingFactor a b j*qmaFourAxisScale a* + (qmaFourAxisSign (qmaFourCouplingSign j)*qmaFourAxisScale b) = j := by + unfold qmaFourCouplingFactor + nlinarith [h] + exact_mod_cast he + rw [← hc,qmaFourCouplingEffective_tensor] + simp only [Matrix.add_kronecker,Matrix.kronecker_add,Matrix.smul_kronecker, + Matrix.kronecker_smul,Matrix.one_kronecker_one,smul_add,smul_smul] + push_cast + module + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEncoding.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..17b7f98b5993a5a15fb6dd2b0adb6801867cde04 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourEncoding.lean @@ -0,0 +1,121 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourBasis + +namespace OAI + +/-! The two rational singlet columns spanning the four-spin encoded qubit. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourRaw0 : Fin 16 → ℚ := ![0,0,0,0,0,1,-1,0,0,-1,1,0,0,0,0,0] +def qmaFourRaw1 : Fin 16 → ℚ := ![0,0,0,2,0,-1,-1,0,0,-1,-1,0,2,0,0,0] + +def qmaFourRawEncoding : Matrix (Fin 16) (Fin 2) ℚ := + fun s b => if b = 0 then qmaFourRaw0 s else qmaFourRaw1 s + +theorem qmaFourRawEncoding_gram : qmaFourRawEncoding.transpose*qmaFourRawEncoding = + Matrix.diagonal ![(4:ℚ),12] := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,Matrix.mul_apply, + Matrix.transpose_apply,Matrix.diagonal_apply,Fin.sum_univ_succ] + +theorem qmaFourExchangeRational_mulVec (i j : Fin 4) (v : Fin 16 → ℚ) (s : Fin 16) : + (qmaFourExchangeRational i j *ᵥ v) s = + 2*v (qmaFourIndex (sourceSpinSwap i j (qmaFourBits s)))-v s := by + simp only [qmaFourExchangeRational,Matrix.mulVec,dotProduct,sub_mul, + Finset.sum_sub_distrib,mul_assoc,ite_mul,one_mul,zero_mul,← Finset.mul_sum] + simp + +def qmaFourRawLogical (i j : Fin 4) : Matrix (Fin 2) (Fin 2) ℚ := + if (i = 0 ∧ j = 1) ∨ (i = 2 ∧ j = 3) then !![-3,0;0,1] + else if (i = 0 ∧ j = 2) ∨ (i = 1 ∧ j = 3) then !![0,-3;-1,-2] + else !![0,3;1,-2] + +theorem qmaFourRawEncoding_action01 : + qmaFourExchangeRational 0 1*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 0 1 := by + ext s b + change (qmaFourExchangeRational 0 1 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action02 : + qmaFourExchangeRational 0 2*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 0 2 := by + ext s b + change (qmaFourExchangeRational 0 2 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action03 : + qmaFourExchangeRational 0 3*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 0 3 := by + ext s b + change (qmaFourExchangeRational 0 3 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action12 : + qmaFourExchangeRational 1 2*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 1 2 := by + ext s b + change (qmaFourExchangeRational 1 2 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action13 : + qmaFourExchangeRational 1 3*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 1 3 := by + ext s b + change (qmaFourExchangeRational 1 3 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action23 : + qmaFourExchangeRational 2 3*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical 2 3 := by + ext s b + change (qmaFourExchangeRational 2 3 *ᵥ fun t => qmaFourRawEncoding t b) s = _ + rw [qmaFourExchangeRational_mulVec] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourRawLogical, + qmaFourIndex,qmaFourBits,sourceSpinSwap_apply,Equiv.swap_apply_def, + Matrix.mul_apply,Fin.sum_univ_two] + +theorem qmaFourRawEncoding_action (i j : Fin 4) (hij : i < j) : + qmaFourExchangeRational i j*qmaFourRawEncoding = qmaFourRawEncoding*qmaFourRawLogical i j := by + fin_cases i + · fin_cases j + · norm_num at hij + · exact qmaFourRawEncoding_action01 + · exact qmaFourRawEncoding_action02 + · exact qmaFourRawEncoding_action03 + · fin_cases j + · norm_num at hij + · norm_num at hij + · exact qmaFourRawEncoding_action12 + · exact qmaFourRawEncoding_action13 + · fin_cases j + · norm_num at hij + · norm_num at hij + · norm_num at hij + · exact qmaFourRawEncoding_action23 + · fin_cases j <;> norm_num at hij + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourFields.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourFields.lean new file mode 100644 index 0000000000000000000000000000000000000000..519c2a4f0dee0ed150df55b9d96346bcdf74a5d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourFields.lean @@ -0,0 +1,36 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourLogical + +namespace OAI + +/-! Logical X and Z fields are realized by internal physical exchanges. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourField (x z : ℝ) : Matrix (Fin 16) (Fin 16) ℂ := + ((x/(2*Real.sqrt 3):ℝ):ℂ) • (qmaFourExchange 0 3-qmaFourExchange 0 2)- + ((z/2:ℝ):ℂ) • qmaFourExchange 0 1 + +theorem qmaFourField_compression (x z : ℝ) : + qmaFourEncoding.conjTranspose*qmaFourField x z*qmaFourEncoding = + (x:ℂ) • pauliX+(z:ℂ) • pauliZ+((z/2:ℝ):ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ) := by + have hs : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by norm_num)) + have hsc : (Real.sqrt 3:ℂ) ≠ 0 := by exact_mod_cast hs + simp only [qmaFourField,Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_smul,Matrix.smul_mul] + rw [qmaFourEncoding_compression 0 3 (by decide), + qmaFourEncoding_compression 0 2 (by decide),qmaFourEncoding_compression 0 1 (by decide), + qmaFourLogical_X,qmaFourLogical_Z] + push_cast + simp only [smul_smul,smul_sub,smul_neg] + have hx : ((x:ℂ)/(2*(Real.sqrt 3:ℂ)))*(2*(Real.sqrt 3:ℂ)) = x := by field_simp + have hz : ((z:ℂ)/2)*2 = z := by ring + rw [hx,hz] + module + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGapCertificate.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGapCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ebf34289710e61be4678a6de54da5867c972e03 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGapCertificate.lean @@ -0,0 +1,183 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourEncoding + +namespace OAI + +/-! A rational positive factorization of the four-spin penalty above the +singlet projection. Each fixed row is checked separately at default limits. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourProjectionRational : Matrix (Fin 16) (Fin 16) ℚ := fun s t => + qmaFourRaw0 s*qmaFourRaw0 t/4+qmaFourRaw1 s*qmaFourRaw1 t/12 + +def qmaFourPenaltyRational : Matrix (Fin 16) (Fin 16) ℚ := + qmaFourExchangeRational 0 1+qmaFourExchangeRational 0 2+qmaFourExchangeRational 0 3+ + qmaFourExchangeRational 1 2+qmaFourExchangeRational 1 3+qmaFourExchangeRational 2 3+(6:ℚ) • (1 : Matrix (Fin 16) (Fin 16) ℚ) + +def qmaFourWeight (s : Fin 16) : Fin 5 := + ⟨s.val/8+s.val/4%2+s.val/2%2+s.val%2,by have hs := s.isLt; omega⟩ + +def qmaFourSymmetricWeights : Fin 5 → ℚ := ![8,2,4/3,2,8] + +def qmaFourSymmetricRational : Matrix (Fin 16) (Fin 16) ℚ := fun s t => + if qmaFourWeight s = qmaFourWeight t then qmaFourSymmetricWeights (qmaFourWeight s) else 0 + +def qmaFourGapRational : Matrix (Fin 16) (Fin 16) ℚ := + qmaFourPenaltyRational-(4:ℚ) • (1-qmaFourProjectionRational) + +theorem qmaFourGapRational_row0 (t : Fin 16) : + qmaFourGapRational 0 t = qmaFourSymmetricRational 0 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row1 (t : Fin 16) : + qmaFourGapRational 1 t = qmaFourSymmetricRational 1 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row2 (t : Fin 16) : + qmaFourGapRational 2 t = qmaFourSymmetricRational 2 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row3 (t : Fin 16) : + qmaFourGapRational 3 t = qmaFourSymmetricRational 3 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row4 (t : Fin 16) : + qmaFourGapRational 4 t = qmaFourSymmetricRational 4 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row5 (t : Fin 16) : + qmaFourGapRational 5 t = qmaFourSymmetricRational 5 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row6 (t : Fin 16) : + qmaFourGapRational 6 t = qmaFourSymmetricRational 6 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row7 (t : Fin 16) : + qmaFourGapRational 7 t = qmaFourSymmetricRational 7 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row8 (t : Fin 16) : + qmaFourGapRational 8 t = qmaFourSymmetricRational 8 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row9 (t : Fin 16) : + qmaFourGapRational 9 t = qmaFourSymmetricRational 9 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row10 (t : Fin 16) : + qmaFourGapRational 10 t = qmaFourSymmetricRational 10 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row11 (t : Fin 16) : + qmaFourGapRational 11 t = qmaFourSymmetricRational 11 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row12 (t : Fin 16) : + qmaFourGapRational 12 t = qmaFourSymmetricRational 12 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row13 (t : Fin 16) : + qmaFourGapRational 13 t = qmaFourSymmetricRational 13 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row14 (t : Fin 16) : + qmaFourGapRational 14 t = qmaFourSymmetricRational 14 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_row15 (t : Fin 16) : + qmaFourGapRational 15 t = qmaFourSymmetricRational 15 t := by + fin_cases t <;> + norm_num [qmaFourGapRational,qmaFourPenaltyRational,qmaFourProjectionRational, + qmaFourExchangeRational,qmaFourRaw0,qmaFourRaw1,qmaFourSymmetricRational, + qmaFourSymmetricWeights,qmaFourWeight,qmaFourIndex,qmaFourBits, + sourceSpinSwap_apply,Equiv.swap_apply_def,Matrix.one_apply,Matrix.smul_apply,smul_eq_mul,Matrix.sub_apply] + +theorem qmaFourGapRational_factor : qmaFourGapRational = qmaFourSymmetricRational := by + ext s t + fin_cases s + · exact qmaFourGapRational_row0 t + · exact qmaFourGapRational_row1 t + · exact qmaFourGapRational_row2 t + · exact qmaFourGapRational_row3 t + · exact qmaFourGapRational_row4 t + · exact qmaFourGapRational_row5 t + · exact qmaFourGapRational_row6 t + · exact qmaFourGapRational_row7 t + · exact qmaFourGapRational_row8 t + · exact qmaFourGapRational_row9 t + · exact qmaFourGapRational_row10 t + · exact qmaFourGapRational_row11 t + · exact qmaFourGapRational_row12 t + · exact qmaFourGapRational_row13 t + · exact qmaFourGapRational_row14 t + · exact qmaFourGapRational_row15 t + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGround.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGround.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0dbca00e9a3f02cdc18d6f68fb49910914f9ef9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourGround.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourLogical + +namespace OAI + +/-! The four-spin penalty vanishes exactly on the encoded qubit. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical + +theorem qmaFourLogical_sum : + qmaFourLogical 0 1+qmaFourLogical 0 2+qmaFourLogical 0 3+ + qmaFourLogical 1 2+qmaFourLogical 1 3+qmaFourLogical 2 3 = + (-6:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ) := by + ext a b + fin_cases a <;> fin_cases b <;> simp [qmaFourLogical] <;> ring + +theorem qmaFourPenalty_exchange : qmaFourPenalty = + qmaFourExchange 0 1+qmaFourExchange 0 2+qmaFourExchange 0 3+ + qmaFourExchange 1 2+qmaFourExchange 1 3+qmaFourExchange 2 3+ + (6:ℂ) • (1 : Matrix (Fin 16) (Fin 16) ℂ) := by + ext s t + by_cases h : s = t + all_goals + simp [qmaFourPenalty,qmaFourPenaltyRational,qmaFourExchange,Matrix.map_apply,h] + +theorem qmaFourPenalty_encoding : qmaFourPenalty*qmaFourEncoding = 0 := by + rw [qmaFourPenalty_exchange] + simp only [Matrix.add_mul,Matrix.smul_mul,Matrix.one_mul] + rw [qmaFourEncoding_action 0 1 (by decide),qmaFourEncoding_action 0 2 (by decide), + qmaFourEncoding_action 0 3 (by decide),qmaFourEncoding_action 1 2 (by decide), + qmaFourEncoding_action 1 3 (by decide),qmaFourEncoding_action 2 3 (by decide)] + rw [← Matrix.mul_add,← Matrix.mul_add,← Matrix.mul_add,← Matrix.mul_add, + ← Matrix.mul_add,qmaFourLogical_sum,Matrix.mul_smul,Matrix.mul_one] + simp + +theorem qmaFourPenalty_range (x : Fin 2 → ℂ) : + qmaFourPenalty *ᵥ (qmaFourEncoding *ᵥ x) = 0 := by + rw [Matrix.mulVec_mulVec,qmaFourPenalty_encoding,Matrix.zero_mulVec] + +theorem qmaFourPenalty_kernel (x : EuclideanSpace ℂ (Fin 16)) + (hx : qmaFourPenalty *ᵥ (fun i => x i) = 0) : + qmaFourProjection *ᵥ (fun i => x i) = (fun i => x i) := by + have hq : qmaQuadratic qmaFourPenalty (fun i => x i) = 0 := by + simp [qmaQuadratic,hx] + have hg := qmaFourGap_form x + rw [hq] at hg + have hP := qmaFourEncoding_projector + have hgram := qmaFourEncoding_gram + have hproj : qmaFourProjection*qmaFourProjection = qmaFourProjection := by + rw [← hP] + calc + _ = qmaFourEncoding*(qmaFourEncoding.conjTranspose*qmaFourEncoding)* + qmaFourEncoding.conjTranspose := by simp only [Matrix.mul_assoc] + _ = _ := by rw [hgram,Matrix.mul_one] + have hstar : qmaFourProjection.conjTranspose = qmaFourProjection := by + rw [← hP,Matrix.conjTranspose_mul,Matrix.conjTranspose_conjTranspose] + let y : EuclideanSpace ℂ (Fin 16) := + WithLp.toLp 2 ((fun i => x i)-qmaFourProjection *ᵥ (fun i => x i)) + have hyop : qmaMatrixOperator (1-qmaFourProjection) x = y := by + ext i + simp [qmaMatrixOperator_apply,y,Matrix.sub_apply,sub_mul,Finset.sum_sub_distrib, + Matrix.one_apply,Matrix.mulVec,dotProduct] + have hy : ‖y‖^2 = qmaQuadratic (1-qmaFourProjection) (fun i => x i) := by + rw [← real_inner_self_eq_norm_sq,qmaEuclidean_real_inner,← hyop] + rw [← ContinuousLinearMap.adjoint_inner_right] + rw [← qmaMatrixOperator_star] + simp only [Matrix.conjTranspose_sub,Matrix.conjTranspose_one,hstar] + rw [← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul] + have he : (1-qmaFourProjection)*(1-qmaFourProjection) = 1-qmaFourProjection := by + noncomm_ring [hproj] + rw [he] + rw [← qmaEuclidean_real_inner] + exact (qmaQuadratic_operator (1-qmaFourProjection) x).symm + have hn : ‖y‖ = 0 := by + rw [qmaQuadratic_sub] at hy + have hnon := sq_nonneg ‖y‖ + nlinarith + have hz := norm_eq_zero.mp hn + have hv : (fun i => x i)-qmaFourProjection *ᵥ (fun i => x i) = 0 := by + simpa only [y,WithLp.toLp_eq_zero] using hz + exact (sub_eq_zero.mp hv).symm + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourIsometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourIsometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..c79cad4a52d9e928eec31464f255f34f3088e3ab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourIsometry.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourEncoding + +namespace OAI + +/-! Normalization of the two exact singlet columns. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourRawComplex : Matrix (Fin 16) (Fin 2) ℂ := + qmaFourRawEncoding.map (Rat.castHom ℂ) + +def qmaFourNormalization : Matrix (Fin 2) (Fin 2) ℂ := + Matrix.diagonal ![1/2,1/(2*(Real.sqrt 3:ℝ))] + +def qmaFourEncoding : Matrix (Fin 16) (Fin 2) ℂ := qmaFourRawComplex*qmaFourNormalization + +theorem qmaFourRawComplex_adjoint : qmaFourRawComplex.conjTranspose = + qmaFourRawEncoding.transpose.map (Rat.castHom ℂ) := by + ext b s + simp [qmaFourRawComplex,Matrix.conjTranspose_apply,Matrix.transpose_apply] + +theorem qmaFourRawComplex_gram : qmaFourRawComplex.conjTranspose*qmaFourRawComplex = + Matrix.diagonal ![(4:ℂ),12] := by + rw [qmaFourRawComplex_adjoint] + change qmaFourRawEncoding.transpose.map (Rat.castHom ℂ)* + qmaFourRawEncoding.map (Rat.castHom ℂ) = _ + rw [← Matrix.map_mul,qmaFourRawEncoding_gram] + ext a b + fin_cases a <;> fin_cases b <;> norm_num [Matrix.diagonal_apply] + +theorem qmaFourEncoding_gram : qmaFourEncoding.conjTranspose*qmaFourEncoding = 1 := by + have hs0 : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by norm_num)) + have hsc : (Real.sqrt 3:ℂ) ≠ 0 := by exact_mod_cast hs0 + have hs : (Real.sqrt 3:ℂ)^2 = 3 := by exact_mod_cast Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 3) + have htwo : (starRingEnd ℂ) (2:ℂ) = 2 := by + exact Complex.conj_ofReal 2 + calc + _ = qmaFourNormalization.conjTranspose*(qmaFourRawComplex.conjTranspose*qmaFourRawComplex)* + qmaFourNormalization := by + simp only [qmaFourEncoding,Matrix.conjTranspose_mul,Matrix.mul_assoc] + _ = qmaFourNormalization.conjTranspose*Matrix.diagonal ![(4:ℂ),12]*qmaFourNormalization := by + rw [qmaFourRawComplex_gram] + _ = 1 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourNormalization,Matrix.mul_apply,Matrix.conjTranspose_apply, + Matrix.diagonal_apply,Matrix.one_apply,Fin.sum_univ_two,Complex.star_def,htwo] + field_simp + rw [hs] + norm_num + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourLogical.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourLogical.lean new file mode 100644 index 0000000000000000000000000000000000000000..02e9f76bb4f9751993c25cf329ec9cfd2fb64851 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourLogical.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourProjector + +namespace OAI + +/-! Exact logical actions of the six physical exchanges in the singlet code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourLogical (i j : Fin 4) : Matrix (Fin 2) (Fin 2) ℂ := + if (i = 0 ∧ j = 1) ∨ (i = 2 ∧ j = 3) then !![-3,0;0,1] + else if (i = 0 ∧ j = 2) ∨ (i = 1 ∧ j = 3) then !![0,-(Real.sqrt 3:ℂ);-(Real.sqrt 3:ℂ),-2] + else !![0,(Real.sqrt 3:ℂ);(Real.sqrt 3:ℂ),-2] + +theorem qmaFourLogical_normalize (i j : Fin 4) : + (qmaFourRawLogical i j).map (Rat.castHom ℂ)*qmaFourNormalization = + qmaFourNormalization*qmaFourLogical i j := by + have hs0 : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by norm_num)) + have hsc : (Real.sqrt 3:ℂ) ≠ 0 := by exact_mod_cast hs0 + have hs : (Real.sqrt 3:ℂ)^2 = 3 := by exact_mod_cast Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 3) + unfold qmaFourRawLogical qmaFourLogical + split_ifs <;> ext a b <;> fin_cases a <;> fin_cases b <;> + norm_num [qmaFourNormalization,Matrix.mul_apply,Matrix.diagonal_apply,Matrix.map_apply,Fin.sum_univ_two] + all_goals field_simp + all_goals ring_nf + all_goals simp [hs] + +theorem qmaFourEncoding_action (i j : Fin 4) (hij : i < j) : + qmaFourExchange i j*qmaFourEncoding = qmaFourEncoding*qmaFourLogical i j := by + have he := congrArg (fun M : Matrix (Fin 16) (Fin 2) ℚ => M.map (Rat.castHom ℂ)) + (qmaFourRawEncoding_action i j hij) + rw [Matrix.map_mul,Matrix.map_mul] at he + change qmaFourExchange i j*qmaFourRawComplex = + qmaFourRawComplex*(qmaFourRawLogical i j).map (Rat.castHom ℂ) at he + rw [qmaFourEncoding,← Matrix.mul_assoc,he,Matrix.mul_assoc,qmaFourLogical_normalize, + ← Matrix.mul_assoc] + +theorem qmaFourEncoding_compression (i j : Fin 4) (hij : i < j) : + qmaFourEncoding.conjTranspose*qmaFourExchange i j*qmaFourEncoding = qmaFourLogical i j := by + rw [Matrix.mul_assoc,qmaFourEncoding_action i j hij,← Matrix.mul_assoc,qmaFourEncoding_gram, + Matrix.one_mul] + +theorem qmaFourLogical_Z : qmaFourLogical 0 1 = -(1 : Matrix (Fin 2) (Fin 2) ℂ)-(2:ℂ) • pauliZ := by + ext a b + fin_cases a <;> fin_cases b <;> norm_num [qmaFourLogical,pauliZ,Matrix.one_apply] + +theorem qmaFourLogical_X : qmaFourLogical 0 3-qmaFourLogical 0 2 = + (2*(Real.sqrt 3:ℂ)) • pauliX := by + ext a b + fin_cases a <;> fin_cases b <;> simp [qmaFourLogical,pauliX] + all_goals ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourNorm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a43b5bfd4ff16b154b1ac55aa0e53513dba5a05 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourNorm.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourAxis +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumEightBasis + +namespace OAI + +/-! Dimension-independent operator bounds for the actual exchange encoding. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFourSpin_norm (i : Fin 4) (μ : Fin 3) : ‖spinMatrixOperator (qmaFourSpin i μ)‖ ≤ 1 := by + rw [qmaFourSpin_source] + change ‖spinMatrixOperator ((sourceLocalPauli 4 i μ).submatrix + qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm)‖ ≤ 1 + rw [MediatorGraph.reindex_operator_norm] + exact sourceLocalPauli_operator_norm 4 i μ + +theorem qmaFourExchange_norm (i j : Fin 4) (hij : i ≠ j) : + ‖spinMatrixOperator (qmaFourExchange i j)‖ ≤ 3 := by + rw [qmaFourExchange_source] + change ‖spinMatrixOperator ((sourceHeisenbergMatrix 4 i j).submatrix + qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm)‖ ≤ 3 + rw [MediatorGraph.reindex_operator_norm] + exact sourceHeisenbergMatrix_operator_norm 4 i j hij + +theorem qmaFourCross_norm (i j : Fin 4) : ‖spinMatrixOperator (qmaFourCross i j)‖ ≤ 3 := by + rw [← qmaFourCross_source,MediatorGraph.reindex_operator_norm] + apply sourceHeisenbergMatrix_operator_norm + intro h + have hv := congrArg Fin.val h + have hi := i.isLt + simp only [Fin.val_natAdd,Fin.val_castAdd] at hv + omega + +theorem qmaFourWeightedCross_norm (a b : Fin 4 → ℝ) : + ‖spinMatrixOperator (qmaFourWeightedCross a b)‖ ≤ + 3*(∑ i, |a i|)*(∑ j, |b j|) := by + rw [qmaFourWeightedCross,spinMatrixOperator_sum] + calc + _ ≤ ∑ i, ∑ j, 3*|a i| *|b j| := by + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro i _ + rw [spinMatrixOperator_sum] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro j _ + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs,abs_mul] + calc + _ ≤ (|a i| *|b j|)*3 := mul_le_mul_of_nonneg_left (qmaFourCross_norm i j) (by positivity) + _ = _ := by ring + _ = (∑ i, 3*|a i|)*(∑ j, |b j|) := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro i _ + rw [Finset.mul_sum] + _ = _ := by rw [← Finset.mul_sum] + +theorem qmaFourAxisWeights_abs_sum (a : Fin 2) (p : Bool) : + (∑ i, |qmaFourAxisWeights a p i|) ≤ 28 := by + fin_cases a <;> cases p <;> + norm_num [qmaFourAxisWeights,qmaFourXWeights,qmaFourZWeights,Fin.sum_univ_succ] + +theorem qmaFourAxisCross_norm (a b : Fin 2) (p q : Bool) : + ‖spinMatrixOperator (qmaFourWeightedCross (qmaFourAxisWeights a p) (qmaFourAxisWeights b q))‖ ≤ + 2352 := by + apply (qmaFourWeightedCross_norm _ _).trans + have ha := qmaFourAxisWeights_abs_sum a p + have hb := qmaFourAxisWeights_abs_sum b q + have ha0 : 0 ≤ ∑ i, |qmaFourAxisWeights a p i| := by positivity + have hb0 : 0 ≤ ∑ i, |qmaFourAxisWeights b q i| := by positivity + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourPositive.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourPositive.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0abf0e032d3805ee52602a23320dde6ae138028 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourPositive.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourGapCertificate +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourIsometry +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalInput +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOperatorQuadratic + +namespace OAI + +/-! The checked rational certificate is nonnegative on all complex states. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourSymmetricColumn : Matrix (Fin 16) (Fin 5) ℚ := + fun s k => if qmaFourWeight s = k then 1 else 0 + +theorem qmaFourSymmetricRational_factor : + qmaFourSymmetricColumn*Matrix.diagonal qmaFourSymmetricWeights*qmaFourSymmetricColumn.transpose = + qmaFourSymmetricRational := by + ext s t + simp only [Matrix.mul_apply,Matrix.transpose_apply,qmaFourSymmetricColumn] + by_cases h : qmaFourWeight s = qmaFourWeight t + · simp [qmaFourSymmetricRational,← h] + · simp only [qmaFourSymmetricRational,h,ite_false] + apply Finset.sum_eq_zero + intro k _ + by_cases hsk : qmaFourWeight s = k + · have htk : qmaFourWeight t ≠ k := fun ht => h (hsk.trans ht.symm) + simp [hsk,htk] + · simp [hsk] + +theorem qmaRatMatrix_adjoint {α β : Type*} (M : Matrix α β ℚ) : + (M.map (Rat.castHom ℂ)).conjTranspose = M.transpose.map (Rat.castHom ℂ) := by + ext a b + simp [Matrix.conjTranspose_apply,Matrix.transpose_apply] + +def qmaFourSymmetricColumnComplex : Matrix (Fin 16) (Fin 5) ℂ := + qmaFourSymmetricColumn.map (Rat.castHom ℂ) + +def qmaFourSymmetricDiagonal : Matrix (Fin 5) (Fin 5) ℂ := + Matrix.diagonal (fun k => ((qmaFourSymmetricWeights k:ℝ):ℂ)) + +theorem qmaFourSymmetricDiagonal_cast : + (Matrix.diagonal qmaFourSymmetricWeights).map (Rat.castHom ℂ) = qmaFourSymmetricDiagonal := by + ext a b + by_cases h : a = b + · subst b + simp only [Matrix.map_apply,Matrix.diagonal_apply,ite_true,qmaFourSymmetricDiagonal] + norm_cast + · simp [h,qmaFourSymmetricDiagonal] + +theorem qmaFourSymmetricComplex_factor : + qmaFourSymmetricRational.map (Rat.castHom ℂ) = qmaFourSymmetricColumnComplex* + qmaFourSymmetricDiagonal*qmaFourSymmetricColumnComplex.conjTranspose := by + rw [← qmaFourSymmetricRational_factor,Matrix.map_mul,Matrix.map_mul, + qmaFourSymmetricDiagonal_cast] + rw [qmaFourSymmetricColumnComplex,qmaRatMatrix_adjoint] + +theorem qmaFourSymmetric_nonneg (x : EuclideanSpace ℂ (Fin 16)) : + 0 ≤ qmaQuadratic (qmaFourSymmetricRational.map (Rat.castHom ℂ)) (fun i => x i) := by + rw [qmaFourSymmetricComplex_factor] + have he := qmaQuadratic_sandwich qmaFourSymmetricColumnComplex.conjTranspose qmaFourSymmetricDiagonal x + rw [Matrix.conjTranspose_conjTranspose] at he + rw [he,← qmaQuadratic_operator] + unfold qmaFourSymmetricDiagonal + rw [qmaQuadratic_diagonal_real] + apply Finset.sum_nonneg + intro k _ + apply mul_nonneg _ (Complex.normSq_nonneg _) + fin_cases k <;> norm_num [qmaFourSymmetricWeights] + +def qmaFourProjection : Matrix (Fin 16) (Fin 16) ℂ := qmaFourProjectionRational.map (Rat.castHom ℂ) +def qmaFourPenalty : Matrix (Fin 16) (Fin 16) ℂ := qmaFourPenaltyRational.map (Rat.castHom ℂ) + +theorem qmaFourGap_complex : qmaFourPenalty-(4:ℂ) • (1-qmaFourProjection) = + qmaFourSymmetricRational.map (Rat.castHom ℂ) := by + rw [← qmaFourGapRational_factor] + ext s t + simp only [qmaFourPenalty,qmaFourProjection,qmaFourGapRational,Matrix.map_apply, + Matrix.sub_apply,Matrix.smul_apply,smul_eq_mul,map_sub,map_mul,map_ofNat,Matrix.one_apply] + by_cases h : s = t <;> simp [h] + +theorem qmaFourGap_form (x : EuclideanSpace ℂ (Fin 16)) : + 4*(qmaQuadratic (1 : Matrix (Fin 16) (Fin 16) ℂ) (fun i => x i)- + qmaQuadratic qmaFourProjection (fun i => x i)) ≤ qmaQuadratic qmaFourPenalty (fun i => x i) := by + have h := qmaFourSymmetric_nonneg x + rw [← qmaFourGap_complex,qmaQuadratic_sub] at h + have hs : qmaQuadratic ((4:ℂ) • (1-qmaFourProjection)) (fun i => x i) = + 4*qmaQuadratic (1-qmaFourProjection) (fun i => x i) := by + simpa only [Complex.ofReal_ofNat] using + qmaQuadratic_smul (1-qmaFourProjection) (4:ℝ) (fun i => x i) + rw [hs,qmaQuadratic_sub] at h + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourProjector.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourProjector.lean new file mode 100644 index 0000000000000000000000000000000000000000..a17bbb5aaee84aefb01a145e425bab1701da8b80 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourProjector.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourPositive + +namespace OAI + +/-! The rational projection is exactly the normalized singlet range. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical + +theorem qmaFourNormalization_square : qmaFourNormalization*qmaFourNormalization.conjTranspose = + (Matrix.diagonal ![(1/4:ℚ),1/12]).map (Rat.castHom ℂ) := by + have hs0 : Real.sqrt 3 ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (by norm_num)) + have hsc : (Real.sqrt 3:ℂ) ≠ 0 := by exact_mod_cast hs0 + have hs : (Real.sqrt 3:ℂ)^2 = 3 := by exact_mod_cast Real.sq_sqrt (by norm_num : (0:ℝ) ≤ 3) + have htwo : (starRingEnd ℂ) (2:ℂ) = 2 := Complex.conj_ofReal 2 + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourNormalization,Matrix.mul_apply,Matrix.conjTranspose_apply,Matrix.map_apply, + Matrix.diagonal_apply,Fin.sum_univ_two,Complex.star_def,htwo] + field_simp + rw [hs] + norm_num + +theorem qmaFourProjectionRational_factor : + qmaFourRawEncoding*Matrix.diagonal ![(1/4:ℚ),1/12]*qmaFourRawEncoding.transpose = + qmaFourProjectionRational := by + ext s t + simp [Matrix.mul_apply,Matrix.diagonal_apply,Matrix.transpose_apply,Fin.sum_univ_two, + qmaFourRawEncoding,qmaFourProjectionRational] + ring + +theorem qmaFourEncoding_projector : qmaFourEncoding*qmaFourEncoding.conjTranspose = qmaFourProjection := by + calc + _ = qmaFourRawComplex*(qmaFourNormalization*qmaFourNormalization.conjTranspose)* + qmaFourRawComplex.conjTranspose := by + simp only [qmaFourEncoding,Matrix.conjTranspose_mul,Matrix.mul_assoc] + _ = qmaFourProjection := by + rw [qmaFourNormalization_square,qmaFourRawComplex_adjoint,qmaFourRawComplex, + ← Matrix.map_mul,← Matrix.map_mul,qmaFourProjectionRational_factor] + rfl + +theorem qmaFour_complement_gap (x : EuclideanSpace ℂ (Fin 16)) + (hx : qmaFourEncoding.conjTranspose *ᵥ (fun i => x i) = 0) : + 4*‖x‖^2 ≤ qmaQuadratic qmaFourPenalty (fun i => x i) := by + have hp : qmaFourProjection *ᵥ (fun i => x i) = 0 := by + rw [← qmaFourEncoding_projector,← Matrix.mulVec_mulVec,hx,Matrix.mulVec_zero] + have hzero : qmaQuadratic qmaFourProjection (fun i => x i) = 0 := by simp [qmaQuadratic,hp] + have hone : qmaQuadratic (1 : Matrix (Fin 16) (Fin 16) ℂ) (fun i => x i) = ‖x‖^2 := by + rw [qmaQuadratic_operator,qmaMatrixOperator_square,spinMatrixOperator_one,one_apply_eq_self, + real_inner_self_eq_norm_sq] + have h := qmaFourGap_form x + rwa [hzero,sub_zero,hone] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpatial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpatial.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d8458895dcd315f7dc8c0831341df8cd1aa0f03 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpatial.lean @@ -0,0 +1,105 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumBlockEdges +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighbors +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialSubdivision + +namespace OAI + +/-! Four-spin encoding preserves neighboring-cell geometry and constant density. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical +variable {n rows width : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +def qmaFourBlockCell (cell : Fin n → QMAGridCell rows width) (i : Fin (n*4)) : + QMAGridCell rows width := cell (finProdFinEquiv.symm i).1 + +def qmaFourExchangeAnchor (cell : Fin n → QMAGridCell rows width) + (pairAnchor : κ → QMAGridCell rows width) (fieldAnchor : τ → QMAGridCell rows width) : + QMAFourExchangeIndex n κ τ → QMAGridCell rows width + | .inl (i,_) => cell i + | .inr (.inl (e,_)) => pairAnchor e + | .inr (.inr (.inl (e,_))) => pairAnchor e + | .inr (.inr (.inr (e,_))) => fieldAnchor e + +omit [Fintype κ] [Fintype τ] in +theorem qmaFourExchange_spatial (cell : Fin n → QMAGridCell rows width) + (pairAnchor : κ → QMAGridCell rows width) (fieldAnchor : τ → QMAGridCell rows width) + (left right : κ → Fin n) (site : τ → Fin n) + (hl : ∀ e, QMAGridCellsNear (cell (left e)) (pairAnchor e)) + (hr : ∀ e, QMAGridCellsNear (cell (right e)) (pairAnchor e)) + (hs : ∀ e, QMAGridCellsNear (cell (site e)) (fieldAnchor e)) + (x : QMAFourExchangeIndex n κ τ) : + QMAGridCellsNear (qmaFourBlockCell cell (qmaFourExchangeLeft left right site x)) + (qmaFourExchangeAnchor cell pairAnchor fieldAnchor x) ∧ + QMAGridCellsNear (qmaFourBlockCell cell (qmaFourExchangeRight left right site x)) + (qmaFourExchangeAnchor cell pairAnchor fieldAnchor x) := by + rcases x with ⟨i,k⟩ | (⟨e,p,q⟩ | (⟨e,s,k⟩ | ⟨e,k⟩)) + · simp only [qmaFourExchangeLeft,qmaFourExchangeRight,qmaFourBlockCell, + Equiv.symm_apply_apply,qmaFourExchangeAnchor] + exact ⟨qmaGridCellsNear_refl _,qmaGridCellsNear_refl _⟩ + · simpa only [qmaFourExchangeLeft,qmaFourExchangeRight,qmaFourBlockCell, + Equiv.symm_apply_apply,qmaFourExchangeAnchor] using And.intro (hl e) (hr e) + · simp only [qmaFourExchangeLeft,qmaFourExchangeRight,qmaFourBlockCell, + Equiv.symm_apply_apply,qmaFourExchangeAnchor] + split_ifs + · exact ⟨hl e,hl e⟩ + · exact ⟨hr e,hr e⟩ + · simpa only [qmaFourExchangeLeft,qmaFourExchangeRight,qmaFourBlockCell, + Equiv.symm_apply_apply,qmaFourExchangeAnchor] using And.intro (hs e) (hs e) + +theorem qmaProductFilter_card {α β : Type*} [Fintype α] [Fintype β] + (p : α → Prop) [DecidablePred p] : + (Finset.univ.filter (fun q : α × β => p q.1)).card = + Fintype.card β*(Finset.univ.filter p).card := by + have he : (Finset.univ.filter (fun q : α × β => p q.1)) = + (Finset.univ.filter p) ×ˢ (Finset.univ : Finset β) := by ext q; simp + rw [he,Finset.card_product] + simp only [Finset.card_univ,Nat.mul_comm] + +theorem qmaFourBlockCell_density (cell : Fin n → QMAGridCell rows width) {A : ℕ} + (hcell : ∀ p, (Finset.univ.filter (fun i => cell i = p)).card ≤ A) + (p : QMAGridCell rows width) : + (Finset.univ.filter (fun i => qmaFourBlockCell cell i = p)).card ≤ 4*A := by + have he : (Finset.univ.filter (fun i => qmaFourBlockCell cell i = p)).card = + (Finset.univ.filter (fun x : Fin n × Fin 4 => cell x.1 = p)).card := by + apply Finset.card_equiv finProdFinEquiv.symm + intro i + constructor + · intro hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp hi).2⟩ + · intro hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp hi).2⟩ + rw [he,qmaProdFilter_card (α := Fin n) 4 (fun i => cell i = p)] + exact Nat.mul_le_mul_left 4 (hcell p) + +theorem qmaFourExchangeAnchor_density (cell : Fin n → QMAGridCell rows width) + (pairAnchor : κ → QMAGridCell rows width) (fieldAnchor : τ → QMAGridCell rows width) + {A B C : ℕ} + (hcell : ∀ p, (Finset.univ.filter (fun i => cell i = p)).card ≤ A) + (hp : ∀ p, (Finset.univ.filter (fun e => pairAnchor e = p)).card ≤ B) + (hf : ∀ p, (Finset.univ.filter (fun e => fieldAnchor e = p)).card ≤ C) + (p : QMAGridCell rows width) : + (Finset.univ.filter (fun e => qmaFourExchangeAnchor cell pairAnchor fieldAnchor e = p)).card ≤ + 6*A+22*B+3*C := by + rw [qmaSumFilter_card,qmaSumFilter_card,qmaSumFilter_card] + change (Finset.univ.filter (fun x : Fin n × Fin 6 => cell x.1 = p)).card + + ((Finset.univ.filter (fun x : κ × (Fin 4 × Fin 4) => pairAnchor x.1 = p)).card + + ((Finset.univ.filter (fun x : κ × (Fin 2 × Fin 3) => pairAnchor x.1 = p)).card + + (Finset.univ.filter (fun x : τ × Fin 3 => fieldAnchor x.1 = p)).card)) ≤ _ + rw [qmaProductFilter_card (fun i => cell i = p), + qmaProductFilter_card (β := Fin 4 × Fin 4) (fun e => pairAnchor e = p), + qmaProductFilter_card (β := Fin 2 × Fin 3) (fun e => pairAnchor e = p), + qmaProductFilter_card (β := Fin 3) (fun e => fieldAnchor e = p)] + simp only [Fintype.card_prod,Fintype.card_fin] + have h1 := Nat.mul_le_mul_left 6 (hcell p) + have h2 := Nat.mul_le_mul_left 16 (hp p) + have h3 := Nat.mul_le_mul_left 6 (hp p) + have h4 := Nat.mul_le_mul_left 3 (hf p) + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpin.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpin.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4146c2e8e3bfcdd25567c2d23fa4ccacf0f1c3c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpin.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliMonomial +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourGround + +namespace OAI + +/-! Physical single-spin actions on the four-spin encoding. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourSpinIndex (i : Fin 4) (μ : Fin 3) (s : Fin 16) : Fin 16 := + qmaFourIndex (Function.update (qmaFourBits s) i (qmaPauliBit μ (qmaFourBits s i))) + +def qmaFourSpinRational (i : Fin 4) (μ : Fin 3) : Matrix (Fin 16) (Fin 16) ℚ := + fun s t => qmaPhysicalPauliSign μ (qmaFourBits s i)* + (if qmaFourSpinIndex i μ s = t then 1 else 0) + +def qmaFourSpin (i : Fin 4) (μ : Fin 3) : Matrix (Fin 16) (Fin 16) ℂ := + qmaPauliPhase μ • (qmaFourSpinRational i μ).map (Rat.castHom ℂ) + +theorem qmaFourSpin_source (i : Fin 4) (μ : Fin 3) : qmaFourSpin i μ = + (sourceLocalPauli 4 i μ).submatrix qmaFourBits qmaFourBits := by + ext s t + have he : qmaFourSpinIndex i μ s = t ↔ + Function.update (qmaFourBits s) i (qmaPauliBit μ (qmaFourBits s i)) = qmaFourBits t := + qmaFourBasisEquiv.eq_symm_apply.symm + simp only [qmaFourSpin,Matrix.smul_apply,smul_eq_mul,Matrix.map_apply, + qmaFourSpinRational,map_mul,Matrix.submatrix_apply,qmaLocalPauli_monomial] + by_cases h : qmaFourSpinIndex i μ s = t + · simp [h,he.mp h] + · have ht := mt he.mpr h + simp [h,ht] + +theorem qmaFourSpinRational_mulVec (i : Fin 4) (μ : Fin 3) (v : Fin 16 → ℚ) (s : Fin 16) : + (qmaFourSpinRational i μ *ᵥ v) s = + qmaPhysicalPauliSign μ (qmaFourBits s i)*v (qmaFourSpinIndex i μ s) := by + simp only [qmaFourSpinRational,Matrix.mulVec,dotProduct,mul_assoc,← Finset.mul_sum, + ite_mul,one_mul,zero_mul] + simp + +def qmaFourSpinRawAction (i : Fin 4) (μ : Fin 3) : Matrix (Fin 16) (Fin 2) ℚ := + fun s b => qmaPhysicalPauliSign μ (qmaFourBits s i)*qmaFourRawEncoding (qmaFourSpinIndex i μ s) b + +theorem qmaFourSpinRawAction_eq (i : Fin 4) (μ : Fin 3) : + qmaFourSpinRational i μ*qmaFourRawEncoding = qmaFourSpinRawAction i μ := by + ext s b + exact qmaFourSpinRational_mulVec i μ (fun t => qmaFourRawEncoding t b) s + +theorem qmaFourSpin_encoding (i : Fin 4) (μ : Fin 3) : + qmaFourSpin i μ*qmaFourEncoding = qmaPauliPhase μ • + ((qmaFourSpinRawAction i μ).map (Rat.castHom ℂ)*qmaFourNormalization) := by + rw [qmaFourSpin,qmaFourEncoding,Matrix.smul_mul,← Matrix.mul_assoc,qmaFourRawComplex, + ← Matrix.map_mul,qmaFourSpinRawAction_eq] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinCertificate.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..79b841b3ea82fdb7c6c2cafbb84a62d7fca9af5b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinCertificate.lean @@ -0,0 +1,320 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourSpin + +namespace OAI + +/-! Fixed rational certificates for the one-spin excited columns. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFourPenaltyRational_mulVec (v : Fin 16 → ℚ) (s : Fin 16) : + (qmaFourPenaltyRational *ᵥ v) s = 2*( + v (qmaFourIndex (sourceSpinSwap 0 1 (qmaFourBits s)))+ + v (qmaFourIndex (sourceSpinSwap 0 2 (qmaFourBits s)))+ + v (qmaFourIndex (sourceSpinSwap 0 3 (qmaFourBits s)))+ + v (qmaFourIndex (sourceSpinSwap 1 2 (qmaFourBits s)))+ + v (qmaFourIndex (sourceSpinSwap 1 3 (qmaFourBits s)))+ + v (qmaFourIndex (sourceSpinSwap 2 3 (qmaFourBits s)))) := by + simp only [qmaFourPenaltyRational,Matrix.add_mulVec,Pi.add_apply,Matrix.smul_mulVec, + Matrix.one_mulVec,Pi.smul_apply,smul_eq_mul,qmaFourExchangeRational_mulVec] + ring + +theorem qmaFourSpinRawAction_orthogonal00 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 0 0 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen00 : + qmaFourPenaltyRational*qmaFourSpinRawAction 0 0 = + (4:ℚ) • qmaFourSpinRawAction 0 0 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 0 0 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal01 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 0 1 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen01 : + qmaFourPenaltyRational*qmaFourSpinRawAction 0 1 = + (4:ℚ) • qmaFourSpinRawAction 0 1 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 0 1 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal02 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 0 2 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen02 : + qmaFourPenaltyRational*qmaFourSpinRawAction 0 2 = + (4:ℚ) • qmaFourSpinRawAction 0 2 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 0 2 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal10 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 1 0 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen10 : + qmaFourPenaltyRational*qmaFourSpinRawAction 1 0 = + (4:ℚ) • qmaFourSpinRawAction 1 0 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 1 0 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal11 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 1 1 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen11 : + qmaFourPenaltyRational*qmaFourSpinRawAction 1 1 = + (4:ℚ) • qmaFourSpinRawAction 1 1 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 1 1 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal12 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 1 2 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen12 : + qmaFourPenaltyRational*qmaFourSpinRawAction 1 2 = + (4:ℚ) • qmaFourSpinRawAction 1 2 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 1 2 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal20 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 2 0 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen20 : + qmaFourPenaltyRational*qmaFourSpinRawAction 2 0 = + (4:ℚ) • qmaFourSpinRawAction 2 0 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 2 0 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal21 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 2 1 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen21 : + qmaFourPenaltyRational*qmaFourSpinRawAction 2 1 = + (4:ℚ) • qmaFourSpinRawAction 2 1 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 2 1 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal22 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 2 2 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen22 : + qmaFourPenaltyRational*qmaFourSpinRawAction 2 2 = + (4:ℚ) • qmaFourSpinRawAction 2 2 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 2 2 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal30 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 3 0 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen30 : + qmaFourPenaltyRational*qmaFourSpinRawAction 3 0 = + (4:ℚ) • qmaFourSpinRawAction 3 0 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 3 0 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal31 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 3 1 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen31 : + qmaFourPenaltyRational*qmaFourSpinRawAction 3 1 = + (4:ℚ) • qmaFourSpinRawAction 3 1 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 3 1 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal32 : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction 3 2 = 0 := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [Matrix.mul_apply,Matrix.transpose_apply,Fin.sum_univ_succ, + qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def] + +theorem qmaFourSpinRawAction_eigen32 : + qmaFourPenaltyRational*qmaFourSpinRawAction 3 2 = + (4:ℚ) • qmaFourSpinRawAction 3 2 := by + ext s b + change (qmaFourPenaltyRational *ᵥ fun t => qmaFourSpinRawAction 3 2 t b) s = _ + rw [qmaFourPenaltyRational_mulVec] + simp only [Matrix.smul_apply,smul_eq_mul] + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinRawAction,qmaPhysicalPauliSign,qmaFourSpinIndex,qmaPauliBit, + qmaFourRawEncoding,qmaFourRaw0,qmaFourRaw1,qmaFourIndex,qmaFourBits, + Function.update_apply,Equiv.swap_apply_def,sourceSpinSwap_apply] + +theorem qmaFourSpinRawAction_orthogonal (i : Fin 4) (μ : Fin 3) : + qmaFourRawEncoding.transpose*qmaFourSpinRawAction i μ = 0 := by + fin_cases i + · fin_cases μ + · exact qmaFourSpinRawAction_orthogonal00 + · exact qmaFourSpinRawAction_orthogonal01 + · exact qmaFourSpinRawAction_orthogonal02 + · fin_cases μ + · exact qmaFourSpinRawAction_orthogonal10 + · exact qmaFourSpinRawAction_orthogonal11 + · exact qmaFourSpinRawAction_orthogonal12 + · fin_cases μ + · exact qmaFourSpinRawAction_orthogonal20 + · exact qmaFourSpinRawAction_orthogonal21 + · exact qmaFourSpinRawAction_orthogonal22 + · fin_cases μ + · exact qmaFourSpinRawAction_orthogonal30 + · exact qmaFourSpinRawAction_orthogonal31 + · exact qmaFourSpinRawAction_orthogonal32 + +theorem qmaFourSpinRawAction_eigen (i : Fin 4) (μ : Fin 3) : + qmaFourPenaltyRational*qmaFourSpinRawAction i μ = (4:ℚ) • qmaFourSpinRawAction i μ := by + fin_cases i + · fin_cases μ + · exact qmaFourSpinRawAction_eigen00 + · exact qmaFourSpinRawAction_eigen01 + · exact qmaFourSpinRawAction_eigen02 + · fin_cases μ + · exact qmaFourSpinRawAction_eigen10 + · exact qmaFourSpinRawAction_eigen11 + · exact qmaFourSpinRawAction_eigen12 + · fin_cases μ + · exact qmaFourSpinRawAction_eigen20 + · exact qmaFourSpinRawAction_eigen21 + · exact qmaFourSpinRawAction_eigen22 + · fin_cases μ + · exact qmaFourSpinRawAction_eigen30 + · exact qmaFourSpinRawAction_eigen31 + · exact qmaFourSpinRawAction_eigen32 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTable.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTable.lean new file mode 100644 index 0000000000000000000000000000000000000000..4560c3aad84a8f3aa44f9a29a124a4e1634249dc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTable.lean @@ -0,0 +1,183 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourSpinCertificate + +namespace OAI + +/-! Sparse rational tables for the four-spin contractions. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourSpinTable00 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,-1,1,0,0,0,0,0,0,0,0,0,0,1,-1,0] s + else ![0,-1,-1,0,2,0,0,0,0,0,0,2,0,-1,-1,0] s + +theorem qmaFourSpinRawAction_table00 : + qmaFourSpinRawAction 0 0 = qmaFourSpinTable00 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable00,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable01 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,1,-1,0,0,0,0,0,0,0,0,0,0,1,-1,0] s + else ![0,1,1,0,-2,0,0,0,0,0,0,2,0,-1,-1,0] s + +theorem qmaFourSpinRawAction_table01 : + qmaFourSpinRawAction 0 1 = qmaFourSpinTable01 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable01,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable02 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,0,1,-1,0,0,1,-1,0,0,0,0,0] s + else ![0,0,0,2,0,-1,-1,0,0,1,1,0,-2,0,0,0] s + +theorem qmaFourSpinRawAction_table02 : + qmaFourSpinRawAction 0 2 = qmaFourSpinTable02 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable02,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable10 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,1,-1,0,0,0,0,0,0,0,0,0,0,-1,1,0] s + else ![0,-1,-1,0,0,0,0,2,2,0,0,0,0,-1,-1,0] s + +theorem qmaFourSpinRawAction_table10 : + qmaFourSpinRawAction 1 0 = qmaFourSpinTable10 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable10,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable11 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,-1,1,0,0,0,0,0,0,0,0,0,0,-1,1,0] s + else ![0,1,1,0,0,0,0,2,-2,0,0,0,0,-1,-1,0] s + +theorem qmaFourSpinRawAction_table11 : + qmaFourSpinRawAction 1 1 = qmaFourSpinTable11 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable11,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable12 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,0,-1,1,0,0,-1,1,0,0,0,0,0] s + else ![0,0,0,2,0,1,1,0,0,-1,-1,0,-2,0,0,0] s + +theorem qmaFourSpinRawAction_table12 : + qmaFourSpinRawAction 1 2 = qmaFourSpinTable12 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable12,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable20 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,-1,0,0,1,1,0,0,-1,0,0,0,0] s + else ![0,2,0,0,-1,0,0,-1,-1,0,0,-1,0,0,2,0] s + +theorem qmaFourSpinRawAction_table20 : + qmaFourSpinRawAction 2 0 = qmaFourSpinTable20 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable20,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable21 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,1,0,0,1,-1,0,0,-1,0,0,0,0] s + else ![0,-2,0,0,1,0,0,-1,1,0,0,-1,0,0,2,0] s + +theorem qmaFourSpinRawAction_table21 : + qmaFourSpinRawAction 2 1 = qmaFourSpinTable21 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable21,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable22 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,0,1,1,0,0,-1,-1,0,0,0,0,0] s + else ![0,0,0,-2,0,-1,1,0,0,-1,1,0,2,0,0,0] s + +theorem qmaFourSpinRawAction_table22 : + qmaFourSpinRawAction 2 2 = qmaFourSpinTable22 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable22,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable30 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,1,0,0,-1,-1,0,0,1,0,0,0,0] s + else ![0,0,2,0,-1,0,0,-1,-1,0,0,-1,0,2,0,0] s + +theorem qmaFourSpinRawAction_table30 : + qmaFourSpinRawAction 3 0 = qmaFourSpinTable30 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable30,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable31 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,-1,0,0,-1,1,0,0,1,0,0,0,0] s + else ![0,0,-2,0,1,0,0,-1,1,0,0,-1,0,2,0,0] s + +theorem qmaFourSpinRawAction_table31 : + qmaFourSpinRawAction 3 1 = qmaFourSpinTable31 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable31,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable32 : Matrix (Fin 16) (Fin 2) ℚ := fun s b => + if b = 0 then ![0,0,0,0,0,-1,-1,0,0,1,1,0,0,0,0,0] s + else ![0,0,0,-2,0,1,-1,0,0,1,-1,0,2,0,0,0] s + +theorem qmaFourSpinRawAction_table32 : + qmaFourSpinRawAction 3 2 = qmaFourSpinTable32 := by + ext s b + fin_cases s <;> fin_cases b <;> + norm_num [qmaFourSpinTable32,qmaFourSpinRawAction,qmaPhysicalPauliSign, + qmaFourSpinIndex,qmaPauliBit,qmaFourIndex,qmaFourBits,qmaFourRawEncoding, + qmaFourRaw0,qmaFourRaw1,Function.update_apply,Equiv.swap_apply_def] + +def qmaFourSpinTable (i : Fin 4) (μ : Fin 3) : Matrix (Fin 16) (Fin 2) ℚ := + ![![qmaFourSpinTable00,qmaFourSpinTable01,qmaFourSpinTable02],![qmaFourSpinTable10,qmaFourSpinTable11,qmaFourSpinTable12],![qmaFourSpinTable20,qmaFourSpinTable21,qmaFourSpinTable22],![qmaFourSpinTable30,qmaFourSpinTable31,qmaFourSpinTable32]] i μ + +theorem qmaFourSpinRawAction_table (i : Fin 4) (μ : Fin 3) : + qmaFourSpinRawAction i μ = qmaFourSpinTable i μ := by + fin_cases i + · fin_cases μ + · exact qmaFourSpinRawAction_table00 + · exact qmaFourSpinRawAction_table01 + · exact qmaFourSpinRawAction_table02 + · fin_cases μ + · exact qmaFourSpinRawAction_table10 + · exact qmaFourSpinRawAction_table11 + · exact qmaFourSpinRawAction_table12 + · fin_cases μ + · exact qmaFourSpinRawAction_table20 + · exact qmaFourSpinRawAction_table21 + · exact qmaFourSpinRawAction_table22 + · fin_cases μ + · exact qmaFourSpinRawAction_table30 + · exact qmaFourSpinRawAction_table31 + · exact qmaFourSpinRawAction_table32 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTransition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTransition.lean new file mode 100644 index 0000000000000000000000000000000000000000..592ebb91bc9d9f09dbdd66235b3ece6b3babe709 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourSpinTransition.lean @@ -0,0 +1,44 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourSpinCertificate + +namespace OAI + +/-! Single-spin transitions leave the singlet code and have penalty four. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFourSpin_star (i : Fin 4) (μ : Fin 3) : + (qmaFourSpin i μ).conjTranspose = qmaFourSpin i μ := by + rw [qmaFourSpin_source,Matrix.conjTranspose_submatrix,sourceLocalPauli_star] + +theorem qmaFourSpin_orthogonal (i : Fin 4) (μ : Fin 3) : + qmaFourEncoding.conjTranspose*qmaFourSpin i μ*qmaFourEncoding = 0 := by + rw [Matrix.mul_assoc,qmaFourSpin_encoding,Matrix.mul_smul] + have he : qmaFourEncoding.conjTranspose* + ((qmaFourSpinRawAction i μ).map (Rat.castHom ℂ)*qmaFourNormalization) = 0 := by + rw [qmaFourEncoding,Matrix.conjTranspose_mul,qmaFourRawComplex_adjoint] + calc + _ = qmaFourNormalization.conjTranspose* + ((qmaFourRawEncoding.transpose*qmaFourSpinRawAction i μ).map (Rat.castHom ℂ))* + qmaFourNormalization := by rw [Matrix.map_mul]; simp only [Matrix.mul_assoc] + _ = 0 := by rw [qmaFourSpinRawAction_orthogonal]; simp + rw [he,smul_zero] + +theorem qmaFourSpin_excitation (i : Fin 4) (μ : Fin 3) : + qmaFourPenalty*(qmaFourSpin i μ*qmaFourEncoding) = + (4:ℂ) • (qmaFourSpin i μ*qmaFourEncoding) := by + rw [qmaFourSpin_encoding,Matrix.mul_smul,← Matrix.mul_assoc,qmaFourPenalty, + ← Matrix.map_mul,qmaFourSpinRawAction_eigen] + have he : ((4:ℚ) • qmaFourSpinRawAction i μ).map (Rat.castHom ℂ) = + (4:ℂ) • (qmaFourSpinRawAction i μ).map (Rat.castHom ℂ) := by + ext s b + simp + rw [he,Matrix.smul_mul,smul_comm] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourStencils.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourStencils.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ff12e4fa4cd0b90b252c5fa37a3595da07645b6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourStencils.lean @@ -0,0 +1,54 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourWeighted + +namespace OAI + +/-! Rational physical-spin weights giving shifted logical X and Z. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourXWeights (positive : Bool) : Fin 4 → ℝ := + if positive then ![11,-1,-13,3] else ![11,-1,3,-13] + +def qmaFourZWeights (positive : Bool) : Fin 4 → ℝ := + if positive then ![1,-1,0,0] else ![1,1,0,0] + +theorem qmaFourXWeights_true : + qmaFourWeightedCorrelation (qmaFourXWeights true) = + (400:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+(128*(Real.sqrt 3:ℂ)) • pauliX := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourWeightedCorrelation,qmaFourXWeights,qmaFourCorrelation, + qmaFourLogical,Fin.sum_univ_succ,Matrix.one_apply,pauliX] <;> ring + +theorem qmaFourXWeights_false : + qmaFourWeightedCorrelation (qmaFourXWeights false) = + (400:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+(-128*(Real.sqrt 3:ℂ)) • pauliX := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourWeightedCorrelation,qmaFourXWeights,qmaFourCorrelation, + qmaFourLogical,Fin.sum_univ_succ,Matrix.one_apply,pauliX] <;> ring + +theorem qmaFourZWeights_true : + qmaFourWeightedCorrelation (qmaFourZWeights true) = + (8/3:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+(4/3:ℂ) • pauliZ := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourWeightedCorrelation,qmaFourZWeights,qmaFourCorrelation, + qmaFourLogical,Fin.sum_univ_succ,Matrix.one_apply,pauliZ] + +theorem qmaFourZWeights_false : + qmaFourWeightedCorrelation (qmaFourZWeights false) = + (4/3:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+(-4/3:ℂ) • pauliZ := by + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaFourWeightedCorrelation,qmaFourZWeights,qmaFourCorrelation, + qmaFourLogical,Fin.sum_univ_succ,Matrix.one_apply,pauliZ] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCoefficientBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCoefficientBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e9dc754d4a1ea1f9442129b3b52b7d22856d878 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCoefficientBounds.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFields + +namespace OAI + +/-! Polynomial bounds for the internal counterterm coefficients. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaFourCouplingFactor_nonneg (a b : Fin 2) (t : ℝ) : 0 ≤ qmaFourCouplingFactor a b t := by + unfold qmaFourCouplingFactor + positivity + +theorem qmaFourCouplingFactor_bound (a b : Fin 2) (t : ℝ) : qmaFourCouplingFactor a b t ≤ |t| := by + have ha := (qmaFourAxisScale_bounds a).1 + have hb := (qmaFourAxisScale_bounds b).1 + have hf := qmaFourCouplingFactor_nonneg a b t + have he : qmaFourCouplingFactor a b t*qmaFourAxisScale a*qmaFourAxisScale b = |t| := + qmaFourCouplingSize_square a b t + calc + _ ≤ qmaFourCouplingFactor a b t*qmaFourAxisScale a := by nlinarith + _ ≤ qmaFourCouplingFactor a b t*qmaFourAxisScale a*qmaFourAxisScale b := by + exact le_mul_of_one_le_right (mul_nonneg hf (le_trans (by norm_num) ha)) hb + _ = _ := he + +theorem qmaFourAxisShift_abs_bound (a : Fin 2) (p : Bool) : |qmaFourAxisShift a p| ≤ 400 := by + fin_cases a <;> cases p <;> norm_num [qmaFourAxisShift] + +theorem qmaFourAxisScale_abs_bound (a : Fin 2) : |qmaFourAxisScale a| ≤ 256 := by + rw [abs_of_pos (qmaFourAxisScale_pos a)] + exact (qmaFourAxisScale_bounds a).2 + +theorem qmaFourAxisSign_abs (p : Bool) : |qmaFourAxisSign p| = 1 := by + cases p <;> norm_num [qmaFourAxisSign] + +theorem qmaFourCounterA_bound (a b : Fin 2) (t : ℝ) : |qmaFourCounterA a b t| ≤ 102400*|t| := by + rw [qmaFourCounterA,abs_mul,abs_mul,abs_of_nonneg (qmaFourCouplingFactor_nonneg a b t)] + calc + _ ≤ (|t| * 256)*400 := mul_le_mul + (mul_le_mul (qmaFourCouplingFactor_bound a b t) (qmaFourAxisScale_abs_bound a) + (abs_nonneg _) (abs_nonneg t)) (qmaFourAxisShift_abs_bound b _) + (abs_nonneg _) (by positivity) + _ = _ := by ring + +theorem qmaFourCounterB_bound (a b : Fin 2) (t : ℝ) : |qmaFourCounterB a b t| ≤ 102400*|t| := by + rw [qmaFourCounterB,abs_mul,abs_mul,abs_mul,qmaFourAxisSign_abs,one_mul, + abs_of_nonneg (qmaFourCouplingFactor_nonneg a b t)] + calc + _ ≤ (|t| * 400)*256 := mul_le_mul + (mul_le_mul (qmaFourCouplingFactor_bound a b t) (qmaFourAxisShift_abs_bound a true) + (abs_nonneg _) (abs_nonneg t)) (qmaFourAxisScale_abs_bound b) + (abs_nonneg _) (by positivity) + _ = _ := by ring + +variable {n : ℕ} {κ : Type*} [Fintype κ] + +theorem qmaFourTensorCounterterm_linear_bound (i j : Fin n) (a b : Fin 2) (t : ℝ) : + ‖spinMatrixOperator (qmaFourTensorCounterterm i j a b t)‖ ≤ 1228800*|t| := by + apply (qmaFourTensorCounterterm_norm i j a b t).trans + have ha := qmaFourCounterA_bound a b t + have hb := qmaFourCounterB_bound a b t + linarith + +theorem qmaFourTensorFamilyCounterterm_bound (left right : κ → Fin n) + (a b : κ → Fin 2) (t : κ → ℝ) : + ‖spinMatrixOperator (qmaFourTensorFamilyCounterterm left right a b t)‖ ≤ + 1228800*(∑ e, |t e|) := by + rw [qmaFourTensorFamilyCounterterm,spinMatrixOperator_sum,Finset.mul_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun e _ => qmaFourTensorCounterterm_linear_bound _ _ _ _ _)) + +theorem qmaFourTensorFamilyCounterterm_star (left right : κ → Fin n) + (a b : κ → Fin 2) (t : κ → ℝ) : + (qmaFourTensorFamilyCounterterm left right a b t).conjTranspose = + qmaFourTensorFamilyCounterterm left right a b t := by + simp only [qmaFourTensorFamilyCounterterm,Matrix.conjTranspose_sum,qmaFourTensorCounterterm_star] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcc73d5cc5521556c8d2ea4d6ce644c379a47b17 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorComparison.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorGround +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorEffectiveError + +namespace OAI + +/-! Explicit full-space comparison with the calibrated logical matrix. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} + +theorem qmaEffectiveBottom_matrix_error + (L : EuclideanSpace ℂ (Fin n → Fin 2) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 2)) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (B : EuclideanSpace ℂ (Fin n → Fin 2) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (N : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) {δ : ℝ} + (he : ∀ p : EuclideanSpace ℂ (Fin n → Fin 2), ‖p‖ = 1 → + |Perturbation.effectiveForm L T B p-qmaQuadratic N (fun i => p i)| ≤ δ) : + |Perturbation.effectiveBottom L T B-MediatorGraph.normalizedBottom N| ≤ δ := by + obtain ⟨p,hp,hmin⟩ := Perturbation.effectiveForm_minimizer L T B u hu + rw [Perturbation.effectiveBottom_eq L T B p hp hmin] + have hlow := qmaNormalizedBottom_le N p hp + have herror := abs_le.mp (he p hp) + have hupp : Perturbation.effectiveForm L T B p-δ ≤ MediatorGraph.normalizedBottom N := by + apply le_qmaNormalizedBottom N u hu + intro x hx + have hm := hmin x + simp only [hx,one_pow,mul_one] at hm + have herr := (abs_le.mp (he x hx)).2 + linarith + exact abs_le.mpr ⟨by linarith,by linarith⟩ + +theorem qmaFourTensorPerturbation_operator (r : ℝ) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + (qmaMatrixOperator ((r:ℂ) • V+C)).restrictScalars ℝ = qmaFourTensorPerturbation r V C := by + rw [qmaMatrixOperator_add,qmaMatrixOperator_smul] + ext x s + change (r:ℂ)*(qmaMatrixOperator V x) s+(qmaMatrixOperator C x) s = + (r • qmaMatrixOperator V x+qmaMatrixOperator C x) s + simp only [PiLp.add_apply,PiLp.smul_apply,Complex.real_smul] + +theorem qmaFourTensorOff_inverse_bound (r : ℝ) (hr : 0 < r) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (hH : qmaFourTensorPenalty n*(V*qmaFourTensorEncoding n) = (8:ℂ) • (V*qmaFourTensorEncoding n)) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hTA : ∀ x, T (qmaFourTensorPadded n r x) = x) (hTn : ‖T‖ ≤ 1/(4*r^2)) + {v c : ℝ} (hVn : ‖spinMatrixOperator V‖ ≤ v) (hCn : ‖spinMatrixOperator C‖ ≤ c) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + ‖T (qmaFourTensorOff (qmaFourTensorPerturbation r V C) p)‖ ≤ + (v/(8*r)+c/(4*r^2))*‖p‖ := by + rw [qmaFourTensorOff_split r V C hV p] + apply qmaSecondOrder_inverse_column_bound T hr hTn + · have h := qmaFourTensorInverse_column hr T hTA (V*qmaFourTensorEncoding n) hV hH p + simpa only [qmaMatrixOperator_mul,ContinuousLinearMap.comp_apply,qmaFourTensorInclusion, + ContinuousLinearMap.coe_restrictScalars'] using h + · exact qmaFourTensor_column_norm V hVn p + · apply ((qmaFourTensorHigh n).le_opNorm _).trans + exact (mul_le_mul (qmaFourTensorHigh_norm n) (qmaFourTensor_column_norm C hCn p) + (norm_nonneg _) zero_le_one).trans_eq (one_mul _) + +theorem qmaFourTensor_comparison (r : ℝ) (hr : 0 < r) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hVs : V.conjTranspose = V) (hCs : C.conjTranspose = C) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (hH : qmaFourTensorPenalty n*(V*qmaFourTensorEncoding n) = (8:ℂ) • (V*qmaFourTensorEncoding n)) + {v c : ℝ} (hv : 0 ≤ v) (hc : 0 ≤ c) + (hVn : ‖spinMatrixOperator V‖ ≤ v) (hCn : ‖spinMatrixOperator C‖ ≤ c) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) + (hsmall : 2*(r*v+c+‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖+ + (v*c/(4*r)+c^2/(4*r^2))) ≤ 4*r^2) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r ((r:ℂ) • V+C))- + MediatorGraph.normalizedBottom (qmaFourTensorEffectiveMatrix V C)| ≤ + 2*(r*v+c+‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖+ + (v*c/(4*r)+c^2/(4*r^2)))*(v/(8*r)+c/(4*r^2))^2+ + (v*c/(4*r)+c^2/(4*r^2)) := by + let δ := v*c/(4*r)+c^2/(4*r^2) + let N := qmaFourTensorEffectiveMatrix V C + let K := qmaFourTensorPerturbation r V C + obtain ⟨T,hAT,hTA,hTn⟩ := qmaFourTensor_inverse_exists n hr + have hδ : 0 ≤ δ := by dsimp [δ]; positivity + have herror (p : EuclideanSpace ℂ (Fin n → Fin 2)) (hp : ‖p‖ = 1) : + |Perturbation.effectiveForm (qmaFourTensorLow K) T (qmaFourTensorOff K) p- + qmaQuadratic N (fun i => p i)| ≤ δ := by + simpa only [hp,one_pow,mul_one] using qmaFourTensorEffective_error r hr V C hV hH T hAT hTA hTn hv hc hVn hCn p + have hbound (p : EuclideanSpace ℂ (Fin n → Fin 2)) (hp : ‖p‖ = 1) : + |Perturbation.effectiveForm (qmaFourTensorLow K) T (qmaFourTensorOff K) p| ≤ + ‖spinMatrixOperator N‖+δ := by + have he := herror p hp + have hn := qmaQuadratic_norm_bound N p + simp only [hp,one_pow,mul_one] at hn + have ht := abs_sub_le (Perturbation.effectiveForm (qmaFourTensorLow K) T (qmaFourTensorOff K) p) + (qmaQuadratic N (fun i => p i)) 0 + simp only [sub_zero] at ht + linarith + have hU : ((r:ℂ) • V+C).conjTranspose = (r:ℂ) • V+C := by + simp only [Matrix.conjTranspose_add,Matrix.conjTranspose_smul,hVs,hCs,Complex.star_def,Complex.conj_ofReal] + have hUn : ‖spinMatrixOperator ((r:ℂ) • V+C)‖ ≤ r*v+c := by + rw [spinMatrixOperator_add] + apply (norm_add_le _ _).trans + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs,abs_of_pos hr] + exact add_le_add (mul_le_mul_of_nonneg_left hVn hr.le) hCn + have hground := qmaFourTensorGround_error r hr ((r:ℂ) • V+C) hU T hAT + (show 0 ≤ r*v+c by positivity) (show 0 ≤ ‖spinMatrixOperator N‖+δ by positivity) + (show 0 ≤ v/(8*r)+c/(4*r^2) by positivity) + (by simpa only [add_assoc] using hsmall) hUn + (by rw [qmaFourTensorPerturbation_operator]; exact qmaFourTensorOff_inverse_bound r hr V C hV hH T hTA hTn hVn hCn) + (by rw [qmaFourTensorPerturbation_operator]; exact hbound) u hu + rw [qmaFourTensorPerturbation_operator] at hground + have heff := qmaEffectiveBottom_matrix_error (qmaFourTensorLow K) T (qmaFourTensorOff K) N u hu herror + have h := (abs_sub_le + (MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r ((r:ℂ) • V+C))) + (Perturbation.effectiveBottom (qmaFourTensorLow K) T (qmaFourTensorOff K)) + (MediatorGraph.normalizedBottom N)).trans (add_le_add hground heff) + simpa only [N,δ,add_assoc] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCompression.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCompression.lean new file mode 100644 index 0000000000000000000000000000000000000000..292430e592898b292101b84d422af612b74776e8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCompression.lean @@ -0,0 +1,42 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorCross + +namespace OAI + +/-! Exact one-block and two-block compression in the full tensor encoding. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +theorem qmaFourTensor_site_compression (i : Fin n) (A : Matrix (Fin 16) (Fin 16) ℂ) : + (qmaFourTensorEncoding n).conjTranspose*qmaSiteMatrix i A*qmaFourTensorEncoding n = + qmaSiteMatrix i (qmaFourEncoding.conjTranspose*A*qmaFourEncoding) := by + simp only [qmaFourTensorEncoding,qmaSiteMatrix,qmaTensorMatrix_star,qmaTensorMatrix_mul] + congr 1 + funext k + by_cases h : k = i + · simp only [h,ite_true] + · simp only [h,ite_false,Matrix.mul_one,qmaFourEncoding_gram] + +theorem qmaFourTensor_pair_compression (i j : Fin n) + (A B : Matrix (Fin 16) (Fin 16) ℂ) : + (qmaFourTensorEncoding n).conjTranspose*qmaPairMatrix i j A B*qmaFourTensorEncoding n = + qmaPairMatrix i j (qmaFourEncoding.conjTranspose*A*qmaFourEncoding) + (qmaFourEncoding.conjTranspose*B*qmaFourEncoding) := by + simp only [qmaFourTensorEncoding,qmaPairMatrix,qmaTensorMatrix_star,qmaTensorMatrix_mul] + congr 1 + funext k + by_cases hi : k = i + · simp only [hi,ite_true] + · by_cases hj : k = j + · subst k + simp only [hi,ite_false,ite_true] + · simp only [hi,hj,ite_false,Matrix.mul_one,qmaFourEncoding_gram] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCross.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCross.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e09c7f96d1c89e1be3516b362528a9033269d4c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorCross.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorSpin +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTensorPair + +namespace OAI + +/-! Actual inter-block Heisenberg columns in the many-block four-spin code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +def qmaFourTensorPairColumn (i j : Fin n) (p q : Fin 4) (μ : Fin 3) : + Matrix (Fin n → Fin 16) (Fin n → Fin 2) ℂ := + qmaTensorMatrix (fun k => if k = i then qmaFourSpin p μ*qmaFourEncoding + else if k = j then qmaFourSpin q μ*qmaFourEncoding else qmaFourEncoding) + +def qmaFourTensorCross (i j : Fin n) (p q : Fin 4) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + ∑ μ : Fin 3, qmaSiteMatrix i (qmaFourSpin p μ)*qmaSiteMatrix j (qmaFourSpin q μ) + +theorem qmaFourTensorCross_column (i j : Fin n) (hij : i ≠ j) (p q : Fin 4) : + qmaFourTensorCross i j p q*qmaFourTensorEncoding n = + ∑ μ : Fin 3, qmaFourTensorPairColumn i j p q μ := by + rw [qmaFourTensorCross,Matrix.sum_mul] + apply Finset.sum_congr rfl + intro μ _ + rw [Matrix.mul_assoc,qmaFourTensorEncoding,qmaSiteMatrix_tensor,qmaSiteMatrix_tensor,qmaFourTensorPairColumn] + congr 1 + funext k + by_cases hki : k = i + · subst k + simp [hij] + · by_cases hkj : k = j + · subst k + simp [Ne.symm hij] + · simp [hki,hkj] + +theorem qmaFourTensorPairColumn_orthogonal (i j : Fin n) (p q : Fin 4) (μ : Fin 3) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorPairColumn i j p q μ = 0 := by + rw [qmaFourTensorEncoding,qmaFourTensorPairColumn,qmaTensorMatrix_star,qmaTensorMatrix_mul] + apply qmaTensorMatrix_zero_at _ i + simp only [ite_true,← Matrix.mul_assoc,qmaFourSpin_orthogonal] + +theorem qmaFourTensorPairColumn_excitation (i j : Fin n) (hij : i ≠ j) + (p q : Fin 4) (μ : Fin 3) : + qmaFourTensorPenalty n*qmaFourTensorPairColumn i j p q μ = + (8:ℂ) • qmaFourTensorPairColumn i j p q μ := by + have h := qmaTensorPenalty_eigen qmaFourPenalty + (fun k : Fin n => if k = i then qmaFourSpin p μ*qmaFourEncoding + else if k = j then qmaFourSpin q μ*qmaFourEncoding else qmaFourEncoding) + (fun k => (if k = i then (4:ℂ) else 0)+(if k = j then (4:ℂ) else 0)) (by + intro k + by_cases hki : k = i + · subst k + simp only [ite_true,hij,ite_false,add_zero] + exact qmaFourSpin_excitation p μ + · by_cases hkj : k = j + · subst k + simp only [hki,ite_true,ite_false,zero_add] + exact qmaFourSpin_excitation q μ + · simp only [hki,hkj,ite_false,zero_add,zero_smul,qmaFourPenalty_encoding]) + simpa only [qmaFourTensorPenalty,qmaFourTensorPairColumn,Finset.sum_add_distrib, + Finset.sum_ite_eq',Finset.mem_univ,ite_true,show (4:ℂ)+4 = 8 by norm_num] using h + +theorem qmaFourTensorCross_orthogonal (i j : Fin n) (hij : i ≠ j) (p q : Fin 4) : + (qmaFourTensorEncoding n).conjTranspose*(qmaFourTensorCross i j p q*qmaFourTensorEncoding n) = 0 := by + rw [qmaFourTensorCross_column i j hij,Matrix.mul_sum] + simp only [qmaFourTensorPairColumn_orthogonal,Finset.sum_const_zero] + +theorem qmaFourTensorCross_excitation (i j : Fin n) (hij : i ≠ j) (p q : Fin 4) : + qmaFourTensorPenalty n*(qmaFourTensorCross i j p q*qmaFourTensorEncoding n) = + (8:ℂ) • (qmaFourTensorCross i j p q*qmaFourTensorEncoding n) := by + rw [qmaFourTensorCross_column i j hij,Matrix.mul_sum] + simp only [qmaFourTensorPairColumn_excitation i j hij,Finset.smul_sum] + +theorem qmaFourTensorPairColumn_gram (i j : Fin n) + (p q r s : Fin 4) (μ ν : Fin 3) : + (qmaFourTensorPairColumn i j p q μ).conjTranspose*qmaFourTensorPairColumn i j r s ν = + if μ = ν then qmaPairMatrix i j (qmaFourCorrelation p r) (qmaFourCorrelation q s) else 0 := by + rw [qmaFourTensorPairColumn,qmaFourTensorPairColumn,qmaTensorMatrix_star,qmaTensorMatrix_mul] + by_cases hμ : μ = ν + · subst ν + rw [ite_eq_left rfl,qmaPairMatrix] + congr 1 + funext k + by_cases hki : k = i + · simp only [hki,ite_true,qmaFourSpin_correlation] + · by_cases hkj : k = j + · subst k + simp only [hki,ite_true,ite_false,qmaFourSpin_correlation] + · simp only [hki,hkj,ite_false,qmaFourEncoding_gram] + · rw [ite_eq_right hμ] + apply qmaTensorMatrix_zero_at _ i + simp only [ite_true,qmaFourSpin_correlation,hμ,ite_false] + +theorem qmaFourTensorCross_gram (i j : Fin n) (hij : i ≠ j) (p q r s : Fin 4) : + (qmaFourTensorCross i j p q*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorCross i j r s*qmaFourTensorEncoding n) = + (3:ℂ) • qmaPairMatrix i j (qmaFourCorrelation p r) (qmaFourCorrelation q s) := by + rw [qmaFourTensorCross_column i j hij,qmaFourTensorCross_column i j hij] + simp only [Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.mul_sum, + qmaFourTensorPairColumn_gram i j,Finset.sum_ite_eq',Finset.mem_univ,ite_true,Finset.sum_const] + norm_cast + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffective.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffective.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab185f2fc23627e2830ac92de2b98ce597e42e25 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffective.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorWeighted +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorCompression + +namespace OAI + +/-! Physical counterterms calibrate each edge of the full tensor simulator. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +def qmaFourTensorCoupling (i j : Fin n) (a b : Fin 2) (t : ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + (qmaFourCouplingSize a b t:ℂ) • qmaFourTensorWeighted i j + (qmaFourAxisWeights a true) (qmaFourAxisWeights b (qmaFourCouplingSign t)) + +def qmaFourTensorEffective (i j : Fin n) (a b : Fin 2) (t : ℝ) : + Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ := + (-1/8:ℂ) • ((qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n)) + +theorem qmaFourTensorEffective_tensor (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + qmaFourTensorEffective i j a b t = (-qmaFourCouplingFactor a b t:ℂ) • + qmaPairMatrix i j + ((qmaFourAxisShift a true:ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + (qmaFourAxisScale a:ℂ) • qmaFourAxis a) + ((qmaFourAxisShift b (qmaFourCouplingSign t):ℂ) • (1 : Matrix (Fin 2) (Fin 2) ℂ)+ + ((qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisScale b:ℝ):ℂ) • qmaFourAxis b) := by + rw [qmaFourTensorEffective,qmaFourTensorCoupling,Matrix.smul_mul,Matrix.conjTranspose_smul, + Matrix.smul_mul,Matrix.mul_smul,smul_smul,smul_smul] + rw [qmaFourTensorWeighted_gram i j hij,qmaFourAxisWeights_correlation,qmaFourAxisWeights_correlation] + simp only [qmaFourAxisSign,ite_true,one_mul,Complex.star_def,Complex.conj_ofReal, + smul_smul,qmaFourCouplingFactor] + push_cast + congr 1 + ring + +theorem qmaFourTensorEffective_expansion (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + qmaFourTensorEffective i j a b t = + (-qmaFourCouplingFactor a b t*qmaFourAxisShift a true* + qmaFourAxisShift b (qmaFourCouplingSign t):ℂ) • (1 : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ)+ + (-qmaFourCouplingFactor a b t*qmaFourAxisScale a* + qmaFourAxisShift b (qmaFourCouplingSign t):ℂ) • qmaSiteMatrix i (qmaFourAxis a)+ + (-qmaFourCouplingFactor a b t*qmaFourAxisShift a true* + (qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisScale b):ℂ) • qmaSiteMatrix j (qmaFourAxis b)+ + (t:ℂ) • qmaPairMatrix i j (qmaFourAxis a) (qmaFourAxis b) := by + have hc : (-qmaFourCouplingFactor a b t*qmaFourAxisScale a* + (qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisScale b):ℂ) = t := by + have h := qmaFourCouplingSign_calibration a b t + have he : -qmaFourCouplingFactor a b t*qmaFourAxisScale a* + (qmaFourAxisSign (qmaFourCouplingSign t)*qmaFourAxisScale b) = t := by + unfold qmaFourCouplingFactor + nlinarith [h] + exact_mod_cast he + rw [← hc,qmaFourTensorEffective_tensor i j hij] + simp only [qmaPairMatrix_add_left _ _ hij,qmaPairMatrix_add_right _ _ hij, + qmaPairMatrix_smul_left _ _ hij,qmaPairMatrix_smul_right _ _ hij, + qmaPairMatrix_one_right _ _ hij,qmaPairMatrix_one_left _ _ hij,qmaSiteMatrix_one, + smul_add,smul_smul] + push_cast + module + +def qmaFourTensorCounterterm (i j : Fin n) (a b : Fin 2) (t : ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + qmaSiteMatrix i (qmaFourAxisField a (qmaFourCounterA a b t))+ + qmaSiteMatrix j (qmaFourAxisField b (qmaFourCounterB a b t)) + +theorem qmaFourTensorCounterterm_effective (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorCounterterm i j a b t*qmaFourTensorEncoding n+ + qmaFourTensorEffective i j a b t = + (t:ℂ) • qmaPairMatrix i j (qmaFourAxis a) (qmaFourAxis b)+ + (qmaFourEnergyOffset a b t:ℂ) • (1 : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ) := by + rw [qmaFourTensorCounterterm,Matrix.mul_add,Matrix.add_mul, + qmaFourTensor_site_compression,qmaFourTensor_site_compression, + qmaFourAxisField_compression,qmaFourAxisField_compression,qmaFourTensorEffective_expansion i j hij] + simp only [qmaSiteMatrix_add,qmaSiteMatrix_smul,qmaSiteMatrix_one, + qmaFourEnergyOffset,qmaFourCounterA,qmaFourCounterB] + push_cast + module + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffectiveError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffectiveError.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7859931cbb251f058a90d1d2ba41b3040c03180 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorEffectiveError.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorError + +namespace OAI + +/-! The actual effective form approximates the calibrated tensor matrix. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} + +def qmaFourTensorPerturbation (r : ℝ) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16) := + r • (qmaMatrixOperator V).restrictScalars ℝ+(qmaMatrixOperator C).restrictScalars ℝ + +def qmaFourTensorEffectiveMatrix (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) := + (qmaFourTensorEncoding n).conjTranspose*C*qmaFourTensorEncoding n- + (1/8:ℂ) • ((V*qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n)) + +theorem qmaFourTensor_restrict_column (V : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaFourTensorRestriction n (qmaMatrixOperator V (qmaFourTensorInclusion n p)) = 0 := by + change qmaMatrixOperator _ (qmaMatrixOperator _ (qmaMatrixOperator _ p)) = 0 + rw [← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul, + ← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul,Matrix.mul_assoc,hV] + ext s + simp only [qmaMatrixOperator_apply,Matrix.zero_apply,zero_mul,Finset.sum_const_zero,PiLp.zero_apply] + +theorem qmaFourTensorOff_split (r : ℝ) (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaFourTensorOff (qmaFourTensorPerturbation r V C) p = + r • qmaMatrixOperator V (qmaFourTensorInclusion n p)+ + qmaFourTensorHigh n (qmaMatrixOperator C (qmaFourTensorInclusion n p)) := by + change qmaFourTensorHigh n (r • qmaMatrixOperator V (qmaFourTensorInclusion n p)+ + qmaMatrixOperator C (qmaFourTensorInclusion n p)) = _ + rw [map_add,map_smul,qmaFourTensorHigh_fixed _ (qmaFourTensor_restrict_column V hV p)] + +theorem qmaQuadratic_operator_gram {σ τ : Type*} [Fintype σ] [Fintype τ] [DecidableEq τ] + (W : Matrix σ τ ℂ) (p : EuclideanSpace ℂ τ) : + qmaQuadratic (W.conjTranspose*W) (fun i => p i) = ‖qmaMatrixOperator W p‖^2 := by + rw [qmaQuadratic_operator,qmaMatrixOperator_mul,ContinuousLinearMap.comp_apply, + ← qmaMatrixOperator_real_adjoint,real_inner_self_eq_norm_sq] + +theorem qmaFourTensorEffectiveMatrix_form + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaQuadratic (qmaFourTensorEffectiveMatrix V C) (fun i => p i) = + ⟪qmaFourTensorInclusion n p,qmaMatrixOperator C (qmaFourTensorInclusion n p)⟫_ℝ- + (1/8)*‖qmaMatrixOperator V (qmaFourTensorInclusion n p)‖^2 := by + rw [qmaFourTensorEffectiveMatrix,qmaQuadratic_sub, + show (1/8:ℂ) = ((1/8:ℝ):ℂ) from by norm_num,qmaQuadratic_smul, + qmaQuadratic_sandwich,qmaQuadratic_operator_gram,qmaMatrixOperator_mul,ContinuousLinearMap.comp_apply] + rfl + +theorem qmaFourTensorLow_form (r : ℝ) (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + ⟪p,qmaFourTensorLow (qmaFourTensorPerturbation r V C) p⟫_ℝ = + ⟪qmaFourTensorInclusion n p,qmaMatrixOperator C (qmaFourTensorInclusion n p)⟫_ℝ := by + change ⟪p,qmaFourTensorRestriction n (qmaFourTensorPerturbation r V C (qmaFourTensorInclusion n p))⟫_ℝ = _ + rw [← qmaFourTensor_inclusion_adjoint] + change ⟪qmaFourTensorInclusion n p,r • qmaMatrixOperator V (qmaFourTensorInclusion n p)+ + qmaMatrixOperator C (qmaFourTensorInclusion n p)⟫_ℝ = _ + rw [inner_add_right,inner_smul_right,qmaFourTensor_inclusion_adjoint, + qmaFourTensor_restrict_column V hV p,inner_zero_right,mul_zero,zero_add] + +theorem qmaFourTensor_column_norm (M : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + {b : ℝ} (hb : ‖spinMatrixOperator M‖ ≤ b) (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + ‖qmaMatrixOperator M (qmaFourTensorInclusion n p)‖ ≤ b*‖p‖ := by + apply ((qmaMatrixOperator M).le_opNorm _).trans + rw [qmaMatrixOperator_square,qmaFourTensor_inclusion_norm] + exact mul_le_mul_of_nonneg_right hb (norm_nonneg p) + +theorem qmaFourTensorEffective_error (r : ℝ) (hr : 0 < r) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (hH : qmaFourTensorPenalty n*(V*qmaFourTensorEncoding n) = (8:ℂ) • (V*qmaFourTensorEncoding n)) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hAT : ∀ x, qmaFourTensorPadded n r (T x) = x) (hTA : ∀ x, T (qmaFourTensorPadded n r x) = x) + (hTn : ‖T‖ ≤ 1/(4*r^2)) {v c : ℝ} (hv : 0 ≤ v) (hc : 0 ≤ c) + (hVn : ‖spinMatrixOperator V‖ ≤ v) (hCn : ‖spinMatrixOperator C‖ ≤ c) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + |Perturbation.effectiveForm (qmaFourTensorLow (qmaFourTensorPerturbation r V C)) T + (qmaFourTensorOff (qmaFourTensorPerturbation r V C)) p- + qmaQuadratic (qmaFourTensorEffectiveMatrix V C) (fun i => p i)| ≤ + (v*c/(4*r)+c^2/(4*r^2))*‖p‖^2 := by + let w := qmaMatrixOperator V (qmaFourTensorInclusion n p) + let z := qmaFourTensorHigh n (qmaMatrixOperator C (qmaFourTensorInclusion n p)) + have hw : T w = (8*r^2)⁻¹ • w := by + have h := qmaFourTensorInverse_column hr T hTA (V*qmaFourTensorEncoding n) hV hH p + simpa only [qmaMatrixOperator_mul,ContinuousLinearMap.comp_apply,w,qmaFourTensorInclusion, + ContinuousLinearMap.coe_restrictScalars'] using h + have hwn : ‖w‖ ≤ v*‖p‖ := qmaFourTensor_column_norm V hVn p + have hzn : ‖z‖ ≤ c*‖p‖ := by + apply ((qmaFourTensorHigh n).le_opNorm _).trans + exact (mul_le_mul (qmaFourTensorHigh_norm n) (qmaFourTensor_column_norm C hCn p) + (norm_nonneg _) zero_le_one).trans_eq (one_mul _) + have h := qmaSecondOrder_column_error T hr hv hc (norm_nonneg p) + (qmaInverse_symmetric _ T hAT (qmaFourTensorPadded_symmetric n r)) hTn w z hw hwn hzn + rw [Perturbation.effectiveForm,Perturbation.inverseForm,qmaFourTensorLow_form r V C hV p, + qmaFourTensorEffectiveMatrix_form,qmaFourTensorOff_split r V C hV p] + convert h using 1 + rw [show (⟪qmaFourTensorInclusion n p,qmaMatrixOperator C (qmaFourTensorInclusion n p)⟫_ℝ- + ⟪r • w+z,T (r • w+z)⟫_ℝ)- + (⟪qmaFourTensorInclusion n p,qmaMatrixOperator C (qmaFourTensorInclusion n p)⟫_ℝ-(1/8)*‖w‖^2) = + -(⟪r • w+z,T (r • w+z)⟫_ℝ-(1/8)*‖w‖^2) by ring,abs_neg] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorError.lean new file mode 100644 index 0000000000000000000000000000000000000000..02b898708b8491f30b53e860ae256ff1efe9d337 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorError.lean @@ -0,0 +1,85 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorForms + +namespace OAI + +/-! The counterterm's off-diagonal contribution to the second-order energy. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped InnerProductSpace + +variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +theorem qmaInverse_symmetric (A T : H →L[ℝ] H) + (hAT : ∀ x, A (T x) = x) + (hA : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ) (x y : H) : + ⟪x,T y⟫_ℝ = ⟪T x,y⟫_ℝ := by + calc + _ = ⟪A (T x),T y⟫_ℝ := by rw [hAT] + _ = ⟪T x,A (T y)⟫_ℝ := (hA _ _).symm + _ = _ := by rw [hAT] + +theorem qmaSecondOrder_column_identity (T : H →L[ℝ] H) {r : ℝ} (hr : r ≠ 0) + (hT : ∀ x y, ⟪x,T y⟫_ℝ = ⟪T x,y⟫_ℝ) (w z : H) + (hw : T w = (8*r^2)⁻¹ • w) : + ⟪r • w+z,T (r • w+z)⟫_ℝ-(1/8)*‖w‖^2 = + (1/(4*r))*⟪w,z⟫_ℝ+⟪z,T z⟫_ℝ := by + have hwz : ⟪w,T z⟫_ℝ = (8*r^2)⁻¹*⟪w,z⟫_ℝ := by + rw [hT,hw,inner_smul_left] + simp only [starRingEnd_apply,star_trivial] + simp only [map_add,map_smul,inner_add_left,inner_add_right,inner_smul_left,inner_smul_right, + starRingEnd_apply,star_trivial,hwz,hw,real_inner_self_eq_norm_sq] + simp only [real_inner_comm z w] + field_simp + ring + +theorem qmaSecondOrder_column_error (T : H →L[ℝ] H) {r v c l : ℝ} (hr : 0 < r) + (hv : 0 ≤ v) (_hc : 0 ≤ c) (hl : 0 ≤ l) + (hT : ∀ x y, ⟪x,T y⟫_ℝ = ⟪T x,y⟫_ℝ) (hTn : ‖T‖ ≤ 1/(4*r^2)) + (w z : H) (hw : T w = (8*r^2)⁻¹ • w) (hwn : ‖w‖ ≤ v*l) (hzn : ‖z‖ ≤ c*l) : + |⟪r • w+z,T (r • w+z)⟫_ℝ-(1/8)*‖w‖^2| ≤ + (v*c/(4*r)+c^2/(4*r^2))*l^2 := by + have hwz : |⟪w,z⟫_ℝ| ≤ v*c*l^2 := by + calc + _ ≤ ‖w‖*‖z‖ := abs_real_inner_le_norm _ _ + _ ≤ (v*l)*(c*l) := mul_le_mul hwn hzn (norm_nonneg _) (mul_nonneg hv hl) + _ = _ := by ring + have hz2 : ‖z‖^2 ≤ c^2*l^2 := by + simpa only [mul_pow] using pow_le_pow_left₀ (norm_nonneg z) hzn 2 + have hzt : |⟪z,T z⟫_ℝ| ≤ c^2/(4*r^2)*l^2 := by + calc + _ ≤ ‖z‖*‖T z‖ := abs_real_inner_le_norm _ _ + _ ≤ ‖z‖*(‖T‖*‖z‖) := mul_le_mul_of_nonneg_left (T.le_opNorm z) (norm_nonneg z) + _ = ‖T‖*‖z‖^2 := by ring + _ ≤ (1/(4*r^2))*(c^2*l^2) := mul_le_mul hTn hz2 (sq_nonneg _) (by positivity) + _ = _ := by ring + rw [qmaSecondOrder_column_identity T (ne_of_gt hr) hT w z hw] + calc + _ ≤ |(1/(4*r))*⟪w,z⟫_ℝ|+|⟪z,T z⟫_ℝ| := abs_add_le _ _ + _ = (1/(4*r))*|⟪w,z⟫_ℝ|+|⟪z,T z⟫_ℝ| := by + rw [abs_mul,abs_of_nonneg (by positivity : 0 ≤ 1/(4*r))] + _ ≤ (1/(4*r))*(v*c*l^2)+c^2/(4*r^2)*l^2 := + add_le_add (mul_le_mul_of_nonneg_left hwz (by positivity)) hzt + _ = _ := by ring + +theorem qmaSecondOrder_inverse_column_bound (T : H →L[ℝ] H) {r v c l : ℝ} (hr : 0 < r) + (hTn : ‖T‖ ≤ 1/(4*r^2)) (w z : H) (hw : T w = (8*r^2)⁻¹ • w) + (hwn : ‖w‖ ≤ v*l) (hzn : ‖z‖ ≤ c*l) : + ‖T (r • w+z)‖ ≤ (v/(8*r)+c/(4*r^2))*l := by + rw [map_add,map_smul,hw,smul_smul] + have hs : r*(8*r^2)⁻¹ = 1/(8*r) := by field_simp + rw [hs] + calc + _ ≤ ‖(1/(8*r)) • w‖+‖T z‖ := norm_add_le _ _ + _ = (1/(8*r))*‖w‖+‖T z‖ := by rw [norm_smul,Real.norm_eq_abs,abs_of_pos (by positivity)] + _ ≤ (1/(8*r))*(v*l)+(1/(4*r^2))*(c*l) := by + apply add_le_add (mul_le_mul_of_nonneg_left hwn (by positivity)) + exact (T.le_opNorm z).trans + (mul_le_mul hTn hzn (norm_nonneg _) (by positivity)) + _ = _ := by ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamily.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..d36f8139ee556979f7be1735dbcafe059b5f4765 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamily.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorEffective + +namespace OAI + +/-! Exact effective Hamiltonian of a family of distinct logical edges. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +variable {σ τ κ : Type*} [Fintype σ] [Fintype τ] [Fintype κ] [DecidableEq κ] + +omit [Fintype τ] [DecidableEq κ] in +theorem qmaOrthogonalColumns_sum_gram (W : κ → Matrix σ τ ℂ) + (hW : ∀ e f, e ≠ f → (W e).conjTranspose*W f = 0) : + (∑ e, W e).conjTranspose*(∑ e, W e) = ∑ e, (W e).conjTranspose*W e := by + simp only [Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.mul_sum] + apply Finset.sum_congr rfl + intro e _ + apply Finset.sum_eq_single e + · intro f _ hfe + exact hW f e hfe + · intro he + exact (he (Finset.mem_univ e)).elim + +variable {n : ℕ} + +theorem qmaFourTensorCoupling_distinct (i j k l : Fin n) (hij : i ≠ j) (hkl : k ≠ l) + (hne : ({i,j} : Finset (Fin n)) ≠ {k,l}) (a b c d : Fin 2) (t u : ℝ) : + (qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorCoupling k l c d u*qmaFourTensorEncoding n) = 0 := by + simp only [qmaFourTensorCoupling,Matrix.smul_mul,Matrix.conjTranspose_smul, + Matrix.mul_smul,qmaFourTensorWeighted_distinct i j k l hij hkl hne,smul_zero] + +def qmaFourTensorFamilyCoupling (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + ∑ e, qmaFourTensorCoupling (left e) (right e) (a e) (b e) (t e) + +def qmaFourTensorFamilyCounterterm (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + ∑ e, qmaFourTensorCounterterm (left e) (right e) (a e) (b e) (t e) + +omit [DecidableEq κ] in +theorem qmaFourTensorFamily_effective (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorFamilyCounterterm left right a b t* + qmaFourTensorEncoding n + + (-1/8:ℂ) • ((qmaFourTensorFamilyCoupling left right a b t*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorFamilyCoupling left right a b t*qmaFourTensorEncoding n)) = + (∑ e, (t e:ℂ) • qmaPairMatrix (left e) (right e) (qmaFourAxis (a e)) (qmaFourAxis (b e)))+ + ((∑ e, qmaFourEnergyOffset (a e) (b e) (t e):ℝ):ℂ) • + (1 : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ) := by + have hW (e f : κ) (hef : e ≠ f) : + (qmaFourTensorCoupling (left e) (right e) (a e) (b e) (t e)*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorCoupling (left f) (right f) (a f) (b f) (t f)*qmaFourTensorEncoding n) = 0 := + qmaFourTensorCoupling_distinct _ _ _ _ (hneq e) (hneq f) (hdist e f hef) _ _ _ _ _ _ + simp only [qmaFourTensorFamilyCoupling,Matrix.sum_mul] + rw [qmaOrthogonalColumns_sum_gram _ hW] + simp only [qmaFourTensorFamilyCounterterm,Matrix.mul_sum,Matrix.sum_mul,Finset.smul_sum] + rw [← Finset.sum_add_distrib] + have he (e : κ) := qmaFourTensorCounterterm_effective (left e) (right e) (hneq e) (a e) (b e) (t e) + simp only [qmaFourTensorEffective] at he + simp only [he,Finset.sum_add_distrib,← Finset.sum_smul,Complex.ofReal_sum] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9a99b39f9d93af803c542017f6cd3e8797b7b5e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyAccuracy.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorOperatorBounds + +namespace OAI + +/-! A polynomial-precision simulator for an arbitrary family of distinct X/Z pairs. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} {κ : Type*} [Fintype κ] + +def qmaFourTensorFamilyTarget (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) := + (∑ e, (t e:ℂ) • qmaPairMatrix (left e) (right e) (qmaFourAxis (a e)) (qmaFourAxis (b e)))+ + ((∑ e, qmaFourEnergyOffset (a e) (b e) (t e):ℝ):ℂ) • + (1 : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ) + +def qmaFourTensorFamilyBudget (t : κ → ℝ) : ℝ := + let s := ∑ e, (1+|t e|) + 1+7056*s+1228800*s+(7056*s)^2 + +theorem qmaFourTensorFamily_effective_eq (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) : + qmaFourTensorEffectiveMatrix (qmaFourTensorFamilyCoupling left right a b t) + (qmaFourTensorFamilyCounterterm left right a b t) = qmaFourTensorFamilyTarget left right a b t := by + have h := qmaFourTensorFamily_effective left right a b t hneq hdist + change _ = qmaFourTensorFamilyTarget left right a b t at h + rw [qmaFourTensorEffectiveMatrix] + rw [← h] + module + +theorem qmaFourTensorFamily_budget_bounds (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) : + 1 ≤ qmaFourTensorFamilyBudget t ∧ + ‖spinMatrixOperator (qmaFourTensorFamilyCoupling left right a b t)‖ ≤ qmaFourTensorFamilyBudget t ∧ + ‖spinMatrixOperator (qmaFourTensorFamilyCounterterm left right a b t)‖ ≤ qmaFourTensorFamilyBudget t ∧ + ‖spinMatrixOperator (qmaFourTensorEffectiveMatrix (qmaFourTensorFamilyCoupling left right a b t) + (qmaFourTensorFamilyCounterterm left right a b t))‖ ≤ qmaFourTensorFamilyBudget t := by + let V := qmaFourTensorFamilyCoupling left right a b t + let C := qmaFourTensorFamilyCounterterm left right a b t + let s := ∑ e, (1+|t e|) + have hs : 0 ≤ s := Finset.sum_nonneg (fun _ _ => by positivity) + have hv : ‖spinMatrixOperator V‖ ≤ 7056*s := qmaFourTensorFamily_norm left right a b t + have hcoeff : (∑ e, |t e|) ≤ s := Finset.sum_le_sum (fun _ _ => by linarith) + have hc : ‖spinMatrixOperator C‖ ≤ 1228800*s := + (qmaFourTensorFamilyCounterterm_bound left right a b t).trans + (mul_le_mul_of_nonneg_left hcoeff (by norm_num)) + have hb : qmaFourTensorNormBudget V C ≤ qmaFourTensorFamilyBudget t := by + have hv2 := pow_le_pow_left₀ (norm_nonneg (spinMatrixOperator V)) hv 2 + change 1+‖spinMatrixOperator V‖+‖spinMatrixOperator C‖+‖spinMatrixOperator V‖^2 ≤ + 1+7056*s+1228800*s+(7056*s)^2 + linarith + have h := qmaFourTensorNormBudget_bounds V C + exact ⟨h.1.trans hb,h.2.1.trans hb,h.2.2.1.trans hb,h.2.2.2.trans hb⟩ + +theorem qmaFourTensorFamily_accuracy (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix (9*(qmaFourTensorFamilyBudget t)^3*N) + (((9*(qmaFourTensorFamilyBudget t)^3*N:ℝ):ℂ) • qmaFourTensorFamilyCoupling left right a b t+ + qmaFourTensorFamilyCounterterm left right a b t))- + MediatorGraph.normalizedBottom (qmaFourTensorFamilyTarget left right a b t)| ≤ 1/(N:ℝ) := by + have hb := qmaFourTensorFamily_budget_bounds left right a b t + have h := qmaFourTensor_polynomial_accuracy (qmaFourTensorFamilyBudget t) hb.1 + (qmaFourTensorFamilyCoupling left right a b t) (qmaFourTensorFamilyCounterterm left right a b t) + (qmaFourTensorFamily_star left right a b t hneq) + (qmaFourTensorFamilyCounterterm_star left right a b t) + (qmaFourTensorFamily_orthogonal left right a b t hneq) + (qmaFourTensorFamily_excitation left right a b t hneq) hb.2.1 hb.2.2.1 hb.2.2.2 u hu N hN + rwa [qmaFourTensorFamily_effective_eq left right a b t hneq hdist] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..684ae51d0707c0ae00d86fd1b111dbe02d65ad95 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFamilyBounds.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorNorm +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFamily + +namespace OAI + +/-! Bounds and excitation identities for the whole physical edge family. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ : Type*} [Fintype κ] + +theorem qmaFourTensorCoupling_orthogonal (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + (qmaFourTensorEncoding n).conjTranspose*(qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n) = 0 := by + simp only [qmaFourTensorCoupling,Matrix.smul_mul,Matrix.mul_smul, + qmaFourTensorWeighted_orthogonal i j hij,smul_zero] + +theorem qmaFourTensorCoupling_excitation (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + qmaFourTensorPenalty n*(qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n) = + (8:ℂ) • (qmaFourTensorCoupling i j a b t*qmaFourTensorEncoding n) := by + simp only [qmaFourTensorCoupling,Matrix.smul_mul,Matrix.mul_smul, + qmaFourTensorWeighted_excitation i j hij,smul_comm (8:ℂ)] + +theorem qmaFourTensorFamily_orthogonal (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) : + (qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorFamilyCoupling left right a b t*qmaFourTensorEncoding n) = 0 := by + simp only [qmaFourTensorFamilyCoupling,Matrix.sum_mul,Matrix.mul_sum, + qmaFourTensorCoupling_orthogonal _ _ (hneq _),Finset.sum_const_zero] + +theorem qmaFourTensorFamily_excitation (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) : + qmaFourTensorPenalty n*(qmaFourTensorFamilyCoupling left right a b t*qmaFourTensorEncoding n) = + (8:ℂ) • (qmaFourTensorFamilyCoupling left right a b t*qmaFourTensorEncoding n) := by + simp only [qmaFourTensorFamilyCoupling,Matrix.sum_mul,Matrix.mul_sum, + qmaFourTensorCoupling_excitation _ _ (hneq _),Finset.smul_sum] + +theorem qmaFourTensorFamily_norm (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) : + ‖spinMatrixOperator (qmaFourTensorFamilyCoupling left right a b t)‖ ≤ + 7056*(∑ e, (1+|t e|)) := by + rw [qmaFourTensorFamilyCoupling,spinMatrixOperator_sum,Finset.mul_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun e _ => qmaFourTensorCoupling_norm _ _ _ _ _)) + +theorem qmaSiteMatrix_commute (i j : Fin n) (hij : i ≠ j) (A B : Matrix (Fin 16) (Fin 16) ℂ) : + qmaSiteMatrix i A*qmaSiteMatrix j B = qmaSiteMatrix j B*qmaSiteMatrix i A := by + simp only [qmaSiteMatrix,qmaTensorMatrix_mul] + congr 1 + funext k + by_cases hi : k = i + · subst k + simp only [ite_true,hij,ite_false,Matrix.mul_one,Matrix.one_mul] + · by_cases hj : k = j + · subst k + simp only [ite_true,Ne.symm hij,ite_false,Matrix.mul_one,Matrix.one_mul] + · simp only [hi,hj,ite_false] + +theorem qmaFourTensorCross_star (i j : Fin n) (hij : i ≠ j) (p q : Fin 4) : + (qmaFourTensorCross i j p q).conjTranspose = qmaFourTensorCross i j p q := by + simp only [qmaFourTensorCross,Matrix.conjTranspose_sum,Matrix.conjTranspose_mul, + qmaSiteMatrix_star,qmaFourSpin_star] + apply Finset.sum_congr rfl + intro μ _ + exact qmaSiteMatrix_commute j i (Ne.symm hij) _ _ + +theorem qmaFourTensorCoupling_star (i j : Fin n) (hij : i ≠ j) (a b : Fin 2) (t : ℝ) : + (qmaFourTensorCoupling i j a b t).conjTranspose = qmaFourTensorCoupling i j a b t := by + simp only [qmaFourTensorCoupling,qmaFourTensorWeighted,Matrix.conjTranspose_smul, + Matrix.conjTranspose_sum,Complex.star_def,Complex.conj_ofReal,qmaFourTensorCross_star i j hij] + +theorem qmaFourTensorFamily_star (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) : + (qmaFourTensorFamilyCoupling left right a b t).conjTranspose = + qmaFourTensorFamilyCoupling left right a b t := by + simp only [qmaFourTensorFamilyCoupling,Matrix.conjTranspose_sum, + qmaFourTensorCoupling_star _ _ (hneq _)] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFields.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFields.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fb6911794442b6952ae0e1b3d8000583247fcb1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFields.lean @@ -0,0 +1,123 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFamilyBounds + +namespace OAI + +/-! Internal physical exchange fields retain bounds in every tensor block. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +theorem qmaFourExchange_pauli (p q : Fin 4) (hpq : p ≠ q) : + qmaFourExchange p q = ∑ μ : Fin 3, qmaFourSpin p μ*qmaFourSpin q μ := by + rw [qmaFourExchange_source] + change (sourceHeisenbergMatrix 4 p q).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm = _ + rw [← sourceLocalPauli_sum 4 p q hpq,MediatorGraph.submatrix_sum] + apply Finset.sum_congr rfl + intro μ _ + rw [← Matrix.submatrix_mul_equiv _ _ _ qmaFourBasisEquiv.symm _,qmaFourSpin_source,qmaFourSpin_source] + rfl + +theorem qmaFourSpin_commute (p q : Fin 4) (hpq : p ≠ q) (μ ν : Fin 3) : + qmaFourSpin p μ*qmaFourSpin q ν = qmaFourSpin q ν*qmaFourSpin p μ := by + simp only [qmaFourSpin_source] + change (sourceLocalPauli 4 p μ).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm * + (sourceLocalPauli 4 q ν).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm = + (sourceLocalPauli 4 q ν).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm * + (sourceLocalPauli 4 p μ).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm + rw [Matrix.submatrix_mul_equiv _ _ _ qmaFourBasisEquiv.symm _, + Matrix.submatrix_mul_equiv _ _ _ qmaFourBasisEquiv.symm _,sourceLocalPauli_commute 4 p q hpq] + +theorem qmaFourExchange_star (p q : Fin 4) (hpq : p ≠ q) : + (qmaFourExchange p q).conjTranspose = qmaFourExchange p q := by + simp only [qmaFourExchange_pauli p q hpq,Matrix.conjTranspose_sum,Matrix.conjTranspose_mul, + qmaFourSpin_star,qmaFourSpin_commute q p (Ne.symm hpq)] + +theorem qmaFourTensorExchange_norm (i : Fin n) (p q : Fin 4) (hpq : p ≠ q) : + ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourExchange p q))‖ ≤ 3 := by + rw [qmaFourExchange_pauli p q hpq,qmaSiteMatrix_sum,spinMatrixOperator_sum] + calc + _ ≤ ∑ μ : Fin 3, ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourSpin p μ*qmaFourSpin q μ))‖ := norm_sum_le _ _ + _ ≤ ∑ _ : Fin 3, (1:ℝ) := by + apply Finset.sum_le_sum + intro μ _ + rw [← qmaSiteMatrix_mul,spinMatrixOperator_mul] + exact (ContinuousLinearMap.opNorm_comp_le _ _).trans + (by simpa using (mul_le_mul (qmaFourTensorSpin_norm i p μ) (qmaFourTensorSpin_norm i q μ) + (norm_nonneg _) zero_le_one)) + _ = 3 := by norm_num + +theorem qmaSiteMatrix_neg (i : Fin n) (A : Matrix (Fin 16) (Fin 16) ℂ) : + qmaSiteMatrix i (-A) = -qmaSiteMatrix i A := by + rw [← neg_one_smul ℂ A,qmaSiteMatrix_smul,neg_one_smul] + +theorem qmaSiteMatrix_sub (i : Fin n) (A B : Matrix (Fin 16) (Fin 16) ℂ) : + qmaSiteMatrix i (A-B) = qmaSiteMatrix i A-qmaSiteMatrix i B := by + simp only [sub_eq_add_neg,qmaSiteMatrix_add,qmaSiteMatrix_neg] + +theorem qmaFourField_star (x z : ℝ) : (qmaFourField x z).conjTranspose = qmaFourField x z := by + simp only [qmaFourField,Matrix.conjTranspose_sub,Matrix.conjTranspose_smul, + Complex.star_def,Complex.conj_ofReal,qmaFourExchange_star 0 3 (by decide), + qmaFourExchange_star 0 2 (by decide),qmaFourExchange_star 0 1 (by decide)] + +theorem qmaFourTensorField_norm (i : Fin n) (x z : ℝ) : + ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourField x z))‖ ≤ 6*(|x|+|z|) := by + have hs : 1 ≤ Real.sqrt 3 := by + have h0 := Real.sqrt_nonneg 3 + have h2 := Real.sq_sqrt (show (0:ℝ) ≤ 3 by norm_num) + nlinarith + have hx : |x/(2*Real.sqrt 3)| ≤ |x| := by + rw [abs_div,abs_of_pos (by positivity : 0 < 2*Real.sqrt 3)] + apply (div_le_iff₀ (by positivity : 0 < 2*Real.sqrt 3)).mpr + nlinarith [abs_nonneg x] + have hz : |z/2| ≤ |z| := by rw [abs_div]; norm_num + rw [qmaFourField,qmaSiteMatrix_sub,qmaSiteMatrix_smul,qmaSiteMatrix_smul, + qmaSiteMatrix_sub,spinMatrixOperator_sub,spinMatrixOperator_smul,spinMatrixOperator_smul] + have hdiff : ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourExchange 0 3)- + qmaSiteMatrix i (qmaFourExchange 0 2))‖ ≤ 6 := by + rw [spinMatrixOperator_sub] + exact (norm_sub_le _ _).trans ((add_le_add (qmaFourTensorExchange_norm i 0 3 (by decide)) + (qmaFourTensorExchange_norm i 0 2 (by decide))).trans_eq (by norm_num)) + have hlast := qmaFourTensorExchange_norm i 0 1 (by decide) + calc + _ ≤ ‖((x/(2*Real.sqrt 3):ℝ):ℂ) • spinMatrixOperator + (qmaSiteMatrix i (qmaFourExchange 0 3)-qmaSiteMatrix i (qmaFourExchange 0 2))‖+ + ‖((z/2:ℝ):ℂ) • spinMatrixOperator (qmaSiteMatrix i (qmaFourExchange 0 1))‖ := norm_sub_le _ _ + _ = |x/(2*Real.sqrt 3)| * ‖spinMatrixOperator + (qmaSiteMatrix i (qmaFourExchange 0 3)-qmaSiteMatrix i (qmaFourExchange 0 2))‖+ + |z/2| * ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourExchange 0 1))‖ := by + simp only [norm_smul,Complex.norm_real,Real.norm_eq_abs] + _ ≤ |x| * 6+|z| * 3 := add_le_add (mul_le_mul hx hdiff (norm_nonneg _) (abs_nonneg x)) + (mul_le_mul hz hlast (norm_nonneg _) (abs_nonneg z)) + _ ≤ _ := by nlinarith [abs_nonneg z] + +theorem qmaFourAxisField_star (a : Fin 2) (t : ℝ) : + (qmaFourAxisField a t).conjTranspose = qmaFourAxisField a t := by + unfold qmaFourAxisField + split_ifs <;> exact qmaFourField_star _ _ + +theorem qmaFourTensorAxisField_norm (i : Fin n) (a : Fin 2) (t : ℝ) : + ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourAxisField a t))‖ ≤ 6*|t| := by + unfold qmaFourAxisField + split_ifs + · simpa only [abs_zero,add_zero] using qmaFourTensorField_norm i t 0 + · simpa only [abs_zero,zero_add] using qmaFourTensorField_norm i 0 t + +theorem qmaFourTensorCounterterm_star (i j : Fin n) (a b : Fin 2) (t : ℝ) : + (qmaFourTensorCounterterm i j a b t).conjTranspose = qmaFourTensorCounterterm i j a b t := by + simp only [qmaFourTensorCounterterm,Matrix.conjTranspose_add,qmaSiteMatrix_star,qmaFourAxisField_star] + +theorem qmaFourTensorCounterterm_norm (i j : Fin n) (a b : Fin 2) (t : ℝ) : + ‖spinMatrixOperator (qmaFourTensorCounterterm i j a b t)‖ ≤ + 6*(|qmaFourCounterA a b t|+|qmaFourCounterB a b t|) := by + rw [qmaFourTensorCounterterm,spinMatrixOperator_add] + exact (norm_add_le _ _).trans ((add_le_add (qmaFourTensorAxisField_norm i a _) + (qmaFourTensorAxisField_norm j b _)).trans_eq (by ring)) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorForms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorForms.lean new file mode 100644 index 0000000000000000000000000000000000000000..80a3244d2a5f9a55cfa86a4560b773244b581def --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorForms.lean @@ -0,0 +1,134 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorInverse + +namespace OAI + +/-! The full physical quadratic form in its actual encoded and orthogonal coordinates. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} + +theorem qmaFourTensor_inclusion_norm (n : ℕ) (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + ‖qmaFourTensorInclusion n p‖ = ‖p‖ := + Perturbation.orthogonalInclusion_norm _ _ (qmaFourTensor_restrict_include n) + (qmaFourTensor_inclusion_adjoint n) p + +theorem qmaFourTensor_norm_decomposition (n : ℕ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + ‖qmaFourTensorRestriction n x‖^2+‖qmaFourTensorHigh n x‖^2 = ‖x‖^2 := by + rw [← qmaFourTensor_highPart] + exact Perturbation.orthogonalParts_norm _ _ (qmaFourTensor_restrict_include n) + (qmaFourTensor_inclusion_adjoint n) x + +theorem qmaFourTensorHigh_norm (n : ℕ) : ‖qmaFourTensorHigh n‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ zero_le_one + intro x + have h := qmaFourTensor_norm_decomposition n x + have h0 := norm_nonneg (qmaFourTensorHigh n x) + have h1 := norm_nonneg x + rw [one_mul] + nlinarith [sq_nonneg ‖qmaFourTensorRestriction n x‖] + +theorem qmaFourTensorHigh_fixed (x : EuclideanSpace ℂ (Fin n → Fin 16)) + (hx : qmaFourTensorRestriction n x = 0) : qmaFourTensorHigh n x = x := by + rw [← qmaFourTensor_highPart] + simp only [Perturbation.orthogonalHighPart,hx,map_zero,sub_zero] + +theorem qmaFourTensorHigh_symmetric (x y : EuclideanSpace ℂ (Fin n → Fin 16)) : + ⟪x,qmaFourTensorHigh n y⟫_ℝ = ⟪qmaFourTensorHigh n x,y⟫_ℝ := by + apply qmaMatrixOperator_real_symmetric + simp only [Matrix.conjTranspose_sub,Matrix.conjTranspose_one,qmaFourTensor_projection_star] + +theorem qmaFourTensor_penalty_low (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaMatrixOperator (qmaFourTensorPenalty n) (qmaFourTensorInclusion n p) = 0 := by + change qmaMatrixOperator _ (qmaMatrixOperator _ p) = 0 + rw [← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul,qmaFourTensorPenalty_encoding] + ext s + simp only [qmaMatrixOperator_apply,Matrix.zero_apply,zero_mul,Finset.sum_const_zero,PiLp.zero_apply] + +theorem qmaFourTensor_padded_high (r : ℝ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) + (hx : qmaFourTensorRestriction n x = 0) : + qmaFourTensorPadded n r x = r^2 • qmaMatrixOperator (qmaFourTensorPenalty n) x := by + have hp : qmaMatrixOperator (qmaFourTensorProjection n) x = 0 := by + rw [← qmaFourTensorEncoding_projector,qmaMatrixOperator_mul,ContinuousLinearMap.comp_apply] + change qmaFourTensorInclusion n (qmaFourTensorRestriction n x) = 0 + rw [hx,map_zero] + change r^2 • qmaMatrixOperator (_+_) x = _ + rw [qmaMatrixOperator_add,_root_.add_apply,qmaMatrixOperator_smul, + _root_.smul_apply,hp,smul_zero,add_zero] + +def qmaFourTensorPhysical (r : ℝ) + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) := + r^2 • (qmaMatrixOperator (qmaFourTensorPenalty n)).restrictScalars ℝ+K + +def qmaFourTensorLow + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) := + (qmaFourTensorRestriction n).comp (K.comp (qmaFourTensorInclusion n)) + +def qmaFourTensorOff + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) := + (qmaFourTensorHigh n).comp (K.comp (qmaFourTensorInclusion n)) + +def qmaFourTensorHighPerturbation + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) := + (qmaFourTensorHigh n).comp (K.comp (qmaFourTensorHigh n)) + +theorem qmaFourTensorPhysical_symmetric (r : ℝ) + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hK : ∀ x y, ⟪x,K y⟫_ℝ = ⟪K x,y⟫_ℝ) (x y : EuclideanSpace ℂ (Fin n → Fin 16)) : + ⟪x,qmaFourTensorPhysical r K y⟫_ℝ = ⟪qmaFourTensorPhysical r K x,y⟫_ℝ := by + change ⟪x,r^2 • qmaMatrixOperator (qmaFourTensorPenalty n) y+K y⟫_ℝ = + ⟪r^2 • qmaMatrixOperator (qmaFourTensorPenalty n) x+K x,y⟫_ℝ + simp only [inner_add_right,inner_add_left,inner_smul_right,inner_smul_left, + starRingEnd_apply,star_trivial,hK, + qmaMatrixOperator_real_symmetric _ (qmaFourTensor_penalty_star n)] + +theorem qmaFourTensorPhysical_low (r : ℝ) + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaFourTensorPhysical r K (qmaFourTensorInclusion n p) = + qmaFourTensorInclusion n (qmaFourTensorLow K p)+qmaFourTensorOff K p := by + change r^2 • qmaMatrixOperator (qmaFourTensorPenalty n) (qmaFourTensorInclusion n p)+ + K (qmaFourTensorInclusion n p) = _ + rw [qmaFourTensor_penalty_low,smul_zero,zero_add] + symm + have h := Perturbation.orthogonal_assemble (qmaFourTensorInclusion n) + (qmaFourTensorRestriction n) (K (qmaFourTensorInclusion n p)) + rw [qmaFourTensor_highPart] at h + exact h + +theorem qmaFourTensorPhysical_high (r : ℝ) + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (x : EuclideanSpace ℂ (Fin n → Fin 16)) (hx : qmaFourTensorRestriction n x = 0) : + ⟪x,qmaFourTensorPhysical r K x⟫_ℝ = + Perturbation.penaltyForm (qmaFourTensorPadded n r) x+⟪x,qmaFourTensorHighPerturbation K x⟫_ℝ := by + change ⟪x,r^2 • qmaMatrixOperator (qmaFourTensorPenalty n) x+K x⟫_ℝ = _ + rw [inner_add_right,← qmaFourTensor_padded_high r x hx] + congr 1 + change ⟪x,K x⟫_ℝ = ⟪x,qmaFourTensorHigh n (K (qmaFourTensorHigh n x))⟫_ℝ + rw [qmaFourTensorHigh_fixed x hx,qmaFourTensorHigh_symmetric,qmaFourTensorHigh_fixed x hx] + +theorem qmaFourTensorPhysical_energy (r : ℝ) + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hK : ∀ x y, ⟪x,K y⟫_ℝ = ⟪K x,y⟫_ℝ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + ⟪x,qmaFourTensorPhysical r K x⟫_ℝ = + Perturbation.lowBlockEnergy (qmaFourTensorLow K) (qmaFourTensorPadded n r) + (qmaFourTensorHighPerturbation K) (qmaFourTensorOff K) + (qmaFourTensorRestriction n x) (qmaFourTensorHigh n x) := by + rw [← qmaFourTensor_highPart] + apply Perturbation.orthogonalBlock_full_energy + (qmaFourTensorInclusion n) (qmaFourTensorRestriction n) + · exact qmaFourTensor_restrict_include n + · exact qmaFourTensor_inclusion_adjoint n + · exact qmaFourTensorPhysical_symmetric r K hK + · exact qmaFourTensorPhysical_low r K + · intro p + exact qmaFourTensorRestriction_high n _ + · exact qmaFourTensorPhysical_high r K + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFullFamily.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFullFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..93fd5e0f492605cd1d3bffff85c94339054e4b46 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorFullFamily.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorOnsite + +namespace OAI + +/-! Full X/Z families, including scalar and one-site terms, have polynomial simulators. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {κ τ : Type*} [Fintype κ] [Fintype τ] + +def qmaFourTensorFullCounterterm (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) := + qmaFourTensorFamilyCounterterm left right a b t+qmaFourTensorOnsite site axis weight constant + +def qmaFourTensorFullTarget (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) := + qmaFourTensorFamilyTarget left right a b t+ + ((∑ e, (weight e:ℂ) • qmaSiteMatrix (site e) (qmaFourAxis (axis e)))+(constant:ℂ) • 1) + +def qmaFourTensorFullBudget (t : κ → ℝ) (weight : τ → ℝ) (constant : ℝ) : ℝ := + let s := ∑ e, (1+|t e|) + let c := 1228800*s+7*(∑ e, |weight e|)+|constant| + 1+7056*s+c+(7056*s)^2 + +theorem qmaFourTensorFull_effective (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + qmaFourTensorEffectiveMatrix (qmaFourTensorFamilyCoupling left right a b t) + (qmaFourTensorFullCounterterm left right a b t site axis weight constant) = + qmaFourTensorFullTarget left right a b t site axis weight constant := by + rw [qmaFourTensorFullTarget,← qmaFourTensorFamily_effective_eq left right a b t hneq hdist] + simp only [qmaFourTensorEffectiveMatrix,qmaFourTensorFullCounterterm,Matrix.mul_add,Matrix.add_mul] + rw [qmaFourTensorOnsite_compression] + abel + +theorem qmaFourTensorFull_budget (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + qmaFourTensorNormBudget (qmaFourTensorFamilyCoupling left right a b t) + (qmaFourTensorFullCounterterm left right a b t site axis weight constant) ≤ + qmaFourTensorFullBudget t weight constant := by + let s := ∑ e, (1+|t e|) + have hs : 0 ≤ s := Finset.sum_nonneg (fun _ _ => by positivity) + have hcoeff : (∑ e, |t e|) ≤ s := Finset.sum_le_sum (fun _ _ => by linarith) + have hv := qmaFourTensorFamily_norm left right a b t + have hc : ‖spinMatrixOperator (qmaFourTensorFullCounterterm left right a b t site axis weight constant)‖ ≤ + 1228800*s+7*(∑ e, |weight e|)+|constant| := by + rw [qmaFourTensorFullCounterterm,spinMatrixOperator_add] + apply (norm_add_le _ _).trans + have hp := (qmaFourTensorFamilyCounterterm_bound left right a b t).trans + (mul_le_mul_of_nonneg_left hcoeff (by norm_num)) + have hf := qmaFourTensorOnsite_norm site axis weight constant + linarith + have hv2 := pow_le_pow_left₀ (norm_nonneg (spinMatrixOperator (qmaFourTensorFamilyCoupling left right a b t))) hv 2 + change 1+‖spinMatrixOperator (qmaFourTensorFamilyCoupling left right a b t)‖+ + ‖spinMatrixOperator (qmaFourTensorFullCounterterm left right a b t site axis weight constant)‖+ + ‖spinMatrixOperator (qmaFourTensorFamilyCoupling left right a b t)‖^2 ≤ + 1+7056*s+(1228800*s+7*(∑ e, |weight e|)+|constant|)+(7056*s)^2 + linarith + +theorem qmaFourTensorFull_accuracy (left right : κ → Fin n) (a b : κ → Fin 2) (t : κ → ℝ) + (hneq : ∀ e, left e ≠ right e) + (hdist : ∀ e f, e ≠ f → ({left e,right e} : Finset (Fin n)) ≠ {left f,right f}) + (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix + (9*(qmaFourTensorFullBudget t weight constant)^3*N) + (((9*(qmaFourTensorFullBudget t weight constant)^3*N:ℝ):ℂ) • + qmaFourTensorFamilyCoupling left right a b t+ + qmaFourTensorFullCounterterm left right a b t site axis weight constant))- + MediatorGraph.normalizedBottom (qmaFourTensorFullTarget left right a b t site axis weight constant)| ≤ 1/(N:ℝ) := by + let V := qmaFourTensorFamilyCoupling left right a b t + let C := qmaFourTensorFullCounterterm left right a b t site axis weight constant + have hB := qmaFourTensorFull_budget left right a b t site axis weight constant + have hb := qmaFourTensorNormBudget_bounds V C + have hCs : C.conjTranspose = C := by + simp only [C,qmaFourTensorFullCounterterm,Matrix.conjTranspose_add,qmaFourTensorFamilyCounterterm_star, + qmaFourTensorOnsite_star] + have h := qmaFourTensor_polynomial_accuracy (qmaFourTensorFullBudget t weight constant) (hb.1.trans hB) + V C (qmaFourTensorFamily_star left right a b t hneq) hCs + (qmaFourTensorFamily_orthogonal left right a b t hneq) + (qmaFourTensorFamily_excitation left right a b t hneq) + (hb.2.1.trans hB) (hb.2.2.1.trans hB) (hb.2.2.2.trans hB) + (EuclideanSpace.single (fun _ => 0) 1) (by simp [PiLp.norm_single]) N hN + rw [show qmaFourTensorEffectiveMatrix V C = qmaFourTensorFullTarget left right a b t site axis weight constant + from qmaFourTensorFull_effective left right a b t hneq hdist site axis weight constant] at h + exact h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGap.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..f12291496439308cdaa8ff173bc8b429fe6e7532 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGap.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTensorSucc + +namespace OAI + +/-! The actual many-block four-spin penalty has a uniform full-complement gap. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical ComplexOrder + +theorem qmaFourProjection_star : qmaFourProjection.conjTranspose = qmaFourProjection := by + rw [← qmaFourEncoding_projector,Matrix.conjTranspose_mul,Matrix.conjTranspose_conjTranspose] + +theorem qmaFourProjection_square : qmaFourProjection*qmaFourProjection = qmaFourProjection := by + rw [← qmaFourEncoding_projector] + calc + _ = qmaFourEncoding*(qmaFourEncoding.conjTranspose*qmaFourEncoding)* + qmaFourEncoding.conjTranspose := by simp only [Matrix.mul_assoc] + _ = _ := by rw [qmaFourEncoding_gram,Matrix.mul_one] + +def qmaFourTensorEncoding (n : ℕ) : Matrix (Fin n → Fin 16) (Fin n → Fin 2) ℂ := + qmaTensorMatrix (fun _ => qmaFourEncoding) + +def qmaFourTensorProjection (n : ℕ) : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + qmaTensorMatrix (fun _ => qmaFourProjection) + +def qmaFourTensorPenalty (n : ℕ) : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + qmaTensorPenalty n qmaFourPenalty + +theorem qmaFourTensorEncoding_gram (n : ℕ) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorEncoding n = 1 := + qmaTensorMatrix_gram _ (fun _ => qmaFourEncoding_gram) + +theorem qmaFourTensorEncoding_projector (n : ℕ) : + qmaFourTensorEncoding n*(qmaFourTensorEncoding n).conjTranspose = qmaFourTensorProjection n := by + rw [qmaFourTensorEncoding,qmaTensorMatrix_star,qmaTensorMatrix_mul] + simp only [qmaFourEncoding_projector,qmaFourTensorProjection] + +theorem qmaFourTensorComplement_posSemidef (n : ℕ) : + (1-qmaFourTensorProjection n).PosSemidef := + qmaTensorMatrix_complement_posSemidef _ (fun _ => qmaFourProjection_star) + (fun _ => qmaFourProjection_square) + +theorem qmaFourTensorGap_posSemidef (n : ℕ) : + (qmaFourTensorPenalty n-(4:ℂ) • (1-qmaFourTensorProjection n)).PosSemidef := by + induction n with + | zero => + have hP : qmaFourTensorProjection 0 = 1 := by + ext s t + simp [qmaFourTensorProjection,qmaTensorMatrix,Matrix.one_apply,Subsingleton.elim s t] + simpa only [qmaFourTensorPenalty,qmaTensorPenalty,Fin.sum_univ_zero,hP,sub_self,smul_zero,sub_zero] + using (Matrix.PosSemidef.zero : (0 : Matrix (Fin 0 → Fin 16) (Fin 0 → Fin 16) ℂ).PosSemidef) + | succ n ih => + let P := qmaFourTensorProjection n + let H := qmaFourTensorPenalty n + have he : qmaFourTensorPenalty (n+1)-(4:ℂ) • (1-qmaFourTensorProjection (n+1)) = + (qmaFourPenalty ⊗ₖ (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ H- + (4:ℂ) • (1-qmaFourProjection ⊗ₖ P)).submatrix + (qmaTensorSuccEquiv (Fin 16) n) (qmaTensorSuccEquiv (Fin 16) n) := by + rw [qmaFourTensorPenalty,qmaTensorPenalty_succ,qmaFourTensorProjection,qmaTensorMatrix_succ] + simp only [Matrix.submatrix_sub,Matrix.submatrix_smul,Pi.sub_apply,Pi.smul_apply, + Matrix.submatrix_one_equiv] + rfl + have hsplit : qmaFourPenalty ⊗ₖ (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ H-(4:ℂ) • (1-qmaFourProjection ⊗ₖ P) = + (qmaFourPenalty-(4:ℂ) • (1-qmaFourProjection)) ⊗ₖ (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ)+ + (1 : Matrix (Fin 16) (Fin 16) ℂ) ⊗ₖ (H-(4:ℂ) • (1-P))+ + (4:ℂ) • ((1-qmaFourProjection) ⊗ₖ (1-P)) := by + ext s t + rcases s with ⟨s₁,s₂⟩ + rcases t with ⟨t₁,t₂⟩ + by_cases h₁ : s₁ = t₁ <;> by_cases h₂ : s₂ = t₂ <;> + simp [Matrix.kroneckerMap_apply,h₁,h₂,Prod.ext_iff] <;> ring + rw [he,hsplit] + apply Matrix.PosSemidef.submatrix + exact ((qmaFourGap_posSemidef.kronecker Matrix.PosSemidef.one).add + (Matrix.PosSemidef.one.kronecker ih)).add + ((qmaFourComplement_posSemidef.kronecker (qmaFourTensorComplement_posSemidef n)).smul + (by norm_num)) + +theorem qmaFourTensor_complement_gap (n : ℕ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) + (hx : (qmaFourTensorEncoding n).conjTranspose *ᵥ (fun i => x i) = 0) : + 4*‖x‖^2 ≤ qmaQuadratic (qmaFourTensorPenalty n) (fun i => x i) := by + have hp : qmaFourTensorProjection n *ᵥ (fun i => x i) = 0 := by + rw [← qmaFourTensorEncoding_projector,← Matrix.mulVec_mulVec,hx,Matrix.mulVec_zero] + have hzero : qmaQuadratic (qmaFourTensorProjection n) (fun i => x i) = 0 := by + simp [qmaQuadratic,hp] + have hone : qmaQuadratic (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (fun i => x i) = ‖x‖^2 := by + rw [qmaQuadratic_operator,qmaMatrixOperator_square,spinMatrixOperator_one,one_apply_eq_self, + real_inner_self_eq_norm_sq] + have h := (Complex.nonneg_iff.mp + ((qmaFourTensorGap_posSemidef n).dotProduct_mulVec_nonneg (fun i => x i))).1 + change 0 ≤ qmaQuadratic _ (fun i => x i) at h + rw [qmaQuadratic_sub] at h + have hs : qmaQuadratic ((4:ℂ) • (1-qmaFourTensorProjection n)) (fun i => x i) = + 4*qmaQuadratic (1-qmaFourTensorProjection n) (fun i => x i) := by + simpa only [Complex.ofReal_ofNat] using + qmaQuadratic_smul (1-qmaFourTensorProjection n) (4:ℝ) (fun i => x i) + rw [hs,qmaQuadratic_sub,hzero,hone] at h + linarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGround.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGround.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba60b62d05156454523295e9d6c6f8e8d1d196d3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorGround.lean @@ -0,0 +1,127 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorError +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFamilyBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGroundComparison + +namespace OAI + +/-! Full physical ground-energy comparison for the four-spin tensor simulator. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} + +def qmaFourTensorPhysicalMatrix (r : ℝ) (U : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) := + (r^2:ℂ) • qmaFourTensorPenalty n+U + +theorem qmaFourTensorPhysicalMatrix_apply (r : ℝ) + (U : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + qmaMatrixOperator (qmaFourTensorPhysicalMatrix r U) x = + qmaFourTensorPhysical r ((qmaMatrixOperator U).restrictScalars ℝ) x := by + rw [qmaFourTensorPhysicalMatrix,qmaMatrixOperator_add,qmaMatrixOperator_smul,qmaFourTensorPhysical] + ext s + simp only [_root_.add_apply,_root_.smul_apply,PiLp.add_apply,PiLp.smul_apply] + simp only [ContinuousLinearMap.coe_restrictScalars',Complex.real_smul,Complex.ofReal_pow, + smul_eq_mul] + +theorem qmaFourTensorHighPerturbation_norm + (K : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) : + ‖qmaFourTensorHighPerturbation K‖ ≤ ‖K‖ := by + unfold qmaFourTensorHighPerturbation + calc + _ ≤ ‖qmaFourTensorHigh n‖*‖K.comp (qmaFourTensorHigh n)‖ := ContinuousLinearMap.opNorm_comp_le _ _ + _ ≤ 1*(‖K‖*1) := mul_le_mul (qmaFourTensorHigh_norm n) + ((ContinuousLinearMap.opNorm_comp_le _ _).trans + (mul_le_mul_of_nonneg_left (qmaFourTensorHigh_norm n) (norm_nonneg K))) + (norm_nonneg _) zero_le_one + _ = _ := by ring + +theorem qmaFourTensorGround_error (r : ℝ) (hr : 0 < r) + (U : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) (hU : U.conjTranspose = U) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hAT : ∀ x, qmaFourTensorPadded n r (T x) = x) + {d m η : ℝ} (hd : 0 ≤ d) (hm : 0 ≤ m) (hη : 0 ≤ η) + (hsmall : 2*(d+m) ≤ 4*r^2) (hUn : ‖spinMatrixOperator U‖ ≤ d) + (hTB : ∀ p, ‖T (qmaFourTensorOff ((qmaMatrixOperator U).restrictScalars ℝ) p)‖ ≤ η*‖p‖) + (hbound : ∀ p : EuclideanSpace ℂ (Fin n → Fin 2), ‖p‖ = 1 → + |Perturbation.effectiveForm (qmaFourTensorLow ((qmaMatrixOperator U).restrictScalars ℝ)) + T (qmaFourTensorOff ((qmaMatrixOperator U).restrictScalars ℝ)) p| ≤ m) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r U)- + Perturbation.effectiveBottom (qmaFourTensorLow ((qmaMatrixOperator U).restrictScalars ℝ)) + T (qmaFourTensorOff ((qmaMatrixOperator U).restrictScalars ℝ))| ≤ 2*(d+m)*η^2 := by + let K := (qmaMatrixOperator U).restrictScalars ℝ + let C := qmaFourTensorLow K + let B := qmaFourTensorOff K + let D := qmaFourTensorHighPerturbation K + let A := qmaFourTensorPadded n r + have hK : ∀ x y, ⟪x,K y⟫_ℝ = ⟪K x,y⟫_ℝ := qmaMatrixOperator_real_symmetric U hU + have hDnorm : ‖D‖ ≤ d := (qmaFourTensorHighPerturbation_norm K).trans (by + simpa only [K,ContinuousLinearMap.norm_restrictScalars,qmaMatrixOperator_square] using hUn) + have hD (q : EuclideanSpace ℂ (Fin n → Fin 16)) : |⟪q,D q⟫_ℝ| ≤ d*‖q‖^2 := by + simpa only [one_mul] using Perturbation.highPerturbation_abs_le D + (g := d) (ε := 1) (by simpa only [one_mul] using hDnorm) q + have hAsymm : ∀ x y, ⟪x,A y⟫_ℝ = ⟪A x,y⟫_ℝ := qmaFourTensorPadded_symmetric n r + have hgap : ∀ q, (4*r^2)*‖q‖^2 ≤ Perturbation.penaltyForm A q := + qmaFourTensor_padded_gap n r + obtain ⟨p,hp,hmin⟩ := Perturbation.effectiveForm_minimizer C T B u hu + rw [Perturbation.effectiveBottom_eq C T B p hp hmin] + let μ := Perturbation.effectiveForm C T B p + let ε := 2*(d+m)*η^2 + have hμ : |μ| ≤ m := hbound p hp + have hl (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + (μ-ε)*‖x‖^2 ≤ ⟪x,qmaFourTensorPhysical r K x⟫_ℝ := by + rw [qmaFourTensorPhysical_energy r K hK] + have h := Perturbation.sharp_lowBlockEnergy_lower C A T D B hd hm hη hsmall hAT hAsymm hgap + hTB hD (abs_le.mp hμ).2 hmin (qmaFourTensorRestriction n x) (qmaFourTensorHigh n x) + rw [qmaFourTensor_norm_decomposition] at h + have hle : ‖qmaFourTensorRestriction n x‖^2 ≤ ‖x‖^2 := by + have hn := qmaFourTensor_norm_decomposition n x + nlinarith [sq_nonneg ‖qmaFourTensorHigh n x‖] + have he : 0 ≤ ε := by dsimp [ε]; positivity + nlinarith + have hu0 : ‖qmaFourTensorInclusion n u‖ = 1 := (qmaFourTensor_inclusion_norm n u).trans hu + have hlow : μ-ε ≤ MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r U) := by + apply le_qmaNormalizedBottom _ (qmaFourTensorInclusion n u) hu0 + intro x hx + rw [qmaQuadratic_operator,qmaFourTensorPhysicalMatrix_apply] + simpa only [hx,one_pow,mul_one] using hl x + let q := -(T (B p)) + let x := qmaFourTensorInclusion n p+q + have hq : qmaFourTensorRestriction n q = 0 := by + change qmaFourTensorRestriction n (-(T (B p))) = 0 + rw [map_neg,qmaFourTensorInverse_high hr T hAT (B p) (qmaFourTensorRestriction_high n _),neg_zero] + have hxn : ‖x‖^2 = ‖p‖^2+‖q‖^2 := + Perturbation.orthogonalAssemble_norm _ _ (qmaFourTensor_restrict_include n) + (qmaFourTensor_inclusion_adjoint n) p q hq + have hxpos : 0 < ‖x‖^2 := by rw [hxn,hp]; positivity + have hxe : ⟪x,qmaFourTensorPhysical r K x⟫_ℝ = Perturbation.lowBlockEnergy C A D B p q := + Perturbation.orthogonalBlock_energy _ _ _ _ _ _ _ (qmaFourTensor_restrict_include n) + (qmaFourTensor_inclusion_adjoint n) (qmaFourTensorPhysical_symmetric r K hK) + (qmaFourTensorPhysical_low r K) (fun _ => qmaFourTensorRestriction_high n _) + (qmaFourTensorPhysical_high r K) p q hq + have htrial : ⟪x,qmaFourTensorPhysical r K x⟫_ℝ/‖x‖^2 ≤ μ+(d+m)*η^2 := by + rw [hxe,hxn] + exact Perturbation.sharp_lowBlockRayleigh_trial_upper C A T D B hd hm hη hAT hTB hD + (abs_le.mp hμ).1 p hp rfl + have hb : BddBelow {e | ∃ x : EuclideanSpace ℂ (Fin n → Fin 16), 0 < ‖x‖^2 ∧ + e = ⟪x,spinMatrixOperator (qmaFourTensorPhysicalMatrix r U) x⟫_ℝ/‖x‖^2} := by + refine ⟨μ-ε,?_⟩ + rintro e ⟨y,hy,rfl⟩ + rw [← qmaMatrixOperator_square,qmaFourTensorPhysicalMatrix_apply] + exact (le_div_iff₀ hy).mpr (hl y) + have hup : MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r U) ≤ μ+(d+m)*η^2 := by + rw [MediatorGraph.normalizedBottom_eq_rayleigh] + apply (csInf_le hb ⟨x,hxpos,rfl⟩).trans + simpa only [← qmaMatrixOperator_square,qmaFourTensorPhysicalMatrix_apply] using htrial + have heps : (d+m)*η^2 ≤ ε := by + dsimp [ε] + nlinarith [mul_nonneg (add_nonneg hd hm) (sq_nonneg η)] + exact abs_le.mpr ⟨by linarith,by linarith⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorHilbert.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorHilbert.lean new file mode 100644 index 0000000000000000000000000000000000000000..687cb72c5662a3ef15e13dc683066f88b836c339 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorHilbert.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFamily +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoerciveInverse +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QubitMediatorForms + +namespace OAI + +/-! Actual low/high coordinates and the bounded padded inverse for the four-spin code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical ComplexOrder + +def qmaFourTensorInclusion (n : ℕ) : + EuclideanSpace ℂ (Fin n → Fin 2) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16) := + (qmaMatrixOperator (qmaFourTensorEncoding n)).restrictScalars ℝ + +def qmaFourTensorRestriction (n : ℕ) : + EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 2) := + (qmaMatrixOperator (qmaFourTensorEncoding n).conjTranspose).restrictScalars ℝ + +def qmaFourTensorHigh (n : ℕ) : + EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16) := + (qmaMatrixOperator (1-qmaFourTensorProjection n)).restrictScalars ℝ + +theorem qmaFourTensor_restrict_include (n : ℕ) (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + qmaFourTensorRestriction n (qmaFourTensorInclusion n p) = p := by + change qmaMatrixOperator _ (qmaMatrixOperator _ p) = p + rw [← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul,qmaFourTensorEncoding_gram, + qmaMatrixOperator_square,spinMatrixOperator_one] + rfl + +theorem qmaFourTensor_inclusion_adjoint (n : ℕ) (p : EuclideanSpace ℂ (Fin n → Fin 2)) + (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + ⟪qmaFourTensorInclusion n p,x⟫_ℝ = ⟪p,qmaFourTensorRestriction n x⟫_ℝ := by + have h := ContinuousLinearMap.adjoint_inner_right (qmaMatrixOperator (qmaFourTensorEncoding n)) p x + rw [← qmaMatrixOperator_star] at h + rw [qmaEuclidean_real_inner,qmaEuclidean_real_inner] + exact congrArg Complex.re h.symm + +theorem qmaFourTensor_highPart (n : ℕ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + Perturbation.orthogonalHighPart (qmaFourTensorInclusion n) (qmaFourTensorRestriction n) x = + qmaFourTensorHigh n x := by + unfold Perturbation.orthogonalHighPart qmaFourTensorHigh qmaFourTensorInclusion qmaFourTensorRestriction + change x-qmaMatrixOperator _ (qmaMatrixOperator _ x) = qmaMatrixOperator _ x + rw [← ContinuousLinearMap.comp_apply,← qmaMatrixOperator_mul,qmaFourTensorEncoding_projector] + simp only [qmaMatrixOperator_square,spinMatrixOperator_sub,spinMatrixOperator_one] + rfl + +theorem qmaFourTensorRestriction_high (n : ℕ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + qmaFourTensorRestriction n (qmaFourTensorHigh n x) = 0 := by + rw [← qmaFourTensor_highPart] + exact Perturbation.orthogonalHighPart_kernel _ _ (qmaFourTensor_restrict_include n) x + +theorem qmaFourTensor_projection_star (n : ℕ) : + (qmaFourTensorProjection n).conjTranspose = qmaFourTensorProjection n := by + rw [← qmaFourTensorEncoding_projector,Matrix.conjTranspose_mul,Matrix.conjTranspose_conjTranspose] + +theorem qmaFourTensor_penalty_star (n : ℕ) : + (qmaFourTensorPenalty n).conjTranspose = qmaFourTensorPenalty n := by + have h := (qmaFourTensorGap_posSemidef n).isHermitian + have hp := qmaFourTensor_projection_star n + have hs : ((4:ℂ) • (1-qmaFourTensorProjection n)).conjTranspose = + (4:ℂ) • (1-qmaFourTensorProjection n) := by + simp only [Matrix.conjTranspose_smul,Matrix.conjTranspose_sub,Matrix.conjTranspose_one,hp] + norm_num + have he := congrArg (fun M : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ => + M+(4:ℂ) • (1-qmaFourTensorProjection n)) h.eq + simpa only [Matrix.conjTranspose_sub,hs,sub_add_cancel] using he + +def qmaFourTensorPaddedMatrix (n : ℕ) : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + qmaFourTensorPenalty n+(4:ℂ) • qmaFourTensorProjection n + +def qmaFourTensorPadded (n : ℕ) (r : ℝ) : + EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16) := + r^2 • (qmaMatrixOperator (qmaFourTensorPaddedMatrix n)).restrictScalars ℝ + +theorem qmaFourTensor_padded_gap (n : ℕ) (r : ℝ) (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + (4*r^2)*‖x‖^2 ≤ ⟪x,qmaFourTensorPadded n r x⟫_ℝ := by + have he : qmaFourTensorPaddedMatrix n-(4:ℂ) • 1 = + qmaFourTensorPenalty n-(4:ℂ) • (1-qmaFourTensorProjection n) := by + unfold qmaFourTensorPaddedMatrix + module + have hh := (Complex.nonneg_iff.mp + ((he ▸ qmaFourTensorGap_posSemidef n).dotProduct_mulVec_nonneg (fun i => x i))).1 + change 0 ≤ qmaQuadratic (qmaFourTensorPaddedMatrix n-(4:ℂ) • 1) (fun i => x i) at hh + rw [qmaQuadratic_sub] at hh + have hone : qmaQuadratic ((4:ℂ) • (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ)) + (fun i => x i) = 4*‖x‖^2 := by + rw [show (4:ℂ) = ((4:ℝ):ℂ) from rfl,qmaQuadratic_smul,qmaQuadratic_operator, + qmaMatrixOperator_square,spinMatrixOperator_one,one_apply_eq_self,real_inner_self_eq_norm_sq] + rw [hone] at hh + have h := mul_le_mul_of_nonneg_left (sub_nonneg.mp hh) (sq_nonneg r) + change _ ≤ ⟪x,r^2 • qmaMatrixOperator (qmaFourTensorPaddedMatrix n) x⟫_ℝ + rw [inner_smul_right,← qmaQuadratic_operator] + nlinarith + +theorem qmaFourTensor_inverse_exists (n : ℕ) {r : ℝ} (hr : 0 < r) : + ∃ T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16), + (∀ x, qmaFourTensorPadded n r (T x) = x) ∧ + (∀ x, T (qmaFourTensorPadded n r x) = x) ∧ ‖T‖ ≤ 1/(4*r^2) := + qmaCoerciveInverse_exists _ (by positivity) (qmaFourTensor_padded_gap n r) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorInverse.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorInverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..086295ed8bf646ceb05e8c454b2fc6c5204d301f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorInverse.lean @@ -0,0 +1,90 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorHilbert + +namespace OAI + +/-! The bounded inverse acts exactly on the physical two-block excitations. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators InnerProductSpace Classical +variable {n : ℕ} + +theorem qmaFourTensor_padded_star (n : ℕ) : + (qmaFourTensorPaddedMatrix n).conjTranspose = qmaFourTensorPaddedMatrix n := by + simp only [qmaFourTensorPaddedMatrix,Matrix.conjTranspose_add,Matrix.conjTranspose_smul, + qmaFourTensor_penalty_star,qmaFourTensor_projection_star] + norm_num + +theorem qmaFourTensorPadded_symmetric (n : ℕ) (r : ℝ) + (x y : EuclideanSpace ℂ (Fin n → Fin 16)) : + ⟪x,qmaFourTensorPadded n r y⟫_ℝ = ⟪qmaFourTensorPadded n r x,y⟫_ℝ := by + change ⟪x,r^2 • qmaMatrixOperator _ y⟫_ℝ = ⟪r^2 • qmaMatrixOperator _ x,y⟫_ℝ + rw [inner_smul_right,inner_smul_left,qmaMatrixOperator_real_symmetric _ (qmaFourTensor_padded_star n)] + simp only [starRingEnd_apply,star_trivial] + +theorem qmaFourTensorPadded_encoding (n : ℕ) : + qmaFourTensorPaddedMatrix n*qmaFourTensorEncoding n = (4:ℂ) • qmaFourTensorEncoding n := by + rw [qmaFourTensorPaddedMatrix,Matrix.add_mul,qmaFourTensorPenalty_encoding, + Matrix.smul_mul,← qmaFourTensorEncoding_projector,Matrix.mul_assoc,qmaFourTensorEncoding_gram, + Matrix.mul_one,zero_add] + +theorem qmaFourTensorPadded_restrict (n : ℕ) (r : ℝ) + (x : EuclideanSpace ℂ (Fin n → Fin 16)) : + qmaFourTensorRestriction n (qmaFourTensorPadded n r x) = + (4*r^2) • qmaFourTensorRestriction n x := by + have hm := congrArg Matrix.conjTranspose (qmaFourTensorPadded_encoding n) + simp only [Matrix.conjTranspose_mul,Matrix.conjTranspose_smul,qmaFourTensor_padded_star] at hm + norm_num at hm + have he := congrArg (fun M => qmaMatrixOperator M x) hm + rw [qmaMatrixOperator_mul,qmaMatrixOperator_smul] at he + change qmaFourTensorRestriction n (qmaMatrixOperator (qmaFourTensorPaddedMatrix n) x) = + (4:ℂ) • qmaFourTensorRestriction n x at he + change qmaFourTensorRestriction n (r^2 • qmaMatrixOperator (qmaFourTensorPaddedMatrix n) x) = _ + rw [map_smul,he] + ext s + simp only [PiLp.smul_apply,Complex.real_smul] + push_cast + ring + +theorem qmaFourTensorInverse_high {r : ℝ} (hr : 0 < r) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hAT : ∀ x, qmaFourTensorPadded n r (T x) = x) + (x : EuclideanSpace ℂ (Fin n → Fin 16)) (hx : qmaFourTensorRestriction n x = 0) : + qmaFourTensorRestriction n (T x) = 0 := by + have h := congrArg (qmaFourTensorRestriction n) (hAT x) + rw [qmaFourTensorPadded_restrict,hx] at h + exact (smul_eq_zero.mp h).resolve_left (by positivity) + +theorem qmaFourTensorPadded_column + (W : Matrix (Fin n → Fin 16) (Fin n → Fin 2) ℂ) + (hW : (qmaFourTensorEncoding n).conjTranspose*W = 0) + (hH : qmaFourTensorPenalty n*W = (8:ℂ) • W) : + qmaFourTensorPaddedMatrix n*W = (8:ℂ) • W := by + rw [qmaFourTensorPaddedMatrix,Matrix.add_mul,hH,Matrix.smul_mul, + ← qmaFourTensorEncoding_projector,Matrix.mul_assoc,hW,Matrix.mul_zero,smul_zero,add_zero] + +theorem qmaFourTensorInverse_column {r : ℝ} (hr : 0 < r) + (T : EuclideanSpace ℂ (Fin n → Fin 16) →L[ℝ] EuclideanSpace ℂ (Fin n → Fin 16)) + (hTA : ∀ x, T (qmaFourTensorPadded n r x) = x) + (W : Matrix (Fin n → Fin 16) (Fin n → Fin 2) ℂ) + (hW : (qmaFourTensorEncoding n).conjTranspose*W = 0) + (hH : qmaFourTensorPenalty n*W = (8:ℂ) • W) + (p : EuclideanSpace ℂ (Fin n → Fin 2)) : + T (qmaMatrixOperator W p) = (8*r^2)⁻¹ • qmaMatrixOperator W p := by + apply qmaInverse_eigenvector _ _ hTA _ (by positivity) + have he := congrArg (fun M => qmaMatrixOperator M p) (qmaFourTensorPadded_column W hW hH) + rw [qmaMatrixOperator_mul,qmaMatrixOperator_smul] at he + change r^2 • qmaMatrixOperator (qmaFourTensorPaddedMatrix n) (qmaMatrixOperator W p) = _ + simp only [ContinuousLinearMap.comp_apply,_root_.smul_apply] at he + rw [he] + ext s + simp only [PiLp.smul_apply,Complex.real_smul] + push_cast + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorNorm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa96ec80fc3df62309ce3ba4a821ddd5cd548942 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorNorm.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorEffective +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCouplingBounds + +namespace OAI + +/-! Spectator-independent bounds for the actual many-block physical couplings. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +theorem qmaFourSpin_square (p : Fin 4) (μ : Fin 3) : + qmaFourSpin p μ*qmaFourSpin p μ = 1 := by + rw [qmaFourSpin_source] + change (sourceLocalPauli 4 p μ).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm * + (sourceLocalPauli 4 p μ).submatrix qmaFourBasisEquiv.symm qmaFourBasisEquiv.symm = 1 + rw [Matrix.submatrix_mul_equiv _ _ _ qmaFourBasisEquiv.symm _,sourceLocalPauli_sq, + Matrix.submatrix_one_equiv] + +theorem qmaFourTensorSpin_norm (i : Fin n) (p : Fin 4) (μ : Fin 3) : + ‖spinMatrixOperator (qmaSiteMatrix i (qmaFourSpin p μ))‖ ≤ 1 := by + apply spinMatrixOperator_unitary_norm + rw [qmaSiteMatrix_star,qmaFourSpin_star,qmaSiteMatrix_mul,qmaFourSpin_square,qmaSiteMatrix_one] + +theorem qmaFourTensorCross_norm (i j : Fin n) (p q : Fin 4) : + ‖spinMatrixOperator (qmaFourTensorCross i j p q)‖ ≤ 3 := by + rw [qmaFourTensorCross,spinMatrixOperator_sum] + calc + _ ≤ ∑ μ : Fin 3, ‖spinMatrixOperator + (qmaSiteMatrix i (qmaFourSpin p μ)*qmaSiteMatrix j (qmaFourSpin q μ))‖ := norm_sum_le _ _ + _ ≤ ∑ _ : Fin 3, (1:ℝ) := by + apply Finset.sum_le_sum + intro μ _ + rw [spinMatrixOperator_mul] + exact (ContinuousLinearMap.opNorm_comp_le _ _).trans + (by simpa using (mul_le_mul (qmaFourTensorSpin_norm i p μ) (qmaFourTensorSpin_norm j q μ) + (norm_nonneg _) zero_le_one)) + _ = 3 := by norm_num + +theorem qmaFourTensorWeighted_norm (i j : Fin n) (a b : Fin 4 → ℝ) : + ‖spinMatrixOperator (qmaFourTensorWeighted i j a b)‖ ≤ + 3*(∑ p, |a p|)*(∑ q, |b q|) := by + rw [qmaFourTensorWeighted,spinMatrixOperator_sum] + calc + _ ≤ ∑ p, ∑ q, 3*|a p| * |b q| := by + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro p _ + rw [spinMatrixOperator_sum] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro q _ + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs,abs_mul] + calc + _ ≤ (|a p| * |b q|)*3 := mul_le_mul_of_nonneg_left (qmaFourTensorCross_norm i j p q) (by positivity) + _ = _ := by ring + _ = (∑ p, 3*|a p|)*(∑ q, |b q|) := by + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro p _ + rw [Finset.mul_sum] + _ = _ := by rw [← Finset.mul_sum] + +theorem qmaFourTensorAxisCross_norm (i j : Fin n) (a b : Fin 2) (p q : Bool) : + ‖spinMatrixOperator (qmaFourTensorWeighted i j (qmaFourAxisWeights a p) (qmaFourAxisWeights b q))‖ ≤ + 2352 := by + apply (qmaFourTensorWeighted_norm _ _ _ _).trans + have ha := qmaFourAxisWeights_abs_sum a p + have hb := qmaFourAxisWeights_abs_sum b q + have ha0 : 0 ≤ ∑ k, |qmaFourAxisWeights a p k| := by positivity + have hb0 : 0 ≤ ∑ k, |qmaFourAxisWeights b q k| := by positivity + nlinarith + +theorem qmaFourTensorCoupling_norm (i j : Fin n) (a b : Fin 2) (t : ℝ) : + ‖spinMatrixOperator (qmaFourTensorCoupling i j a b t)‖ ≤ 7056*(1+|t|) := by + rw [qmaFourTensorCoupling,spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg (qmaFourCouplingSize_nonneg a b t)] + have hn := qmaFourTensorAxisCross_norm i j a b true (qmaFourCouplingSign t) + have hs := qmaFourCouplingSize_bound a b t + have hnon := qmaFourCouplingSize_nonneg a b t + calc + _ ≤ qmaFourCouplingSize a b t*2352 := mul_le_mul_of_nonneg_left hn hnon + _ ≤ _ := by nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOnsite.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOnsite.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fce6decea0d1bf39297eb5d27e7fcd7a34a53cf --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOnsite.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorFamilyAccuracy + +namespace OAI + +/-! Internal physical exchanges encode the one-site and scalar X/Z terms. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} {τ : Type*} [Fintype τ] + +def qmaFourTensorFields (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + ∑ e, qmaSiteMatrix (site e) (qmaFourAxisField (axis e) (weight e)) + +def qmaFourTensorFieldShift (axis : τ → Fin 2) (weight : τ → ℝ) : ℝ := + ∑ e, qmaFourAxisFieldShift (axis e) (weight e) + +def qmaFourTensorOnsite (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) (constant : ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + qmaFourTensorFields site axis weight+((constant-qmaFourTensorFieldShift axis weight:ℝ):ℂ) • 1 + +theorem qmaFourTensorOnsite_compression (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorOnsite site axis weight constant*qmaFourTensorEncoding n = + (∑ e, (weight e:ℂ) • qmaSiteMatrix (site e) (qmaFourAxis (axis e)))+(constant:ℂ) • 1 := by + simp only [qmaFourTensorOnsite,qmaFourTensorFields,Matrix.mul_add,Matrix.add_mul, + Matrix.mul_sum,Matrix.sum_mul,qmaFourTensor_site_compression,qmaFourAxisField_compression, + qmaSiteMatrix_add,qmaSiteMatrix_smul,qmaSiteMatrix_one,Matrix.mul_smul,Matrix.smul_mul, + Matrix.mul_one,qmaFourTensorEncoding_gram,Finset.sum_add_distrib,← Finset.sum_smul] + simp only [← Complex.ofReal_sum,qmaFourTensorFieldShift] + module + +theorem qmaFourTensorFields_star (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) : + (qmaFourTensorFields site axis weight).conjTranspose = qmaFourTensorFields site axis weight := by + simp only [qmaFourTensorFields,Matrix.conjTranspose_sum,qmaSiteMatrix_star,qmaFourAxisField_star] + +theorem qmaFourTensorOnsite_star (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + (qmaFourTensorOnsite site axis weight constant).conjTranspose = qmaFourTensorOnsite site axis weight constant := by + simp only [qmaFourTensorOnsite,Matrix.conjTranspose_add,qmaFourTensorFields_star, + Matrix.conjTranspose_smul,Complex.star_def,Complex.conj_ofReal,Matrix.conjTranspose_one] + +theorem qmaFourTensorFields_norm (site : τ → Fin n) (axis : τ → Fin 2) (weight : τ → ℝ) : + ‖spinMatrixOperator (qmaFourTensorFields site axis weight)‖ ≤ 6*(∑ e, |weight e|) := by + rw [qmaFourTensorFields,spinMatrixOperator_sum,Finset.mul_sum] + exact (norm_sum_le _ _).trans (Finset.sum_le_sum (fun e _ => qmaFourTensorAxisField_norm _ _ _)) + +theorem qmaFourAxisFieldShift_abs (a : Fin 2) (t : ℝ) : |qmaFourAxisFieldShift a t| ≤ |t| := by + unfold qmaFourAxisFieldShift + split_ifs + · simpa only [abs_zero] using abs_nonneg t + · rw [abs_div] + norm_num + +theorem qmaFourTensorFieldShift_abs (axis : τ → Fin 2) (weight : τ → ℝ) : + |qmaFourTensorFieldShift axis weight| ≤ ∑ e, |weight e| := by + unfold qmaFourTensorFieldShift + exact (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum (fun e _ => qmaFourAxisFieldShift_abs _ _)) + +theorem qmaFourTensorOnsite_norm (site : τ → Fin n) (axis : τ → Fin 2) + (weight : τ → ℝ) (constant : ℝ) : + ‖spinMatrixOperator (qmaFourTensorOnsite site axis weight constant)‖ ≤ + 7*(∑ e, |weight e|)+|constant| := by + have h1 : ‖spinMatrixOperator (1 : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ)‖ ≤ 1 := by + apply spinMatrixOperator_unitary_norm + simp + have hs := qmaFourTensorFieldShift_abs axis weight + have hf := qmaFourTensorFields_norm site axis weight + rw [qmaFourTensorOnsite,spinMatrixOperator_add] + apply (norm_add_le _ _).trans + rw [spinMatrixOperator_smul,norm_smul,Complex.norm_real,Real.norm_eq_abs] + have hscalar := mul_le_mul_of_nonneg_left h1 (abs_nonneg (constant-qmaFourTensorFieldShift axis weight)) + have habs := abs_sub constant (qmaFourTensorFieldShift axis weight) + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOperatorBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOperatorBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0a2458e312f6fca726171209a21cc081bea266f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOperatorBounds.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorScale +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorCoefficientBounds + +namespace OAI + +/-! Polynomial norm budget for the exact calibrated effective matrix. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped InnerProductSpace Classical +variable {n : ℕ} + +theorem qmaFourTensorEncoding_norm (n : ℕ) : ‖qmaMatrixOperator (qmaFourTensorEncoding n)‖ ≤ 1 := by + apply ContinuousLinearMap.opNorm_le_bound _ zero_le_one + intro p + rw [one_mul] + exact le_of_eq (qmaFourTensor_inclusion_norm n p) + +theorem qmaFourTensor_column_operator_norm (V : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + ‖qmaMatrixOperator (V*qmaFourTensorEncoding n)‖ ≤ ‖spinMatrixOperator V‖ := by + rw [qmaMatrixOperator_mul] + exact (ContinuousLinearMap.opNorm_comp_le _ _).trans + ((mul_le_mul_of_nonneg_left (qmaFourTensorEncoding_norm n) (norm_nonneg _)).trans_eq (mul_one _)) + +theorem qmaFourTensor_compression_norm (C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + ‖spinMatrixOperator ((qmaFourTensorEncoding n).conjTranspose*C*qmaFourTensorEncoding n)‖ ≤ + ‖spinMatrixOperator C‖ := by + rw [← qmaMatrixOperator_square,qmaMatrixOperator_mul,qmaMatrixOperator_mul,qmaMatrixOperator_star] + have hE := qmaFourTensorEncoding_norm n + have hEs : ‖(qmaMatrixOperator (qmaFourTensorEncoding n)).adjoint‖ ≤ 1 := by + simpa only [LinearIsometryEquiv.norm_map] using hE + calc + _ ≤ (‖(qmaMatrixOperator (qmaFourTensorEncoding n)).adjoint‖*‖qmaMatrixOperator C‖)* + ‖qmaMatrixOperator (qmaFourTensorEncoding n)‖ := + (ContinuousLinearMap.opNorm_comp_le _ _).trans + (mul_le_mul_of_nonneg_right (ContinuousLinearMap.opNorm_comp_le _ _) (norm_nonneg _)) + _ ≤ (1*‖qmaMatrixOperator C‖)*1 := mul_le_mul + (mul_le_mul_of_nonneg_right hEs (norm_nonneg _)) hE (norm_nonneg _) (by positivity) + _ = _ := by rw [one_mul,mul_one]; rfl + +theorem qmaFourTensorEffectiveMatrix_norm (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + ‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖ ≤ + ‖spinMatrixOperator C‖+‖spinMatrixOperator V‖^2/8 := by + have hgram : ‖spinMatrixOperator ((V*qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n))‖ ≤ + ‖spinMatrixOperator V‖^2 := by + rw [← qmaMatrixOperator_square,qmaMatrixOperator_mul,qmaMatrixOperator_star, + ContinuousLinearMap.norm_adjoint_comp_self] + have h := qmaFourTensor_column_operator_norm V + nlinarith [norm_nonneg (qmaMatrixOperator (V*qmaFourTensorEncoding n)),norm_nonneg (spinMatrixOperator V)] + rw [qmaFourTensorEffectiveMatrix,spinMatrixOperator_sub] + apply (norm_sub_le _ _).trans + rw [spinMatrixOperator_smul,norm_smul] + have hs : ‖(1/8:ℂ)‖ = (1/8:ℝ) := by norm_num + rw [hs] + have hleft := qmaFourTensor_compression_norm C + nlinarith + +def qmaFourTensorNormBudget (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : ℝ := + 1+‖spinMatrixOperator V‖+‖spinMatrixOperator C‖+‖spinMatrixOperator V‖^2 + +theorem qmaFourTensorNormBudget_bounds (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) : + 1 ≤ qmaFourTensorNormBudget V C ∧ ‖spinMatrixOperator V‖ ≤ qmaFourTensorNormBudget V C ∧ + ‖spinMatrixOperator C‖ ≤ qmaFourTensorNormBudget V C ∧ + ‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖ ≤ qmaFourTensorNormBudget V C := by + have hv := norm_nonneg (spinMatrixOperator V) + have hc := norm_nonneg (spinMatrixOperator C) + have he := qmaFourTensorEffectiveMatrix_norm V C + unfold qmaFourTensorNormBudget + constructor + · nlinarith [sq_nonneg ‖spinMatrixOperator V‖] + constructor + · nlinarith [sq_nonneg ‖spinMatrixOperator V‖] + constructor + · nlinarith [sq_nonneg ‖spinMatrixOperator V‖] + · nlinarith [sq_nonneg ‖spinMatrixOperator V‖] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOrthogonal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOrthogonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1d699da2a1677788206249aa4684d012b2effc6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorOrthogonal.lean @@ -0,0 +1,65 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorCross + +namespace OAI + +/-! Distinct logical pairs have orthogonal first-excited columns. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +theorem qmaFourSpin_column_adjoint (p : Fin 4) (μ : Fin 3) : + (qmaFourSpin p μ*qmaFourEncoding).conjTranspose*qmaFourEncoding = 0 := by + rw [Matrix.conjTranspose_mul,qmaFourSpin_star] + exact qmaFourSpin_orthogonal p μ + +theorem qmaFourTensorPairColumn_unmatched_first (i j k l : Fin n) + (hik : i ≠ k) (hil : i ≠ l) (p q r s : Fin 4) (μ ν : Fin 3) : + (qmaFourTensorPairColumn i j p q μ).conjTranspose* + qmaFourTensorPairColumn k l r s ν = 0 := by + rw [qmaFourTensorPairColumn,qmaFourTensorPairColumn,qmaTensorMatrix_star,qmaTensorMatrix_mul] + apply qmaTensorMatrix_zero_at _ i + simp only [ite_true,hik,hil,ite_false,qmaFourSpin_column_adjoint] + +theorem qmaFourTensorPairColumn_unmatched_second (i j k l : Fin n) + (hij : i ≠ j) (hjk : j ≠ k) (hjl : j ≠ l) (p q r s : Fin 4) (μ ν : Fin 3) : + (qmaFourTensorPairColumn i j p q μ).conjTranspose* + qmaFourTensorPairColumn k l r s ν = 0 := by + rw [qmaFourTensorPairColumn,qmaFourTensorPairColumn,qmaTensorMatrix_star,qmaTensorMatrix_mul] + apply qmaTensorMatrix_zero_at _ j + simp only [Ne.symm hij,ite_false,ite_true,hjk,hjl,qmaFourSpin_column_adjoint] + +theorem qmaFourTensorPairColumn_distinct (i j k l : Fin n) (hij : i ≠ j) (hkl : k ≠ l) + (hne : ({i,j} : Finset (Fin n)) ≠ {k,l}) (p q r s : Fin 4) (μ ν : Fin 3) : + (qmaFourTensorPairColumn i j p q μ).conjTranspose* + qmaFourTensorPairColumn k l r s ν = 0 := by + by_cases hi : i ∈ ({k,l} : Finset (Fin n)) + · by_cases hj : j ∈ ({k,l} : Finset (Fin n)) + · exfalso + apply hne + have hsub : ({i,j} : Finset (Fin n)) ⊆ {k,l} := by + intro x hx + rcases Finset.mem_insert.mp hx with rfl | hx + · exact hi + · simpa only [Finset.mem_singleton.mp hx] using hj + exact Finset.eq_of_subset_of_card_le hsub (by simp [hij,hkl]) + · have hj' : j ≠ k ∧ j ≠ l := by simpa using hj + exact qmaFourTensorPairColumn_unmatched_second i j k l hij hj'.1 hj'.2 p q r s μ ν + · have hi' : i ≠ k ∧ i ≠ l := by simpa using hi + exact qmaFourTensorPairColumn_unmatched_first i j k l hi'.1 hi'.2 p q r s μ ν + +theorem qmaFourTensorCross_distinct (i j k l : Fin n) (hij : i ≠ j) (hkl : k ≠ l) + (hne : ({i,j} : Finset (Fin n)) ≠ {k,l}) (p q r s : Fin 4) : + (qmaFourTensorCross i j p q*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorCross k l r s*qmaFourTensorEncoding n) = 0 := by + rw [qmaFourTensorCross_column i j hij,qmaFourTensorCross_column k l hkl] + simp only [Matrix.conjTranspose_sum,Matrix.sum_mul,Matrix.mul_sum, + qmaFourTensorPairColumn_distinct i j k l hij hkl hne,Finset.sum_const_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..04620038d730b617695ec2a46e15fed0cce03fed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorScale.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorComparison + +namespace OAI + +/-! Polynomial penalty scale for the full four-spin comparison. -/ + +noncomputable section +namespace ContinuumCoulomb + +theorem qmaFourTensor_scale_bounds {b r v c e : ℝ} (hb : 1 ≤ b) (hr : 4*b ≤ r) + (hv0 : 0 ≤ v) (hc0 : 0 ≤ c) (_he0 : 0 ≤ e) (hv : v ≤ b) (hc : c ≤ b) (he : e ≤ b) : + 2*(r*v+c+e+(v*c/(4*r)+c^2/(4*r^2))) ≤ 4*r^2 ∧ + 2*(r*v+c+e+(v*c/(4*r)+c^2/(4*r^2)))*(v/(8*r)+c/(4*r^2))^2+ + (v*c/(4*r)+c^2/(4*r^2)) ≤ 9*b^3/r := by + have hb0 : 0 ≤ b := by linarith + have hr1 : 1 ≤ r := by linarith + have hr0 : 0 < r := by linarith + have hvc : v*c ≤ b^2 := (mul_le_mul hv hc hc0 hb0).trans_eq (by ring) + have hc2 : c^2 ≤ b^2 := pow_le_pow_left₀ hc0 hc 2 + have hden : 4*r ≤ 4*r^2 := by nlinarith + have hδ : v*c/(4*r)+c^2/(4*r^2) ≤ b^2/r := by + calc + _ ≤ b^2/(4*r)+b^2/(4*r^2) := add_le_add + (div_le_div_of_nonneg_right hvc (by positivity)) + (div_le_div_of_nonneg_right hc2 (by positivity)) + _ ≤ b^2/(4*r)+b^2/(4*r) := add_le_add le_rfl + (div_le_div_of_nonneg_left (sq_nonneg b) (by positivity : 0 < 4*r) hden) + _ = (b^2/r)/2 := by field_simp; ring + _ ≤ b^2/r := by nlinarith [div_nonneg (sq_nonneg b) hr0.le] + have hη : v/(8*r)+c/(4*r^2) ≤ b/r := by + calc + _ ≤ b/(8*r)+b/(4*r^2) := add_le_add + (div_le_div_of_nonneg_right hv (by positivity)) + (div_le_div_of_nonneg_right hc (by positivity)) + _ ≤ b/(8*r)+b/(4*r) := add_le_add le_rfl + (div_le_div_of_nonneg_left hb0 (by positivity : 0 < 4*r) hden) + _ = 3/8*(b/r) := by field_simp; ring + _ ≤ b/r := by nlinarith [div_nonneg hb0 hr0.le] + have hδb : v*c/(4*r)+c^2/(4*r^2) ≤ b := hδ.trans (by + apply (div_le_iff₀ hr0).mpr + nlinarith) + have hsum : r*v+c+e+(v*c/(4*r)+c^2/(4*r^2)) ≤ 4*b*r := by + have hrv := mul_le_mul_of_nonneg_left hv hr0.le + have hbr := mul_le_mul_of_nonneg_left hr1 hb0 + nlinarith + constructor + · have hbr := mul_le_mul_of_nonneg_left hr hr0.le + nlinarith + · have hη0 : 0 ≤ v/(8*r)+c/(4*r^2) := by positivity + have hsq := pow_le_pow_left₀ hη0 hη 2 + have hmain : 2*(r*v+c+e+(v*c/(4*r)+c^2/(4*r^2)))*(v/(8*r)+c/(4*r^2))^2 ≤ 8*b^3/r := by + calc + _ ≤ (2*(4*b*r))*(b/r)^2 := mul_le_mul + (mul_le_mul_of_nonneg_left hsum (by norm_num)) hsq (sq_nonneg _) (by positivity) + _ = _ := by field_simp; ring + have hb23 : b^2 ≤ b^3 := pow_le_pow_right₀ hb (by omega) + have hδ3 := hδ.trans (div_le_div_of_nonneg_right hb23 hr0.le) + exact (add_le_add hmain hδ3).trans_eq (by ring) + +open Matrix +open scoped InnerProductSpace Classical +variable {n : ℕ} + +theorem qmaFourTensor_polynomial_comparison (r b : ℝ) (hb : 1 ≤ b) (hr : 4*b ≤ r) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hVs : V.conjTranspose = V) (hCs : C.conjTranspose = C) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (hH : qmaFourTensorPenalty n*(V*qmaFourTensorEncoding n) = (8:ℂ) • (V*qmaFourTensorEncoding n)) + (hVn : ‖spinMatrixOperator V‖ ≤ b) (hCn : ‖spinMatrixOperator C‖ ≤ b) + (hNn : ‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖ ≤ b) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix r ((r:ℂ) • V+C))- + MediatorGraph.normalizedBottom (qmaFourTensorEffectiveMatrix V C)| ≤ 9*b^3/r := by + have hb0 : 0 ≤ b := by linarith + have hr0 : 0 < r := by linarith + have hs := qmaFourTensor_scale_bounds hb hr hb0 hb0 (norm_nonneg _) + (le_refl b) (le_refl b) hNn + exact (qmaFourTensor_comparison r hr0 V C hVs hCs hV hH hb0 hb0 hVn hCn u hu hs.1).trans hs.2 + +theorem qmaFourTensor_polynomial_accuracy (b : ℝ) (hb : 1 ≤ b) + (V C : Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ) + (hVs : V.conjTranspose = V) (hCs : C.conjTranspose = C) + (hV : (qmaFourTensorEncoding n).conjTranspose*(V*qmaFourTensorEncoding n) = 0) + (hH : qmaFourTensorPenalty n*(V*qmaFourTensorEncoding n) = (8:ℂ) • (V*qmaFourTensorEncoding n)) + (hVn : ‖spinMatrixOperator V‖ ≤ b) (hCn : ‖spinMatrixOperator C‖ ≤ b) + (hNn : ‖spinMatrixOperator (qmaFourTensorEffectiveMatrix V C)‖ ≤ b) + (u : EuclideanSpace ℂ (Fin n → Fin 2)) (hu : ‖u‖ = 1) (N : ℕ) (hN : 0 < N) : + |MediatorGraph.normalizedBottom (qmaFourTensorPhysicalMatrix (9*b^3*N) (((9*b^3*N:ℝ):ℂ) • V+C))- + MediatorGraph.normalizedBottom (qmaFourTensorEffectiveMatrix V C)| ≤ 1/(N:ℝ) := by + have hN1 : (1:ℝ) ≤ N := by exact_mod_cast hN + have hb0 : 0 < b := by linarith + have hb13 : b ≤ b^3 := by simpa only [pow_one] using pow_le_pow_right₀ hb (show 1 ≤ 3 by omega) + have hlarge : 4*b ≤ 9*b^3*N := by nlinarith [mul_le_mul_of_nonneg_left hN1 (by positivity : 0 ≤ 9*b^3)] + have h := qmaFourTensor_polynomial_comparison (9*b^3*N) b hb hlarge V C hVs hCs hV hH hVn hCn hNn u hu + have he : 9*b^3/(9*b^3*N) = 1/(N:ℝ) := by field_simp + rwa [he] at h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorSpin.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorSpin.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a2c9f621801c6bac243e5362fcacb42702e403c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorSpin.lean @@ -0,0 +1,45 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTensorAction + +namespace OAI + +/-! Single physical-spin excitations in the full tensor code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaFourTensorSpinColumn (n : ℕ) (i : Fin n) (p : Fin 4) (μ : Fin 3) : + Matrix (Fin n → Fin 16) (Fin n → Fin 2) ℂ := + qmaTensorMatrix (fun k => if k = i then qmaFourSpin p μ*qmaFourEncoding else qmaFourEncoding) + +theorem qmaFourTensorSpinColumn_action (n : ℕ) (i : Fin n) (p : Fin 4) (μ : Fin 3) : + qmaSiteMatrix i (qmaFourSpin p μ)*qmaFourTensorEncoding n = qmaFourTensorSpinColumn n i p μ := by + rw [qmaFourTensorEncoding,qmaSiteMatrix_tensor] + rfl + +theorem qmaFourTensorSpinColumn_orthogonal (n : ℕ) (i : Fin n) (p : Fin 4) (μ : Fin 3) : + (qmaFourTensorEncoding n).conjTranspose*qmaFourTensorSpinColumn n i p μ = 0 := by + rw [qmaFourTensorEncoding,qmaFourTensorSpinColumn,qmaTensorMatrix_star,qmaTensorMatrix_mul] + apply qmaTensorMatrix_zero_at _ i + simp only [ite_true,← Matrix.mul_assoc,qmaFourSpin_orthogonal] + +theorem qmaFourTensorSpinColumn_excitation (n : ℕ) (i : Fin n) (p : Fin 4) (μ : Fin 3) : + qmaFourTensorPenalty n*qmaFourTensorSpinColumn n i p μ = + (4:ℂ) • qmaFourTensorSpinColumn n i p μ := by + have h := qmaTensorPenalty_eigen qmaFourPenalty + (fun k : Fin n => if k = i then qmaFourSpin p μ*qmaFourEncoding else qmaFourEncoding) + (fun k => if k = i then (4:ℂ) else 0) (by + intro k + by_cases hk : k = i + · simp only [hk,ite_true] + exact qmaFourSpin_excitation p μ + · simp only [hk,ite_false,zero_smul,qmaFourPenalty_encoding]) + simpa only [qmaFourTensorPenalty,qmaFourTensorSpinColumn,Finset.sum_ite_eq', + Finset.mem_univ,ite_true] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorWeighted.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorWeighted.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05519350e52b57ba3b24947eebe1b8de1dc6f57 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourTensorWeighted.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourTensorOrthogonal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTensorPairLinear +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCounterterm + +namespace OAI + +/-! Factorized Heisenberg couplings in the full many-block tensor code. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical +variable {n : ℕ} + +def qmaFourTensorWeighted (i j : Fin n) (a b : Fin 4 → ℝ) : + Matrix (Fin n → Fin 16) (Fin n → Fin 16) ℂ := + ∑ p, ∑ q, ((a p*b q:ℝ):ℂ) • qmaFourTensorCross i j p q + +theorem qmaFourTensorWeighted_orthogonal (i j : Fin n) (hij : i ≠ j) (a b : Fin 4 → ℝ) : + (qmaFourTensorEncoding n).conjTranspose*(qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n) = 0 := by + simp only [qmaFourTensorWeighted,Matrix.sum_mul,Matrix.smul_mul,Matrix.mul_sum,Matrix.mul_smul, + qmaFourTensorCross_orthogonal i j hij,smul_zero,Finset.sum_const_zero] + +theorem qmaFourTensorWeighted_excitation (i j : Fin n) (hij : i ≠ j) (a b : Fin 4 → ℝ) : + qmaFourTensorPenalty n*(qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n) = + (8:ℂ) • (qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n) := by + simp only [qmaFourTensorWeighted,Matrix.sum_mul,Matrix.smul_mul,Matrix.mul_sum,Matrix.mul_smul, + qmaFourTensorCross_excitation i j hij] + simp only [Finset.smul_sum,smul_comm (8:ℂ)] + +theorem qmaFourTensorWeighted_gram (i j : Fin n) (hij : i ≠ j) (a b : Fin 4 → ℝ) : + (qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n) = + (3:ℂ) • qmaPairMatrix i j (qmaFourWeightedCorrelation a) (qmaFourWeightedCorrelation b) := by + simp only [qmaFourTensorWeighted,Matrix.sum_mul,Matrix.smul_mul,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,Matrix.mul_sum,Matrix.mul_smul,smul_smul, + Complex.star_def,Complex.conj_ofReal,qmaFourTensorCross_gram i j hij,qmaFourWeightedCorrelation, + qmaPairMatrix_sum_left _ _ hij,qmaPairMatrix_sum_right _ _ hij, + qmaPairMatrix_smul_left _ _ hij,qmaPairMatrix_smul_right _ _ hij,Finset.smul_sum,smul_smul] + have hswap (f : Fin 4 → Fin 4 → Fin 4 → Fin 4 → + Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ) : + (∑ p, ∑ q, ∑ r, ∑ s, f p q r s) = ∑ p, ∑ r, ∑ q, ∑ s, f p q r s := by + apply Finset.sum_congr rfl + intro p _ + rw [Finset.sum_comm] + rw [hswap] + apply Finset.sum_congr rfl + intro q _ + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro r _ + rw [qmaFourCorrelation_comm s q,qmaFourCorrelation_comm r p] + congr 1 + push_cast + ring + +theorem qmaFourTensorWeighted_distinct (i j k l : Fin n) (hij : i ≠ j) (hkl : k ≠ l) + (hne : ({i,j} : Finset (Fin n)) ≠ {k,l}) (a b c d : Fin 4 → ℝ) : + (qmaFourTensorWeighted i j a b*qmaFourTensorEncoding n).conjTranspose* + (qmaFourTensorWeighted k l c d*qmaFourTensorEncoding n) = 0 := by + simp only [qmaFourTensorWeighted,Matrix.sum_mul,Matrix.smul_mul,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,Matrix.mul_sum,Matrix.mul_smul, + qmaFourTensorCross_distinct i j k l hij hkl hne,smul_zero,Finset.sum_const_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourWeighted.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourWeighted.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ae24736842f22a0dd8344ca495d0deb1679ae5b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumFourWeighted.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFourCross +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorGraph + +namespace OAI + +/-! Factorized real Heisenberg couplings between two four-spin blocks. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical + +def qmaFourWeightedCorrelation (a : Fin 4 → ℝ) : Matrix (Fin 2) (Fin 2) ℂ := + ∑ i, ∑ k, ((a i*a k:ℝ):ℂ) • qmaFourCorrelation i k + +def qmaFourWeightedCross (a b : Fin 4 → ℝ) : + Matrix (Fin 16 × Fin 16) (Fin 16 × Fin 16) ℂ := + ∑ i, ∑ j, ((a i*b j:ℝ):ℂ) • qmaFourCross i j + +theorem qmaFourWeightedCross_orthogonal (a b : Fin 4 → ℝ) : + qmaFourDoubleEncoding.conjTranspose*qmaFourWeightedCross a b*qmaFourDoubleEncoding = 0 := by + simp only [qmaFourWeightedCross,Matrix.mul_sum,Matrix.sum_mul,Matrix.mul_smul,Matrix.smul_mul] + simp only [qmaFourCross_orthogonal,smul_zero,Finset.sum_const_zero] + +theorem qmaFourWeightedCross_excitation (a b : Fin 4 → ℝ) : + qmaFourDoublePenalty*(qmaFourWeightedCross a b*qmaFourDoubleEncoding) = + (8:ℂ) • (qmaFourWeightedCross a b*qmaFourDoubleEncoding) := by + simp only [qmaFourWeightedCross,Matrix.mul_sum,Matrix.sum_mul,Matrix.smul_mul, + Matrix.mul_smul,qmaFourCross_excitation] + simp only [Finset.smul_sum,smul_comm (8:ℂ)] + +theorem qmaFourWeightedCross_gram (a b : Fin 4 → ℝ) : + (qmaFourWeightedCross a b*qmaFourDoubleEncoding).conjTranspose* + (qmaFourWeightedCross a b*qmaFourDoubleEncoding) = + (3:ℂ) • (qmaFourWeightedCorrelation a ⊗ₖ qmaFourWeightedCorrelation b) := by + simp only [qmaFourWeightedCross,Matrix.sum_mul,Matrix.smul_mul,Matrix.conjTranspose_sum, + Matrix.conjTranspose_smul,Matrix.mul_sum,Matrix.mul_smul,smul_smul, + Complex.star_def,Complex.conj_ofReal,qmaFourCross_gram,qmaFourWeightedCorrelation, + MediatorGraph.sum_kronecker,MediatorGraph.kronecker_sum,Matrix.smul_kronecker, + Matrix.kronecker_smul,Finset.smul_sum,smul_smul] + have hswap (f : Fin 4 → Fin 4 → Fin 4 → Fin 4 → Matrix (Fin 2 × Fin 2) (Fin 2 × Fin 2) ℂ) : + (∑ i, ∑ j, ∑ k, ∑ l, f i j k l) = ∑ j, ∑ l, ∑ i, ∑ k, f i j k l := by + rw [Finset.sum_comm] + calc + _ = ∑ j, ∑ i, ∑ l, ∑ k, f i j k l := by + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro i _ + rw [Finset.sum_comm] + _ = _ := by + apply Finset.sum_congr rfl + intro j _ + rw [Finset.sum_comm] + rw [hswap] + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro i _ + apply Finset.sum_congr rfl + intro k _ + rw [qmaFourCorrelation_comm k i,qmaFourCorrelation_comm l j] + congr 1 + push_cast + ring + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetAlgebra.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5e5b43c360c92deb68818020472c5e1e00fe44e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetAlgebra.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalError +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCircuitPauli + +namespace OAI + +/-! Exact low-block algebra for subdivision and three-body mediator gadgets. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem qmaGadget_pair_square (A B : Matrix ι ι ℂ) (b : ℂ) + (hA : A*A = 1) (hB : B*B = 1) (hAB : A*B = B*A) : + (A+b • B)*(A+b • B) = (1+b^2) • (1 : Matrix ι ι ℂ)+(2*b) • (A*B) := by + calc + _ = A*A+b • (A*B)+b • (B*A)+(b*b) • (B*B) := by + simp only [add_mul,mul_add,smul_mul_assoc,mul_smul_comm,smul_add,smul_smul] + abel + _ = _ := by + rw [hA,hB,←hAB] + module + +theorem qmaGadget_pair_sandwich (A B C : Matrix ι ι ℂ) (b : ℂ) + (hA : A*A = 1) (hB : B*B = 1) (hAB : A*B = B*A) + (hAC : A*C = C*A) (hBC : B*C = C*B) : + (A+b • B)*C*(A+b • B) = (1+b^2) • C+(2*b) • (A*B*C) := by + have hc : (A+b • B)*C = C*(A+b • B) := by + simp only [add_mul,mul_add,smul_mul_assoc,mul_smul_comm,hAC,hBC] + rw [hc,mul_assoc,qmaGadget_pair_square A B b hA hB hAB,mul_add,mul_smul_comm, + mul_smul_comm,mul_one] + have he : C*(A*B) = A*B*C := by + rw [←mul_assoc,←hAC,mul_assoc,←hBC,←mul_assoc] + rw [he] + +theorem qmaGadget_penalty_product (C : Matrix ι ι ℂ) (a b : ℂ) (hC : C*C = 1) : + (a • (1 : Matrix ι ι ℂ)+b • C)*(a • (1 : Matrix ι ι ℂ)-b • C) = + (a^2-b^2) • (1 : Matrix ι ι ℂ) := by + simp only [add_mul,mul_sub,smul_mul_assoc,mul_smul_comm,one_mul,mul_one,hC] + module + +def qmaGadgetPenaltyInverse (C : Matrix ι ι ℂ) (a b : ℂ) : Matrix ι ι ℂ := + (a^2-b^2)⁻¹ • (a • (1 : Matrix ι ι ℂ)-b • C) + +theorem qmaGadgetPenaltyInverse_right (C : Matrix ι ι ℂ) (a b : ℂ) + (hC : C*C = 1) (hab : a^2-b^2 ≠ 0) : + (a • (1 : Matrix ι ι ℂ)+b • C)*qmaGadgetPenaltyInverse C a b = 1 := by + rw [qmaGadgetPenaltyInverse,mul_smul_comm,qmaGadget_penalty_product C a b hC, + smul_smul,inv_mul_cancel₀ hab,one_smul] + +theorem qmaGadget_effective (A B C : Matrix ι ι ℂ) (a b c : ℂ) + (hA : A*A = 1) (hB : B*B = 1) (hAB : A*B = B*A) + (hAC : A*C = C*A) (hBC : B*C = C*B) : + (A+c • B)*qmaGadgetPenaltyInverse C a b*(A+c • B) = + (a^2-b^2)⁻¹ • + (a • ((1+c^2) • (1 : Matrix ι ι ℂ)+(2*c) • (A*B))- + b • ((1+c^2) • C+(2*c) • (A*B*C))) := by + rw [qmaGadgetPenaltyInverse,mul_smul_comm,smul_mul_assoc,mul_sub, + mul_smul_comm,mul_smul_comm,mul_one,sub_mul,smul_mul_assoc,smul_mul_assoc, + qmaGadget_pair_square A B c hA hB hAB,qmaGadget_pair_sandwich A B C c hA hB hAB hAC hBC] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetCounterterms.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetCounterterms.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd65d3c4ec60b2f3df37e227ca2f5fdfc7a3c836 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGadgetCounterterms.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGadgetAlgebra + +namespace OAI + +/-! Exact counterterms make the subdivision and three-body Schur +complements equal the intended interactions. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def qmaSubdivisionCoupling (A B : Matrix ι ι ℂ) (r J : ℂ) : Matrix ι ι ℂ := + r • (A+(-J/2) • B) + +def qmaSubdivisionCounter (rJ : ℂ) : Matrix ι ι ℂ := + (1+(-rJ/2)^2) • (1 : Matrix ι ι ℂ) + +theorem qmaSubdivision_effective (A B : Matrix ι ι ℂ) (r J : ℂ) (hr : r ≠ 0) + (hA : A*A = 1) (hB : B*B = 1) (hAB : A*B = B*A) : + qmaSubdivisionCounter J- + qmaSubdivisionCoupling A B r J*((r^2)⁻¹ • (1 : Matrix ι ι ℂ))* + qmaSubdivisionCoupling A B r J = J • (A*B) := by + unfold qmaSubdivisionCounter qmaSubdivisionCoupling + have hs : r * (r^2)⁻¹ * r = 1 := by field_simp + have hp : (r • (A+(-J/2) • B))*((r^2)⁻¹ • (1 : Matrix ι ι ℂ))* + (r • (A+(-J/2) • B)) = (A+(-J/2) • B)*(A+(-J/2) • B) := by + simp only [smul_mul_assoc, mul_smul_comm, mul_one, smul_smul] + rw [← mul_assoc, hs, one_smul] + rw [hp, qmaGadget_pair_square A B (-J/2) hA hB hAB] + module + +def qmaThirdGadgetWeight (r J : ℂ) : ℂ := J*((r^3)^2-(r^2)^2)/(2*r^6) + +def qmaThirdGadgetCoupling (A B : Matrix ι ι ℂ) (r J : ℂ) : Matrix ι ι ℂ := + r^2 • (A+qmaThirdGadgetWeight r J • B) + +def qmaThirdGadgetCounter (A B C : Matrix ι ι ℂ) (r J : ℂ) : Matrix ι ι ℂ := + let c := qmaThirdGadgetWeight r J + ((r^2*r^2)*((r^3)^2-(r^2)^2)⁻¹) • + (r^3 • ((1+c^2) • (1 : Matrix ι ι ℂ)+(2*c) • (A*B))- + r^2 • ((1+c^2) • C)) + +theorem qmaThirdGadget_effective (A B C : Matrix ι ι ℂ) (r J : ℂ) + (hr : r ≠ 0) (hden : (r^3)^2-(r^2)^2 ≠ 0) + (hA : A*A = 1) (hB : B*B = 1) (hAB : A*B = B*A) + (hAC : A*C = C*A) (hBC : B*C = C*B) : + qmaThirdGadgetCounter A B C r J- + qmaThirdGadgetCoupling A B r J*qmaGadgetPenaltyInverse C (r^3) (r^2)* + qmaThirdGadgetCoupling A B r J = J • (A*B*C) := by + have he : qmaThirdGadgetCounter A B C r J- + qmaThirdGadgetCoupling A B r J*qmaGadgetPenaltyInverse C (r^3) (r^2)* + qmaThirdGadgetCoupling A B r J = + ((r^2*r^2)*((r^3)^2-(r^2)^2)⁻¹*r^2*(2*qmaThirdGadgetWeight r J)) • (A*B*C) := by + unfold qmaThirdGadgetCounter qmaThirdGadgetCoupling + rw [smul_mul_assoc,mul_smul_comm,smul_mul_assoc,smul_smul, + qmaGadget_effective A B C (r^3) (r^2) (qmaThirdGadgetWeight r J) hA hB hAB hAC hBC] + module + rw [he] + have hc : (r^2*r^2)*((r^3)^2-(r^2)^2)⁻¹*r^2*(2*qmaThirdGadgetWeight r J) = J := by + unfold qmaThirdGadgetWeight + have h2 : r^2-1 ≠ 0 := by + intro h + apply hden + calc + _ = r^4*(r^2-1) := by ring + _ = 0 := by rw [h, mul_zero] + field_simp [hr, hden, h2] + rw [hc] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateArrival.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateArrival.lean new file mode 100644 index 0000000000000000000000000000000000000000..943b6586831b305671dac99fd7f8d9903f241d8f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateArrival.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridLocality + +namespace OAI + +/-! The insertion column is an actual operand, so adjacent gates remain close to the sweep. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +theorem qmaGateSites_nonempty (work : ℕ) (g : QMAGate) : (qmaGateSites work g).Nonempty := by + cases g <;> simp [qmaGateSites] + +def qmaGateArrivalIndex (work : ℕ) (e : Equiv.Perm (Fin (work+1))) (g : QMAGate) : + Fin (work+1) := + ⟨qmaGateCut work e g-1,by + have h := qmaGateCut_le work e g + have hp : 0 < qmaGateCut work e g := by unfold qmaGateCut; omega + omega⟩ + +def qmaGateArrivalColumn (work : ℕ) (e : Equiv.Perm (Fin (work+1))) (g : QMAGate) : + Fin (work+1) := e (qmaGateArrivalIndex work e g) + +theorem qmaGateArrivalColumn_mem (work : ℕ) (e : Equiv.Perm (Fin (work+1))) (g : QMAGate) : + qmaGateArrivalColumn work e g ∈ qmaGateSites work g := by + obtain ⟨i,hi,he⟩ := Finset.exists_mem_eq_sup (qmaGateSites work g) + (qmaGateSites_nonempty work g) (fun j => (e.symm j).val) + have heq : qmaGateArrivalIndex work e g = e.symm i := by + apply Fin.ext + change (qmaGateSites work g).sup (fun j => (e.symm j).val)+1-1 = _ + omega + simpa only [qmaGateArrivalColumn,heq,Equiv.apply_symm_apply] using hi + +theorem qmaGateArrivalColumn_near (work : ℕ) (e : Equiv.Perm (Fin (work+1))) + (g : QMAGate) (hg : g.WellFormed (work+1)) (ha : g.Adjacent) + (i : Fin (work+1)) (hi : i ∈ qmaGateSites work g) : + i.val ≤ (qmaGateArrivalColumn work e g).val+1 ∧ + (qmaGateArrivalColumn work e g).val ≤ i.val+1 := by + obtain ⟨lo,hlo⟩ := qmaAdjacentGate_window work g hg ha + have h1 := hlo i hi + have h2 := hlo _ (qmaGateArrivalColumn_mem work e g) + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateCode.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cc48c66115ed8934177508da11b4076f45e400a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateCode.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCircuitCode + +namespace OAI + +/-! Literal constructors and coordinate selectors for the fixed H/T/CNOT +alphabet used by the nearest-neighbor circuit preprocessor. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCircuitCode +open ExactQuantumFactoring.BitStackProgram + +def gateTag : QMAGate → ℕ + | .hadamard _ => 0 + | .phaseT _ => 1 + | .controlledNot _ _ => 2 + +def gateLeft : QMAGate → ℕ + | .hadamard i => i + | .phaseT i => i + | .controlledNot i _ => i + +def gateRight : QMAGate → ℕ + | .hadamard i => i + | .phaseT i => i + | .controlledNot _ j => j + +noncomputable def hadamardProgram : Procedure Nat.bits gateCode QMAGate.hadamard := + ((Procedure.sumLeft (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits)).comp + (Procedure.sumLeft Nat.bits Nat.bits)).result (by intro i; rfl) + +noncomputable def phaseProgram : Procedure Nat.bits gateCode QMAGate.phaseT := + ((Procedure.sumLeft (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits)).comp + (Procedure.sumRight Nat.bits Nat.bits)).result (by intro i; rfl) + +noncomputable def cnotProgram : Procedure (prodCode Nat.bits Nat.bits) gateCode + (fun p => QMAGate.controlledNot p.1 p.2) := + (Procedure.sumRight (sumCode Nat.bits Nat.bits) (prodCode Nat.bits Nat.bits)).result + (by intro p; rfl) + +noncomputable def gateTagProgram : Procedure gateCode Nat.bits gateTag := by + let h := Procedure.constant Nat.bits Nat.bits 0 + let t := Procedure.constant Nat.bits Nat.bits 1 + let c := Procedure.constant (prodCode Nat.bits Nat.bits) Nat.bits 2 + exact ((Procedure.casesSum (Procedure.casesSum h t) c).precompose qmaGateEquiv).congrFun + (by intro g; cases g <;> rfl) + +noncomputable def gateLeftProgram : Procedure gateCode Nat.bits gateLeft := + ((Procedure.casesSum (Procedure.casesSum (Procedure.identity Nat.bits) (Procedure.identity Nat.bits)) + (Procedure.first Nat.bits Nat.bits)).precompose qmaGateEquiv).congrFun + (by intro g; cases g <;> rfl) + +noncomputable def gateRightProgram : Procedure gateCode Nat.bits gateRight := + ((Procedure.casesSum (Procedure.casesSum (Procedure.identity Nat.bits) (Procedure.identity Nat.bits)) + (Procedure.second Nat.bits Nat.bits)).precompose qmaGateEquiv).congrFun + (by intro g; cases g <;> rfl) + +def swapList (a : ℕ) : List QMAGate := + [.controlledNot a (a+1),.controlledNot (a+1) a,.controlledNot a (a+1)] + +theorem swapList_reverse (a : ℕ) : (swapList a).reverse=swapList a := rfl + +noncomputable def swapListProgram : Procedure Nat.bits (listCode gateCode) swapList := by + let a := Procedure.identity Nat.bits + let b := Procedure.successor + let forward := cnotProgram.comp (a.pair b) + let backward := cnotProgram.comp (b.pair a) + let nil := Procedure.constant Nat.bits (listCode gateCode) [] + let one := (Procedure.listCons gateCode).comp (forward.pair nil) + let two := (Procedure.listCons gateCode).comp (backward.pair one) + exact (Procedure.listCons gateCode).comp (forward.pair two) + +end ContinuumCoulomb.QuantumCircuitCode + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateEntryProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateEntryProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d1eedc7cbfa8ccf05b1586ebcd3a044f93c6444 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateEntryProgram.lean @@ -0,0 +1,288 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryBitProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateScalarReduction + +namespace OAI + +/-! Exact gate entries from a bounded register scan. Work is unary, addresses +and support labels are binary, and each quantum bit is read from the supplied +small support table. No sum over ambient configurations occurs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumGateEntryProgram +open ExactQuantumFactoring.BitStackProgram QuantumAlgebraicScalar QuantumCircuitCode +open scoped Classical + +abbrev Input := ℕ × (ℕ × (QMAGate × QuantumHistoryBitProgram.Data)) +def inputCode : Input → List Bool := prodCode unaryCode + (prodCode Nat.bits (prodCode gateCode QuantumHistoryBitProgram.dataCode)) + +def left (x : Input) : ℕ := gateLeft x.2.2.1 % (x.1+1) +def right (x : Input) : ℕ := gateRight x.2.2.1 % (x.1+1) +def row (x : Input) (k : ℕ) : Fin 2 := QuantumHistoryBitProgram.row x.2.2.2 (x.2.1+k) +def column (x : Input) (k : ℕ) : Fin 2 := QuantumHistoryBitProgram.column x.2.2.2 (x.2.1+k) + +def point (x : Input) (k : ℕ) : Bool := + if gateTag x.2.2.1 = 2 then + decide ((row x k).val = + if k = right x ∧ (column x (left x)).val = 1 then + 1-(column x k).val else (column x k).val) + else decide (k=left x) || decide ((row x k).val=(column x k).val) + +def allWork (x : Input) : Bool := ((List.range (x.1+1)).map (point x)).all id + +theorem allWork_iff (x : Input) : allWork x = true ↔ + ∀ i : Fin (x.1+1), point x i.val = true := by + simp only [allWork,List.all_map,List.all_eq_true,List.mem_range,Function.comp_apply,id_eq] + exact ⟨fun h i => h i.val i.isLt,fun h i hi => h ⟨i,hi⟩⟩ + +theorem allWork_single (x : Input) (hg : gateTag x.2.2.1 ≠ 2) : + allWork x = true ↔ ∀ i : Fin (x.1+1), + i ≠ qmaQubit x.1 (gateLeft x.2.2.1) → row x i.val=column x i.val := by + rw [allWork_iff] + simp only [point,ite_eq_right hg,Bool.or_eq_true,decide_eq_true_eq] + constructor + · intro h i hi + rcases h i with he | he + · exact False.elim (hi (Fin.ext he)) + · exact Fin.ext he + · intro h i + by_cases hi : i=qmaQubit x.1 (gateLeft x.2.2.1) + · exact Or.inl (congrArg Fin.val hi) + · exact Or.inr (congrArg Fin.val (h i hi)) + +private theorem swap_val (b : Fin 2) : (Equiv.swap (0 : Fin 2) 1 b).val = 1-b.val := by + fin_cases b <;> decide + +theorem allWork_cnot (work base a b : ℕ) (d : QuantumHistoryBitProgram.Data) : + allWork (work,base,.controlledNot a b,d) = true ↔ + (fun i : Fin (work+1) => row (work,base,.controlledNot a b,d) i.val) = + qmaControlledNot work (qmaQubit work a) (qmaQubit work b) + (fun i => column (work,base,.controlledNot a b,d) i.val) := by + rw [allWork_iff,funext_iff] + apply forall_congr' + intro i + change decide ((row (work,base,.controlledNot a b,d) i.val).val = + if i.val=b%(work+1) ∧ (column (work,base,.controlledNot a b,d) (a%(work+1))).val=1 then + 1-(column (work,base,.controlledNot a b,d) i.val).val + else (column (work,base,.controlledNot a b,d) i.val).val)=true ↔ _ + rw [decide_eq_true_eq] + have ht : (i.val=b%(work+1)) ↔ i=qmaQubit work b := + ⟨fun h => Fin.ext h,fun h => congrArg Fin.val h⟩ + have hc : (column (work,base,.controlledNot a b,d) (a%(work+1))).val=1 ↔ + column (work,base,.controlledNot a b,d) (a%(work+1))=1 := + ⟨fun h => Fin.ext h,fun h => congrArg Fin.val h⟩ + have he : (i.val=b%(work+1) ∧ + (column (work,base,.controlledNot a b,d) (a%(work+1))).val=1) ↔ + (i=qmaQubit work b ∧ + column (work,base,.controlledNot a b,d) (a%(work+1))=1) := and_congr ht hc + by_cases h : i=qmaQubit work b ∧ + column (work,base,.controlledNot a b,d) (a%(work+1))=1 + · have hr : qmaControlledNot work (qmaQubit work a) (qmaQubit work b) + (fun j => column (work,base,.controlledNot a b,d) j.val) i = + Equiv.swap (0:Fin 2) 1 (column (work,base,.controlledNot a b,d) i.val) := + ite_eq_left h + rw [ite_eq_left (he.mpr h),hr,Fin.ext_iff,swap_val] + · have hr : qmaControlledNot work (qmaQubit work a) (qmaQubit work b) + (fun j => column (work,base,.controlledNot a b,d) j.val) i = + column (work,base,.controlledNot a b,d) i.val := ite_eq_right h + rw [ite_eq_right (mt he.mp h),hr,Fin.ext_iff] + +def entry (x : Input) : Scalar := + if allWork x then + if gateTag x.2.2.1=0 then + QuantumAlgebraicHistory.hadamard (row x (left x)) (column x (left x)) + else if gateTag x.2.2.1=1 then + QuantumAlgebraicHistory.phaseT (row x (left x)) (column x (left x)) + else rat 1 + else rat 0 + +theorem entry_eq (work base : ℕ) (g : QMAGate) (d : QuantumHistoryBitProgram.Data) : + entry (work,base,g,d) = QuantumAlgebraicHistory.gate work g + (fun i => row (work,base,g,d) i.val) (fun i => column (work,base,g,d) i.val) := by + cases g with + | hadamard j => + rw [QuantumGateScalarReduction.hadamard_entry] + have hh := allWork_single (work,base,.hadamard j,d) (by change (0 : ℕ) ≠ 2; decide) + by_cases h : allWork (work,base,.hadamard j,d)=true + · have hv : entry (work,base,.hadamard j,d) = QuantumAlgebraicHistory.hadamard + (row (work,base,.hadamard j,d) (left (work,base,.hadamard j,d))) + (column (work,base,.hadamard j,d) (left (work,base,.hadamard j,d))) := by + unfold entry + rw [ite_eq_left h] + exact ite_eq_left rfl + refine hv.trans ?_ + symm + exact ite_eq_left (hh.mp h) + · have hv : entry (work,base,.hadamard j,d)=rat 0 := ite_eq_right h + refine hv.trans ?_ + symm + exact ite_eq_right (mt hh.mpr h) + | phaseT j => + rw [QuantumGateScalarReduction.phaseT_entry] + have hh := allWork_single (work,base,.phaseT j,d) (by change (1 : ℕ) ≠ 2; decide) + by_cases h : allWork (work,base,.phaseT j,d)=true + · have hv : entry (work,base,.phaseT j,d) = QuantumAlgebraicHistory.phaseT + (row (work,base,.phaseT j,d) (left (work,base,.phaseT j,d))) + (column (work,base,.phaseT j,d) (left (work,base,.phaseT j,d))) := by + unfold entry + rw [ite_eq_left h] + rw [ite_eq_right (by change (1 : ℕ) ≠ 0; decide)] + exact ite_eq_left rfl + refine hv.trans ?_ + symm + exact ite_eq_left (hh.mp h) + · have hv : entry (work,base,.phaseT j,d)=rat 0 := ite_eq_right h + refine hv.trans ?_ + symm + exact ite_eq_right (mt hh.mpr h) + | controlledNot a b => + have hh := allWork_cnot work base a b d + unfold entry QuantumAlgebraicHistory.gate + simp only [gateTag] + by_cases h : allWork (work,base,.controlledNot a b,d)=true + · simp [h,hh.mp h] + · have hn := mt hh.mpr h + simp [h,hn] + +noncomputable opaque leftProgram : Procedure inputCode Nat.bits left := by + let work := Procedure.unaryToBits.comp + (Procedure.first unaryCode (prodCode Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode))) + let tail := Procedure.second unaryCode + (prodCode Nat.bits (prodCode gateCode QuantumHistoryBitProgram.dataCode)) + let tail' := (Procedure.second Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode)).comp tail + let gate := (Procedure.first gateCode QuantumHistoryBitProgram.dataCode).comp tail' + exact Procedure.binaryMod.comp ((gateLeftProgram.comp gate).pair + (Procedure.successor.comp work)) + +noncomputable opaque rightProgram : Procedure inputCode Nat.bits right := by + let work := Procedure.unaryToBits.comp + (Procedure.first unaryCode (prodCode Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode))) + let tail := Procedure.second unaryCode + (prodCode Nat.bits (prodCode gateCode QuantumHistoryBitProgram.dataCode)) + let tail' := (Procedure.second Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode)).comp tail + let gate := (Procedure.first gateCode QuantumHistoryBitProgram.dataCode).comp tail' + exact Procedure.binaryMod.comp ((gateRightProgram.comp gate).pair + (Procedure.successor.comp work)) + +abbrev PointInput := Input × ℕ +def pointCode : PointInput → List Bool := prodCode inputCode Nat.bits + +noncomputable opaque queryProgram : Procedure pointCode QuantumHistoryBitProgram.queryCode + (fun p => (p.1.2.1+p.2,p.1.2.2.2)) := by + let x := Procedure.first inputCode Nat.bits + let k := Procedure.second inputCode Nat.bits + let tail := (Procedure.second unaryCode + (prodCode Nat.bits (prodCode gateCode QuantumHistoryBitProgram.dataCode))).comp x + let base := (Procedure.first Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode)).comp tail + let rest := (Procedure.second Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode)).comp tail + let d := (Procedure.second gateCode QuantumHistoryBitProgram.dataCode).comp rest + exact (Procedure.binaryAdd.comp (base.pair k)).pair d + +noncomputable opaque pointRowProgram : Procedure pointCode Nat.bits + (fun p => (row p.1 p.2).val) := QuantumHistoryBitProgram.rowProgram.comp queryProgram + +noncomputable opaque pointColumnProgram : Procedure pointCode Nat.bits + (fun p => (column p.1 p.2).val) := QuantumHistoryBitProgram.columnProgram.comp queryProgram + +noncomputable opaque tagProgram : Procedure inputCode Nat.bits (fun x => gateTag x.2.2.1) := by + let tail := Procedure.second unaryCode + (prodCode Nat.bits (prodCode gateCode QuantumHistoryBitProgram.dataCode)) + let rest := (Procedure.second Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode)).comp tail + exact gateTagProgram.comp + ((Procedure.first gateCode QuantumHistoryBitProgram.dataCode).comp rest) + +noncomputable opaque pointProgram : Procedure pointCode Procedure.boolCode + (fun p => point p.1 p.2) := by + let x := Procedure.first inputCode Nat.bits + let k := Procedure.second inputCode Nat.bits + let l := leftProgram.comp x + let r := rightProgram.comp x + let s := pointRowProgram + let t := pointColumnProgram + let control := pointColumnProgram.comp (x.pair l) + let one := Procedure.constant pointCode Nat.bits 1 + let tag := tagProgram.comp x + let hit := Procedure.boolAnd.comp + ((Procedure.binaryEq.comp (k.pair r)).pair (Procedure.binaryEq.comp (control.pair one))) + let flipped := Procedure.binarySub.comp (one.pair t) + let expected := Procedure.conditional hit flipped t + let cnot := Procedure.binaryEq.comp (s.pair expected) + let single := Procedure.boolOr.comp + ((Procedure.binaryEq.comp (k.pair l)).pair (Procedure.binaryEq.comp (s.pair t))) + exact (Procedure.conditional (Procedure.binaryEq.comp + (tag.pair (Procedure.constant pointCode Nat.bits 2))) cnot single).congrFun (by + intro p + simp only [Function.comp_apply,point,decide_eq_true_eq,Bool.and_eq_true]) + +noncomputable opaque allWorkProgram : Procedure inputCode Procedure.boolCode allWork := by + let testAt : Procedure (prodCode unaryCode inputCode) Procedure.boolCode + (fun p => point p.2 p.1) := + pointProgram.comp ((Procedure.second unaryCode inputCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode inputCode))) + let count := Procedure.unarySuccessor.comp + (Procedure.first unaryCode (prodCode Nat.bits + (prodCode gateCode QuantumHistoryBitProgram.dataCode))) + exact (QuantumHistoryBitProgram.allProgram.comp + ((Procedure.tabulate (f := point) false testAt).comp + (count.pair (Procedure.identity inputCode)))).congrFun (by intro x; rfl) + +noncomputable opaque entryProgram : Procedure inputCode scalarCode entry := by + let x := Procedure.identity inputCode + let query := x.pair leftProgram + let values := (pointRowProgram.comp query).pair (pointColumnProgram.comp query) + let h := (QuantumHistoryBitProgram.matrixEntryProgram QuantumAlgebraicHistory.hadamard).comp values + let t := (QuantumHistoryBitProgram.matrixEntryProgram QuantumAlgebraicHistory.phaseT).comp values + let one := Procedure.constant inputCode scalarCode (rat 1) + let zero := Procedure.constant inputCode scalarCode (rat 0) + let isH := Procedure.binaryEq.comp (tagProgram.pair (Procedure.constant inputCode Nat.bits 0)) + let isT := Procedure.binaryEq.comp (tagProgram.pair (Procedure.constant inputCode Nat.bits 1)) + exact (Procedure.conditional allWorkProgram + (Procedure.conditional isH h (Procedure.conditional isT t one)) zero).congrFun (by + intro x + simp only [Function.comp_apply,id_eq,entry,decide_eq_true_eq,QuantumHistoryBitProgram.matrixEntry] + have hs : QuantumHistoryBitProgram.bit (row x (left x)).val=row x (left x) := by + apply Fin.ext + exact Nat.mod_eq_of_lt (Fin.isLt _) + have ht : QuantumHistoryBitProgram.bit (column x (left x)).val=column x (left x) := by + apply Fin.ext + exact Nat.mod_eq_of_lt (Fin.isLt _) + rw [hs,ht]) + +noncomputable def certificate : + Turing.TM2ComputableInPolyTime inputCode scalarCode entry := entryProgram.toTM2 + +theorem entry_on_support (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (s t : Fin (QuantumOrderedSupport.sites c hT a).length → Fin 2) (g : QMAGate) : + entry (c.work,qmaHistoryReferenceWork c+1+(c.gates.length+2),g, + QuantumOrderedSupport.encodedSites c hT a, + QuantumSupportLookup.supportBits c hT a s, + QuantumSupportLookup.supportBits c hT a t) = + QuantumAlgebraicHistory.gate c.work g + (fun i => qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun j => s ((QuantumOrderedSupport.supportEquiv c hT a).symm j)) + (.inr (.inr i))) + (fun i => qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun j => t ((QuantumOrderedSupport.supportEquiv c hT a).symm j)) + (.inr (.inr i))) := by + rw [entry_eq] + congr 1 + · funext i + simpa only [row,QuantumOrderedSupport.siteNumber] using + QuantumHistoryBitProgram.row_actual c hT a s t (.inr (.inr i)) + · funext i + simpa only [column,QuantumOrderedSupport.siteNumber] using + QuantumHistoryBitProgram.column_actual c hT a s t (.inr (.inr i)) + +end ContinuumCoulomb.QuantumGateEntryProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateLocality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..639a025006564ca83c55a43548d3b85374bbce38 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateLocality.lean @@ -0,0 +1,57 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalTensor + +namespace OAI + +/-! The fixed verifier gates act on at most two actual qubits. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaGateSites (work : ℕ) : QMAGate → Finset (Fin (work+1)) + | .hadamard i => {qmaQubit work i} + | .phaseT i => {qmaQubit work i} + | .controlledNot i j => {qmaQubit work i,qmaQubit work j} + +theorem qmaGateSites_card (work : ℕ) (g : QMAGate) : (qmaGateSites work g).card ≤ 2 := by + cases g with + | hadamard i => simp [qmaGateSites] + | phaseT i => simp [qmaGateSites] + | controlledNot i j => + by_cases h : qmaQubit work i = qmaQubit work j + · simp [qmaGateSites,h] + · simp [qmaGateSites,h] + +theorem qmaGateMatrix_local (work : ℕ) (g : QMAGate) : + QMALocalOn (qmaGateSites work g) (qmaGateMatrix work g) := by + cases g with + | hadamard i => + apply qmaLocalOn_sourceTensor + intro k hk + exact ite_eq_right (by simpa only [qmaGateSites,Finset.mem_singleton] using hk) + | phaseT i => + apply qmaLocalOn_sourceTensor + intro k hk + exact ite_eq_right (by simpa only [qmaGateSites,Finset.mem_singleton] using hk) + | controlledNot i j => + let S := qmaGateSites work (.controlledNot i j) + let ci : {k // k ∈ S} := ⟨qmaQubit work i,by simp [S,qmaGateSites]⟩ + let f : QMASupportBasis S → QMASupportBasis S := fun s k => + if k.val = qmaQubit work j ∧ s ci = 1 then Equiv.swap (0:Fin 2) 1 (s k) else s k + apply qmaLocalOn_permutation S (qmaControlledNot work (qmaQubit work i) (qmaQubit work j)) f + · intro t + funext k + rfl + · intro t + funext k + have hk : k.val ≠ qmaQubit work j := by + have h := k.property + simp only [S,qmaGateSites,Finset.mem_insert,Finset.mem_singleton,not_or] at h + exact h.2 + simp [qmaSupportSplit,Equiv.piEquivPiSubtypeProd,qmaControlledNot,hk] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateProduct.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..6bb91027c6b12134da4015e1e925c2a40c26a2a8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateProduct.lean @@ -0,0 +1,43 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumWireSwap + +namespace OAI + +/-! Exact sequential products for the circuit transformations used by the sparse history. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix + +abbrev qmaGateProduct (work : ℕ) (gs : List QMAGate) : + Matrix (SourceSpinBasis (work+1)) (SourceSpinBasis (work+1)) ℂ := + qmaCircuitMatrix ⟨work,0,gs⟩ + +theorem qmaGateProduct_fold (work : ℕ) (gs : List QMAGate) + (M : Matrix (SourceSpinBasis (work+1)) (SourceSpinBasis (work+1)) ℂ) : + gs.foldl (fun A g => qmaGateMatrix work g*A) M = qmaGateProduct work gs*M := by + induction gs generalizing M with + | nil => simp [qmaGateProduct,qmaCircuitMatrix] + | cons g gs ih => + simp only [List.foldl_cons] + rw [ih] + change _ = gs.foldl (fun A g => qmaGateMatrix work g*A) (qmaGateMatrix work g*1)*M + rw [ih] + simp only [mul_one,mul_assoc] + +theorem qmaGateProduct_append (work : ℕ) (xs ys : List QMAGate) : + qmaGateProduct work (xs++ys) = qmaGateProduct work ys*qmaGateProduct work xs := by + change (xs++ys).foldl _ 1 = _ + rw [List.foldl_append,qmaGateProduct_fold] + rfl + +theorem qmaGateProduct_singleton (work : ℕ) (g : QMAGate) : + qmaGateProduct work [g] = qmaGateMatrix work g := by + simp [qmaGateProduct,qmaCircuitMatrix] + +theorem qmaGateProduct_nil (work : ℕ) : qmaGateProduct work [] = 1 := rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateScalarReduction.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateScalarReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..74990a3ad320e5d3ce43b2457f65584dcd7f9cc8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateScalarReduction.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicHistory + +namespace OAI + +/-! Exact scalar reduction of a one-site gate tensor to its active entry +and spectator equality test. This avoids an ambient spin-basis sum in the +literal history-matrix evaluator. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumGateScalarReduction +open QuantumAlgebraicScalar QuantumFixedPauli QuantumAlgebraicHistory +open scoped Classical + +@[simp] theorem mul_one (x : Scalar) : mul x (rat 1)=x := by + rcases x with ⟨⟨a,b⟩,⟨c,d⟩⟩ + simp [mul,rat,realRat,realMul,realSub,realAdd,realNeg] + +@[simp] theorem one_mul (x : Scalar) : mul (rat 1) x=x := by + rcases x with ⟨⟨a,b⟩,⟨c,d⟩⟩ + simp [mul,rat,realRat,realMul,realSub,realAdd,realNeg] + +@[simp] theorem mul_zero (x : Scalar) : mul x (rat 0)=rat 0 := by + rcases x with ⟨⟨a,b⟩,⟨c,d⟩⟩ + simp [mul,rat,realRat,realMul,realSub,realAdd,realNeg] + +@[simp] theorem zero_mul (x : Scalar) : mul (rat 0) x=rat 0 := by + rcases x with ⟨⟨a,b⟩,⟨c,d⟩⟩ + simp [mul,rat,realRat,realMul,realSub,realAdd,realNeg] + +theorem listProduct_single {α : Type} [DecidableEq α] (i : α) (z : Scalar) + (xs : List α) (hx : xs.Nodup) : + product (xs.map (fun j => if j=i then z else rat 1)) = + if i ∈ xs then z else rat 1 := by + induction xs with + | nil => simp [product] + | cons a xs ih => + by_cases ha : a=i + · subst a + have hn : i ∉ xs := (List.nodup_cons.mp hx).1 + simp [product,ih (List.nodup_cons.mp hx).2,hn] + · simp [product,ha,ih (List.nodup_cons.mp hx).2,Ne.symm ha] + +theorem listProduct_zero (xs : List Scalar) (h : rat 0 ∈ xs) : product xs=rat 0 := by + induction xs with + | nil => simp at h + | cons a xs ih => + rcases List.mem_cons.mp h with ha | hx + · subst a + simp [product] + · simp [product,ih hx] + +theorem finiteProduct_single {α : Type} [Fintype α] [DecidableEq α] + (i : α) (z : Scalar) : + finiteProduct (fun j => if j=i then z else rat 1)=z := by + have hn : (enumerate α).Nodup := + List.nodup_ofFn.mpr (Fintype.equivFin α).symm.injective + have hi : i ∈ enumerate α := + List.mem_ofFn.mpr ⟨(Fintype.equivFin α) i,(Fintype.equivFin α).symm_apply_apply i⟩ + rw [finiteProduct,listProduct_single i z _ hn,ite_eq_left hi] + +theorem finiteProduct_zero {α : Type} [Fintype α] (f : α → Scalar) + (i : α) (hi : f i=rat 0) : finiteProduct f=rat 0 := by + apply listProduct_zero + apply List.mem_map.mpr + refine ⟨i,?_,hi⟩ + exact List.mem_ofFn.mpr + ⟨(Fintype.equivFin α) i,(Fintype.equivFin α).symm_apply_apply i⟩ + +def sparseEntry {α : Type} [DecidableEq α] (i : α) + (A : Fin 2 → Fin 2 → Scalar) (s t : α → Fin 2) : Scalar := + if ∀ j, j ≠ i → s j=t j then A (s i) (t i) else rat 0 + +theorem finiteProduct_sparse {α : Type} [Fintype α] [DecidableEq α] + (i : α) (A : Fin 2 → Fin 2 → Scalar) (s t : α → Fin 2) : + finiteProduct (fun j => if j=i then A (s j) (t j) else identity (s j) (t j)) = + sparseEntry i A s t := by + by_cases h : ∀ j, j ≠ i → s j=t j + · have he : (fun j => if j=i then A (s j) (t j) else identity (s j) (t j)) = + (fun j => if j=i then A (s i) (t i) else rat 1) := by + funext j + by_cases hj : j=i + · simp [hj] + · simp [hj,identity,h j hj] + rw [he,finiteProduct_single] + exact (ite_eq_left h).symm + · obtain ⟨j,hj⟩ := not_forall.mp h + have hji : j ≠ i := fun he => hj (by simp [he]) + have hst : s j ≠ t j := fun he => hj (fun _ => he) + rw [finiteProduct_zero _ j (by simp [hji,identity,hst])] + exact (ite_eq_right h).symm + +theorem hadamard_entry (work j : ℕ) (s t : SourceSpinBasis (work+1)) : + gate work (.hadamard j) s t=sparseEntry (qmaQubit work j) hadamard s t := + finiteProduct_sparse _ _ _ _ + +theorem phaseT_entry (work j : ℕ) (s t : SourceSpinBasis (work+1)) : + gate work (.phaseT j) s t=sparseEntry (qmaQubit work j) phaseT s t := + finiteProduct_sparse _ _ _ _ + +end ContinuumCoulomb.QuantumGateScalarReduction + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateUnitary.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateUnitary.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cc1216d32d0fffc6010d14cc9542940f6f86985 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGateUnitary.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumVerifier + +namespace OAI + +/-! Exact unitarity of the fixed verifier gates, needed for the +circuit-to-Hamiltonian construction. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators + +theorem qmaHadamard_gram : qmaHadamard.conjTranspose * qmaHadamard = 1 := by + have hs : (starRingEnd ℂ) bellScale = bellScale := bellScale_star + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaHadamard,Matrix.mul_apply,Matrix.conjTranspose_apply, + Fin.sum_univ_succ,bellScale_star,star_mul,hs] <;> + ring_nf <;> norm_num [bellScale_sq,hs] + +theorem qmaPhaseT_gram : qmaPhaseT.conjTranspose * qmaPhaseT = 1 := by + have hs : (starRingEnd ℂ) bellScale = bellScale := bellScale_star + ext a b + fin_cases a <;> fin_cases b <;> + norm_num [qmaPhaseT,Matrix.mul_apply,Matrix.conjTranspose_apply, + Fin.sum_univ_succ,bellScale_star,star_mul,hs] + ring_nf + norm_num [bellScale_sq,hs] + +theorem sourceTensor_conjTranspose (n : ℕ) (M : Fin n → Matrix (Fin 2) (Fin 2) ℂ) : + (sourceTensor n M).conjTranspose = sourceTensor n (fun i => (M i).conjTranspose) := by + ext s t + simp [sourceTensor,Matrix.conjTranspose_apply] + +theorem sourceTensor_gram (n : ℕ) (M : Fin n → Matrix (Fin 2) (Fin 2) ℂ) + (hM : ∀ i, (M i).conjTranspose * M i = 1) : + (sourceTensor n M).conjTranspose * sourceTensor n M = 1 := by + rw [sourceTensor_conjTranspose,sourceTensor_mul] + simp_rw [hM] + exact sourceTensor_one n + +theorem qmaControlledNot_involutive (work : ℕ) (control target : Fin (work+1)) + (hct : control ≠ target) : Function.Involutive (qmaControlledNot work control target) := by + intro s + have hc : qmaControlledNot work control target s control = s control := by + simp [qmaControlledNot,hct] + funext i + change (if i = target ∧ qmaControlledNot work control target s control = 1 then + Equiv.swap (0:Fin 2) 1 (qmaControlledNot work control target s i) + else qmaControlledNot work control target s i) = s i + rw [hc] + by_cases hi : i = target + · subst i + by_cases hs : s control = 1 <;> simp [qmaControlledNot,hs] + · simp [hi,qmaControlledNot] + +theorem qmaGateMatrix_gram (work : ℕ) (g : QMAGate) (hg : g.WellFormed (work+1)) : + (qmaGateMatrix work g).conjTranspose * qmaGateMatrix work g = 1 := by + classical + cases g with + | hadamard i => + apply sourceTensor_gram + intro k + split_ifs <;> simp [qmaHadamard_gram] + | phaseT i => + apply sourceTensor_gram + intro k + split_ifs <;> simp [qmaPhaseT_gram] + | controlledNot i j => + have hij : qmaQubit work i ≠ qmaQubit work j := by + intro heq + have hval := congrArg Fin.val heq + simp only [qmaQubit,Nat.mod_eq_of_lt hg.1,Nat.mod_eq_of_lt hg.2.1] at hval + exact hg.2.2 hval + have hf := qmaControlledNot_involutive work (qmaQubit work i) (qmaQubit work j) hij + ext s t + change (∑ b, star (if b = qmaControlledNot work (qmaQubit work i) (qmaQubit work j) s + then (1:ℂ) else 0) * + (if b = qmaControlledNot work (qmaQubit work i) (qmaQubit work j) t then 1 else 0)) = + if s = t then 1 else 0 + simp only [apply_ite,star_one,star_zero] + rw [Finset.sum_eq_single (qmaControlledNot work (qmaQubit work i) (qmaQubit work j) s)] + · simp [hf.injective.eq_iff] + · intro b _hb hbs + simp [hbs] + · simp + +theorem qmaCircuitMatrix_gram (c : QMACircuit) (hc : c.WellFormed) : + (qmaCircuitMatrix c).conjTranspose * qmaCircuitMatrix c = 1 := by + have hfold (gs : List QMAGate) (hgs : ∀ g ∈ gs, g.WellFormed (c.work+1)) + (M : Matrix (SourceSpinBasis (c.work+1)) (SourceSpinBasis (c.work+1)) ℂ) + (hM : M.conjTranspose*M = 1) : + (gs.foldl (fun A g => qmaGateMatrix c.work g*A) M).conjTranspose * + gs.foldl (fun A g => qmaGateMatrix c.work g*A) M = 1 := by + induction gs generalizing M with + | nil => exact hM + | cons g gs ih => + apply ih (fun q hq => hgs q (List.mem_cons_of_mem g hq)) + rw [Matrix.conjTranspose_mul] + calc + M.conjTranspose*(qmaGateMatrix c.work g).conjTranspose*(qmaGateMatrix c.work g*M) = + M.conjTranspose*((qmaGateMatrix c.work g).conjTranspose*qmaGateMatrix c.work g)*M := by + noncomm_ring + _ = 1 := by rw [qmaGateMatrix_gram c.work g (hgs g (List.mem_cons_self)),mul_one,hM] + exact hfold c.gates hc.2 1 (by simp) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGates.lean new file mode 100644 index 0000000000000000000000000000000000000000..65d77c222d9c027a9c0d5197668118e07850c610 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGates.lean @@ -0,0 +1,121 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumVerifier +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.SpinMatrixNorm + +namespace OAI + +/-! Unitarity of the actual finite H,T,CNOT verifier circuits. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators + +theorem qmaHadamard_gram : qmaHadamard.conjTranspose * qmaHadamard = 1 := by + have hraw : (!![1, 1; 1, -1] : Matrix (Fin 2) (Fin 2) ℂ).conjTranspose * + !![1, 1; 1, -1] = (2 : ℂ) • 1 := by + ext i j + fin_cases i <;> fin_cases j <;> norm_num [Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_two] + unfold qmaHadamard + rw [Matrix.conjTranspose_smul, bellScale_star, smul_mul_assoc, mul_smul_comm, + hraw, smul_smul, smul_smul, mul_assoc, bellScale_twice_sq, one_smul] + +theorem qmaPhaseT_gram : qmaPhaseT.conjTranspose * qmaPhaseT = 1 := by + have hz : star (bellScale * (1 + Complex.I)) * (bellScale * (1 + Complex.I)) = 1 := by + have hI : star Complex.I = -Complex.I := by simp + simp only [star_mul, bellScale_star, star_add, star_one, hI] + calc + _ = bellScale ^ 2 * (1 - Complex.I ^ 2) := by ring + _ = 1 := by rw [Complex.I_sq, bellScale_sq]; norm_num + ext i j + fin_cases i <;> fin_cases j + · norm_num [qmaPhaseT, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_two] + · norm_num [qmaPhaseT, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_two] + · norm_num [qmaPhaseT, Matrix.mul_apply, Matrix.conjTranspose_apply, Fin.sum_univ_two] + · change (qmaPhaseT.conjTranspose * qmaPhaseT) (1 : Fin 2) (1 : Fin 2) = 1 + rw [Matrix.mul_apply, Fin.sum_univ_two] + change star (0 : ℂ) * 0 + + star (bellScale * (1 + Complex.I)) * (bellScale * (1 + Complex.I)) = 1 + simpa only [star_zero, zero_mul, zero_add] using hz + +theorem qmaLocal_gram (n : ℕ) (i : Fin n) (M : Matrix (Fin 2) (Fin 2) ℂ) + (hM : M.conjTranspose * M = 1) : + (sourceTensor n (fun k => if k = i then M else 1)).conjTranspose * + sourceTensor n (fun k => if k = i then M else 1) = 1 := by + rw [sourceTensor_star, sourceTensor_mul] + have h (k : Fin n) : (if k = i then M else 1).conjTranspose * + (if k = i then M else 1) = 1 := by + by_cases hk : k = i <;> simp [hk, hM] + simp_rw [h] + exact sourceTensor_one n + +theorem qmaControlledNot_involutive (work : ℕ) (control target : Fin (work + 1)) + (hne : control ≠ target) : Function.Involutive (qmaControlledNot work control target) := by + have hcontrol (s : SourceSpinBasis (work + 1)) : + qmaControlledNot work control target s control = s control := by + simp [qmaControlledNot, hne] + intro s + funext i + change (if i = target ∧ qmaControlledNot work control target s control = 1 then + Equiv.swap (0 : Fin 2) 1 (qmaControlledNot work control target s i) + else qmaControlledNot work control target s i) = s i + rw [hcontrol] + unfold qmaControlledNot + by_cases hi : i = target ∧ s control = 1 + · simp [hi, Equiv.swap_apply_self] + · simp [hi] + +theorem qmaPermutation_gram {α : Type*} [Fintype α] [DecidableEq α] + (f : α → α) (hf : Function.Injective f) : + let M : Matrix α α ℂ := fun s t => if s = f t then 1 else 0 + M.conjTranspose * M = 1 := by + dsimp only + ext s t + change (∑ k : α, star (if k = f s then (1 : ℂ) else 0) * + (if k = f t then 1 else 0)) = if s = t then 1 else 0 + simp [hf.eq_iff, eq_comm] + +theorem qmaQubit_val {work i : ℕ} (hi : i < work + 1) : (qmaQubit work i).val = i := + Nat.mod_eq_of_lt hi + +theorem qmaGateMatrix_gram (work : ℕ) (g : QMAGate) (hg : g.WellFormed (work + 1)) : + (qmaGateMatrix work g).conjTranspose * qmaGateMatrix work g = 1 := by + cases g with + | hadamard i => exact qmaLocal_gram _ _ _ qmaHadamard_gram + | phaseT i => exact qmaLocal_gram _ _ _ qmaPhaseT_gram + | controlledNot i j => + have hne : qmaQubit work i ≠ qmaQubit work j := by + intro h + have hv := congrArg Fin.val h + rw [qmaQubit_val hg.1, qmaQubit_val hg.2.1] at hv + exact hg.2.2 hv + exact qmaPermutation_gram _ (qmaControlledNot_involutive work _ _ hne).injective + +theorem qmaCircuitMatrix_gram (c : QMACircuit) (hc : c.WellFormed) : + (qmaCircuitMatrix c).conjTranspose * qmaCircuitMatrix c = 1 := by + have hfold (gs : List QMAGate) (hgs : ∀ g ∈ gs, g.WellFormed (c.work + 1)) + (M : Matrix (SourceSpinBasis (c.work + 1)) (SourceSpinBasis (c.work + 1)) ℂ) + (hM : M.conjTranspose * M = 1) : + (gs.foldl (fun N g => qmaGateMatrix c.work g * N) M).conjTranspose * + gs.foldl (fun N g => qmaGateMatrix c.work g * N) M = 1 := by + induction gs generalizing M with + | nil => exact hM + | cons g gs ih => + apply ih (fun g' hg' => hgs g' (List.mem_cons_of_mem g hg')) + calc + (qmaGateMatrix c.work g * M).conjTranspose * (qmaGateMatrix c.work g * M) = + M.conjTranspose * ((qmaGateMatrix c.work g).conjTranspose * qmaGateMatrix c.work g) * M := by + rw [Matrix.conjTranspose_mul] + noncomm_ring + _ = 1 := by rw [qmaGateMatrix_gram c.work g (hgs g (List.mem_cons_self)), mul_one, hM] + exact hfold c.gates hc.2 1 (by simp) + +theorem qmaCircuit_preserves_norm (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis (c.work + 1))) : + ‖spinMatrixOperator (qmaCircuitMatrix c) psi‖ = ‖psi‖ := + spinMatrixOperator_unitary_norm_map _ (qmaCircuitMatrix_gram c hc) psi + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGeometryPowers.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGeometryPowers.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfe7cd10f2129b2f769c9bd052aa16e339406b15 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGeometryPowers.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySizeBounds + +namespace OAI + +/-! One uniform power bounds all finite geometric inputs of the actual +history-to-lattice coefficient program. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumOrderedSourceIndex QuantumForkList QuantumPaddedLabelProgram + +attribute [local irreducible] spatialDensity + +def geometryEnvelope (A B D R n : ℕ) : ℕ := + rawBondFactor*n+spatialSizeFactor D*n+spatialSizeFactor D*n*R+ + boxFactor A B*(n+1)+1 + +private theorem geometryEnvelope_parts (A B D R n : ℕ) : + rawBondFactor*n ≤ geometryEnvelope A B D R n ∧ + spatialSizeFactor D*n ≤ geometryEnvelope A B D R n ∧ + spatialSizeFactor D*n*R ≤ geometryEnvelope A B D R n ∧ + boxFactor A B*(n+1) ≤ geometryEnvelope A B D R n := by + unfold geometryEnvelope + omega + +theorem geometryEnvelope_power (A B D R : ℕ) : ∃ k : ℕ, ∀ n, + geometryEnvelope A B D R n ≤ (n+2)^k := by + let p : Polynomial ℕ := Polynomial.C rawBondFactor*Polynomial.X+ + Polynomial.C (spatialSizeFactor D)*Polynomial.X+ + Polynomial.C (spatialSizeFactor D*R)*Polynomial.X+ + Polynomial.C (boxFactor A B)*(Polynomial.X+1)+1 + obtain ⟨k,hk⟩ := natPolynomial_power_bound p + refine ⟨k,fun n => ?_⟩ + have h := hk n + simp only [p,Polynomial.eval_add,Polynomial.eval_mul, + Polynomial.eval_X,Polynomial.eval_C,Polynomial.eval_one] at h + convert h using 1; unfold geometryEnvelope; ring + +private theorem crossing_card_bound {A B R : ℕ} (M : QMASpatialExchangeModel A B) + (hA : 0 < A) (hd : ∀ v, qmaGraphDegree M.left M.right v ≤ 3) + (hR : QMASpatialExchangeModel.routeLengthBound A B=R) : + (M.portRouteData hA hd).crossingCells.card ≤ Fintype.card M.Term*R := by + have h := (M.portRouteData hA hd).crossingCells_card_le (M.bufferedPath_length hd) + change _ ≤ Fintype.card M.Term*QMASpatialExchangeModel.routeLengthBound A B at h + rw [hR] at h + exact h + +theorem model_geometry_power : ∃ k : ℕ, ∀ (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ), + (input c hc hT hne N).bonds.length ≤ (qubitCount (qmaSparseCircuit c)+2)^k ∧ + Fintype.card (model c hc hT hne N).Term ≤ (qubitCount (qmaSparseCircuit c)+2)^k ∧ + ((model c hc hT hne N).portRouteData finalDensity_pos + (model_degree c hc hT hne N)).crossingCells.card ≤ + (qubitCount (qmaSparseCircuit c)+2)^k ∧ + 256*(model c hc hT hne N).bufferedWidth ≤ (qubitCount (qmaSparseCircuit c)+2)^k ∧ + 256*(model c hc hT hne N).bufferedHeight ≤ (qubitCount (qmaSparseCircuit c)+2)^k := by + obtain ⟨k,hk⟩ := geometryEnvelope_power (spatialDensity rawDensity historyDegree) + (27*spatialDensity rawDensity historyDegree) historyDegree routeRounds + refine ⟨k,fun c hc hT hne N => ?_⟩ + have hb := history_bonds_linear (qmaSparseCircuit c) hT N + rw [← input_bonds c hc hT hne N] at hb + have hs := model_size_linear c hc hT hne N + have he : Fintype.card (model c hc hT hne N).Term ≤ + spatialSizeFactor historyDegree*qubitCount (qmaSparseCircuit c) := by omega + have hx := model_box_bound (model c hc hT hne N) + (model_rows_bound c hc hT hne N) (model_width_bound c hc hT hne N) + have hr := crossing_card_bound (model c hc hT hne N) finalDensity_pos + (model_degree c hc hT hne N) routeRounds_eq + have hr' : ((model c hc hT hne N).portRouteData finalDensity_pos + (model_degree c hc hT hne N)).crossingCells.card ≤ + spatialSizeFactor historyDegree*qubitCount (qmaSparseCircuit c)*routeRounds := + hr.trans (Nat.mul_le_mul_right routeRounds he) + have hp := hk (qubitCount (qmaSparseCircuit c)) + obtain ⟨hb',he',hr'',hx'⟩ := geometryEnvelope_parts (spatialDensity rawDensity historyDegree) + (27*spatialDensity rawDensity historyDegree) historyDegree routeRounds + (qubitCount (qmaSparseCircuit c)) + exact ⟨hb.trans (hb'.trans hp),he.trans (he'.trans hp),hr'.trans (hr''.trans hp), + hx.1.trans (hx'.trans hp),hx.2.trans (hx'.trans hp)⟩ + +theorem outputCoefficientNat_one (m D L T : ℕ) : 1 ≤ outputCoefficientNat m D L T := by + have h (M L T k : ℕ) (hL : 1 ≤ L) : 1 ≤ envelopeNat M L T k := by + induction k with + | zero => exact hL + | succ k ih => dsimp only [envelopeNat,coefficientNat]; omega + exact h _ _ _ _ (by dsimp only [coefficientNat]; omega) + +theorem outputCoefficientNat_of_power {D a n k m L T : ℕ} + (h : ∀ x : QuantumCoefficientPrograms.Input, outputCoefficientNat x.1 D x.2.1 x.2.2 ≤ + ((QuantumCoefficientPrograms.inputCode x).length+2)^a) + (hm : m ≤ (n+2)^k) (hL : L ≤ (n+2)^k) (hT : T ≤ (n+2)^k) : + outputCoefficientNat m D L T ≤ (n+2)^((k+4)*a) := + QuantumCoefficientPrograms.input_function_power h hm hL hT + +theorem latticeBound_of_power {D a n k m r L T : ℕ} + (h : ∀ x : QuantumCoefficientPrograms.LatticeInput, + QuantumCoefficientPrograms.latticeBound D x.1 x.2.1 x.2.2.1 x.2.2.2 ≤ + ((QuantumCoefficientPrograms.latticeInputCode x).length+2)^a) + (hm : m ≤ (n+2)^k) (hr : r ≤ (n+2)^k) + (hL : L ≤ (n+2)^k) (hT : T ≤ (n+2)^k) : + QuantumCoefficientPrograms.latticeBound D m r L T ≤ (n+2)^((k+4)*a) := + QuantumCoefficientPrograms.lattice_function_power h hm hr hL hT + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphCoefficientBound.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphCoefficientBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..86346f90c555f32df031fac0f9b31c149652ae9f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphCoefficientBound.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingCoefficientBound +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCrossingSelection +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMergeEdges + +namespace OAI + +/-! Summing parallel edges or selecting the two interactions of a crossing +preserves polynomial coefficient bounds. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +namespace QMARationalExchangeGraph +variable (G : QMARationalExchangeGraph) + +theorem merge_coefficientBound {m L : ℝ} (hm : (Fintype.card G.Edge:ℝ) ≤ m) + (hL : 1 ≤ L) (hc : G.CoefficientBound L) : + G.merge.CoefficientBound ((m+1)*L) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + constructor + · change |(G.constant:ℝ)| ≤ _ + nlinarith [hc.1] + · intro p + dsimp only [merge] + push_cast + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _e : G.Edge, L := Finset.sum_le_sum (fun e _ => by + split_ifs + · exact hc.2 e + · simpa using hL0) + _ = (Fintype.card G.Edge:ℝ)*L := by simp + _ ≤ m*L := mul_le_mul_of_nonneg_right hm hL0 + _ ≤ (m+1)*L := by nlinarith + +end QMARationalExchangeGraph + +namespace QMARationalCrossingSelection +variable {G : QMARationalExchangeGraph} {r : ℕ} (S : QMARationalCrossingSelection G r) + +theorem weight_abs_bound {m L : ℝ} (hm : (Fintype.card G.Edge:ℝ) ≤ m) + (hL : 1 ≤ L) (hc : G.CoefficientBound L) (p : Fin r × Fin 2) : + |(S.weight p:ℝ)| ≤ m*L := by + have hL0 : 0 ≤ L := by linarith + have hcard : (Fintype.card {e : G.Edge // S.tag e = some p}:ℝ) ≤ + (Fintype.card G.Edge:ℝ) := by exact_mod_cast Fintype.card_subtype_le (fun e => S.tag e = some p) + unfold weight + push_cast + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + calc + _ ≤ ∑ _e : {e : G.Edge // S.tag e = some p}, L := Finset.sum_le_sum (fun e _ => hc.2 e.val) + _ = (Fintype.card {e : G.Edge // S.tag e = some p}:ℝ)*L := by simp + _ ≤ m*L := mul_le_mul_of_nonneg_right (hcard.trans hm) hL0 + +theorem output_coefficientBound {N : ℚ} (hN : 0 ≤ N) {m L T : ℝ} + (hm : (Fintype.card G.Edge:ℝ) ≤ m) (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) + (hc : G.CoefficientBound L) : + (S.layer.output N).CoefficientBound (qmaCrossingCoefficientBound m r ((m+1)*L) T) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL0 : 0 ≤ L := by linarith + have hLL : L ≤ (m+1)*L := by nlinarith + have hcount : (Fintype.card S.layer.base.Edge:ℝ) ≤ m := by + have h : Fintype.card S.layer.base.Edge ≤ Fintype.card G.Edge := Fintype.card_subtype_le _ + have h' : (Fintype.card S.layer.base.Edge:ℝ) ≤ (Fintype.card G.Edge:ℝ) := by exact_mod_cast h + exact h'.trans hm + have hbase : S.layer.base.CoefficientBound ((m+1)*L) := + ⟨hc.1.trans hLL,fun e => (hc.2 e.val).trans hLL⟩ + apply S.layer.output_coefficientBound hN hcount (hL.trans hLL) hT hbase + · intro i + exact (S.weight_abs_bound hm hL hc (i,0)).trans (by nlinarith) + · intro i + exact (S.weight_abs_bound hm hL hc (i,1)).trans (by nlinarith) + +end QMARationalCrossingSelection +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..099f971c9687438ab6e804340f2a393eee1f4c09 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGraphDegree.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumParallelGraph + +namespace OAI + +/-! Incidence counts for the actual ordinary-spin routing graphs. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph +open scoped BigOperators Classical +variable {ν κ : Type*} [Fintype ν] [Fintype κ] + +def qmaGraphDegree {n : ℕ} (left right : ν → Fin n) (v : Fin n) : ℕ := + ∑ e, if left e = v ∨ right e = v then 1 else 0 + +theorem qmaParallelGraph_old_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → κ → Fin n) (member : Fin r → κ → Fin 2) (v : Fin n) : + qmaGraphDegree (qmaParallelGraphLeft left site) (qmaParallelGraphRight right member) (old n r v) = + qmaGraphDegree left right v + ∑ e, ∑ a, if site e a = v then 1 else 0 := by + have ho := old_injective n r + have hf (e : Fin r) (b : Fin 2) : fresh n r e b ≠ old n r v := (old_ne_fresh n r v e b).symm + simp only [qmaGraphDegree,Fintype.sum_sum_type,Fintype.sum_prod_type] + simp [qmaParallelGraphLeft,qmaParallelGraphRight,ho.eq_iff,hf] + +theorem qmaParallelGraph_new_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → κ → Fin n) (member : Fin r → κ → Fin 2) (e : Fin r) (b : Fin 2) : + qmaGraphDegree (qmaParallelGraphLeft left site) (qmaParallelGraphRight right member) (fresh n r e b) = + 1 + ∑ a, if member e a = b then 1 else 0 := by + have hf := fresh_injective n r + have ho (v : Fin n) : old n r v ≠ fresh n r e b := old_ne_fresh n r v e b + have heq (f : Fin r) (a : Fin 2) : fresh n r f a = fresh n r e b ↔ f = e ∧ a = b := by + constructor + · intro h + have hh : (f,a) = (e,b) := hf h + exact Prod.mk.inj hh + · rintro ⟨rfl,rfl⟩ + rfl + simp only [qmaGraphDegree,Fintype.sum_sum_type,Fintype.sum_prod_type] + simp only [qmaParallelGraphLeft,qmaParallelGraphRight,ho,false_or,heq,ite_false, + Finset.sum_const_zero,zero_add] + have hc : (∑ f : Fin r, if f = e ∧ (0:Fin 2) = b ∨ f = e ∧ (1:Fin 2) = b then 1 else 0) = 1 := by + fin_cases b <;> simp + rw [hc] + apply congrArg (1+·) + rw [Finset.sum_eq_single e] + · simp + · intro f _ hfe + simp [hfe] + · simp + +theorem qmaParallelGraph_fork_degree {n r : ℕ} (left right : ν → Fin n) + (site : Fin r → Fin 3 → Fin n) (e : Fin r) (b : Fin 2) : + qmaGraphDegree (qmaParallelGraphLeft left site) + (qmaParallelGraphRight right (fun _ => qmaForkMember)) (fresh n r e b) = + if b = 0 then 2 else 3 := by + rw [qmaParallelGraph_new_degree] + fin_cases b <;> simp [qmaForkMember,Fin.sum_univ_three] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridAcceptance.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridAcceptance.lean new file mode 100644 index 0000000000000000000000000000000000000000..e298f1ddf96b834db3379f1624fcf0d8ac5fd23f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridAcceptance.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedEvolution + +namespace OAI + +/-! The concrete fresh-row circuit preserves verifier acceptance exactly. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Classical + +abbrev qmaGridCircuit (c : QMACircuit) : QMACircuit := + ⟨qmaGridWork c.gates.length c.work,c.witness, + qmaGridCircuitFrom c.gates.length c.work 0 c.gates (by omega)⟩ + +theorem qmaGridCircuit_wellFormed (c : QMACircuit) (hc : c.WellFormed) : + (qmaGridCircuit c).WellFormed := by + refine ⟨?_,qmaGridCircuitFrom_wellFormed _ _ _ _ _ hc.2⟩ + exact hc.1.trans (Nat.le_add_right _ _) + +theorem qmaGridCircuit_length (c : QMACircuit) : + (qmaGridCircuit c).gates.length = (3*(c.work+1)+1)*c.gates.length := + qmaGridCircuitFrom_length _ _ _ _ _ + +theorem qmaGridCircuit_size (c : QMACircuit) : + (qmaGridCircuit c).work+(qmaGridCircuit c).gates.length = + c.work+(4*c.work+5)*c.gates.length := by + rw [qmaGridCircuit_length] + change c.work+c.gates.length*(c.work+1)+(3*(c.work+1)+1)*c.gates.length = _ + ring + +theorem qmaGridQubit_zero (rows width : ℕ) : + qmaGridQubit rows width 0 = qmaPaddedLeft width (rows*(width+1)) := by + funext i + apply Fin.ext + simp [qmaGridQubit] + +theorem qmaWirePermutation_refl (n : ℕ) : + qmaWirePermutation (qmaWireBasis (Equiv.refl (Fin n))) = + (1 : Matrix (SourceSpinBasis n) (SourceSpinBasis n) ℂ) := by + ext s t + simp only [qmaWirePermutation,qmaWireBasis,Equiv.coe_fn_mk,Matrix.one_apply] + rfl + +theorem qmaGridCircuit_matrix (c : QMACircuit) : + qmaCircuitMatrix (qmaGridCircuit c) = + qmaWirePermutation (qmaWireBasis + (qmaGridFrame c.gates.length c.work c.gates.length le_rfl))* + qmaCircuitMatrix (qmaPaddedCircuit c (c.gates.length*(c.work+1))) := by + change qmaGateProduct (qmaGridWork c.gates.length c.work) + (qmaGridCircuitFrom c.gates.length c.work 0 c.gates _) = + qmaWirePermutation (qmaWireBasis + (qmaGridFrame c.gates.length c.work c.gates.length le_rfl))* + qmaGateProduct (qmaGridWork c.gates.length c.work) + (c.gates.map (qmaMapGate c.work (qmaGridWork c.gates.length c.work) + (qmaPaddedLeft c.work (c.gates.length*(c.work+1))))) + have h := qmaGridCircuitFrom_matrix c.gates.length c.work 0 c.gates (by omega) + simpa only [qmaGridFrame,qmaWirePermutation_refl,mul_one,Nat.zero_add,qmaGridQubit_zero] using h + +theorem qmaGridCircuit_output (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaOutputVector (qmaGridCircuit c) (qmaGridCircuit_wellFormed c hc) psi = + qmaApplyMatrix (qmaWirePermutation (qmaWireBasis + (qmaGridFrame c.gates.length c.work c.gates.length le_rfl))) + (qmaOutputVector (qmaPaddedCircuit c (c.gates.length*(c.work+1))) + (qmaPaddedCircuit_wellFormed c hc _) psi) := by + change qmaApplyMatrix (qmaCircuitMatrix (qmaGridCircuit c)) + (qmaInputVector (qmaPaddedCircuit c (c.gates.length*(c.work+1))) + (qmaPaddedCircuit_wellFormed c hc _) psi) = _ + rw [qmaGridCircuit_matrix,qmaApplyMatrix_mul] + rfl + +theorem qmaGridFrame_output (c : QMACircuit) : + (qmaGridFrame c.gates.length c.work c.gates.length le_rfl).symm + (qmaPaddedLeft c.work (c.gates.length*(c.work+1)) (Fin.last c.work)) = + Fin.last (qmaGridWork c.gates.length c.work) := by + rw [←qmaGridQubit_zero,qmaGridFrame_active] + apply Fin.ext + change c.gates.length*(c.work+1)+c.work = c.work+c.gates.length*(c.work+1) + omega + +theorem qmaGridCircuit_acceptance (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaAcceptance (qmaGridCircuit c) (qmaGridCircuit_wellFormed c hc) psi = + qmaAcceptance c hc psi := by + rw [qmaAcceptance_projection (qmaGridCircuit c) (qmaGridCircuit_wellFormed c hc) psi, + qmaAcceptance_projection c hc psi,qmaGridCircuit_output c hc psi] + rw [←qmaGridFrame_output] + rw [qmaWirePermutation_probability] + exact qmaPaddedOutput_probability c hc _ psi (Fin.last c.work) 1 + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCircuit.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCircuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..14661ce3ab64af32f8cd8ce31b82a7b1fd15deed --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCircuit.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridFrame + +namespace OAI + +/-! A concrete circuit that transfers its full active register to a fresh row per gate. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Classical + +def qmaGridCircuitFrom (rows width : ℕ) : + (start : ℕ) → (gs : List QMAGate) → start+gs.length ≤ rows → List QMAGate + | _,[],_ => [] + | start,g::gs,h => + qmaGridTransfer rows width ⟨start,by simp only [List.length_cons] at h; omega⟩ ++ + [qmaMapGate width (qmaGridWork rows width) + (qmaGridQubit rows width ⟨start+1,by simp only [List.length_cons] at h; omega⟩) g] ++ + qmaGridCircuitFrom rows width (start+1) gs (by simp only [List.length_cons] at h; omega) + +theorem qmaGridCircuitFrom_length (rows width start : ℕ) (gs : List QMAGate) + (h : start+gs.length ≤ rows) : + (qmaGridCircuitFrom rows width start gs h).length = (3*(width+1)+1)*gs.length := by + induction gs generalizing start with + | nil => simp [qmaGridCircuitFrom] + | cons g gs ih => + simp only [qmaGridCircuitFrom,List.length_append,List.length_cons,List.length_nil, + qmaGridTransfer_length,ih] + ring + +theorem qmaGridTransfer_frame (rows width start : ℕ) (h : start < rows) : + qmaGateProduct (qmaGridWork rows width) (qmaGridTransfer rows width ⟨start,h⟩)* + qmaWirePermutation (qmaWireBasis (qmaGridFrame rows width start (Nat.le_of_lt h))) = + qmaWirePermutation (qmaWireBasis (qmaGridFrame rows width (start+1) h)) := by + unfold qmaGridTransfer + rw [qmaRowTransfer_matrix _ _ + (qmaGridRows_disjoint rows width _ _ (qmaGridRow_ne rows ⟨start,h⟩))] + exact qmaWireBasis_product _ _ + +theorem qmaGridCircuitFrom_matrix (rows width start : ℕ) (gs : List QMAGate) + (h : start+gs.length ≤ rows) : + qmaGateProduct (qmaGridWork rows width) (qmaGridCircuitFrom rows width start gs h)* + qmaWirePermutation (qmaWireBasis (qmaGridFrame rows width start (by omega))) = + qmaWirePermutation (qmaWireBasis (qmaGridFrame rows width (start+gs.length) h))* + qmaGateProduct (qmaGridWork rows width) + (gs.map (qmaMapGate width (qmaGridWork rows width) (qmaGridQubit rows width 0))) := by + induction gs generalizing start with + | nil => simp [qmaGridCircuitFrom,qmaGateProduct_nil] + | cons g gs ih => + have hs : start < rows := by simp only [List.length_cons] at h; omega + have ht : start+1+gs.length ≤ rows := by simp only [List.length_cons] at h; omega + let work := qmaGridWork rows width + let G := qmaGateMatrix work (qmaMapGate width work (qmaGridQubit rows width 0) g) + let P := qmaWirePermutation (qmaWireBasis (qmaGridFrame rows width (start+1) hs)) + have hg : qmaGateMatrix work (qmaMapGate width work + (qmaGridQubit rows width ⟨start+1,by omega⟩) g)*P = P*G := by + rw [←qmaGridFrame_gate rows width (start+1) hs g] + exact (qmaGate_wire_intertwines work _ _).symm + simp only [qmaGridCircuitFrom,List.map_cons] + rw [show qmaMapGate width work (qmaGridQubit rows width 0) g :: + gs.map (qmaMapGate width work (qmaGridQubit rows width 0)) = + [qmaMapGate width work (qmaGridQubit rows width 0) g] ++ + gs.map (qmaMapGate width work (qmaGridQubit rows width 0)) from rfl] + simp only [qmaGateProduct_append,qmaGateProduct_singleton] + calc + _ = qmaGateProduct work (qmaGridCircuitFrom rows width (start+1) gs ht)* + (qmaGateMatrix work (qmaMapGate width work + (qmaGridQubit rows width ⟨start+1,by omega⟩) g)*P) := by + dsimp only [P,work] + rw [mul_assoc,mul_assoc,qmaGridTransfer_frame rows width start hs] + _ = qmaGateProduct work (qmaGridCircuitFrom rows width (start+1) gs ht)*P*G := by + rw [hg,mul_assoc] + _ = _ := by + rw [ih (start+1) ht] + have he : start+1+gs.length = start+(g::gs).length := by simp; omega + simp only [he,mul_assoc,G,work] + +theorem qmaGridCircuitFrom_wellFormed (rows width start : ℕ) (gs : List QMAGate) + (h : start+gs.length ≤ rows) (hg : ∀ g ∈ gs, g.WellFormed (width+1)) : + ∀ g ∈ qmaGridCircuitFrom rows width start gs h, + g.WellFormed (qmaGridWork rows width+1) := by + induction gs generalizing start with + | nil => simp [qmaGridCircuitFrom] + | cons g gs ih => + intro k hk + have ht : start+1+gs.length ≤ rows := by simp only [List.length_cons] at h; omega + simp only [qmaGridCircuitFrom,List.mem_append,List.mem_singleton] at hk + rcases hk with (hk | rfl) | hk + · exact qmaGridTransfer_wellFormed rows width _ k hk + · exact qmaMapGate_wellFormed width _ _ (qmaGridRow_injective rows width _) + g (hg g (by simp)) + · exact ih (start+1) ht (fun k hk => hg k (by simp [hk])) k hk + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridColor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridColor.lean new file mode 100644 index 0000000000000000000000000000000000000000..80a6bd8475c44ce3350098ac2e736dd6264d6ad1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridColor.lean @@ -0,0 +1,54 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridSlots + +namespace OAI + +/-! A constant number of spatial colors separates overlapping local interactions. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +variable {E : Type*} [Fintype E] {rows width B : ℕ} + +def qmaGridColor (anchor : E → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun e => anchor e = p)).card ≤ B) (e : E) : + Fin 3 × Fin 3 × Fin B := + (⟨(anchor e).1.val%3,Nat.mod_lt _ (by decide)⟩, + ⟨(anchor e).2.val%3,Nat.mod_lt _ (by decide)⟩,qmaGridSlot anchor h e) + +theorem qmaGridColor_eq (anchor : E → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun e => anchor e = p)).card ≤ B) + {e f : E} (hcolor : qmaGridColor anchor h e = qmaGridColor anchor h f) + (hr : (anchor e).1.val ≤ (anchor f).1.val+2) + (hr' : (anchor f).1.val ≤ (anchor e).1.val+2) + (hc : (anchor e).2.val ≤ (anchor f).2.val+2) + (hc' : (anchor f).2.val ≤ (anchor e).2.val+2) : e = f := by + have hrow := congrArg (fun c : Fin 3 × Fin 3 × Fin B => c.1.val) hcolor + have hcol := congrArg (fun c : Fin 3 × Fin 3 × Fin B => c.2.1.val) hcolor + have hslot := congrArg (fun c : Fin 3 × Fin 3 × Fin B => c.2.2) hcolor + change (anchor e).1.val%3 = (anchor f).1.val%3 at hrow + change (anchor e).2.val%3 = (anchor f).2.val%3 at hcol + apply qmaGridSlot_injective_on_cell anchor h _ hslot + apply Prod.ext <;> apply Fin.ext <;> omega + +theorem qmaGridColor_disjoint {Q : Type*} (cell : Q → QMAGridCell rows width) + (anchor : E → QMAGridCell rows width) (sites : E → Finset Q) + (h : ∀ p, (Finset.univ.filter (fun e => anchor e = p)).card ≤ B) + (hlocal : ∀ e, ∀ q ∈ sites e, QMAGridCellsNear (cell q) (anchor e)) + {e f : E} (hef : e ≠ f) (hcolor : qmaGridColor anchor h e = qmaGridColor anchor h f) : + Disjoint (sites e) (sites f) := by + apply Finset.disjoint_left.mpr + intro q he hf + have ha := hlocal e q he + have hb := hlocal f q hf + apply hef + apply qmaGridColor_eq anchor h hcolor <;> dsimp [QMAGridCellsNear] at ha hb <;> omega + +theorem qmaGridColor_card : Fintype.card (Fin 3 × Fin 3 × Fin B) = 9*B := by + simp only [Fintype.card_prod,Fintype.card_fin] + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05c7f81a50420f6e1061857be07f2e24e391858 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridCoordinates.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumClockCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedFamily + +namespace OAI + +/-! Explicit row/column coordinates for every physical computation qubit. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaGridCoordinates (rows width : ℕ) (k : Fin (qmaGridWork rows width+1)) : QMAGridCell rows width := + (⟨k.val/(width+1),by + apply (Nat.div_lt_iff_lt_mul (by omega : 0 < width+1)).mpr + have hk := k.isLt + change k.val < width+rows*(width+1)+1 at hk + nlinarith⟩, + ⟨k.val%(width+1),Nat.mod_lt _ (by omega)⟩) + +theorem qmaGridCoordinates_right (rows width : ℕ) (k : Fin (qmaGridWork rows width+1)) : + qmaGridQubit rows width (qmaGridCoordinates rows width k).1 (qmaGridCoordinates rows width k).2 = k := by + apply Fin.ext + change k.val/(width+1)*(width+1)+k.val%(width+1) = k.val + simpa only [Nat.mul_comm] using Nat.div_add_mod k.val (width+1) + +theorem qmaGridCoordinates_left (rows width : ℕ) (r : Fin (rows+1)) (j : Fin (width+1)) : + qmaGridCoordinates rows width (qmaGridQubit rows width r j) = (r,j) := + qmaGridQubit_injective rows width (qmaGridCoordinates_right _ _ _) + +def qmaSparseWorkCell (c : QMACircuit) (i : Fin ((qmaSparseCircuit c).work+1)) : + QMAGridCell (qmaNearestCircuit c).gates.length c.work := + qmaGridCoordinates (qmaNearestCircuit c).gates.length c.work i + +theorem qmaSparseWorkCell_near_gate (c : QMACircuit) (hc : c.WellFormed) + (t : Fin (qmaSparseCircuit c).gates.length) (i : Fin ((qmaSparseCircuit c).work+1)) + (hi : i ∈ qmaGateSites (qmaSparseCircuit c).work (qmaSparseCircuit c).gates[t.val]) : + QMAGridCellsNear (qmaSparseWorkCell c i) (qmaSparseGateCell c t) := by + let u := t.cast (qmaSparseTags_length c).symm + have hu : qmaSparseTime c u = t := by apply Fin.ext; rfl + rw [←hu,←qmaSparseTag_gate] at hi + obtain ⟨r,j,he,hl,hr,hj,hj'⟩ := + qmaSparseTags_located c hc _ (List.getElem_mem u.isLt) i hi + unfold qmaSparseWorkCell + rw [he,qmaGridCoordinates_left] + change r.val ≤ (qmaSparseCell c u).1.val+1 ∧ + (qmaSparseCell c u).1.val ≤ r.val+1 ∧ + j.val ≤ (qmaSparseCell c u).2.val+1 ∧ (qmaSparseCell c u).2.val ≤ j.val+1 + exact ⟨hr,hl.trans (Nat.le_succ _),hj,hj'⟩ + +def qmaSparseQubitCell (c : QMACircuit) (hT : 0 < (qmaSparseCircuit c).gates.length) : + QMACircuitQubit (qmaSparseCircuit c) → QMAGridCell (qmaNearestCircuit c).gates.length c.work + | .inl b => qmaSparseClockCell c hT b + | .inr i => qmaSparseWorkCell c i + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridFrame.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridFrame.lean new file mode 100644 index 0000000000000000000000000000000000000000..dcf05eb9bdf546f440082c1982d004727b98320d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridFrame.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMappedGate + +namespace OAI + +/-! The cumulative row-transfer frame locates the active register exactly. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def qmaGridFrame (rows width : ℕ) : (t : ℕ) → t ≤ rows → + Equiv.Perm (Fin (qmaGridWork rows width+1)) + | 0,_ => Equiv.refl _ + | t+1,ht => + (qmaTransferPermutation (qmaRowPairs (qmaGridQubit rows width (⟨t,by omega⟩ : Fin (rows+1))) + (qmaGridQubit rows width (⟨t+1,by omega⟩ : Fin (rows+1))))).trans + (qmaGridFrame rows width t (by omega)) + +theorem qmaGridFrame_active (rows width t : ℕ) (ht : t ≤ rows) (i : Fin (width+1)) : + (qmaGridFrame rows width t ht).symm (qmaGridQubit rows width 0 i) = + qmaGridQubit rows width ⟨t,by omega⟩ i := by + induction t with + | zero => rfl + | succ t ih => + have hp : t ≤ rows := by omega + let r : Fin rows := ⟨t,by omega⟩ + change (qmaTransferPermutation (qmaRowPairs (qmaGridQubit rows width r.castSucc) + (qmaGridQubit rows width r.succ))).symm + ((qmaGridFrame rows width t hp).symm (qmaGridQubit rows width 0 i)) = _ + rw [ih hp] + exact (qmaTransferPermutation (qmaRowPairs (qmaGridQubit rows width r.castSucc) + (qmaGridQubit rows width r.succ))).symm_apply_eq.mpr + (qmaGridTransfer_coordinates rows width r i).2.symm + +theorem qmaGridFrame_gate (rows width t : ℕ) (ht : t ≤ rows) (g : QMAGate) : + qmaRelabelGate (qmaGridWork rows width) (qmaGridFrame rows width t ht).symm + (qmaMapGate width (qmaGridWork rows width) (qmaGridQubit rows width 0) g) = + qmaMapGate width (qmaGridWork rows width) (qmaGridQubit rows width ⟨t,by omega⟩) g := by + rw [qmaRelabelGate_map] + apply qmaMapGate_congr + intro i + exact qmaGridFrame_active rows width t ht i + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridLocality.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..9617dad7eff78d6768d5c0765b974982dc273d30 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridLocality.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRowStageSupport + +namespace OAI + +/-! A concrete polynomial-size verifier with geometrically local computation gates. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +def QMAGridLocal (rows width : ℕ) (g : QMAGate) : Prop := + ∃ r : Fin (rows+1), ∃ lo : Fin (width+1), ∀ k ∈ qmaGateSites (qmaGridWork rows width) g, + ∃ s : Fin (rows+1), ∃ j : Fin (width+1), + k = qmaGridQubit rows width s j ∧ r.val ≤ s.val ∧ s.val ≤ r.val+1 ∧ + lo.val ≤ j.val ∧ j.val ≤ lo.val+1 + +theorem qmaRowStage_gridLocal (rows width : ℕ) (r : Fin rows) + (e : Equiv.Perm (Fin (width+1))) (g : QMAGate) + (hg : g.WellFormed (width+1)) (ha : g.Adjacent) (k : QMAGate) + (hk : k ∈ qmaRowStage width (qmaGridWork rows width) + (qmaGridQubit rows width r.castSucc) (qmaGridQubit rows width r.succ) e g) : + QMAGridLocal rows width k := by + rcases qmaRowStage_member _ _ _ _ _ g k hk with rfl | ⟨i,hi⟩ + · obtain ⟨lo,hlo⟩ := qmaAdjacentGate_window width g hg ha + refine ⟨r.castSucc,lo,?_⟩ + intro k hk + rw [qmaMapGate_sites] at hk + obtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp hk + exact ⟨r.succ,j,rfl,by simp,by simp,(hlo j hj).1,(hlo j hj).2⟩ + · refine ⟨r.castSucc,i,?_⟩ + intro v hv + rcases qmaWireSwap_sites _ _ k hi v hv with rfl | rfl + · exact ⟨r.castSucc,i,rfl,le_rfl,by simp,le_rfl,by omega⟩ + · exact ⟨r.succ,i,rfl,by simp,by simp,le_rfl,by omega⟩ + +theorem qmaSweepCircuitFrom_local (rows width start : ℕ) (gs : List QMAGate) + (h : start+gs.length ≤ rows) + (hg : ∀ g ∈ gs, g.WellFormed (width+1)) (ha : ∀ g ∈ gs, g.Adjacent) : + ∀ k ∈ qmaSweepCircuitFrom rows width start gs h, QMAGridLocal rows width k := by + induction gs generalizing start with + | nil => simp [qmaSweepCircuitFrom] + | cons g gs ih => + intro k hk + have hs : start < rows := by simp only [List.length_cons] at h; omega + have ht : start+1+gs.length ≤ rows := by simp only [List.length_cons] at h; omega + rcases List.mem_append.mp hk with hk | hk + · exact qmaRowStage_gridLocal rows width ⟨start,hs⟩ _ g + (hg g (by simp)) (ha g (by simp)) k hk + · exact ih (start+1) ht (fun k hk => hg k (by simp [hk])) + (fun k hk => ha k (by simp [hk])) k hk + +theorem qmaSweepCircuit_size (c : QMACircuit) : + (qmaSweepCircuit c).work+(qmaSweepCircuit c).gates.length = + c.work+(4*c.work+5)*c.gates.length := by + change qmaGridWork c.gates.length c.work+ + (qmaSweepCircuitFrom c.gates.length c.work 0 c.gates _).length = _ + rw [qmaSweepCircuitFrom_length] + unfold qmaGridWork + ring + +abbrev qmaSparseCircuit (c : QMACircuit) : QMACircuit := qmaSweepCircuit (qmaNearestCircuit c) + +theorem qmaSparseCircuit_wellFormed (c : QMACircuit) (hc : c.WellFormed) : + (qmaSparseCircuit c).WellFormed := + qmaSweepCircuit_wellFormed (qmaNearestCircuit c) (qmaNearestCircuit_wellFormed c hc) + +theorem qmaSparseCircuit_acceptance (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaAcceptance (qmaSparseCircuit c) (qmaSparseCircuit_wellFormed c hc) psi = + qmaAcceptance c hc psi := by + rw [qmaSweepCircuit_acceptance (qmaNearestCircuit c) (qmaNearestCircuit_wellFormed c hc), + qmaNearestCircuit_acceptance c hc] + +theorem qmaSparseCircuit_local (c : QMACircuit) (hc : c.WellFormed) : + ∀ g ∈ (qmaSparseCircuit c).gates, + QMAGridLocal (qmaNearestCircuit c).gates.length c.work g := + qmaSweepCircuitFrom_local _ _ _ _ _ (qmaNearestCircuit_wellFormed c hc).2 + (qmaNearestCircuit_adjacent c hc) + +theorem qmaSparseCircuit_size (c : QMACircuit) : + (qmaSparseCircuit c).work+(qmaSparseCircuit c).gates.length ≤ + c.work+(4*c.work+5)*(6*c.work+7)*c.gates.length := by + rw [qmaSweepCircuit_size] + exact Nat.add_le_add_left (by + simpa only [Nat.mul_assoc] using + Nat.mul_le_mul_left (4*c.work+5) (qmaNearestList_length c.work c.gates)) c.work + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridMidpoint.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridMidpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..912cdde7f0528ec56ed539bb8777b00a217c6277 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridMidpoint.lean @@ -0,0 +1,54 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialReference +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRoutingInputProgram + +namespace OAI + +/-! Integer midpoints choose a common neighboring cell deterministically. +Their coordinate map has a literal polynomial register program. -/ + +noncomputable section +namespace ContinuumCoulomb +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +def qmaGridMidpoint {rows width : ℕ} (p q : QMAGridCell rows width) : + QMAGridCell rows width := + (⟨(p.1.val+q.1.val)/2,by have := p.1.isLt; have := q.1.isLt; omega⟩, + ⟨(p.2.val+q.2.val)/2,by have := p.2.isLt; have := q.2.isLt; omega⟩) + +theorem qmaGridMidpoint_near {rows width : ℕ} (p q a : QMAGridCell rows width) + (hp : QMAGridCellsNear p a) (hq : QMAGridCellsNear q a) : + QMAGridCellsNear p (qmaGridMidpoint p q) ∧ + QMAGridCellsNear q (qmaGridMidpoint p q) := by + rcases hp with ⟨hp₁,hp₂,hp₃,hp₄⟩ + rcases hq with ⟨hq₁,hq₂,hq₃,hq₄⟩ + unfold QMAGridCellsNear qmaGridMidpoint + dsimp only + omega + +namespace QuantumGridMidpoint + +def value (x : Pair × Pair) : Pair := + ((x.1.1+x.2.1)/2,(x.1.2+x.2.2)/2) + +noncomputable def program : Procedure (prodCode pairCode pairCode) pairCode value := by + let p := Procedure.first pairCode pairCode + let q := Procedure.second pairCode pairCode + let first := Procedure.first Nat.bits Nat.bits + let second := Procedure.second Nat.bits Nat.bits + let two := Procedure.constant (prodCode pairCode pairCode) Nat.bits 2 + let row := Procedure.binaryDiv.comp + ((Procedure.binaryAdd.comp ((first.comp p).pair (first.comp q))).pair two) + let col := Procedure.binaryDiv.comp + ((Procedure.binaryAdd.comp ((second.comp p).pair (second.comp q))).pair two) + exact row.pair col + +theorem value_eq {rows width : ℕ} (p q : QMAGridCell rows width) : + value ((p.1.val,p.2.val),(q.1.val,q.2.val)) = + ((qmaGridMidpoint p q).1.val,(qmaGridMidpoint p q).2.val) := rfl + +end QuantumGridMidpoint +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighbors.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighbors.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc7b70295643f3b679bea0c615f820e13eaaa904 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighbors.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialModel +import Mathlib.Order.Interval.Finset.Nat + +namespace OAI + +/-! Neighboring-cell geometry gives a constant interaction-degree bound. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaLineNeighbors {n : ℕ} (p : Fin n) : Finset (Fin n) := + Finset.univ.filter (fun q => q.val ≤ p.val+1 ∧ p.val ≤ q.val+1) + +theorem qmaLineNeighbors_card {n : ℕ} (p : Fin n) : (qmaLineNeighbors p).card ≤ 3 := by + have hm : (qmaLineNeighbors p).card ≤ (Finset.Icc (p.val-1) (p.val+1)).card := by + apply Finset.card_le_card_of_injOn Fin.val + · intro q hq + have h := (Finset.mem_filter.mp hq).2 + simp only [Finset.mem_coe,Finset.mem_Icc] + omega + · intro q _ r _ h + exact Fin.ext h + rw [Nat.card_Icc] at hm + omega + +def qmaGridNeighbors {rows width : ℕ} (p : QMAGridCell rows width) : + Finset (QMAGridCell rows width) := qmaLineNeighbors p.1 ×ˢ qmaLineNeighbors p.2 + +theorem qmaGridNeighbors_mem {rows width : ℕ} (p q : QMAGridCell rows width) : + q ∈ qmaGridNeighbors p ↔ QMAGridCellsNear q p := by + simp only [qmaGridNeighbors,Finset.mem_product,qmaLineNeighbors,Finset.mem_filter, + Finset.mem_univ,true_and,QMAGridCellsNear] + tauto + +theorem qmaGridNeighbors_card {rows width : ℕ} (p : QMAGridCell rows width) : + (qmaGridNeighbors p).card ≤ 9 := by + rw [qmaGridNeighbors,Finset.card_product] + exact (Nat.mul_le_mul (qmaLineNeighbors_card p.1) (qmaLineNeighbors_card p.2)).trans (by decide) + +theorem qmaGrid_incidence_bound {Q E : Type*} [Fintype E] [DecidableEq Q] + {rows width B : ℕ} (cell : Q → QMAGridCell rows width) + (anchor : E → QMAGridCell rows width) (sites : E → Finset Q) + (hlocal : ∀ a, ∀ q ∈ sites a, QMAGridCellsNear (cell q) (anchor a)) + (hdensity : ∀ p, (Finset.univ.filter (fun a => anchor a = p)).card ≤ B) (q : Q) : + (Finset.univ.filter (fun a => q ∈ sites a)).card ≤ 9*B := by + let near := qmaGridNeighbors (cell q) + let fiber := fun p => Finset.univ.filter (fun a => anchor a = p) + have hs : Finset.univ.filter (fun a => q ∈ sites a) ⊆ near.biUnion fiber := by + intro a ha + apply Finset.mem_biUnion.mpr + refine ⟨anchor a,?_,?_⟩ + · apply (qmaGridNeighbors_mem _ _).mpr + exact qmaGridCellsNear_symm (hlocal a q (Finset.mem_filter.mp ha).2) + · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,rfl⟩ + calc + _ ≤ (near.biUnion fiber).card := Finset.card_le_card hs + _ ≤ ∑ p ∈ near, (fiber p).card := Finset.card_biUnion_le + _ ≤ ∑ _p ∈ near, B := Finset.sum_le_sum (fun p _ => hdensity p) + _ = near.card*B := by simp + _ ≤ 9*B := Nat.mul_le_mul_right B (qmaGridNeighbors_card _) + + +theorem QMASpatialModel.incidence_bound {d A B : ℕ} (M : QMASpatialModel d A B) (q : M.Q) : + (Finset.univ.filter (fun a => q ∈ M.sites a)).card ≤ 9*B := + qmaGrid_incidence_bound M.cell M.anchor M.sites M.geometry M.termDensity q + +theorem qmaGrid_density_card {Q : Type*} [Fintype Q] {rows width A : ℕ} + (cell : Q → QMAGridCell rows width) + (hdensity : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) : + Fintype.card Q ≤ (rows+1)*(width+1)*A := by + calc + Fintype.card Q = ∑ p : QMAGridCell rows width, + (Finset.univ.filter (fun q => cell q = p)).card := by + exact Finset.card_eq_sum_card_fiberwise (fun _ _ => Finset.mem_univ _) + _ ≤ ∑ _p : QMAGridCell rows width, A := + Finset.sum_le_sum (fun p _ => hdensity p) + _ = (rows+1)*(width+1)*A := by simp [Fintype.card_prod] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighborsFour.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighborsFour.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6ab398d569f5c352cad537ca4ec6f71266d841c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridNeighborsFour.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridWalk + +namespace OAI + +/-! The four local ports of an interior square-grid point. -/ + +namespace ContinuumCoulomb + +def qmaGridNeighbor (p : ℕ × ℕ) (a : Fin 4) : ℕ × ℕ := + ![(p.1+1,p.2),(p.1,p.2+1),(p.1-1,p.2),(p.1,p.2-1)] a + +theorem qmaGridNeighbor_injective (p : ℕ × ℕ) (hx : 0 < p.1) (hy : 0 < p.2) : + Function.Injective (qmaGridNeighbor p) := by + intro a b h + fin_cases a <;> fin_cases b <;> simp [qmaGridNeighbor] at h ⊢ <;> omega + +theorem qmaGridNeighbor_adj (p : ℕ × ℕ) (hx : 0 < p.1) (hy : 0 < p.2) (a : Fin 4) : + qmaSquareGrid.Adj p (qmaGridNeighbor p a) := by + fin_cases a <;> simp [qmaGridNeighbor,qmaSquareGrid,Nat.dist] <;> omega + +theorem qmaGridNeighbor_exists {p q : ℕ × ℕ} (ha : qmaSquareGrid.Adj p q) : + ∃ a : Fin 4, qmaGridNeighbor p a = q := by + change Nat.dist p.1 q.1 + Nat.dist p.2 q.2 = 1 at ha + have h : (q.1 = p.1+1 ∧ q.2 = p.2) ∨ (q.1 = p.1 ∧ q.2 = p.2+1) ∨ + (q.1+1 = p.1 ∧ q.2 = p.2) ∨ (q.1 = p.1 ∧ q.2+1 = p.2) := by + unfold Nat.dist at ha + omega + rcases h with ⟨hx,hy⟩ | ⟨hx,hy⟩ | ⟨hx,hy⟩ | ⟨hx,hy⟩ + · exact ⟨0,Prod.ext hx.symm hy.symm⟩ + · exact ⟨1,Prod.ext hx.symm hy.symm⟩ + · refine ⟨2,?_⟩ + apply Prod.ext <;> simp [qmaGridNeighbor] <;> omega + · refine ⟨3,?_⟩ + apply Prod.ext <;> simp [qmaGridNeighbor] <;> omega + +def qmaGridNeighborIndex (p q : ℕ × ℕ) : Fin 4 := + if q.1 = p.1+1 then 0 else if q.2 = p.2+1 then 1 else if q.1+1 = p.1 then 2 else 3 + +theorem qmaGridNeighborIndex_spec {p q : ℕ × ℕ} (hx : 0 < p.1) (hy : 0 < p.2) + (ha : qmaSquareGrid.Adj p q) : qmaGridNeighbor p (qmaGridNeighborIndex p q) = q := by + obtain ⟨a,rfl⟩ := qmaGridNeighbor_exists ha + rcases p with ⟨x,y⟩ + have hs : x-1+1 = x := by omega + fin_cases a <;> simp [qmaGridNeighborIndex,qmaGridNeighbor,hs] + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2ced35f4de0c96f6a5c82a677ba0aa70ce3d2dc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridPorts.lean @@ -0,0 +1,60 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTranslatedPatch +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighborsFour + +namespace OAI + +/-! Distinct entry and exit spin locations for every grid cell. -/ + +namespace ContinuumCoulomb + +def qmaGridPort (p : ℕ × ℕ) (a : Fin 4) : ℕ × ℕ := + ![(32*p.1+23,32*p.2+16),(32*p.1+16,32*p.2+23), + (32*p.1+9,32*p.2+16),(32*p.1+16,32*p.2+9)] a + +theorem qmaGridPort_cell (p : ℕ × ℕ) (a : Fin 4) : + ((qmaGridPort p a).1/32,(qmaGridPort p a).2/32) = p := by + apply Prod.ext <;> fin_cases a <;> simp [qmaGridPort,Nat.add_div] + +theorem qmaGridPort_injective : Function.Injective (fun x : (ℕ × ℕ) × Fin 4 => qmaGridPort x.1 x.2) := by + rintro ⟨p,a⟩ ⟨q,b⟩ h + have he := congrArg (fun z : ℕ × ℕ => (z.1/32,z.2/32)) h + simp only [qmaGridPort_cell] at he + subst q + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + have hab : a = b := by + fin_cases a <;> fin_cases b <;> simp [qmaGridPort] at hx hy ⊢ + subst b + rfl + +theorem qmaGridPort_ne_center (p q : ℕ × ℕ) (a : Fin 4) : qmaGridPort p a ≠ qmaExpandedPoint q := by + intro h + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + fin_cases a <;> simp [qmaGridPort,qmaExpandedPoint] at hx hy <;> omega + +theorem qmaExpandedPoint_injective : Function.Injective qmaExpandedPoint := by + intro p q h + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + apply Prod.ext <;> simp only [qmaExpandedPoint] at hx hy <;> omega + +def qmaDirectedPort (p q : ℕ × ℕ) : ℕ × ℕ := qmaGridPort p (qmaGridNeighborIndex p q) + +theorem qmaDirectedPort_injective {p q r s : ℕ × ℕ} + (hp : 0 < p.1 ∧ 0 < p.2) (hr : 0 < r.1 ∧ 0 < r.2) + (hpq : qmaSquareGrid.Adj p q) (hrs : qmaSquareGrid.Adj r s) + (h : qmaDirectedPort p q = qmaDirectedPort r s) : p = r ∧ q = s := by + have he : (p,qmaGridNeighborIndex p q) = (r,qmaGridNeighborIndex r s) := qmaGridPort_injective h + constructor + · exact congrArg Prod.fst he + · have hh := congrArg (fun z : (ℕ × ℕ) × Fin 4 => qmaGridNeighbor z.1 z.2) he + simpa only [qmaGridNeighborIndex_spec hp.1 hp.2 hpq,qmaGridNeighborIndex_spec hr.1 hr.2 hrs] using hh + +theorem qmaGridPort_bounds {p : ℕ × ℕ} {X Y : ℕ} (hx : p.1 < X) (hy : p.2 < Y) (a : Fin 4) : + (qmaGridPort p a).1 < 32*X ∧ (qmaGridPort p a).2 < 32*Y := by + fin_cases a <;> simp [qmaGridPort] <;> omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridSlots.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7fe714f92d8425a64022fc9410273bdd6a51a04 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridSlots.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighbors + +namespace OAI + +/-! A bounded cell fiber admits distinct fine-grid slots for all its qubits. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +variable {Q : Type*} [Fintype Q] {rows width A : ℕ} + +def qmaGridFiberSlot (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) + (p : QMAGridCell rows width) : {q // cell q = p} ↪ Fin A := + (Fintype.equivFin {q // cell q = p}).toEmbedding.trans { + toFun := fun i => ⟨i.val,lt_of_lt_of_le i.isLt (by + simpa only [Fintype.card_subtype] using h p)⟩ + inj' := fun _ _ he => Fin.ext (congrArg (fun i : Fin A => i.val) he) } + +def qmaGridSlot (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) (q : Q) : Fin A := + qmaGridFiberSlot cell h (cell q) ⟨q,rfl⟩ + +theorem qmaGridSlot_eq (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) + (q : Q) (p : QMAGridCell rows width) (hq : cell q = p) : + qmaGridSlot cell h q = qmaGridFiberSlot cell h p ⟨q,hq⟩ := by + subst p + rfl + +theorem qmaGridSlot_injective_on_cell (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) + {q r : Q} (hc : cell q = cell r) (hs : qmaGridSlot cell h q = qmaGridSlot cell h r) : q = r := by + have he : qmaGridFiberSlot cell h (cell r) ⟨q,hc⟩ = + qmaGridFiberSlot cell h (cell r) ⟨r,rfl⟩ := by + rw [qmaGridSlot_eq cell h q (cell r) hc] at hs + exact hs + exact congrArg Subtype.val ((qmaGridFiberSlot cell h (cell r)).injective he) + +def qmaFineGridSite (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) (q : Q) : + Fin ((rows+1)*A) × Fin (width+1) := + (finProdFinEquiv ((cell q).1,qmaGridSlot cell h q),(cell q).2) + +theorem qmaFineGridSite_injective (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) : + Function.Injective (qmaFineGridSite cell h) := by + intro q r he + have hx := finProdFinEquiv.injective (congrArg Prod.fst he) + have hcol := congrArg Prod.snd he + have hrow := congrArg Prod.fst hx + have hslot := congrArg Prod.snd hx + apply qmaGridSlot_injective_on_cell cell h (Prod.ext hrow hcol) hslot + +theorem qmaFineGridSite_bounds (cell : Q → QMAGridCell rows width) + (h : ∀ p, (Finset.univ.filter (fun q => cell q = p)).card ≤ A) + (q : Q) (p : QMAGridCell rows width) (hne : QMAGridCellsNear (cell q) p) : + (qmaFineGridSite cell h q).1.val < (p.1.val+2)*A ∧ + p.1.val*A ≤ (qmaFineGridSite cell h q).1.val+A ∧ + (qmaFineGridSite cell h q).2.val ≤ p.2.val+1 ∧ + p.2.val ≤ (qmaFineGridSite cell h q).2.val+1 := by + obtain ⟨hr,hr',hc,hc'⟩ := hne + have hs := (qmaGridSlot cell h q).isLt + have hm := Nat.mul_le_mul_right A hr + have hm' := Nat.mul_le_mul_right A hr' + change (qmaGridSlot cell h q).val+A*(cell q).1.val < (p.1.val+2)*A ∧ + p.1.val*A ≤ (qmaGridSlot cell h q).val+A*(cell q).1.val+A ∧ _ + exact ⟨by nlinarith,by nlinarith,hc,hc'⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridWalk.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridWalk.lean new file mode 100644 index 0000000000000000000000000000000000000000..e576671d9758d68ea95d674768251b323d470684 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGridWalk.lean @@ -0,0 +1,71 @@ +import Mathlib.Combinatorics.SimpleGraph.Paths +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumManhattanRoute + +namespace OAI + +/-! A finite unit-step route has a simple subroute with no larger length. -/ + +namespace ContinuumCoulomb + +def qmaSquareGrid : SimpleGraph (ℕ × ℕ) where + Adj p q := Nat.dist p.1 q.1 + Nat.dist p.2 q.2 = 1 + symm := ⟨by intro p q h; simpa only [Nat.dist_comm] using h⟩ + loopless := ⟨by intro p; simp⟩ + +theorem qmaManhattanPoint_adj (p q : ℕ × ℕ) (k : ℕ) + (hk : k < qmaManhattanLength p q) : + qmaSquareGrid.Adj (qmaManhattanPoint p q k) (qmaManhattanPoint p q (k+1)) := + qmaManhattanPoint_step p q k hk + +def qmaGridWalk (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) : + qmaSquareGrid.Walk (p 0) (p L) := + match L with + | 0 => .nil + | L+1 => .cons (hstep 0 (by omega)) + (qmaGridWalk (fun k => p (k+1)) L (fun k hk => hstep (k+1) (by omega))) + +theorem qmaGridWalk_length (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) : + (qmaGridWalk p L hstep).length = L := by + induction L generalizing p with + | zero => rfl + | succ L ih => simp only [qmaGridWalk,SimpleGraph.Walk.length_cons,ih] + +theorem qmaGridWalk_support (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) {z : ℕ × ℕ} + (hz : z ∈ (qmaGridWalk p L hstep).support) : ∃ k ≤ L, p k = z := by + induction L generalizing p with + | zero => + simp only [qmaGridWalk,SimpleGraph.Walk.support_nil,List.mem_singleton] at hz + exact ⟨0,le_rfl,hz.symm⟩ + | succ L ih => + simp only [qmaGridWalk,SimpleGraph.Walk.support_cons,List.mem_cons] at hz + rcases hz with hz | hz + · exact ⟨0,by omega,hz.symm⟩ + · obtain ⟨k,hk,he⟩ := ih (fun k => p (k+1)) _ hz + exact ⟨k+1,by omega,he⟩ + +noncomputable def qmaSimpleGridPath (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) : + qmaSquareGrid.Path (p 0) (p L) := (qmaGridWalk p L hstep).toPath + +theorem qmaSimpleGridPath_length (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) : + (qmaSimpleGridPath p L hstep).val.length ≤ L := + ((qmaGridWalk p L hstep).length_bypass_le_length).trans_eq (qmaGridWalk_length p L hstep) + +theorem qmaSimpleGridPath_support (p : ℕ → ℕ × ℕ) (L : ℕ) + (hstep : ∀ k < L, qmaSquareGrid.Adj (p k) (p (k+1))) {z : ℕ × ℕ} + (hz : z ∈ (qmaSimpleGridPath p L hstep).val.support) : ∃ k ≤ L, p k = z := + qmaGridWalk_support p L hstep ((qmaGridWalk p L hstep).support_toPath_subset_support hz) + + +theorem qmaGridPath_getVert_step {u v : ℕ × ℕ} (P : qmaSquareGrid.Path u v) + (i : Fin P.val.length) : + qmaSquareGrid.Adj (P.val.getVert i.castSucc.val) (P.val.getVert i.succ.val) := + P.val.adj_getVert_succ i.isLt + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGroundComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGroundComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..970e6aa66ce5d54fe3328c19d6cd6500da5e98b9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumGroundComparison.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOperatorQuadratic +import OAI.MathematicalPhysics.ContinuumCoulomb.ManyBody.MediatorGraph + +namespace OAI + +/-! Operator-norm perturbations of the actual finite spin ground energy. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped InnerProductSpace +variable {σ : Type*} [Fintype σ] [DecidableEq σ] + +theorem qmaQuadratic_norm_bound (M : Matrix σ σ ℂ) (x : EuclideanSpace ℂ σ) : + |qmaQuadratic M (fun i => x i)| ≤ ‖spinMatrixOperator M‖*‖x‖^2 := by + rw [qmaQuadratic_operator,qmaMatrixOperator_square] + calc + _ ≤ ‖x‖*‖spinMatrixOperator M x‖ := abs_real_inner_le_norm _ _ + _ ≤ ‖x‖*(‖spinMatrixOperator M‖*‖x‖) := + mul_le_mul_of_nonneg_left ((spinMatrixOperator M).le_opNorm x) (norm_nonneg x) + _ = _ := by ring + +theorem qmaNormalizedBottom_bddBelow (M : Matrix σ σ ℂ) : + BddBelow {e | ∃ x : EuclideanSpace ℂ σ, ‖x‖ = 1 ∧ + e = ⟪x,spinMatrixOperator M x⟫_ℝ} := by + refine ⟨-‖spinMatrixOperator M‖,?_⟩ + rintro e ⟨x,hx,rfl⟩ + have h := (abs_le.mp (qmaQuadratic_norm_bound M x)).1 + simpa only [hx,one_pow,mul_one,qmaQuadratic_operator,qmaMatrixOperator_square] using h + +theorem qmaNormalizedBottom_le (M : Matrix σ σ ℂ) (x : EuclideanSpace ℂ σ) + (hx : ‖x‖ = 1) : + MediatorGraph.normalizedBottom M ≤ qmaQuadratic M (fun i => x i) := by + rw [qmaQuadratic_operator,qmaMatrixOperator_square] + exact csInf_le (qmaNormalizedBottom_bddBelow M) ⟨x,hx,rfl⟩ + +theorem le_qmaNormalizedBottom (M : Matrix σ σ ℂ) (u : EuclideanSpace ℂ σ) + (hu : ‖u‖ = 1) {b : ℝ} + (h : ∀ x : EuclideanSpace ℂ σ, ‖x‖ = 1 → b ≤ qmaQuadratic M (fun i => x i)) : + b ≤ MediatorGraph.normalizedBottom M := by + apply le_csInf (show {e | ∃ x : EuclideanSpace ℂ σ, ‖x‖ = 1 ∧ + e = ⟪x,spinMatrixOperator M x⟫_ℝ}.Nonempty from ⟨_,u,hu,rfl⟩) + rintro e ⟨x,hx,rfl⟩ + simpa only [qmaQuadratic_operator,qmaMatrixOperator_square] using h x hx + +theorem qmaNormalizedBottom_error (M N : Matrix σ σ ℂ) + (u : EuclideanSpace ℂ σ) (hu : ‖u‖ = 1) {δ : ℝ} + (herror : ∀ x : EuclideanSpace ℂ σ, ‖x‖ = 1 → + |qmaQuadratic M (fun i => x i)-qmaQuadratic N (fun i => x i)| ≤ δ) : + |MediatorGraph.normalizedBottom M-MediatorGraph.normalizedBottom N| ≤ δ := by + have hMN : MediatorGraph.normalizedBottom N-δ ≤ MediatorGraph.normalizedBottom M := by + apply le_qmaNormalizedBottom M u hu + intro x hx + have hN := qmaNormalizedBottom_le N x hx + have he := (abs_le.mp (herror x hx)).1 + linarith + have hNM : MediatorGraph.normalizedBottom M-δ ≤ MediatorGraph.normalizedBottom N := by + apply le_qmaNormalizedBottom N u hu + intro x hx + have hM := qmaNormalizedBottom_le M x hx + have he := (abs_le.mp (herror x hx)).2 + linarith + exact abs_le.mpr ⟨by linarith,by linarith⟩ + +theorem qmaNormalizedBottom_norm_error (M N : Matrix σ σ ℂ) + (u : EuclideanSpace ℂ σ) (hu : ‖u‖ = 1) {δ : ℝ} + (herror : ‖spinMatrixOperator (M-N)‖ ≤ δ) : + |MediatorGraph.normalizedBottom M-MediatorGraph.normalizedBottom N| ≤ δ := by + apply qmaNormalizedBottom_error M N u hu + intro x hx + rw [← qmaQuadratic_sub] + have h := (qmaQuadratic_norm_bound (M-N) x).trans + (mul_le_mul_of_nonneg_right herror (sq_nonneg ‖x‖)) + simpa only [hx,one_pow,mul_one] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHalfCorridor.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHalfCorridor.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbb47ca35d1bd5b3eb9601e79eb3f25260cebabb --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHalfCorridor.lean @@ -0,0 +1,70 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellPathTemplates +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInnerPorts + +namespace OAI + +/-! Each external corridor splits into two paths contained in their own cells, +joined by one unit edge. These paths meet the internal templates only at ports. -/ + +namespace ContinuumCoulomb + +def qmaHalfCorridorPath (cross : Bool) : Fin 4 → List (ℕ × ℕ) := + if cross then ![ + [(22,16),(23,16),(24,16),(25,16),(26,16),(27,16),(28,16),(29,16),(30,16),(31,16)], + [(16,22),(16,23),(16,24),(16,25),(16,26),(16,27),(16,28),(16,29),(16,30),(16,31)], + [(10,16),(9,16),(8,16),(7,16),(6,16),(5,16),(4,16),(3,16),(2,16),(1,16),(0,16)], + [(16,10),(16,9),(16,8),(16,7),(16,6),(16,5),(16,4),(16,3),(16,2),(16,1),(16,0)]] else ![ + [(23,16),(24,16),(25,16),(26,16),(27,16),(28,16),(29,16),(30,16),(31,16)], + [(16,23),(16,24),(16,25),(16,26),(16,27),(16,28),(16,29),(16,30),(16,31)], + [(9,16),(8,16),(7,16),(6,16),(5,16),(4,16),(3,16),(2,16),(1,16),(0,16)], + [(16,9),(16,8),(16,7),(16,6),(16,5),(16,4),(16,3),(16,2),(16,1),(16,0)]] + +def qmaLocalPatchPath (e : Fin 9) : List (ℕ × ℕ) := + (qmaCrossingPatchPath e).map (fun z => (10+z.1,10+z.2)) + +def qmaCellBoundary : Fin 4 → ℕ × ℕ := ![(31,16),(16,31),(0,16),(16,0)] + +def qmaLocalPort (cross : Bool) (a : Fin 4) : ℕ × ℕ := + if cross then qmaInnerPort (0,0) a else qmaCellPort a + +theorem qmaHalfCorridor_endpoints (cross : Bool) (a : Fin 4) : + (qmaHalfCorridorPath cross a).head? = some (qmaLocalPort cross a) ∧ + (qmaHalfCorridorPath cross a).getLast? = some (qmaCellBoundary a) := by + cases cross <;> fin_cases a <;> decide + +theorem qmaHalfCorridor_length (cross : Bool) (a : Fin 4) : + 9 ≤ (qmaHalfCorridorPath cross a).length ∧ (qmaHalfCorridorPath cross a).length ≤ 11 := by + cases cross <;> fin_cases a <;> decide + +theorem qmaHalfCorridor_chain (cross : Bool) (a : Fin 4) : + (qmaHalfCorridorPath cross a).IsChain + (fun p q => Nat.dist p.1 q.1+Nat.dist p.2 q.2 = 1) := by + cases cross <;> fin_cases a <;> decide + +theorem qmaHalfCorridor_simple (cross : Bool) (a : Fin 4) : + (qmaHalfCorridorPath cross a).Nodup := by + cases cross <;> fin_cases a <;> decide + +theorem qmaHalfCorridor_bounded (cross : Bool) (a : Fin 4) : + ∀ p ∈ qmaHalfCorridorPath cross a, p.1 < 32 ∧ p.2 < 32 := by + cases cross <;> fin_cases a <;> decide + +theorem qmaHalfCorridor_disjoint (cross : Bool) (a b : Fin 4) (hab : a ≠ b) : + Disjoint (qmaHalfCorridorPath cross a).toFinset (qmaHalfCorridorPath cross b).toFinset := by + cases cross <;> fin_cases a <;> fin_cases b <;> first | exact (hab rfl).elim | decide + +theorem qmaHalfCorridor_pair (a : Fin 4) (e : Fin 6) : + Disjoint ((qmaHalfCorridorPath false a).drop 1).toFinset (qmaCellPairPath e).toFinset := by + fin_cases a <;> fin_cases e <;> decide + +theorem qmaHalfCorridor_ray (a b : Fin 4) : + Disjoint ((qmaHalfCorridorPath false a).drop 1).toFinset (qmaCellRayPath b).toFinset := by + fin_cases a <;> fin_cases b <;> decide + +theorem qmaHalfCorridor_patch (a : Fin 4) (e : Fin 9) : + Disjoint ((qmaHalfCorridorPath true a).drop 1).toFinset (qmaLocalPatchPath e).toFinset := by + fin_cases a <;> fin_cases e <;> decide + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistory.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..326df95f6a351fa4ca2de82a2691a8c52c5e23d1 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistory.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPrefix +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.ClockPathBound + +namespace OAI + +/-! Quantitative propagation for the actual H,T,CNOT circuit history. -/ + +noncomputable section +open scoped BigOperators +namespace ContinuumCoulomb +open Matrix + +def qmaHistoryGauge (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) (t : ℕ) : + EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + qmaApplyMatrix (qmaPrefixMatrix c t).conjTranspose (u t) + +def qmaPropagationEnergy (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + ∑ t ∈ Finset.range c.gates.length, ‖u (t+1)-qmaApplyMatrix (qmaStepMatrix c t) (u t)‖^2 + +theorem qmaHistoryGauge_norm (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) (t : ℕ) : + ‖qmaHistoryGauge c u t‖ = ‖u t‖ := by + apply qmaApplyMatrix_norm + simpa only [Matrix.conjTranspose_conjTranspose] using qmaPrefixMatrix_cogram c hc t + +theorem qmaHistoryGauge_step (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) + (t : ℕ) (ht : t < c.gates.length) : + qmaHistoryGauge c u (t+1)-qmaHistoryGauge c u t = + qmaApplyMatrix (qmaPrefixMatrix c (t+1)).conjTranspose + (u (t+1)-qmaApplyMatrix (qmaStepMatrix c t) (u t)) := by + have hp : (qmaPrefixMatrix c (t+1)).conjTranspose*qmaStepMatrix c t = + (qmaPrefixMatrix c t).conjTranspose := by + rw [qmaPrefixMatrix_succ c t ht,Matrix.conjTranspose_mul,mul_assoc, + qmaStepMatrix_gram c hc t ht,mul_one] + rw [qmaApplyMatrix_sub,←qmaApplyMatrix_mul,hp] + rfl + +theorem qmaHistoryGauge_energy (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + clockPathEnergy (qmaHistoryGauge c u) c.gates.length = qmaPropagationEnergy c u := by + apply Finset.sum_congr rfl + intro t ht + rw [qmaHistoryGauge_step c hc u t (Finset.mem_range.mp ht),qmaApplyMatrix_norm] + simpa only [Matrix.conjTranspose_conjTranspose] using qmaPrefixMatrix_cogram c hc (t+1) + +theorem qma_history_anchor_bound (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) (t : ℕ) + (ht : t ≤ c.gates.length) : + ‖u t-qmaApplyMatrix (qmaPrefixMatrix c t) (u 0)‖^2 ≤ + (c.gates.length:ℝ)*qmaPropagationEnergy c u := by + have heq : qmaApplyMatrix (qmaPrefixMatrix c t) + (qmaHistoryGauge c u t-qmaHistoryGauge c u 0) = + u t-qmaApplyMatrix (qmaPrefixMatrix c t) (u 0) := by + rw [qmaApplyMatrix_sub] + change qmaApplyMatrix (qmaPrefixMatrix c t) + (qmaApplyMatrix (qmaPrefixMatrix c t).conjTranspose (u t)) - + qmaApplyMatrix (qmaPrefixMatrix c t) + (qmaApplyMatrix (qmaPrefixMatrix c 0).conjTranspose (u 0)) = _ + rw [←qmaApplyMatrix_mul,qmaPrefixMatrix_cogram c hc t] + simp + have h := clock_path_anchor_bound (qmaHistoryGauge c u) c.gates.length t ht + rw [qmaHistoryGauge_energy c hc u] at h + rw [←heq,qmaApplyMatrix_norm _ (qmaPrefixMatrix_gram c hc t)] + exact h + +theorem qma_history_mass_bound (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + (∑ t ∈ Finset.range (c.gates.length+1), ‖u t‖^2) ≤ + 2*(c.gates.length+1:ℝ)*‖u 0‖^2 + + 2*c.gates.length*(c.gates.length+1:ℝ)*qmaPropagationEnergy c u := by + have h := clock_path_mass_bound (qmaHistoryGauge c u) c.gates.length + simpa only [qmaHistoryGauge_norm c hc u,qmaHistoryGauge_energy c hc u] using h + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryBitProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryBitProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..02c4774c43a447a7ceb24974a4b4d6291a9d965d --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryBitProgram.lean @@ -0,0 +1,130 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSupportLookup +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAlgebraicScalarProgram + +namespace OAI + +/-! Literal bit reads for the small history tables, and a bounded Boolean +scan. The register bound is unary; this scan has no spin-configuration loop. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryBitProgram +open ExactQuantumFactoring.BitStackProgram QuantumAlgebraicScalar + +abbrev Data := List ℕ × (List ℕ × List ℕ) +def dataCode : Data → List Bool := + prodCode (listCode Nat.bits) (prodCode (listCode Nat.bits) (listCode Nat.bits)) +abbrev Query := ℕ × Data +def queryCode : Query → List Bool := prodCode Nat.bits dataCode + +def bit (n : ℕ) : Fin 2 := ⟨n % 2,Nat.mod_lt _ (by decide)⟩ + +def row (d : Data) (q : ℕ) : Fin 2 := + bit (QuantumSupportLookup.value (q,d.1,d.2.1)) + +def column (d : Data) (q : ℕ) : Fin 2 := + bit (QuantumSupportLookup.value (q,d.1,d.2.2)) + +def readPair (x : Query) : ℕ × ℕ := ((row x.2 x.1).val,(column x.2 x.1).val) + +noncomputable opaque rowProgram : Procedure queryCode Nat.bits (fun x => (row x.2 x.1).val) := by + let q := Procedure.first Nat.bits dataCode + let d := Procedure.second Nat.bits dataCode + let labels := (Procedure.first (listCode Nat.bits) + (prodCode (listCode Nat.bits) (listCode Nat.bits))).comp d + let values := (Procedure.second (listCode Nat.bits) + (prodCode (listCode Nat.bits) (listCode Nat.bits))).comp d + let s := (Procedure.first (listCode Nat.bits) (listCode Nat.bits)).comp values + exact Procedure.binaryMod.comp + ((QuantumSupportLookup.program.comp (q.pair (labels.pair s))).pair + (Procedure.constant queryCode Nat.bits 2)) + +noncomputable opaque columnProgram : + Procedure queryCode Nat.bits (fun x => (column x.2 x.1).val) := by + let q := Procedure.first Nat.bits dataCode + let d := Procedure.second Nat.bits dataCode + let labels := (Procedure.first (listCode Nat.bits) + (prodCode (listCode Nat.bits) (listCode Nat.bits))).comp d + let values := (Procedure.second (listCode Nat.bits) + (prodCode (listCode Nat.bits) (listCode Nat.bits))).comp d + let t := (Procedure.second (listCode Nat.bits) (listCode Nat.bits)).comp values + exact Procedure.binaryMod.comp + ((QuantumSupportLookup.program.comp (q.pair (labels.pair t))).pair + (Procedure.constant queryCode Nat.bits 2)) + +noncomputable opaque readPairProgram : + Procedure queryCode (prodCode Nat.bits Nat.bits) readPair := + rowProgram.pair columnProgram + +theorem bit_as_test (n : ℕ) : bit n = if n % 2 = 0 then 0 else 1 := by + apply Fin.ext + have hn := Nat.mod_lt n (by decide : 0 < 2) + by_cases h : n % 2 = 0 + · simp [bit,h] + · have he : n % 2 = 1 := by omega + simp [bit,he] + +def matrixEntry (A : Fin 2 → Fin 2 → Scalar) (x : ℕ × ℕ) : Scalar := + A (bit x.1) (bit x.2) + +noncomputable opaque matrixEntryProgram (A : Fin 2 → Fin 2 → Scalar) : + Procedure (prodCode Nat.bits Nat.bits) scalarCode (matrixEntry A) := by + let l := Procedure.first Nat.bits Nat.bits + let r := Procedure.second Nat.bits Nat.bits + let two := Procedure.constant (prodCode Nat.bits Nat.bits) Nat.bits 2 + let zero := Procedure.constant (prodCode Nat.bits Nat.bits) Nat.bits 0 + let bl := Procedure.binaryEq.comp ((Procedure.binaryMod.comp (l.pair two)).pair zero) + let br := Procedure.binaryEq.comp ((Procedure.binaryMod.comp (r.pair two)).pair zero) + exact ((Procedure.ofBool₂ scalarCode + (fun b c => A (if b then 0 else 1) (if c then 0 else 1))).comp + (bl.pair br)).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq,matrixEntry,bit_as_test]) + +def allBits (xs : List Bool) : Bool := xs.all id + +private theorem fold_and (xs : List Bool) (b : Bool) : + xs.foldl (fun a c => c && a) b = (b && xs.all id) := by + induction xs generalizing b with + | nil => simp + | cons c xs ih => + simp only [List.foldl_cons,List.all_cons,id_eq,ih] + cases b <;> cases c <;> rfl + +noncomputable opaque allProgram : + Procedure (listCode Procedure.boolCode) Procedure.boolCode allBits := by + let p := Procedure.foldList false Procedure.boolAnd (Polynomial.C 1) (by + intro xs b i + norm_num [Procedure.boolCode]) + exact (p.comp ((Procedure.identity (listCode Procedure.boolCode)).pair + (Procedure.constant (listCode Procedure.boolCode) Procedure.boolCode true))).congrFun + (by intro xs; simp only [Function.comp_apply,id_eq,fold_and,Bool.true_and,allBits]) + +theorem row_actual (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (s t : Fin (QuantumOrderedSupport.sites c hT a).length → Fin 2) + (q : QuantumOrderedSupport.Qubit c) : + row (QuantumOrderedSupport.encodedSites c hT a, + QuantumSupportLookup.supportBits c hT a s, + QuantumSupportLookup.supportBits c hT a t) + (QuantumOrderedSupport.siteNumber c q) = + qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun i => s ((QuantumOrderedSupport.supportEquiv c hT a).symm i)) q := + QuantumSupportLookup.support_readBit c hT a s q + +theorem column_actual (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (s t : Fin (QuantumOrderedSupport.sites c hT a).length → Fin 2) + (q : QuantumOrderedSupport.Qubit c) : + column (QuantumOrderedSupport.encodedSites c hT a, + QuantumSupportLookup.supportBits c hT a s, + QuantumSupportLookup.supportBits c hT a t) + (QuantumOrderedSupport.siteNumber c q) = + qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun i => t ((QuantumOrderedSupport.supportEquiv c hT a).symm i)) q := + QuantumSupportLookup.support_readBit c hT a t q + +end ContinuumCoulomb.QuantumHistoryBitProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCellProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCellProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..463ea82c3e629a238da74bfcd0238b4eb08292a6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCellProgram.lean @@ -0,0 +1,104 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSweepCellProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryPrecisionProgram + +namespace OAI + +/-! Polynomial generation of the exact ordered history cell arrays. All +list loops are bounded by unary circuit counts; coordinate arithmetic is +binary. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryCells +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode QuantumHistoryDescriptors +open QuantumOrderedCellProgram QuantumRouteCode + +abbrev Input := QMACircuit × ℕ +abbrev inputCode := QuantumHistoryDescriptors.referenceCode + +noncomputable opaque gateCellProgram : Procedure inputCode pairCode + (fun x => gateCell x.1 x.2) := + (Procedure.listGet pairCode (0,0)).comp + ((Procedure.second circuitCode Nat.bits).pair + (QuantumSweepCells.valueProgram.comp (Procedure.first circuitCode Nat.bits))) + +noncomputable opaque referenceCellProgram : Procedure inputCode pairCode + (fun x => referenceCell x.1 x.2) := by + let c := Procedure.first circuitCode Nat.bits + let i := Procedure.second circuitCode Nat.bits + let sparse := sparseCircuitProgram.comp c + let descriptor := orderedAtProgram.comp (sparse.pair i) + let time := timeValueProgram.comp (sparse.pair descriptor) + exact gateCellProgram.comp (c.pair time) + +noncomputable opaque qubitCellProgram : Procedure inputCode pairCode + (fun x => qubitCell x.1 x.2) := by + let c := Procedure.first circuitCode Nat.bits + let j := Procedure.second circuitCode Nat.bits + let sparse := sparseCircuitProgram.comp c + let refs := Procedure.successor.comp (referenceWorkProgram.comp sparse) + let time := Procedure.unaryToBits.comp (timeProgram.comp sparse) + let two := Procedure.constant inputCode Nat.bits 2 + let one := Procedure.constant inputCode Nat.bits 1 + let cutoff := Procedure.binaryAdd.comp (time.pair two) + let k := Procedure.binarySub.comp (j.pair refs) + let before := Procedure.binarySub.comp (k.pair one) + let last := Procedure.binarySub.comp (time.pair one) + let clock := Procedure.conditional (Procedure.binaryLe.comp (before.pair last)) before last + let work := Procedure.binarySub.comp (k.pair cutoff) + let modulus := Procedure.successor.comp (Procedure.unaryToBits.comp (workProgram.comp c)) + let coords := (Procedure.binaryDiv.comp (work.pair modulus)).pair + (Procedure.binaryMod.comp (work.pair modulus)) + exact (Procedure.conditional (Procedure.binaryLt.comp (j.pair refs)) referenceCellProgram + (Procedure.conditional (Procedure.binaryLt.comp (k.pair cutoff)) + (gateCellProgram.comp (c.pair clock)) coords)).congrFun (by + intro x + simp only [qubitCell,Function.comp_apply,id_eq,decide_eq_true_eq,min_def]) + +noncomputable opaque termCellProgram : Procedure inputCode pairCode + (fun x => termCell x.1 x.2) := by + let c := Procedure.first circuitCode Nat.bits + let i := Procedure.second circuitCode Nat.bits + let refs := Procedure.successor.comp (referenceWorkProgram.comp (sparseCircuitProgram.comp c)) + let index := Procedure.conditional (Procedure.binaryLt.comp (i.pair refs)) i + (Procedure.binarySub.comp (i.pair refs)) + exact (referenceCellProgram.comp (c.pair index)).congrFun (by + intro x + simp only [termCell,Function.comp_apply,decide_eq_true_eq]) + +private noncomputable def qubitEntryProgram : + Procedure (prodCode unaryCode circuitCode) pairCode + (fun x => qubitCell x.2 x.1) := + qubitCellProgram.comp ((Procedure.second unaryCode circuitCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode circuitCode))) + +private noncomputable def termEntryProgram : + Procedure (prodCode unaryCode circuitCode) pairCode + (fun x => termCell x.2 x.1) := + termCellProgram.comp ((Procedure.second unaryCode circuitCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode circuitCode))) + +noncomputable opaque qubitCellsProgram : Procedure circuitCode (listCode pairCode) qubitCells := + ((Procedure.tabulate (f := fun c i => qubitCell c i) (0,0) qubitEntryProgram).comp + ((QuantumHistoryPrecisionProgram.sourceQubitsProgram.comp sparseCircuitProgram).pair + (Procedure.identity circuitCode))).congrFun (by intro c; rfl) + +noncomputable opaque referenceCellsProgram : + Procedure circuitCode (listCode pairCode) referenceCells := + ((Procedure.tabulate (f := fun c i => termCell c i) (0,0) termEntryProgram).comp + ((QuantumHistorySamplerProgram.countProgram.comp sparseCircuitProgram).pair + (Procedure.identity circuitCode))).congrFun (by intro c; rfl) + +noncomputable opaque valueProgram : Procedure circuitCode stateCode value := + (qubitCellsProgram.pair ((anchorsProgram 4096).comp referenceCellsProgram)).congrFun (by + intro c + simp only [value,Function.comp_apply,patternCount_eq]) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime circuitCode stateCode value := + valueProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryCells + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCells.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..eed7ace8abc81fb74ab3caf957a476ba164ae274 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryCells.lean @@ -0,0 +1,179 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSweepCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDescriptorSites +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialReference +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedCellTable +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedLabelTable + +namespace OAI + +/-! Natural cell lookups for the actual sparse history. The reference +lookup uses the same time-grouped descriptors as the sampled Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryCells +open QuantumHistoryDescriptors QuantumOrderedSourceIndex + +def encodeCell {rows width : ℕ} (p : QMAGridCell rows width) : ℕ × ℕ := + (p.1.val,p.2.val) + +def gateCell (c : QMACircuit) (t : ℕ) : ℕ × ℕ := + ((QuantumSweepCells.value c).drop t).headD (0,0) + +def referenceCell (c : QMACircuit) (i : ℕ) : ℕ × ℕ := + gateCell c (timeValue (qmaSparseCircuit c) (orderedAt (qmaSparseCircuit c) i)) + +def qubitCell (c : QMACircuit) (j : ℕ) : ℕ × ℕ := + let s := qmaSparseCircuit c + let refs := referenceWork s+1 + if j + change referenceCell c (if i.val + change referenceCell c (if qmaHistoryReferenceWork (qmaSparseCircuit c)+1+i.val< + qmaHistoryReferenceWork (qmaSparseCircuit c)+1 + then qmaHistoryReferenceWork (qmaSparseCircuit c)+1+i.val + else qmaHistoryReferenceWork (qmaSparseCircuit c)+1+i.val- + (qmaHistoryReferenceWork (qmaSparseCircuit c)+1))=_ + rw [ite_eq_right (by omega),Nat.add_sub_cancel_left] + exact referenceCell_actual c hT i.castSucc + +theorem qubitCells_actual (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) : + qubitCells c=List.ofFn (fun i : Fin (qubitCount (qmaSparseCircuit c)) => + encodeCell (qmaOrderedQubitCell c hT (qubits (qmaSparseCircuit c) i))) := by + apply List.ext_getElem + · simp only [qubitCells,List.length_map,List.length_range,List.length_ofFn] + · intro i hi hj + simp only [qubitCells,List.getElem_map,List.getElem_range,List.getElem_ofFn] + let j : Fin (qubitCount (qmaSparseCircuit c)) := ⟨i,by + simpa only [List.length_ofFn] using hj⟩ + have he := congrFun (qubits_index (qmaSparseCircuit c)) (qubits (qmaSparseCircuit c) j) + simp only [QuantumOrderedLabelTable.index,Equiv.symm_apply_apply] at he + simpa only [←he] using qubitCell_actual c hT (qubits (qmaSparseCircuit c) j) + +theorem referenceCells_actual (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) : + referenceCells c=List.ofFn (fun i : Fin (referenceCount (qmaSparseCircuit c)) => + encodeCell (qmaOrderedTermCell c hT (reference (qmaSparseCircuit c) i))) := by + apply List.ext_getElem + · simp only [referenceCells,List.length_map,List.length_range,List.length_ofFn] + · intro i hi hj + simp only [referenceCells,List.getElem_map,List.getElem_range,List.getElem_ofFn] + let j : Fin (referenceCount (qmaSparseCircuit c)) := ⟨i,by + simpa only [List.length_ofFn] using hj⟩ + simpa only [Equiv.symm_apply_apply] using + termCell_actual c hT (reference (qmaSparseCircuit c) j) + +private theorem sourceTerms_first (c : QMACircuit) (hT : 0 a (reference c i)))= + List.ofFn (fun i : Fin (referenceCount c*patternCount) => + a (QuantumPaddedLabelProgram.sourceTerms c hT i).1) := by + rw [QuantumOrderedCellProgram.anchors_ofFn] + rw [←QuantumOrderedLabelTable.product_table (fun p : + Fin (referenceCount c) × Fin patternCount => a (reference c p.1))] + apply congrArg List.ofFn + funext i + rw [sourceTerms_first] + +theorem value_actual (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) : + value c=QuantumOrderedCellTable.table (qubits (qmaSparseCircuit c)) + (QuantumPaddedLabelProgram.sourceTerms (qmaSparseCircuit c) hT) + (fun q => encodeCell (qmaOrderedQubitCell c hT q)) + (fun a => encodeCell (qmaOrderedTermCell c hT a.1)) := by + apply Prod.ext + · exact qubitCells_actual c hT + · change QuantumOrderedCellProgram.anchors patternCount (referenceCells c)=_ + rw [referenceCells_actual c hT] + dsimp only [QuantumOrderedCellTable.table] + exact anchors_source (qmaSparseCircuit c) hT (fun a => encodeCell (qmaOrderedTermCell c hT a)) + +end ContinuumCoulomb.QuantumHistoryCells + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryComparison.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..d899a4fd6202a4c54691220dbf4f6843a1e1af68 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryComparison.lean @@ -0,0 +1,124 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryBitProgram + +namespace OAI + +/-! Unary-bounded equality checks for the clock/work registers. A single +specified bit may be flipped, as required by the propagation delta. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryComparison +open ExactQuantumFactoring.BitStackProgram QuantumHistoryBitProgram + +abbrev Input := ℕ × (ℕ × (Bool × (ℕ × Data))) +def inputCode : Input → List Bool := prodCode unaryCode + (prodCode Nat.bits (prodCode Procedure.boolCode (prodCode Nat.bits dataCode))) + +def point (x : Input) (k : ℕ) : Bool := + decide (row x.2.2.2.2 (x.2.1+k) = + if x.2.2.1=true ∧ x.2.1+k=x.2.2.2.1 then + Equiv.swap (0:Fin 2) 1 (column x.2.2.2.2 (x.2.1+k)) + else column x.2.2.2.2 (x.2.1+k)) + +def value (x : Input) : Bool := ((List.range x.1).map (point x)).all id + +theorem value_iff (x : Input) : value x=true ↔ + ∀ i : Fin x.1, row x.2.2.2.2 (x.2.1+i.val) = + if x.2.2.1=true ∧ x.2.1+i.val=x.2.2.2.1 then + Equiv.swap (0:Fin 2) 1 (column x.2.2.2.2 (x.2.1+i.val)) + else column x.2.2.2.2 (x.2.1+i.val) := by + simp only [value,List.all_map,List.all_eq_true,List.mem_range, + Function.comp_apply,id_eq,point,decide_eq_true_eq] + exact ⟨fun h i => h i.val i.isLt,fun h i hi => h ⟨i,hi⟩⟩ + +theorem no_flip_iff (count base target : ℕ) (d : Data) : + value (count,base,false,target,d)=true ↔ + ∀ i : Fin count, row d (base+i.val)=column d (base+i.val) := by + rw [value_iff] + simp only [Bool.false_eq_true,false_and,ite_false] + +theorem value_equiv_iff {ι : Type} {count : ℕ} (e : ι ≃ Fin count) + (base target : ℕ) (d : Data) : + value (count,base,false,target,d)=true ↔ + (fun i => row d (base+(e i).val))=(fun i => column d (base+(e i).val)) := by + rw [no_flip_iff,funext_iff] + constructor + · intro h i + exact h (e i) + · intro h i + obtain ⟨j,rfl⟩ := e.surjective i + exact h j + +theorem value_flip_iff {ι : Type} [DecidableEq ι] {count : ℕ} (e : ι ≃ Fin count) + (base : ℕ) (q : ι) (d : Data) : + value (count,base,true,base+(e q).val,d)=true ↔ + (fun i => row d (base+(e i).val))= + qmaBitFlip q (fun i => column d (base+(e i).val)) := by + rw [value_iff,funext_iff] + have hv (i : ι) (hi : i≠q) : (e i).val≠(e q).val := + fun h => hi (e.injective (Fin.ext h)) + constructor + · intro h i + by_cases hi : i=q + · subst i + simpa [qmaBitFlip] using h (e q) + · simpa [qmaBitFlip,hi,hv i hi] using h (e i) + · intro h i + obtain ⟨j,rfl⟩ := e.surjective i + by_cases hj : j=q + · subst j + simpa [qmaBitFlip] using h q + · simpa [qmaBitFlip,hj,hv j hj] using h j + +abbrev PointInput := Input × ℕ +def pointCode : PointInput → List Bool := prodCode inputCode Nat.bits + +noncomputable opaque countProgram : Procedure inputCode unaryCode Prod.fst := Procedure.first _ _ +noncomputable opaque baseProgram : Procedure inputCode Nat.bits (fun x => x.2.1) := + (Procedure.first _ _).comp (Procedure.second _ _) +noncomputable opaque flipProgram : Procedure inputCode Procedure.boolCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp ((Procedure.second _ _).comp (Procedure.second _ _)) +noncomputable opaque targetProgram : Procedure inputCode Nat.bits (fun x => x.2.2.2.1) := + (Procedure.first _ _).comp + ((Procedure.second _ _).comp ((Procedure.second _ _).comp (Procedure.second _ _))) +noncomputable opaque dataProgram : Procedure inputCode dataCode (fun x => x.2.2.2.2) := + (Procedure.second _ _).comp + ((Procedure.second _ _).comp ((Procedure.second _ _).comp (Procedure.second _ _))) + +private theorem swap_val (b : Fin 2) : (Equiv.swap (0:Fin 2) 1 b).val=1-b.val := by + fin_cases b <;> decide + +noncomputable opaque pointProgram : Procedure pointCode Procedure.boolCode + (fun p => point p.1 p.2) := by + let x := Procedure.first inputCode Nat.bits + let k := Procedure.second inputCode Nat.bits + let label := Procedure.binaryAdd.comp ((baseProgram.comp x).pair k) + let query := label.pair (dataProgram.comp x) + let r := rowProgram.comp query + let c := columnProgram.comp query + let flip := Procedure.boolAnd.comp ((flipProgram.comp x).pair + (Procedure.binaryEq.comp (label.pair (targetProgram.comp x)))) + let expected := Procedure.conditional flip + (Procedure.binarySub.comp ((Procedure.constant pointCode Nat.bits 1).pair c)) c + exact (Procedure.binaryEq.comp (r.pair expected)).congrFun (by + intro p + apply Bool.eq_iff_iff.mpr + simp only [Function.comp_apply,point,decide_eq_true_eq,Bool.and_eq_true] + split_ifs <;> simp only [Fin.ext_iff,swap_val]) + +noncomputable opaque unaryPointProgram : + Procedure (prodCode unaryCode inputCode) Procedure.boolCode + (fun x => point x.2 x.1) := + pointProgram.comp ((Procedure.second unaryCode inputCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode inputCode))) + +noncomputable opaque program : Procedure inputCode Procedure.boolCode value := + (allProgram.comp ((Procedure.tabulate (f := fun x i => point x i) false unaryPointProgram).comp + (countProgram.pair (Procedure.identity inputCode)))).congrFun (by + intro x + simp only [Function.comp_apply,id_eq,value,allBits]) + +end ContinuumCoulomb.QuantumHistoryComparison + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDegree.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a74dcf1b2161091dcd26722c25f7df590650aee --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDegree.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawIncidence +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryFork +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListFinalDegree + +namespace OAI + +/-! A fixed degree bound for the literal raw history output. Consequently a +constant number of literal fork rounds suffices. -/ + +noncomputable section +namespace ContinuumCoulomb +open QuantumOrderedIncidence QuantumRawIncidence QuantumOrderedLabelTable +open scoped Classical + +namespace QuantumOrderedLabelCompile + +theorem output_degree {ι κ : Type} [Fintype ι] [DecidableEq ι] + [Fintype κ] [DecidableEq κ] {n m D : ℕ} + (q : Fin n ≃ ι) (e : Fin m ≃ κ) (xs : κ → List ι) + (w : κ → ι → Fin 4) (J : κ → ℚ) + (hlen : ∀ a, (xs a).length ≤ 6) (hdup : ∀ a, (xs a).Nodup) + (hD : 1 ≤ D) (hinc : Bounded xs D) (N v : ℕ) + (hv : v QuantumOrderedSupport.sites b hT p.1) + (sourceWord b hT) (sampledWeight k b hT)) := by + unfold historyInput + rw [sourceEntries_table] + have h := QuantumOrderedLabelCompile.output_degree (qubits b) (sourceTerms b hT) + (fun p : Term b => QuantumOrderedSupport.sites b hT p.1) + (sourceWord b hT) (sampledWeight k b hT) + (fun p => QuantumOrderedSupport.sites_length b hT p.1) + (fun p => QuantumOrderedSupport.sites_nodup b hT p.1) + (by decide : 1 ≤ 2359296) (QuantumHistoryIncidence.sparse_padded_bound c hc hT hne) + N v.val (by simpa only [historyQubits,← hi] using v.isLt) + have hd : 6+22*(12544*2359296)=historyDegree := by norm_num [historyDegree] + rw [hd] at h + change degree (QuantumOrderedLabelCompile.output (historyInput b hT N)).1 v.val ≤ + historyDegree + rw [hi] + exact h + +theorem sparse_fork_degree_three (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) + (v : Fin (forkState (qmaSparseCircuit c) hT N historyDegree).1) : + degree ((forkState (qmaSparseCircuit c) hT N historyDegree).2.1 ++ + activeBonds (forkState (qmaSparseCircuit c) hT N historyDegree).2.2.2) v.val ≤ 3 := by + exact initial_iterate_full_degree_of_bound _ _ + (fun b hb => (history_valid (qmaSparseCircuit c) hT N b hb).2.2) _ _ _ + (sparse_history_degree c hc hT hne N) v + +end QuantumPaddedLabelProgram +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDelta.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDelta.lean new file mode 100644 index 0000000000000000000000000000000000000000..474e8018411fa6a08ad55e4505871d6f86558b01 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDelta.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryComparison +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateEntryProgram + +namespace OAI + +/-! Exact register evaluation of the propagation delta. The equality scans +are bounded by the unary circuit size; every bit is read from the supplied +local support table. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDelta +open QuantumAlgebraicScalar QuantumHistoryDescriptors QuantumHistoryBitProgram +open QuantumHistoryDiagonal QuantumHistorySiteProgram + +def guard (c : QMACircuit) (t : ℕ) (d : Data) : Bool := + decide (clockRow c d t=1 ∧ clockRow c d (t+2)=0 ∧ clockRow c d (t+1)=0) + +def flipped (c : QMACircuit) (t : ℕ) (d : Data) : Bool := + QuantumHistoryComparison.value + (c.gates.length+2+(c.work+1),referenceWork c+1,true,referenceWork c+1+(t+1),d) + +def sameClock (c : QMACircuit) (d : Data) : Bool := + QuantumHistoryComparison.value (c.gates.length+2,referenceWork c+1,false,0,d) + +def entry (c : QMACircuit) (t : ℕ) (d : Data) : Scalar := + if guard c t d then + sub (rat (if flipped c t d then 1 else 0)) + (mul (rat (if sameClock c d then 1 else 0)) + (QuantumGateEntryProgram.entry + (c.work,referenceWork c+1+(c.gates.length+2),gateAt (c,t),d))) + else rat 0 + +def qubitEquiv (c : QMACircuit) : + QMACircuitQubit c ≃ Fin (c.gates.length+2+(c.work+1)) := finSumFinEquiv + +theorem qubitEquiv_val (c : QMACircuit) (q : QMACircuitQubit c) : + (qubitEquiv c q).val=distributedNumber c q := by + cases q <;> rfl + +theorem readRow_eq (c : QMACircuit) (d : Data) (q : QMACircuitQubit c) : + readRow c d q=row d (referenceWork c+1+(qubitEquiv c q).val) := by + rw [qubitEquiv_val] + exact congrArg (row d) (number_inr c q) + +theorem readColumn_eq (c : QMACircuit) (d : Data) (q : QMACircuitQubit c) : + readColumn c d q=column d (referenceWork c+1+(qubitEquiv c q).val) := by + rw [qubitEquiv_val] + exact congrArg (column d) (number_inr c q) + +theorem guard_iff (c : QMACircuit) (t : Fin c.gates.length) (d : Data) : + guard c t.val d=true ↔ + QMAClockGuard c.gates.length t (readRow c d ∘ Sum.inl) ∧ + readRow c d (.inl (qmaClockMiddle c.gates.length t))=0 := by + have he : (clockRow c d t.val=1 ∧ clockRow c d (t.val+2)=0 ∧ + clockRow c d (t.val+1)=0) ↔ + QMAClockGuard c.gates.length t (readRow c d ∘ Sum.inl) ∧ + readRow c d (.inl (qmaClockMiddle c.gates.length t))=0 := by + simp only [QMAClockGuard,Function.comp_apply,readRow,QuantumOrderedSupport.siteNumber, + clockRow,referenceWork_eq,qmaClockLeft,qmaClockRight,qmaClockMiddle,and_assoc] + exact ⟨fun h => he.mp (of_decide_eq_true h),fun h => decide_eq_true (he.mpr h)⟩ + +theorem flipped_iff (c : QMACircuit) (t : Fin c.gates.length) (d : Data) : + flipped c t.val d=true ↔ readRow c d= + qmaBitFlip (.inl (qmaClockMiddle c.gates.length t)) (readColumn c d) := by + have h := QuantumHistoryComparison.value_flip_iff (qubitEquiv c) + (referenceWork c+1) (.inl (qmaClockMiddle c.gates.length t)) d + have he : (qubitEquiv c (.inl (qmaClockMiddle c.gates.length t))).val=t.val+1 := rfl + change QuantumHistoryComparison.value + (c.gates.length+2+(c.work+1),referenceWork c+1,true,referenceWork c+1+(t.val+1),d)=true ↔ _ + simpa only [he,← readRow_eq,← readColumn_eq] using h + +theorem sameClock_iff (c : QMACircuit) (d : Data) : + sameClock c d=true ↔ readRow c d ∘ Sum.inl=readColumn c d ∘ Sum.inl := by + have h := QuantumHistoryComparison.value_equiv_iff + (Equiv.refl (Fin (c.gates.length+2))) (referenceWork c+1) 0 d + simpa only [sameClock,Equiv.refl_apply,readRow,readColumn, + QuantumOrderedSupport.siteNumber,referenceWork_eq,Function.comp_def] using h + +theorem gate_entry (c : QMACircuit) (t : ℕ) (d : Data) : + QuantumGateEntryProgram.entry + (c.work,referenceWork c+1+(c.gates.length+2),gateAt (c,t),d)= + QuantumAlgebraicHistory.gate c.work (gateAt (c,t)) + (readRow c d ∘ Sum.inr) (readColumn c d ∘ Sum.inr) := by + rw [QuantumGateEntryProgram.entry_eq] + rfl + +theorem entry_actual (c : QMACircuit) (t : Fin c.gates.length) (d : Data) : + entry c t.val d=QuantumAlgebraicHistory.delta c t (readRow c d) (readColumn c d) := by + unfold entry QuantumAlgebraicHistory.delta QuantumAlgebraicHistory.identity + rw [gate_entry] + simp only [flipped_iff c t d,sameClock_iff c d,gateAt] + by_cases hg : guard c t.val d=true + · have hh := (guard_iff c t d).mp hg + simp only [hg,hh,and_self,ite_true] + · have hh := mt (guard_iff c t d).mpr hg + simp only [hg,hh,Bool.false_eq_true,ite_false] + +end ContinuumCoulomb.QuantumHistoryDelta + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDeltaProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDeltaProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..a702fc0ff29498632df96d3beb61cb11a7ff06b9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDeltaProgram.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryDelta +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryDiagonalProgram + +namespace OAI + +/-! A polynomial exact-arithmetic program for the propagation delta entry. +Only equality scans depend on circuit size; the matrix arity stays local. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDelta +open ExactQuantumFactoring.BitStackProgram QuantumAlgebraicScalar +open QuantumHistoryDiagonal QuantumCircuitCode QuantumHistoryDescriptors + +noncomputable opaque guardProgram : Procedure inputCode Procedure.boolCode + (fun x : Input => guard x.1 x.2.1.2 x.2.2) := by + let zero := Procedure.constant inputCode Nat.bits 0 + let one := Procedure.constant inputCode Nat.bits 1 + let two := Procedure.constant inputCode Nat.bits 2 + let left := Procedure.binaryEq.comp ((clockValueProgram indexProgram).pair one) + let right := Procedure.binaryEq.comp + ((clockValueProgram (Procedure.binaryAdd.comp (indexProgram.pair two))).pair zero) + let middle := Procedure.binaryEq.comp + ((clockValueProgram (Procedure.successor.comp indexProgram)).pair zero) + exact (Procedure.boolAnd.comp (left.pair + (Procedure.boolAnd.comp (right.pair middle)))).congrFun (by + intro x + apply Bool.eq_iff_iff.mpr + simp only [guard,Function.comp_apply,Bool.and_eq_true,decide_eq_true_eq, + Nat.succ_eq_add_one,Fin.ext_iff,Fin.val_one,Fin.val_zero]) + +noncomputable opaque clockCountProgram : Procedure inputCode unaryCode + (fun x : Input => x.1.gates.length+2) := + Procedure.unaryAdd.comp + ((QuantumHistoryDescriptors.timeProgram.comp circuitProgram).pair + (Procedure.constant inputCode unaryCode 2)) + +noncomputable opaque allCountProgram : Procedure inputCode unaryCode + (fun x : Input => x.1.gates.length+2+(x.1.work+1)) := + Procedure.unaryAdd.comp (clockCountProgram.pair + (Procedure.unarySuccessor.comp (workProgram.comp circuitProgram))) + +noncomputable opaque flippedProgram : Procedure inputCode Procedure.boolCode + (fun x : Input => flipped x.1 x.2.1.2 x.2.2) := by + let target := Procedure.binaryAdd.comp + (clockBaseProgram.pair (Procedure.successor.comp indexProgram)) + let args := allCountProgram.pair (clockBaseProgram.pair + ((Procedure.constant inputCode Procedure.boolCode true).pair (target.pair dataProgram))) + exact QuantumHistoryComparison.program.comp args + +noncomputable opaque sameClockProgram : Procedure inputCode Procedure.boolCode + (fun x : Input => sameClock x.1 x.2.2) := + QuantumHistoryComparison.program.comp + (clockCountProgram.pair (clockBaseProgram.pair + ((Procedure.constant inputCode Procedure.boolCode false).pair + ((Procedure.constant inputCode Nat.bits 0).pair dataProgram)))) + +noncomputable opaque gateEntryProgram : Procedure inputCode scalarCode + (fun x : Input => QuantumGateEntryProgram.entry + (x.1.work,referenceWork x.1+1+(x.1.gates.length+2), + QuantumHistorySiteProgram.gateAt (x.1,x.2.1.2),x.2.2)) := + QuantumGateEntryProgram.entryProgram.comp + ((workProgram.comp circuitProgram).pair (workBaseProgram.pair + ((QuantumHistorySiteProgram.gateAtProgram.comp + (circuitProgram.pair indexProgram)).pair dataProgram))) + +noncomputable opaque program : Procedure inputCode scalarCode + (fun x : Input => entry x.1 x.2.1.2 x.2.2) := by + let zero := Procedure.constant inputCode scalarCode (rat 0) + let one := Procedure.constant inputCode scalarCode (rat 1) + let first := Procedure.conditional flippedProgram one zero + let second := mulProgram.comp + ((Procedure.conditional sameClockProgram one zero).pair gateEntryProgram) + exact (Procedure.conditional guardProgram + (subProgram.comp (first.pair second)) zero).congrFun (by + intro x + simp only [entry,Function.comp_apply] + simp only [apply_ite rat]) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode scalarCode + (fun x : Input => entry x.1 x.2.1.2 x.2.2) := program.toTM2 + +end ContinuumCoulomb.QuantumHistoryDelta + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptorProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptorProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ade22b88d877b33f8b28f6037d37a0bc42251ee --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptorProgram.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryDescriptors + +namespace OAI + +/-! Polynomial generation of the literal history-term descriptor list. Only +the circuit's unary work count and gate-list length control enumeration. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDescriptors +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode + +abbrev IndexInput := ℕ × (ℕ × ℕ) +def indexCode : IndexInput → List Bool := + prodCode Nat.bits (prodCode Nat.bits Nat.bits) + +noncomputable opaque atIndexProgram : Procedure indexCode descriptorCode + (fun x => atIndex x.1 x.2.1 x.2.2) := by + let work := Procedure.first Nat.bits (prodCode Nat.bits Nat.bits) + let rest := Procedure.second Nat.bits (prodCode Nat.bits Nat.bits) + let time := (Procedure.first Nat.bits Nat.bits).comp rest + let index := (Procedure.second Nat.bits Nat.bits).comp rest + let one := Procedure.successor.comp time + let three := Procedure.binaryAdd.comp + (one.pair (Procedure.constant indexCode Nat.bits 2)) + let inputs := Procedure.binaryAdd.comp (three.pair (Procedure.successor.comp work)) + let afterInput := Procedure.successor.comp inputs + let tag (n : ℕ) := Procedure.constant indexCode Nat.bits n + let sub {f : IndexInput → ℕ} (bound : Procedure indexCode Nat.bits f) : + Procedure indexCode Nat.bits (fun x => x.2.2-f x) := + Procedure.binarySub.comp (index.pair bound) + let lt {f : IndexInput → ℕ} (bound : Procedure indexCode Nat.bits f) : + Procedure indexCode Procedure.boolCode (fun x => decide (x.2.2 c.gates.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength gateCode (.hadamard 0)).comp + gatesProgram + +noncomputable opaque countProgram : Procedure circuitCode unaryCode + (fun c => 2*c.gates.length+c.work+5) := by + let twice := Procedure.unaryMul.comp + ((Procedure.constant circuitCode unaryCode 2).pair timeProgram) + exact Procedure.unaryAdd.comp + ((Procedure.unaryAdd.comp (twice.pair workProgram)).pair + (Procedure.constant circuitCode unaryCode 5)) + +noncomputable opaque sourceEntryProgram : + Procedure (prodCode unaryCode circuitCode) descriptorCode + (fun x => atIndex x.2.work x.2.gates.length x.1) := by + let circuit := Procedure.second unaryCode circuitCode + let index := Procedure.unaryToBits.comp (Procedure.first unaryCode circuitCode) + let work := Procedure.unaryToBits.comp (workProgram.comp circuit) + let time := Procedure.unaryToBits.comp (timeProgram.comp circuit) + exact atIndexProgram.comp (work.pair (time.pair index)) + +noncomputable opaque sourceProgram : Procedure circuitCode (listCode descriptorCode) source := + ((Procedure.tabulate (f := fun c i => atIndex c.work c.gates.length i) + (0,0) sourceEntryProgram).comp + (countProgram.pair (Procedure.identity circuitCode))).congrFun (by intro c; rfl) + +noncomputable def sourceCertificate : Turing.TM2ComputableInPolyTime circuitCode + (listCode descriptorCode) source := sourceProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryDescriptors + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptors.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptors.lean new file mode 100644 index 0000000000000000000000000000000000000000..82e1d510e25cf7a8cf5b7e28b8e9369559d699ea --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDescriptors.lean @@ -0,0 +1,89 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFirstUseProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedReference + +namespace OAI + +/-! Literal numeric descriptors for the actual history terms, in the exact +finite-sum order used before time grouping. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDescriptors +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode + +abbrev Descriptor := ℕ × ℕ +def descriptorCode : Descriptor → List Bool := prodCode Nat.bits Nat.bits + +def encode (c : QMACircuit) : QMACircuitTerm c → Descriptor + | .inl i => (0,i.val) + | .inr (.inl b) => (1,b.val) + | .inr (.inr (.inl i)) => (2,i.val) + | .inr (.inr (.inr (.inl _))) => (3,0) + | .inr (.inr (.inr (.inr t))) => (4,t.val) + +def atIndex (work time i : ℕ) : Descriptor := + if i < time+1 then (0,i) else + if i < time+1+2 then (1,i-(time+1)) else + if i < time+1+2+(work+1) then (2,i-(time+1+2)) else + if i < time+1+2+(work+1)+1 then (3,0) else + (4,i-(time+1+2+(work+1)+1)) + +theorem atIndex_actual (c : QMACircuit) (a : QMACircuitTerm c) : + atIndex c.work c.gates.length ((qmaHistoryTermIndex c) a).val = encode c a := by + rcases a with i | (b | (i | (u | t))) + · have hi := i.isLt + change atIndex c.work c.gates.length i.val=(0,i.val) + simp only [atIndex,ite_eq_left hi] + · have hb := b.isLt + change atIndex c.work c.gates.length (c.gates.length+1+b.val)=(1,b.val) + have h₁ : ¬c.gates.length+1+b.val < c.gates.length+1 := by omega + have h₂ : c.gates.length+1+b.val < c.gates.length+1+2 := by omega + simp only [atIndex,ite_eq_right h₁,ite_eq_left h₂,Nat.add_sub_cancel_left] + · have hi := i.isLt + change atIndex c.work c.gates.length (c.gates.length+1+(2+i.val))=(2,i.val) + have h₁ : ¬c.gates.length+1+(2+i.val) < c.gates.length+1 := by omega + have h₂ : ¬c.gates.length+1+(2+i.val) < c.gates.length+1+2 := by omega + have h₃ : c.gates.length+1+(2+i.val) < c.gates.length+1+2+(c.work+1) := by omega + simp only [atIndex,ite_eq_right h₁,ite_eq_right h₂,ite_eq_left h₃] + congr 1 + omega + · cases u + change atIndex c.work c.gates.length (c.gates.length+1+(2+(c.work+1)+0))=(3,0) + have h₁ : ¬c.gates.length+1+(2+(c.work+1)+0) < c.gates.length+1 := by omega + have h₂ : ¬c.gates.length+1+(2+(c.work+1)+0) < c.gates.length+1+2 := by omega + have h₃ : ¬c.gates.length+1+(2+(c.work+1)+0) < c.gates.length+1+2+(c.work+1) := by omega + have h₄ : c.gates.length+1+(2+(c.work+1)+0) < c.gates.length+1+2+(c.work+1)+1 := by omega + simp only [atIndex,ite_eq_right h₁,ite_eq_right h₂,ite_eq_right h₃,ite_eq_left h₄] + · have ht := t.isLt + change atIndex c.work c.gates.length + (c.gates.length+1+(2+((c.work+1)+(1+t.val))))=(4,t.val) + have h₁ : ¬c.gates.length+1+(2+((c.work+1)+(1+t.val))) < c.gates.length+1 := by omega + have h₂ : ¬c.gates.length+1+(2+((c.work+1)+(1+t.val))) < c.gates.length+1+2 := by omega + have h₃ : ¬c.gates.length+1+(2+((c.work+1)+(1+t.val))) < c.gates.length+1+2+(c.work+1) := by omega + have h₄ : ¬c.gates.length+1+(2+((c.work+1)+(1+t.val))) < c.gates.length+1+2+(c.work+1)+1 := by omega + simp only [atIndex,ite_eq_right h₁,ite_eq_right h₂,ite_eq_right h₃,ite_eq_right h₄] + congr 1 + omega + +def source (c : QMACircuit) : List Descriptor := + (List.range (2*c.gates.length+c.work+5)).map (atIndex c.work c.gates.length) + +theorem source_actual (c : QMACircuit) : + source c=(qmaHistoryTermList c).map (encode c) := by + apply List.ext_getElem + · simp only [source,List.length_map,List.length_range,qmaHistoryTermList,List.length_ofFn, + qmaHistoryReferenceWork] + · intro i hi hj + simp only [source,List.getElem_map,List.getElem_range,qmaHistoryTermList, + List.getElem_ofFn] + have he := atIndex_actual c ((qmaHistoryTermIndex c).symm ⟨i,by + simpa only [List.length_map,qmaHistoryTermList,List.length_ofFn] using hj⟩) + simpa only [Equiv.apply_symm_apply] using he + +theorem source_length (c : QMACircuit) : (source c).length=2*c.gates.length+c.work+5 := by + simp only [source,List.length_map,List.length_range] + +end ContinuumCoulomb.QuantumHistoryDescriptors + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb2df4a32d38ea0937e4b658d13390d14572af28 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonal.lean @@ -0,0 +1,100 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDescriptorSites +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryBitProgram + +namespace OAI + +/-! The four diagonal descriptor cases are evaluated directly from their +clock/work bits. Their values are exact rational entries of the actual +distributed history operator, before the rebit construction. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDiagonal +open QuantumHistoryDescriptors QuantumHistorySiteProgram QuantumHistoryBitProgram +open QuantumAlgebraicScalar +open scoped Classical + +def clockRow (c : QMACircuit) (d : Data) (i : ℕ) : Fin 2 := + row d (referenceWork c+1+i) + +def workRow (c : QMACircuit) (d : Data) (i : ℕ) : Fin 2 := + row d (referenceWork c+1+(c.gates.length+2)+i) + +def readRow (c : QMACircuit) (d : Data) : QMACircuitQubit c → Fin 2 := + fun q => row d (QuantumOrderedSupport.siteNumber c (.inr q)) + +def readColumn (c : QMACircuit) (d : Data) : QMACircuitQubit c → Fin 2 := + fun q => column d (QuantumOrderedSupport.siteNumber c (.inr q)) + +def weight (c : QMACircuit) (a : Descriptor) (d : Data) : ℚ := + if a.1=0 then + (if clockRow c d a.2=0 ∧ clockRow c d (a.2+1)=1 then 1 else 0) else + if a.1=1 then + (if a.2=0 then (if clockRow c d 0=1 then 0 else 1) + else (if clockRow c d (c.gates.length+1)=0 then 0 else 1)) else + if a.1=2 then + let time := QuantumFirstUseProgram.value (c,a.2) + if clockRow c d time=1 ∧ clockRow c d (time+1)=0 ∧ + c.witness ≤ a.2 ∧ workRow c d a.2≠0 then 14 else 0 else + if a.1=3 then + (if clockRow c d c.gates.length=1 ∧ workRow c d c.work≠1 then 1 else 0) else 0 + +theorem distributed_entry (c : QMACircuit) (a : QMACircuitTerm c) + (ha : (encode c a).1<4) (d : Data) : + QuantumAlgebraicHistory.distributed c (qmaFirstUseTime c) a + (readRow c d) (readColumn c d) = + if readRow c d=readColumn c d then rat (weight c (encode c a) d) else rat 0 := by + rcases a with i | (b | (i | (u | t))) + · rfl + · fin_cases b <;> rfl + · change (if readRow c d=readColumn c d then rat + (if qmaClockAt c.gates.length (qmaFirstUseTime c i) (readRow c d ∘ Sum.inl) ∧ + qmaInputCheck c i (readRow c d ∘ Sum.inr) then 14 else 0) else rat 0) = + if readRow c d=readColumn c d then rat + (if clockRow c d (QuantumFirstUseProgram.value (c,i.val))=1 ∧ + clockRow c d (QuantumFirstUseProgram.value (c,i.val)+1)=0 ∧ + c.witness ≤ i.val ∧ workRow c d i.val≠0 then 14 else 0) else rat 0 + simp only [QuantumFirstUseProgram.value_eq] + unfold qmaClockAt qmaInputCheck + have he : (clockRow c d (qmaFirstUse c i)=1 ∧ + clockRow c d (qmaFirstUse c i+1)=0) ∧ + (c.witness ≤ i.val ∧ workRow c d i.val≠0) ↔ + clockRow c d (qmaFirstUse c i)=1 ∧ + clockRow c d (qmaFirstUse c i+1)=0 ∧ + c.witness ≤ i.val ∧ workRow c d i.val≠0 := by tauto + simp only [readRow,clockRow,workRow,referenceWork_eq, + QuantumOrderedSupport.siteNumber,Function.comp_apply,Fin.val_castSucc,Fin.val_succ] at * + simp only [he] + rfl + · cases u + rfl + · norm_num [encode] at ha + +def supportData (c : QMACircuit) (hT : 0 + qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun j => s ((QuantumOrderedSupport.supportEquiv c hT a).symm j)) (.inr q) := by + funext q + exact QuantumHistoryBitProgram.row_actual c hT a s t (.inr q) + +theorem readColumn_actual (c : QMACircuit) (hT : 0 + qmaSupportExtend ((qmaOrderedHistoryModel c hT).sites a) + (fun j => t ((QuantumOrderedSupport.supportEquiv c hT a).symm j)) (.inr q) := by + funext q + exact QuantumHistoryBitProgram.column_actual c hT a s t (.inr q) + +end ContinuumCoulomb.QuantumHistoryDiagonal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonalProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonalProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..cba2b792090c9db5a8dbee1fa6cac387ec62ad9b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryDiagonalProgram.lean @@ -0,0 +1,95 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryDiagonal +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDescriptorSiteProgram + +namespace OAI + +/-! Exact scalar-register evaluation of the diagonal history descriptors. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryDiagonal +open ExactQuantumFactoring.BitStackProgram QuantumAlgebraicScalar +open QuantumCircuitCode QuantumHistoryDescriptors QuantumHistoryBitProgram + +abbrev Input := QMACircuit × (Descriptor × Data) +def inputCode : Input → List Bool := prodCode circuitCode (prodCode descriptorCode dataCode) + +noncomputable opaque circuitProgram : Procedure inputCode circuitCode Prod.fst := Procedure.first _ _ +noncomputable opaque descriptorProgram : Procedure inputCode descriptorCode (fun x => x.2.1) := + (Procedure.first _ _).comp (Procedure.second _ _) +noncomputable opaque dataProgram : Procedure inputCode dataCode (fun x => x.2.2) := + (Procedure.second _ _).comp (Procedure.second _ _) +noncomputable opaque tagProgram : Procedure inputCode Nat.bits (fun x => x.2.1.1) := + (Procedure.first _ _).comp descriptorProgram +noncomputable opaque indexProgram : Procedure inputCode Nat.bits (fun x => x.2.1.2) := + (Procedure.second _ _).comp descriptorProgram +noncomputable opaque timeProgram : Procedure inputCode Nat.bits (fun x => x.1.gates.length) := + Procedure.unaryToBits.comp (QuantumHistoryDescriptors.timeProgram.comp circuitProgram) + +noncomputable opaque clockBaseProgram : Procedure inputCode Nat.bits + (fun x => referenceWork x.1+1) := + Procedure.successor.comp (referenceWorkProgram.comp circuitProgram) + +noncomputable opaque workBaseProgram : Procedure inputCode Nat.bits + (fun x => referenceWork x.1+1+(x.1.gates.length+2)) := + Procedure.binaryAdd.comp (clockBaseProgram.pair + (Procedure.binaryAdd.comp (timeProgram.pair (Procedure.constant inputCode Nat.bits 2)))) + +noncomputable def clockValueProgram {f : Input → ℕ} (p : Procedure inputCode Nat.bits f) : + Procedure inputCode Nat.bits (fun x => (clockRow x.1 x.2.2 (f x)).val) := + rowProgram.comp ((Procedure.binaryAdd.comp (clockBaseProgram.pair p)).pair dataProgram) + +noncomputable def workValueProgram {f : Input → ℕ} (p : Procedure inputCode Nat.bits f) : + Procedure inputCode Nat.bits (fun x => (workRow x.1 x.2.2 (f x)).val) := + rowProgram.comp ((Procedure.binaryAdd.comp (workBaseProgram.pair p)).pair dataProgram) + +noncomputable opaque firstUseProgram : Procedure inputCode Nat.bits + (fun x => QuantumFirstUseProgram.value (x.1,x.2.1.2)) := + Procedure.unaryToBits.comp + (QuantumFirstUseProgram.program.comp (circuitProgram.pair indexProgram)) + +noncomputable opaque weightProgram : Procedure inputCode scalarCode + (fun x => rat (weight x.1 x.2.1 x.2.2)) := by + let const (n : ℕ) := Procedure.constant inputCode Nat.bits n + let eq {f : Input → ℕ} (p : Procedure inputCode Nat.bits f) (n : ℕ) := + Procedure.binaryEq.comp (p.pair (const n)) + let both {f g : Input → Bool} (p : Procedure inputCode Procedure.boolCode f) + (q : Procedure inputCode Procedure.boolCode g) := Procedure.boolAnd.comp (p.pair q) + let not {f : Input → Bool} (p : Procedure inputCode Procedure.boolCode f) := + Procedure.boolNot.comp p + let scalar (n : ℚ) := Procedure.constant inputCode scalarCode (rat n) + let zero := scalar 0 + let one := scalar 1 + let fault := Procedure.conditional + (both (eq (clockValueProgram indexProgram) 0) + (eq (clockValueProgram (Procedure.successor.comp indexProgram)) 1)) one zero + let left := Procedure.conditional (eq (clockValueProgram (const 0)) 1) zero one + let right := Procedure.conditional + (eq (clockValueProgram (Procedure.successor.comp timeProgram)) 0) zero one + let boundary := Procedure.conditional (eq indexProgram 0) left right + let witness := Procedure.unaryToBits.comp (witnessProgram.comp circuitProgram) + let initial := both (eq (clockValueProgram firstUseProgram) 1) + (both (eq (clockValueProgram (Procedure.successor.comp firstUseProgram)) 0) + (both (Procedure.binaryLe.comp (witness.pair indexProgram)) + (not (eq (workValueProgram indexProgram) 0)))) + let input := Procedure.conditional initial (scalar 14) zero + let work := Procedure.unaryToBits.comp (workProgram.comp circuitProgram) + let output := Procedure.conditional + (both (eq (clockValueProgram timeProgram) 1) (not (eq (workValueProgram work) 1))) one zero + exact (Procedure.conditional (eq tagProgram 0) fault + (Procedure.conditional (eq tagProgram 1) boundary + (Procedure.conditional (eq tagProgram 2) input + (Procedure.conditional (eq tagProgram 3) output zero)))).congrFun (by + intro x + simp only [weight,Function.comp_apply,id_eq,decide_eq_true_eq,Bool.and_eq_true, + Bool.not_eq_true_eq_eq_false,decide_eq_false_iff_not,ne_eq,Fin.ext_iff,Fin.val_zero, + Fin.val_one,Nat.succ_eq_add_one] + simp only [apply_ite rat]) + +noncomputable def weightCertificate : Turing.TM2ComputableInPolyTime inputCode scalarCode + (fun x => rat (weight x.1 x.2.1 x.2.2)) := weightProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryDiagonal + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..e27a28cc3db23d5bb52d2c0ab5be808e88e9371a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnergy.lean @@ -0,0 +1,108 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistory +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInputProjection +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.ClockWeightedBound + +namespace OAI + +/-! A quantitative circuit-history promise gap, for all history vectors. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +def qmaHistoryMass (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + ∑ t ∈ Finset.range (c.gates.length+1), ‖u t‖^2 + +def qmaInputPenalty (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + ‖qmaMask (fun s => ¬QMAAncillaZero c s) (u 0)‖^2 + +def qmaOutputPenalty (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + ‖qmaMask (fun s => s (Fin.last c.work) ≠ 1) (u c.gates.length)‖^2 + +def qmaHistoryEnergy (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : ℝ := + qmaOutputPenalty c u+7*qmaInputPenalty c u+ + 8*c.gates.length*qmaPropagationEnergy c u + +theorem qma_history_legal_endpoint_bound (c : QMACircuit) (hc : c.WellFormed) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + ‖u c.gates.length-qmaApplyMatrix (qmaCircuitMatrix c) + (qmaMask (QMAAncillaZero c) (u 0))‖^2 ≤ + 2*c.gates.length*qmaPropagationEnergy c u+2*qmaInputPenalty c u := by + let v := qmaMask (QMAAncillaZero c) (u 0) + have ha := qma_history_anchor_bound c hc u c.gates.length le_rfl + rw [qmaPrefixMatrix_length] at ha + have hb : ‖qmaApplyMatrix (qmaCircuitMatrix c) (u 0-v)‖^2 = qmaInputPenalty c u := by + rw [qmaApplyMatrix_norm _ (qmaCircuitMatrix_gram c hc)] + dsimp [v] + rw [qmaMask_sub_self] + rfl + have he : (u c.gates.length-qmaApplyMatrix (qmaCircuitMatrix c) (u 0))+ + qmaApplyMatrix (qmaCircuitMatrix c) (u 0-v) = + u c.gates.length-qmaApplyMatrix (qmaCircuitMatrix c) v := by + rw [qmaApplyMatrix_sub] + abel + have h := norm_add_sq_two + (u c.gates.length-qmaApplyMatrix (qmaCircuitMatrix c) (u 0)) + (qmaApplyMatrix (qmaCircuitMatrix c) (u 0-v)) + rw [he,hb] at h + exact h.trans (by linarith) + +theorem qma_history_output_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + ‖qmaMask (QMAAncillaZero c) (u 0)‖^2 ≤ + 2*qmaOutputPenalty c u+12*c.gates.length*qmaPropagationEnergy c u+ + 12*qmaInputPenalty c u := by + let p := fun s : SourceSpinBasis (c.work+1) => s (Fin.last c.work) ≠ 1 + let v := qmaMask (QMAAncillaZero c) (u 0) + let w := qmaApplyMatrix (qmaCircuitMatrix c) v + have hs := qmaRejectVector_sound_all c hc hsound (qmaExtractWitness c (u 0)) + rw [qmaExtractWitness_norm c hc] at hs + have hr : qmaRejectVector c hc (qmaExtractWitness c (u 0)) = qmaMask p w := by + rw [qmaRejectVector,qmaOutputVector,qmaInputVector_extract] + rw [hr] at hs + have hd : ‖qmaMask p w-qmaMask p (u c.gates.length)‖^2 ≤ + 2*c.gates.length*qmaPropagationEnergy c u+2*qmaInputPenalty c u := by + have h := pow_le_pow_left₀ (norm_nonneg _) + (qmaMask_sub_norm_le p w (u c.gates.length)) 2 + rw [norm_sub_rev w] at h + exact h.trans (qma_history_legal_endpoint_bound c hc u) + have ht := norm_add_sq_three (qmaMask p (u c.gates.length)) + (qmaMask p w-qmaMask p (u c.gates.length)) + have he : qmaMask p (u c.gates.length)+ + (qmaMask p w-qmaMask p (u c.gates.length)) = qmaMask p w := by abel + rw [he] at ht + change 3*‖qmaMask p w‖^2 ≤ 4*qmaOutputPenalty c u+ + 12*‖qmaMask p w-qmaMask p (u c.gates.length)‖^2 at ht + nlinarith + +theorem qma_history_energy_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + 2*qmaHistoryMass c u ≤ 5*(c.gates.length+1:ℝ)*qmaHistoryEnergy c u := by + have hm := clock_path_weighted_mass_bound (qmaHistoryGauge c u) c.gates.length + simp only [qmaHistoryGauge_norm c hc u,qmaHistoryGauge_energy c hc u] at hm + change 4*qmaHistoryMass c u ≤ 5*(c.gates.length+1:ℝ)*‖u 0‖^2+ + 20*c.gates.length*(c.gates.length+1:ℝ)*qmaPropagationEnergy c u at hm + have hsplit := qmaMask_complement_square (QMAAncillaZero c) (u 0) + change ‖qmaMask (QMAAncillaZero c) (u 0)‖^2+qmaInputPenalty c u = ‖u 0‖^2 at hsplit + have hout := qma_history_output_sound c hc hsound u + have hx := mul_le_mul_of_nonneg_left hout + (by positivity : 0 ≤ 5*(c.gates.length+1:ℝ)) + have hi : 0 ≤ (c.gates.length+1:ℝ)*qmaInputPenalty c u := by + unfold qmaInputPenalty + positivity + unfold qmaHistoryEnergy + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnumeration.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fd0e008b37fe617d46ed869d60a38c2a2131a3c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryEnumeration.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumDistributedPositive +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumReferenceComparison + +namespace OAI + +/-! Explicit consecutive labels for every term in the distributed history. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +def qmaUnitFin : Unit ≃ Fin 1 where + toFun _ := 0 + invFun _ := () + left_inv u := by cases u; rfl + right_inv i := by fin_cases i; rfl + +abbrev qmaHistoryReferenceWork (c : QMACircuit) : ℕ := 2*c.gates.length+c.work+4 + +def qmaHistoryTermIndex (c : QMACircuit) : QMACircuitTerm c ≃ Fin (qmaHistoryReferenceWork c+1) := + (Equiv.sumCongr (Equiv.refl _) + ((Equiv.sumCongr (Equiv.refl _) + ((Equiv.sumCongr (Equiv.refl _) + ((Equiv.sumCongr qmaUnitFin (Equiv.refl _)).trans finSumFinEquiv)).trans + finSumFinEquiv)).trans finSumFinEquiv)).trans + (finSumFinEquiv.trans (finCongr (by unfold qmaHistoryReferenceWork; omega))) + +def qmaHistoryReferenceTerms (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (i : Fin (qmaHistoryReferenceWork c+1)) := + qmaDistributedTermMatrix c τ ((qmaHistoryTermIndex c).symm i) + +theorem qmaHistoryReferenceTerms_sum (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) : + (∑ i, qmaHistoryReferenceTerms c τ i) = qmaDistributedQubitHamiltonian c τ := by + unfold qmaHistoryReferenceTerms + rw [(qmaHistoryTermIndex c).symm.sum_comp,qmaDistributedTerm_sum] + +theorem qmaHistoryReferenceTerms_nonnegative (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) + (i : Fin (qmaHistoryReferenceWork c+1)) + (u : (QMACircuitQubit c → Fin 2) → ℂ) : + 0 ≤ qmaQuadratic (qmaHistoryReferenceTerms c τ i) u := + qmaDistributedTerm_nonnegative c τ _ u + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryFork.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryFork.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c60fc4da61c0dbb6095eef2b9806e9ad8a7bce3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryFork.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkListInitialAccuracy +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedLabelEnergy + +namespace OAI + +/-! The actual history compiler produces a bounded loop-free exchange list. +Its initial subdivision and ordered fork rounds preserve the full-space +ground energy with the accumulated explicit error. -/ + +noncomputable section +namespace ContinuumCoulomb +open MediatorGraph QuantumRawExchange +open scoped BigOperators Classical + +namespace QuantumOrderedLabelCompile +open QuantumOrderedLabelTable + +theorem output_valid {ι κ : Type} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + {n m : ℕ} (q : Fin n ≃ ι) (e : Fin m ≃ κ) (xs : κ → List ι) + (w : κ → ι → Fin 4) (J : κ → ℚ) + (hlen : ∀ a, (xs a).length ≤ 6) (hx : ∀ a, (xs a).Nodup) (N : ℕ) + (b : MediatorListProgram.Bond) (hb : b ∈ (output (N,n,table e (index q) xs w J)).1) : + b.1 < qubitCount (N,n,table e (index q) xs w J) ∧ + b.2.1 < qubitCount (N,n,table e (index q) xs w J) ∧ b.1 ≠ b.2.1 := by + rw [output_table q e xs w J hlen hx N] at hb + have hv := QuantumOrderedRawBlock.output_valid N + (numberedSites (qubits6 q e) (terms6 e) (finalSites xs w)) + (numberedWord (qubits6 q e) (terms6 e) (finalWord xs w)) + (fun i => finalCoefficient J N (terms6 e i)) b hb + have hn : qubitCount (N,n,table e (index q) xs w J)=finalCount n m*4 := by + rw [qubitCount_table,finalCount_eq] + omega + simpa only [hn,finalCount] using hv + +end QuantumOrderedLabelCompile + +namespace QuantumPaddedLabelProgram +open QuantumPaddedHistory QuantumOrderedSourceIndex QuantumForkList + +theorem history_valid (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) + (b : MediatorListProgram.Bond) (hb : b ∈ (historyOutput c hT N).1) : + b.1 < historyQubits c hT N ∧ b.2.1 < historyQubits c hT N ∧ b.1 ≠ b.2.1 := by + let k := QuantumAlgebraicHistory.samplePrecision c N + have hi : historyInput c hT N = + (N,qubitCount c,QuantumOrderedLabelTable.table (sourceTerms c hT) + (QuantumOrderedLabelTable.index (qubits c)) + (fun p : Term c => QuantumOrderedSupport.sites c hT p.1) + (sourceWord c hT) (sampledWeight k c hT)) := by + unfold historyInput + rw [sourceEntries_table] + unfold historyOutput at hb + rw [hi] at hb + have hv := QuantumOrderedLabelCompile.output_valid (qubits c) (sourceTerms c hT) + (fun p : Term c => QuantumOrderedSupport.sites c hT p.1) + (sourceWord c hT) (sampledWeight k c hT) + (fun p => QuantumOrderedSupport.sites_length c hT p.1) + (fun p => QuantumOrderedSupport.sites_nodup c hT p.1) N b hb + simpa only [historyQubits,hi] using hv + +def forkState (c : QMACircuit) (hT : 0 < c.gates.length) (N D : ℕ) : State := + iterate (N:ℚ) D (initial (historyQubits c hT N) (historyOutput c hT N).1 + (historyOutput c hT N).2 (N:ℚ)) + +theorem fork_accuracy (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) (D : ℕ) : + |normalizedBottom (matrix (forkState c hT N D))-(qmaOrderedHistoryModel c hT).energy| ≤ + ((D:ℝ)+10)/(N:ℝ) := by + have hb : SourceBondLists.bounded (historyQubits c hT N) (historyOutput c hT N).1 := + fun b hb => ⟨(history_valid c hT N b hb).1,(history_valid c hT N b hb).2.1⟩ + have hn : ∀ b ∈ (historyOutput c hT N).1, b.1 ≠ b.2.1 := + fun b hb => (history_valid c hT N b hb).2.2 + have he := initial_iterated_accuracy (historyQubits c hT N) (historyOutput c hT N).1 + hb hn (historyOutput c hT N).2 (N:ℚ) (by exact_mod_cast hN) D + have hh := history_accuracy c hT N hN + have he' : |normalizedBottom (matrix (forkState c hT N D))- + normalizedBottom (rawMatrix (historyQubits c hT N) (historyOutput c hT N))| ≤ + ((D:ℝ)+1)/(N:ℝ) := by + have hcast : ((N:ℚ):ℝ)=(N:ℝ) := by norm_cast + rw [hcast] at he + exact he + exact (abs_sub_le _ _ _).trans ((add_le_add he' hh).trans_eq (by ring)) + +end QuantumPaddedLabelProgram +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryHeight.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..f90b7d715a9a62ca71c744489c9e6c002d7175d0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryHeight.lean @@ -0,0 +1,242 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedCoefficient +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientHeight + +namespace OAI + +/-! Polynomial bounds for the actual rational-register history entries. +The only matrix multiplication takes place on the five-site propagation +core, with at most32 intermediate configurations. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open QuantumAlgebraicScalar QuantumFixedPauli Matrix +open scoped BigOperators Classical + +theorem height_identity {α : Type} [DecidableEq α] (s t : α) : + height (identity s t) ≤ 1 := by + by_cases h : s = t <;> simp [identity,h] + +theorem height_hadamard (s t : Fin 2) : height (hadamard s t) ≤ 2 := by + fin_cases s <;> fin_cases t <;> + norm_num [hadamard,mul,realMul,realSub,realAdd,realNeg,sqrtHalf, + rat,realRat,height,realHeight] + +theorem height_phaseT (s t : Fin 2) : height (phaseT s t) ≤ 2 := by + fin_cases s <;> fin_cases t <;> + norm_num [phaseT,mul,realMul,realSub,realAdd,realNeg,QuantumAlgebraicScalar.add,sqrtHalf, + rat,realRat,imaginary,height,realHeight] + +private theorem height_single_product (n : ℕ) (i : Fin n) + (A : Fin 2 → Fin 2 → Scalar) (hA : ∀ s t, height (A s t) ≤ 2) + (s t : SourceSpinBasis n) : + height (finiteProduct (fun k => if k = i then A (s k) (t k) + else identity (s k) (t k))) ≤ 2 := by + apply (height_finiteProduct _).trans + calc + _ ≤ ∏ k : Fin n, if k = i then (2:ℚ) else 1 := by + apply Finset.prod_le_prod₀ (fun _ _ => height_nonnegative _) + intro k _ + by_cases h : k = i + · simpa only [h,ite_true] using hA (s k) (t k) + · simpa only [h,ite_false] using height_identity (s k) (t k) + _ = 2 := by simp + +theorem height_gate (work : ℕ) (g : QMAGate) (s t : SourceSpinBasis (work+1)) : + height (gate work g s t) ≤ 2 := by + cases g with + | hadamard i => exact height_single_product _ _ _ height_hadamard s t + | phaseT i => exact height_single_product _ _ _ height_phaseT s t + | controlledNot i j => + dsimp only [gate] + split_ifs <;> norm_num + +theorem height_delta (c : QMACircuit) (t : Fin c.gates.length) + (s r : QMACircuitQubit c → Fin 2) : height (delta c t s r) ≤ 3 := by + dsimp only [delta] + split_ifs + · apply (height_sub _ _).trans + have hm := height_mul + (identity (s ∘ Sum.inl) (r ∘ Sum.inl)) + (gate c.work (c.gates.getD t.val (.hadamard 0)) (s ∘ Sum.inr) (r ∘ Sum.inr)) + have hi := height_identity s (qmaBitFlip (Sum.inl (qmaClockMiddle c.gates.length t)) r) + have hj := height_identity (s ∘ Sum.inl) (r ∘ Sum.inl) + have hg := height_gate c.work (c.gates.getD t.val (.hadamard 0)) + (s ∘ Sum.inr) (r ∘ Sum.inr) + have hn := height_nonnegative + (gate c.work (c.gates.getD t.val (.hadamard 0)) (s ∘ Sum.inr) (r ∘ Sum.inr)) + nlinarith + · norm_num + +theorem propagation_configurations (c : QMACircuit) (t : Fin c.gates.length) : + Fintype.card (QMASupportBasis (qmaPropagationSites c t)) ≤ 32 := by + have h := pow_le_pow_right₀ (by norm_num : (1:ℕ) ≤ 2) (qmaPropagationSites_card c t) + simpa only [QMASupportBasis,Fintype.card_fun,Fintype.card_fin,Fintype.card_coe, + show (2:ℕ)^5 = 32 by norm_num] using h + +theorem height_propagationCore (c : QMACircuit) (t : Fin c.gates.length) + (s r : QMASupportBasis (qmaPropagationSites c t)) : + height (propagationCore c t s r) ≤ 288 := by + have hentry (u : QMASupportBasis (qmaPropagationSites c t)) : + height (mul (adjoint (deltaCore c t) s u) (deltaCore c t u r)) ≤ 9 := by + apply (height_mul _ _).trans + simp only [adjoint,height_conj,deltaCore] + calc + _ ≤ (3:ℚ)*3 := mul_le_mul (height_delta c t _ _) (height_delta c t _ _) + (height_nonnegative _) (by norm_num) + _ = 9 := by norm_num + have hsum := (height_finiteSum (fun u => + mul (adjoint (deltaCore c t) s u) (deltaCore c t u r))).trans + (Finset.sum_le_sum (fun u _ => hentry u)) + have hcard : (Fintype.card (QMASupportBasis (qmaPropagationSites c t)):ℚ) ≤ 32 := + Nat.cast_le.mpr (propagation_configurations c t) + change height (finiteSum _) ≤ 288 + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] at hsum + linarith + +theorem height_lift {ι : Type} [Fintype ι] [DecidableEq ι] (S : Finset ι) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) Scalar) + (s t : ι → Fin 2) : + height (lift S A s t) ≤ height (A (fun i => s i.val) (fun i => t i.val)) := by + apply (height_mul _ _).trans + simpa using mul_le_mul_of_nonneg_left + (height_identity (fun i : {i // i ∉ S} => s i.val) (fun i => t i.val)) + (height_nonnegative (A (fun i => s i.val) (fun i => t i.val))) + +def historyHeight (c : QMACircuit) : ℚ := + 14+288*((14*(c.work+1)+8)*c.gates.length) + +theorem historyHeight_nonnegative (c : QMACircuit) : 0 ≤ historyHeight c := by + unfold historyHeight + positivity + +theorem height_distributed (c : QMACircuit) + (τ : Fin (c.work+1) → Fin (c.gates.length+1)) (a : QMACircuitTerm c) + (s r : QMACircuitQubit c → Fin 2) : + height (distributed c τ a s r) ≤ historyHeight c := by + have h14 : (14:ℚ) ≤ historyHeight c := by + unfold historyHeight + have hn : 0 ≤ 288*((14*(c.work+1)+8)*c.gates.length:ℚ) := by positivity + linarith + rcases a with i | (b | (i | (u | t))) + · dsimp only [distributed,QuantumAlgebraicHistory.diagonal] + split_ifs <;> norm_num <;> linarith + · by_cases hb : b = 0 + · simp only [distributed,hb,ite_true,QuantumAlgebraicHistory.diagonal] + split_ifs <;> norm_num <;> linarith + · simp only [distributed,hb,ite_false,QuantumAlgebraicHistory.diagonal] + split_ifs <;> norm_num <;> linarith + · dsimp only [distributed,QuantumAlgebraicHistory.diagonal] + split_ifs <;> norm_num <;> linarith + · dsimp only [distributed,QuantumAlgebraicHistory.diagonal] + split_ifs <;> norm_num <;> linarith + · apply (height_mul _ _).trans + have hl := (height_lift _ (propagationCore c t) s r).trans + (height_propagationCore c t _ _) + have hw : 0 ≤ ((14*(c.work+1)+8)*c.gates.length:ℚ) := by positivity + rw [height_rat,abs_of_nonneg hw] + apply (mul_le_mul_of_nonneg_left hl hw).trans + unfold historyHeight + linarith + +theorem height_localY (n : ℕ) (i : Fin n) (s t : SourceSpinBasis n) : + height (localY n i s t) ≤ 1 := by + apply (height_finiteProduct _).trans + apply Finset.prod_le_one₀ (fun _ _ => height_nonnegative _) + intro k _ + by_cases h : k = i + · simpa only [h,ite_true] using height_pauli 2 (s k) (t k) + · simpa only [h,ite_false] using height_identity (s k) (t k) + +theorem height_rebit {ι : Type} [Fintype ι] [DecidableEq ι] (n : ℕ) (i : Fin n) + (A : Matrix (ι → Fin 2) (ι → Fin 2) Scalar) (s t : Fin n ⊕ ι → Fin 2) : + height (rebit n i A s t) ≤ 2*height (A (s ∘ Sum.inr) (t ∘ Sum.inr)) := by + have hI := height_identity (s ∘ Sum.inl) (t ∘ Sum.inl) + have hY := height_localY n i (s ∘ Sum.inl) (t ∘ Sum.inl) + have hR := height_realPart (A (s ∘ Sum.inr) (t ∘ Sum.inr)) + have hJ := height_imagPart (A (s ∘ Sum.inr) (t ∘ Sum.inr)) + have hYR := height_mul (localY n i (s ∘ Sum.inl) (t ∘ Sum.inl)) + (imagPart (A (s ∘ Sum.inr) (t ∘ Sum.inr))) + have hIR := height_mul (identity (s ∘ Sum.inl) (t ∘ Sum.inl)) + (realPart (A (s ∘ Sum.inr) (t ∘ Sum.inr))) + have hN := height_mul (neg imaginary) + (mul (localY n i (s ∘ Sum.inl) (t ∘ Sum.inl)) + (imagPart (A (s ∘ Sum.inr) (t ∘ Sum.inr)))) + simp only [height_neg,height_imaginary,one_mul] at hN + apply (height_add _ _).trans + nlinarith [height_nonnegative (realPart (A (s ∘ Sum.inr) (t ∘ Sum.inr))), + height_nonnegative (imagPart (A (s ∘ Sum.inr) (t ∘ Sum.inr)))] + +theorem height_pairY (n : ℕ) (i j : Fin n) (s t : SourceSpinBasis n) : + height (pairY n i j s t) ≤ 1 := by + have hp := (height_mul (QuantumFixedPauli.pauli 2 (s i) (t i)) (QuantumFixedPauli.pauli 2 (s j) (t j))).trans + (mul_le_mul (height_pauli 2 (s i) (t i)) (height_pauli 2 (s j) (t j)) + (height_nonnegative _) (by norm_num)) + have hδ : height (rat (if ∀ k, k ≠ i → k ≠ j → s k = t k then 1 else 0)) ≤ 1 := by + split_ifs <;> norm_num + apply (height_mul _ _).trans + simpa using mul_le_mul hp hδ (height_nonnegative _) (by norm_num) + +theorem height_referenceEdge {ι : Type} [Fintype ι] [DecidableEq ι] + (n : ℕ) (i : Fin n) (s t : Fin (n+1) ⊕ ι → Fin 2) : + height (referenceEdge n i s t) ≤ 1 := by + have hI := height_identity (s ∘ Sum.inl) (t ∘ Sum.inl) + have hY := height_pairY (n+1) i.castSucc i.succ (s ∘ Sum.inl) (t ∘ Sum.inl) + have hS := height_sub (identity (s ∘ Sum.inl) (t ∘ Sum.inl)) + (pairY (n+1) i.castSucc i.succ (s ∘ Sum.inl) (t ∘ Sum.inl)) + have hhalf := height_mul (rat (1/2)) + (sub (identity (s ∘ Sum.inl) (t ∘ Sum.inl)) + (pairY (n+1) i.castSucc i.succ (s ∘ Sum.inl) (t ∘ Sum.inl))) + norm_num only [height_rat,abs_of_pos (by norm_num : (0:ℚ) < 1/2)] at hhalf + have hB : height (mul (rat (1/2)) + (sub (identity (s ∘ Sum.inl) (t ∘ Sum.inl)) + (pairY (n+1) i.castSucc i.succ (s ∘ Sum.inl) (t ∘ Sum.inl)))) ≤ 1 := by + linarith + apply (height_mul _ _).trans + simpa using mul_le_mul hB (height_identity (s ∘ Sum.inr) (t ∘ Sum.inr)) + (height_nonnegative _) (by norm_num) + +theorem height_orderedTerm (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (s t : Fin (qmaHistoryReferenceWork c+1) ⊕ QMACircuitQubit c → Fin 2) : + height (orderedTerm c hT a s t) ≤ 2*historyHeight c := by + cases a with + | inl i => + exact (height_rebit _ _ _ s t).trans + (mul_le_mul_of_nonneg_left (height_distributed c _ _ _ _) (by norm_num)) + | inr i => + apply (height_referenceEdge _ _ s t).trans + have h : (14:ℚ) ≤ historyHeight c := by + unfold historyHeight + have hn : 0 ≤ 288*((14*(c.work+1)+8)*c.gates.length:ℚ) := by positivity + linarith + linarith + +theorem height_orderedCore (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (s t : QMASupportBasis ((qmaOrderedHistoryModel c hT).sites a)) : + height (orderedCore c hT a s t) ≤ 2*historyHeight c := + height_orderedTerm c hT a _ _ + +theorem orderedCoefficient_height (c : QMACircuit) (hT : 0 < c.gates.length) + (a : QMAReferenceTerm (qmaHistoryReferenceWork c)) + (w : {x // x ∈ (qmaOrderedHistoryModel c hT).sites a} → Fin 4) : + realHeight (realCoefficient (orderedCore c hT a) w) ≤ 128*historyHeight c := by + have hp : (2:ℚ)^Fintype.card {x // x ∈ (qmaOrderedHistoryModel c hT).sites a} ≤ 64 := by + have hc := (qmaOrderedHistoryModel c hT).card a + rw [Fintype.card_coe] + have hb := pow_le_pow_right₀ (by norm_num : (1:ℚ) ≤ 2) hc + norm_num at hb ⊢ + exact hb + calc + _ ≤ (2:ℚ)^Fintype.card {x // x ∈ (qmaOrderedHistoryModel c hT).sites a}* + (2*historyHeight c) := + realHeight_coefficient _ _ _ (height_orderedCore c hT a) + _ ≤ 64*(2*historyHeight c) := + mul_le_mul_of_nonneg_right hp (mul_nonneg (by norm_num) (historyHeight_nonnegative c)) + _ = _ := by ring + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryIncidence.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e0ded4dd033472fe11f718a8557f3ecfce22267 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryIncidence.lean @@ -0,0 +1,76 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedIncidence +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedLabelTable +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridNeighbors + +namespace OAI + +/-! The sparse verifier history has uniformly bounded site incidence, even +with all 4096 padded Pauli patterns retained. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryIncidence +open QuantumOrderedIncidence +open scoped BigOperators Classical + +theorem sparse_reference_bound (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) : + Bounded (QuantumOrderedSupport.sites (qmaSparseCircuit c) hT) 576 := by + intro q + let ss : QMAReferenceTerm (qmaHistoryReferenceWork (qmaSparseCircuit c)) → + Finset (QuantumOrderedSupport.Qubit (qmaSparseCircuit c)) := + fun a => (QuantumOrderedSupport.sites (qmaSparseCircuit c) hT a).toFinset + have hlocal : ∀ a, ∀ j ∈ ss a, + QMAGridCellsNear (qmaOrderedQubitCell c hT j) (qmaOrderedTermCell c hT a) := by + intro a j hj + apply qmaOrderedHistoryModel_spatial c hc hT hne a j + exact (QuantumOrderedSupport.sites_finset (qmaSparseCircuit c) hT a) ▸ hj + have h := qmaGrid_incidence_bound (qmaOrderedQubitCell c hT) (qmaOrderedTermCell c hT) + ss hlocal (qmaOrderedTermCell_fiber_card c hT hne) q + have hm (a : QMAReferenceTerm (qmaHistoryReferenceWork (qmaSparseCircuit c))) : + q ∈ QuantumOrderedSupport.sites (qmaSparseCircuit c) hT a ↔ q ∈ ss a := + List.mem_toFinset.symm + have he : count (QuantumOrderedSupport.sites (qmaSparseCircuit c) hT) q = + (Finset.univ.filter (fun a : QMAReferenceTerm + (qmaHistoryReferenceWork (qmaSparseCircuit c)) => + q ∈ ss a)).card := by + rw [count,Finset.card_filter] + apply Finset.sum_congr rfl + intro a _ + by_cases ha : q ∈ QuantumOrderedSupport.sites (qmaSparseCircuit c) hT a + · rw [ite_eq_left ha,ite_eq_left ((hm a).mp ha)] + · rw [ite_eq_right ha,ite_eq_right (mt (hm a).mpr ha)] + exact he.trans_le (h.trans (by norm_num : 9*64 ≤ 576)) + +theorem padded_bound {ι κ ν : Type} [Fintype κ] [Fintype ν] + (xs : κ → List ι) {D : ℕ} (hx : Bounded xs D) : + Bounded (fun p : κ × ν => xs p.1) (Fintype.card ν*D) := by + intro q + calc + count (fun p : κ × ν => xs p.1) q = Fintype.card ν*count xs q := by + rw [count,Fintype.sum_prod_type] + have hi (e : κ) : (∑ _k : ν, if q ∈ xs e then 1 else 0) = + Fintype.card ν*(if q ∈ xs e then 1 else 0) := by + by_cases h : q ∈ xs e <;> simp [h] + simp_rw [hi] + exact (Finset.mul_sum _ _ _).symm + _ ≤ Fintype.card ν*D := Nat.mul_le_mul_left _ (hx q) + +theorem sparse_padded_bound (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) : + Bounded (fun p : QuantumPaddedHistory.Term (qmaSparseCircuit c) => + QuantumOrderedSupport.sites (qmaSparseCircuit c) hT p.1) 2359296 := by + have h := padded_bound (ν := Fin 6 → Fin 4) + (QuantumOrderedSupport.sites (qmaSparseCircuit c) hT) + (sparse_reference_bound c hc hT hne) + simp only [Fintype.card_fun,Fintype.card_fin] at h + have hn : 4^6*576=2359296 := by norm_num + rw [hn] at h + exact h + +end ContinuumCoulomb.QuantumHistoryIncidence + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLattice.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..1196e1935f1923ab461d189dfb0dc6eadb14e3a7 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLattice.lean @@ -0,0 +1,150 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySpatial +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFinalPrecision + +namespace OAI + +/-! The actual sparse verifier compiler, through the specified planar lattice. +The final precision pays for every early and routing error; the scalar offset +is removed from both thresholds exactly. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumPaddedLabelProgram QuantumForkList QuantumAlgebraicHistory +open scoped Classical + +-- Keep the fixed density symbolic; expanding it as a numeral is unnecessary. +attribute [local irreducible] spatialDensity + +private theorem spatialDensity_pos (A D : ℕ) (hA : 0 < A) : 0 < spatialDensity A D := by + unfold spatialDensity + exact Nat.mul_pos (Nat.mul_pos (pow_pos (by omega) D) (Nat.succ_pos D)) hA + +theorem finalDensity_pos : 0 < finalDensity := spatialDensity_pos rawDensity historyDegree (by decide) + +theorem iterate_count_ge (N : ℚ) (s : State) (k : ℕ) : s.1 ≤ (iterate N k s).1 := by + induction k with + | zero => exact le_rfl + | succ k ih => + change s.1 ≤ (iterate N k s).1+2*pairCount (iterate N k s).2.2.2 + exact ih.trans (Nat.le_add_right _ _) + +theorem model_vertices_ge (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + historyQubits (qmaSparseCircuit c) hT N ≤ (model c hc hT hne N).n := by + change _ ≤ (input c hc hT hne N).state.1 + rw [input_state] + let s := initial (historyQubits (qmaSparseCircuit c) hT N) + (historyOutput (qmaSparseCircuit c) hT N).1 (historyOutput (qmaSparseCircuit c) hT N).2 (N:ℚ) + exact (show historyQubits (qmaSparseCircuit c) hT N ≤ s.1 from Nat.le_add_right _ _).trans + (iterate_count_ge (N:ℚ) s historyDegree) + +theorem model_vertices_pos (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + 0 < (model c hc hT hne N).n := by + have hp : 0 < historyQubits (qmaSparseCircuit c) hT N := by + rw [historyQubits_eq,QuantumOrderedSourceIndex.qubitCount_eq] + omega + exact hp.trans_le (model_vertices_ge c hc hT hne N) + +-- The certified value is fixed, but need never be expanded into a numeral. +private opaque routeRoundValue : { k : ℕ // + QMASpatialExchangeModel.routeLengthBound (spatialDensity rawDensity historyDegree) + (27*spatialDensity rawDensity historyDegree) = k } := + ⟨QMASpatialExchangeModel.routeLengthBound (spatialDensity rawDensity historyDegree) + (27*spatialDensity rawDensity historyDegree),rfl⟩ + +def routeRounds : ℕ := routeRoundValue.val +theorem routeRounds_eq : QMASpatialExchangeModel.routeLengthBound + (spatialDensity rawDensity historyDegree) (27*spatialDensity rawDensity historyDegree) = + routeRounds := routeRoundValue.property +def totalRounds : ℕ := historyDegree+routeRounds+83 +def latticePrecision (c : QMACircuit) : ℕ := finalPrecision totalRounds (qmaSparseCircuit c) + +private theorem combine_errors (D K : ℕ) (N : ℝ) : + ((K:ℝ)+82)/N+((D:ℝ)+10)/N = (((D+K+83:ℕ):ℝ)+9)/N := by + push_cast + ring + +def lattice (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) := + (model c hc hT hne N).latticeGraph finalDensity_pos (model_degree c hc hT hne N) (N:ℚ) + +theorem lattice_history_error (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) (hN : 0 < N) : + |(lattice c hc hT hne N).energy-(qmaOrderedHistoryModel (qmaSparseCircuit c) hT).energy| ≤ + ((totalRounds:ℝ)+9)/(N:ℝ) := by + have hr := (model c hc hT hne N).lattice_energy_error_nat finalDensity_pos + (model_degree c hc hT hne N) N hN + rw [routeRounds_eq] at hr + have he := model_history_error c hc hT hne N hN + have hr' : |(lattice c hc hT hne N).energy-(model c hc hT hne N).energy| ≤ + ((routeRounds:ℝ)+82)/(N:ℝ) := hr + calc + _ ≤ |(lattice c hc hT hne N).energy-(model c hc hT hne N).energy|+ + |(model c hc hT hne N).energy-(qmaOrderedHistoryModel (qmaSparseCircuit c) hT).energy| := + abs_sub_le _ _ _ + _ ≤ ((routeRounds:ℝ)+82)/(N:ℝ)+((historyDegree:ℝ)+10)/(N:ℝ) := add_le_add hr' he + _ = _ := combine_errors historyDegree routeRounds (N:ℝ) + +def source (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) : SquareLatticeHeisenberg := + (model c hc hT hne (latticePrecision c)).latticeSource finalDensity_pos + (model_degree c hc hT hne (latticePrecision c)) (latticePrecision c:ℚ) + (model_vertices_pos c hc hT hne (latticePrecision c)) + (xzYesThreshold (qmaSparseCircuit c)) (xzNoThreshold (qmaSparseCircuit c)) + (xz_threshold_lt (qmaSparseCircuit c)) + +theorem source_energy (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) : + realSourceGroundEnergy (source c hc hT hne) = + (lattice c hc hT hne (latticePrecision c)).energy- + ((lattice c hc hT hne (latticePrecision c)).constant:ℝ) := + (model c hc hT hne (latticePrecision c)).latticeSource_energy finalDensity_pos + (model_degree c hc hT hne (latticePrecision c)) _ _ _ _ _ + +theorem source_accepting (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖=1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + realSourceGroundEnergy (source c hc hT hne) ≤ ((source c hc hT hne).lower:ℝ) := by + have herr := lattice_history_error c hc hT hne (latticePrecision c) + (finalPrecision_pos totalRounds (qmaSparseCircuit c)) + have he := final_accepting totalRounds (qmaSparseCircuit c) hT + (qmaSparseCircuit_wellFormed c hc) herr psi hpsi + ((qmaSparseCircuit_acceptance c hc psi) ▸ hacc) + rw [source_energy] + change _ ≤ ((xzYesThreshold (qmaSparseCircuit c)- + (lattice c hc hT hne (latticePrecision c)).constant:ℚ):ℝ) + push_cast + linarith + +theorem source_rejecting (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖=1 → qmaAcceptance c hc psi ≤ 1/3) : + ((source c hc hT hne).upper:ℝ) ≤ realSourceGroundEnergy (source c hc hT hne) := by + have herr := lattice_history_error c hc hT hne (latticePrecision c) + (finalPrecision_pos totalRounds (qmaSparseCircuit c)) + have he := final_rejecting totalRounds (qmaSparseCircuit c) hT + (qmaSparseCircuit_wellFormed c hc) herr + (by intro psi hpsi; rw [qmaSparseCircuit_acceptance]; exact hsound psi hpsi) + rw [source_energy] + change ((xzNoThreshold (qmaSparseCircuit c)- + (lattice c hc hT hne (latticePrecision c)).constant:ℚ):ℝ) ≤ _ + push_cast + linarith + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ce99a8a9309f55ee64bc066bddbe743a8824846 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralCorrectness.lean @@ -0,0 +1,74 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryRoutedEnergy +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialFinalCount + +namespace OAI + +/-! The literal circuit compiler satisfies the original Heisenberg yes/no +promise. Its scalar shift and finite edge order are those of the emitted tape. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySourceProgram +open QuantumHistorySpatial QuantumHistoryPreparedProgram QuantumPaddedLabelProgram + +theorem value_eq_latticeOutput (c : QMACircuit) : + value c = QuantumListRouteProgram.latticeOutput (routedState c) + (thresholds c).1 (thresholds c).2 := rfl + +theorem routed_vertices_pos (c : QMACircuit) (hc : c.WellFormed) : + 0 < (routedState c).1.1 := by + rw [routedState_actual c hc] + exact (model_vertices_pos (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c) (precision c)).trans_le + (QuantumFinalRoutingProgram.spatial_count_le + (QuantumHistorySpatial.input (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c) (precision c)) + finalDensity_pos (precision c) (thresholds c).1 (thresholds c).2) + +theorem routed_realization (c : QMACircuit) (hc : c.WellFormed) : + ∃ (hs : QuantumListSchedule.Valid (routedState c).1) + (Q : QMAPathEmbedding (QuantumListSchedule.schedule (routedState c).1 hs)), + QuantumListRouteProgram.Represents (routedState c) hs Q ∧ + ∀ e, qmaSquareGrid.Adj + (Q.position ((QuantumListSchedule.schedule (routedState c).1 hs).graph.left e)) + (Q.position ((QuantumListSchedule.schedule (routedState c).1 hs).graph.right e)) := by + rw [routedState_actual c hc] + obtain ⟨hs,Q,hQ,_,hgrid⟩ := QuantumFinalRoutingProgram.spatial_realization + (QuantumHistorySpatial.input (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c) (precision c)) + finalDensity_pos (N := (precision c : ℚ)) + (by exact_mod_cast precision_pos c) (thresholds c).1 (thresholds c).2 + exact ⟨hs,Q,hQ,hgrid⟩ + +theorem literal_valid (c : QMACircuit) (hc : c.WellFormed) : (value c).Valid := by + rw [value_eq_latticeOutput] + obtain ⟨hs,Q,hQ,hgrid⟩ := routed_realization c hc + exact QuantumListRouteProgram.latticeOutput_valid _ hs Q hQ hgrid + (routed_vertices_pos c hc) _ _ (thresholds_lt c) + +theorem literal_accepting (c : QMACircuit) (hc : c.WellFormed) {k : ℕ} + (hp : (value c).PolynomialPromise k) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (ha : 2/3 ≤ qmaAcceptance c hc psi) : + value c ∈ (sourceHeisenbergPromise k).yes := by + rw [value_eq_latticeOutput] at hp ⊢ + obtain ⟨hs,Q,hQ,hgrid⟩ := routed_realization c hc + exact QuantumListRouteProgram.latticeOutput_yes _ hs Q hQ hgrid + (routed_vertices_pos c hc) _ _ (thresholds_lt c) hp + (routed_accepting c hc psi hpsi ha) + +theorem literal_rejecting (c : QMACircuit) (hc : c.WellFormed) {k : ℕ} + (hp : (value c).PolynomialPromise k) + (ha : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) : + value c ∈ (sourceHeisenbergPromise k).no := by + rw [value_eq_latticeOutput] at hp ⊢ + obtain ⟨hs,Q,hQ,hgrid⟩ := routed_realization c hc + exact QuantumListRouteProgram.latticeOutput_no _ hs Q hQ hgrid + (routed_vertices_pos c hc) _ _ (thresholds_lt c) hp + (routed_rejecting c hc ha) + +end ContinuumCoulomb.QuantumHistorySourceProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralPromise.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralPromise.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05f8a7fa4d1a5132c1262a54b7b4276a6e11383 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryLiteralPromise.lean @@ -0,0 +1,52 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialSourcePromise +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySourcePromise +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryRoutedEnergy + +namespace OAI + +/-! One polynomial promise exponent for the literal circuit-to-source +program, with the original verifier's empty circuits prepared explicitly. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySourceProgram +open QuantumHistorySpatial QuantumHistoryPreparedProgram QuantumPaddedLabelProgram +open QuantumAlgebraicHistory QuantumOrderedSourceIndex QuantumCoefficientPrograms + +theorem circuit_polynomialPromise : ∃ k : ℕ, 0 < k ∧ + ∀ (c : QMACircuit) (_hc : c.WellFormed), (value c).PolynomialPromise k := by + obtain ⟨a,ha⟩ := source_data_power + refine ⟨2*a+6,by omega,fun c hc => ?_⟩ + let d := qmaNonemptyCircuit c + let hd := qmaNonemptyCircuit_wellFormed c hc + let ht := qmaNonemptyCircuit_sparse_pos c + let he := qmaNonemptyCircuit_nearest c + let I := QuantumHistorySpatial.input d hd ht he (precision c) + let n := qubitCount (qmaPreparedCircuit c) + have hn : 0 < n := qubitCount_positive _ + obtain ⟨L,hL,hC,hx,hy,hw⟩ := ha d hd ht he + have lift (m : ℕ) (hm : m ≤ (n+2)^a) : (m:ℝ) ≤ (n+1:ℝ)^(2*a+6) := by + have hb : m ≤ (n+1)^(2*a+6) := hm.trans + ((power_base_change hn).trans (pow_le_pow_right₀ (by omega : 1 ≤ n+1) (by omega))) + exact_mod_cast hb + have hsize : n ≤ I.model.n := by + have h := model_vertices_ge d hd ht he (precision c) + rw [QuantumPaddedLabelProgram.historyQubits_eq] at h + have hn' : n ≤ 4*(qubitCount (qmaSparseCircuit d)+3717*termCount (qmaSparseCircuit d)) := by + change n ≤ 4*(n+_) + omega + exact hn'.trans h + rw [value_actual c hc] + apply QuantumFinalRoutingProgram.spatial_polynomialPromise I finalDensity_pos + (N := (precision c:ℚ)) (T := precision c) (n := n) + (by exact_mod_cast precision_pos c) (model_vertices_pos d hd ht he (precision c)) hsize + hL (by simp only [Rat.cast_natCast,abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ precision c)]; exact le_rfl) + hC _ _ (xz_threshold_lt (qmaPreparedCircuit c)) (lift _ hx) (lift _ hy) + · rw [route_rounds_eq] + exact lift _ hw + · exact final_threshold_gap_bound (qmaPreparedCircuit c) hn (time_le_qubitCount _) (by omega) + +end ContinuumCoulomb.QuantumHistorySourceProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..809d56c8b8d4a9ae57fa41469179a155117f3e13 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrix.lean @@ -0,0 +1,72 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFiniteHistory +import Mathlib.LinearAlgebra.Matrix.Hermitian + +namespace OAI + +/-! The actual finite Hermitian circuit-history Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +abbrev QMAPropagationBasis (c : QMACircuit) := + Fin c.gates.length × SourceSpinBasis (c.work+1) + +def qmaPropagationMap (c : QMACircuit) : + (QMAHistoryBasis c → ℂ) →ₗ[ℂ] (QMAPropagationBasis c → ℂ) where + toFun u ts := + u (⟨ts.1.val+1,Nat.succ_lt_succ ts.1.isLt⟩,ts.2)- + (qmaStepMatrix c ts.1.val).mulVec + (fun s => u (⟨ts.1.val,ts.1.isLt.trans (Nat.lt_succ_self _)⟩,s)) ts.2 + map_add' u v := by + funext ts + change (u _+v _)-(qmaStepMatrix c ts.1.val).mulVec + ((fun s => u (⟨ts.1.val,ts.1.isLt.trans (Nat.lt_succ_self _)⟩,s))+ + (fun s => v (⟨ts.1.val,ts.1.isLt.trans (Nat.lt_succ_self _)⟩,s))) ts.2 = _ + rw [Matrix.mulVec_add] + simp only [Pi.add_apply] + ring + map_smul' a u := by + funext ts + change a*u _-(qmaStepMatrix c ts.1.val).mulVec + (a • (fun s => u (⟨ts.1.val,ts.1.isLt.trans (Nat.lt_succ_self _)⟩,s))) ts.2 = _ + rw [Matrix.mulVec_smul] + simp only [Pi.smul_apply,smul_eq_mul,RingHom.id_apply] + ring + +def qmaPropagationMatrix (c : QMACircuit) : + Matrix (QMAPropagationBasis c) (QMAHistoryBasis c) ℂ := + LinearMap.toMatrix' (qmaPropagationMap c) + +def qmaInitialDiagonal (c : QMACircuit) (p : QMAHistoryBasis c) : ℂ := + if p.1.val = 0 ∧ ¬QMAAncillaZero c p.2 then 1 else 0 + +def qmaFinalDiagonal (c : QMACircuit) (p : QMAHistoryBasis c) : ℂ := + if p.1.val = c.gates.length ∧ p.2 (Fin.last c.work) ≠ 1 then 1 else 0 + +def qmaHistoryHamiltonian (c : QMACircuit) : Matrix (QMAHistoryBasis c) (QMAHistoryBasis c) ℂ := + Matrix.diagonal (qmaFinalDiagonal c)+ + (7:ℂ) • Matrix.diagonal (qmaInitialDiagonal c)+ + (8*c.gates.length:ℂ) • ((qmaPropagationMatrix c).conjTranspose*qmaPropagationMatrix c) + +theorem qmaHistoryHamiltonian_hermitian (c : QMACircuit) : + (qmaHistoryHamiltonian c).IsHermitian := by + have hi : (Matrix.diagonal (qmaInitialDiagonal c)).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro p + unfold qmaInitialDiagonal + split <;> simp + have ho : (Matrix.diagonal (qmaFinalDiagonal c)).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro p + unfold qmaFinalDiagonal + split <;> simp + exact (ho.add (hi.smul (by simp))).add + ((Matrix.isHermitian_conjTranspose_mul_self (qmaPropagationMatrix c)).smul (by simp [isSelfAdjoint_iff])) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrixForm.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrixForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..db1b74e09995dc729e2f5f747b155d0317e999e5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryMatrixForm.lean @@ -0,0 +1,96 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryMatrix + +namespace OAI + +/-! The finite matrix is exactly the quadratic history form. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaQuadratic_clock_mask (c : QMACircuit) (t : Fin (c.gates.length+1)) + (p : SourceSpinBasis (c.work+1) → Prop) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (Matrix.diagonal (fun k : QMAHistoryBasis c => + if k.1 = t ∧ p k.2 then (1:ℂ) else 0)) u = + ‖qmaMask p (qmaHistoryFromVector c u t.val)‖^2 := by + have h := qmaQuadratic_diagonal_mask (fun k : QMAHistoryBasis c => k.1 = t ∧ p k.2) u + have hm : qmaQuadratic (Matrix.diagonal (fun k : QMAHistoryBasis c => + if k.1 = t ∧ p k.2 then (1:ℂ) else 0)) u = + ∑ k : QMAHistoryBasis c, if k.1 = t ∧ p k.2 then Complex.normSq (u k) else 0 := by + convert h using 1 + · congr 2 + funext k + split <;> simp_all + · apply Finset.sum_congr rfl + intro k _ + split <;> simp_all + rw [hm,EuclideanSpace.norm_sq_eq] + simp [Fintype.sum_prod_type,ite_and,Finset.sum_ite_irrel,Complex.sq_norm,apply_ite] + +theorem qmaPropagationMatrix_mulVec (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) + (t : Fin c.gates.length) (s : SourceSpinBasis (c.work+1)) : + (qmaPropagationMatrix c).mulVec u (t,s) = + (qmaHistoryFromVector c u (t.val+1)-qmaApplyMatrix (qmaStepMatrix c t.val) + (qmaHistoryFromVector c u t.val)) s := by + rw [qmaPropagationMatrix,LinearMap.toMatrix'_mulVec] + simp [qmaPropagationMap,qmaHistoryFromVector,qmaClockIndex,qmaApplyMatrix, +] + +theorem qmaPropagationMatrix_energy (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic ((qmaPropagationMatrix c).conjTranspose*qmaPropagationMatrix c) u = + qmaPropagationEnergy c (qmaHistoryFromVector c u) := by + rw [qmaQuadratic_gram] + unfold qmaPropagationEnergy + rw [←Fin.sum_univ_eq_sum_range,Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro t _ + rw [EuclideanSpace.norm_sq_eq] + simp only [qmaPropagationMatrix_mulVec,Complex.sq_norm] + +theorem qmaInitialDiagonal_energy (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (Matrix.diagonal (qmaInitialDiagonal c)) u = + qmaInputPenalty c (qmaHistoryFromVector c u) := by + have he : qmaInitialDiagonal c = fun k : QMAHistoryBasis c => + if k.1 = (0 : Fin (c.gates.length+1)) ∧ ¬QMAAncillaZero c k.2 then (1:ℂ) else 0 := by + funext k + simp only [qmaInitialDiagonal,Fin.val_eq_zero_iff] + rw [he] + convert qmaQuadratic_clock_mask c 0 (fun s => ¬QMAAncillaZero c s) u using 1 + · congr 2 + funext k + split <;> simp_all + · rfl + +theorem qmaFinalDiagonal_energy (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (Matrix.diagonal (qmaFinalDiagonal c)) u = + qmaOutputPenalty c (qmaHistoryFromVector c u) := by + have he : qmaFinalDiagonal c = fun k : QMAHistoryBasis c => + if k.1 = Fin.last c.gates.length ∧ k.2 (Fin.last c.work) ≠ 1 then (1:ℂ) else 0 := by + funext k + simp [qmaFinalDiagonal,Fin.ext_iff] + rw [he] + convert qmaQuadratic_clock_mask c (Fin.last c.gates.length) + (fun s => s (Fin.last c.work) ≠ 1) u using 1 + · congr 2 + funext k + split <;> simp_all + · rfl + +theorem qmaHistoryHamiltonian_form (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (qmaHistoryHamiltonian c) u = + qmaHistoryEnergy c (qmaHistoryFromVector c u) := by + unfold qmaHistoryHamiltonian + rw [qmaQuadratic_add,qmaQuadratic_add] + have hs : (8*c.gates.length:ℂ) = ((8*(c.gates.length:ℝ):ℝ):ℂ) := by push_cast; rfl + rw [hs,qmaQuadratic_smul] + have h7 : (7:ℂ) = ((7:ℝ):ℂ) := by norm_num + rw [h7,qmaQuadratic_smul] + rw [qmaInitialDiagonal_energy,qmaFinalDiagonal_energy,qmaPropagationMatrix_energy] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryOutputBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryOutputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ea44b74786a775a199564611e7f926408bf087e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryOutputBounds.lean @@ -0,0 +1,84 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedOutputBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySpatial +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialInputBounds + +namespace OAI + +/-! Coefficient envelopes for the actual sparse-history and degree-three +spatial output, preserving the exact numeric output order. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumPaddedLabelProgram QuantumPaddedHistory QuantumOrderedSourceIndex +open QuantumForkList +open scoped Classical + +def historyCoefficientBudget (c : QMACircuit) (N : ℕ) : ℕ := + QuantumOrderedLabelCompile.coefficientEnvelope (qubitCount c) (termCount c) + (QuantumAlgebraicHistory.coefficientBudget c) N + +theorem history_output_bound (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : + |((historyOutput c hT N).2:ℝ)| ≤ historyCoefficientBudget c N ∧ + ∀ b ∈ (historyOutput c hT N).1, |(b.2.2:ℝ)| ≤ historyCoefficientBudget c N := by + unfold historyOutput historyInput + rw [sourceEntries_table] + exact QuantumOrderedLabelCompile.output_coefficients (qubits c) (sourceTerms c hT) + (fun p : Term c => QuantumOrderedSupport.sites c hT p.1) (sourceWord c hT) + (sampledWeight (QuantumAlgebraicHistory.samplePrecision c N) c hT) + (fun p => QuantumOrderedSupport.sites_length c hT p.1) + (fun p => QuantumOrderedSupport.sites_nodup c hT p.1) + (fun p => sampledWeight_bound _ c hT p) N + +theorem input_bonds (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (input c hc hT hne N).bonds=(historyOutput (qmaSparseCircuit c) hT N).1 := by + unfold historyOutput historyInput + rw [sourceEntries_table] + rfl + +theorem input_constant (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (input c hc hT hne N).constant=(historyOutput (qmaSparseCircuit c) hT N).2 := by + unfold historyOutput historyInput + rw [sourceEntries_table] + rfl + +theorem input_n (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (input c hc hT hne N).n=historyQubits (qmaSparseCircuit c) hT N := by + unfold historyQubits historyInput + rw [sourceEntries_table] + rfl + +private theorem outputNat_one (n m B N : ℕ) : 1 ≤ QuantumRawExchange.outputNat n m B N := by + dsimp only [QuantumRawExchange.outputNat] + omega + +theorem historyCoefficientBudget_one (c : QMACircuit) (N : ℕ) : + 1 ≤ historyCoefficientBudget c N := outputNat_one _ _ _ _ + +theorem model_coefficientBound (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (model c hc hT hne N).exchangeGraph.CoefficientBound + (outputCoefficientNat (input c hc hT hne N).bonds.length historyDegree + (historyCoefficientBudget (qmaSparseCircuit c) N) N) := by + have hb := history_output_bound (qmaSparseCircuit c) hT N + have hp : (input c hc hT hne N).precision=(N:ℚ) := rfl + apply (input c hc hT hne N).model_nat_coefficientBound + (by rw [hp]; exact_mod_cast Nat.zero_le N) + (historyCoefficientBudget_one _ N) + (by rw [hp,Rat.cast_natCast,abs_of_nonneg (Nat.cast_nonneg N : (0:ℝ) ≤ N)]) + · rw [input_constant] + exact hb.1 + · rw [input_bonds] + exact hb.2 + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryParameterBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryParameterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..301fb3a3dece7a23b32f31491486f397772fd381 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryParameterBounds.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryOutputBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientEnvelopeProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPromisePowers +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFinalPrecision + +namespace OAI + +/-! Uniform polynomial powers for the actual history coefficients. These +bounds are in the retained history-qubit count, not in an auxiliary circuit. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumOrderedSourceIndex QuantumAlgebraicHistory +open QuantumCoefficientPrograms + +def parameterEnvelope (rounds n : ℕ) : ℕ := + n+8192*n+128*(14+288*((14*(n+1)+8)*n))+60*(rounds+9)*(n+1)+1 + +theorem parameterEnvelope_power (rounds : ℕ) : ∃ k : ℕ, ∀ n, + parameterEnvelope rounds n ≤ (n+2)^k := by + let p : Polynomial ℕ := Polynomial.X+8192*Polynomial.X+ + 128*(14+288*((14*(Polynomial.X+1)+8)*Polynomial.X))+ + Polynomial.C (60*(rounds+9))*(Polynomial.X+1)+1 + obtain ⟨k,hk⟩ := natPolynomial_power_bound p + refine ⟨k,fun n => ?_⟩ + simpa only [p,parameterEnvelope,Polynomial.eval_add,Polynomial.eval_mul, + Polynomial.eval_X,Polynomial.eval_C,Polynomial.eval_natCast,Polynomial.eval_ofNat, + Polynomial.eval_one] using hk n + +theorem qubitCount_positive (c : QMACircuit) : 0 < qubitCount c := by + rw [qubitCount_eq] + omega + +theorem time_le_qubitCount (c : QMACircuit) : c.gates.length ≤ qubitCount c := by + rw [qubitCount_eq] + omega + +theorem termCount_bound (c : QMACircuit) : termCount c ≤ 8192*qubitCount c := by + rw [termCount_eq,qubitCount_eq] + omega + +theorem parameters_le_envelope (rounds : ℕ) (c : QMACircuit) : + qubitCount c ≤ parameterEnvelope rounds (qubitCount c) ∧ + termCount c ≤ parameterEnvelope rounds (qubitCount c) ∧ + coefficientBudget c ≤ parameterEnvelope rounds (qubitCount c) ∧ + finalPrecision rounds c ≤ parameterEnvelope rounds (qubitCount c) := by + have hwork : c.work+1 ≤ qubitCount c+1 := by rw [qubitCount_eq]; omega + have htime : c.gates.length ≤ qubitCount c := by rw [qubitCount_eq]; omega + have ht := termCount_bound c + have hb : coefficientBudget c ≤ + 128*(14+288*((14*(qubitCount c+1)+8)*qubitCount c)) := by + unfold coefficientBudget + gcongr + have hp : finalPrecision rounds c ≤ 60*(rounds+9)*(qubitCount c+1) := by + unfold finalPrecision + gcongr + unfold parameterEnvelope + omega + +theorem parameters_power (rounds : ℕ) : ∃ k : ℕ, ∀ c : QMACircuit, + qubitCount c ≤ (qubitCount c+2)^k ∧ + termCount c ≤ (qubitCount c+2)^k ∧ + coefficientBudget c ≤ (qubitCount c+2)^k ∧ + finalPrecision rounds c ≤ (qubitCount c+2)^k := by + obtain ⟨k,hk⟩ := parameterEnvelope_power rounds + refine ⟨k,fun c => ?_⟩ + obtain ⟨h₁,h₂,h₃,h₄⟩ := parameters_le_envelope rounds c + exact ⟨h₁.trans (hk _),h₂.trans (hk _),h₃.trans (hk _),h₄.trans (hk _)⟩ + +theorem historyCoefficientBudget_power (rounds : ℕ) : ∃ k : ℕ, ∀ c : QMACircuit, + historyCoefficientBudget c (finalPrecision rounds c) ≤ (qubitCount c+2)^k := by + obtain ⟨a,ha⟩ := parameters_power rounds + obtain ⟨b,hb⟩ := QuantumCoefficientEnvelopeProgram.polynomial_bound + refine ⟨(a+4)*b,fun c => ?_⟩ + obtain ⟨hn,hm,hB,hN⟩ := ha c + exact lattice_function_power hb hn hm hB hN + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryPrecisionProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryPrecisionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..290fc061943fb526303c2e01b203b0e16ed39aa9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryPrecisionProgram.lean @@ -0,0 +1,119 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySamplerProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedLabelEnergy + +namespace OAI + +/-! The prescribed sampling precision is computed in unary. Composition +with the checked local sampler yields the actual early raw exchange compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryPrecisionProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode QuantumAlgebraicHistory + +abbrev Input := ℕ × QMACircuit +abbrev inputCode := QuantumHistorySamplerProgram.inputCode + +noncomputable opaque coefficientBudgetProgram : Procedure circuitCode unaryCode coefficientBudget := by + let const (n : ℕ) := Procedure.constant circuitCode unaryCode n + let inner := Procedure.unaryMul.comp + ((Procedure.unaryAdd.comp + ((Procedure.unaryMul.comp ((const 14).pair + (Procedure.unarySuccessor.comp workProgram))).pair (const 8))).pair + QuantumHistoryDescriptors.timeProgram) + exact Procedure.unaryMul.comp ((const 128).pair + (Procedure.unaryAdd.comp ((const 14).pair + (Procedure.unaryMul.comp ((const 288).pair inner))))) + +noncomputable opaque termBudgetProgram : Procedure circuitCode unaryCode termBudget := + (Procedure.unaryMul.comp + ((Procedure.constant circuitCode unaryCode 4096).pair + QuantumHistorySamplerProgram.countProgram)).congrFun (by + intro c + simp only [termBudget,Function.comp_apply,QuantumOrderedSourceIndex.referenceCount_eq]) + +noncomputable opaque circuitProgram : Procedure inputCode circuitCode Prod.snd := + Procedure.second _ _ +noncomputable opaque inverseErrorProgram : Procedure inputCode unaryCode Prod.fst := + Procedure.first _ _ + +noncomputable opaque termAllowanceProgram : Procedure inputCode unaryCode + (fun x : Input => termBudget x.2+1) := + Procedure.unarySuccessor.comp (termBudgetProgram.comp circuitProgram) + +noncomputable opaque coefficientAllowanceProgram : Procedure inputCode unaryCode + (fun x : Input => coefficientBudget x.2+1) := + Procedure.unarySuccessor.comp (coefficientBudgetProgram.comp circuitProgram) + +noncomputable opaque precisionFactorProgram : Procedure inputCode unaryCode + (fun x : Input => (termBudget x.2+1)*(coefficientBudget x.2+1)) := + Procedure.unaryMul.comp (termAllowanceProgram.pair coefficientAllowanceProgram) + +noncomputable opaque precisionProgram : Procedure inputCode unaryCode + (fun x : Input => samplePrecision x.2 x.1) := + (Procedure.unaryMul.comp (precisionFactorProgram.pair inverseErrorProgram)).congrFun + (by intro x; rfl) + +noncomputable opaque sourceQubitsProgram : Procedure circuitCode unaryCode + QuantumOrderedSourceIndex.qubitCount := by + let const (n : ℕ) := Procedure.constant circuitCode unaryCode n + let clocks := Procedure.unaryMul.comp ((const 3).pair QuantumHistoryDescriptors.timeProgram) + let work := Procedure.unaryMul.comp ((const 2).pair workProgram) + exact (Procedure.unaryAdd.comp + ((Procedure.unaryAdd.comp (clocks.pair work)).pair (const 8))).congrFun (by + intro c + simpa only [Function.comp_apply] using (QuantumOrderedSourceIndex.qubitCount_eq c).symm) + +def prepare (x : Input) : QuantumOrderedLabelFamily.Input := + (x.1,QuantumOrderedSourceIndex.qubitCount x.2, + QuantumHistorySamplerProgram.entries (samplePrecision x.2 x.1,x.2)) + +noncomputable opaque prepareProgram : Procedure inputCode QuantumOrderedLabelFamily.inputCode prepare := + inverseErrorProgram.pair ((sourceQubitsProgram.comp circuitProgram).pair + (QuantumHistorySamplerProgram.program.comp (precisionProgram.pair circuitProgram))) + +def output (x : Input) : List MediatorListProgram.Bond × ℚ := + QuantumOrderedLabelCompile.output (prepare x) + +noncomputable opaque outputProgram : Procedure inputCode + (prodCode (listCode MediatorListProgram.bondCode) ratCode) output := + QuantumOrderedLabelCompile.outputProgram.comp prepareProgram + +def physicalQubits (x : Input) : ℕ := QuantumOrderedLabelCompile.qubitCount (prepare x) + +theorem physicalQubits_eq (x : Input) : + physicalQubits x=4*QuantumOrderedLabelCompile.outputCount (prepare x) := by + simp only [physicalQubits,QuantumOrderedLabelCompile.qubitCount, + QuantumOrderedLabelCompile.outputCount,Function.comp_apply] + +noncomputable opaque outputCountProgram : Procedure inputCode unaryCode + (fun x => QuantumOrderedLabelCompile.outputCount (prepare x)) := + QuantumOrderedLabelCompile.outputCountProgram.comp prepareProgram + +noncomputable opaque physicalQubitsProgram : Procedure inputCode unaryCode physicalQubits := + (Procedure.unaryMul.comp ((Procedure.constant inputCode unaryCode 4).pair + outputCountProgram)).congrFun (fun x => (physicalQubits_eq x).symm) + +theorem prepare_actual (N : ℕ) (c : QMACircuit) (hT : 0 ((time c+1:ℕ):ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp + (Procedure.unarySuccessor.comp timeProgram)) + +noncomputable opaque lowerProgram : Procedure circuitCode ratCode + (fun c => (thresholds c).1) := by + let denominator := Procedure.ratMul.comp + ((Procedure.constant circuitCode ratCode 20).pair thresholdTimeProgram) + exact (Procedure.ratDiv.comp + ((Procedure.constant circuitCode ratCode 7).pair denominator)).congrFun (by + intro c + simp only [thresholds,QuantumAlgebraicHistory.xzYesThreshold,time, + Function.comp_apply,Nat.cast_add,Nat.cast_one]) + +noncomputable opaque upperProgram : Procedure circuitCode ratCode + (fun c => (thresholds c).2) := by + let denominator := Procedure.ratMul.comp + ((Procedure.constant circuitCode ratCode 60).pair thresholdTimeProgram) + exact (Procedure.ratDiv.comp + ((Procedure.constant circuitCode ratCode 23).pair denominator)).congrFun (by + intro c + simp only [thresholds,QuantumAlgebraicHistory.xzNoThreshold,time, + Function.comp_apply,Nat.cast_add,Nat.cast_one]) + +noncomputable opaque thresholdsProgram : Procedure circuitCode + (prodCode ratCode ratCode) thresholds := + (lowerProgram.pair upperProgram).congrFun (by intro c; rfl) + +abbrev FinalInput := (ℚ × QuantumForkGridProgram.PreparedInput) × (ℚ × ℚ) +def finalInputCode : FinalInput → List Bool := + prodCode (prodCode ratCode QuantumForkGridProgram.preparedCode) (prodCode ratCode ratCode) + +def finalInput (c : QMACircuit) : FinalInput := + (((precision c:ℚ),prepared c),thresholds c) + +noncomputable opaque rationalPrecisionProgram : Procedure circuitCode ratCode + (fun c => (precision c:ℚ)) := + Procedure.natToRat.comp (Procedure.unaryToBits.comp precisionProgram) + +noncomputable opaque finalInputProgram : Procedure circuitCode finalInputCode finalInput := + (rationalPrecisionProgram.pair preparedProgram).pair thresholdsProgram + +theorem precision_pos (c : QMACircuit) : 0 rfl + · rfl + · rfl + · rfl + · rfl + · rfl + +def rawCells (c : QMACircuit) : List (ℕ × ℕ) := QuantumOrderedRawCells.value (value c) + +noncomputable opaque rawCellsProgram : Procedure circuitCode + (listCode QuantumRouteCode.pairCode) rawCells := + QuantumOrderedRawCells.program.comp valueProgram + +theorem rawCells_actual (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) : + rawCells c=List.ofFn (fun i : Fin + (finalCount (qubitCount (qmaSparseCircuit c)) + (referenceCount (qmaSparseCircuit c)*patternCount)*4) => + encodeCell (QuantumOrderedOutputSpatial.physicalCell + (qubits (qmaSparseCircuit c)) + (QuantumPaddedLabelProgram.sourceTerms (qmaSparseCircuit c) hT) + (qmaOrderedQubitCell c hT) (fun p => qmaOrderedTermCell c hT p.1) i.val)) := by + rw [rawCells,value_actual c hT,QuantumOrderedRawCells.value_table] + apply congrArg List.ofFn + funext i + rw [QuantumOrderedOutputSpatial.physicalCell, + QuantumRawCellLocality.blockCell_fin] + change cell6 (encodeCell ∘ qmaOrderedQubitCell c hT) + (encodeCell ∘ (fun p => qmaOrderedTermCell c hT p.1)) + (qubits6 (qubits (qmaSparseCircuit c)) + (QuantumPaddedLabelProgram.sourceTerms (qmaSparseCircuit c) hT) + (finProdFinEquiv.symm i).1)=_ + rw [map_cell6] + simp only [Function.comp_apply,QuantumOrderedOutputSpatial.logicalCell,qmaFourBlockCell] + +theorem rawCells_length (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) (N : ℕ) : + (rawCells c).length=QuantumPaddedLabelProgram.historyQubits + (qmaSparseCircuit c) hT N := by + rw [rawCells_actual c hT,List.length_ofFn, + QuantumPaddedLabelProgram.historyQubits_eq,finalCount_eq] + simp only [termCount] + omega + +theorem rawCells_get (c : QMACircuit) + (hT : 0<(qmaSparseCircuit c).gates.length) (j : ℕ) + (hj : j<(rawCells c).length) : + (rawCells c)[j]=encodeCell (QuantumOrderedOutputSpatial.physicalCell + (qubits (qmaSparseCircuit c)) + (QuantumPaddedLabelProgram.sourceTerms (qmaSparseCircuit c) hT) + (qmaOrderedQubitCell c hT) (fun p => qmaOrderedTermCell c hT p.1) j) := by + simp only [rawCells_actual c hT,List.getElem_ofFn] + +theorem input_cell (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N j : ℕ) : + (QuantumHistorySpatial.input c hc hT hne N).cell j= + QuantumOrderedOutputSpatial.physicalCell (qubits (qmaSparseCircuit c)) + (QuantumPaddedLabelProgram.sourceTerms (qmaSparseCircuit c) hT) + (qmaOrderedQubitCell c hT) (fun p => qmaOrderedTermCell c hT p.1) j := by + simp only [QuantumHistorySpatial.input,QuantumOrderedOutputSpatial.input,id] + +theorem rawCells_input_length (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + (rawCells c).length=(QuantumHistorySpatial.input c hc hT hne N).n := by + rw [QuantumHistorySpatial.input_n] + exact rawCells_length c hT N + +theorem rawCells_input_get (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N j : ℕ) + (hj : j<(rawCells c).length) : + (rawCells c)[j]=encodeCell ((QuantumHistorySpatial.input c hc hT hne N).cell j) := by + rw [input_cell] + exact rawCells_get c hT j hj + +noncomputable def rawCertificate : Turing.TM2ComputableInPolyTime circuitCode + (listCode QuantumRouteCode.pairCode) rawCells := rawCellsProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryCells + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutedEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..930ad2688ca6bfca551bc0a21fae5f1a349194a0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutedEnergy.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySourceProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialFinalEnergy + +namespace OAI + +/-! Full-space history comparison and verifier implications for the +literal circuit-to-lattice output, including empty-circuit preparation. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySourceProgram +open QuantumHistorySpatial QuantumHistoryPreparedProgram QuantumPaddedLabelProgram +open QuantumAlgebraicHistory + +def routedState (c : QMACircuit) : QuantumListRouteProgram.State := + QuantumFinalRoutingProgram.routed rawDensity historyDegree (finalInput c) + +theorem routedState_actual (c : QMACircuit) (hc : c.WellFormed) : + routedState c = QuantumFinalRoutingProgram.routed rawDensity historyDegree + (((precision c:ℚ),QuantumSpatialInputTape.input + (QuantumHistorySpatial.input (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c) (precision c))), + thresholds c) := + congrArg (QuantumFinalRoutingProgram.routed rawDensity historyDegree) (finalInput_actual c hc) + +theorem route_rounds_eq : QuantumSpatialPortProgram.rounds rawDensity historyDegree = routeRounds := + (QuantumSpatialPortProgram.rounds_eq rawDensity historyDegree).symm.trans routeRounds_eq + +theorem history_error (c : QMACircuit) (hc : c.WellFormed) : + |QuantumListSchedule.energy (routedState c).1- + (qmaOrderedHistoryModel (qmaPreparedCircuit c) (qmaNonemptyCircuit_sparse_pos c)).energy| ≤ + ((totalRounds:ℝ)+9)/(precision c:ℝ) := by + let d := qmaNonemptyCircuit c + let hd := qmaNonemptyCircuit_wellFormed c hc + let ht := qmaNonemptyCircuit_sparse_pos c + let he := qmaNonemptyCircuit_nearest c + have hr := QuantumFinalRoutingProgram.spatial_energy_error + (QuantumHistorySpatial.input d hd ht he (precision c)) finalDensity_pos + (N := (precision c:ℚ)) (by exact_mod_cast precision_pos c) + (thresholds c).1 (thresholds c).2 + have hh := model_history_error d hd ht he (precision c) (precision_pos c) + rw [route_rounds_eq] at hr + rw [routedState_actual c hc] + have hn : ((precision c:ℚ):ℝ) = (precision c:ℝ) := Rat.cast_natCast _ + rw [hn] at hr + calc + _ ≤ |QuantumListSchedule.energy + (QuantumFinalRoutingProgram.routed rawDensity historyDegree + (((precision c:ℚ),QuantumSpatialInputTape.input + (QuantumHistorySpatial.input d hd ht he (precision c))),thresholds c)).1- + (model d hd ht he (precision c)).energy|+ + |(model d hd ht he (precision c)).energy- + (qmaOrderedHistoryModel (qmaPreparedCircuit c) ht).energy| := abs_sub_le _ _ _ + _ ≤ ((routeRounds:ℝ)+82)/(precision c:ℝ)+((historyDegree:ℝ)+10)/(precision c:ℝ) := + add_le_add hr hh + _ = _ := by simp only [totalRounds,Nat.cast_add,Nat.cast_ofNat]; ring + +theorem routed_accepting (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖=1) + (ha : 2/3 ≤ qmaAcceptance c hc psi) : + QuantumListSchedule.energy (routedState c).1 ≤ ((thresholds c).1:ℝ) := by + exact final_accepting totalRounds (qmaPreparedCircuit c) (qmaNonemptyCircuit_sparse_pos c) + (qmaPreparedCircuit_wellFormed c hc) (history_error c hc) psi hpsi + ((qmaPreparedCircuit_acceptance c hc psi).symm ▸ ha) + +theorem routed_rejecting (c : QMACircuit) (hc : c.WellFormed) + (ha : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖=1 → qmaAcceptance c hc psi ≤ 1/3) : + ((thresholds c).2:ℝ) ≤ QuantumListSchedule.energy (routedState c).1 := by + apply final_rejecting totalRounds (qmaPreparedCircuit c) (qmaNonemptyCircuit_sparse_pos c) + (qmaPreparedCircuit_wellFormed c hc) (history_error c hc) + intro psi hpsi + exact (qmaPreparedCircuit_acceptance c hc psi).symm ▸ ha psi hpsi + +end ContinuumCoulomb.QuantumHistorySourceProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutingProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutingProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a85e7a4bd4971b3139c3bfdd586233a6b640698 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryRoutingProgram.lean @@ -0,0 +1,59 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySpatialProgram + +namespace OAI + +/-! The completed history input is fed to the fixed number of fork rounds, +then to the literal endpoint/anchor array constructor. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatialProgram +open ExactQuantumFactoring.BitStackProgram + +def gridOutput (x : Input) : QuantumForkGridProgram.Cells := + QuantumForkGridProgram.output QuantumPaddedLabelProgram.historyDegree (prepared x) + +noncomputable opaque gridProgram : Procedure inputCode + QuantumForkGridProgram.cellsCode gridOutput := + (QuantumForkGridProgram.outputProgram QuantumPaddedLabelProgram.historyDegree).comp preparedProgram + +def routing (x : Input) : QuantumRoutingInputProgram.Data := + QuantumForkRoutingData.value (gridOutput x) + +noncomputable opaque routingProgram : Procedure inputCode + QuantumRoutingInputProgram.dataCode routing := + QuantumForkRoutingData.program.comp gridProgram + +theorem gridOutput_actual (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + gridOutput (N,c)= + ((QuantumHistorySpatial.input c hc hT hne N).state, + List.ofFn (fun i : Fin (QuantumHistorySpatial.input c hc hT hne N).state.1 => + QuantumSpatialInputTape.coordinates + ((QuantumHistorySpatial.input c hc hT hne N).cells i.val))) := by + rw [gridOutput,prepared_actual c hc hT hne N] + exact QuantumSpatialInputTape.output_eq (QuantumHistorySpatial.input c hc hT hne N) + +theorem gridOutput_state (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + (gridOutput (N,c)).1=QuantumPaddedLabelProgram.forkState + (qmaSparseCircuit c) hT N QuantumPaddedLabelProgram.historyDegree := by + rw [gridOutput_actual c hc hT hne N,QuantumHistorySpatial.input_state] + +theorem routing_actual (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + routing (N,c)=QuantumRoutingInputProgram.actualData + (QuantumHistorySpatial.model c hc hT hne N) (Equiv.refl _) := by + rw [routing,gridOutput,prepared_actual c hc hT hne N] + exact QuantumSpatialInputTape.routing_eq (QuantumHistorySpatial.input c hc hT hne N) + +noncomputable def routingCertificate : Turing.TM2ComputableInPolyTime inputCode + QuantumRoutingInputProgram.dataCode routing := routingProgram.toTM2 + +end ContinuumCoulomb.QuantumHistorySpatialProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySamplerProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySamplerProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cbaed81c68e237ff62a6236b56dbf48793b50fc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySamplerProgram.lean @@ -0,0 +1,116 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryTableCorrectness +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPaddedLabelTable + +namespace OAI + +/-! Literal polynomial generation of all sampled history packets. The +runtime list is indexed by the unary number of source terms, not Hilbert-space +dimension; each local matrix uses one of seven fixed arity programs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySamplerProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode QuantumHistoryDescriptors +open QuantumAlgebraicScalar QuantumFixedPauli +open scoped Classical + +local instance finDecision (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _ + +private theorem matrixData_instances {β : Type} (F G : Fintype β) + (A : Matrix β β Scalar) : @matrixData β F A=@matrixData β G A := by + cases Subsingleton.elim F G + rfl + +private theorem pair_matrixData_instances {β : Type} (F G : Fintype β) + (A : Matrix β β Scalar) (xs : List ℕ) : + (xs,@matrixData β F A)=(xs,@matrixData β G A) := + congrArg (fun ys : List Scalar => (xs,ys)) (matrixData_instances F G A) + +abbrev Input := ℕ × QMACircuit +def inputCode : Input → List Bool := prodCode unaryCode circuitCode + +def packet (x : Input) (i : ℕ) : List QuantumOrderedLabelFamily.Entry := + let labels := supportLabels x.2 i + QuantumPaddedLabelProgram.uniformPacket + (x.1,labels,QuantumHistoryTableProgram.table (x.2,i,labels)) + +def entries (x : Input) : List QuantumOrderedLabelFamily.Entry := + (List.ofFn (fun i : Fin (QuantumOrderedSourceIndex.referenceCount x.2) => packet x i.val)).flatten + +noncomputable opaque countProgram : Procedure circuitCode unaryCode + QuantumOrderedSourceIndex.referenceCount := by + let t := Procedure.unaryMul.comp + ((Procedure.constant circuitCode unaryCode 4).pair timeProgram) + let w := Procedure.unaryMul.comp + ((Procedure.constant circuitCode unaryCode 2).pair workProgram) + exact (Procedure.unaryAdd.comp + ((Procedure.unaryAdd.comp (t.pair w)).pair + (Procedure.constant circuitCode unaryCode 9))).congrFun (by + intro c + simpa only [Function.comp_apply] using (QuantumOrderedSourceIndex.referenceCount_eq c).symm) + +noncomputable opaque packetProgram : Procedure (prodCode unaryCode inputCode) + (listCode QuantumOrderedLabelFamily.entryCode) (fun x => packet x.2 x.1) := by + let i := Procedure.unaryToBits.comp (Procedure.first unaryCode inputCode) + let x := Procedure.second unaryCode inputCode + let k := (Procedure.first unaryCode circuitCode).comp x + let c := (Procedure.second unaryCode circuitCode).comp x + let labels := supportLabelsProgram.comp (c.pair i) + let matrix := QuantumHistoryTableProgram.tableProgram.comp (c.pair (i.pair labels)) + exact QuantumPaddedLabelProgram.uniformProgram.comp (k.pair (labels.pair matrix)) + +noncomputable opaque program : Procedure inputCode + (listCode QuantumOrderedLabelFamily.entryCode) entries := by + let c := Procedure.second unaryCode circuitCode + let nested := (Procedure.tabulate (f := fun x i => packet x i) [] packetProgram).comp + ((countProgram.comp c).pair (Procedure.identity inputCode)) + exact ((QuantumRawExchange.flattenProgram QuantumOrderedLabelFamily.entryCode ([],0)).comp + nested).congrFun (by + intro x + simp only [Function.comp_apply,id_eq,entries] + apply congrArg List.flatten + simpa only [List.length_range,List.getElem_range,Fin.val_cast] using + (List.ofFn_getElem_eq_map (List.range (QuantumOrderedSourceIndex.referenceCount x.2)) + (packet x)).symm) + +theorem packet_actual (k : ℕ) (c : QMACircuit) (hT : 0 QuantumPaddedLabelProgram.uniformPacket (k,p)) hp + +theorem entries_actual (k : ℕ) (c : QMACircuit) (hT : 0 (sampledOrderedWeight (samplePrecision c N) c hT p:ℝ))) - + (qmaOrderedHistoryModel c hT).energy| ≤ 1/(N:ℝ) := by + let k := samplePrecision c N + let M := (termBudget c:ℝ) + let B := (coefficientBudget c:ℝ) + have hM : 0 ≤ M := Nat.cast_nonneg _ + have hB : 0 ≤ B := Nat.cast_nonneg _ + have hNR : (0:ℝ) < N := Nat.cast_pos.mpr hN + have hpow : (k:ℝ)+1 ≤ (2:ℝ)^k := by + have hp : k+1 ≤ 2^k := Nat.succ_le_iff.mpr (Nat.lt_two_pow_self (n := k)) + exact_mod_cast hp + have hkp : (0:ℝ) < (k:ℝ)+1 := + add_pos_of_nonneg_of_pos (Nat.cast_nonneg k) (by norm_num) + have hcard : (Fintype.card (OrderedPauliTerm c hT):ℝ) ≤ M := by + change (Fintype.card (OrderedPauliTerm c hT):ℝ) ≤ (termBudget c:ℝ) + unfold termBudget + exact_mod_cast orderedWord_count c hT + have hk : (k:ℝ) = (M+1)*(B+1)*N := by + simp only [k,samplePrecision,M,B,Nat.cast_mul,Nat.cast_add,Nat.cast_one] + calc + _ ≤ ∑ p : OrderedPauliTerm c hT, + |((orderedRealCoefficient c hT p).2:ℝ)| * (2:ℝ)⁻¹^k := + sampledOrdered_error k c hT + _ ≤ ∑ _p : OrderedPauliTerm c hT, B*(2:ℝ)⁻¹^k := by + apply Finset.sum_le_sum + intro p _ + exact mul_le_mul_of_nonneg_right (orderedCoefficient_second_bound c hT p) + (by positivity) + _ = (Fintype.card (OrderedPauliTerm c hT):ℝ)*B*(2:ℝ)⁻¹^k := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + ring + _ ≤ M*B*(2:ℝ)⁻¹^k := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hcard hB) (by positivity) + _ = M*B/((2:ℝ)^k) := by rw [inv_pow]; rfl + _ ≤ M*B/((k:ℝ)+1) := div_le_div_of_nonneg_left (mul_nonneg hM hB) hkp hpow + _ ≤ 1/(N:ℝ) := by + apply (div_le_div_iff₀ hkp hNR).mpr + rw [hk] + nlinarith + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySiteProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySiteProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd4674a27d049a16e6fd93f23c0108f2843fa433 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySiteProgram.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateCode +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedSupport +import OAI.Computability.QuantumFactoring.BitStackListIndex +import OAI.Computability.QuantumFactoring.BitStackListMapWith +import OAI.Computability.QuantumFactoring.BitStackListLength + +namespace OAI + +/-! Literal ordered gate and propagation support lists. The values agree +with the exact support order used by the local history matrix tables. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySiteProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode + +abbrev GateInput := ℕ × QMAGate +def gateInputCode : GateInput → List Bool := prodCode Nat.bits gateCode + +def gateLabels (x : GateInput) : List ℕ := + let left := gateLeft x.2 % (x.1+1) + let right := gateRight x.2 % (x.1+1) + if gateTag x.2=2 then [left,right] else [left] + +noncomputable def gateLabelsProgram : + Procedure gateInputCode (listCode Nat.bits) gateLabels := by + let work := Procedure.first Nat.bits gateCode + let gate := Procedure.second Nat.bits gateCode + let modulus := Procedure.successor.comp work + let left := Procedure.binaryMod.comp ((gateLeftProgram.comp gate).pair modulus) + let right := Procedure.binaryMod.comp ((gateRightProgram.comp gate).pair modulus) + let nil := Procedure.constant gateInputCode (listCode Nat.bits) [] + let single := (Procedure.listCons Nat.bits).comp (left.pair nil) + let pair := (Procedure.listCons Nat.bits).comp + (left.pair ((Procedure.listCons Nat.bits).comp (right.pair nil))) + let isCnot := Procedure.binaryEq.comp ((gateTagProgram.comp gate).pair + (Procedure.constant gateInputCode Nat.bits 2)) + exact (Procedure.conditional isCnot pair single).congrFun (by + intro x + simp only [Function.comp_apply,gateLabels,decide_eq_true_eq]) + +theorem gateLabels_actual (work : ℕ) (g : QMAGate) : + gateLabels (work,g)=(QuantumOrderedSupport.gateSites work g).map Fin.val := by + cases g <;> rfl + +def distributedNumber (c : QMACircuit) : QMACircuitQubit c → ℕ := + Sum.elim Fin.val (fun i => c.gates.length+2+i.val) + +abbrev Input := QMACircuit × ℕ +def inputCode : Input → List Bool := prodCode circuitCode Nat.bits + +def gateAt (x : Input) : QMAGate := x.1.gates.getD x.2 (.hadamard 0) + +def propagationLabels (x : Input) : List ℕ := + [x.2,x.2+1,x.2+2] ++ + (gateLabels (x.1.work,gateAt x)).map (fun i => x.1.gates.length+2+i) + +noncomputable def gateAtProgram : Procedure inputCode gateCode gateAt := by + let circuit := Procedure.first circuitCode Nat.bits + let index := Procedure.second circuitCode Nat.bits + exact ((Procedure.listGet gateCode (.hadamard 0)).comp + (index.pair (gatesProgram.comp circuit))).congrFun (by + intro x + simp only [Function.comp_apply,gateAt,List.headD_eq_head?_getD, + List.head?_drop,List.getD_eq_getElem?_getD]) + +noncomputable def propagationLabelsProgram : + Procedure inputCode (listCode Nat.bits) propagationLabels := by + let circuit := Procedure.first circuitCode Nat.bits + let index := Procedure.second circuitCode Nat.bits + let work := Procedure.unaryToBits.comp (workProgram.comp circuit) + let gates := gatesProgram.comp circuit + let count := Procedure.unaryToBits.comp + ((ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength gateCode (.hadamard 0)).comp gates) + let offset := Procedure.binaryAdd.comp (count.pair (Procedure.constant inputCode Nat.bits 2)) + let nil := Procedure.constant inputCode (listCode Nat.bits) [] + let one := Procedure.successor.comp index + let two := Procedure.successor.comp one + let clock := (Procedure.listCons Nat.bits).comp + (index.pair ((Procedure.listCons Nat.bits).comp + (one.pair ((Procedure.listCons Nat.bits).comp (two.pair nil))))) + let gateSites := gateLabelsProgram.comp (work.pair gateAtProgram) + let translated := (Procedure.listMapWith (f := fun a b : ℕ => a+b) 0 0 + Procedure.binaryAdd).comp (offset.pair gateSites) + exact (Procedure.listAppend Nat.bits 0).comp (clock.pair translated) + +theorem propagationLabels_actual (c : QMACircuit) (t : Fin c.gates.length) : + propagationLabels (c,t.val)= + (QuantumOrderedSupport.propagationSites c t).map (distributedNumber c) := by + simp only [propagationLabels,gateAt,gateLabels_actual, + QuantumOrderedSupport.propagationSites,List.map_append,List.map_cons,List.map_nil, + List.map_map,Function.comp_def,distributedNumber,qmaClockLeft,qmaClockMiddle,qmaClockRight] + rfl + +end ContinuumCoulomb.QuantumHistorySiteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySizeBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySizeBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..122ff80caa65caa89edb3386006ebb7aca5ae9b5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySizeBounds.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryParameterBounds +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawOutputSize +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryLattice + +namespace OAI + +/-! Linear size and box bounds for the exact spatial graph before routing. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumOrderedSourceIndex QuantumPaddedLabelProgram QuantumForkList + +def rawBondFactor : ℕ := 6*(1+3717*8192)+22*(12544*8192) +def spatialSizeFactor (D : ℕ) : ℕ := 4*(1+3717*8192)+(5+12*D)*rawBondFactor + +theorem history_bonds_linear (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : + (historyOutput c hT N).1.length ≤ rawBondFactor*qubitCount c := by + have h := historyOutput_length c hT N + have hm := termCount_bound c + calc + _ ≤ 6*(qubitCount c+3717*termCount c)+22*(12544*termCount c) := h + _ ≤ 6*(qubitCount c+3717*(8192*qubitCount c))+ + 22*(12544*(8192*qubitCount c)) := by gcongr + _ = _ := by unfold rawBondFactor; ring + +theorem model_size_linear (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (model c hc hT hne N).n+Fintype.card (model c hc hT hne N).Term ≤ + spatialSizeFactor historyDegree*qubitCount (qmaSparseCircuit c) := by + have h := (input c hc hT hne N).model_size + rw [input_n,historyQubits_eq,input_bonds] at h + have hb := history_bonds_linear (qmaSparseCircuit c) hT N + have hm := termCount_bound (qmaSparseCircuit c) + calc + _ ≤ 4*(qubitCount (qmaSparseCircuit c)+3717*termCount (qmaSparseCircuit c))+ + 5*(historyOutput (qmaSparseCircuit c) hT N).1.length+ + 12*historyDegree*(historyOutput (qmaSparseCircuit c) hT N).1.length := h + _ ≤ 4*(qubitCount (qmaSparseCircuit c)+3717*(8192*qubitCount (qmaSparseCircuit c)))+ + 5*(rawBondFactor*qubitCount (qmaSparseCircuit c))+ + 12*historyDegree*(rawBondFactor*qubitCount (qmaSparseCircuit c)) := by gcongr + _ = _ := by unfold spatialSizeFactor; ring + +theorem model_rows_bound (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (model c hc hT hne N).rows ≤ qubitCount (qmaSparseCircuit c) := by + rw [model,SpatialInput.model_rows,qubitCount_eq] + change (qmaNearestCircuit c).gates.length ≤ + 3*(qmaSparseCircuit c).gates.length+ + 2*(c.work+(qmaNearestCircuit c).gates.length*(c.work+1))+8 + nlinarith + +theorem model_width_bound (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (model c hc hT hne N).width ≤ qubitCount (qmaSparseCircuit c) := by + rw [model,SpatialInput.model_width,qubitCount_eq] + change c.work ≤ 3*(qmaSparseCircuit c).gates.length+ + 2*(c.work+(qmaNearestCircuit c).gates.length*(c.work+1))+8 + omega + +def boxFactor (A B : ℕ) : ℕ := 256*(8*(9*B+9))*(A+1) + +theorem model_box_bound {A B n : ℕ} (M : QMASpatialExchangeModel A B) + (hr : M.rows ≤ n) (hw : M.width ≤ n) : + 256*M.bufferedWidth ≤ boxFactor A B*(n+1) ∧ + 256*M.bufferedHeight ≤ boxFactor A B*(n+1) := by + constructor + · calc + _ = 256*(8*(9*B+9))*A*(M.rows+1) := by unfold QMASpatialExchangeModel.bufferedWidth; ring + _ ≤ 256*(8*(9*B+9))*(A+1)*(n+1) := by gcongr; omega + _ = _ := rfl + · calc + _ = 256*(8*(9*B+9))*1*(M.width+1) := by unfold QMASpatialExchangeModel.bufferedHeight; ring + _ ≤ 256*(8*(9*B+9))*(A+1)*(n+1) := by gcongr; omega + _ = _ := rfl + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePowers.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePowers.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad53992b677df1bc8e3b64a817f763fb0b60ea29 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePowers.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGeometryPowers + +namespace OAI + +/-! The literal coefficient programs and the exact geometry admit a common +polynomial exponent, uniform over verifier circuits. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumOrderedSourceIndex QuantumAlgebraicHistory QuantumForkList QuantumPaddedLabelProgram +open QuantumCoefficientPrograms + +theorem source_data_power : ∃ k : ℕ, ∀ (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []), ∃ L : ℕ, + 1 ≤ L ∧ (model c hc hT hne (latticePrecision c)).exchangeGraph.CoefficientBound L ∧ + 256*(model c hc hT hne (latticePrecision c)).bufferedWidth ≤ + (qubitCount (qmaSparseCircuit c)+2)^k ∧ + 256*(model c hc hT hne (latticePrecision c)).bufferedHeight ≤ + (qubitCount (qmaSparseCircuit c)+2)^k ∧ + latticeBound routeRounds (Fintype.card (model c hc hT hne (latticePrecision c)).Term) + ((model c hc hT hne (latticePrecision c)).portRouteData finalDensity_pos + (model_degree c hc hT hne (latticePrecision c))).crossingCells.card L (latticePrecision c) ≤ + (qubitCount (qmaSparseCircuit c)+2)^k := by + obtain ⟨g,hg⟩ := model_geometry_power + obtain ⟨a,ha⟩ := historyCoefficientBudget_power totalRounds + obtain ⟨b,hb⟩ := parameters_power totalRounds + obtain ⟨d,hd⟩ := outputCoefficientNat_power historyDegree + obtain ⟨e,he⟩ := latticeBound_power routeRounds + let k₁ := g+a+b + let k₂ := k₁+(k₁+4)*d + refine ⟨k₂+(k₂+4)*e,fun c hc hT hne => ?_⟩ + let n := qubitCount (qmaSparseCircuit c) + let N := latticePrecision c + let L := outputCoefficientNat (input c hc hT hne N).bonds.length historyDegree + (historyCoefficientBudget (qmaSparseCircuit c) N) N + have lift {i j : ℕ} (h : i ≤ j) : (n+2)^i ≤ (n+2)^j := + pow_le_pow_right₀ (by omega : 1 ≤ n+2) h + obtain ⟨hm,ht,hr,hx,hy⟩ := hg c hc hT hne N + have hraw := ha (qmaSparseCircuit c) + have hN := (hb (qmaSparseCircuit c)).2.2.2 + have hL : L ≤ (n+2)^((k₁+4)*d) := outputCoefficientNat_of_power hd + (hm.trans (lift (by dsimp [k₁]; omega))) + (hraw.trans (lift (by dsimp [k₁]; omega))) + (hN.trans (lift (by dsimp [k₁]; omega))) + have hf : latticeBound routeRounds (Fintype.card (model c hc hT hne N).Term) + ((model c hc hT hne N).portRouteData finalDensity_pos + (model_degree c hc hT hne N)).crossingCells.card L N ≤ + (n+2)^((k₂+4)*e) := latticeBound_of_power he + (ht.trans (lift (by dsimp [k₂,k₁]; omega))) + (hr.trans (lift (by dsimp [k₂,k₁]; omega))) + (hL.trans (lift (by dsimp [k₂]; omega))) + (hN.trans (lift (by dsimp [k₂,k₁]; omega))) + exact ⟨L,outputCoefficientNat_one _ _ _ _,model_coefficientBound c hc hT hne N, + hx.trans (lift (by dsimp [k₂,k₁]; omega)), + hy.trans (lift (by dsimp [k₂,k₁]; omega)), + hf.trans (lift (by omega))⟩ + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourceProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourceProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..298646f01b09e1503c9a94acef158e67b52cee53 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourceProgram.lean @@ -0,0 +1,64 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryPreparedProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFinalRoutingProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPreparedVerifier + +namespace OAI + +/-! The complete literal circuit-to-source map, including nonempty padding, +sampling precision, fork and route programs, and rational thresholds. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySourceProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode BinaryEncoding + +def value : QMACircuit → BinaryHeisenberg := + QuantumFinalRoutingProgram.value QuantumHistorySpatial.rawDensity + QuantumPaddedLabelProgram.historyDegree ∘ QuantumHistoryPreparedProgram.finalInput + +theorem inputCode_eq : QuantumHistoryPreparedProgram.finalInputCode= + QuantumFinalRoutingProgram.inputCode := rfl + +private noncomputable opaque inputProgram : Procedure circuitCode + QuantumFinalRoutingProgram.inputCode QuantumHistoryPreparedProgram.finalInput := by + rw [← inputCode_eq] + exact QuantumHistoryPreparedProgram.finalInputProgram + +noncomputable opaque program : Procedure circuitCode binaryHeisenbergCodec.encode value := + @Procedure.comp QMACircuit QuantumFinalRoutingProgram.Input BinaryHeisenberg + circuitCode QuantumFinalRoutingProgram.inputCode binaryHeisenbergCodec.encode + QuantumHistoryPreparedProgram.finalInput + (QuantumFinalRoutingProgram.value QuantumHistorySpatial.rawDensity + QuantumPaddedLabelProgram.historyDegree) + (QuantumFinalRoutingProgram.program QuantumHistorySpatial.rawDensity + QuantumPaddedLabelProgram.historyDegree) inputProgram + +theorem value_actual (c : QMACircuit) (hc : c.WellFormed) : + value c=QuantumFinalRoutingProgram.value QuantumHistorySpatial.rawDensity + QuantumPaddedLabelProgram.historyDegree + (((QuantumHistoryPreparedProgram.precision c:ℚ),QuantumSpatialInputTape.input + (QuantumHistorySpatial.input (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c) + (QuantumHistoryPreparedProgram.precision c))), + (QuantumAlgebraicHistory.xzYesThreshold (qmaPreparedCircuit c), + QuantumAlgebraicHistory.xzNoThreshold (qmaPreparedCircuit c))) := + congrArg (QuantumFinalRoutingProgram.value QuantumHistorySpatial.rawDensity + QuantumPaddedLabelProgram.historyDegree) (QuantumHistoryPreparedProgram.finalInput_actual c hc) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime circuitCode + binaryHeisenbergCodec.encode value := program.toTM2 + +def fromVerifier (V : QuantumVerifier) : BitString → BinaryHeisenberg := value ∘ V.generate + +noncomputable def fromVerifier_uniform (V : QuantumVerifier) : + Turing.TM2ComputableInPolyTime (id : BitString → List Bool) + binaryHeisenbergCodec.encode (fromVerifier V) := + TM2Composition.computable V.generateUnary certificate + +theorem fromVerifier_actual (V : QuantumVerifier) (x : BitString) : + fromVerifier V x=value (V.generate x) := rfl + +end ContinuumCoulomb.QuantumHistorySourceProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePromise.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePromise.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d837730eddcbca47263ebd56250bbf60ffc1daa --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySourcePromise.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySourcePowers +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPreparedLattice + +namespace OAI + +/-! The specified verifier output satisfies the exact polynomial source +promise, with one exponent for all circuits, including empty-circuit padding. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumOrderedSourceIndex QuantumAlgebraicHistory QuantumCoefficientPrograms + +theorem source_polynomialPromise : ∃ k : ℕ, 0 < k ∧ + ∀ (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []), + (source c hc hT hne).binary.PolynomialPromise k := by + obtain ⟨a,ha⟩ := source_data_power + refine ⟨2*a+6,by omega,fun c hc hT hne => ?_⟩ + let n := qubitCount (qmaSparseCircuit c) + have hn : 0 < n := qubitCount_positive _ + obtain ⟨L,hL,hC,hx,hy,hw⟩ := ha c hc hT hne + have lift (m : ℕ) (hm : m ≤ (n+2)^a) : (m:ℝ) ≤ (n+1:ℝ)^(2*a+6) := by + have hb : m ≤ (n+1)^(2*a+6) := hm.trans + ((power_base_change hn).trans + (pow_le_pow_right₀ (by omega : 1 ≤ n+1) (by omega))) + exact_mod_cast hb + have hsize : n ≤ (model c hc hT hne (latticePrecision c)).n := by + have h := model_vertices_ge c hc hT hne (latticePrecision c) + rw [QuantumPaddedLabelProgram.historyQubits_eq] at h + dsimp only [n] + omega + unfold source + apply (model c hc hT hne (latticePrecision c)).latticeSource_binary_promise + finalDensity_pos (model_degree c hc hT hne (latticePrecision c)) + (latticePrecision c:ℚ) (model_vertices_pos c hc hT hne (latticePrecision c)) + (xzYesThreshold (qmaSparseCircuit c)) (xzNoThreshold (qmaSparseCircuit c)) + (xz_threshold_lt (qmaSparseCircuit c)) hsize + (by exact_mod_cast Nat.zero_le (latticePrecision c)) hL + (by simp only [Rat.cast_natCast,abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ latticePrecision c)]; exact le_rfl) hC + (lift _ hx) (lift _ hy) + · rw [routeRounds_eq] + exact lift _ hw + · exact final_threshold_gap_bound (qmaSparseCircuit c) hn + (time_le_qubitCount _) (by omega) + +theorem preparedSource_polynomialPromise : ∃ k : ℕ, 0 < k ∧ + ∀ (c : QMACircuit) (hc : c.WellFormed), + (preparedSource c hc).binary.PolynomialPromise k := by + obtain ⟨k,hk,h⟩ := source_polynomialPromise + exact ⟨k,hk,fun c hc => h (qmaNonemptyCircuit c) (qmaNonemptyCircuit_wellFormed c hc) + (qmaNonemptyCircuit_sparse_pos c) (qmaNonemptyCircuit_nearest c)⟩ + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatial.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatial.lean new file mode 100644 index 0000000000000000000000000000000000000000..efad7d12d7a6fce103e2c1c57aea41d5951da785 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatial.lean @@ -0,0 +1,86 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedOutputSpatial + +namespace OAI + +/-! The actual sparse verifier history has a fixed-density, degree-three +spatial exchange output. Its energy is that of the literal fork compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatial +open QuantumPaddedHistory QuantumOrderedSourceIndex QuantumPaddedLabelProgram +open QuantumForkList +open scoped Classical + +def rawDensity : ℕ := 4*(45+3717*(4096*64)) +def finalDensity : ℕ := spatialDensity rawDensity historyDegree + +theorem padded_anchor_density (c : QMACircuit) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) + (p : QMAGridCell (qmaNearestCircuit c).gates.length c.work) : + (Finset.univ.filter (fun a : Term (qmaSparseCircuit c) => + qmaOrderedTermCell c hT a.1=p)).card ≤ 4096*64 := by + rw [qmaProductFilter_card (β := Fin 6 → Fin 4) (fun a => qmaOrderedTermCell c hT a=p)] + simp only [Fintype.card_fun,Fintype.card_fin] + exact Nat.mul_le_mul_left _ (qmaOrderedTermCell_fiber_card c hT hne p) + +def input (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + SpatialInput (qmaNearestCircuit c).gates.length c.work rawDensity historyDegree := by + change SpatialInput _ _ (4*(45+3717*(4096*64))) (6+22*(12544*2359296)) + exact QuantumOrderedOutputSpatial.input (qubits (qmaSparseCircuit c)) + (sourceTerms (qmaSparseCircuit c) hT) + (fun p : Term (qmaSparseCircuit c) => QuantumOrderedSupport.sites (qmaSparseCircuit c) hT p.1) + (sourceWord (qmaSparseCircuit c) hT) + (sampledWeight (QuantumAlgebraicHistory.samplePrecision (qmaSparseCircuit c) N) + (qmaSparseCircuit c) hT) + (fun p => QuantumOrderedSupport.sites_length (qmaSparseCircuit c) hT p.1) + (fun p => QuantumOrderedSupport.sites_nodup (qmaSparseCircuit c) hT p.1) + (qmaOrderedQubitCell c hT) (fun p => qmaOrderedTermCell c hT p.1) + (by intro p; simpa only [Finset.filter_congr_decidable] using qmaOrderedQubitCell_fiber_card c hT hne p) + (by intro p; simpa only [Finset.filter_congr_decidable] using padded_anchor_density c hT hne p) + (fun p i hi => qmaOrderedHistoryModel_spatial c hc hT hne p.1 i + ((QuantumOrderedSupport.sites_finset (qmaSparseCircuit c) hT p.1) ▸ + List.mem_toFinset.mpr hi)) + (by decide) (QuantumHistoryIncidence.sparse_padded_bound c hc hT hne) N + +theorem input_state (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (input c hc hT hne N).state=forkState (qmaSparseCircuit c) hT N historyDegree := by + unfold SpatialInput.state forkState historyQubits historyOutput historyInput + rw [sourceEntries_table] + rfl + +def model (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) := (input c hc hT hne N).model + +theorem model_energy (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) : + (model c hc hT hne N).energy = + MediatorGraph.normalizedBottom (matrix (forkState (qmaSparseCircuit c) hT N historyDegree)) := by + rw [model,SpatialInput.model_energy,input_state] + +theorem model_history_error (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) (hN : 0 < N) : + |(model c hc hT hne N).energy-(qmaOrderedHistoryModel (qmaSparseCircuit c) hT).energy| ≤ + ((historyDegree:ℝ)+10)/(N:ℝ) := by + rw [model_energy] + exact fork_accuracy (qmaSparseCircuit c) hT N hN historyDegree + +theorem model_degree (c : QMACircuit) (hc : c.WellFormed) + (hT : 0 < (qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates ≠ []) (N : ℕ) + (v : Fin (model c hc hT hne N).n) : + qmaGraphDegree (model c hc hT hne N).left (model c hc hT hne N).right v ≤ 3 := + (input c hc hT hne N).model_degree v + +end ContinuumCoulomb.QuantumHistorySpatial + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatialProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatialProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba20672aeef356ae509fd4454a5b310e33395d88 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpatialProgram.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryRawCells +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialInputTape + +namespace OAI + +/-! The literal sampled history and its row/column labels are combined into +the exact prepared input of the fixed-round fork compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistorySpatialProgram +open ExactQuantumFactoring.BitStackProgram QuantumCircuitCode +open QuantumHistoryPrecisionProgram + +abbrev Input := QuantumHistoryPrecisionProgram.Input +abbrev inputCode := QuantumHistoryPrecisionProgram.inputCode + +def sparseInput (x : Input) : Input := (x.1,qmaSparseCircuit x.2) + +noncomputable opaque sparseInputProgram : Procedure inputCode inputCode sparseInput := + inverseErrorProgram.pair (sparseCircuitProgram.comp circuitProgram) + +def initialInput (x : Input) : QuantumForkList.InitialInput := + ((x.1:ℚ),physicalQubits (sparseInput x),output (sparseInput x)) + +noncomputable opaque initialInputProgram : Procedure inputCode + QuantumForkList.initialInputCode initialInput := + (Procedure.natToRat.comp (Procedure.unaryToBits.comp inverseErrorProgram)).pair + ((physicalQubitsProgram.comp sparseInputProgram).pair + (outputProgram.comp sparseInputProgram)) + +def prepared (x : Input) : QuantumForkGridProgram.PreparedInput := + (initialInput x,QuantumHistoryCells.rawCells x.2) + +noncomputable opaque cellsProgram : Procedure inputCode + (listCode QuantumRouteCode.pairCode) (QuantumHistoryCells.rawCells ∘ Prod.snd) := + @Procedure.comp Input QMACircuit (List QuantumRouteCode.Pair) + inputCode circuitCode (listCode QuantumRouteCode.pairCode) + Prod.snd QuantumHistoryCells.rawCells QuantumHistoryCells.rawCellsProgram circuitProgram + +noncomputable opaque preparedProgram : Procedure inputCode + QuantumForkGridProgram.preparedCode prepared := by + refine (@Procedure.pair Input QuantumForkList.InitialInput (List QuantumRouteCode.Pair) + inputCode QuantumForkList.initialInputCode (listCode QuantumRouteCode.pairCode) + initialInput (QuantumHistoryCells.rawCells ∘ Prod.snd) + initialInputProgram cellsProgram).congrFun ?_ + intro x + simp only [prepared,Function.comp_apply] + +theorem rawCells_input (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + QuantumHistoryCells.rawCells c=List.ofFn + (fun i : Fin (QuantumHistorySpatial.input c hc hT hne N).n => + QuantumSpatialInputTape.coordinates + ((QuantumHistorySpatial.input c hc hT hne N).cell i.val)) := by + apply List.ext_getElem + · rw [List.length_ofFn] + exact QuantumHistoryCells.rawCells_input_length c hc hT hne N + · intro j hj _ + rw [List.getElem_ofFn] + simpa only [QuantumSpatialInputTape.coordinates,QuantumHistoryCells.encodeCell] using + QuantumHistoryCells.rawCells_input_get c hc hT hne N j hj + +theorem initialInput_actual (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + initialInput (N,c)= + ((QuantumHistorySpatial.input c hc hT hne N).precision, + (QuantumHistorySpatial.input c hc hT hne N).n, + (QuantumHistorySpatial.input c hc hT hne N).bonds, + (QuantumHistorySpatial.input c hc hT hne N).constant) := by + rw [initialInput,sparseInput,physicalQubits_actual N (qmaSparseCircuit c) hT, + output_actual N (qmaSparseCircuit c) hT,QuantumHistorySpatial.input_n, + QuantumHistorySpatial.input_bonds,QuantumHistorySpatial.input_constant] + rfl + +theorem prepared_actual (c : QMACircuit) (hc : c.WellFormed) + (hT : 0<(qmaSparseCircuit c).gates.length) + (hne : (qmaNearestCircuit c).gates≠[]) (N : ℕ) : + prepared (N,c)=QuantumSpatialInputTape.input + (QuantumHistorySpatial.input c hc hT hne N) := by + unfold prepared QuantumSpatialInputTape.input + rw [initialInput_actual c hc hT hne N,rawCells_input c hc hT hne N] + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode + QuantumForkGridProgram.preparedCode prepared := preparedProgram.toTM2 + +end ContinuumCoulomb.QuantumHistorySpatialProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpectrum.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpectrum.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8ae1227fcebead4558798027bccad672ef36ef2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistorySpectrum.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryMatrixForm + +namespace OAI + +/-! Normalized finite-dimensional spectral bounds for the history matrix. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators + +def qmaHistoryVector (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + EuclideanSpace ℂ (QMAHistoryBasis c) := + WithLp.toLp 2 (fun p => u p.1.val p.2) + +theorem qmaHistoryVector_slice (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) + (t : ℕ) (ht : t ≤ c.gates.length) : + qmaHistoryFromVector c (fun p => qmaHistoryVector c u p) t = u t := by + ext s + simp [qmaHistoryFromVector,qmaClockIndex,qmaHistoryVector,Nat.min_eq_left ht] + +theorem qmaHistoryVector_norm (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + ‖qmaHistoryVector c u‖^2 = qmaHistoryMass c u := by + rw [EuclideanSpace.norm_sq_eq] + unfold qmaHistoryMass + rw [←Fin.sum_univ_eq_sum_range,Fintype.sum_prod_type] + simp [qmaHistoryVector,EuclideanSpace.norm_sq_eq] + +theorem qmaHistoryVector_propagation (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaPropagationEnergy c (qmaHistoryFromVector c (fun p => qmaHistoryVector c u p)) = + qmaPropagationEnergy c u := by + apply Finset.sum_congr rfl + intro t ht + have ht' := Finset.mem_range.mp ht + rw [qmaHistoryVector_slice c u t (Nat.le_of_lt ht'), + qmaHistoryVector_slice c u (t+1) (Nat.succ_le_of_lt ht')] + +theorem qmaHistoryVector_form (c : QMACircuit) + (u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaQuadratic (qmaHistoryHamiltonian c) (fun p => qmaHistoryVector c u p) = + qmaHistoryEnergy c u := by + rw [qmaHistoryHamiltonian_form] + unfold qmaHistoryEnergy qmaInputPenalty qmaOutputPenalty + rw [qmaHistoryVector_propagation,qmaHistoryVector_slice c u 0 (Nat.zero_le _), + qmaHistoryVector_slice c u c.gates.length le_rfl] + +theorem qmaQuadratic_vector_smul {ι : Type*} [Fintype ι] + (M : Matrix ι ι ℂ) (a : ℝ) (u : ι → ℂ) : + qmaQuadratic M ((a:ℂ) • u) = a^2*qmaQuadratic M u := by + simp [qmaQuadratic,Matrix.mulVec_smul,star_smul,dotProduct_smul,smul_dotProduct, + Complex.mul_re,pow_two] + ring + +theorem qmaHistoryHamiltonian_sound (c : QMACircuit) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) + (u : EuclideanSpace ℂ (QMAHistoryBasis c)) : + 2*‖u‖^2 ≤ 5*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaHistoryHamiltonian c) (fun p => u p) := by + have h := qma_history_energy_sound c hc hsound + (qmaHistoryFromVector c (fun p => u p)) + rw [qmaHistoryFromVector_mass,←qmaHistoryHamiltonian_form] at h + exact h + +theorem qmaHistoryHamiltonian_accepting (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : EuclideanSpace ℂ (QMAHistoryBasis c), ‖u‖ = 1 ∧ + 3*(c.gates.length+1:ℝ)*qmaQuadratic (qmaHistoryHamiltonian c) (fun p => u p) ≤ 1 := by + obtain ⟨u,hm,he⟩ := qma_history_accepting_witness c hc psi hpsi hacc + let w := qmaHistoryVector c u + have hw : 0 < ‖w‖^2 := by simpa only [w,qmaHistoryVector_norm] using hm + have hn : ‖w‖ ≠ 0 := by intro h; rw [h] at hw; norm_num at hw + let v := ((‖w‖⁻¹:ℝ):ℂ) • w + have hv : ‖v‖ = 1 := by simp [v,norm_smul,hn] + refine ⟨v,hv,?_⟩ + have hq : qmaQuadratic (qmaHistoryHamiltonian c) (fun p => v p) = + (‖w‖⁻¹)^2*qmaQuadratic (qmaHistoryHamiltonian c) (fun p => w p) := by + convert qmaQuadratic_vector_smul (qmaHistoryHamiltonian c) (‖w‖⁻¹) (fun p => w p) using 1 + congr 1 + have he' : 3*(c.gates.length+1:ℝ)* + qmaQuadratic (qmaHistoryHamiltonian c) (fun p => w p) ≤ ‖w‖^2 := by + simpa only [w,qmaHistoryVector_form,qmaHistoryVector_norm] using he + have hm' := mul_le_mul_of_nonneg_left he' (sq_nonneg (‖w‖⁻¹)) + have hi : (‖w‖⁻¹)^2*‖w‖^2 = 1 := by field_simp + rw [hq] + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryTableCorrectness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryTableCorrectness.lean new file mode 100644 index 0000000000000000000000000000000000000000..026c50ba5132b6425604ba33cbd2ad46018bdad5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryTableCorrectness.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryTableProgram + +namespace OAI + +/-! The total table dispatcher agrees with the actual ordered history core, +including its canonical finite enumeration. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumHistoryTableProgram +open QuantumHistoryDescriptors QuantumAlgebraicScalar QuantumFixedPauli +open scoped Classical + +theorem nondiagonal_term (c : QMACircuit) (a : QMACircuitTerm c) + (ha : ¬(encode c a).1<4) : + ∃ t : Fin c.gates.length, a=QuantumPropagationOrder.term c t := by + rcases a with i | (b | (i | (u | t))) + · norm_num [encode] at ha + · norm_num [encode] at ha + · norm_num [encode] at ha + · norm_num [encode] at ha + · exact ⟨t,rfl⟩ + +theorem propagationLabels_tail (c : QMACircuit) (hT : 0 + change localTable (QuantumOrderedSupport.sites c hT (.inl i)).length + (c,i.val,QuantumOrderedSupport.encodedSites c hT (.inl i))=_ + have hi : i.val + change localTable (QuantumOrderedSupport.sites c hT (.inr i)).length + (c,qmaHistoryReferenceWork c+1+i.val,QuantumOrderedSupport.encodedSites c hT (.inr i))=_ + have hi : ¬qmaHistoryReferenceWork c+1+i.val x.2.1) := + (Procedure.first _ _).comp restProgram +noncomputable opaque labelsProgram : Procedure inputCode (listCode Nat.bits) (fun x => x.2.2) := + (Procedure.second _ _).comp restProgram +noncomputable opaque descriptorProgram : Procedure inputCode descriptorCode + (fun x => orderedAt x.1 x.2.1) := + orderedAtProgram.comp (circuitProgram.pair indexProgram) +noncomputable opaque cutoffProgram : Procedure inputCode Nat.bits + (fun x => referenceWork x.1+1) := + Procedure.successor.comp (referenceWorkProgram.comp circuitProgram) + +noncomputable opaque localTableProgram (n : ℕ) : Procedure inputCode matrixCode (localTable n) := by + let diagonal := (QuantumHistoryDiagonal.tableProgram n).comp + (circuitProgram.pair (descriptorProgram.pair labelsProgram)) + let time := (Procedure.second Nat.bits Nat.bits).comp descriptorProgram + let propagation := (QuantumPropagationSampler.tableListProgram n).comp + (circuitProgram.pair (time.pair ((Procedure.listTail Nat.bits).comp labelsProgram))) + let edge := (QuantumReferenceEdgeTable.tableProgram n).comp + ((Procedure.binarySub.comp (indexProgram.pair cutoffProgram)).pair labelsProgram) + let localTest := Procedure.binaryLt.comp (indexProgram.pair cutoffProgram) + let tag := (Procedure.first Nat.bits Nat.bits).comp descriptorProgram + let diagonalTest := Procedure.binaryLt.comp + (tag.pair (Procedure.constant inputCode Nat.bits 4)) + exact (Procedure.conditional localTest + (Procedure.conditional diagonalTest diagonal propagation) edge).congrFun (by + intro x + simp only [localTable,Function.comp_apply,decide_eq_true_eq]) + +def table (x : Input) : List Scalar := + if x.2.2.length=0 then localTable 0 x else + if x.2.2.length=1 then localTable 1 x else + if x.2.2.length=2 then localTable 2 x else + if x.2.2.length=3 then localTable 3 x else + if x.2.2.length=4 then localTable 4 x else + if x.2.2.length=5 then localTable 5 x else localTable 6 x + +noncomputable opaque tableProgram : Procedure inputCode matrixCode table := by + let count := Procedure.unaryToBits.comp + ((ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength Nat.bits 0).comp labelsProgram) + let test (n : ℕ) := Procedure.binaryEq.comp + (count.pair (Procedure.constant inputCode Nat.bits n)) + exact (Procedure.conditional (test 0) (localTableProgram 0) + (Procedure.conditional (test 1) (localTableProgram 1) + (Procedure.conditional (test 2) (localTableProgram 2) + (Procedure.conditional (test 3) (localTableProgram 3) + (Procedure.conditional (test 4) (localTableProgram 4) + (Procedure.conditional (test 5) (localTableProgram 5) (localTableProgram 6))))))).congrFun + (by intro x; simp only [table,Function.comp_apply,id_eq,decide_eq_true_eq]) + +theorem table_eq (x : Input) (h : x.2.2.length≤6) : table x=localTable x.2.2.length x := by + generalize hn : x.2.2.length=n at * + interval_cases n <;> simp only [table,hn] <;> norm_num + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode matrixCode table := + tableProgram.toTM2 + +end ContinuumCoulomb.QuantumHistoryTableProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocal.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e03283e3702403883323e879a5ad677140bfd3f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocal.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistorySampling +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedTwoStage + +namespace OAI + +/-! The actual circuit-history Hamiltonian is sent to an explicitly +specified rational three-local even-Y family. Sampling and the two +subdivision stages each have their own inverse-precision error bound. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open scoped Classical + +def historySites (c : QMACircuit) (hT : 0 < c.gates.length) + (p : OrderedPauliTerm c hT) : List ((qmaOrderedHistoryModel c hT).Q) := + QuantumOrderedSupport.sites c hT p.val.1 + +theorem historySites_nodup (c : QMACircuit) (hT : 0 < c.gates.length) + (p : OrderedPauliTerm c hT) : (historySites c hT p).Nodup := + QuantumOrderedSupport.sites_nodup c hT p.val.1 + +theorem historySites_length (c : QMACircuit) (hT : 0 < c.gates.length) + (p : OrderedPauliTerm c hT) : (historySites c hT p).length ≤ 6 := + QuantumOrderedSupport.sites_length c hT p.val.1 + +theorem historySites_cover (c : QMACircuit) (hT : 0 < c.gates.length) + (p : OrderedPauliTerm c hT) : + qmaPauliSupport (orderedWord c hT p) ⊆ (historySites c hT p).toFinset := by + have hsites : (historySites c hT p).toFinset = + (qmaOrderedHistoryModel c hT).sites p.val.1 := + QuantumOrderedSupport.sites_finset c hT p.val.1 + have hsub : (qmaOrderedHistoryModel c hT).sites p.val.1 ⊆ + (historySites c hT p).toFinset := le_of_eq hsites.symm + exact (qmaPauliExtend_support _ _).trans hsub + +abbrev ThreeLocalTerm (c : QMACircuit) (hT : 0 < c.gates.length) := + (OrderedPauliTerm c hT × Fin 4) × Fin 4 + +abbrev ThreeLocalQubit (c : QMACircuit) (hT : 0 < c.gates.length) := + ((qmaOrderedHistoryModel c hT).Q ⊕ OrderedPauliTerm c hT) ⊕ (OrderedPauliTerm c hT × Fin 4) + +def threeLocalWord (c : QMACircuit) (hT : 0 < c.gates.length) : + ThreeLocalTerm c hT → ThreeLocalQubit c hT → Fin 4 := + QuantumOrderedTwoStage.word (ι := (qmaOrderedHistoryModel c hT).Q) + (κ := OrderedPauliTerm c hT) (historySites c hT) (orderedWord c hT) + +def threeLocalSites (c : QMACircuit) (hT : 0 < c.gates.length) : + ThreeLocalTerm c hT → List (ThreeLocalQubit c hT) := + QuantumOrderedTwoStage.sites (historySites c hT) + +def threeLocalCoefficient (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : + ThreeLocalTerm c hT → ℚ := + QuantumOrderedTwoStage.coefficient + (sampledOrderedWeight (samplePrecision c N) c hT) N + +def threeLocalEnergy (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : ℝ := + MediatorGraph.normalizedBottom (qmaPauliFamily (threeLocalWord c hT) + (fun p => (threeLocalCoefficient c hT N p:ℝ))) + +def sampledHistoryEnergy (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : ℝ := + MediatorGraph.normalizedBottom (qmaPauliFamily (orderedWord c hT) + (fun p => (sampledOrderedWeight (samplePrecision c N) c hT p:ℝ))) + +theorem threeLocal_support (c : QMACircuit) (hT : 0 < c.gates.length) + (p : (OrderedPauliTerm c hT × Fin 4) × Fin 4) : + (qmaPauliSupport (threeLocalWord c hT p)).card ≤ 3 := + QuantumOrderedTwoStage.support _ (historySites_length c hT) _ p + +theorem threeLocal_even (c : QMACircuit) (hT : 0 < c.gates.length) + (p : (OrderedPauliTerm c hT × Fin 4) × Fin 4) : + Even (qmaPauliYCount (threeLocalWord c hT p)) := + QuantumOrderedTwoStage.even _ _ (historySites_nodup c hT) + (historySites_cover c hT) (orderedWord_even c hT) p + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocalEnergy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb873c496e025f4fcd3bab97c76854589c1940e6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryThreeLocalEnergy.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryThreeLocal + +namespace OAI + +/-! Full-space energy comparison for the literal three-local history family. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open scoped Classical + +private theorem familyBottom_instances {ι κ : Type} + (F G : Fintype ι) (d e : DecidableEq ι) (P Q : Fintype κ) + (w : κ → ι → Fin 4) (J : κ → ℝ) : + (letI := F; letI := d; letI := P; + MediatorGraph.normalizedBottom (qmaPauliFamily w J)) = + (letI := G; letI := e; letI := Q; + MediatorGraph.normalizedBottom (qmaPauliFamily w J)) := by + cases Subsingleton.elim F G + cases Subsingleton.elim d e + cases Subsingleton.elim P Q + rfl + +private theorem normalizedBottom_instances {α : Type} + (F G : Fintype α) (d e : DecidableEq α) (H : Matrix α α ℂ) : + @MediatorGraph.normalizedBottom α F d H = + @MediatorGraph.normalizedBottom α G e H := by + cases Subsingleton.elim F G + cases Subsingleton.elim d e + rfl + +private theorem bottomError_instances {α : Type} + (F G : Fintype α) (d e : DecidableEq α) (H : Matrix α α ℂ) (E r : ℝ) + (h : |@MediatorGraph.normalizedBottom α F d H-E| ≤ r) : + |@MediatorGraph.normalizedBottom α G e H-E| ≤ r := by + rw [normalizedBottom_instances G F e d H] + exact h + +private theorem threeLocal_energy_eq (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) : threeLocalEnergy c hT N = + MediatorGraph.normalizedBottom (qmaPauliFamily + (QuantumOrderedTwoStage.word (historySites c hT) (orderedWord c hT)) + (fun p => (QuantumOrderedTwoStage.coefficient + (sampledOrderedWeight (samplePrecision c N) c hT) N p:ℝ))) := by + unfold threeLocalEnergy threeLocalWord threeLocalCoefficient + exact familyBottom_instances _ _ _ _ _ _ _ _ + +private theorem sampledHistory_energy_eq (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) : sampledHistoryEnergy c hT N = + MediatorGraph.normalizedBottom (qmaPauliFamily (orderedWord c hT) + (fun p => (sampledOrderedWeight (samplePrecision c N) c hT p:ℝ))) := by + unfold sampledHistoryEnergy + exact familyBottom_instances _ _ _ _ _ _ _ _ + +private theorem history_twoStage_error (c : QMACircuit) (hT : 0 < c.gates.length) + (J : OrderedPauliTerm c hT → ℚ) (N : ℕ) (hN : 1 ≤ N) : + |MediatorGraph.normalizedBottom (qmaPauliFamily + (QuantumOrderedTwoStage.word (historySites c hT) (orderedWord c hT)) + (fun p => (QuantumOrderedTwoStage.coefficient J N p:ℝ)))- + MediatorGraph.normalizedBottom (qmaPauliFamily (orderedWord c hT) + (fun p => (J p:ℝ)))| ≤ 2/(N:ℝ) := by + have h := QuantumOrderedTwoStage.accuracy + (ι := (qmaOrderedHistoryModel c hT).Q) (κ := OrderedPauliTerm c hT) + (historySites c hT) (orderedWord c hT) + J (historySites_nodup c hT) (historySites_cover c hT) N hN + exact bottomError_instances _ _ _ _ _ _ _ h + +theorem threeLocal_sampled_error (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) : + |threeLocalEnergy c hT N-sampledHistoryEnergy c hT N| ≤ 2/(N:ℝ) := by + rw [threeLocal_energy_eq,sampledHistory_energy_eq] + exact history_twoStage_error c hT + (sampledOrderedWeight (samplePrecision c N) c hT) N (by omega) + +theorem sampledHistory_error (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) : + |sampledHistoryEnergy c hT N-(qmaOrderedHistoryModel c hT).energy| ≤ 1/(N:ℝ) := + sampledOrdered_accuracy c hT N hN + +theorem threeLocal_accuracy (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) : + |threeLocalEnergy c hT N-(qmaOrderedHistoryModel c hT).energy| ≤ 3/(N:ℝ) := by + exact (abs_sub_le (threeLocalEnergy c hT N) (sampledHistoryEnergy c hT N) + (qmaOrderedHistoryModel c hT).energy).trans + ((add_le_add (threeLocal_sampled_error c hT N hN) + (sampledHistory_error c hT N hN)).trans_eq (by ring)) + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryWitness.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8bd3ec6d5a3387cf280b16d343845836b5970ee --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryWitness.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryEnergy + +namespace OAI + +/-! Explicit accepting histories and their exact mass and energy. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators + +def qmaIdealHistory (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) + (t : ℕ) : EuclideanSpace ℂ (SourceSpinBasis (c.work+1)) := + qmaApplyMatrix (qmaPrefixMatrix c t) (qmaInputVector c hc psi) + +theorem qmaIdealHistory_mass (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaHistoryMass c (qmaIdealHistory c hc psi) = (c.gates.length+1:ℝ)*‖psi‖^2 := by + simp [qmaHistoryMass,qmaIdealHistory, + qmaApplyMatrix_norm _ (qmaPrefixMatrix_gram c hc _),qmaInputVector_norm] + +theorem qmaIdealHistory_propagation (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaPropagationEnergy c (qmaIdealHistory c hc psi) = 0 := by + apply Finset.sum_eq_zero + intro t ht + simp only [qmaIdealHistory,qmaPrefixMatrix_succ c t (Finset.mem_range.mp ht), + qmaApplyMatrix_mul,sub_self,norm_zero,zero_pow (by decide : 2 ≠ 0)] + +theorem qmaIdealHistory_input (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaInputPenalty c (qmaIdealHistory c hc psi) = 0 := by + have he : qmaMask (fun s => ¬QMAAncillaZero c s) (qmaInputVector c hc psi) = 0 := by + classical + ext s + by_cases hs : QMAAncillaZero c s + · simp [hs] + · have hs' : ¬∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 := hs + simp [hs,qmaInputVector,qmaInitialState,hs'] + simp only [qmaInputPenalty,qmaIdealHistory,qmaPrefixMatrix_zero,qmaApplyMatrix_one, + he,norm_zero,zero_pow (by decide : 2 ≠ 0)] + +theorem qmaIdealHistory_energy (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaHistoryEnergy c (qmaIdealHistory c hc psi) = ‖qmaRejectVector c hc psi‖^2 := by + rw [qmaHistoryEnergy,qmaIdealHistory_input,qmaIdealHistory_propagation] + simp only [mul_zero,add_zero,qmaOutputPenalty,qmaIdealHistory,qmaPrefixMatrix_length, + qmaRejectVector,qmaOutputVector] + +theorem qma_history_accepting_witness (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + ∃ u : ℕ → EuclideanSpace ℂ (SourceSpinBasis (c.work+1)), + 0 < qmaHistoryMass c u ∧ + 3*(c.gates.length+1:ℝ)*qmaHistoryEnergy c u ≤ qmaHistoryMass c u := by + refine ⟨qmaIdealHistory c hc psi,?_,?_⟩ + · rw [qmaIdealHistory_mass,hpsi] + positivity + · rw [qmaIdealHistory_mass,qmaIdealHistory_energy,hpsi] + have h := mul_le_mul_of_nonneg_left (qmaRejectVector_of_accept c hc psi hpsi hacc) + (by positivity : 0 ≤ 3*(c.gates.length+1:ℝ)) + nlinarith + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZ.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZ.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5b338ff6ad9ab9e511c546867958c5856646897 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZ.lean @@ -0,0 +1,92 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryThreeLocalEnergy +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedXZEnergy + +namespace OAI + +/-! The literal X/Z family attached to the actual ordered verifier history, +including the scalar-sampling error and polynomial counts. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open scoped Classical + +abbrev XZTerm (c : QMACircuit) (hT : 0 < c.gates.length) := + QuantumOrderedXZ.OutputTerm (OrderedPauliTerm c hT) + +abbrev XZQubit (c : QMACircuit) (hT : 0 < c.gates.length) := + QuantumOrderedXZ.OutputQubit (qmaOrderedHistoryModel c hT).Q (OrderedPauliTerm c hT) + +def xzWord (c : QMACircuit) (hT : 0 < c.gates.length) : + XZTerm c hT → XZQubit c hT → Fin 4 := + QuantumOrderedXZ.word (historySites c hT) (orderedWord c hT) + +def xzSites (c : QMACircuit) (hT : 0 < c.gates.length) : + XZTerm c hT → List (XZQubit c hT) := + QuantumOrderedXZ.sites (historySites c hT) (orderedWord c hT) + +def xzCoefficient (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : XZTerm c hT → ℚ := + QuantumOrderedXZ.coefficient (sampledOrderedWeight (samplePrecision c N) c hT) N + +def xzEnergy (c : QMACircuit) (hT : 0 < c.gates.length) (N : ℕ) : ℝ := + QuantumOrderedXZ.energy (historySites c hT) (orderedWord c hT) + (sampledOrderedWeight (samplePrecision c N) c hT) N + +theorem xz_sites_nodup (c : QMACircuit) (hT : 0 < c.gates.length) (p : XZTerm c hT) : + (xzSites c hT p).Nodup := + QuantumOrderedXZ.sites_nodup _ _ (historySites_length c hT) (historySites_nodup c hT) p + +theorem xz_sites_length (c : QMACircuit) (hT : 0 < c.gates.length) (p : XZTerm c hT) : + (xzSites c hT p).length ≤ 2 := + QuantumOrderedXZ.sites_length _ _ (historySites_length c hT) p + +theorem xz_sites_cover (c : QMACircuit) (hT : 0 < c.gates.length) (p : XZTerm c hT) : + qmaPauliSupport (xzWord c hT p) ⊆ (xzSites c hT p).toFinset := by + intro i hi + have h := QuantumOrderedXZ.sites_cover (historySites c hT) (orderedWord c hT) p hi + have hm : i ∈ xzSites c hT p := by + simpa only [xzSites,List.mem_toFinset] using h + exact List.mem_toFinset.mpr hm + +theorem xz_noY (c : QMACircuit) (hT : 0 < c.gates.length) (p : XZTerm c hT) + (i : XZQubit c hT) : xzWord c hT p i ≠ 2 := + QuantumOrderedXZ.noY _ _ (historySites_length c hT) (historySites_nodup c hT) + (historySites_cover c hT) (orderedWord_even c hT) p i + +theorem xz_support (c : QMACircuit) (hT : 0 < c.gates.length) (p : XZTerm c hT) : + (qmaPauliSupport (xzWord c hT p)).card ≤ 2 := + QuantumOrderedXZ.support _ _ (historySites_length c hT) p + +theorem xz_sampled_error (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) : |xzEnergy c hT N-sampledHistoryEnergy c hT N| ≤ 5/(N:ℝ) := by + unfold xzEnergy sampledHistoryEnergy + exact QuantumOrderedXZ.accuracy _ _ _ (historySites_length c hT) + (historySites_nodup c hT) (historySites_cover c hT) (orderedWord_even c hT) N (by omega) + +theorem xz_accuracy (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (hN : 0 < N) : + |xzEnergy c hT N-(qmaOrderedHistoryModel c hT).energy| ≤ 6/(N:ℝ) := by + exact (abs_sub_le (xzEnergy c hT N) (sampledHistoryEnergy c hT N) + (qmaOrderedHistoryModel c hT).energy).trans + ((add_le_add (xz_sampled_error c hT N hN) + (sampledHistory_error c hT N hN)).trans_eq (by ring)) + +theorem xz_term_count (c : QMACircuit) (hT : 0 < c.gates.length) : + Fintype.card (XZTerm c hT) ≤ 3136*4096*(4*c.gates.length+2*c.work+9) := by + rw [QuantumOrderedXZ.term_count] + exact (Nat.mul_le_mul_left 3136 (orderedWord_count c hT)).trans_eq (by ring) + +theorem xz_qubit_count (c : QMACircuit) (hT : 0 < c.gates.length) : + Fintype.card (XZQubit c hT) ≤ 3*c.gates.length+2*c.work+8+ + 581*4096*(4*c.gates.length+2*c.work+9) := by + rw [QuantumOrderedXZ.qubit_count] + have hq : Fintype.card (qmaOrderedHistoryModel c hT).Q = + 3*c.gates.length+2*c.work+8 := (qmaOrderedHistoryModel_size c hT).1 + rw [hq] + exact Nat.add_le_add_left + ((Nat.mul_le_mul_left 581 (orderedWord_count c hT)).trans_eq (by ring)) _ + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..25856b4f2806c3b4de74a96901d79a345782f9fc --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZBounds.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryXZ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumOrderedWeightBounds + +namespace OAI + +/-! Coefficient control for the actual sampled verifier history throughout +the five fixed gadget stages. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory +open QuantumAlgebraicScalar +open scoped Classical + +private theorem halfRoot_bounds (k : ℕ) : + 0 ≤ RationalSquareRoot.value (k,1/2) ∧ RationalSquareRoot.value (k,1/2) ≤ 1 := by + have hv : RationalSquareRoot.value (k,(1/2:ℚ)) = DyadicRootProgram.value k 1 2 := by + norm_num [RationalSquareRoot.value] + rw [hv] + constructor + · unfold DyadicRootProgram.value + positivity + · have h := (DyadicRootProgram.value_error k 1 2 (by omega)).1 + have hs : Real.sqrt ((1:ℝ)/2) ≤ 1 := (Real.sqrt_le_iff).mpr (by norm_num) + have ht : (DyadicRootProgram.value k 1 2:ℝ) ≤ 1 := by + norm_num only [Nat.cast_one,Nat.cast_ofNat] at h + linarith + exact_mod_cast ht + +theorem sample_height_bound (k : ℕ) (x : RealScalar) : |sample k x| ≤ realHeight x := by + have h := halfRoot_bounds k + calc + _ ≤ |x.1|+|x.2*RationalSquareRoot.value (k,1/2)| := abs_add_le _ _ + _ = |x.1|+|x.2| * RationalSquareRoot.value (k,1/2) := by + rw [abs_mul,abs_of_nonneg h.1] + _ ≤ |x.1|+|x.2| * 1 := add_le_add le_rfl + (mul_le_mul_of_nonneg_left h.2 (abs_nonneg _)) + _ = realHeight x := by simp only [realHeight,mul_one] + +theorem sampledOrdered_weight_bound (c : QMACircuit) (hT : 0 < c.gates.length) + (k : ℕ) (p : OrderedPauliTerm c hT) : + |sampledOrderedWeight k c hT p| ≤ (coefficientBudget c:ℚ) := by + apply (sample_height_bound k (orderedRealCoefficient c hT p)).trans + rw [coefficientBudget_cast] + exact orderedCoefficient_height c hT p.val.1 p.val.2 + +def xzCoefficientBound (c : QMACircuit) (N : ℕ) : ℚ := + QuantumOrderedXZ.pipelineBound (termBudget c) (coefficientBudget c) N 5 + +theorem xzCoefficient_bound (c : QMACircuit) (hT : 0 < c.gates.length) + (N : ℕ) (p : XZTerm c hT) : |xzCoefficient c hT N p| ≤ xzCoefficientBound c N := by + apply QuantumOrderedXZ.pipeline_coefficient_bound + (sampledOrderedWeight (samplePrecision c N) c hT) + (show (0:ℚ) ≤ coefficientBudget c from Nat.cast_nonneg _) + (show Fintype.card (OrderedPauliTerm c hT) ≤ termBudget c from orderedWord_count c hT) + (sampledOrdered_weight_bound c hT (samplePrecision c N)) N p + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZPromise.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZPromise.lean new file mode 100644 index 0000000000000000000000000000000000000000..c015099b39b605ce2fe9dab57cb30cb5a223adea --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumHistoryXZPromise.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumHistoryXZ + +namespace OAI + +/-! Explicit inverse-polynomial thresholds for the actual two-local X/Z +history output. The precision is a fixed linear unary function of clock length. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumAlgebraicHistory + +def xzPrecision (c : QMACircuit) : ℕ := 360*(c.gates.length+1) +def xzYesThreshold (c : QMACircuit) : ℚ := 7/(20*(c.gates.length+1:ℚ)) +def xzNoThreshold (c : QMACircuit) : ℚ := 23/(60*(c.gates.length+1:ℚ)) + +theorem xzPrecision_positive (c : QMACircuit) : 0 < xzPrecision c := by + unfold xzPrecision + omega + +theorem xz_threshold_gap (c : QMACircuit) : + xzNoThreshold c-xzYesThreshold c = 1/(30*(c.gates.length+1:ℚ)) := by + have ht : (c.gates.length+1:ℚ) ≠ 0 := by positivity + unfold xzNoThreshold xzYesThreshold + field_simp + ring + +theorem xz_threshold_lt (c : QMACircuit) : xzYesThreshold c < xzNoThreshold c := by + have h := xz_threshold_gap c + have hp : (0:ℚ) < 1/(30*(c.gates.length+1:ℚ)) := by positivity + linarith + +private theorem yes_budget (c : QMACircuit) : + 1/(3*(c.gates.length+1:ℝ))+6/(xzPrecision c:ℝ) = (xzYesThreshold c:ℝ) := by + have ht : (c.gates.length+1:ℝ) ≠ 0 := by positivity + simp only [xzPrecision,xzYesThreshold,Nat.cast_mul,Nat.cast_add,Nat.cast_one, + Nat.cast_ofNat,Rat.cast_div,Rat.cast_mul,Rat.cast_add,Rat.cast_natCast, + Rat.cast_one,Rat.cast_ofNat] + field_simp + ring + +private theorem no_budget (c : QMACircuit) : + 2/(5*(c.gates.length+1:ℝ))-6/(xzPrecision c:ℝ) = (xzNoThreshold c:ℝ) := by + have ht : (c.gates.length+1:ℝ) ≠ 0 := by positivity + simp only [xzPrecision,xzNoThreshold,Nat.cast_mul,Nat.cast_add,Nat.cast_one, + Nat.cast_ofNat,Rat.cast_div,Rat.cast_mul,Rat.cast_add,Rat.cast_natCast, + Rat.cast_one,Rat.cast_ofNat] + field_simp + ring + +theorem xz_accepting (c : QMACircuit) (hT : 0 < c.gates.length) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) (hpsi : ‖psi‖ = 1) + (hacc : 2/3 ≤ qmaAcceptance c hc psi) : + xzEnergy c hT (xzPrecision c) ≤ (xzYesThreshold c:ℝ) := by + have he := (abs_le.mp (xz_accuracy c hT _ (xzPrecision_positive c))).2 + have hh := qmaOrderedHistoryModel_yes c hT hc psi hpsi hacc + rw [← yes_budget] + linarith + +theorem xz_rejecting (c : QMACircuit) (hT : 0 < c.gates.length) (hc : c.WellFormed) + (hsound : ∀ psi : EuclideanSpace ℂ (SourceSpinBasis c.witness), + ‖psi‖ = 1 → qmaAcceptance c hc psi ≤ 1/3) : + (xzNoThreshold c:ℝ) ≤ xzEnergy c hT (xzPrecision c) := by + have he := (abs_le.mp (xz_accuracy c hT _ (xzPrecision_positive c))).1 + have hh := qmaOrderedHistoryModel_no c hT hc hsound + rw [← no_budget] + linarith + +end ContinuumCoulomb.QuantumAlgebraicHistory + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedListProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedListProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4cbaf1bd54e92bf0670b6915d7a71adf0852b53 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedListProgram.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteLeafProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInflatedPath +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumForkGridProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRoutePieces + +namespace OAI + +/-! The eightfold scaled route is an explicit list computation. Its loop +bound is eight times the input route length. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumInflatedListProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode + +abbrev Input := ℕ × List Pair +def inputCode : Input → List Bool := prodCode Nat.bits (listCode pairCode) +def point (x : Input) : Pair := qmaInflatedPoint (QuantumForkGridProgram.lookup x.2) x.1 +def value (xs : List Pair) : List Pair := + (List.range (8*(xs.length-1)+1)).map (fun k => point (k,xs)) + +noncomputable opaque pointProgram : Procedure inputCode pairCode point := by + let k := Procedure.first Nat.bits (listCode pairCode) + let xs := Procedure.second Nat.bits (listCode pairCode) + let eight := Procedure.constant inputCode Nat.bits 8 + let index := Procedure.binaryDiv.comp (k.pair eight) + let indexNext := Procedure.successor.comp index + let get := Procedure.listGet pairCode (0,0) + let p := QuantumRouteLeafCode.centerProgram.comp (get.comp (index.pair xs)) + let q := QuantumRouteLeafCode.centerProgram.comp (get.comp (indexNext.pair xs)) + let rest := Procedure.binaryMod.comp (k.pair eight) + exact QuantumRouteCode.pointProgram.comp ((p.pair q).pair rest) + +noncomputable opaque lengthProgram : Procedure (listCode pairCode) unaryCode + (fun xs => 8*(xs.length-1)+1) := + Procedure.unarySuccessor.comp (Procedure.unaryMul.comp + ((Procedure.constant (listCode pairCode) unaryCode 8).pair + (Procedure.unaryPred.comp + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength pairCode (0,0))))) + +noncomputable opaque indexedProgram : Procedure (prodCode unaryCode (listCode pairCode)) + pairCode (fun x => point (x.1,x.2)) := + pointProgram.comp + ((Procedure.unaryToBits.comp (Procedure.first unaryCode (listCode pairCode))).pair + (Procedure.second unaryCode (listCode pairCode))) + +noncomputable opaque tabProgram : Procedure (prodCode unaryCode (listCode pairCode)) + (listCode pairCode) (fun x => (List.range x.1).map (fun k => point (k,x.2))) := + Procedure.tabulate (f := fun xs k => point (k,xs)) (0,0) indexedProgram + +noncomputable opaque program : Procedure (listCode pairCode) (listCode pairCode) value := + (tabProgram.comp (lengthProgram.pair (Procedure.identity (listCode pairCode)))).congrFun + (by intro xs; rfl) + +theorem length_value (xs : List Pair) : (value xs).length=8*(xs.length-1)+1 := by + simp only [value,List.length_map,List.length_range] + +theorem get_value (xs : List Pair) (k : ℕ) (hk : k < 8*(xs.length-1)+1) : + (value xs)[k]'(by simpa only [length_value] using hk)= + qmaInflatedPoint (QuantumForkGridProgram.lookup xs) k := by + simp only [value,List.getElem_map,List.getElem_range,point] + +theorem lookup_range (p : ℕ → Pair) (n k : ℕ) (hk : k simp only [qmaLeafCenter] at hx hy <;> omega + +theorem qmaInflatedPoint_step (p : ℕ → ℕ × ℕ) {L : ℕ} + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) {k : ℕ} (hk : k < 8*L) : + qmaSquareGrid.Adj (qmaInflatedPoint p k) (qmaInflatedPoint p (k+1)) := by + have hdiv : k/8 < L := by omega + have hlen := qmaLeafCenter_adj_length (hp _ hdiv) + have hm : k%8 < 8 := Nat.mod_lt _ (by decide) + by_cases h7 : k%8 = 7 + · have hq : (k+1)/8 = k/8+1 := by omega + have hr : (k+1)%8 = 0 := by omega + have hs := qmaManhattanPoint_adj (qmaLeafCenter (p (k/8))) + (qmaLeafCenter (p (k/8+1))) 7 (by omega) + have he := qmaManhattanPoint_last (qmaLeafCenter (p (k/8))) (qmaLeafCenter (p (k/8+1))) + rw [hlen] at he + change qmaSquareGrid.Adj + (qmaManhattanPoint (qmaLeafCenter (p (k/8))) (qmaLeafCenter (p (k/8+1))) 7) + (qmaManhattanPoint (qmaLeafCenter (p (k/8))) (qmaLeafCenter (p (k/8+1))) 8) at hs + rw [he] at hs + simpa only [qmaInflatedPoint,h7,hq,hr,qmaManhattanPoint_zero] using hs + · have hq : (k+1)/8 = k/8 := by omega + have hr : (k+1)%8 = k%8+1 := by omega + simpa only [qmaInflatedPoint,hq,hr] using + qmaManhattanPoint_adj (qmaLeafCenter (p (k/8))) + (qmaLeafCenter (p (k/8+1))) (k%8) (by omega) + +theorem qmaInflatedPoint_gridline (p : ℕ → ℕ × ℕ) {L : ℕ} + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) {k : ℕ} (hk : k ≤ 8*L) : + (qmaInflatedPoint p k).1%8 = 4 ∨ (qmaInflatedPoint p k).2%8 = 4 := by + by_cases h0 : k%8 = 0 + · rw [qmaInflatedPoint_boundary p h0] + left + simp [qmaLeafCenter,Nat.add_mod] + · have hdiv : k/8 < L := by omega + have hlen := qmaLeafCenter_adj_length (hp _ hdiv) + exact qmaLeafCenter_point_gridline _ _ _ (by omega) + +theorem qmaInflatedPoint_not_center (p : ℕ → ℕ × ℕ) {L : ℕ} + (hpos : ∀ i ≤ L, 0 < (p i).1 ∧ 0 < (p i).2) + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) {k : ℕ} + (hk : k ≤ 8*L) (h0 : k%8 ≠ 0) (r : ℕ × ℕ) : + qmaInflatedPoint p k ≠ qmaLeafCenter r := by + have hdiv : k/8 < L := by omega + obtain ⟨a,ha⟩ := qmaGridNeighbor_exists (hp _ hdiv) + change qmaManhattanPoint (qmaLeafCenter (p (k/8))) (qmaLeafCenter (p (k/8+1))) (k%8) ≠ _ + rw [← ha,qmaScaledDirectionPoint_eq _ (hpos _ hdiv.le).1 (hpos _ hdiv.le).2 a + (Nat.le_of_lt (Nat.mod_lt _ (by decide)))] + exact qmaScaledDirectionPoint_not_center _ r a + (by omega) (Nat.mod_lt _ (by decide)) + +theorem qmaInflatedPoint_injective (p : ℕ → ℕ × ℕ) {L : ℕ} + (hpos : ∀ i ≤ L, 0 < (p i).1 ∧ 0 < (p i).2) + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) + (hs : ∀ i j, i ≤ L → j ≤ L → p i = p j → i = j) + {i j : ℕ} (hi : i ≤ 8*L) (hj : j ≤ 8*L) + (h : qmaInflatedPoint p i = qmaInflatedPoint p j) : i = j := by + by_cases hi0 : i%8 = 0 + · rw [qmaInflatedPoint_boundary p hi0] at h + by_cases hj0 : j%8 = 0 + · rw [qmaInflatedPoint_boundary p hj0] at h + have he := hs (i/8) (j/8) (by omega) (by omega) (qmaLeafCenter_injective h) + omega + · exact (qmaInflatedPoint_not_center p hpos hp hj hj0 _ h.symm).elim + · by_cases hj0 : j%8 = 0 + · rw [qmaInflatedPoint_boundary p hj0] at h + exact (qmaInflatedPoint_not_center p hpos hp hi hi0 _ h).elim + have hid : i/8 < L := by omega + have hjd : j/8 < L := by omega + have hip : 0 < i%8 := by omega + have hjp : 0 < j%8 := by omega + have hi8 := Nat.mod_lt i (by decide : 0 < 8) + have hj8 := Nat.mod_lt j (by decide : 0 < 8) + have hc := qmaScaledEdge_inner_collision (hpos _ hid.le) (hpos _ hjd.le) + (hp _ hid) (hp _ hjd) hip hi8 hjp hj8 h + rcases hc with ⟨ha,_⟩ | ⟨ha,hb⟩ + · have hd := hs (i/8) (j/8) hid.le hjd.le ha + have hlen := qmaLeafCenter_adj_length (hp (i/8) hid) + change qmaManhattanPoint (qmaLeafCenter (p (i/8))) (qmaLeafCenter (p (i/8+1))) (i%8) = + qmaManhattanPoint (qmaLeafCenter (p (j/8))) (qmaLeafCenter (p (j/8+1))) (j%8) at h + rw [← hd] at h + have hm1 := qmaManhattanPoint_distance (qmaLeafCenter (p (i/8))) + (qmaLeafCenter (p (i/8+1))) (i%8) (by omega) + have hm2 := qmaManhattanPoint_distance (qmaLeafCenter (p (i/8))) + (qmaLeafCenter (p (i/8+1))) (j%8) (by omega) + rw [h] at hm1 + omega + · have hd1 := hs (i/8) (j/8+1) hid.le (by omega) ha + have hd2 := hs (i/8+1) (j/8) (by omega) hjd.le hb + omega + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..73b179556bc4aa6bd91d83e1eb71effee8a87069 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInflatedSeparation.lean @@ -0,0 +1,49 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumInflatedPath + +namespace OAI + +/-! Inflating a planar route family preserves its disjoint interiors. -/ + +namespace ContinuumCoulomb + +theorem qmaInflatedPoint_avoids_vertex (p : ℕ → ℕ × ℕ) {L : ℕ} + (hpos : ∀ i ≤ L, 0 < (p i).1 ∧ 0 < (p i).2) + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) (v : ℕ × ℕ) + (hv : ∀ i, 0 < i → i < L → p i ≠ v) {k : ℕ} (hk0 : 0 < k) (hk : k < 8*L) : + qmaInflatedPoint p k ≠ qmaLeafCenter v := by + by_cases h0 : k%8 = 0 + · rw [qmaInflatedPoint_boundary p h0] + intro h + exact hv (k/8) (by omega) (by omega) (qmaLeafCenter_injective h) + · exact qmaInflatedPoint_not_center p hpos hp hk.le h0 v + +theorem qmaInflatedPoint_disjoint (p q : ℕ → ℕ × ℕ) {L M : ℕ} + (hp0 : ∀ i ≤ L, 0 < (p i).1 ∧ 0 < (p i).2) + (hq0 : ∀ j ≤ M, 0 < (q j).1 ∧ 0 < (q j).2) + (hp : ∀ i < L, qmaSquareGrid.Adj (p i) (p (i+1))) + (hq : ∀ j < M, qmaSquareGrid.Adj (q j) (q (j+1))) + (hd : ∀ i j, 0 < i → i < L → j ≤ M → p i ≠ q j) + (he : ∀ i j, i < L → j < M → + ¬(p i = q j ∧ p (i+1) = q (j+1)) ∧ ¬(p i = q (j+1) ∧ p (i+1) = q j)) + {i j : ℕ} (hi0 : 0 < i) (hi : i < 8*L) (hj : j ≤ 8*M) : + qmaInflatedPoint p i ≠ qmaInflatedPoint q j := by + intro h + by_cases hiz : i%8 = 0 + · rw [qmaInflatedPoint_boundary p hiz] at h + by_cases hjz : j%8 = 0 + · rw [qmaInflatedPoint_boundary q hjz] at h + exact hd (i/8) (j/8) (by omega) (by omega) (by omega) (qmaLeafCenter_injective h) + · exact qmaInflatedPoint_not_center q hq0 hq hj hjz _ h.symm + · by_cases hjz : j%8 = 0 + · rw [qmaInflatedPoint_boundary q hjz] at h + exact qmaInflatedPoint_not_center p hp0 hp hi.le hiz _ h + have hid : i/8 < L := by omega + have hjd : j/8 < M := by omega + have hc := qmaScaledEdge_inner_collision (hp0 _ hid.le) (hq0 _ hjd.le) + (hp _ hid) (hq _ hjd) (by omega : 0 < i%8) (Nat.mod_lt _ (by decide)) + (by omega : 0 < j%8) (Nat.mod_lt _ (by decide)) h + exact hc.elim (he _ _ hid hjd).1 (he _ _ hid hjd).2 + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInnerPorts.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInnerPorts.lean new file mode 100644 index 0000000000000000000000000000000000000000..18d7490e40ed5aff3f7b3ce6d14f501e602fa074 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInnerPorts.lean @@ -0,0 +1,107 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridPorts + +namespace OAI + +/-! Moving crossing terminals one unit into their private patch leaves the +external corridors free and creates space for the two mediator spins. -/ + +namespace ContinuumCoulomb + +def qmaInnerPort (p : ℕ × ℕ) (a : Fin 4) : ℕ × ℕ := + ![(32*p.1+22,32*p.2+16),(32*p.1+16,32*p.2+22), + (32*p.1+10,32*p.2+16),(32*p.1+16,32*p.2+10)] a + +def qmaGadgetAncilla (p : ℕ × ℕ) (b : Fin 2) : ℕ × ℕ := + ![(32*p.1+14,32*p.2+18),(32*p.1+18,32*p.2+14)] b + +theorem qmaInnerPort_cell (p : ℕ × ℕ) (a : Fin 4) : + ((qmaInnerPort p a).1/32,(qmaInnerPort p a).2/32) = p := by + apply Prod.ext <;> fin_cases a <;> simp [qmaInnerPort,Nat.add_div] + +theorem qmaGadgetAncilla_cell (p : ℕ × ℕ) (a : Fin 2) : + ((qmaGadgetAncilla p a).1/32,(qmaGadgetAncilla p a).2/32) = p := by + apply Prod.ext <;> fin_cases a <;> simp [qmaGadgetAncilla,Nat.add_div] + +theorem qmaExpandedPoint_cell (p : ℕ × ℕ) : + ((qmaExpandedPoint p).1/32,(qmaExpandedPoint p).2/32) = p := by + apply Prod.ext <;> simp [qmaExpandedPoint,Nat.add_div] + +theorem qmaInnerPort_injective : Function.Injective + (fun x : (ℕ × ℕ) × Fin 4 => qmaInnerPort x.1 x.2) := by + rintro ⟨p,a⟩ ⟨q,b⟩ h + have he := congrArg (fun z : ℕ × ℕ => (z.1/32,z.2/32)) h + simp only [qmaInnerPort_cell] at he + subst q + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + have hab : a = b := by fin_cases a <;> fin_cases b <;> simp [qmaInnerPort] at hx hy ⊢ + subst b + rfl + +theorem qmaGadgetAncilla_injective : Function.Injective + (fun x : (ℕ × ℕ) × Fin 2 => qmaGadgetAncilla x.1 x.2) := by + rintro ⟨p,a⟩ ⟨q,b⟩ h + have he := congrArg (fun z : ℕ × ℕ => (z.1/32,z.2/32)) h + simp only [qmaGadgetAncilla_cell] at he + subst q + have hx := congrArg Prod.fst h + have hab : a = b := by fin_cases a <;> fin_cases b <;> simp [qmaGadgetAncilla] at hx ⊢ + subst b + rfl + +theorem qmaInnerPort_ne_center (p q : ℕ × ℕ) (a : Fin 4) : + qmaInnerPort p a ≠ qmaExpandedPoint q := by + intro h + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + fin_cases a <;> simp [qmaInnerPort,qmaExpandedPoint] at hx hy <;> omega + +theorem qmaInnerPort_ne_port (p q : ℕ × ℕ) (a b : Fin 4) : + qmaInnerPort p a ≠ qmaGridPort q b := by + intro h + have hx := congrArg Prod.fst h + have hy := congrArg Prod.snd h + fin_cases a <;> fin_cases b <;> simp [qmaInnerPort,qmaGridPort] at hx hy <;> omega + +theorem qmaGadgetAncilla_ne_center (p q : ℕ × ℕ) (a : Fin 2) : + qmaGadgetAncilla p a ≠ qmaExpandedPoint q := by + intro h + have hx := congrArg Prod.fst h + fin_cases a <;> simp [qmaGadgetAncilla,qmaExpandedPoint] at hx <;> omega + +theorem qmaGadgetAncilla_ne_port (p q : ℕ × ℕ) (a : Fin 2) (b : Fin 4) : + qmaGadgetAncilla p a ≠ qmaGridPort q b := by + intro h + have hx := congrArg Prod.fst h + fin_cases a <;> fin_cases b <;> simp [qmaGadgetAncilla,qmaGridPort] at hx <;> omega + +theorem qmaGadgetAncilla_ne_inner (p q : ℕ × ℕ) (a : Fin 2) (b : Fin 4) : + qmaGadgetAncilla p a ≠ qmaInnerPort q b := by + intro h + have hx := congrArg Prod.fst h + fin_cases a <;> fin_cases b <;> simp [qmaGadgetAncilla,qmaInnerPort] at hx <;> omega + +def qmaPortIndex (z : ℕ × ℕ) : Fin 4 := + if z.1%32 = 23 then 0 else if z.2%32 = 23 then 1 else if z.1%32 = 9 then 2 else 3 + +theorem qmaPortIndex_spec (p : ℕ × ℕ) (a : Fin 4) : qmaPortIndex (qmaGridPort p a) = a := by + fin_cases a <;> simp [qmaPortIndex,qmaGridPort,Nat.add_mod] + +def qmaCrossingMove (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] (z : ℕ × ℕ) : ℕ × ℕ := + let p := (z.1/32,z.2/32) + if cross p ∧ z ≠ qmaExpandedPoint p then qmaInnerPort p (qmaPortIndex z) else z + +theorem qmaCrossingMove_center (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] (p : ℕ × ℕ) : + qmaCrossingMove cross (qmaExpandedPoint p) = qmaExpandedPoint p := by + simp [qmaCrossingMove,qmaExpandedPoint_cell] + +theorem qmaCrossingMove_port (cross : (ℕ × ℕ) → Prop) [DecidablePred cross] (p : ℕ × ℕ) (a : Fin 4) : + qmaCrossingMove cross (qmaGridPort p a) = if cross p then qmaInnerPort p a else qmaGridPort p a := by + simp only [qmaCrossingMove,qmaGridPort_cell,qmaPortIndex_spec] + by_cases hp : cross p + · rw [ite_eq_left ⟨hp,qmaGridPort_ne_center p p a⟩,ite_eq_left hp] + · rw [ite_eq_right (fun h => hp h.1),ite_eq_right hp] + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInputProjection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInputProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..26e0b0b68799b5970c1e4fb529dccf9e97d7951b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInputProjection.lean @@ -0,0 +1,39 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSoundness + +namespace OAI + +/-! The legal initial subspace is exactly the zero-ancilla witness embedding. -/ + +noncomputable section +namespace ContinuumCoulomb + +def qmaExtractWitness (c : QMACircuit) + (u : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + EuclideanSpace ℂ (SourceSpinBasis c.witness) := + WithLp.toLp 2 (fun s => u (qmaWitnessExtend c s)) + +theorem qmaInputVector_extract (c : QMACircuit) (hc : c.WellFormed) + (u : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + qmaInputVector c hc (qmaExtractWitness c u) = qmaMask (QMAAncillaZero c) u := by + classical + ext s + by_cases hs : QMAAncillaZero c s + · have hs' : ∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 := hs + simp only [qmaInputVector,qmaInitialState,PiLp.toLp_apply,ite_eq_left hs', + qmaExtractWitness,qmaMask_apply,ite_eq_left hs] + change u (qmaWitnessExtend c (qmaWitnessRestrict c hc s)) = u s + rw [qmaWitnessExtend_restrict c hc s hs] + · have hs' : ¬∀ i : Fin (c.work+1), c.witness ≤ i.val → s i = 0 := hs + simp only [qmaInputVector,qmaInitialState,PiLp.toLp_apply,ite_eq_right hs', + qmaMask_apply,ite_eq_right hs] + +theorem qmaExtractWitness_norm (c : QMACircuit) (hc : c.WellFormed) + (u : EuclideanSpace ℂ (SourceSpinBasis (c.work+1))) : + ‖qmaExtractWitness c u‖ = ‖qmaMask (QMAAncillaZero c) u‖ := by + rw [←qmaInputVector_extract c hc u,qmaInputVector_norm] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalHalfSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalHalfSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b58dc24c023cb580bc303c41919e08d5c62d3171 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalHalfSeparation.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumTranslatedInternalSeparation + +namespace OAI + +/-! The two orientations of the internal-path/external-corridor separation. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +theorem internal_half_disjoint (p : ℕ × ℕ) (e : QMAInternalEdge) (a : Fin 4) + (b : Bool) (he : P.RoutingAllowed (qmaInternalBody p e)) (hb : b = decide (P.IsCrossing p)) : + Disjoint (((qmaInternalPath e).drop 1).dropLast).toFinset (qmaHalfCorridorPath b a).toFinset := by + subst b + rcases e with e | (e | e) + · have hn : ¬P.IsCrossing p := he.2 + simpa only [qmaInternalPath,hn,decide_false] using qmaCellRay_half e a + · have hn : ¬P.IsCrossing p := he.1 + simpa only [qmaInternalPath,hn,decide_false] using qmaCellPair_half e a + · have hp : P.IsCrossing p := he + simpa only [qmaInternalPath,hp,decide_true] using qmaLocalPatch_half e a + +theorem half_internal_disjoint (p : ℕ × ℕ) (e : QMAInternalEdge) (a : Fin 4) + (b : Bool) (he : P.RoutingAllowed (qmaInternalBody p e)) (hb : b = decide (P.IsCrossing p)) : + Disjoint ((qmaHalfCorridorPath b a).drop 1).toFinset (qmaInternalPath e).toFinset := by + subst b + rcases e with e | (e | e) + · have hn : ¬P.IsCrossing p := he.2 + simpa only [qmaInternalPath,hn,decide_false] using qmaHalfCorridor_ray a e + · have hn : ¬P.IsCrossing p := he.1 + simpa only [qmaInternalPath,hn,decide_false] using qmaHalfCorridor_pair a e + · have hp : P.IsCrossing p := he + simpa only [qmaInternalPath,hp,decide_true] using qmaHalfCorridor_patch a e + +theorem internal_halfAt_disjoint (p q : ℕ × ℕ) (e : QMAInternalEdge) (a : Fin 4) + (b : Bool) (he : P.RoutingAllowed (qmaInternalBody p e)) (hb : b = decide (P.IsCrossing q)) : + Disjoint ((((qmaInternalBody p e).path).drop 1).dropLast).toFinset + (qmaHalfPathAt q b a).toFinset := by + apply Finset.disjoint_left.mpr + intro z hz hw + have hz' := List.mem_toFinset.mp hz + rw [qmaInternalBody_path,← List.map_drop,← List.map_dropLast] at hz' + obtain ⟨u,hu,heu⟩ := List.mem_map.mp hz' + obtain ⟨v,hv,hev⟩ := List.mem_map.mp (List.mem_toFinset.mp hw) + have hu' := List.mem_of_mem_drop (List.mem_of_mem_dropLast hu) + have hh := qmaCellTranslate_unique (qmaInternalPath_bounded e u hu') + (qmaHalfCorridor_bounded b a v hv) (heu.trans hev.symm) + rcases hh with ⟨rfl,rfl⟩ + exact Finset.disjoint_left.mp (P.internal_half_disjoint p e a b he hb) + (List.mem_toFinset.mpr hu) (List.mem_toFinset.mpr hv) + +theorem halfAt_internal_disjoint (p q : ℕ × ℕ) (a : Fin 4) (b : Bool) (e : QMAInternalEdge) + (he : P.RoutingAllowed (qmaInternalBody q e)) (hb : b = decide (P.IsCrossing p)) : + Disjoint ((qmaHalfPathAt p b a).drop 1).toFinset (qmaInternalBody q e).path.toFinset := by + apply Finset.disjoint_left.mpr + intro z hz hw + have hz' := List.mem_toFinset.mp hz + change z ∈ ((qmaHalfCorridorPath b a).map (qmaCellTranslate p)).drop 1 at hz' + rw [← List.map_drop] at hz' + have hw' := List.mem_toFinset.mp hw + rw [qmaInternalBody_path] at hw' + obtain ⟨u,hu,heu⟩ := List.mem_map.mp hz' + obtain ⟨v,hv,hev⟩ := List.mem_map.mp hw' + have hh := qmaCellTranslate_unique (qmaHalfCorridor_bounded b a u (List.mem_of_mem_drop hu)) + (qmaInternalPath_bounded e v hv) (heu.trans hev.symm) + rcases hh with ⟨rfl,rfl⟩ + exact Finset.disjoint_left.mp (P.half_internal_disjoint p e a b he hb) + (List.mem_toFinset.mpr hu) (List.mem_toFinset.mpr hv) + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalRouteSeparation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalRouteSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a37b5acaee1a2db034b668b8f98f583b4302d8ab --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumInternalRouteSeparation.lean @@ -0,0 +1,102 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRetainedRoutes +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCellVisitPaths +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalPathClearance + +namespace OAI + +/-! Distinct permitted internal routes in a cell have disjoint interiors. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +abbrev QMAInternalEdge := Fin 4 ⊕ (Fin 6 ⊕ Fin 9) + +def qmaInternalPath : QMAInternalEdge → List (ℕ × ℕ) + | .inl a => qmaCellRayPath a + | .inr (.inl e) => qmaCellPairPath e + | .inr (.inr e) => qmaLocalPatchPath e + +def qmaInternalBody (p : ℕ × ℕ) : QMAInternalEdge → QMACellRouteBody + | .inl a => .ray p a + | .inr (.inl e) => .pair p e + | .inr (.inr e) => .patch p e + +theorem qmaCellPair_pair_injective : Function.Injective + (fun e : Fin 6 => s(qmaCellPairLeft e,qmaCellPairRight e)) := by decide + +theorem qmaInternalPath_bounded (e : QMAInternalEdge) : + ∀ p ∈ qmaInternalPath e, p.1 < 32 ∧ p.2 < 32 := by + rcases e with a | (e | e) + · intro p hp + obtain ⟨_,hx,_,hy⟩ := qmaCellRay_bounded a p hp + omega + · intro p hp + obtain ⟨_,hx,_,hy⟩ := qmaCellPair_bounded e p hp + omega + · intro p hp + obtain ⟨_,hx,_,hy⟩ := qmaLocalPatch_bounded e p hp + omega + +theorem qmaInternalBody_path (p : ℕ × ℕ) (e : QMAInternalEdge) : + (qmaInternalBody p e).path = (qmaInternalPath e).map (qmaCellTranslate p) := by + rcases e with a | (e | e) + · rfl + · rfl + · change (qmaCrossingPatchPath e).map (qmaPatchTranslate p) = + ((qmaCrossingPatchPath e).map (fun z => (10+z.1,10+z.2))).map (qmaCellTranslate p) + rw [List.map_map] + apply List.map_congr_left + intro z _ + exact (qmaCellTranslate_patch p z).symm + +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + +theorem routingPair_index {p : ℕ × ℕ} {e : Fin 6} (h : P.RoutingAllowed (.pair p e)) : + ∃ i : P.Interior, P.cell i = p ∧ e = P.cellPairIndex i := by + obtain ⟨_,i,hi,hp⟩ := h + refine ⟨i,hi,qmaCellPair_pair_injective ?_⟩ + exact hp.symm.trans (P.cellPairIndex_pair i).symm + +theorem internal_allowed_disjoint + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (p : ℕ × ℕ) (e f : QMAInternalEdge) (hef : e ≠ f) + (he : P.RoutingAllowed (qmaInternalBody p e)) + (hf : P.RoutingAllowed (qmaInternalBody p f)) : + Disjoint (((qmaInternalPath e).drop 1).dropLast).toFinset (qmaInternalPath f).toFinset := by + rcases e with a | (a | a) <;> rcases f with b | (b | b) + · change Disjoint (((qmaCellRayPath a).drop 1).dropLast).toFinset (qmaCellRayPath b).toFinset + fin_cases a <;> fin_cases b <;> first | exact (hef rfl).elim | decide + · obtain ⟨⟨v,hv⟩,_⟩ := he + obtain ⟨_,i,hi,_⟩ := hf + exact (havoid i v (hi.trans hv.symm)).elim + · exact (he.2 hf).elim + · obtain ⟨_,i,hi,_⟩ := he + obtain ⟨⟨v,hv⟩,_⟩ := hf + exact (havoid i v (hi.trans hv.symm)).elim + · obtain ⟨i,hi,rfl⟩ := P.routingPair_index he + obtain ⟨j,hj,rfl⟩ := P.routingPair_index hf + have hij : i ≠ j := by + intro h + apply hef + rw [h] + have hn : ¬P.IsCrossing (P.cell i) := by simpa only [hi] using he.1 + have hd := P.ordinary_visit_paths_disjoint hij (hi.trans hj.symm) hn + apply Finset.disjoint_left.mpr + intro z hz hz' + apply Finset.disjoint_left.mp hd _ hz' + exact List.mem_toFinset.mpr + (List.mem_of_mem_drop (List.mem_of_mem_dropLast (List.mem_toFinset.mp hz))) + · exact (he.1 hf).elim + · exact (hf.2 he).elim + · exact (hf.1 he).elim + · change Disjoint (((qmaLocalPatchPath a).drop 1).dropLast).toFinset (qmaLocalPatchPath b).toFinset + fin_cases a <;> fin_cases b <;> first | exact (hef rfl).elim | decide + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneSupport.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba8dc349b47ac70031a3651c7ce42296ebf8b3ea --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneSupport.lean @@ -0,0 +1,82 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumManhattanSupport +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteLanes + +namespace OAI + +/-! Lane expansion preserves disjoint paths; different lanes meet only transversely. -/ + +namespace ContinuumCoulomb + +def qmaLaneDown (C : ℕ) (z : ℕ × ℕ) : ℕ × ℕ := (z.1/C,z.2/C) + +@[simp] theorem qmaLaneDown_point {C : ℕ} (c : Fin C) (p : ℕ × ℕ) : + qmaLaneDown C (qmaLanePoint c p) = p := by + have hC : 0 < C := (Nat.zero_le c.val).trans_lt c.isLt + apply Prod.ext <;> dsimp [qmaLaneDown,qmaLanePoint] + all_goals rw [Nat.add_comm,Nat.add_mul_div_left _ _ hC,Nat.div_eq_of_lt c.isLt,zero_add] + +def qmaLaneSupport {C : ℕ} (c : Fin C) (p q z : ℕ × ℕ) : Prop := + qmaManhattanSupport (qmaLanePoint c p) (qmaLanePoint c q) z + +theorem qmaLaneSupport_down {C : ℕ} (c : Fin C) {p q z : ℕ × ℕ} + (hz : qmaLaneSupport c p q z) : qmaManhattanSupport p q (qmaLaneDown C z) := by + have hdownp := qmaLaneDown_point c p + have hdownq := qmaLaneDown_point c q + rcases hz with ⟨hy,hx⟩ | ⟨hx,hy⟩ + · left + refine ⟨?_,?_⟩ + · have h := congrArg (fun x => x/C) hy + change (qmaLaneDown C z).2 = (qmaLaneDown C (qmaLanePoint c p)).2 at h + rw [hdownp] at h + exact h + · have h := qmaQuotient_bounds _ _ _ C hx.1 hx.2 + change min ((qmaLaneDown C (qmaLanePoint c p)).1) ((qmaLaneDown C (qmaLanePoint c q)).1) ≤ + (qmaLaneDown C z).1 ∧ (qmaLaneDown C z).1 ≤ + max ((qmaLaneDown C (qmaLanePoint c p)).1) ((qmaLaneDown C (qmaLanePoint c q)).1) at h + simpa only [qmaBetween,hdownp,hdownq] using h + · right + refine ⟨?_,?_⟩ + · have h := congrArg (fun x => x/C) hx + change (qmaLaneDown C z).1 = (qmaLaneDown C (qmaLanePoint c q)).1 at h + rw [hdownq] at h + exact h + · have h := qmaQuotient_bounds _ _ _ C hy.1 hy.2 + change min ((qmaLaneDown C (qmaLanePoint c p)).2) ((qmaLaneDown C (qmaLanePoint c q)).2) ≤ + (qmaLaneDown C z).2 ∧ (qmaLaneDown C z).2 ≤ + max ((qmaLaneDown C (qmaLanePoint c p)).2) ((qmaLaneDown C (qmaLanePoint c q)).2) at h + simpa only [qmaBetween,hdownp,hdownq] using h + +theorem qmaLaneSupport_disjoint {C : ℕ} (c : Fin C) {p q u v : ℕ × ℕ} + (h : Disjoint {z | qmaManhattanSupport p q z} {z | qmaManhattanSupport u v z}) : + Disjoint {z | qmaLaneSupport c p q z} {z | qmaLaneSupport c u v z} := by + apply Set.disjoint_left.mpr + intro z hz hz' + exact Set.disjoint_left.mp h (qmaLaneSupport_down c hz) (qmaLaneSupport_down c hz') + +theorem qmaLaneSupport_transverse {C : ℕ} {c d : Fin C} (hcd : c ≠ d) + {p q u v z : ℕ × ℕ} (hc : qmaLaneSupport c p q z) (hd : qmaLaneSupport d u v z) : + (qmaHorizontalLane c p.2 z ∧ qmaVerticalLane d v.1 z) ∨ + (qmaVerticalLane c q.1 z ∧ qmaHorizontalLane d u.2 z) := by + rcases hc with ⟨hc,_⟩ | ⟨hc,_⟩ <;> rcases hd with ⟨hd,_⟩ | ⟨hd,_⟩ + · exact (hcd (qmaHorizontalLane_color hc hd)).elim + · exact Or.inl ⟨hc,hd⟩ + · exact Or.inr ⟨hc,hd⟩ + · exact (hcd (qmaVerticalLane_color hc hd)).elim + +theorem qmaLaneSupport_two_crossings {C : ℕ} {c d : Fin C} (hcd : c ≠ d) + {p q u v z : ℕ × ℕ} (hc : qmaLaneSupport c p q z) (hd : qmaLaneSupport d u v z) : + z = (C*v.1+d.val,C*p.2+c.val) ∨ z = (C*q.1+c.val,C*u.2+d.val) := by + rcases qmaLaneSupport_transverse hcd hc hd with ⟨hy,hx⟩ | ⟨hx,hy⟩ + · exact Or.inl (Prod.ext hx hy) + · exact Or.inr (Prod.ext hx hy) + +theorem qmaLaneSupport_crossing_not_vertex {C : ℕ} {c d : Fin C} (hcd : c ≠ d) + {p q u v z : ℕ × ℕ} (hc : qmaLaneSupport c p q z) (hd : qmaLaneSupport d u v z) + (e : Fin C) (w : ℕ × ℕ) : z ≠ qmaLanePoint e w := by + rcases qmaLaneSupport_transverse hcd hc hd with ⟨hh,hv⟩ | ⟨hv,hh⟩ + · exact qmaLane_crossing_not_vertex hcd hh hv e w + · exact qmaLane_crossing_not_vertex hcd.symm hh hv e w + +end ContinuumCoulomb + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneUnaryProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneUnaryProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..3195bc45ed1acb5a9637aab7ba47e1dc58430232 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLaneUnaryProgram.lean @@ -0,0 +1,34 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpatialSlotProgram +import OAI.Computability.QuantumFactoring.BitStackBoundedUnary + +namespace OAI + +/-! Lane colors can be produced in unary without expanding the binary cell +coordinates: only their residues modulo three enter the lane formula. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumLaneUnaryProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode QuantumOrdinalProgram + +private noncomputable def residue {α : Type} {ea : α → List Bool} {f : α → ℕ} + (p : Procedure ea Nat.bits f) : Procedure ea unaryCode (fun x => f x%3) := + Procedure.boundedUnary + (Procedure.binaryMod.comp (p.pair (Procedure.constant ea Nat.bits 3))) + (Procedure.constant ea unaryCode 3) + (by intro x; exact (Nat.mod_lt (f x) (by decide)).le) + +noncomputable def program (B : ℕ) : + Procedure inputCode unaryCode (QuantumSpatialSlotProgram.lane B) := by + let p := QuantumSpatialSlotProgram.cellProgram + let row := residue ((Procedure.first Nat.bits Nat.bits).comp p) + let col := residue ((Procedure.second Nat.bits Nat.bits).comp p) + let rowTerm := Procedure.unaryMul.comp ((Procedure.constant inputCode unaryCode (3*B)).pair row) + let colTerm := Procedure.unaryMul.comp ((Procedure.constant inputCode unaryCode B).pair col) + exact Procedure.unaryAdd.comp + ((Procedure.unaryAdd.comp (QuantumOrdinalProgram.program.pair colTerm)).pair rowTerm) + +end ContinuumCoulomb.QuantumLaneUnaryProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeCoefficient.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..03b6990650de0244fed71b1b4e9146ac8f0fcd7a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeCoefficient.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpecifiedLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumCoefficientPrograms + +namespace OAI + +/-! The specified physical lattice has a polynomial coefficient envelope, +including both crossing offsets and the final merge of parallel edges. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +namespace QMAEvenRouteData +variable {G : QMARationalExchangeGraph} (P : QMAEvenRouteData G) + +theorem output_edge_count (N : ℚ) (D : ℕ) : + Fintype.card (P.output N D).Edge ≤ 3^(D+1)*Fintype.card G.Edge := by + have h := (P.schedule N).iterate_edge_count N D + have hs : Fintype.card (P.schedule N).graph.Edge ≤ 3*Fintype.card G.Edge := by + change Fintype.card (G.subdivide Finset.univ (fun _ => true) N).Edge ≤ _ + rw [G.subdivide_edge_count] + simp only [Finset.card_univ] + omega + exact h.trans (by simpa [pow_succ,Nat.mul_assoc] using Nat.mul_le_mul_left (3^D) hs) + +end QMAEvenRouteData + +namespace QuantumCoefficientPrograms + +def latticeBound (D m r L T : ℕ) : ℕ := + let m₁ := 3^D*m + let L₁ := iterated m L T D + let m₂ := m₁+9*r + let L₂ := crossingCoefficient m₁ r ((m₁+1)*L₁) T + let L₃ := (m₂+1)*L₂ + let L₄ := iterated (3*m₂) (pathCoefficient m₂ L₃ T) T 80 + (3^81*m₂+1)*L₄ + +theorem pathCoefficient_one (m L T : ℕ) : 1 ≤ pathCoefficient m L T := by + unfold pathCoefficient + omega + +theorem crossingCoefficient_one (m r L T : ℕ) : 1 ≤ crossingCoefficient m r L T := by + unfold crossingCoefficient + omega + +theorem iterated_one {L : ℕ} (hL : 1 ≤ L) (m T D : ℕ) : 1 ≤ iterated m L T D := by + cases D + · exact hL + · exact pathCoefficient_one _ _ _ + +end QuantumCoefficientPrograms + +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) + + theorem lattice_coefficientBound {N : ℚ} (hN : 0 ≤ N) {D : ℕ} + (hD : ∀ e, P.length e ≤ D) + (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) + (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) + {L T : ℕ} (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) (hc : G.CoefficientBound L) : + (P.latticeGraph N hD havoid hpositive).CoefficientBound + (QuantumCoefficientPrograms.latticeBound D (Fintype.card G.Edge) P.crossingCells.card L T) := by + let m := Fintype.card G.Edge + let r := P.crossingCells.card + let m₁ := 3^D*m + let L₁ := QuantumCoefficientPrograms.iterated m L T D + let m₂ := m₁+9*r + let L₂ := QuantumCoefficientPrograms.crossingCoefficient m₁ r ((m₁+1)*L₁) T + let L₃ := (m₂+1)*L₂ + let L₄ := QuantumCoefficientPrograms.iterated (3*m₂) + (QuantumCoefficientPrograms.pathCoefficient m₂ L₃ T) T 80 + have hLr : (1:ℝ) ≤ L := by exact_mod_cast hL + have hL₁n : 1 ≤ L₁ := QuantumCoefficientPrograms.iterated_one hL m T D + have hL₁ : (1:ℝ) ≤ L₁ := by exact_mod_cast hL₁n + have hm₁ : (Fintype.card (P.finishedGraph N D).Edge:ℝ) ≤ m₁ := by + exact_mod_cast P.schedule.iterate_edge_count N D + have hc₁ : (P.finishedGraph N D).CoefficientBound (L₁:ℝ) := by + simpa only [L₁,QuantumCoefficientPrograms.iterated_cast] using + P.schedule.iterate_coefficientBound hN (le_refl (m:ℝ)) hLr hT hc D + have hc₂ : (P.crossingOutput N hD).CoefficientBound (L₂:ℝ) := by + simpa only [L₂,QuantumCoefficientPrograms.crossingCoefficient_cast,Nat.cast_mul,Nat.cast_add, + Nat.cast_one,QuantumCoefficientPrograms.iterated_cast] using + (P.portCrossingSelection N hD).output_coefficientBound hN hm₁ hL₁ hT hc₁ + have hm₂n : Fintype.card (P.crossingOutput N hD).Edge ≤ m₂ := by + have he := (P.portCrossingSelection N hD).layer.output_edge_count N + have hr : Fintype.card (P.portCrossingSelection N hD).retained.Edge ≤ + Fintype.card (P.finishedGraph N D).Edge := Fintype.card_subtype_le _ + have hcount := P.schedule.iterate_edge_count N D + change Fintype.card (P.finishedGraph N D).Edge ≤ m₁ at hcount + change Fintype.card (P.crossingOutput N hD).Edge = + Fintype.card (P.portCrossingSelection N hD).retained.Edge+9*r at he + change Fintype.card (P.crossingOutput N hD).Edge ≤ m₁+9*r + omega + have hm₂ : (Fintype.card (P.crossingOutput N hD).Edge:ℝ) ≤ m₂ := by exact_mod_cast hm₂n + have hL₂n : 1 ≤ L₂ := QuantumCoefficientPrograms.crossingCoefficient_one _ _ _ _ + have hL₂ : (1:ℝ) ≤ L₂ := by exact_mod_cast hL₂n + have hL₃n : 1 ≤ L₃ := by dsimp [L₃]; nlinarith + have hL₃ : (1:ℝ) ≤ L₃ := by exact_mod_cast hL₃n + have hc₃ : (P.crossingOutput N hD).merge.CoefficientBound (L₃:ℝ) := by + simpa only [L₃,Nat.cast_mul,Nat.cast_add,Nat.cast_one] using + (P.crossingOutput N hD).merge_coefficientBound hm₂ hL₂ hc₂ + have hm₃n : Fintype.card (P.crossingOutput N hD).merge.Edge ≤ m₂ := + (P.crossingOutput N hD).merge_edge_count.trans hm₂n + have hm₃ : (Fintype.card (P.crossingOutput N hD).merge.Edge:ℝ) ≤ m₂ := by exact_mod_cast hm₃n + let R := (P.crossingPlanarRoute N hD havoid hpositive).toEven + have hc₄ : (R.output N 80).CoefficientBound (L₄:ℝ) := by + simpa only [L₄,QuantumCoefficientPrograms.iterated_cast, + QuantumCoefficientPrograms.pathCoefficient_cast,Nat.cast_mul,Nat.cast_ofNat] using + R.output_coefficientBound hN hm₃ hL₃ hT hc₃ 80 + have hm₄n : Fintype.card (R.output N 80).Edge ≤ 3^81*m₂ := + (R.output_edge_count N 80).trans (Nat.mul_le_mul_left _ hm₃n) + have hm₄ : (Fintype.card (R.output N 80).Edge:ℝ) ≤ (3^81*m₂:ℕ) := by exact_mod_cast hm₄n + have hL₄n : 1 ≤ L₄ := QuantumCoefficientPrograms.iterated_one + (QuantumCoefficientPrograms.pathCoefficient_one _ _ _) _ _ _ + have hL₄ : (1:ℝ) ≤ L₄ := by exact_mod_cast hL₄n + simpa only [latticeGraph,QuantumCoefficientPrograms.latticeBound, L₄,L₃,L₂,m₂,m₁,L₁,m,r, + Nat.cast_mul,Nat.cast_add,Nat.cast_one] using + (R.output N 80).merge_coefficientBound hm₄ hL₄ hc₄ + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEncoding.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..5339169e97822c7dc234491729287e39e8dbd147 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEncoding.lean @@ -0,0 +1,126 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeSerialization +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeSource +import Mathlib.Data.List.OfFn + +namespace OAI + +/-! Finite source objects serialize to valid binary instances with canonical +rational coefficients and the same physical sites and thresholds. -/ + +namespace ContinuumCoulomb.SquareLatticeHeisenberg + +def binaryEdge (d : SquareLatticeHeisenberg) (i : Fin d.edges) : BinaryHeisenbergEdge := + ⟨d.left i,d.right i,BinaryRational.ofRat (d.coefficient i)⟩ + +def binary (d : SquareLatticeHeisenberg) : BinaryHeisenberg where + coordinate := List.ofFn d.coordinate + edges := List.ofFn d.binaryEdge + lower := BinaryRational.ofRat d.lower + upper := BinaryRational.ofRat d.upper + +@[simp] theorem binary_vertices (d : SquareLatticeHeisenberg) : d.binary.coordinate.length = d.vertices := + List.length_ofFn +@[simp] theorem binary_edges (d : SquareLatticeHeisenberg) : d.binary.edges.length = d.edges := + List.length_ofFn + +private theorem get_ofFn_value {α : Type} {n : ℕ} (f : Fin n → α) (i : ℕ) (hi : i < n) : + (List.ofFn f).get ⟨i,by simpa using hi⟩ = f ⟨i,hi⟩ := by + simp [List.get_eq_getElem] + +theorem binary_getEdge (d : SquareLatticeHeisenberg) (i : Fin d.binary.edges.length) : + d.binary.edges.get i = d.binaryEdge ⟨i.val,by simpa using i.isLt⟩ := by + exact get_ofFn_value d.binaryEdge i.val (by simpa using i.isLt) + +theorem binary_getCoordinate (d : SquareLatticeHeisenberg) (i : Fin d.vertices) : + d.binary.coordinate.getD i.val (0,0) = d.coordinate i := by + rw [List.getD_eq_get _ _ ⟨i.val,by rw [binary_vertices]; exact i.isLt⟩] + simp only [binary,List.get_ofFn] + rfl + +theorem binary_valid (d : SquareLatticeHeisenberg) : d.binary.Valid := by + constructor + · simpa using d.vertices_pos + · exact List.nodup_ofFn.mpr d.coordinate_injective + · intro e + rw [d.binary_getEdge e] + simpa only [binaryEdge,binary_vertices] using + And.intro (d.left ⟨e.val,by simpa using e.isLt⟩).isLt + (d.right ⟨e.val,by simpa using e.isLt⟩).isLt + · intro e + rw [d.binary_getEdge e] + exact (d.coefficient _).den_pos + · intro e + rw [d.binary_getEdge e] + simp only [binaryEdge,d.binary_getCoordinate] + exact d.adjacent _ + · intro e f hef + rw [d.binary_getEdge e,d.binary_getEdge f] + let e' : Fin d.edges := ⟨e.val,by simpa using e.isLt⟩ + let f' : Fin d.edges := ⟨f.val,by simpa using f.isLt⟩ + have hne : e' ≠ f' := by + intro h + apply hef + have hv : e.val = f.val := congrArg (fun z : Fin d.edges => z.val) h + exact Fin.ext hv + have hs := d.edge_simple e' f' hne + constructor + · rintro ⟨hl,hr⟩ + exact hs.1 ⟨Fin.ext hl,Fin.ext hr⟩ + · rintro ⟨hl,hr⟩ + exact hs.2 ⟨Fin.ext hl,Fin.ext hr⟩ + · exact d.lower.den_pos + · exact d.upper.den_pos + · simpa only [binary,BinaryRational.value_ofRat] using d.gap_pos + +@[simp] theorem binary_lower (d : SquareLatticeHeisenberg) : d.binary.lower.value = d.lower := + BinaryRational.value_ofRat _ +@[simp] theorem binary_upper (d : SquareLatticeHeisenberg) : d.binary.upper.value = d.upper := + BinaryRational.value_ofRat _ + +private theorem ext_data {d e : SquareLatticeHeisenberg} + (hn : d.vertices = e.vertices) (hc : HEq d.coordinate e.coordinate) + (hm : d.edges = e.edges) (hl : HEq d.left e.left) (hr : HEq d.right e.right) + (hJ : HEq d.coefficient e.coefficient) (ha : d.lower = e.lower) (hb : d.upper = e.upper) : d = e := by + cases d + cases e + cases hn + cases hm + cases hc + cases hl + cases hr + cases hJ + cases ha + cases hb + rfl + +theorem binary_toSource (d : SquareLatticeHeisenberg) : + d.binary.toSource d.binary_valid = d := by + apply ext_data (d.binary_vertices) ?_ (d.binary_edges) ?_ ?_ ?_ (binary_lower d) (binary_upper d) + · apply (Fin.heq_fun_iff d.binary_vertices).mpr + intro i + exact get_ofFn_value d.coordinate i.val (by simpa using i.isLt) + · apply Function.hfunext (congrArg Fin d.binary_edges) + intro i j hij + apply (Fin.heq_ext_iff d.binary_vertices).mpr + change (d.binary.edges.get i).left = (d.left j).val + rw [d.binary_getEdge i] + dsimp only [binaryEdge] + have hval := Fin.val_eq_val_of_heq hij + exact congrArg (fun e : Fin d.edges => (d.left e).val) (Fin.ext hval) + · apply Function.hfunext (congrArg Fin d.binary_edges) + intro i j hij + apply (Fin.heq_ext_iff d.binary_vertices).mpr + change (d.binary.edges.get i).right = (d.right j).val + rw [d.binary_getEdge i] + dsimp only [binaryEdge] + have hval := Fin.val_eq_val_of_heq hij + exact congrArg (fun e : Fin d.edges => (d.right e).val) (Fin.ext hval) + · apply (Fin.heq_fun_iff d.binary_edges).mpr + intro i + change (d.binary.edges.get i).coefficient.value = _ + rw [d.binary_getEdge i] + exact BinaryRational.value_ofRat _ + +end ContinuumCoulomb.SquareLatticeHeisenberg + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEnvelope.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..c624a3e7f8d1f4721d7cbb453d23a2fdcd492ab4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeEnvelope.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeCoefficient + +namespace OAI + +/-! A literal polynomial program computes the final coefficient envelope; +the exponent in the source promise is uniform over all inputs. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumCoefficientPrograms +open ExactQuantumFactoring.BitStackProgram + +private noncomputable def addP {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x+g x) := Procedure.unaryAdd.comp (p.pair q) +private noncomputable def mulP {α : Type} {ea : α → List Bool} {f g : α → ℕ} + (p : Procedure ea unaryCode f) (q : Procedure ea unaryCode g) : + Procedure ea unaryCode (fun x => f x*g x) := Procedure.unaryMul.comp (p.pair q) + +noncomputable def iteratedOfProgram {α : Type} {ea : α → List Bool} {m L T : α → ℕ} + (pm : Procedure ea unaryCode m) (pl : Procedure ea unaryCode L) + (pt : Procedure ea unaryCode T) (k : ℕ) : + Procedure ea unaryCode (fun x => iterated (m x) (L x) (T x) k) := by + induction k with + | zero => exact pl + | succ k ih => + exact pathCoefficientProgram (mulP (Procedure.constant ea unaryCode (3^k)) pm) ih pt + +abbrev LatticeInput := ℕ × (ℕ × (ℕ × ℕ)) +def latticeInputCode : LatticeInput → List Bool := + prodCode unaryCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + +noncomputable opaque latticeM : Procedure latticeInputCode unaryCode (fun x => x.1) := Procedure.first _ _ +noncomputable opaque latticeTail : Procedure latticeInputCode (prodCode unaryCode (prodCode unaryCode unaryCode)) + (fun x => x.2) := Procedure.second _ _ +noncomputable opaque latticeR : Procedure latticeInputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp latticeTail +noncomputable opaque latticeLT : Procedure latticeInputCode (prodCode unaryCode unaryCode) + (fun x => x.2.2) := (Procedure.second _ _).comp latticeTail +noncomputable opaque latticeL : Procedure latticeInputCode unaryCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp latticeLT +noncomputable opaque latticeT : Procedure latticeInputCode unaryCode (fun x => x.2.2.2) := + (Procedure.second _ _).comp latticeLT + +noncomputable opaque latticeBoundProgram (D : ℕ) : + Procedure latticeInputCode unaryCode (fun x => latticeBound D x.1 x.2.1 x.2.2.1 x.2.2.2) := by + let c := Procedure.constant latticeInputCode unaryCode + let m₁ := mulP (c (3^D)) latticeM + let L₁ := iteratedOfProgram latticeM latticeL latticeT D + let m₂ := addP m₁ (mulP (c 9) latticeR) + let L₂ := crossingCoefficientProgram m₁ latticeR (mulP (addP m₁ (c 1)) L₁) latticeT + let L₃ := mulP (addP m₂ (c 1)) L₂ + let L₄ := iteratedOfProgram (mulP (c 3) m₂) (pathCoefficientProgram m₂ L₃ latticeT) latticeT 80 + exact (mulP (addP (mulP (c (3^81)) m₂) (c 1)) L₄).congrFun (by intro x; rfl) + +theorem latticeBound_power (D : ℕ) : ∃ a : ℕ, ∀ x : LatticeInput, + latticeBound D x.1 x.2.1 x.2.2.1 x.2.2.2 ≤ ((latticeInputCode x).length+2)^a := + unaryProcedure_power_bound (latticeBoundProgram D) + +end ContinuumCoulomb.QuantumCoefficientPrograms + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticePromise.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticePromise.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4c4a3359ba316b76d8e5bef52561e718a5ee1e5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticePromise.lean @@ -0,0 +1,113 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeEncoding +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumSpecifiedLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceEncodingSize + +namespace OAI + +/-! The actual lattice serialization preserves the source energy promise. +Numerical envelopes may be measured against any retained input size; the +output bit length is at least the number of physical spins. -/ + +noncomputable section +namespace ContinuumCoulomb +open ExactQuantumFactoring.BitStackProgram + +namespace SquareLatticeHeisenberg + +/-- The literal serializer receives precisely the finite data of this source. -/ +def binaryPacket (d : SquareLatticeHeisenberg) : QuantumLatticeSerialization.Input := + (List.ofFn d.coordinate, + List.ofFn (fun e => ((d.left e).val,(d.right e).val,d.coefficient e)), + d.lower,d.upper,0) + +theorem binaryPacket_value (d : SquareLatticeHeisenberg) : + QuantumLatticeSerialization.value d.binaryPacket = d.binary := by + have he : (List.ofFn (fun e => ((d.left e).val,(d.right e).val,d.coefficient e))).map + QuantumLatticeSerialization.edge = List.ofFn d.binaryEdge := by + rw [List.map_ofFn] + rfl + change BinaryHeisenberg.mk _ _ _ _ = BinaryHeisenberg.mk _ _ _ _ + dsimp only [binaryPacket] + rw [he] + simp only [sub_zero] + +theorem binary_polynomialPromise (d : SquareLatticeHeisenberg) (n k : ℕ) + (hn : n ≤ d.vertices) + (hc : ∀ i, |((d.coordinate i).1 : ℝ)| ≤ (n+1:ℝ)^k ∧ + |((d.coordinate i).2 : ℝ)| ≤ (n+1:ℝ)^k) + (hJ : ∀ e, |(d.coefficient e : ℝ)| ≤ (n+1:ℝ)^k) + (hg : ((n+1:ℝ)^k)⁻¹ ≤ (d.upper:ℝ)-d.lower) : + d.binary.PolynomialPromise k := by + have hsize : n ≤ (binaryHeisenbergCodec.encode d.binary).length := by + have h := binaryHeisenberg_count_le_length d.binary + rw [d.binary_vertices] at h + omega + have hbase : (n+1:ℝ) ≤ ((binaryHeisenbergCodec.encode d.binary).length+1:ℝ) := by + exact_mod_cast Nat.add_le_add_right hsize 1 + have hpow := pow_le_pow_left₀ (by positivity : (0:ℝ) ≤ n+1) hbase k + constructor + · intro p hp + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hp + exact ⟨(hc i).1.trans hpow,(hc i).2.trans hpow⟩ + · intro e + rw [d.binary_getEdge e] + simp only [binaryEdge,BinaryRational.value_ofRat] + exact (hJ ⟨e.val,by simpa using e.isLt⟩).trans hpow + · simp only [binary_lower,binary_upper] + exact (inv_anti₀ (by positivity : (0:ℝ) < (n+1)^k) hpow).trans hg + +theorem binary_mem_yes (d : SquareLatticeHeisenberg) {k : ℕ} + (hp : d.binary.PolynomialPromise k) (he : realSourceGroundEnergy d ≤ (d.lower:ℝ)) : + d.binary ∈ (sourceHeisenbergPromise k).yes := by + refine ⟨d.binary_valid,hp,?_⟩ + rw [d.binary_toSource,← realSourceGroundEnergy_coe,d.binary_lower] + exact EReal.coe_le_coe he + +theorem binary_mem_no (d : SquareLatticeHeisenberg) {k : ℕ} + (hp : d.binary.PolynomialPromise k) (he : (d.upper:ℝ) ≤ realSourceGroundEnergy d) : + d.binary ∈ (sourceHeisenbergPromise k).no := by + refine ⟨d.binary_valid,hp,?_⟩ + rw [d.binary_toSource,← realSourceGroundEnergy_coe,d.binary_upper] + exact EReal.coe_le_coe he + +end SquareLatticeHeisenberg + +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) +variable (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) +variable (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) +variable (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) + +/-- Preserve a positive gap by moving both thresholds inward by the proved +simulation error, before removing the exact scalar matrix offset. -/ +def marginSource (hn : 0 < G.n) (a b ε : ℚ) (hab : a+ε < b-ε) : SquareLatticeHeisenberg := + P.latticeSource N hD havoid hpositive hn (a+ε) (b-ε) hab + +theorem marginSource_yes (hN : 0 < N) (hn : 0 < G.n) (a b ε : ℚ) + (hab : a+ε < b-ε) (hε : ((D+82:ℕ):ℝ)/(N:ℝ) ≤ (ε:ℝ)) + (he : G.energy ≤ (a:ℝ)) : + realSourceGroundEnergy (P.marginSource N hD havoid hpositive hn a b ε hab) ≤ + ((P.marginSource N hD havoid hpositive hn a b ε hab).lower:ℝ) := by + have h := (abs_le.mp (P.lattice_energy_error N hD havoid hpositive hN)).2 + rw [marginSource,P.latticeSource_energy] + change _ ≤ ((a+ε-(P.latticeGraph N hD havoid hpositive).constant:ℚ):ℝ) + push_cast + linarith + +theorem marginSource_no (hN : 0 < N) (hn : 0 < G.n) (a b ε : ℚ) + (hab : a+ε < b-ε) (hε : ((D+82:ℕ):ℝ)/(N:ℝ) ≤ (ε:ℝ)) + (he : (b:ℝ) ≤ G.energy) : + ((P.marginSource N hD havoid hpositive hn a b ε hab).upper:ℝ) ≤ + realSourceGroundEnergy (P.marginSource N hD havoid hpositive hn a b ε hab) := by + have h := (abs_le.mp (P.lattice_energy_error N hD havoid hpositive hN)).1 + rw [marginSource,P.latticeSource_energy] + change ((b-ε-(P.latticeGraph N hD havoid hpositive).constant:ℚ):ℝ) ≤ _ + push_cast + linarith + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSerialization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSerialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb84beee9ac40e00759694fddebb90d45c45820e --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSerialization.lean @@ -0,0 +1,88 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.SourcePrograms + +namespace OAI + +/-! Literal serialization of rational lattice graphs into the published source +format. The constant matrix offset is subtracted from both thresholds. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumLatticeSerialization +open ExactQuantumFactoring.BitStackProgram +open MediatorListProgram + +abbrev Coordinate := ℤ × ℤ +abbrev Input := List Coordinate × (List Bond × (ℚ × (ℚ × ℚ))) +def coordinateCode : Coordinate → List Bool := prodCode intCode intCode +def thresholdCode : (ℚ × (ℚ × ℚ)) → List Bool := prodCode ratCode (prodCode ratCode ratCode) +def inputCode : Input → List Bool := + prodCode (listCode coordinateCode) (prodCode (listCode bondCode) thresholdCode) + +def edge (b : Bond) : BinaryHeisenbergEdge := ⟨b.1,b.2.1,BinaryRational.ofRat b.2.2⟩ +def value (x : Input) : BinaryHeisenberg where + coordinate := x.1 + edges := x.2.1.map edge + lower := BinaryRational.ofRat (x.2.2.1-x.2.2.2.2) + upper := BinaryRational.ofRat (x.2.2.2.1-x.2.2.2.2) + +noncomputable def rationalProgram : Procedure ratCode binaryRationalCodec.encode BinaryRational.ofRat := + ((EncodingPrograms.appendPair BinaryEncoding.integer BinaryEncoding.natural).comp + ((EncodingPrograms.integerOutput.comp Procedure.ratNum).pair + (EncodingPrograms.naturalOutput.comp Procedure.ratDen))).result (by intro q; rfl) + +noncomputable def coordinateProgram : Procedure coordinateCode SourcePrograms.coordinateCodec.encode id := + ((EncodingPrograms.appendPair BinaryEncoding.integer BinaryEncoding.integer).comp + ((EncodingPrograms.integerOutput.comp (Procedure.first _ _)).pair + (EncodingPrograms.integerOutput.comp (Procedure.second _ _)))).congrFun (by rintro ⟨x,y⟩; rfl) + +noncomputable def edgeProgram : Procedure bondCode binaryHeisenbergEdgeCodec.encode edge := by + let tail := Procedure.second Nat.bits (prodCode Nat.bits ratCode) + let right := EncodingPrograms.naturalOutput.comp ((Procedure.first _ _).comp tail) + let weight := rationalProgram.comp ((Procedure.second _ _).comp tail) + let rest := (EncodingPrograms.appendPair BinaryEncoding.natural binaryRationalCodec).comp (right.pair weight) + exact ((EncodingPrograms.appendPair BinaryEncoding.natural + (BinaryEncoding.pair BinaryEncoding.natural binaryRationalCodec)).comp + ((EncodingPrograms.naturalOutput.comp (Procedure.first _ _)).pair rest)).result (by intro b; rfl) + +noncomputable def coordinatesProgram : Procedure inputCode SourcePrograms.coordinateListCodec.encode Prod.fst := + ((PrefixListPrograms.listOutput SourcePrograms.coordinateCodec (0,0)).comp + ((Procedure.listMap (0,0) (0,0) coordinateProgram).comp + (Procedure.first _ _))).congrFun (by intro x; simp) + +noncomputable def bondsProgram : Procedure inputCode SourcePrograms.edgeListCodec.encode + (fun x => x.2.1.map edge) := + (PrefixListPrograms.listOutput binaryHeisenbergEdgeCodec ⟨0,0,⟨0,1⟩⟩).comp + ((Procedure.listMap (0,0,0) ⟨0,0,⟨0,1⟩⟩ edgeProgram).comp + ((Procedure.first _ _).comp (Procedure.second _ _))) + +noncomputable def thresholdsProgram : Procedure inputCode SourcePrograms.thresholdCodec.encode + (fun x => ((value x).lower,(value x).upper)) := by + let t : Procedure inputCode thresholdCode (fun x => x.2.2) := + (Procedure.second _ _).comp (Procedure.second _ _) + let a := (Procedure.first _ _).comp t + let b := (Procedure.first _ _).comp ((Procedure.second _ _).comp t) + let c := (Procedure.second _ _).comp ((Procedure.second _ _).comp t) + let lower := rationalProgram.comp (Procedure.ratSub.comp (a.pair c)) + let upper := rationalProgram.comp (Procedure.ratSub.comp (b.pair c)) + exact (EncodingPrograms.appendPair binaryRationalCodec binaryRationalCodec).comp (lower.pair upper) + +noncomputable def program : Procedure inputCode binaryHeisenbergCodec.encode value := by + let tail := (EncodingPrograms.appendPair SourcePrograms.edgeListCodec SourcePrograms.thresholdCodec).comp + (bondsProgram.pair thresholdsProgram) + exact ((EncodingPrograms.appendPair SourcePrograms.coordinateListCodec SourcePrograms.sourceTailCodec).comp + (coordinatesProgram.pair tail)).result (by intro x; rfl) + +noncomputable def certificate : Turing.TM2ComputableInPolyTime inputCode binaryHeisenbergCodec.encode value := + program.toTM2 + +@[simp] theorem lower_value (x : Input) : (value x).lower.value = x.2.2.1-x.2.2.2.2 := + BinaryRational.value_ofRat _ +@[simp] theorem upper_value (x : Input) : (value x).upper.value = x.2.2.2.1-x.2.2.2.2 := + BinaryRational.value_ofRat _ +@[simp] theorem edges_length (x : Input) : (value x).edges.length = x.2.1.length := by simp [value] + +end ContinuumCoulomb.QuantumLatticeSerialization + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSource.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSource.lean new file mode 100644 index 0000000000000000000000000000000000000000..f46ffb6bc90b14087687d7e385783e8add3dd0b0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSource.lean @@ -0,0 +1,103 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMergeEdges +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGridWalk +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceMatrix + +namespace OAI + +/-! Convert an actual simple rational grid graph into the field-free source +Hamiltonian, retaining the exact scalar shift in its thresholds. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped BigOperators Classical + +def qmaGridCoordinate (p : ℕ × ℕ) : ℤ × ℤ := (p.1,p.2) + +theorem qmaGridCoordinate_injective : Function.Injective qmaGridCoordinate := by + intro p q h + apply Prod.ext + · exact_mod_cast (show (p.1:ℤ) = q.1 from congrArg Prod.fst h) + · exact_mod_cast (show (p.2:ℤ) = q.2 from congrArg Prod.snd h) + +theorem qmaNatDistance (a b : ℕ) : Int.natAbs ((a:ℤ)-b) = Nat.dist a b := by + rcases le_total a b with h | h + · rw [Int.natAbs_natCast_sub_natCast_of_le h,Nat.dist_eq_sub_of_le h] + · rw [Int.natAbs_natCast_sub_natCast_of_ge h,Nat.dist_eq_sub_of_le_right h] + +theorem qmaGridCoordinate_adj {p q : ℕ × ℕ} (h : qmaSquareGrid.Adj p q) : + Int.natAbs ((qmaGridCoordinate p).1-(qmaGridCoordinate q).1)+ + Int.natAbs ((qmaGridCoordinate p).2-(qmaGridCoordinate q).2) = 1 := by + simpa only [qmaGridCoordinate,qmaNatDistance] using (show Nat.dist p.1 q.1 + Nat.dist p.2 q.2 = 1 from h) + +namespace QMARationalExchangeGraph +variable (G : QMARationalExchangeGraph) + +def Simple : Prop := ∀ e f : G.Edge, e ≠ f → + ¬(G.left e = G.left f ∧ G.right e = G.right f) ∧ + ¬(G.left e = G.right f ∧ G.right e = G.left f) + +theorem merge_simple : G.merge.Simple := by + intro e f hef + constructor + · rintro ⟨hl,hr⟩ + exact hef (G.merge_pair_injective (Prod.ext hl hr)) + · rintro ⟨hl,hr⟩ + have he : G.merge.left e < G.merge.right e := G.mergedEdge_lt e + have hf : G.merge.left f < G.merge.right f := G.mergedEdge_lt f + rw [hl,hr] at he + exact (not_lt_of_ge hf.le) he + +def latticeSource (hn : 0 < G.n) (position : Fin G.n → ℕ × ℕ) + (hinj : Function.Injective position) + (hgrid : ∀ e, qmaSquareGrid.Adj (position (G.left e)) (position (G.right e))) + (hsimple : G.Simple) (a b : ℚ) (hab : a < b) : SquareLatticeHeisenberg where + vertices := G.n + vertices_pos := hn + coordinate := qmaGridCoordinate ∘ position + coordinate_injective := qmaGridCoordinate_injective.comp hinj + edges := Fintype.card G.Edge + left e := G.left ((Fintype.equivFin G.Edge).symm e) + right e := G.right ((Fintype.equivFin G.Edge).symm e) + adjacent _e := qmaGridCoordinate_adj (hgrid _) + edge_simple _e _f hef := hsimple _ _ (fun h => hef ((Fintype.equivFin G.Edge).symm.injective h)) + coefficient e := G.weight ((Fintype.equivFin G.Edge).symm e) + lower := a-G.constant + upper := b-G.constant + gap_pos := sub_lt_sub_right hab _ + +theorem latticeSource_matrix (hn : 0 < G.n) (position : Fin G.n → ℕ × ℕ) + (hinj : Function.Injective position) + (hgrid : ∀ e, qmaSquareGrid.Adj (position (G.left e)) (position (G.right e))) + (hsimple : G.Simple) (a b : ℚ) (hab : a < b) : + (G.latticeSource hn position hinj hgrid hsimple a b hab).bonds.matrix = + qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant - + (G.constant:ℂ) • (1 : Matrix (SourceSpinBasis G.n) (SourceSpinBasis G.n) ℂ) := by + have hs := (Fintype.equivFin G.Edge).symm.sum_comp (fun e => + (G.weight e:ℂ) • sourceHeisenbergMatrix G.n (G.left e) (G.right e)) + change (∑ e : Fin (Fintype.card G.Edge), + (G.weight ((Fintype.equivFin G.Edge).symm e):ℂ) • + sourceHeisenbergMatrix G.n (G.left ((Fintype.equivFin G.Edge).symm e)) + (G.right ((Fintype.equivFin G.Edge).symm e))) = _ + rw [hs] + simp only [qmaExchangeMatrix,Complex.ofReal_ratCast,add_sub_cancel_right] + +theorem latticeSource_energy (hn : 0 < G.n) (position : Fin G.n → ℕ × ℕ) + (hinj : Function.Injective position) + (hgrid : ∀ e, qmaSquareGrid.Adj (position (G.left e)) (position (G.right e))) + (hsimple : G.Simple) (a b : ℚ) (hab : a < b) : + realSourceGroundEnergy (G.latticeSource hn position hinj hgrid hsimple a b hab) = + G.energy-(G.constant:ℝ) := by + rw [← sourceMatrixBottom_eq_realSource,G.latticeSource_matrix] + change sourceMatrixBottom G.n + (qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant - + (G.constant:ℂ) • 1) = G.energy-(G.constant:ℝ) + simpa only [energy,Complex.ofReal_ratCast] using + sourceMatrixBottom_shift G.n + (qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant) (G.constant:ℝ) + +end QMARationalExchangeGraph +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSourceBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSourceBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f8c10d78f358cde904516aefa3d3f0de4308fc5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLatticeSourceBounds.lean @@ -0,0 +1,75 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticePromise +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticeCoefficient + +namespace OAI + +/-! The proved physical box and coefficient estimates imply the exact binary +source promise, measured against the retained input size. -/ + +noncomputable section +namespace ContinuumCoulomb +open scoped Classical + +namespace QMARationalExchangeGraph +variable (G : QMARationalExchangeGraph) + +theorem latticeSource_binary_promise (hn : 0 < G.n) (position : Fin G.n → ℕ × ℕ) + (hinj : Function.Injective position) + (hgrid : ∀ e, qmaSquareGrid.Adj (position (G.left e)) (position (G.right e))) + (hsimple : G.Simple) (a b : ℚ) (hab : a < b) {n k : ℕ} {C : ℝ} + (hsize : n ≤ G.n) + (hposition : ∀ v, (position v).1 ≤ (n+1:ℝ)^k ∧ (position v).2 ≤ (n+1:ℝ)^k) + (hC : G.CoefficientBound C) (hCsize : C ≤ (n+1:ℝ)^k) + (hg : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (G.latticeSource hn position hinj hgrid hsimple a b hab).binary.PolynomialPromise k := by + apply SquareLatticeHeisenberg.binary_polynomialPromise + (G.latticeSource hn position hinj hgrid hsimple a b hab) n k hsize + · intro i + change |(((position i).1:ℤ):ℝ)| ≤ _ ∧ |(((position i).2:ℤ):ℝ)| ≤ _ + simp only [Int.cast_natCast] + rw [abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ ((position i).1:ℝ)), + abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ ((position i).2:ℝ))] + exact hposition i + · intro e + exact (hC.2 ((Fintype.equivFin G.Edge).symm e)).trans hCsize + · change ((n+1:ℝ)^k)⁻¹ ≤ ((b-G.constant:ℚ):ℝ)-((a-G.constant:ℚ):ℝ) + push_cast + linarith + +end QMARationalExchangeGraph + +namespace QMAPortRouteData +variable {G : QMARationalExchangeGraph} (P : QMAPortRouteData G) +variable (N : ℚ) {D : ℕ} (hD : ∀ e, P.length e ≤ D) +variable (havoid : ∀ i : P.Interior, ∀ v, P.cell i ≠ P.position v) +variable (hpositive : ∀ v, 0 < (P.position v).1 ∧ 0 < (P.position v).2) + +theorem latticeSource_binary_promise (hn : 0 < G.n) (a b : ℚ) (hab : a < b) + {n k X Y L T : ℕ} (hsize : n ≤ G.n) + (hsource : ∀ v, (P.position v).1 < X ∧ (P.position v).2 < Y) + (hpath : ∀ e j, j ≤ P.length e → (P.point e j).1 < X ∧ (P.point e j).2 < Y) + (hN : 0 ≤ N) (hL : 1 ≤ L) (hT : |(N:ℝ)| ≤ T) (hc : G.CoefficientBound L) + (hx : (256*X:ℕ) ≤ (n+1:ℝ)^k) (hy : (256*Y:ℕ) ≤ (n+1:ℝ)^k) + (hw : (QuantumCoefficientPrograms.latticeBound D (Fintype.card G.Edge) + P.crossingCells.card L T : ℝ) ≤ (n+1:ℝ)^k) + (hg : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (P.latticeSource N hD havoid hpositive hn a b hab).binary.PolynomialPromise k := by + apply (P.latticeGraph N hD havoid hpositive).latticeSource_binary_promise + (hn.trans_le (P.lattice_vertices_ge N hD havoid hpositive)) + (P.latticePosition N hD havoid hpositive) + (P.lattice_position_injective N hD havoid hpositive) + (P.lattice_adjacent N hD havoid hpositive) + (QMARationalExchangeGraph.merge_simple _) a b hab + (hsize.trans (P.lattice_vertices_ge N hD havoid hpositive)) ?_ + (P.lattice_coefficientBound hN hD havoid hpositive hL hT hc) hw hg + intro i + have hb := P.lattice_bounded N hD havoid hpositive hsource hpath i + exact ⟨(le_of_lt (by exact_mod_cast hb.1)).trans hx, + (le_of_lt (by exact_mod_cast hb.2)).trans hy⟩ + +end QMAPortRouteData +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..22ce1e83be95e4b62222d35c578da76302afdb37 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListGraph.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRationalPathStep +import OAI.MathematicalPhysics.ContinuumCoulomb.Reduction.SourceBondLists + +namespace OAI + +/-! Exact exchange-graph semantics for the finite bond lists manipulated by +the routing compiler. The scalar offset stays part of the full Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListGraph +open Matrix MediatorListProgram +open scoped BigOperators Classical + +def ofBonds (n : ℕ) (xs : List Bond) (c : ℚ) + (hb : SourceBondLists.bounded n xs) (hn : ∀ e ∈ xs, e.1 ≠ e.2.1) : + QMARationalExchangeGraph where + n := n + Edge := Fin xs.length + left := (SourceBondLists.bonds n xs hb).left + right := (SourceBondLists.bonds n xs hb).right + distinct := fun i h => hn _ (List.get_mem xs i) (congrArg Fin.val h) + weight := (SourceBondLists.bonds n xs hb).weight + constant := c + +theorem ofBonds_matrix (n : ℕ) (xs : List Bond) (c : ℚ) + (hb : SourceBondLists.bounded n xs) (hn : ∀ e ∈ xs, e.1 ≠ e.2.1) : + qmaExchangeMatrix (n := n) (ofBonds n xs c hb hn).left (ofBonds n xs c hb hn).right + (fun e => ((ofBonds n xs c hb hn).weight e:ℝ)) c = + SourceBondLists.matrix n xs+(c:ℂ) • 1 := by + rw [SourceBondLists.matrix_bonds n xs hb] + simp only [ofBonds,qmaExchangeMatrix,MediatorIteration.Bonds.matrix,sourceGraphMatrix, + Complex.ofReal_ratCast] + rfl + +theorem ofBonds_energy (n : ℕ) (xs : List Bond) (c : ℚ) + (hb : SourceBondLists.bounded n xs) (hn : ∀ e ∈ xs, e.1 ≠ e.2.1) : + (ofBonds n xs c hb hn).energy = + sourceMatrixBottom n (SourceBondLists.matrix n xs+(c:ℂ) • 1) := by + exact congrArg (sourceMatrixBottom n) (ofBonds_matrix n xs c hb hn) + +def packed (G : QMARationalExchangeGraph) {m : ℕ} (labels : G.Edge ≃ Fin m) : List Bond := + List.ofFn fun i => ((G.left (labels.symm i)).val,(G.right (labels.symm i)).val, + G.weight (labels.symm i)) + +theorem packed_bounded (G : QMARationalExchangeGraph) {m : ℕ} (labels : G.Edge ≃ Fin m) : + SourceBondLists.bounded G.n (packed G labels) := by + intro e he + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp he + exact ⟨(G.left (labels.symm i)).isLt,(G.right (labels.symm i)).isLt⟩ + +theorem packed_noLoops (G : QMARationalExchangeGraph) {m : ℕ} (labels : G.Edge ≃ Fin m) : + ∀ e ∈ packed G labels, e.1 ≠ e.2.1 := by + intro e he h + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp he + exact G.distinct (labels.symm i) (Fin.ext h) + +theorem packed_matrix (G : QMARationalExchangeGraph) {m : ℕ} (labels : G.Edge ≃ Fin m) : + SourceBondLists.matrix G.n (packed G labels)+(G.constant:ℂ) • 1 = + qmaExchangeMatrix G.left G.right (fun e => (G.weight e:ℝ)) G.constant := by + have he (i : Fin m) : + SourceBondLists.bondMatrix G.n + ((G.left (labels.symm i)).val,(G.right (labels.symm i)).val,G.weight (labels.symm i)) = + (G.weight (labels.symm i):ℂ) • + sourceHeisenbergMatrix G.n (G.left (labels.symm i)) (G.right (labels.symm i)) := by + rw [SourceBondLists.bondMatrix,dite_eq_left + ⟨(G.left (labels.symm i)).isLt,(G.right (labels.symm i)).isLt⟩] + simp only [SourceBondLists.matrix,packed,List.map_ofFn,List.sum_ofFn,Function.comp_apply,he, + qmaExchangeMatrix,Complex.ofReal_ratCast] + exact congrArg (fun x => x+(G.constant:ℂ) • 1) + (labels.symm.sum_comp (fun e => (G.weight e:ℂ) • + sourceHeisenbergMatrix G.n (G.left e) (G.right e))) + +theorem packed_energy (G : QMARationalExchangeGraph) {m : ℕ} (labels : G.Edge ≃ Fin m) : + (ofBonds G.n (packed G labels) G.constant (packed_bounded G labels) + (packed_noLoops G labels)).energy = G.energy := by + exact (ofBonds_energy _ _ _ _ _).trans + (congrArg (sourceMatrixBottom G.n) (packed_matrix G labels)) + +end ContinuumCoulomb.QuantumListGraph + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLattice.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ef5693c450e5626fb30d726ffc6d9fa4e54c5e6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLattice.lean @@ -0,0 +1,147 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMergeMatrix +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMergeProperties +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLatticePromise + +namespace OAI + +/-! The actual computed coordinate and bond tapes define a valid lattice +source. Canonical merging preserves its full matrix and scalar threshold shift. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListLattice +open MediatorListProgram +open QuantumListMerge + +def Adjacent (ps : List Pair) (xs : List Bond) (hb : SourceBondLists.bounded ps.length xs) : Prop := + ∀ e (he : e ∈ xs), qmaSquareGrid.Adj + (ps.get ⟨e.1,(hb e he).1⟩) (ps.get ⟨e.2.1,(hb e he).2⟩) + +theorem merge_adjacent (ps : List Pair) (xs : List Bond) + (hb : SourceBondLists.bounded ps.length xs) (ha : Adjacent ps xs hb) + (e : Bond) (he : e ∈ value ps.length xs) : + qmaSquareGrid.Adj + (ps.get ⟨e.1,(bounded ps.length xs e he).1⟩) + (ps.get ⟨e.2.1,(bounded ps.length xs e he).2⟩) := by + obtain ⟨p,hp,rfl⟩ := List.mem_map.mp he + obtain ⟨b,hb',hbp⟩ := List.mem_map.mp ((mem_support hb p).mp hp) + subst p + by_cases h : b.1 ≤ b.2.1 + · simpa only [ordered,min_eq_left h,max_eq_right h] using ha b hb' + · have h' : b.2.1 ≤ b.1 := by omega + simpa only [ordered,min_eq_right h',max_eq_left h'] using (ha b hb').symm + +def source (ps : List Pair) (xs : List Bond) (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : SquareLatticeHeisenberg where + vertices := ps.length + vertices_pos := hp + coordinate i := qmaGridCoordinate (ps.get i) + coordinate_injective := qmaGridCoordinate_injective.comp hn.injective_get + edges := (value ps.length xs).length + left i := ⟨((value ps.length xs).get i).1, + (bounded ps.length xs _ (List.get_mem _ i)).1⟩ + right i := ⟨((value ps.length xs).get i).2.1, + (bounded ps.length xs _ (List.get_mem _ i)).2⟩ + coefficient i := ((value ps.length xs).get i).2.2 + adjacent i := qmaGridCoordinate_adj (merge_adjacent ps xs hb ha _ (List.get_mem _ i)) + edge_simple i j hij := by + have h := value_simple hl i j hij + constructor + · rintro ⟨h1,h2⟩ + exact h.1 ⟨congrArg Fin.val h1,congrArg Fin.val h2⟩ + · rintro ⟨h1,h2⟩ + exact h.2 ⟨congrArg Fin.val h1,congrArg Fin.val h2⟩ + lower := a-c + upper := b-c + gap_pos := sub_lt_sub_right hab c + +theorem source_matrix (ps : List Pair) (xs : List Bond) (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : + (source ps xs hp hn hb hl ha a b c hab).bonds.matrix = SourceBondLists.matrix ps.length xs := + (SourceBondLists.matrix_bonds ps.length (value ps.length xs) (bounded ps.length xs)).symm.trans + (matrix_eq ps.length xs hb) + +theorem source_energy (ps : List Pair) (xs : List Bond) (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : + realSourceGroundEnergy (source ps xs hp hn hb hl ha a b c hab) = + sourceMatrixBottom ps.length (SourceBondLists.matrix ps.length xs) := by + rw [← sourceMatrixBottom_eq_realSource,source_matrix] + rfl + +theorem source_energy_shift (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : + realSourceGroundEnergy (source ps xs hp hn hb hl ha a b c hab) = + sourceMatrixBottom ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1)-(c:ℝ) := by + rw [source_energy] + simpa only [Complex.ofReal_ratCast,add_sub_cancel_right] using + sourceMatrixBottom_shift ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1) (c:ℝ) + +theorem source_yes (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) + (he : sourceMatrixBottom ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1) ≤ (a:ℝ)) : + realSourceGroundEnergy (source ps xs hp hn hb hl ha a b c hab) ≤ + ((source ps xs hp hn hb hl ha a b c hab).lower:ℝ) := by + rw [source_energy_shift] + change _ ≤ ((a-c:ℚ):ℝ) + simpa only [Rat.cast_sub] using sub_le_sub_right he (c:ℝ) + +theorem source_no (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) + (he : (b:ℝ) ≤ sourceMatrixBottom ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1)) : + ((source ps xs hp hn hb hl ha a b c hab).upper:ℝ) ≤ + realSourceGroundEnergy (source ps xs hp hn hb hl ha a b c hab) := by + rw [source_energy_shift] + change ((b-c:ℚ):ℝ) ≤ _ + simpa only [Rat.cast_sub] using sub_le_sub_right he (c:ℝ) + +theorem source_polynomialPromise (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) (n k : ℕ) (hsize : n ≤ ps.length) + (hpos : ∀ p ∈ ps, (p.1:ℝ) ≤ (n+1:ℝ)^k ∧ (p.2:ℝ) ≤ (n+1:ℝ)^k) + {L : ℝ} (hL : 0 ≤ L) (hJ : ∀ e ∈ xs, |(e.2.2:ℝ)| ≤ L) + (hcoeff : xs.length*L ≤ (n+1:ℝ)^k) + (hgap : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (source ps xs hp hn hb hl ha a b c hab).binary.PolynomialPromise k := by + apply SquareLatticeHeisenberg.binary_polynomialPromise _ n k hsize + · intro i + let j : Fin ps.length := ⟨i.val,i.isLt⟩ + change |(((ps.get j).1:ℤ):ℝ)| ≤ _ ∧ |(((ps.get j).2:ℤ):ℝ)| ≤ _ + have hi := hpos _ (List.get_mem ps j) + push_cast + rw [abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ ((ps.get j).1:ℝ)), + abs_of_nonneg (Nat.cast_nonneg _ : (0:ℝ) ≤ ((ps.get j).2:ℝ))] + exact hi + · intro i + let j : Fin (value ps.length xs).length := ⟨i.val,i.isLt⟩ + change |(((value ps.length xs).get j).2.2:ℝ)| ≤ _ + have he := congrArg (fun e : Bond => |(e.2.2:ℝ)|) (value_get ps.length xs j) + exact he.le.trans ((weight_abs_le xs _ hL hJ).trans hcoeff) + · change ((n+1:ℝ)^k)⁻¹ ≤ ((b-c:ℚ):ℝ)-((a-c:ℚ):ℝ) + push_cast + linarith + +end ContinuumCoulomb.QuantumListLattice + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLatticeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLatticeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7293b2976035086fc6e0c233e6fa3ad348e0d46 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListLatticeProgram.lean @@ -0,0 +1,94 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListLattice +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMergeProgram + +namespace OAI + +/-! Literal source serialization from the computed coordinate and bond tapes. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListLattice +open ExactQuantumFactoring.BitStackProgram MediatorListProgram QuantumRouteCode + +abbrev Input := List Pair × (List Bond × (ℚ × (ℚ × ℚ))) +def inputCode : Input → List Bool := prodCode (listCode pairCode) + (prodCode (listCode bondCode) QuantumLatticeSerialization.thresholdCode) + +def packet (x : Input) : QuantumLatticeSerialization.Input := + (x.1.map qmaGridCoordinate,QuantumListMerge.value x.1.length x.2.1,x.2.2) +def value (x : Input) : BinaryHeisenberg := QuantumLatticeSerialization.value (packet x) + +noncomputable def coordinateProgram : Procedure pairCode QuantumLatticeSerialization.coordinateCode + qmaGridCoordinate := + (Procedure.natToInt.comp (Procedure.first Nat.bits Nat.bits)).pair + (Procedure.natToInt.comp (Procedure.second Nat.bits Nat.bits)) + +noncomputable def packetProgram : Procedure inputCode QuantumLatticeSerialization.inputCode packet := by + let ps := Procedure.first (listCode pairCode) + (prodCode (listCode bondCode) QuantumLatticeSerialization.thresholdCode) + let tail := Procedure.second (listCode pairCode) + (prodCode (listCode bondCode) QuantumLatticeSerialization.thresholdCode) + let xs := (Procedure.first (listCode bondCode) QuantumLatticeSerialization.thresholdCode).comp tail + let t := (Procedure.second (listCode bondCode) QuantumLatticeSerialization.thresholdCode).comp tail + let n := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength pairCode (0,0)).comp ps + let bonds := QuantumListMerge.valueProgram.comp (n.pair xs) + let points := (Procedure.listMap (0,0) (0,0) coordinateProgram).comp ps + exact points.pair (bonds.pair t) + +noncomputable def program : Procedure inputCode binaryHeisenbergCodec.encode value := + QuantumLatticeSerialization.program.comp packetProgram + +theorem value_source (ps : List Pair) (xs : List Bond) (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : + value (ps,xs,a,b,c)=(source ps xs hp hn hb hl ha a b c hab).binary := by + have hp' : List.ofFn (fun i : Fin ps.length => qmaGridCoordinate (ps.get i)) = + ps.map qmaGridCoordinate := by + simpa only [List.get_eq_getElem] using List.ofFn_getElem_eq_map ps qmaGridCoordinate + have he' : List.ofFn (fun i : Fin (QuantumListMerge.value ps.length xs).length => + QuantumLatticeSerialization.edge ((QuantumListMerge.value ps.length xs).get i)) = + (QuantumListMerge.value ps.length xs).map QuantumLatticeSerialization.edge := by + simpa only [List.get_eq_getElem] using + List.ofFn_getElem_eq_map (QuantumListMerge.value ps.length xs) QuantumLatticeSerialization.edge + change BinaryHeisenberg.mk _ _ _ _ = BinaryHeisenberg.mk _ _ _ _ + exact congrArg₂ (fun p e => BinaryHeisenberg.mk p e + (BinaryRational.ofRat (a-c)) (BinaryRational.ofRat (b-c))) hp'.symm he'.symm + +theorem value_valid (ps : List Pair) (xs : List Bond) (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) : (value (ps,xs,a,b,c)).Valid := by + rw [value_source ps xs hp hn hb hl ha a b c hab] + exact (source ps xs hp hn hb hl ha a b c hab).binary_valid + +theorem value_mem_yes (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) {k : ℕ} + (hpoly : (value (ps,xs,a,b,c)).PolynomialPromise k) + (he : sourceMatrixBottom ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1) ≤ (a:ℝ)) : + value (ps,xs,a,b,c) ∈ (sourceHeisenbergPromise k).yes := by + rw [value_source ps xs hp hn hb hl ha a b c hab] at hpoly ⊢ + exact SquareLatticeHeisenberg.binary_mem_yes _ hpoly + (source_yes ps xs hp hn hb hl ha a b c hab he) + +theorem value_mem_no (ps : List Pair) (xs : List Bond) + (hp : 0 < ps.length) (hn : ps.Nodup) + (hb : SourceBondLists.bounded ps.length xs) + (hl : ∀ e ∈ xs, e.1≠e.2.1) (ha : Adjacent ps xs hb) + (a b c : ℚ) (hab : a < b) {k : ℕ} + (hpoly : (value (ps,xs,a,b,c)).PolynomialPromise k) + (he : (b:ℝ) ≤ sourceMatrixBottom ps.length + (SourceBondLists.matrix ps.length xs+(c:ℂ) • 1)) : + value (ps,xs,a,b,c) ∈ (sourceHeisenbergPromise k).no := by + rw [value_source ps xs hp hn hb hl ha a b c hab] at hpoly ⊢ + exact SquareLatticeHeisenberg.binary_mem_no _ hpoly + (source_no ps xs hp hn hb hl ha a b c hab he) + +end ContinuumCoulomb.QuantumListLattice + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMerge.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMerge.lean new file mode 100644 index 0000000000000000000000000000000000000000..4308ec153e77c0899fecb3bc397ab23a2b769765 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMerge.lean @@ -0,0 +1,81 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListGraph +import Mathlib.Data.List.Nodup +import Mathlib.Data.List.ProdSigma + +namespace OAI + +/-! Canonical merging of a finite bond tape. A quadratic table of vertex pairs +gives a deterministic order and retains exactly the pairs occurring in the input. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListMerge +open MediatorListProgram + +abbrev Pair := ℕ × ℕ + +def ordered (e : Bond) : Pair := (min e.1 e.2.1,max e.1 e.2.1) +def pairs (n : ℕ) : List Pair := (List.range n).product (List.range n) +def support (n : ℕ) (xs : List Bond) : List Pair := + (pairs n).filter (fun p => decide (p ∈ xs.map ordered)) +def weight (xs : List Bond) (p : Pair) : ℚ := + (xs.map (fun e => if ordered e=p then e.2.2 else 0)).sum +def value (n : ℕ) (xs : List Bond) : List Bond := + (support n xs).map (fun p => (p.1,p.2,weight xs p)) + +theorem pairs_nodup (n : ℕ) : (pairs n).Nodup := + List.nodup_range.product List.nodup_range + +theorem pairs_length (n : ℕ) : (pairs n).length=n*n := by + exact (List.length_product (List.range n) (List.range n)).trans + (congrArg₂ (·*·) List.length_range List.length_range) + +theorem support_nodup (n : ℕ) (xs : List Bond) : (support n xs).Nodup := + (pairs_nodup n).filter _ + +theorem value_length (n : ℕ) (xs : List Bond) : (value n xs).length≤n*n := by + simpa only [value,List.length_map,support,pairs_length] using + ((List.length_filter_le (fun p => decide (p ∈ xs.map ordered)) (pairs n))) + +theorem ordered_bounded {n : ℕ} {e : Bond} (h : e.1 if p=q then z else 0)).sum=z := by + induction ps with + | nil => simp at hp + | cons q qs ih => + obtain ⟨hq,ht⟩ := List.nodup_cons.mp hn + rcases List.mem_cons.mp hp with rfl | hp + · have hz : (qs.map (fun q => if p=q then z else 0)).sum=0 := by + apply List.sum_eq_zero + intro a ha + obtain ⟨q,hq',rfl⟩ := List.mem_map.mp ha + have hne : p≠q := by + intro he + subst q + exact hq hq' + exact ite_eq_right hne + simp [hz] + · have hne : p≠q := fun he => hq (he ▸ hp) + simpa only [List.map_cons,List.sum_cons,ite_eq_right hne,zero_add] using ih ht hp + +private theorem sum_swap {α β M : Type} [AddCommMonoid M] + (xs : List α) (ys : List β) (f : α → β → M) : + (xs.map (fun x => (ys.map (f x)).sum)).sum = + (ys.map (fun y => (xs.map (fun x => f x y)).sum)).sum := by + induction xs with + | nil => simp + | cons x xs ih => + simpa only [List.map_cons,List.sum_cons,List.sum_map_add] using + (congrArg (fun z => (ys.map (f x)).sum+z) ih) + +theorem ordered_matrix (n : ℕ) (e : Bond) (he : e.1 (e.2.2:ℂ) • a) + (qmaHeisenberg_symm n ⟨e.2.1,he.2⟩ ⟨e.1,he.1⟩) + +private theorem pairMatrix_add (n : ℕ) (p : Pair) (a b : ℚ) : + SourceBondLists.bondMatrix n (p.1,p.2,a+b) = + SourceBondLists.bondMatrix n (p.1,p.2,a)+SourceBondLists.bondMatrix n (p.1,p.2,b) := by + unfold SourceBondLists.bondMatrix + split_ifs <;> simp only [Rat.cast_add,add_smul,zero_add] + +private theorem pairMatrix_contribution (n : ℕ) (p : Pair) (e : Bond) + (he : e.1 if ordered e=p then SourceBondLists.bondMatrix n e else 0)).sum := by + induction xs with + | nil => exact SourceBondLists.bondMatrix_zero n _ rfl + | cons e xs ih => + have he := hb e (List.mem_cons_self) + have ht : SourceBondLists.bounded n xs := fun a ha => hb a (List.mem_cons_of_mem _ ha) + change SourceBondLists.bondMatrix n + (p.1,p.2,(if ordered e=p then e.2.2 else 0)+weight xs p) = _ + rw [pairMatrix_add,pairMatrix_contribution n p e he,ih ht] + rfl + +theorem matrix_eq (n : ℕ) (xs : List Bond) (hb : SourceBondLists.bounded n xs) : + SourceBondLists.matrix n (value n xs)=SourceBondLists.matrix n xs := by + have hm : (support n xs).map (fun p => SourceBondLists.bondMatrix n (p.1,p.2,weight xs p)) = + (support n xs).map (fun p => (xs.map + (fun e => if ordered e=p then SourceBondLists.bondMatrix n e else 0)).sum) := by + apply List.map_congr_left + intro p _ + exact matrix_row n xs hb p + simp only [SourceBondLists.matrix,value,List.map_map,Function.comp_def] + rw [hm,sum_swap] + apply congrArg List.sum + apply List.map_congr_left + intro e he + exact sum_indicator (support n xs) (support_nodup n xs) (ordered e) + ((mem_support hb _).mpr (List.mem_map.mpr ⟨e,he,rfl⟩)) _ + +end ContinuumCoulomb.QuantumListMerge + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..083c844e7ce0d77c686e9149c3a3e59ac5bbdcc3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProgram.lean @@ -0,0 +1,106 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMerge +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumFiniteMembership +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawFamilyProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Programs.RationalSumProgram + +namespace OAI + +/-! Literal polynomial pair-table enumeration and rational accumulation for +canonical bond merging. The vertex count is represented in unary. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListMerge +open ExactQuantumFactoring.BitStackProgram MediatorListProgram QuantumRouteCode + +abbrev Input := ℕ × List Bond +def inputCode : Input → List Bool := prodCode unaryCode (listCode bondCode) + +noncomputable def orderedProgram : Procedure bondCode pairCode ordered := by + let a := Procedure.first Nat.bits (prodCode Nat.bits ratCode) + let b := (Procedure.first Nat.bits ratCode).comp + (Procedure.second Nat.bits (prodCode Nat.bits ratCode)) + let h := Procedure.binaryLe.comp (a.pair b) + exact ((Procedure.conditional h a b).pair (Procedure.conditional h b a)).congrFun (by + intro e + by_cases he : e.1 ≤ e.2.1 + · simp [ordered,he] + · have hge : e.2.1 ≤ e.1 := by omega + simp [ordered,he,hge]) + +noncomputable def rowProgram : Procedure (prodCode unaryCode Nat.bits) (listCode pairCode) + (fun x => (List.range x.1).map (fun j => (x.2,j))) := + Procedure.tabulate (f := fun i j => (i,j)) (0,0) + ((Procedure.second unaryCode Nat.bits).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode Nat.bits))) + +noncomputable def pairsProgram : Procedure unaryCode (listCode pairCode) pairs := by + let step := rowProgram.comp ((Procedure.second unaryCode unaryCode).pair + (Procedure.unaryToBits.comp (Procedure.first unaryCode unaryCode))) + let table := (Procedure.tabulate (f := fun n i => (List.range n).map (fun j => (i,j))) [] step).comp + ((Procedure.identity unaryCode).pair (Procedure.identity unaryCode)) + exact ((QuantumRawExchange.flattenProgram pairCode (0,0)).comp table).congrFun (by + intro n + simp only [Function.comp_apply,pairs,List.product,List.flatMap_def,id_eq]) + +private noncomputable def filterProgram : + Procedure (prodCode (listCode pairCode) (listCode pairCode)) (listCode pairCode) + (fun x => x.2.filter (fun p => decide (p ∈ x.1))) := by + let key := Procedure.second (listCode pairCode) pairCode + let keys := Procedure.first (listCode pairCode) pairCode + let member := QuantumFiniteMembership.pairMemberProgram.comp (key.pair keys) + let one := (Procedure.listCons pairCode).comp + (key.pair (Procedure.constant _ (listCode pairCode) [])) + let chunk : Procedure (prodCode (listCode pairCode) pairCode) (listCode pairCode) + (fun x => if x.2 ∈ x.1 then [x.2] else []) := + (Procedure.conditional member one (Procedure.constant _ (listCode pairCode) [])).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq]) + let chunks := Procedure.listMapWith (ea := listCode pairCode) (eb := pairCode) + (ec := listCode pairCode) (f := fun keys p => if p ∈ keys then [p] else []) (0,0) [] chunk + refine ((QuantumRawExchange.flattenProgram pairCode (0,0)).comp chunks).congrFun ?_ + intro x + rcases x with ⟨keys,ps⟩ + induction ps with + | nil => rfl + | cons p ps ih => + by_cases h : p ∈ keys <;> simpa [h] using ih + +noncomputable def supportProgram : Procedure inputCode (listCode pairCode) + (fun x => support x.1 x.2) := + filterProgram.comp + (((Procedure.listMap zeroBond (0,0) orderedProgram).comp (Procedure.second _ _)).pair + (pairsProgram.comp (Procedure.first _ _))) + +noncomputable def weightProgram : Procedure (prodCode pairCode (listCode bondCode)) ratCode + (fun x => weight x.2 x.1) := by + let p := Procedure.first pairCode bondCode + let e := Procedure.second pairCode bondCode + let h := QuantumFiniteMembership.pairEqProgram.comp ((orderedProgram.comp e).pair p) + let w := (Procedure.second Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp e) + let one : Procedure (prodCode pairCode bondCode) ratCode + (fun x => if ordered x.2=x.1 then x.2.2.2 else 0) := + (Procedure.conditional h w (Procedure.constant _ ratCode 0)).congrFun (by + intro x + simp only [Function.comp_apply,decide_eq_true_eq]) + exact RationalSumProgram.sumProgram.comp + (Procedure.listMapWith (ea := pairCode) (eb := bondCode) (ec := ratCode) + (f := fun p e => if ordered e=p then e.2.2 else 0) zeroBond 0 one) + +noncomputable def valueProgram : Procedure inputCode (listCode bondCode) + (fun x => value x.1 x.2) := by + let xs := Procedure.first (listCode bondCode) pairCode + let p := Procedure.second (listCode bondCode) pairCode + let a := (Procedure.first Nat.bits Nat.bits).comp p + let b := (Procedure.second Nat.bits Nat.bits).comp p + let w := weightProgram.comp (p.pair xs) + let entry := a.pair (b.pair w) + exact (Procedure.listMapWith (ea := listCode bondCode) (eb := pairCode) (ec := bondCode) + (f := fun xs p => (p.1,p.2,weight xs p)) (0,0) zeroBond entry).comp + ((Procedure.second _ _).pair supportProgram) + +end ContinuumCoulomb.QuantumListMerge + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProperties.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProperties.lean new file mode 100644 index 0000000000000000000000000000000000000000..d20c172e36875496432b10fed8cdfeb2c89f9b48 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListMergeProperties.lean @@ -0,0 +1,73 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListMerge + +namespace OAI + +/-! The merged tape has one strictly ordered edge per occurring vertex pair, +and its coefficients grow by at most the original edge count. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListMerge +open MediatorListProgram + +def supportIndex (n : ℕ) (xs : List Bond) (i : Fin (value n xs).length) : + Fin (support n xs).length := ⟨i.val,by simpa only [value,List.length_map] using i.isLt⟩ + +theorem value_pair (n : ℕ) (xs : List Bond) (i : Fin (value n xs).length) : + (((value n xs).get i).1, ((value n xs).get i).2.1) = + (support n xs).get (supportIndex n xs i) := by + exact congrArg (fun e : Bond => (e.1,e.2.1)) (value_get n xs i) + +theorem value_pair_injective (n : ℕ) (xs : List Bond) : + Function.Injective (fun i : Fin (value n xs).length => + (((value n xs).get i).1,((value n xs).get i).2.1)) := by + intro i j h + have hp := (value_pair n xs i).symm.trans (h.trans (value_pair n xs j)) + exact Fin.ext (congrArg (fun k : Fin (support n xs).length => k.val) + ((support_nodup n xs).injective_get hp)) + +theorem value_ordered {n : ℕ} {xs : List Bond} + (h : ∀ e ∈ xs, e.1≠e.2.1) : ∀ e ∈ value n xs, e.1 simp [weight] + | cons e xs ih => + have he := h e List.mem_cons_self + have ht := ih (fun a ha => h a (List.mem_cons_of_mem _ ha)) + have hone : |((if ordered e=p then e.2.2 else 0:ℚ):ℝ)| ≤ L := by + by_cases hp : ordered e=p + · simpa only [ite_eq_left hp] using he + · simpa only [ite_eq_right hp,Rat.cast_zero,abs_zero] using hL + change |(((if ordered e=p then e.2.2 else 0:ℚ)+weight xs p:ℚ):ℝ)| ≤ _ + rw [Rat.cast_add] + have ha := abs_add_le ((if ordered e=p then e.2.2 else 0:ℚ):ℝ) (weight xs p:ℝ) + simp only [List.length_cons,Nat.cast_add,Nat.cast_one] + nlinarith + +end ContinuumCoulomb.QuantumListMerge + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathAccuracy.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathAccuracy.lean new file mode 100644 index 0000000000000000000000000000000000000000..44e97e25728bf2ccd995828d39db556b1b2997cd --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathAccuracy.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathStep + +namespace OAI + +/-! The literal bond-list subdivision has the same full-space ground-energy +estimate as the calibrated singlet construction. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListPathStep +open Matrix +open scoped BigOperators + +def encodedInput {n m r : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (J : Fin r → ℚ) (even : Bool) (N c : ℚ) : Input := + ((n,even,N,c),(List.ofFn fun i => ((left i).val,(right i).val,w i), + List.ofFn fun i => ((site i 0).val,(site i 1).val,J i))) + +theorem scale_cast {n m r : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (J : Fin r → ℚ) (even : Bool) (N c : ℚ) : + ((parameters (encodedInput left right w site J even N c)).2.2:ℝ) = + qmaRoutingScale (3*∑ i, (1+2*|(J i:ℝ)|)) + ((3*(∑ i, |(w i:ℝ)|)+|(c:ℝ)|)+4*∑ i, (1+|(J i:ℝ)|)^2) N := by + simp only [parameters,scaleInput,encodedInput,QuantumPathScaleProgram.value, + QuantumPathScaleProgram.active,QuantumPathScaleProgram.correction,QuantumPathScaleProgram.base, + List.map_ofFn,List.sum_ofFn,Function.comp_apply,QuantumPathScaleProgram.linearCost, + QuantumPathScaleProgram.squareCost,qmaRoutingScale] + push_cast + rfl + +theorem encoded_matrix {n m r : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (J : Fin r → ℚ) (even : Bool) (N c : ℚ) : + let x := encodedInput left right w site J even N c + SourceBondLists.matrix (n+r*2) (bonds x)+(constant x:ℂ) • 1 = + qmaPathsGraph left right (fun i => (w i:ℝ)) c (parameters x).2.2 site + (fun _ => even) (fun i => (J i:ℝ)) := by + simpa only [encodedInput,count,bonds,constant,parameters,List.length_ofFn] using + QuantumListPathProgram.fixed_step_matrix left right w site even + (parameters (encodedInput left right w site J even N c)).2.2 c J + +theorem source_matrix {n m r : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (J : Fin r → ℚ) (c : ℚ) : + SourceBondLists.matrix n ((List.ofFn fun i => ((left i).val,(right i).val,w i))++ + List.ofFn fun i => ((site i 0).val,(site i 1).val,J i))+(c:ℂ) • 1 = + qmaExchangeMatrix left right (fun i => (w i:ℝ)) c+ + ∑ i, (J i:ℂ) • sourceHeisenbergMatrix n (site i 0) (site i 1) := by + simp only [SourceBondLists.matrix,List.map_append,List.sum_append] + change SourceBondLists.matrix n (List.ofFn fun i => ((left i).val,(right i).val,w i))+ + SourceBondLists.matrix n (List.ofFn fun i => ((site i 0).val,(site i 1).val,J i))+ + (c:ℂ) • 1 = _ + rw [QuantumListPathProgram.matrix_ofFn,QuantumListPathProgram.matrix_ofFn] + simp only [qmaExchangeMatrix,Complex.ofReal_ratCast] + abel + +theorem energy_error {n m r : ℕ} (left right : Fin m → Fin n) + (hne : ∀ i, left i ≠ right i) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (hsite : ∀ i, Function.Injective (site i)) + (J : Fin r → ℚ) (even : Bool) {N : ℚ} (hN : 0 < N) (c : ℚ) : + let x := encodedInput left right w site J even N c + |sourceMatrixBottom (count x) (SourceBondLists.matrix (count x) (bonds x)+(constant x:ℂ) • 1)- + sourceMatrixBottom n (SourceBondLists.matrix n (x.2.1++x.2.2)+(c:ℂ) • 1)| ≤ 1/(N:ℝ) := by + dsimp only + have hc : count (encodedInput left right w site J even N c) = n+r*2 := by + simp only [count,encodedInput,List.length_ofFn] + have hs : SourceBondLists.matrix n + ((encodedInput left right w site J even N c).2.1++ + (encodedInput left right w site J even N c).2.2)+(c:ℂ) • 1 = + qmaExchangeMatrix left right (fun i => (w i:ℝ)) c+ + ∑ i, (J i:ℂ) • sourceHeisenbergMatrix n (site i 0) (site i 1) := + source_matrix left right w site J c + rw [hc,encoded_matrix,hs,scale_cast] + exact qmaPathsGraph_accuracy left right hne (fun i => (w i:ℝ)) c site hsite + (fun _ => even) (fun i => (J i:ℝ)) (by exact_mod_cast hN) + +end ContinuumCoulomb.QuantumListPathStep + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c479214f3c3af5705186ca482f53d12f88b9b37 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathInput.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathAccuracy + +namespace OAI + +/-! The subdivision guarantee for arbitrary valid input tapes, with no +assumption that their bond lists came from a chosen abstract edge enumeration. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListPathStep +open MediatorListProgram + +theorem bonds_list {n : ℕ} (xs : List Bond) (hb : SourceBondLists.bounded n xs) : + (List.ofFn fun i => (((SourceBondLists.bonds n xs hb).left i).val, + ((SourceBondLists.bonds n xs hb).right i).val, + (SourceBondLists.bonds n xs hb).weight i)) = xs := by + exact List.ofFn_get xs + +theorem input_of_bonds (x : Input) (hk : SourceBondLists.bounded x.1.1 x.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) : + encodedInput (SourceBondLists.bonds x.1.1 x.2.1 hk).left + (SourceBondLists.bonds x.1.1 x.2.1 hk).right + (SourceBondLists.bonds x.1.1 x.2.1 hk).weight + (fun i => ![(SourceBondLists.bonds x.1.1 x.2.2 hs).left i, + (SourceBondLists.bonds x.1.1 x.2.2 hs).right i]) + (SourceBondLists.bonds x.1.1 x.2.2 hs).weight x.1.2.1 x.1.2.2.1 x.1.2.2.2 = x := by + unfold encodedInput + dsimp only [Matrix.cons_val_zero,Matrix.cons_val_one] + rw [bonds_list,bonds_list] + +theorem energy_error_input (x : Input) (hk : SourceBondLists.bounded x.1.1 x.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) + (hnk : ∀ e ∈ x.2.1, e.1 ≠ e.2.1) (hns : ∀ e ∈ x.2.2, e.1 ≠ e.2.1) + (hN : 0 < x.1.2.2.1) : + |sourceMatrixBottom (count x) (SourceBondLists.matrix (count x) (bonds x)+(constant x:ℂ) • 1)- + sourceMatrixBottom x.1.1 (SourceBondLists.matrix x.1.1 (x.2.1++x.2.2)+ + (x.1.2.2.2:ℂ) • 1)| ≤ 1/(x.1.2.2.1:ℝ) := by + let k := SourceBondLists.bonds x.1.1 x.2.1 hk + let s := SourceBondLists.bonds x.1.1 x.2.2 hs + have hk' : ∀ i, k.left i ≠ k.right i := SourceBondLists.bonds_noLoops _ _ hk hnk + have hs' : ∀ i, Function.Injective (![s.left i,s.right i] : Fin 2 → Fin x.1.1) := by + intro i a b hab + have hi : s.left i ≠ s.right i := SourceBondLists.bonds_noLoops _ _ hs hns i + fin_cases a <;> fin_cases b <;> dsimp at hab ⊢ + all_goals simp_all + have h := energy_error k.left k.right hk' k.weight (fun i => ![s.left i,s.right i]) hs' + s.weight x.1.2.1 hN x.1.2.2.2 + rw [input_of_bonds x hk hs] at h + exact h + +theorem graph_energy_error (x : Input) (hk : SourceBondLists.bounded x.1.1 x.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) + (hnk : ∀ e ∈ x.2.1, e.1 ≠ e.2.1) (hns : ∀ e ∈ x.2.2, e.1 ≠ e.2.1) + (hN : 0 < x.1.2.2.1) : + |(graph x hk hs hnk).energy-sourceMatrixBottom x.1.1 + (SourceBondLists.matrix x.1.1 (x.2.1++x.2.2)+(x.1.2.2.2:ℂ) • 1)| ≤ 1/(x.1.2.2.1:ℝ) := by + rw [graph,QuantumListGraph.ofBonds_energy] + exact energy_error_input x hk hs hnk hns hN + +end ContinuumCoulomb.QuantumListPathStep + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathMatrix.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..0aed110a1c526f3c5efd865c749793da22fb245c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathMatrix.lean @@ -0,0 +1,159 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathProgram + +namespace OAI + +/-! Matrix semantics of the literal path-subdivision block. Its fresh labels +are exactly the two ordinary-spin labels in the singlet gadget. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListPathProgram +open Matrix MediatorGraph MediatorListProgram +open scoped BigOperators + +def physicalLeft {n r : ℕ} (i : Fin r) (site : Fin 2 → Fin n) : Fin 3 → Fin (n+r*2) := + ![fresh n r i 0,old n r (site 0),old n r (site 1)] + +def physicalRight {n r : ℕ} (i : Fin r) (even : Bool) : Fin 3 → Fin (n+r*2) := + ![fresh n r i 1,fresh n r i 0,fresh n r i (qmaPathMember even 1)] + +private theorem old_value (n r : ℕ) (i : Fin n) : (old n r i).val = i.val := rfl + +private theorem fresh_value (n r : ℕ) (i : Fin r) (a : Fin 2) : + (fresh n r i a).val = n+2*i.val+a.val := by + change n+(a.val+2*i.val) = _ + omega + +theorem bond_eq {n r : ℕ} (i : Fin r) (site : Fin 2 → Fin n) (even : Bool) (R J : ℚ) + (k : Fin 3) : + bond ((n,even,R),i.val,(site 0).val,(site 1).val,J) k = + ((physicalLeft i site k).val,(physicalRight (n := n) i even k).val, + QuantumPathCode.coefficients (even,R,J) k.castSucc) := by + cases even <;> fin_cases k <;> + simp [bond,left,right,coefficient,physicalLeft,physicalRight,qmaPathMember,fresh_value,old_value] + +theorem block_matrix {n r : ℕ} (i : Fin r) (site : Fin 2 → Fin n) (even : Bool) (R J : ℚ) : + SourceBondLists.matrix (n+r*2) (block ((n,even,R),i.val,(site 0).val,(site 1).val,J)) = + ∑ k : Fin 3, (QuantumPathCode.coefficients (even,R,J) k.castSucc:ℂ) • + sourceHeisenbergMatrix (n+r*2) (physicalLeft i site k) (physicalRight i even k) := by + simp only [SourceBondLists.matrix,block,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + apply Finset.sum_congr rfl + intro k _ + rw [bond_eq,SourceBondLists.bondMatrix,dite_eq_left + ⟨(physicalLeft i site k).isLt,(physicalRight i even k).isLt⟩] + +theorem offset_cast (n i : ℕ) (site : Fin 2 → ℕ) (even : Bool) (R J : ℚ) : + (offset ((n,even,R),i,site 0,site 1,J):ℝ) = qmaPathOffset (J:ℝ)+3*(R:ℝ)^2 := + QuantumPathCode.coefficients_offset (even,R,J) + +theorem indexed_ofFn {m : ℕ} (p : Parameters) (f : Fin m → Bond) (i : Fin m) : + indexed (i.val,(p,List.ofFn f)) = (p,i.val,f i) := by + unfold indexed + rw [List.headD_eq_head?_getD,List.head?_drop, + List.getElem?_eq_getElem (by simpa only [List.length_ofFn] using i.isLt)] + simp only [List.getElem_ofFn,Option.getD_some] + +theorem family_ofFn {m : ℕ} (p : Parameters) (f : Fin m → Bond) : + family (p,List.ofFn f) = (List.ofFn fun i => block (p,i.val,f i)).flatten := by + have hm (g : ℕ → List Bond) : + (List.range m).map g = List.ofFn (fun i : Fin m => g i.val) := by + simpa only [List.length_range,List.getElem_range,Fin.val_cast] using + (List.ofFn_getElem_eq_map (List.range m) g).symm + unfold family + rw [List.length_ofFn,hm] + apply congrArg List.flatten + apply congrArg (fun g : Fin m → List Bond => List.ofFn g) + funext i + rw [indexed_ofFn] + +theorem matrix_flatten (n : ℕ) (xss : List (List Bond)) : + SourceBondLists.matrix n xss.flatten = (xss.map (SourceBondLists.matrix n)).sum := by + simp only [SourceBondLists.matrix,List.map_flatten,List.sum_flatten,List.map_map, + Function.comp_def] + rfl + +theorem family_matrix {n r : ℕ} (site : Fin r → Fin 2 → Fin n) (even : Bool) + (R : ℚ) (J : Fin r → ℚ) : + SourceBondLists.matrix (n+r*2) + (family ((n,even,R),List.ofFn fun i => ((site i 0).val,(site i 1).val,J i))) = + ∑ i : Fin r, ∑ k : Fin 3, (QuantumPathCode.coefficients (even,R,J i) k.castSucc:ℂ) • + sourceHeisenbergMatrix (n+r*2) (physicalLeft i (site i) k) (physicalRight i even k) := by + rw [family_ofFn,matrix_flatten] + simp only [List.map_ofFn,List.sum_ofFn,Function.comp_apply] + exact Finset.sum_congr rfl (fun i _ => block_matrix i (site i) even R (J i)) + +theorem physical_sum {n r : ℕ} (i : Fin r) (site : Fin 2 → Fin n) (even : Bool) + (R J : ℚ) : + (∑ k : Fin 3, (QuantumPathCode.coefficients (even,R,J) k.castSucc:ℂ) • + sourceHeisenbergMatrix (n+r*2) (physicalLeft i site k) (physicalRight i even k)) = + ((R:ℝ)^2:ℂ) • sourceHeisenbergMatrix (n+r*2) (fresh n r i 0) (fresh n r i 1)+ + ∑ a : Fin 2, (qmaPathAmplitude even (R:ℝ) (J:ℝ) a:ℂ) • + sourceHeisenbergMatrix (n+r*2) (old n r (site a)) + (fresh n r i (qmaPathMember even a)) := by + cases even <;> simp [Fin.sum_univ_succ,physicalLeft,physicalRight, + QuantumPathCode.coefficients,qmaPathAmplitude,qmaPathMember,add_assoc,Complex.ofReal_ratCast] <;> + ext s t <;> + simp only [Matrix.add_apply,Matrix.neg_apply,Matrix.smul_apply,smul_eq_mul, + Complex.real_smul,Complex.ofReal_mul,Complex.ofReal_ofNat,Complex.ofReal_ratCast] + +theorem familyOffset_cast {n r : ℕ} (site : Fin r → Fin 2 → Fin n) (even : Bool) + (R : ℚ) (J : Fin r → ℚ) : + (familyOffset ((n,even,R),List.ofFn fun i => ((site i 0).val,(site i 1).val,J i)):ℝ) = + (∑ i : Fin r, qmaPathOffset (J i:ℝ))+3*r*(R:ℝ)^2 := by + simp only [familyOffset,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + calc + _ = ∑ i : Fin r, (offset ((n,even,R),0,(site i 0).val,(site i 1).val,J i):ℝ) := by + push_cast + rfl + _ = ∑ i : Fin r, (qmaPathOffset (J i:ℝ)+3*(R:ℝ)^2) := by + apply Finset.sum_congr rfl + intro i _ + exact offset_cast n 0 (fun a => (site i a).val) even R (J i) + _ = _ := by + rw [Finset.sum_add_distrib] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + ring + +theorem matrix_ofFn {n m : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) : + SourceBondLists.matrix n (List.ofFn fun i => ((left i).val,(right i).val,w i)) = + ∑ i : Fin m, (w i:ℂ) • sourceHeisenbergMatrix n (left i) (right i) := by + simp only [SourceBondLists.matrix,List.map_ofFn,List.sum_ofFn,Function.comp_apply] + apply Finset.sum_congr rfl + intro i _ + rw [SourceBondLists.bondMatrix,dite_eq_left ⟨(left i).isLt,(right i).isLt⟩] + +theorem retained_matrix {n m : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) (r : ℕ) : + SourceBondLists.matrix (n+r*2) (List.ofFn fun i => ((left i).val,(right i).val,w i)) = + ∑ i : Fin m, (w i:ℂ) • sourceHeisenbergMatrix (n+r*2) + (old n r (left i)) (old n r (right i)) := + matrix_ofFn (fun i => old n r (left i)) (fun i => old n r (right i)) w + +theorem fixed_step_matrix {n m r : ℕ} (left right : Fin m → Fin n) (w : Fin m → ℚ) + (site : Fin r → Fin 2 → Fin n) (even : Bool) (R c : ℚ) (J : Fin r → ℚ) : + let selected := List.ofFn fun i => ((site i 0).val,(site i 1).val,J i) + SourceBondLists.matrix (n+r*2) + ((List.ofFn fun i => ((left i).val,(right i).val,w i))++family ((n,even,R),selected))+ + ((c+familyOffset ((n,even,R),selected):ℚ):ℂ) • 1 = + qmaPathsGraph left right (fun i => (w i:ℝ)) c R site (fun _ => even) (fun i => (J i:ℝ)) := by + dsimp only + have hoff : + ((c+familyOffset ((n,even,R),List.ofFn fun i => ((site i 0).val,(site i 1).val,J i)):ℚ):ℂ) = + ((((c:ℝ)+∑ i : Fin r, qmaPathOffset (J i:ℝ))+3*(r:ℝ)*(R:ℝ)^2:ℝ):ℂ) := by + calc + _ = ((c:ℝ)+(familyOffset ((n,even,R),List.ofFn fun i => + ((site i 0).val,(site i 1).val,J i)):ℝ):ℂ) := by simp + _ = _ := by rw [familyOffset_cast]; push_cast; ring + simp only [SourceBondLists.matrix,List.map_append,List.sum_append] + change (SourceBondLists.matrix (n+r*2) (List.ofFn fun i => + ((left i).val,(right i).val,w i))+SourceBondLists.matrix (n+r*2) + (family ((n,even,R),List.ofFn fun i => ((site i 0).val,(site i 1).val,J i))))+_ = _ + rw [retained_matrix,family_matrix,hoff] + simp_rw [physical_sum] + simp only [qmaPathsGraph,qmaExchangeMatrix,Fintype.sum_sum_type,Fintype.sum_prod_type, + qmaParallelGraphLeft,qmaParallelGraphRight,qmaParallelGraphWeight, + Finset.sum_add_distrib,Complex.ofReal_pow,Complex.ofReal_ratCast] + +end ContinuumCoulomb.QuantumListPathProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..109a753c78ebb3f869020d5d5f3727886216c873 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathProgram.lean @@ -0,0 +1,165 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListGraph +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathScaleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRawFamilyProgram + +namespace OAI + +/-! Literal three-edge output for one selected path subdivision. Fresh spin +labels are assigned in the input list order; both path parities are supported. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListPathProgram +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev Parameters := ℕ × (Bool × ℚ) +def parametersCode : Parameters → List Bool := + prodCode unaryCode (prodCode Procedure.boolCode ratCode) +abbrev Input := Parameters × (ℕ × Bond) +def inputCode : Input → List Bool := + prodCode parametersCode (prodCode unaryCode bondCode) + +def left (x : Input) : Fin 3 → ℕ := + ![x.1.1+2*x.2.1,x.2.2.1,x.2.2.2.1] +def right (x : Input) : Fin 3 → ℕ := + ![x.1.1+2*x.2.1+1,x.1.1+2*x.2.1, + x.1.1+2*x.2.1+(if x.1.2.1 then 0 else 1)] +def coefficient (x : Input) (k : Fin 4) : ℚ := + QuantumPathCode.coefficients (x.1.2.1,x.1.2.2,x.2.2.2.2) k +def bond (x : Input) (k : Fin 3) : Bond := + (left x k,right x k,coefficient x k.castSucc) +def block (x : Input) : List Bond := List.ofFn (bond x) +def offset (x : Input) : ℚ := coefficient x 3 + +noncomputable opaque countProgram : Procedure inputCode Nat.bits (fun x => x.1.1) := + Procedure.unaryToBits.comp ((Procedure.first unaryCode + (prodCode Procedure.boolCode ratCode)).comp (Procedure.first _ _)) +noncomputable opaque indexProgram : Procedure inputCode Nat.bits (fun x => x.2.1) := + Procedure.unaryToBits.comp ((Procedure.first unaryCode bondCode).comp (Procedure.second _ _)) +noncomputable opaque sourceProgram : Procedure inputCode bondCode (fun x => x.2.2) := + (Procedure.second unaryCode bondCode).comp (Procedure.second _ _) +noncomputable opaque baseProgram : Procedure inputCode Nat.bits (fun x => x.1.1+2*x.2.1) := + Procedure.binaryAdd.comp (countProgram.pair + (Procedure.binaryMul.comp ((Procedure.constant inputCode Nat.bits 2).pair indexProgram))) +noncomputable opaque nextProgram : Procedure inputCode Nat.bits (fun x => x.1.1+2*x.2.1+1) := + Procedure.binaryAdd.comp (baseProgram.pair (Procedure.constant inputCode Nat.bits 1)) +noncomputable opaque parityProgram : Procedure inputCode Procedure.boolCode (fun x => x.1.2.1) := + (Procedure.first Procedure.boolCode ratCode).comp + ((Procedure.second unaryCode (prodCode Procedure.boolCode ratCode)).comp (Procedure.first _ _)) + +noncomputable opaque leftProgram (k : Fin 3) : Procedure inputCode Nat.bits (fun x => left x k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact baseProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact (Procedure.first Nat.bits (prodCode Nat.bits ratCode)).comp sourceProgram + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact (Procedure.first Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp sourceProgram) + +noncomputable opaque rightProgram (k : Fin 3) : Procedure inputCode Nat.bits (fun x => right x k) := by + refine Fin.cases ?_ (fun k => ?_) k + · exact nextProgram + refine Fin.cases ?_ (fun k => ?_) k + · exact baseProgram + refine Fin.cases ?_ (fun k => Fin.elim0 k) k + exact (Procedure.conditional parityProgram baseProgram nextProgram).congrFun (by + intro x + cases h : x.1.2.1 <;> simp [right,h]) + +noncomputable opaque coefficientProgram (k : Fin 4) : + Procedure inputCode ratCode (fun x => coefficient x k) := by + let r : Procedure inputCode ratCode (fun x => x.1.2.2) := + (Procedure.second Procedure.boolCode ratCode).comp + ((Procedure.second unaryCode (prodCode Procedure.boolCode ratCode)).comp (Procedure.first _ _)) + let j : Procedure inputCode ratCode (fun x => x.2.2.2.2) := + (Procedure.second Nat.bits ratCode).comp + ((Procedure.second Nat.bits (prodCode Nat.bits ratCode)).comp sourceProgram) + exact (QuantumPathCode.coefficientProgram k).comp (parityProgram.pair (r.pair j)) + +noncomputable opaque bondProgram (k : Fin 3) : Procedure inputCode bondCode (fun x => bond x k) := + (leftProgram k).pair ((rightProgram k).pair (coefficientProgram k.castSucc)) +noncomputable opaque blockProgram : Procedure inputCode (listCode bondCode) block := + QuantumRawExchange.fixedListProgram inputCode bondCode 3 (fun k x => bond x k) bondProgram +noncomputable opaque offsetProgram : Procedure inputCode ratCode offset := coefficientProgram 3 + +abbrev FamilyInput := Parameters × List Bond +def familyCode : FamilyInput → List Bool := prodCode parametersCode (listCode bondCode) +def indexed (x : ℕ × FamilyInput) : Input := + (x.2.1,x.1,(x.2.2.drop x.1).headD zeroBond) +def family (x : FamilyInput) : List Bond := + ((List.range x.2.length).map (fun i => block (indexed (i,x)))).flatten +def familyOffset (x : FamilyInput) : ℚ := + (x.2.map (fun e => offset (x.1,0,e))).sum + +noncomputable opaque indexedProgram : + Procedure (prodCode unaryCode familyCode) inputCode indexed := by + let i := Procedure.first unaryCode familyCode + let x := Procedure.second unaryCode familyCode + let p := (Procedure.first parametersCode (listCode bondCode)).comp x + let xs := (Procedure.second parametersCode (listCode bondCode)).comp x + let b := (Procedure.listGet bondCode zeroBond).comp ((Procedure.unaryToBits.comp i).pair xs) + exact p.pair (i.pair b) + +noncomputable opaque familyProgram : Procedure familyCode (listCode bondCode) family := by + let n := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp + (Procedure.second parametersCode (listCode bondCode)) + let tab := (Procedure.tabulate (f := fun x i => block (indexed (i,x))) [] + (blockProgram.comp indexedProgram)).comp (n.pair (Procedure.identity familyCode)) + exact (QuantumRawExchange.flattenProgram bondCode zeroBond).comp tab + +noncomputable opaque familyOffsetProgram : Procedure familyCode ratCode familyOffset := by + let p := Procedure.first parametersCode bondCode + let e := Procedure.second parametersCode bondCode + let entry := offsetProgram.comp (p.pair ((Procedure.constant _ unaryCode 0).pair e)) + exact RationalSumProgram.sumProgram.comp + (Procedure.listMapWith (ea := parametersCode) (eb := bondCode) (ec := ratCode) + (f := fun p e => offset (p,0,e)) zeroBond 0 entry) + +theorem block_length (x : Input) : (block x).length = 3 := List.length_ofFn + +theorem block_bounded (x : Input) (r : ℕ) (hi : x.2.1 < r) + (hl : x.2.2.1 < x.1.1) (hr : x.2.2.2.1 < x.1.1) : + SourceBondLists.bounded (x.1.1+r*2) (block x) := by + intro e he + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp he + fin_cases k <;> dsimp [bond,left,right] + all_goals first | omega | (split_ifs <;> omega) + +theorem block_noLoops (x : Input) (hl : x.2.2.1 < x.1.1) (hr : x.2.2.2.1 < x.1.1) : + ∀ e ∈ block x, e.1 ≠ e.2.1 := by + intro e he + obtain ⟨k,rfl⟩ := List.mem_ofFn.mp he + fin_cases k <;> dsimp [bond,left,right] + all_goals omega + +theorem indexed_mem (p : Parameters) (xs : List Bond) (i : ℕ) (hi : i < xs.length) : + (indexed (i,(p,xs))).2.2 ∈ xs := by + have he : (xs.drop i).headD zeroBond = xs[i] := by + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_eq_getElem hi] + rfl + change (xs.drop i).headD zeroBond ∈ xs + rw [he] + exact List.getElem_mem hi + +theorem family_bounded (x : FamilyInput) (hb : SourceBondLists.bounded x.1.1 x.2) : + SourceBondLists.bounded (x.1.1+x.2.length*2) (family x) := by + intro b hb' + obtain ⟨bs,hbs,hb'⟩ := List.mem_flatten.mp hb' + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' := List.mem_range.mp hi + have hsource := hb _ (indexed_mem x.1 x.2 i hi') + exact block_bounded (indexed (i,x)) x.2.length hi' hsource.1 hsource.2 b hb' + +theorem family_noLoops (x : FamilyInput) (hb : SourceBondLists.bounded x.1.1 x.2) : + ∀ b ∈ family x, b.1 ≠ b.2.1 := by + intro b hb' + obtain ⟨bs,hbs,hb'⟩ := List.mem_flatten.mp hb' + obtain ⟨i,hi,rfl⟩ := List.mem_map.mp hbs + have hi' := List.mem_range.mp hi + have hsource := hb _ (indexed_mem x.1 x.2 i hi') + exact block_noLoops (indexed (i,x)) hsource.1 hsource.2 b hb' + +end ContinuumCoulomb.QuantumListPathProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathStep.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..59777254297d285e83c5ab956ba262b9ef573a5b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListPathStep.lean @@ -0,0 +1,97 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathMatrix + +namespace OAI + +/-! A calibrated selected-subdivision step acting directly on finite bond +lists. The selected list order fixes the labels of every new mediator pair. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListPathStep +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev Input := (ℕ × (Bool × (ℚ × ℚ))) × (List Bond × List Bond) +def headCode : (ℕ × (Bool × (ℚ × ℚ))) → List Bool := + prodCode unaryCode (prodCode Procedure.boolCode (prodCode ratCode ratCode)) +def inputCode : Input → List Bool := + prodCode headCode (prodCode (listCode bondCode) (listCode bondCode)) +abbrev Output := ℕ × (List Bond × ℚ) +def outputCode : Output → List Bool := prodCode unaryCode (prodCode (listCode bondCode) ratCode) + +def scaleInput (x : Input) : QuantumPathScaleProgram.Input := + (x.1.2.2,(x.2.1.map (fun e => e.2.2),x.2.2.map (fun e => e.2.2))) +def parameters (x : Input) : QuantumListPathProgram.Parameters := + (x.1.1,x.1.2.1,QuantumPathScaleProgram.value (scaleInput x)) +def count (x : Input) : ℕ := x.1.1+x.2.2.length*2 +def bonds (x : Input) : List Bond := x.2.1++QuantumListPathProgram.family (parameters x,x.2.2) +def constant (x : Input) : ℚ := x.1.2.2.2+QuantumListPathProgram.familyOffset (parameters x,x.2.2) +def value (x : Input) : Output := (count x,bonds x,constant x) + +noncomputable opaque headProgram : Procedure inputCode headCode Prod.fst := Procedure.first _ _ +noncomputable opaque countInputProgram : Procedure inputCode unaryCode (fun x => x.1.1) := + (Procedure.first _ _).comp headProgram +noncomputable opaque parityProgram : Procedure inputCode Procedure.boolCode (fun x => x.1.2.1) := + (Procedure.first _ _).comp ((Procedure.second _ _).comp headProgram) +noncomputable opaque constantsProgram : Procedure inputCode (prodCode ratCode ratCode) + (fun x => x.1.2.2) := + (Procedure.second _ _).comp ((Procedure.second _ _).comp headProgram) +noncomputable opaque listsProgram : + Procedure inputCode (prodCode (listCode bondCode) (listCode bondCode)) Prod.snd := Procedure.second _ _ +noncomputable opaque retainedProgram : Procedure inputCode (listCode bondCode) (fun x => x.2.1) := + (Procedure.first _ _).comp listsProgram +noncomputable opaque selectedProgram : Procedure inputCode (listCode bondCode) (fun x => x.2.2) := + (Procedure.second _ _).comp listsProgram +noncomputable opaque weightProgram : Procedure bondCode ratCode (fun e => e.2.2) := + (Procedure.second _ _).comp (Procedure.second _ _) +noncomputable opaque weightsProgram : Procedure (listCode bondCode) (listCode ratCode) + (fun xs => xs.map (fun e => e.2.2)) := Procedure.listMap zeroBond 0 weightProgram + +noncomputable opaque scaleInputProgram : + Procedure inputCode QuantumPathScaleProgram.inputCode scaleInput := + constantsProgram.pair ((weightsProgram.comp retainedProgram).pair (weightsProgram.comp selectedProgram)) +noncomputable opaque parametersProgram : + Procedure inputCode QuantumListPathProgram.parametersCode parameters := + countInputProgram.pair (parityProgram.pair (QuantumPathScaleProgram.program.comp scaleInputProgram)) +noncomputable opaque countProgram : Procedure inputCode unaryCode count := by + let n := (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength bondCode zeroBond).comp selectedProgram + exact Procedure.unaryAdd.comp (countInputProgram.pair + (Procedure.unaryMul.comp (n.pair (Procedure.constant inputCode unaryCode 2)))) +noncomputable opaque familyInputProgram : Procedure inputCode QuantumListPathProgram.familyCode + (fun x => (parameters x,x.2.2)) := parametersProgram.pair selectedProgram +noncomputable opaque bondsProgram : Procedure inputCode (listCode bondCode) bonds := + (Procedure.listAppend bondCode zeroBond).comp + (retainedProgram.pair (QuantumListPathProgram.familyProgram.comp familyInputProgram)) +noncomputable opaque constantProgram : Procedure inputCode ratCode constant := + Procedure.ratAdd.comp + (((Procedure.second ratCode ratCode).comp constantsProgram).pair + (QuantumListPathProgram.familyOffsetProgram.comp familyInputProgram)) +noncomputable opaque program : Procedure inputCode outputCode value := + countProgram.pair (bondsProgram.pair constantProgram) + +theorem bonds_bounded (x : Input) + (hk : SourceBondLists.bounded x.1.1 x.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) : + SourceBondLists.bounded (count x) (bonds x) := by + intro e he + rcases List.mem_append.mp he with h | h + · obtain ⟨hl,hr⟩ := hk e h + exact ⟨hl.trans_le (Nat.le_add_right _ _),hr.trans_le (Nat.le_add_right _ _)⟩ + · exact QuantumListPathProgram.family_bounded (parameters x,x.2.2) hs e h + +theorem bonds_noLoops (x : Input) + (hk : ∀ e ∈ x.2.1, e.1 ≠ e.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) : ∀ e ∈ bonds x, e.1 ≠ e.2.1 := by + intro e he + rcases List.mem_append.mp he with h | h + · exact hk e h + · exact QuantumListPathProgram.family_noLoops (parameters x,x.2.2) hs e h + +def graph (x : Input) (hk : SourceBondLists.bounded x.1.1 x.2.1) + (hs : SourceBondLists.bounded x.1.1 x.2.2) (hn : ∀ e ∈ x.2.1, e.1 ≠ e.2.1) : + QMARationalExchangeGraph := + QuantumListGraph.ofBonds (count x) (bonds x) (constant x) (bonds_bounded x hk hs) (bonds_noLoops x hn hs) + +end ContinuumCoulomb.QuantumListPathStep + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteLattice.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteLattice.lean new file mode 100644 index 0000000000000000000000000000000000000000..c63af1161d59ae922895be335f932557c33c8675 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteLattice.lean @@ -0,0 +1,187 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRoutePreservation +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListLatticeProgram + +namespace OAI + +/-! The final literal route tape is itself the serialized lattice source. +Its coordinate and edge order are the computed orders, and its exact scalar +offset is removed from both thresholds. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode MediatorListProgram +open ExactQuantumFactoring.BitStackProgram + +def latticePacket (s : State) (a b : ℚ) : QuantumListLattice.Input := + (s.2.1,erase s.1.2.2,a,b,s.1.2.1) + +def latticeOutput (s : State) (a b : ℚ) : BinaryHeisenberg := + QuantumListLattice.value (latticePacket s a b) + +noncomputable def latticePacketProgram : + Procedure (prodCode stateCode (prodCode ratCode ratCode)) + QuantumListLattice.inputCode (fun x : State × (ℚ × ℚ) => latticePacket x.1 x.2.1 x.2.2) := by + let s := Procedure.first stateCode (prodCode ratCode ratCode) + let t := Procedure.second stateCode (prodCode ratCode ratCode) + let data := (Procedure.first QuantumListSchedule.stateCode + (prodCode (listCode pairCode) (listCode (listCode pairCode)))).comp s + let spatial := (Procedure.second QuantumListSchedule.stateCode + (prodCode (listCode pairCode) (listCode (listCode pairCode)))).comp s + let ps := (Procedure.first (listCode pairCode) (listCode (listCode pairCode))).comp spatial + let tail := (Procedure.second unaryCode (prodCode ratCode (listCode entryCode))).comp data + let c := (Procedure.first ratCode (listCode entryCode)).comp tail + let xs := eraseProgram.comp ((Procedure.second ratCode (listCode entryCode)).comp tail) + let a := (Procedure.first ratCode ratCode).comp t + let b := (Procedure.second ratCode ratCode).comp t + exact ps.pair (xs.pair (a.pair (b.pair c))) + +noncomputable def latticeOutputProgram : + Procedure (prodCode stateCode (prodCode ratCode ratCode)) binaryHeisenbergCodec.encode + (fun x : State × (ℚ × ℚ) => latticeOutput x.1 x.2.1 x.2.2) := + QuantumListLattice.program.comp latticePacketProgram + +private theorem get_of_eq_ofFn {α : Type} {n : ℕ} {xs : List α} {f : Fin n → α} + (h : xs=List.ofFn f) (i : Fin xs.length) : + xs.get i=f ⟨i.val,by simpa only [h,List.length_ofFn] using i.isLt⟩ := by + subst xs + simp only [List.get_eq_getElem,List.getElem_ofFn] + +theorem represented_length (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) : + s.2.1.length=s.1.1 := by rw [hP.1,List.length_ofFn]; rfl + +theorem represented_nodup (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) : + s.2.1.Nodup := by + rw [hP.1] + exact List.nodup_ofFn.mpr P.position_injective + +theorem represented_bounded (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) : + SourceBondLists.bounded s.2.1.length (erase s.1.2.2) := by + rw [represented_length s hs P hP] + exact hs.1 + +theorem represented_adjacent (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + (ha : ∀ e, qmaSquareGrid.Adj (P.position ((schedule s.1 hs).graph.left e)) + (P.position ((schedule s.1 hs).graph.right e))) : + QuantumListLattice.Adjacent s.2.1 (erase s.1.2.2) (represented_bounded s hs P hP) := by + intro e he + obtain ⟨w,hw,rfl⟩ := List.mem_map.mp he + obtain ⟨i,rfl⟩ := List.mem_iff_get.mp hw + rw [get_of_eq_ofFn hP.1,get_of_eq_ofFn hP.1] + exact ha i + +theorem latticeOutput_valid (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + (ha : ∀ e, qmaSquareGrid.Adj (P.position ((schedule s.1 hs).graph.left e)) + (P.position ((schedule s.1 hs).graph.right e))) + (hn : 0 < s.1.1) (a b : ℚ) (hab : a < b) : + (latticeOutput s a b).Valid := by + apply QuantumListLattice.value_valid _ _ + (by rw [represented_length s hs P hP]; exact hn) + (represented_nodup s hs P hP) (represented_bounded s hs P hP) hs.2 + (represented_adjacent s hs P hP ha) a b s.1.2.1 hab + +theorem latticeOutput_yes (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + (ha : ∀ e, qmaSquareGrid.Adj (P.position ((schedule s.1 hs).graph.left e)) + (P.position ((schedule s.1 hs).graph.right e))) + (hn : 0 < s.1.1) (a b : ℚ) (hab : a < b) {k : ℕ} + (hp : (latticeOutput s a b).PolynomialPromise k) + (he : QuantumListSchedule.energy s.1 ≤ (a:ℝ)) : + latticeOutput s a b ∈ (sourceHeisenbergPromise k).yes := by + apply QuantumListLattice.value_mem_yes _ _ + (by rw [represented_length s hs P hP]; exact hn) + (represented_nodup s hs P hP) (represented_bounded s hs P hP) hs.2 + (represented_adjacent s hs P hP ha) a b s.1.2.1 hab hp + rw [represented_length s hs P hP] + exact he + +theorem latticeOutput_no (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + (ha : ∀ e, qmaSquareGrid.Adj (P.position ((schedule s.1 hs).graph.left e)) + (P.position ((schedule s.1 hs).graph.right e))) + (hn : 0 < s.1.1) (a b : ℚ) (hab : a < b) {k : ℕ} + (hp : (latticeOutput s a b).PolynomialPromise k) + (he : (b:ℝ) ≤ QuantumListSchedule.energy s.1) : + latticeOutput s a b ∈ (sourceHeisenbergPromise k).no := by + apply QuantumListLattice.value_mem_no _ _ + (by rw [represented_length s hs P hP]; exact hn) + (represented_nodup s hs P hP) (represented_bounded s hs P hP) hs.2 + (represented_adjacent s hs P hP ha) a b s.1.2.1 hab hp + rw [represented_length s hs P hP] + exact he + +theorem latticeOutput_polynomialPromise (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + (ha : ∀ e, qmaSquareGrid.Adj (P.position ((schedule s.1 hs).graph.left e)) + (P.position ((schedule s.1 hs).graph.right e))) + (hn : 0 < s.1.1) (a b : ℚ) (hab : a < b) (n k : ℕ) (hsize : n ≤ s.1.1) + (hpos : ∀ v, ((P.position v).1:ℝ) ≤ (n+1:ℝ)^k ∧ + ((P.position v).2:ℝ) ≤ (n+1:ℝ)^k) + {L : ℝ} (hL : 0 ≤ L) (hc : (graph s.1 hs).CoefficientBound L) + (hcoeff : s.1.2.2.length*L ≤ (n+1:ℝ)^k) + (hgap : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (latticeOutput s a b).PolynomialPromise k := by + have hbound : ∀ e ∈ erase s.1.2.2, |(e.2.2:ℝ)| ≤ L := by + intro e he + obtain ⟨w,hw,rfl⟩ := List.mem_map.mp he + obtain ⟨i,rfl⟩ := List.mem_iff_get.mp hw + exact hc.2 i + have h := QuantumListLattice.source_polynomialPromise s.2.1 (erase s.1.2.2) + (by rw [represented_length s hs P hP]; exact hn) + (represented_nodup s hs P hP) (represented_bounded s hs P hP) hs.2 + (represented_adjacent s hs P hP ha) a b s.1.2.1 hab n k + (by rwa [represented_length s hs P hP]) + (by + intro p hp + rw [hP.1] at hp + obtain ⟨v,rfl⟩ := List.mem_ofFn.mp hp + exact hpos v) + hL hbound (by simpa only [erase,List.length_map] using hcoeff) hgap + rwa [← QuantumListLattice.value_source] at h + +theorem iterate_count_le (N : ℚ) (s : State) (k : ℕ) : + s.1.1 ≤ (iterate N k s).1.1 := by + rw [iterate_state] + suffices ∀ k, s.1.1 ≤ (QuantumListSchedule.iterate N k s.1).1 from this k + intro k + induction k with + | zero => exact le_rfl + | succ k ih => + change s.1.1 ≤ (QuantumListSchedule.value (N,QuantumListSchedule.iterate N k s.1)).1 + rw [value_count] + exact ih.trans (Nat.le_add_right _ _) + +theorem compiled_lattice_promise {N : ℚ} (hN : 0 < N) (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + {D X Y : ℕ} (hD : ∀ e ∈ s.1.2.2, e.1 ≤ D) (hbox : P.Bounded X Y) + (hn : 0 < s.1.1) (a b ε : ℚ) (hab : a+ε < b-ε) {k : ℕ} + (hp : (latticeOutput (iterate N D s) (a+ε) (b-ε)).PolynomialPromise k) + (herr : (D:ℝ)/(N:ℝ) ≤ (ε:ℝ)) : + (QuantumListSchedule.energy s.1 ≤ (a:ℝ) → + latticeOutput (iterate N D s) (a+ε) (b-ε) ∈ (sourceHeisenbergPromise k).yes) ∧ + ((b:ℝ) ≤ QuantumListSchedule.energy s.1 → + latticeOutput (iterate N D s) (a+ε) (b-ε) ∈ (sourceHeisenbergPromise k).no) := by + obtain ⟨hs',Q,hQ,_hQbox,hgrid,_hsize,henergy⟩ := + compile_realization hN s hs P hP hD hbox + have hn' : 0 < (iterate N D s).1.1 := hn.trans_le (iterate_count_le N s D) + constructor + · intro he + apply latticeOutput_yes (iterate N D s) hs' Q hQ hgrid hn' (a+ε) (b-ε) hab hp + have h := (abs_le.mp henergy).2 + push_cast + linarith + · intro he + apply latticeOutput_no (iterate N D s) hs' Q hQ hgrid hn' (a+ε) (b-ε) hab hp + have h := (abs_le.mp henergy).1 + push_cast + linarith + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteMatching.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteMatching.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea9e6c257b6fce473f9f8b74f9aab591fb20a2a2 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteMatching.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleRelabel +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRoutePreservation +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPackedSchedule + +namespace OAI + +/-! The literal coordinate tape follows the canonical physical subdivision, +with a finite relabeling accounting for each emitted edge order. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open scoped Classical +open QuantumListSchedule + +theorem iterate_matches {Γ : SimpleGraph (ℕ × ℕ)} (N : ℚ) (s : State) + (hs : Valid s.1) (P : QMAPathEmbedding (schedule s.1 hs) Γ) + (hP : Represents s hs P) {T : QMAPathSchedule} (Q : QMAPathEmbedding T Γ) + (E : QMAPathRelabeling (schedule s.1 hs) T) + (hpos : ∀ v, Q.position (E.vertex v)=P.position v) + (hpoint : ∀ e j, Q.point (E.edge e) j=P.point e j) (k : ℕ) : + ∃ (hk : Valid (iterate N k s).1) + (Pk : QMAPathEmbedding (schedule (iterate N k s).1 hk) Γ) + (Ek : QMAPathRelabeling (schedule (iterate N k s).1 hk) (T.iterate N k)), + Represents (iterate N k s) hk Pk ∧ + (∀ v, (Q.iterate N k).position (Ek.vertex v)=Pk.position v) ∧ + (∀ e j, (Q.iterate N k).point (Ek.edge e) j=Pk.point e j) := by + induction k with + | zero => exact ⟨hs,P,E,hP,hpos,hpoint⟩ + | succ k ih => + obtain ⟨hk,Pk,Ek,hPk,hvk,hek⟩ := ih + let F := nextRelabel (N,(iterate N k s).1) hk + refine ⟨value_valid (N,(iterate N k s).1) hk, + nextEmbedding (N,(iterate N k s).1) hk Pk,F.trans (Ek.next N), + value_represents (N,iterate N k s) hk Pk hPk,?_,?_⟩ + · intro v + exact (Ek.next_position Pk (Q.iterate N k) hvk hek N (F.vertex v)).trans (by rfl) + · intro e j + exact (Ek.next_point Pk (Q.iterate N k) hek N (F.edge e) j).trans (by rfl) + +theorem packed_matches (G : QMARationalExchangeGraph) {m : ℕ} + (labels : G.Edge ≃ Fin m) (work : G.Edge → ℕ) + {Γ : SimpleGraph (ℕ × ℕ)} (P : QMAPathEmbedding ⟨G,work⟩ Γ) (N : ℚ) (k : ℕ) : + ∃ (hk : Valid (iterate N k (QuantumPackedSchedule.layout G labels work P)).1) + (Pk : QMAPathEmbedding + (schedule (iterate N k (QuantumPackedSchedule.layout G labels work P)).1 hk) Γ) + (Ek : QMAPathRelabeling + (schedule (iterate N k (QuantumPackedSchedule.layout G labels work P)).1 hk) + ((QMAPathSchedule.mk G work).iterate N k)), + Represents (iterate N k (QuantumPackedSchedule.layout G labels work P)) hk Pk ∧ + (∀ v, (P.iterate N k).position (Ek.vertex v)=Pk.position v) ∧ + (∀ e j, (P.iterate N k).point (Ek.edge e) j=Pk.point e j) := by + exact iterate_matches N _ (QuantumPackedSchedule.valid G labels work) + ((QuantumPackedSchedule.scheduleRelabel G labels work).symm.transport P) + (QuantumPackedSchedule.layout_represents G labels work P) P + (QuantumPackedSchedule.scheduleRelabel G labels work) (fun _ => rfl) (fun _ _ => rfl) k + +theorem packed_matches_of_eq (G : QMARationalExchangeGraph) {m : ℕ} + (labels : G.Edge ≃ Fin m) (work : G.Edge → ℕ) + {Γ : SimpleGraph (ℕ × ℕ)} (P : QMAPathEmbedding ⟨G,work⟩ Γ) (N : ℚ) (k : ℕ) (s : State) + (hs : s=QuantumPackedSchedule.layout G labels work P) : + ∃ (hk : Valid (iterate N k s).1) + (Pk : QMAPathEmbedding + (schedule (iterate N k s).1 hk) Γ) + (Ek : QMAPathRelabeling + (schedule (iterate N k s).1 hk) + ((QMAPathSchedule.mk G work).iterate N k)), + Represents (iterate N k s) hk Pk ∧ + (∀ v, (P.iterate N k).position (Ek.vertex v)=Pk.position v) ∧ + (∀ e j, (P.iterate N k).point (Ek.edge e) j=Pk.point e j) := by + subst s + exact packed_matches G labels work P N k + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPoint.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..83ea73df73a178929b4a88c783bf38aca902a13a --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPoint.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteNextPosition + +namespace OAI + +/-! Exact route-index formulas for the three emitted edges of a selected +source edge and for every retained edge. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode +open scoped Classical + +variable {Γ : SimpleGraph Pair} + +theorem next_edge_retained (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition false s.2.2).length) : + nextEdge (N,s) hs ((tagEquiv (N,s)).symm (.inl i)) = .inl (retainedEquiv s hs i) := by + exact nextEdge_tag (N,s) hs (.inl i) + +theorem next_edge_central (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + nextEdge (N,s) hs ((tagEquiv (N,s)).symm (.inr (i,0))) = + .inr (.inl (activePermutation s hs i)) := by + exact nextEdge_tag (N,s) hs (.inr (i,0)) + +theorem next_edge_left (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + nextEdge (N,s) hs ((tagEquiv (N,s)).symm (.inr (i,1))) = + .inr (.inr (activePermutation s hs i,0)) := by + exact nextEdge_tag (N,s) hs (.inr (i,1)) + +theorem next_edge_right (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + nextEdge (N,s) hs ((tagEquiv (N,s)).symm (.inr (i,2))) = + .inr (.inr (activePermutation s hs i,1)) := by + exact nextEdge_tag (N,s) hs (.inr (i,2)) + +theorem next_point (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (e : Fin (QuantumListSchedule.value (N,s)).2.2.length) + (k : ℕ) : (nextEmbedding (N,s) hs P).point e k = + (P.next N).point (nextEdge (N,s) hs e) k := rfl + +theorem next_point_retained (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (i : Fin (partition false s.2.2).length) (k : ℕ) : + (nextEmbedding (N,s) hs P).point ((tagEquiv (N,s)).symm (.inl i)) k = + P.point (retainedEquiv s hs i).val k := by + rw [next_point,next_edge_retained] + rfl + +theorem next_point_central (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (i : Fin (partition true s.2.2).length) (k : ℕ) : + (nextEmbedding (N,s) hs P).point ((tagEquiv (N,s)).symm (.inr (i,0))) k = + P.point (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)) (k+1) := by + rw [next_point,next_edge_central] + rfl + +theorem next_point_left (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (i : Fin (partition true s.2.2).length) (k : ℕ) : + (nextEmbedding (N,s) hs P).point ((tagEquiv (N,s)).symm (.inr (i,1))) k = + P.point (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)) k := by + rw [next_point,next_edge_left] + rfl + +theorem next_point_right (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (i : Fin (partition true s.2.2).length) (k : ℕ) : + (nextEmbedding (N,s) hs P).point ((tagEquiv (N,s)).symm (.inr (i,2))) k = + P.point (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)) + (2*(schedule s hs).work + (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i))+1-k) := by + rw [next_point,next_edge_right] + rfl + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPosition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPosition.lean new file mode 100644 index 0000000000000000000000000000000000000000..c24c746ac923c19d8ce5e82a4f5a036c0370f79b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextPosition.lean @@ -0,0 +1,111 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteRepresentation + +namespace OAI + +/-! The literal new-coordinate list is exactly the placement of the +next scheduled embedding, in the emitted spin order. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode MediatorGraph +open scoped Classical + +private theorem ofFn_pairs {r : ℕ} (f : Fin r × Fin 2 → Pair) : + List.ofFn (fun k : Fin (r*2) => f (finProdFinEquiv.symm k)) = + (List.ofFn fun i : Fin r => [f (i,0),f (i,1)]).flatten := by + rw [List.ofFn_mul] + apply congrArg List.flatten + apply congrArg (fun g : Fin r → List Pair => List.ofFn g) + funext i + have hh : (fun k : Fin 2 => f (finProdFinEquiv.symm + ⟨i.val*2+k.val,by omega⟩)) = fun k : Fin 2 => f (i,k) := by + funext k + have he : (⟨i.val*2+k.val,by omega⟩ : Fin (r*2))=finProdFinEquiv (i,k) := by + apply Fin.ext + change i.val*2+k.val=k.val+2*i.val + omega + rw [he,Equiv.symm_apply_apply] + rw [hh] + simp [List.ofFn_succ,List.ofFn_zero,Fin.succ] + +private theorem ofFn_vertices {n r : ℕ} (f : Fin (n+r*2) → Pair) : + List.ofFn f = List.ofFn (fun i => f (old n r i)) ++ + (List.ofFn fun i => [f (fresh n r i 0),f (fresh n r i 1)]).flatten := by + rw [List.ofFn_add] + apply congrArg₂ (fun a b : List Pair => a++b) + · apply congrArg List.ofFn + funext i + apply congrArg f + exact Fin.ext rfl + · rw [← ofFn_pairs (fun p : Fin r × Fin 2 => f (fresh n r p.1 p.2))] + apply congrArg List.ofFn + funext k + apply congrArg f + apply Fin.ext + change n+k.val=n+(finProdFinEquiv (finProdFinEquiv.symm k)).val + rw [Equiv.apply_symm_apply] + +private theorem ofFn_cast {n m : ℕ} (h : n=m) (f : Fin n → Pair) : + List.ofFn (fun i : Fin m => f ((finCongr h).symm i))=List.ofFn f := by + subst m + rfl + +variable {Γ : SimpleGraph Pair} + +theorem next_position (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (v : Fin (QuantumListSchedule.value (N,s)).1) : + (nextEmbedding (N,s) hs P).position v = + (P.next N).position (nextVertex (N,s) hs v) := rfl + +theorem next_position_old (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (v : Fin s.1) : + (nextEmbedding (N,s) hs P).position + ((finCongr (value_count (N,s))).symm (old s.1 (partition true s.2.2).length v)) = + P.position v := by + rw [next_position] + change (P.next N).position (vertexRelabel s hs + ((finCongr (value_count (N,s))) ((finCongr (value_count (N,s))).symm + (old s.1 (partition true s.2.2).length v)))) = _ + rw [Equiv.apply_symm_apply,vertexRelabel_old] + exact P.nextPosition_old v + +theorem next_position_fresh (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) (i : Fin (partition true s.2.2).length) (a : Fin 2) : + (nextEmbedding (N,s) hs P).position + ((finCongr (value_count (N,s))).symm (fresh s.1 (partition true s.2.2).length i a)) = + P.point (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)) (a.val+1) := by + rw [next_position] + change (P.next N).position (vertexRelabel s hs + ((finCongr (value_count (N,s))) ((finCongr (value_count (N,s))).symm + (fresh s.1 (partition true s.2.2).length i a)))) = _ + rw [Equiv.apply_symm_apply,vertexRelabel_fresh] + exact P.nextPosition_fresh _ a + +theorem positions_next (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) : + positions x=List.ofFn (nextEmbedding (x.1,x.2.1) hx P).position := by + let Q := nextEmbedding (x.1,x.2.1) hx P + calc + positions x = List.ofFn (fun v => Q.position ((finCongr (value_count (x.1,x.2.1))).symm v)) := by + rw [ofFn_vertices] + change x.2.2.1++((selectedRoutes true x).map freshPoints).flatten = _ + apply congrArg₂ (fun a b : List Pair => a++b) + · have he : (fun v => Q.position ((finCongr (value_count (x.1,x.2.1))).symm + (old x.2.1.1 (partition true x.2.1.2.2).length v)))=P.position := by + funext v + exact next_position_old x.1 x.2.1 hx P v + rw [he] + exact hP.1 + · rw [map_selectedRoutes] + apply congrArg List.flatten + apply congrArg (fun f : Fin (partition true x.2.1.2.2).length → List Pair => List.ofFn f) + funext i + rw [next_position_fresh,next_position_fresh] + exact selected_freshPoints x hx P hP i + _ = List.ofFn Q.position := ofFn_cast _ _ + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextWork.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextWork.lean new file mode 100644 index 0000000000000000000000000000000000000000..846ad38bedbd3a6dbdc4110af460f10421bd0171 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteNextWork.lean @@ -0,0 +1,51 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteNextPoint + +namespace OAI + +/-! Exact remaining-work values in the finite output edge order. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode +open scoped Classical + +private theorem work_map (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (e : Fin (QuantumListSchedule.value (N,s)).2.2.length) : + (schedule (QuantumListSchedule.value (N,s)) (value_valid (N,s) hs)).work e = + ((schedule s hs).next N).work (nextEdge (N,s) hs e) := + (nextRelabel (N,s) hs).work e + +theorem next_work_retained (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition false s.2.2).length) : + (schedule (QuantumListSchedule.value (N,s)) (value_valid (N,s) hs)).work + ((tagEquiv (N,s)).symm (.inl i))=0 := by + exact (work_map N s hs _).trans + (congrArg ((schedule s hs).next N).work (next_edge_retained N s hs i)) + +theorem next_work_central (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + (schedule (QuantumListSchedule.value (N,s)) (value_valid (N,s) hs)).work + ((tagEquiv (N,s)).symm (.inr (i,0)))=0 := by + exact (work_map N s hs _).trans + (congrArg ((schedule s hs).next N).work (next_edge_central N s hs i)) + +theorem next_work_left (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + (schedule (QuantumListSchedule.value (N,s)) (value_valid (N,s) hs)).work + ((tagEquiv (N,s)).symm (.inr (i,1)))=0 := by + exact (work_map N s hs _).trans + (congrArg ((schedule s hs).next N).work (next_edge_left N s hs i)) + +theorem next_work_right (N : ℚ) (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + (schedule (QuantumListSchedule.value (N,s)) (value_valid (N,s) hs)).work + ((tagEquiv (N,s)).symm (.inr (i,2))) = + (schedule s hs).work (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i))-1 := by + exact (work_map N s hs _).trans + (congrArg ((schedule s hs).next N).work (next_edge_right N s hs i)) + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d90fea7c6016fcd1ce0b997e9261e2dabde3397 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputBounds.lean @@ -0,0 +1,58 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteOutputProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleBounds + +namespace OAI + +/-! The actual serialized output satisfies the source coefficient, coordinate +and inverse-gap promise using the fixed-round compiler's proved estimates. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode + +theorem compiled_polynomialPromise {N : ℚ} (hN : 0 < N) + (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs)) (hP : Represents s hs P) + {D X Y : ℕ} (hD : ∀ e ∈ s.1.2.2, e.1 ≤ D) (hbox : P.Bounded X Y) + (hn : 0 < s.1.1) (a b : ℚ) (hab : a < b) + (n k : ℕ) (hsize : n ≤ s.1.1) + (hx : (X:ℝ) ≤ (n+1:ℝ)^k) (hy : (Y:ℝ) ≤ (n+1:ℝ)^k) + {m L T : ℝ} (hm : (s.1.2.2.length:ℝ) ≤ m) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : (graph s.1 hs).CoefficientBound L) + (hcoeff : (3^D*m)*qmaPathIteratedBound m L T D ≤ (n+1:ℝ)^k) + (hgap : ((n+1:ℝ)^k)⁻¹ ≤ (b:ℝ)-a) : + (latticeOutput (iterate N D s) a b).PolynomialPromise k := by + obtain ⟨hs',Q,hQ,hQbox,hgrid,_hsize,_henergy⟩ := + compile_realization hN s hs P hP hD hbox + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + have hL' : 0 ≤ qmaPathIteratedBound m L T D := + le_trans zero_le_one (qmaPathIteratedBound_one hm0 hL D) + have hc' : (graph (iterate N D s).1 hs').CoefficientBound + (qmaPathIteratedBound m L T D) := by + have ht : ∀ (t : QuantumListSchedule.State) (hv : Valid t), + t=QuantumListSchedule.iterate N D s.1 → + (graph t hv).CoefficientBound (qmaPathIteratedBound m L T D) := by + intro t hv he + subst t + exact iterate_coefficientBound hN.le s.1 hs hm hL hT hc D + exact ht _ hs' (iterate_state N s D) + have hcount : ((iterate N D s).1.2.2.length:ℝ) ≤ 3^D*m := by + have hc : (iterate N D s).1.2.2.length ≤ 3^D*s.1.2.2.length := by + rw [iterate_state] + exact iterate_edge_count N s.1 D + have hr : ((iterate N D s).1.2.2.length:ℝ) ≤ 3^D*(s.1.2.2.length:ℝ) := by + exact_mod_cast hc + exact hr.trans (mul_le_mul_of_nonneg_left hm (by positivity)) + apply latticeOutput_polynomialPromise (iterate N D s) hs' Q hQ hgrid + (hn.trans_le (iterate_count_le N s D)) a b hab n k + (hsize.trans (iterate_count_le N s D)) ?_ hL' hc' ?_ hgap + · intro v + exact ⟨(le_of_lt (by exact_mod_cast (hQbox.1 v).1)).trans hx, + (le_of_lt (by exact_mod_cast (hQbox.1 v).2)).trans hy⟩ + · exact (mul_le_mul_of_nonneg_right hcount hL').trans hcoeff + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..8170932a218f4f46c00801b14a2052b721f40569 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteOutputProgram.lean @@ -0,0 +1,35 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteLattice + +namespace OAI + +/-! Fixed-round routing, canonical bond merging, and the final threshold +margin are one literal polynomial source-output program. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open ExactQuantumFactoring.BitStackProgram + +abbrev OutputInput := Input × (ℚ × (ℚ × ℚ)) +def outputInputCode : OutputInput → List Bool := + prodCode inputCode QuantumLatticeSerialization.thresholdCode + +def output (D : ℕ) (x : OutputInput) : BinaryHeisenberg := + latticeOutput (iterate x.1.1 D x.1.2) (x.2.1+x.2.2.2) (x.2.2.1-x.2.2.2) + +noncomputable def outputProgram (D : ℕ) : + Procedure outputInputCode binaryHeisenbergCodec.encode (output D) := by + let x := Procedure.first inputCode QuantumLatticeSerialization.thresholdCode + let t := Procedure.second inputCode QuantumLatticeSerialization.thresholdCode + let a := (Procedure.first ratCode (prodCode ratCode ratCode)).comp t + let be := (Procedure.second ratCode (prodCode ratCode ratCode)).comp t + let b := (Procedure.first ratCode ratCode).comp be + let e := (Procedure.second ratCode ratCode).comp be + let lo := Procedure.ratAdd.comp (a.pair e) + let hi := Procedure.ratSub.comp (b.pair e) + exact latticeOutputProgram.comp (((iterateProgram D).comp x).pair (lo.pair hi)) + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePathOrder.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePathOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cbd49d6e55235d972f1263e28e5a6e67bd4fa7f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePathOrder.lean @@ -0,0 +1,68 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteNextWork + +namespace OAI + +/-! The output path array has exactly the output bond array's tag order. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode + +def pathPiece (r : Routed) : Fin 3 → List Pair := + ![[lookup r.2 1,lookup r.2 2],[lookup r.2 0,lookup r.2 1],(r.2.drop 2).reverse] + +theorem pathBlock_ofFn (r : Routed) : pathBlock r=List.ofFn (pathPiece r) := by + simp [pathBlock,pathPiece,List.ofFn_succ,List.ofFn_zero] + +def tagPath (x : Input) : Tags (x.1,x.2.1) → List Pair + | .inl i => (decoratedEntry x (indexEquiv false x.2.1.2.2 i).val).2 + | .inr (i,k) => pathPiece (decoratedEntry x (indexEquiv true x.2.1.2.2 i).val) k + +private theorem ofFn_triples {m : ℕ} (f : Fin m × Fin 3 → List Pair) : + List.ofFn (fun k : Fin (m*3) => f (finProdFinEquiv.symm k)) = + (List.ofFn fun i : Fin m => List.ofFn fun k : Fin 3 => f (i,k)).flatten := by + rw [List.ofFn_mul] + apply congrArg List.flatten + apply congrArg (fun g : Fin m → List (List Pair) => List.ofFn g) + funext i + apply congrArg (fun g : Fin 3 → List Pair => List.ofFn g) + funext k + have he : (⟨i.val*3+k.val,by omega⟩ : Fin (m*3))=finProdFinEquiv (i,k) := by + apply Fin.ext + change i.val*3+k.val=k.val+3*i.val + omega + rw [he,Equiv.symm_apply_apply] + +theorem paths_flat (x : Input) : paths x=List.ofFn + (fun i => tagPath x (flatTagEquiv (x.1,x.2.1) i)) := by + rw [List.ofFn_add] + change _ = (List.ofFn (fun i : Fin (partition false x.2.1.2.2).length => + tagPath x (flatTagEquiv (x.1,x.2.1) (Fin.castAdd ((partition true x.2.1.2.2).length*3) i))))++ + List.ofFn (fun i : Fin ((partition true x.2.1.2.2).length*3) => + tagPath x (flatTagEquiv (x.1,x.2.1) (Fin.natAdd (partition false x.2.1.2.2).length i))) + simp only [flatTagEquiv,Equiv.trans_apply,finSumFinEquiv_symm_apply_castAdd, + finSumFinEquiv_symm_apply_natAdd,Equiv.sumCongr_apply,Equiv.refl_apply, + Sum.map_inl,Sum.map_inr,tagPath] + have h3 := ofFn_triples (fun p : Fin (partition true x.2.1.2.2).length × Fin 3 => + pathPiece (decoratedEntry x (indexEquiv true x.2.1.2.2 p.1).val) p.2) + rw [h3] + change (selectedRoutes false x).map Prod.snd++((selectedRoutes true x).map pathBlock).flatten = _ + rw [map_selectedRoutes,map_selectedRoutes] + simp_rw [pathBlock_ofFn] + +theorem paths_tagged (x : Input) : paths x=List.ofFn + (fun i => tagPath x (tagEquiv (x.1,x.2.1) i)) := by + rw [paths_flat] + apply List.ext_getElem + · simp only [List.length_ofFn,value_length] + · intro i hi hj + simp only [List.getElem_ofFn,tagEquiv,Equiv.trans_apply,finCongr_apply] + apply congrArg (tagPath x) + apply congrArg (flatTagEquiv (x.1,x.2.1)) + exact Fin.ext rfl + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePieces.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePieces.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e1ef31ff68e50fc021bca8581ac5fa58b3573f6 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePieces.lean @@ -0,0 +1,46 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteProgram + +namespace OAI + +/-! Exact finite route pieces used by one literal subdivision round. -/ + +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumRouteCode + +theorem lookup_range (f : ℕ → Pair) (n i : ℕ) (hi : i f (2*w+1-k)) := by + apply List.ext_getElem + · simp only [List.length_reverse,List.length_drop,List.length_map,List.length_range] + omega + · intro i hi hj + have hi' : i<2*w := by simpa only [List.length_map,List.length_range] using hj + rw [List.getElem_reverse] + simp only [List.getElem_drop,List.getElem_map,List.getElem_range, + List.length_drop,List.length_map,List.length_range] + congr 1 + omega + +theorem freshPoints_range (e : QuantumListSchedule.Entry) (f : ℕ → Pair) (w : ℕ) + (hw : 0 f (2*w+1-k))] := by + have hn : 2*(w-1)+2=2*w := by omega + simp only [pathBlock,lookup_range f (2*w+2) 0 (by omega), + lookup_range f (2*w+2) 1 (by omega),lookup_range f (2*w+2) 2 (by omega), + tail_reverse,hn] + +end ContinuumCoulomb.QuantumListRouteProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePreservation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePreservation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b650c0add11c585253d0e7f42bdb21d9c318d9f0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRoutePreservation.lean @@ -0,0 +1,136 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRoutePathOrder + +namespace OAI + +/-! Preservation of the exact finite coordinate/route representation by one +round, and hence by the fixed number of rounds of the literal compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode +open scoped Classical + +variable {Γ : SimpleGraph Pair} + +private theorem range_map_congr {a b : ℕ} {f g : ℕ → Pair} + (h : a=b) (hf : ∀ k, f k=g k) : + (List.range (2*a+2)).map f=(List.range (2*b+2)).map g := + congrArg₂ List.map (funext hf) (congrArg (fun k => List.range (2*k+2)) h) + +theorem tagPath_next (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) + (t : Tags (x.1,x.2.1)) : + tagPath x t = (List.range (2*(schedule (QuantumListSchedule.value (x.1,x.2.1)) + (value_valid (x.1,x.2.1) hx)).work ((tagEquiv (x.1,x.2.1)).symm t)+2)).map + ((nextEmbedding (x.1,x.2.1) hx P).point ((tagEquiv (x.1,x.2.1)).symm t)) := by + rcases t with i | ⟨i,k⟩ + · change (decoratedEntry x (indexEquiv false x.2.1.2.2 i).val).2 = _ + rw [decoratedEntry_represents x hx P hP] + change (List.range (2*(schedule x.2.1 hx).work (retainedEquiv x.2.1 hx i).val+2)).map + (P.point (retainedEquiv x.2.1 hx i).val) = _ + exact (range_map_congr + ((schedule x.2.1 hx).retained_work_zero (retainedEquiv x.2.1 hx i)) + (fun _ => rfl)).trans + (range_map_congr (next_work_retained x.1 x.2.1 hx i) + (next_point_retained x.1 x.2.1 hx P i)).symm + · change pathPiece (decoratedEntry x (indexEquiv true x.2.1.2.2 i).val) k = _ + rw [decoratedEntry_represents x hx P hP,← selected_index x.2.1 hx i] + let e := qmaSelectedIndex (schedule x.2.1 hx).active (activePermutation x.2.1 hx i) + let w := (schedule x.2.1 hx).work e + let f := P.point e + have hw : 0 f (k+1)) := by + rw [lookup_range f _ _ h1,lookup_range f _ _ h2] + rfl + exact hl.trans (range_map_congr (next_work_central x.1 x.2.1 hx i) + (next_point_central x.1 x.2.1 hx P i)).symm + · change [lookup ((List.range (2*w+2)).map f) 0, + lookup ((List.range (2*w+2)).map f) 1] = _ + have hl : [lookup ((List.range (2*w+2)).map f) 0, + lookup ((List.range (2*w+2)).map f) 1] = (List.range 2).map f := by + rw [lookup_range f _ _ h0,lookup_range f _ _ h1] + rfl + exact hl.trans (range_map_congr (next_work_left x.1 x.2.1 hx i) + (next_point_left x.1 x.2.1 hx P i)).symm + · change (((List.range (2*w+2)).map f).drop 2).reverse = _ + have hl : (((List.range (2*w+2)).map f).drop 2).reverse = + (List.range (2*(w-1)+2)).map (fun k => f (2*w+1-k)) := by + rw [tail_reverse,hn] + exact hl.trans (range_map_congr (next_work_right x.1 x.2.1 hx i) + (next_point_right x.1 x.2.1 hx P i)).symm + +theorem paths_next (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) : + paths x=List.ofFn (fun e => (List.range (2*(schedule + (QuantumListSchedule.value (x.1,x.2.1)) (value_valid (x.1,x.2.1) hx)).work e+2)).map + ((nextEmbedding (x.1,x.2.1) hx P).point e)) := by + rw [paths_tagged] + apply congrArg List.ofFn + funext e + have h := tagPath_next x hx P hP (tagEquiv (x.1,x.2.1) e) + simpa only [Equiv.symm_apply_apply] using h + +theorem value_represents (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) : + Represents (value x) (value_valid (x.1,x.2.1) hx) (nextEmbedding (x.1,x.2.1) hx P) := + ⟨positions_next x hx P hP,paths_next x hx P hP⟩ + +theorem iterate_state (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).1=QuantumListSchedule.iterate N k s.1 := by + induction k with + | zero => rfl + | succ k ih => + change QuantumListSchedule.value (N,(iterate N k s).1)=_ + rw [ih] + rfl + +theorem iterate_represents (N : ℚ) (s : State) (hs : Valid s.1) + (P : QMAPathEmbedding (schedule s.1 hs) Γ) (hP : Represents s hs P) + {X Y : ℕ} (hbox : P.Bounded X Y) (k : ℕ) : + ∃ (hs' : Valid (iterate N k s).1) + (P' : QMAPathEmbedding (schedule (iterate N k s).1 hs') Γ), + Represents (iterate N k s) hs' P' ∧ P'.Bounded X Y := by + induction k with + | zero => exact ⟨hs,P,hP,hbox⟩ + | succ k ih => + obtain ⟨hk,Q,hQ,hQbox⟩ := ih + exact ⟨value_valid (N,(iterate N k s).1) hk, + nextEmbedding (N,(iterate N k s).1) hk Q, + value_represents (N,iterate N k s) hk Q hQ, + nextEmbedding_bounded (N,(iterate N k s).1) hk Q hQbox⟩ + +theorem compile_realization {N : ℚ} (hN : 0 hc _ (List.get_mem _ e)) + · rw [iterate_state] + exact QuantumListSchedule.iterate_size N s.1 D + · rw [iterate_state] + exact QuantumListSchedule.iterate_energy_error hN s.1 hs D + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..84742ab1146ae0876239988c7b80221eee0bd785 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteProgram.lean @@ -0,0 +1,140 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRouteProgram +import OAI.Computability.QuantumFactoring.BitStackListIndex + +namespace OAI + +/-! Literal route lists accompanying the bond/work scheduler. Every new pair +is placed at the first two internal points of its selected route. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open ExactQuantumFactoring.BitStackProgram QuantumRouteCode QuantumListSchedule + +abbrev Routed := Entry × List Pair +def routedCode : Routed → List Bool := prodCode entryCode (listCode pairCode) +abbrev State := QuantumListSchedule.State × (List Pair × List (List Pair)) +def stateCode : State → List Bool := prodCode QuantumListSchedule.stateCode + (prodCode (listCode pairCode) (listCode (listCode pairCode))) +abbrev Input := ℚ × State +def inputCode : Input → List Bool := prodCode ratCode stateCode + +def indexed (x : ℕ × Input) : Routed := + (((x.2.2.1.2.2.drop x.1).headD zeroEntry),((x.2.2.2.2.drop x.1).headD [])) +def decorated (x : Input) : List Routed := + (List.range x.2.1.2.2.length).map (fun i => indexed (i,x)) +def selectedRoutes (b : Bool) (x : Input) : List Routed := + (decorated x).filter (fun r => selected b r.1) +def lookup (p : List Pair) (i : ℕ) : Pair := (p.drop i).headD (0,0) +def freshPoints (r : Routed) : List Pair := [lookup r.2 1,lookup r.2 2] +def pathBlock (r : Routed) : List (List Pair) := + [[lookup r.2 1,lookup r.2 2],[lookup r.2 0,lookup r.2 1],(r.2.drop 2).reverse] +def positions (x : Input) : List Pair := + x.2.2.1++((selectedRoutes true x).map freshPoints).flatten +def paths (x : Input) : List (List Pair) := + (selectedRoutes false x).map Prod.snd++((selectedRoutes true x).map pathBlock).flatten +def value (x : Input) : State := (QuantumListSchedule.value (x.1,x.2.1),positions x,paths x) + +noncomputable opaque precisionProgram : Procedure inputCode ratCode Prod.fst := Procedure.first _ _ +noncomputable opaque dataProgram : Procedure inputCode stateCode Prod.snd := Procedure.second _ _ +noncomputable opaque scheduleProgram : Procedure inputCode QuantumListSchedule.stateCode + (fun x => x.2.1) := (Procedure.first _ _).comp dataProgram +noncomputable opaque spatialProgram : Procedure inputCode + (prodCode (listCode pairCode) (listCode (listCode pairCode))) (fun x => x.2.2) := + (Procedure.second _ _).comp dataProgram +noncomputable opaque oldPositionsProgram : Procedure inputCode (listCode pairCode) + (fun x => x.2.2.1) := (Procedure.first _ _).comp spatialProgram +noncomputable opaque oldPathsProgram : Procedure inputCode (listCode (listCode pairCode)) + (fun x => x.2.2.2) := (Procedure.second _ _).comp spatialProgram +noncomputable opaque entriesProgram : Procedure inputCode (listCode entryCode) + (fun x => x.2.1.2.2) := + (Procedure.second _ _).comp ((Procedure.second _ _).comp scheduleProgram) +noncomputable opaque countProgram : Procedure inputCode unaryCode + (fun x => x.2.1.2.2.length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength entryCode zeroEntry).comp entriesProgram + +noncomputable opaque indexedProgram : + Procedure (prodCode unaryCode inputCode) routedCode indexed := by + let k := Procedure.unaryToBits.comp (Procedure.first unaryCode inputCode) + let x := Procedure.second unaryCode inputCode + exact ((Procedure.listGet entryCode zeroEntry).comp (k.pair (entriesProgram.comp x))).pair + ((Procedure.listGet (listCode pairCode) []).comp (k.pair (oldPathsProgram.comp x))) +noncomputable opaque decoratedTabProgram : + Procedure (prodCode unaryCode inputCode) (listCode routedCode) + (fun x => (List.range x.1).map (fun i => indexed (i,x.2))) := + Procedure.tabulate (f := fun x i => indexed (i,x)) (zeroEntry,[]) indexedProgram +noncomputable opaque decoratedProgram : Procedure inputCode (listCode routedCode) decorated := + (decoratedTabProgram.comp (countProgram.pair (Procedure.identity inputCode))).congrFun + (by intro x; rfl) + +noncomputable opaque filterProgram (b : Bool) : + Procedure (listCode routedCode) (listCode routedCode) + (fun xs => xs.filter (fun r => selected b r.1)) := by + let single := (Procedure.listCons routedCode).comp ((Procedure.identity routedCode).pair + (Procedure.constant routedCode (listCode routedCode) [])) + let bit := (QuantumListSchedule.selectedProgram b).comp + (Procedure.first entryCode (listCode pairCode)) + let chunk := Procedure.conditional bit single + (Procedure.constant routedCode (listCode routedCode) []) + refine ((QuantumRawExchange.flattenProgram routedCode (zeroEntry,[])).comp + (Procedure.listMap (zeroEntry,[]) [] chunk)).congrFun ?_ + intro xs + induction xs with + | nil => rfl + | cons r rs ih => + dsimp only [Function.comp_apply] at ih + cases h : selected b r.1 <;> simpa [h] using ih +noncomputable opaque selectedProgram (b : Bool) : + Procedure inputCode (listCode routedCode) (selectedRoutes b) := + (filterProgram b).comp decoratedProgram +noncomputable opaque lookupProgram (k : ℕ) : + Procedure routedCode pairCode (fun r => lookup r.2 k) := + (Procedure.listGet pairCode (0,0)).comp + ((Procedure.constant routedCode Nat.bits k).pair (Procedure.second entryCode (listCode pairCode))) + +private noncomputable def pairList {α : Type} (ea : α → List Bool) + {f g : α → Pair} (p : Procedure ea pairCode f) (q : Procedure ea pairCode g) : + Procedure ea (listCode pairCode) (fun x => [f x,g x]) := + (Procedure.listCons pairCode).comp (p.pair + ((Procedure.listCons pairCode).comp (q.pair (Procedure.constant ea (listCode pairCode) [])))) +noncomputable opaque freshProgram : Procedure routedCode (listCode pairCode) freshPoints := + pairList routedCode (lookupProgram 1) (lookupProgram 2) +noncomputable opaque pathBlockProgram : Procedure routedCode (listCode (listCode pairCode)) pathBlock := by + let first := freshProgram + let second := pairList routedCode (lookupProgram 0) (lookupProgram 1) + let third := (Procedure.listReverse pairCode (0,0)).comp + ((Procedure.listDrop pairCode).comp + ((Procedure.constant routedCode Nat.bits 2).pair + (Procedure.second entryCode (listCode pairCode)))) + exact (Procedure.listCons (listCode pairCode)).comp (first.pair + ((Procedure.listCons (listCode pairCode)).comp (second.pair + ((Procedure.listCons (listCode pairCode)).comp + (third.pair (Procedure.constant routedCode (listCode (listCode pairCode)) [])))))) +noncomputable opaque positionsProgram : Procedure inputCode (listCode pairCode) positions := + (Procedure.listAppend pairCode (0,0)).comp (oldPositionsProgram.pair + ((QuantumRawExchange.flattenProgram pairCode (0,0)).comp + ((Procedure.listMap (zeroEntry,[]) [] freshProgram).comp (selectedProgram true)))) +noncomputable opaque pathsProgram : Procedure inputCode (listCode (listCode pairCode)) paths := + (Procedure.listAppend (listCode pairCode) []).comp + (((Procedure.listMap (zeroEntry,[]) [] (Procedure.second entryCode (listCode pairCode))).comp + (selectedProgram false)).pair + ((QuantumRawExchange.flattenProgram (listCode pairCode) []).comp + ((Procedure.listMap (zeroEntry,[]) [] pathBlockProgram).comp (selectedProgram true)))) +noncomputable opaque program : Procedure inputCode stateCode value := + (QuantumListSchedule.program.comp (precisionProgram.pair scheduleProgram)).pair + (positionsProgram.pair pathsProgram) + +def iterate (N : ℚ) : ℕ → State → State + | 0,s => s + | k+1,s => value (N,iterate N k s) +noncomputable opaque iterateProgram (k : ℕ) : + Procedure inputCode stateCode (fun x => iterate x.1 k x.2) := by + induction k with + | zero => exact dataProgram + | succ k ih => exact program.comp (precisionProgram.pair ih) + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteRepresentation.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteRepresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e307eff18cca186a9849fc6642e6c6df5131f1f --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteRepresentation.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteSelection +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRoutePieces +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleRealization + +namespace OAI + +/-! Representation of a scheduled embedding by finite position and route arrays. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule QuantumRouteCode +open scoped Classical + +variable {Γ : SimpleGraph Pair} + +def Represents (x : State) (hx : Valid x.1) + (P : QMAPathEmbedding (schedule x.1 hx) Γ) : Prop := + x.2.1=List.ofFn P.position ∧ + x.2.2=List.ofFn (fun e => (List.range (2*(schedule x.1 hx).work e+2)).map (P.point e)) + +theorem decoratedEntry_represents (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) + (i : Fin x.2.1.2.2.length) : decoratedEntry x i= + (x.2.1.2.2.get i,(List.range (2*(schedule x.2.1 hx).work i+2)).map (P.point i)) := by + unfold decoratedEntry + rw [hP.2,List.headD_eq_head?_getD,List.head?_drop,List.getElem?_ofFn] + simp only [dite_eq_left i.isLt,Option.getD_some] + +theorem map_selectedRoutes {α : Type} (b : Bool) (x : Input) (f : Routed → α) : + (selectedRoutes b x).map f=List.ofFn + (fun i : Fin (partition b x.2.1.2.2).length => + f (decoratedEntry x (indexEquiv b x.2.1.2.2 i).val)) := by + apply List.ext_getElem + · simp only [List.length_map,List.length_ofFn,selectedRoutes_length] + · intro i hi hj + simp only [List.getElem_map,List.getElem_ofFn] + have hb : i<(partition b x.2.1.2.2).length := by simpa using hj + have h := selectedRoutes_get b x ⟨i,hb⟩ + exact congrArg f h + +theorem selected_index (s : QuantumListSchedule.State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) : + qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)= + (indexEquiv true s.2.2 i).val := + congrArg Subtype.val ((schedule s hs).active.equivFin.symm_apply_apply (activeEquiv s hs i)) + +theorem selected_freshPoints (x : Input) (hx : Valid x.2.1) + (P : QMAPathEmbedding (schedule x.2.1 hx) Γ) (hP : Represents x.2 hx P) + (i : Fin (partition true x.2.1.2.2).length) : + freshPoints (decoratedEntry x (indexEquiv true x.2.1.2.2 i).val)= + [P.point (qmaSelectedIndex (schedule x.2.1 hx).active (activePermutation x.2.1 hx i)) 1, + P.point (qmaSelectedIndex (schedule x.2.1 hx).active (activePermutation x.2.1 hx i)) 2] := by + rw [decoratedEntry_represents x hx P hP] + have hw : 0<(schedule x.2.1 hx).work (indexEquiv true x.2.1.2.2 i).val := + (selected_true_iff _).mp (indexEquiv true x.2.1.2.2 i).property + rw [freshPoints_range _ _ _ hw,selected_index] + +end ContinuumCoulomb.QuantumListRouteProgram + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteSelection.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..27cb67add606aaec841c2dc6cc4f172a7cde2c43 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListRouteSelection.lean @@ -0,0 +1,61 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteProgram +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleGraph + +namespace OAI + +/-! The route-array filter selects exactly the same source indices as the +literal work-list filter, preserving their order. -/ + +namespace ContinuumCoulomb.QuantumListRouteProgram +open QuantumListSchedule + +private theorem headD_drop {α : Type} (xs : List α) (d : α) (i : Fin xs.length) : + (xs.drop i.val).headD d=xs.get i := by + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_eq_getElem i.isLt] + rfl + +def decoratedEntry (x : Input) (i : Fin x.2.1.2.2.length) : Routed := + (x.2.1.2.2.get i,(x.2.2.2.drop i.val).headD []) + +theorem decorated_eq (x : Input) : decorated x=List.ofFn (decoratedEntry x) := by + have h := (List.ofFn_getElem_eq_map (List.range x.2.1.2.2.length) + (fun i => indexed (i,x))).symm + simp only [List.length_range,List.getElem_range] at h + rw [decorated,h] + apply congrArg List.ofFn + funext i + exact congrArg (fun e => (e,(x.2.2.2.drop i.val).headD [])) + (headD_drop x.2.1.2.2 zeroEntry i) + +theorem selectedRoutes_eq (b : Bool) (x : Input) : + selectedRoutes b x=(QuantumListSchedule.indices b x.2.1.2.2).map (decoratedEntry x) := by + rw [selectedRoutes,decorated_eq,List.ofFn_eq_map,List.filter_map] + rfl + +theorem selectedRoutes_length (b : Bool) (x : Input) : + (selectedRoutes b x).length=(partition b x.2.1.2.2).length := by + rw [selectedRoutes_eq,List.length_map,indices_length] + +theorem selectedRoutes_get (b : Bool) (x : Input) (i : Fin (partition b x.2.1.2.2).length) : + (selectedRoutes b x).get (Fin.cast (selectedRoutes_length b x).symm i) = + decoratedEntry x (indexEquiv b x.2.1.2.2 i).val := by + change _ = decoratedEntry x ((indices b x.2.1.2.2).get + (Fin.cast (indices_length b x.2.1.2.2).symm i)) + have hl : i.val<(selectedRoutes b x).length := by + rw [selectedRoutes_length] + exact i.isLt + have hr : i.val<(indices b x.2.1.2.2).length := by + rw [indices_length] + exact i.isLt + have h := congrArg (fun rs : List Routed => rs[i.val]?) (selectedRoutes_eq b x) + simpa only [List.getElem?_map,List.getElem?_eq_getElem hl,List.getElem?_eq_getElem hr, + Option.map_some,Option.some.injEq,List.get_eq_getElem,Fin.val_cast] using h + +theorem selectedRoutes_entries (b : Bool) (x : Input) : + (selectedRoutes b x).map Prod.fst=partition b x.2.1.2.2 := by + rw [selectedRoutes_eq,List.map_map] + exact indices_map b x.2.1.2.2 + +end ContinuumCoulomb.QuantumListRouteProgram + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListSchedule.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..167a2657affefa7cd9420c4de53bd68e0fb38f76 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListSchedule.lean @@ -0,0 +1,200 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleProgram + +namespace OAI + +/-! Validity, fixed-round termination and full-space energy bounds for the +literal list-work routing compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open Matrix MediatorListProgram + +theorem partition_zero (xs : List Entry) (e : Entry) (he : e ∈ partition false xs) : e.1=0 := by + have h := (List.mem_filter.mp he).2 + by_contra hn + simp [selected,hn] at h + +theorem partition_positive (xs : List Entry) (e : Entry) (he : e ∈ partition true xs) : 0 rfl + +theorem indexed_erase (x : Input) (i : ℕ) : + blockBondInput (indexed (i,x)) = QuantumListPathProgram.indexed + (i,(QuantumListPathStep.parameters (stepInput x),erase (partition true x.2.2.2))) := by + dsimp only [indexed,blockBondInput,QuantumListPathProgram.indexed] + rw [erase_head] + +theorem erase_family (x : Input) : + erase (family x) = QuantumListPathProgram.family + (QuantumListPathStep.parameters (stepInput x),erase (partition true x.2.2.2)) := by + calc + _ = ((List.range (partition true x.2.2.2).length).map + (fun i => erase (block (indexed (i,x))))).flatten := by + simp only [erase,family,List.map_flatten,List.map_map,Function.comp_def] + _ = _ := by + simp_rw [erase_block,indexed_erase] + simp only [QuantumListPathProgram.family,erase,List.length_map] + +theorem erase_value (x : Input) : erase (value x).2.2 = QuantumListPathStep.bonds (stepInput x) := by + change erase (partition false x.2.2.2++family x) = _ + rw [erase_append,erase_family] + rfl + +theorem partition_matrix (n : ℕ) (xs : List Entry) : + SourceBondLists.matrix n (erase (partition false xs)++erase (partition true xs)) = + SourceBondLists.matrix n (erase xs) := by + induction xs with + | nil => rfl + | cons e xs ih => + by_cases he : e.1=0 + · simpa [partition,selected,he,erase,SourceBondLists.matrix,add_assoc] using + congrArg (fun x => SourceBondLists.bondMatrix n e.2+x) ih + · simp [partition,selected,he,erase,SourceBondLists.matrix] at ih ⊢ + rw [← ih] + abel + +def Valid (s : State) : Prop := SourceBondLists.bounded s.1 (erase s.2.2) ∧ + ∀ e ∈ erase s.2.2, e.1 ≠ e.2.1 + +theorem partition_valid (s : State) (hs : Valid s) (b : Bool) : + SourceBondLists.bounded s.1 (erase (partition b s.2.2)) ∧ + ∀ e ∈ erase (partition b s.2.2), e.1 ≠ e.2.1 := by + have hm : ∀ e ∈ erase (partition b s.2.2), e ∈ erase s.2.2 := by + intro e he + obtain ⟨a,ha,rfl⟩ := List.mem_map.mp he + exact List.mem_map.mpr ⟨a,(List.mem_filter.mp ha).1,rfl⟩ + exact ⟨fun e he => hs.1 e (hm e he),fun e he => hs.2 e (hm e he)⟩ + +theorem value_valid (x : Input) (hx : Valid x.2) : Valid (value x) := by + have hk := partition_valid x.2 hx false + have hs := partition_valid x.2 hx true + constructor + · change SourceBondLists.bounded (QuantumListPathStep.count (stepInput x)) (erase (value x).2.2) + rw [erase_value] + exact QuantumListPathStep.bonds_bounded (stepInput x) hk.1 hs.1 + · rw [erase_value] + exact QuantumListPathStep.bonds_noLoops (stepInput x) hk.2 hs.1 + +def energy (s : State) : ℝ := + sourceMatrixBottom s.1 (SourceBondLists.matrix s.1 (erase s.2.2)+(s.2.1:ℂ) • 1) + +theorem value_energy_error (x : Input) (hx : Valid x.2) (hN : 0 exact hs + | succ k ih => exact value_valid (N,iterate N k s) ih + +theorem iterate_work_le (N : ℚ) (s : State) {D : ℕ} (hD : ∀ e ∈ s.2.2, e.1≤D) (k : ℕ) : + ∀ e ∈ (iterate N k s).2.2, e.1≤D-k := by + induction k with + | zero => exact hD + | succ k ih => + simpa only [iterate,Nat.sub_sub] using value_work_le (N,iterate N k s) ih + +theorem iterate_complete (N : ℚ) (s : State) {D : ℕ} (hD : ∀ e ∈ s.2.2, e.1≤D) : + ∀ e ∈ (iterate N D s).2.2, e.1=0 := by + intro e he + have h := iterate_work_le N s hD D e he + omega + +theorem iterate_energy_error {N : ℚ} (hN : 0 simp [iterate] + | succ k ih => + calc + _ ≤ |energy (value (N,iterate N k s))-energy (iterate N k s)|+ + |energy (iterate N k s)-energy s| := abs_sub_le _ _ _ + _ ≤ 1/(N:ℝ)+(k:ℝ)/(N:ℝ) := + add_le_add (value_energy_error (N,iterate N k s) (iterate_valid N s hs k) hN) ih + _ = _ := by push_cast; ring + +theorem partition_lengths (xs : List Entry) : + (partition false xs).length+(partition true xs).length=xs.length := by + induction xs with + | nil => rfl + | cons e xs ih => + by_cases he : e.1=0 <;> simp [partition,selected,he] at ih ⊢ <;> omega + +theorem family_length (x : Input) : (family x).length=(partition true x.2.2.2).length*3 := by + have hl (is : List ℕ) : (is.map (fun i => block (indexed (i,x)))).flatten.length=is.length*3 := by + induction is with + | nil => rfl + | cons i is ih => + simp only [List.map_cons,List.flatten_cons,List.length_append,block,List.length_ofFn, + List.length_cons] at * + omega + simpa only [family,List.length_range] using hl (List.range (partition true x.2.2.2).length) + +theorem value_size (x : Input) : + (value x).1+(value x).2.2.length ≤ 5*(x.2.1+x.2.2.2.length) := by + change QuantumListPathStep.count (stepInput x)+(partition false x.2.2.2++family x).length ≤ _ + simp only [QuantumListPathStep.count,stepInput,erase,List.length_map,List.length_append,family_length] + have h := partition_lengths x.2.2.2 + omega + +theorem iterate_size (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).1+(iterate N k s).2.2.length ≤ 5^k*(s.1+s.2.2.length) := by + induction k with + | zero => simp only [iterate,pow_zero,one_mul,le_refl] + | succ k ih => + change (value (N,iterate N k s)).1+(value (N,iterate N k s)).2.2.length ≤ _ + exact (value_size (N,iterate N k s)).trans + (by simpa only [pow_succ,Nat.mul_assoc,Nat.mul_comm 5] using Nat.mul_le_mul_left 5 ih) + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleBounds.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..e14725114fafb4d2ff73d3335d61c85b11ca4cd3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleBounds.lean @@ -0,0 +1,63 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleWeights +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathIteratedBound + +namespace OAI + +/-! Polynomial coefficient bounds for the actual finite output tape of the +fixed-round subdivision program. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open scoped Classical + +theorem value_edge_count (x : Input) : (value x).2.2.length≤3*x.2.2.2.length := by + rw [value_length] + have h := partition_lengths x.2.2.2 + omega + +theorem iterate_edge_count (N : ℚ) (s : State) (k : ℕ) : + (iterate N k s).2.2.length≤3^k*s.2.2.length := by + induction k with + | zero => simp [iterate] + | succ k ih => + exact (value_edge_count (N,iterate N k s)).trans + ((Nat.mul_le_mul_left 3 ih).trans_eq (by rw [pow_succ]; ac_rfl)) + +theorem value_coefficientBound {N : ℚ} (hN : 0 ≤ N) (s : State) (hs : Valid s) + {m L T : ℝ} (hm : (s.2.2.length:ℝ) ≤ m) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : (graph s hs).CoefficientBound L) : + (graph (value (N,s)) (value_valid (N,s) hs)).CoefficientBound + (qmaPathCoefficientBound m L T) := by + have hm' : (Fintype.card (graph s hs).Edge:ℝ) ≤ m := by + have hcard : Fintype.card (graph s hs).Edge=s.2.2.length := + (Fintype.card_congr (α := (graph s hs).Edge) (β := Fin s.2.2.length) + (Equiv.refl _)).trans (Fintype.card_fin _) + exact (congrArg (fun n : ℕ => (n:ℝ)) hcard).le.trans hm + have h := (graph s hs).subdivide_coefficientBound (schedule s hs).active + (fun _ => false) hN hm' hL hT hc + constructor + · exact (congrArg (fun q : ℚ => |(q:ℝ)|) (next_constant N s hs)).le.trans h.1 + · intro e + exact (congrArg (fun q : ℚ => |(q:ℝ)|) (next_weight N s hs e)).le.trans (h.2 _) + +theorem iterate_coefficientBound {N : ℚ} (hN : 0 ≤ N) (s : State) (hs : Valid s) + {m L T : ℝ} (hm : (s.2.2.length:ℝ) ≤ m) (hL : 1 ≤ L) + (hT : |(N:ℝ)| ≤ T) (hc : (graph s hs).CoefficientBound L) (k : ℕ) : + (graph (iterate N k s) (iterate_valid N s hs k)).CoefficientBound + (qmaPathIteratedBound m L T k) := by + have hm0 : 0 ≤ m := (Nat.cast_nonneg _).trans hm + induction k with + | zero => exact hc + | succ k ih => + have hcount : ((iterate N k s).2.2.length:ℝ) ≤ 3^k*m := by + have hcast : ((iterate N k s).2.2.length:ℝ) ≤ 3^k*(s.2.2.length:ℝ) := by + exact_mod_cast iterate_edge_count N s k + exact hcast.trans (mul_le_mul_of_nonneg_left hm (by positivity)) + exact value_coefficientBound hN (iterate N k s) (iterate_valid N s hs k) + hcount (qmaPathIteratedBound_one hm0 hL k) hT ih + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGeometry.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..f14002714e82e044d6a000d341599456cec98397 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGeometry.lean @@ -0,0 +1,201 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleOrder +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathRelabelingProperties + +namespace OAI + +/-! The exact emitted edge order realizes the abstract scheduled subdivision. +This transfers the disjoint-route invariant to the literal list compiler. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open MediatorGraph +open scoped Classical + +private def role {a b : ℕ} (e : Fin a ≃ Fin b) (p : Fin a × Fin 3) : + Fin b ⊕ (Fin b × Fin 2) := + ![.inl (e p.1),.inr (e p.1,0),.inr (e p.1,1)] p.2 + +private def unrole {a b : ℕ} (e : Fin a ≃ Fin b) : + Fin b ⊕ (Fin b × Fin 2) → Fin a × Fin 3 + | .inl i => (e.symm i,0) + | .inr (i,k) => (e.symm i,k.succ) + +private def roleEquiv {a b : ℕ} (e : Fin a ≃ Fin b) : + (Fin a × Fin 3) ≃ (Fin b ⊕ (Fin b × Fin 2)) where + toFun := role e + invFun := unrole e + left_inv := by + rintro ⟨i,k⟩ + fin_cases k <;> simp [role,unrole] + right_inv := by + rintro (i | ⟨i,k⟩) + · simp [role,unrole] + · fin_cases k <;> simp [role,unrole] + +private theorem oldValue (n r : ℕ) (i : Fin n) : (old n r i).val=i.val := rfl +private theorem freshValue (n r : ℕ) (i : Fin r) (a : Fin 2) : + (fresh n r i a).val=n+2*i.val+a.val := by + change n+(a.val+2*i.val)=_ + omega + +def nextEdge (x : Input) (hs : Valid x.2) : + (schedule (value x) (value_valid x hs)).graph.Edge ≃ + ((schedule x.2 hs).next x.1).graph.Edge := + (tagEquiv x).trans (Equiv.sumCongr (retainedEquiv x.2 hs) + (roleEquiv (activePermutation x.2 hs))) + +theorem value_count (x : Input) : + (value x).1=x.2.1+(partition true x.2.2.2).length*2 := by + simp only [value,QuantumListPathStep.count,stepInput,erase,List.length_map] + +def nextVertex (x : Input) (hs : Valid x.2) : + Fin (schedule (value x) (value_valid x hs)).graph.n ≃ + Fin ((schedule x.2 hs).next x.1).graph.n := + (finCongr (value_count x)).trans (vertexRelabel x.2 hs) + +private theorem indexed_entry (x : Input) (i : Fin (partition true x.2.2.2).length) : + (indexed (i.val,x)).2.2=(partition true x.2.2.2).get i := by + change ((partition true x.2.2.2).drop i.val).headD zeroEntry = _ + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_eq_getElem i.isLt] + rfl + +private theorem indexed_bond (x : Input) (i : Fin (partition true x.2.2.2).length) : + blockBondInput (indexed (i.val,x)) = + (QuantumListPathStep.parameters (stepInput x),i.val,((partition true x.2.2.2).get i).2) := by + change (QuantumListPathStep.parameters (stepInput x),i.val,(indexed (i.val,x)).2.2.2) = _ + rw [indexed_entry] + +private def tagLeft (x : Input) (hs : Valid x.2) : Tags x → + Fin (x.2.1+(partition true x.2.2.2).length*2) + | .inl i => old _ _ ((graph x.2 hs).left (retainedEquiv x.2 hs i).val) + | .inr (i,k) => ![fresh _ _ i 0, + old _ _ ((graph x.2 hs).left (qmaSelectedIndex (schedule x.2 hs).active (activePermutation x.2 hs i))), + old _ _ ((graph x.2 hs).right (qmaSelectedIndex (schedule x.2 hs).active (activePermutation x.2 hs i)))] k + +private def tagRight (x : Input) (hs : Valid x.2) : Tags x → + Fin (x.2.1+(partition true x.2.2.2).length*2) + | .inl i => old _ _ ((graph x.2 hs).right (retainedEquiv x.2 hs i).val) + | .inr (i,k) => ![fresh _ _ i 1,fresh _ _ i 0,fresh _ _ i 1] k + +private theorem left_tag (x : Input) (hs : Valid x.2) (t : Tags x) : + finCongr (value_count x) + ((graph (value x) (value_valid x hs)).left ((tagEquiv x).symm t)) = + tagLeft x hs t := by + apply Fin.ext + change ((value x).2.2.get ((tagEquiv x).symm t)).2.1 = _ + rw [tagEquiv_get,Equiv.apply_symm_apply] + rcases t with i | ⟨i,k⟩ + · change ((partition false x.2.2.2).get i).2.1 = _ + simpa only [tagLeft,oldValue,graph] using + (congrArg (fun e : Entry => e.2.1) (retained_source x.2 hs i)).symm + · have he := active_source x.2 hs i + simp only [List.get_eq_getElem] at he + fin_cases k <;> + simp [tagValue,tagLeft,QuantumListPathProgram.bond,QuantumListPathProgram.left, + indexed_bond,QuantumListPathStep.parameters,stepInput,graph, + oldValue,freshValue,he] + +private theorem right_tag (x : Input) (hs : Valid x.2) (t : Tags x) : + finCongr (value_count x) + ((graph (value x) (value_valid x hs)).right ((tagEquiv x).symm t)) = + tagRight x hs t := by + apply Fin.ext + change ((value x).2.2.get ((tagEquiv x).symm t)).2.2.1 = _ + rw [tagEquiv_get,Equiv.apply_symm_apply] + rcases t with i | ⟨i,k⟩ + · change ((partition false x.2.2.2).get i).2.2.1 = _ + simpa only [tagRight,oldValue,graph] using + (congrArg (fun e : Entry => e.2.2.1) (retained_source x.2 hs i)).symm + · fin_cases k <;> + simp [tagValue,tagRight,QuantumListPathProgram.bond,QuantumListPathProgram.right, + indexed_bond,QuantumListPathStep.parameters,stepInput, + freshValue] + +def tagEdge (x : Input) (hs : Valid x.2) : Tags x → + QMAPartialPathsEdge (schedule x.2 hs).active + | .inl i => .inl (retainedEquiv x.2 hs i) + | .inr p => .inr (role (activePermutation x.2 hs) p) + +private theorem nextEdge_eq (x : Input) (hs : Valid x.2) (i : Fin (value x).2.2.length) : + nextEdge x hs i=tagEdge x hs (tagEquiv x i) := by + change (Equiv.sumCongr (retainedEquiv x.2 hs) + (roleEquiv (activePermutation x.2 hs))) (tagEquiv x i) = _ + generalize tagEquiv x i=t + rcases t with i | ⟨i,k⟩ <;> rfl + +theorem nextEdge_tag (x : Input) (hs : Valid x.2) (t : Tags x) : + nextEdge x hs ((tagEquiv x).symm t) = tagEdge x hs t := by + have h := nextEdge_eq x hs ((tagEquiv x).symm t) + simpa only [Equiv.apply_symm_apply] using h + +private theorem tag_left_relabel (x : Input) (hs : Valid x.2) (t : Tags x) : + vertexRelabel x.2 hs (tagLeft x hs t) = + ((schedule x.2 hs).next x.1).graph.left (tagEdge x hs t) := by + rcases t with i | ⟨i,k⟩ + · exact vertexRelabel_old _ _ _ + · fin_cases k + · exact vertexRelabel_fresh _ _ _ _ + · exact vertexRelabel_old _ _ _ + · exact vertexRelabel_old _ _ _ + +private theorem tag_right_relabel (x : Input) (hs : Valid x.2) (t : Tags x) : + vertexRelabel x.2 hs (tagRight x hs t) = + ((schedule x.2 hs).next x.1).graph.right (tagEdge x hs t) := by + rcases t with i | ⟨i,k⟩ + · exact vertexRelabel_old _ _ _ + · fin_cases k + · exact vertexRelabel_fresh _ _ _ _ + · exact vertexRelabel_fresh _ _ _ _ + · exact vertexRelabel_fresh _ _ _ _ + +private theorem work_tag (x : Input) (hs : Valid x.2) (t : Tags x) : + (tagValue x t).1=((schedule x.2 hs).next x.1).work (tagEdge x hs t) := by + rcases t with i | ⟨i,k⟩ + · exact partition_zero _ _ (List.get_mem _ i) + · fin_cases k + · rfl + · rfl + · change (indexed (i.val,x)).2.2.1-1 = + (x.2.2.2.get (qmaSelectedIndex (schedule x.2 hs).active (activePermutation x.2 hs i))).1-1 + rw [indexed_entry] + exact congrArg (fun e : Entry => e.1-1) (active_source x.2 hs i).symm + +private theorem next_left (x : Input) (hs : Valid x.2) (i : Fin (value x).2.2.length) : + nextVertex x hs ((graph (value x) (value_valid x hs)).left i) = + ((schedule x.2 hs).next x.1).graph.left (nextEdge x hs i) := by + rw [nextEdge_eq] + have h : finCongr (value_count x) ((graph (value x) (value_valid x hs)).left i) = + tagLeft x hs (tagEquiv x i) := by + simpa only [Equiv.symm_apply_apply] using left_tag x hs (tagEquiv x i) + exact (congrArg (vertexRelabel x.2 hs) h).trans (tag_left_relabel x hs (tagEquiv x i)) + +private theorem next_right (x : Input) (hs : Valid x.2) (i : Fin (value x).2.2.length) : + nextVertex x hs ((graph (value x) (value_valid x hs)).right i) = + ((schedule x.2 hs).next x.1).graph.right (nextEdge x hs i) := by + rw [nextEdge_eq] + have h : finCongr (value_count x) ((graph (value x) (value_valid x hs)).right i) = + tagRight x hs (tagEquiv x i) := by + simpa only [Equiv.symm_apply_apply] using right_tag x hs (tagEquiv x i) + exact (congrArg (vertexRelabel x.2 hs) h).trans (tag_right_relabel x hs (tagEquiv x i)) + +private theorem next_work (x : Input) (hs : Valid x.2) (i : Fin (value x).2.2.length) : + (schedule (value x) (value_valid x hs)).work i = + ((schedule x.2 hs).next x.1).work (nextEdge x hs i) := by + change ((value x).2.2.get i).1 = _ + rw [tagEquiv_get,nextEdge_eq] + exact work_tag x hs (tagEquiv x i) + +def nextRelabel (x : Input) (hs : Valid x.2) : + QMAPathRelabeling (schedule (value x) (value_valid x hs)) + ((schedule x.2 hs).next x.1) where + vertex := nextVertex x hs + edge := nextEdge x hs + left := next_left x hs + right := next_right x hs + work := next_work x hs + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGraph.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1bfbd1533f55d4f8e7a4a44071bee904ef668a8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleGraph.lean @@ -0,0 +1,109 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListSchedule +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathSchedule + +namespace OAI + +/-! The actual edge-indexed schedule represented by a literal bond/work tape. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open MediatorListProgram +open scoped Classical + +def graph (s : State) (hs : Valid s) : QMARationalExchangeGraph where + n := s.1 + Edge := Fin s.2.2.length + left i := ⟨(s.2.2.get i).2.1, + (hs.1 _ (List.mem_map.mpr ⟨_,List.get_mem _ i,rfl⟩)).1⟩ + right i := ⟨(s.2.2.get i).2.2.1, + (hs.1 _ (List.mem_map.mpr ⟨_,List.get_mem _ i,rfl⟩)).2⟩ + weight i := (s.2.2.get i).2.2.2 + constant := s.2.1 + distinct i h := hs.2 _ (List.mem_map.mpr ⟨_,List.get_mem _ i,rfl⟩) (congrArg Fin.val h) + +def schedule (s : State) (hs : Valid s) : QMAPathSchedule where + graph := graph s hs + work i := (s.2.2.get i).1 + +theorem graph_packed (s : State) (hs : Valid s) : + QuantumListGraph.packed (graph s hs) (Equiv.refl _) = erase s.2.2 := by + change List.ofFn (fun i => (s.2.2.get i).2) = s.2.2.map Prod.snd + simpa only [List.get_eq_getElem] using List.ofFn_getElem_eq_map s.2.2 Prod.snd + +theorem graph_energy (s : State) (hs : Valid s) : (graph s hs).energy = energy s := by + have h := QuantumListGraph.packed_matrix (graph s hs) (Equiv.refl _) + rw [graph_packed] at h + exact congrArg (sourceMatrixBottom s.1) h.symm + +theorem schedule_active (s : State) (hs : Valid s) (i : (schedule s hs).graph.Edge) : + i ∈ (schedule s hs).active ↔ 0<(s.2.2.get i).1 := + QMAPathSchedule.mem_active (schedule s hs) i + +def indices (b : Bool) (xs : List Entry) : List (Fin xs.length) := + (List.finRange xs.length).filter (fun i => selected b (xs.get i)) + +theorem indices_nodup (b : Bool) (xs : List Entry) : (indices b xs).Nodup := + (List.nodup_finRange _).filter _ + +theorem indices_map (b : Bool) (xs : List Entry) : + (indices b xs).map xs.get = partition b xs := by + unfold indices partition + have h : (List.finRange xs.length).map xs.get = xs := by + rw [← List.ofFn_eq_map,List.ofFn_get] + calc + _ = ((List.finRange xs.length).map xs.get).filter (selected b) := List.filter_map.symm + _ = _ := congrArg (List.filter (selected b)) h + +theorem mem_indices (b : Bool) (xs : List Entry) (i : Fin xs.length) : + i ∈ indices b xs ↔ selected b (xs.get i) = true := by + simp only [indices,List.mem_filter,List.mem_finRange,true_and] + +theorem indices_length (b : Bool) (xs : List Entry) : + (indices b xs).length=(partition b xs).length := by + have h := congrArg List.length (indices_map b xs) + simpa only [List.length_map] using h + +def indexEquiv (b : Bool) (xs : List Entry) : + Fin (partition b xs).length ≃ {i : Fin xs.length // selected b (xs.get i)=true} := + (finCongr (indices_length b xs).symm).trans + (((indices_nodup b xs).getEquiv (indices b xs)).trans + (Equiv.subtypeEquivRight (mem_indices b xs))) + +theorem indexEquiv_get (b : Bool) (xs : List Entry) (i : Fin (partition b xs).length) : + xs.get (indexEquiv b xs i).val=(partition b xs).get i := by + change xs.get ((indices b xs).get (Fin.cast (indices_length b xs).symm i)) = _ + have hil : i.val<(indices b xs).length := by rw [indices_length]; exact i.isLt + have h := congrArg (fun ys : List Entry => ys[i.val]?) (indices_map b xs) + simpa only [List.getElem?_map,List.getElem?_eq_getElem hil,List.getElem?_eq_getElem i.isLt, + Option.map_some,Option.some.injEq,List.get_eq_getElem,Fin.val_cast] using h + +theorem selected_true_iff (e : Entry) : selected true e=true ↔ 0 simp [selected,h] + +def activeEquiv (s : State) (hs : Valid s) : + Fin (partition true s.2.2).length ≃ {i : (graph s hs).Edge // i ∈ (schedule s hs).active} := + (indexEquiv true s.2.2).trans (Equiv.subtypeEquivRight (fun i => + (selected_true_iff (s.2.2.get i)).trans (schedule_active s hs i).symm)) + +def retainedEquiv (s : State) (hs : Valid s) : + Fin (partition false s.2.2).length ≃ {i : (graph s hs).Edge // i ∉ (schedule s hs).active} := + (indexEquiv false s.2.2).trans (Equiv.subtypeEquivRight (fun i => by + apply (selected_false_iff (s.2.2.get i)).trans + have hn : (s.2.2.get i).1=0 ↔ ¬0<(s.2.2.get i).1 := by omega + exact hn.trans (not_congr (schedule_active s hs i)).symm)) + +def activePermutation (s : State) (hs : Valid s) : + Fin (partition true s.2.2).length ≃ Fin (schedule s hs).active.card := + (activeEquiv s hs).trans (schedule s hs).active.equivFin + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleLabels.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..24d4439ca9841d7a72c8719dd4dca5abdf20c13b --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleLabels.lean @@ -0,0 +1,48 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleGraph +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathRelabeling + +namespace OAI + +/-! The selected-list ordering gives an explicit correspondence with the +abstract schedule's fresh spins. Retained source spins keep their labels. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open MediatorGraph + +theorem active_source (s : State) (hs : Valid s) (i : Fin (partition true s.2.2).length) : + s.2.2.get (qmaSelectedIndex (schedule s hs).active (activePermutation s hs i)) = + (partition true s.2.2).get i := by + have he : qmaSelectedIndex (schedule s hs).active (activePermutation s hs i) = + (activeEquiv s hs i).val := + congrArg Subtype.val ((schedule s hs).active.equivFin.symm_apply_apply (activeEquiv s hs i)) + exact (congrArg (fun j : (schedule s hs).graph.Edge => s.2.2.get j) he).trans + (indexEquiv_get true s.2.2 i) + +theorem retained_source (s : State) (hs : Valid s) (i : Fin (partition false s.2.2).length) : + s.2.2.get (retainedEquiv s hs i).val=(partition false s.2.2).get i := + indexEquiv_get false s.2.2 i + +def vertexRelabel (s : State) (hs : Valid s) : + Fin (s.1+(partition true s.2.2).length*2) ≃ Fin (s.1+(schedule s hs).active.card*2) := + ((vertexEquiv s.1 (partition true s.2.2).length).symm.trans + (Equiv.sumCongr (Equiv.refl (Fin s.1)) + (Equiv.prodCongr (activePermutation s hs) (Equiv.refl (Fin 2))))).trans + (vertexEquiv s.1 (schedule s hs).active.card) + +theorem vertexRelabel_old (s : State) (hs : Valid s) (v : Fin s.1) : + vertexRelabel s hs (old s.1 (partition true s.2.2).length v) = + old s.1 (schedule s hs).active.card v := by + simp [vertexRelabel,old] + +theorem vertexRelabel_fresh (s : State) (hs : Valid s) + (i : Fin (partition true s.2.2).length) (a : Fin 2) : + vertexRelabel s hs (fresh s.1 (partition true s.2.2).length i a) = + fresh s.1 (schedule s hs).active.card (activePermutation s hs i) a := by + simp [vertexRelabel,fresh] + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleOrder.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f78168608a71f3160d79c64c6c3144f5db0c053 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleOrder.lean @@ -0,0 +1,91 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleLabels + +namespace OAI + +/-! Exact edge order in the emitted next-round list: retained edges followed +by three consecutive edges for each selected source edge. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open MediatorListProgram + +abbrev Tags (x : Input) := Fin (partition false x.2.2.2).length ⊕ + (Fin (partition true x.2.2.2).length × Fin 3) + +def tagValue (x : Input) : Tags x → Entry + | .inl i => (partition false x.2.2.2).get i + | .inr (i,k) => (blockWork (indexed (i.val,x)) k, + QuantumListPathProgram.bond (blockBondInput (indexed (i.val,x))) k) + +def flatTagEquiv (x : Input) : + Fin ((partition false x.2.2.2).length+(partition true x.2.2.2).length*3) ≃ Tags x := + finSumFinEquiv.symm.trans (Equiv.sumCongr (Equiv.refl _) finProdFinEquiv.symm) + +theorem family_ofFn (x : Input) : family x = + (List.ofFn fun i : Fin (partition true x.2.2.2).length => block (indexed (i.val,x))).flatten := by + have h : (List.range (partition true x.2.2.2).length).map (fun i => block (indexed (i,x))) = + List.ofFn (fun i : Fin (partition true x.2.2.2).length => block (indexed (i.val,x))) := by + simpa only [List.length_range,List.getElem_range,Fin.val_cast] using + (List.ofFn_getElem_eq_map (List.range (partition true x.2.2.2).length) + (fun i => block (indexed (i,x)))).symm + exact congrArg List.flatten h + +private theorem ofFn_triples {m : ℕ} (f : Fin m × Fin 3 → Entry) : + List.ofFn (fun k : Fin (m*3) => f (finProdFinEquiv.symm k)) = + (List.ofFn fun i : Fin m => List.ofFn fun k : Fin 3 => f (i,k)).flatten := by + rw [List.ofFn_mul] + apply congrArg List.flatten + apply congrArg (fun g : Fin m → List Entry => List.ofFn g) + funext i + apply congrArg (fun g : Fin 3 → Entry => List.ofFn g) + funext k + have he : (⟨i.val*3+k.val,by omega⟩ : Fin (m*3))=finProdFinEquiv (i,k) := by + apply Fin.ext + change i.val*3+k.val=k.val+3*i.val + omega + rw [he,Equiv.symm_apply_apply] + +theorem value_ofFn (x : Input) : + (value x).2.2 = List.ofFn (fun i => tagValue x (flatTagEquiv x i)) := by + rw [List.ofFn_add] + change _ = (List.ofFn (fun i : Fin (partition false x.2.2.2).length => + tagValue x (flatTagEquiv x (Fin.castAdd ((partition true x.2.2.2).length*3) i))))++ + List.ofFn (fun i : Fin ((partition true x.2.2.2).length*3) => + tagValue x (flatTagEquiv x (Fin.natAdd (partition false x.2.2.2).length i))) + simp only [flatTagEquiv,Equiv.trans_apply,finSumFinEquiv_symm_apply_castAdd, + finSumFinEquiv_symm_apply_natAdd,Equiv.sumCongr_apply,Equiv.refl_apply, + Sum.map_inl,Sum.map_inr,tagValue] + rw [List.ofFn_get] + have h3 := ofFn_triples (fun p : Fin (partition true x.2.2.2).length × Fin 3 => + (blockWork (indexed (p.1.val,x)) p.2, + QuantumListPathProgram.bond (blockBondInput (indexed (p.1.val,x))) p.2)) + rw [h3] + change partition false x.2.2.2++family x = _ + rw [family_ofFn] + rfl + +theorem value_length (x : Input) : (value x).2.2.length = + (partition false x.2.2.2).length+(partition true x.2.2.2).length*3 := by + change (partition false x.2.2.2++family x).length = _ + rw [List.length_append,family_length] + +def tagEquiv (x : Input) : Fin (value x).2.2.length ≃ Tags x := + (finCongr (value_length x)).trans (flatTagEquiv x) + +theorem tagEquiv_get (x : Input) (i : Fin (value x).2.2.length) : + (value x).2.2.get i=tagValue x (tagEquiv x i) := by + have hi : i.val<(partition false x.2.2.2).length+(partition true x.2.2.2).length*3 := by + rw [← value_length] + exact i.isLt + have h := congrArg (fun xs : List Entry => xs[i.val]?) (value_ofFn x) + have hc : Fin.cast (value_length x) i = ⟨i.val,hi⟩ := Fin.ext rfl + change (value x).2.2.get i = tagValue x (flatTagEquiv x (Fin.cast (value_length x) i)) + rw [hc] + simpa only [List.getElem?_eq_getElem i.isLt,List.getElem?_ofFn,dite_eq_left hi, + Option.some.injEq,List.get_eq_getElem] using h + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleProgram.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e36c7ddd69586f01e6c2355e22198fa033e1e806 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleProgram.lean @@ -0,0 +1,164 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListPathInput + +namespace OAI + +/-! A fixed-round routing compiler on literal bond/work lists. Each active +edge receives one singlet pair; its unfinished tail retains one less work unit. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open ExactQuantumFactoring.BitStackProgram MediatorListProgram + +abbrev Entry := ℕ × Bond +def entryCode : Entry → List Bool := prodCode unaryCode bondCode +def zeroEntry : Entry := (0,zeroBond) +def selected (active : Bool) (e : Entry) : Bool := if e.1=0 then !active else active +def partition (active : Bool) (xs : List Entry) : List Entry := xs.filter (selected active) +def erase (xs : List Entry) : List Bond := xs.map Prod.snd + +noncomputable opaque selectedProgram (active : Bool) : + Procedure entryCode Procedure.boolCode (selected active) := + (Procedure.conditional (Procedure.unaryZero.comp (Procedure.first unaryCode bondCode)) + (Procedure.constant entryCode Procedure.boolCode (!active)) + (Procedure.constant entryCode Procedure.boolCode active)).congrFun (by intro e; simp only [Function.comp_apply,selected,decide_eq_true_eq]) + +noncomputable opaque partitionProgram (active : Bool) : + Procedure (listCode entryCode) (listCode entryCode) (partition active) := by + let single : Procedure entryCode (listCode entryCode) (fun e => [e]) := + (Procedure.listCons entryCode).comp ((Procedure.identity entryCode).pair + (Procedure.constant entryCode (listCode entryCode) [])) + let chunk := Procedure.conditional (selectedProgram active) single + (Procedure.constant entryCode (listCode entryCode) []) + refine ((QuantumRawExchange.flattenProgram entryCode zeroEntry).comp + (Procedure.listMap zeroEntry [] chunk)).congrFun ?_ + intro xs + induction xs with + | nil => rfl + | cons e xs ih => + dsimp only [Function.comp_apply] at ih + cases h : selected active e <;> simpa [partition,h] using ih + +noncomputable opaque eraseProgram : Procedure (listCode entryCode) (listCode bondCode) erase := + Procedure.listMap zeroEntry zeroBond (Procedure.second unaryCode bondCode) + +abbrev State := ℕ × (ℚ × List Entry) +def stateCode : State → List Bool := prodCode unaryCode (prodCode ratCode (listCode entryCode)) +abbrev Input := ℚ × State +def inputCode : Input → List Bool := prodCode ratCode stateCode + +def stepInput (x : Input) : QuantumListPathStep.Input := + ((x.2.1,false,x.1,x.2.2.1),(erase (partition false x.2.2.2),erase (partition true x.2.2.2))) + +noncomputable opaque stateProgram : Procedure inputCode stateCode Prod.snd := Procedure.second _ _ +noncomputable opaque precisionProgram : Procedure inputCode ratCode Prod.fst := Procedure.first _ _ +noncomputable opaque countInputProgram : Procedure inputCode unaryCode (fun x => x.2.1) := + (Procedure.first _ _).comp stateProgram +noncomputable opaque tailProgram : Procedure inputCode (prodCode ratCode (listCode entryCode)) + (fun x => x.2.2) := (Procedure.second _ _).comp stateProgram +noncomputable opaque scalarInputProgram : Procedure inputCode ratCode (fun x => x.2.2.1) := + (Procedure.first _ _).comp tailProgram +noncomputable opaque entriesProgram : Procedure inputCode (listCode entryCode) (fun x => x.2.2.2) := + (Procedure.second _ _).comp tailProgram +noncomputable opaque selectedEntriesProgram (b : Bool) : + Procedure inputCode (listCode entryCode) (fun x => partition b x.2.2.2) := + (partitionProgram b).comp entriesProgram +noncomputable opaque stepInputProgram : + Procedure inputCode QuantumListPathStep.inputCode stepInput := + (countInputProgram.pair ((Procedure.constant inputCode Procedure.boolCode false).pair + (precisionProgram.pair scalarInputProgram))).pair + ((eraseProgram.comp (selectedEntriesProgram false)).pair + (eraseProgram.comp (selectedEntriesProgram true))) + +abbrev BlockInput := QuantumListPathProgram.Parameters × (ℕ × Entry) +def blockInputCode : BlockInput → List Bool := + prodCode QuantumListPathProgram.parametersCode (prodCode unaryCode entryCode) +def blockBondInput (x : BlockInput) : QuantumListPathProgram.Input := (x.1,x.2.1,x.2.2.2) +def blockWork (x : BlockInput) (k : Fin 3) : ℕ := if k=2 then x.2.2.1-1 else 0 +def block (x : BlockInput) : List Entry := + List.ofFn fun k => (blockWork x k,QuantumListPathProgram.bond (blockBondInput x) k) + +noncomputable opaque blockBondInputProgram : + Procedure blockInputCode QuantumListPathProgram.inputCode blockBondInput := by + let p := Procedure.first QuantumListPathProgram.parametersCode (prodCode unaryCode entryCode) + let t := Procedure.second QuantumListPathProgram.parametersCode (prodCode unaryCode entryCode) + let i := (Procedure.first unaryCode entryCode).comp t + let e := (Procedure.second unaryCode entryCode).comp t + exact p.pair (i.pair ((Procedure.second unaryCode bondCode).comp e)) + +noncomputable opaque blockWorkProgram (k : Fin 3) : + Procedure blockInputCode unaryCode (fun x => blockWork x k) := by + by_cases hk : k=2 + · let p : Procedure blockInputCode unaryCode (fun x => x.2.2.1-1) := + Procedure.unaryPred.comp ((Procedure.first unaryCode bondCode).comp + ((Procedure.second unaryCode entryCode).comp + (Procedure.second QuantumListPathProgram.parametersCode (prodCode unaryCode entryCode)))) + exact p.congrFun (by intro x; simp only [blockWork,hk,ite_true]) + · exact (Procedure.constant blockInputCode unaryCode 0).congrFun + (by intro x; simp only [blockWork,hk,ite_false]) + +noncomputable opaque blockProgram : Procedure blockInputCode (listCode entryCode) block := + QuantumRawExchange.fixedListProgram blockInputCode entryCode 3 + (fun k x => (blockWork x k,QuantumListPathProgram.bond (blockBondInput x) k)) + (fun k => (blockWorkProgram k).pair ((QuantumListPathProgram.bondProgram k).comp blockBondInputProgram)) + +def indexed (x : ℕ × Input) : BlockInput := + (QuantumListPathStep.parameters (stepInput x.2),x.1, + ((partition true x.2.2.2.2).drop x.1).headD zeroEntry) +def family (x : Input) : List Entry := + ((List.range (partition true x.2.2.2).length).map (fun i => block (indexed (i,x)))).flatten + +def value (x : Input) : State := + (QuantumListPathStep.count (stepInput x),QuantumListPathStep.constant (stepInput x), + partition false x.2.2.2++family x) + +noncomputable opaque indexedProgram : + Procedure (prodCode unaryCode inputCode) blockInputCode indexed := by + let i := Procedure.first unaryCode inputCode + let x := Procedure.second unaryCode inputCode + let p := (QuantumListPathStep.parametersProgram.comp stepInputProgram).comp x + let xs := (selectedEntriesProgram true).comp x + let e := (Procedure.listGet entryCode zeroEntry).comp ((Procedure.unaryToBits.comp i).pair xs) + exact p.pair (i.pair e) + +noncomputable opaque familyLengthProgram : Procedure inputCode unaryCode + (fun x => (partition true x.2.2.2).length) := + (ExactQuantumFactoring.NativeAIG.Emission.listUnaryLength entryCode zeroEntry).comp + (selectedEntriesProgram true) + +noncomputable opaque familyTabProgram : + Procedure (prodCode unaryCode inputCode) (listCode (listCode entryCode)) + (fun x => (List.range x.1).map (fun i => block (indexed (i,x.2)))) := + Procedure.tabulate (f := fun x i => block (indexed (i,x))) [] (blockProgram.comp indexedProgram) + +noncomputable opaque familyInputProgram : Procedure inputCode (prodCode unaryCode inputCode) + (fun x => ((partition true x.2.2.2).length,x)) := + familyLengthProgram.pair (Procedure.identity inputCode) + +noncomputable opaque familyNestedProgram : Procedure inputCode (listCode (listCode entryCode)) + (fun x => (List.range (partition true x.2.2.2).length).map (fun i => block (indexed (i,x)))) := + (familyTabProgram.comp familyInputProgram).congrFun (by intro x; rfl) + +noncomputable opaque familyProgram : Procedure inputCode (listCode entryCode) family := + (QuantumRawExchange.flattenProgram entryCode zeroEntry).comp familyNestedProgram + +noncomputable opaque program : Procedure inputCode stateCode value := + (QuantumListPathStep.countProgram.comp stepInputProgram).pair + ((QuantumListPathStep.constantProgram.comp stepInputProgram).pair + ((Procedure.listAppend entryCode zeroEntry).comp + ((selectedEntriesProgram false).pair familyProgram))) + +def iterate (N : ℚ) : ℕ → State → State + | 0,s => s + | k+1,s => value (N,iterate N k s) + +noncomputable opaque iterateProgram (k : ℕ) : + Procedure inputCode stateCode (fun x => iterate x.1 k x.2) := by + induction k with + | zero => exact stateProgram + | succ k ih => exact program.comp (precisionProgram.pair ih) + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRealization.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..65aa81b2f9cb75baa21715158cfe56e97e87f846 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRealization.lean @@ -0,0 +1,80 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleGeometry + +namespace OAI + +/-! Actual finite-list schedule: route preservation and nearest-neighbor +realization after the prescribed number of rounds. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open scoped Classical + +variable {Γ : SimpleGraph (ℕ × ℕ)} + +def nextEmbedding (x : Input) (hs : Valid x.2) + (P : QMAPathEmbedding (schedule x.2 hs) Γ) : + QMAPathEmbedding (schedule (value x) (value_valid x hs)) Γ := + (nextRelabel x hs).symm.transport (P.next x.1) + +theorem nextEmbedding_bounded (x : Input) (hs : Valid x.2) + (P : QMAPathEmbedding (schedule x.2 hs) Γ) {X Y : ℕ} + (h : P.Bounded X Y) : (nextEmbedding x hs P).Bounded X Y := + (nextRelabel x hs).symm.transport_bounded (P.next x.1) (P.next_bounded x.1 h) + +theorem value_degree (x : Input) (hs : Valid x.2) {d : ℕ} (h3 : 3≤d) + (hd : ∀ v, qmaGraphDegree (graph x.2 hs).left (graph x.2 hs).right v≤d) : + ∀ v, qmaGraphDegree (graph (value x) (value_valid x hs)).left + (graph (value x) (value_valid x hs)).right v≤d := by + intro v + exact (le_of_eq ((nextRelabel x hs).degree v).symm).trans + ((schedule x.2 hs).next_degree x.1 h3 hd _) + +def iterateEmbedding (N : ℚ) (s : State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) : + (k : ℕ) → QMAPathEmbedding (schedule (iterate N k s) (iterate_valid N s hs k)) Γ + | 0 => P + | k+1 => nextEmbedding (N,iterate N k s) (iterate_valid N s hs k) + (iterateEmbedding N s hs P k) + +theorem iterateEmbedding_bounded (N : ℚ) (s : State) (hs : Valid s) + (P : QMAPathEmbedding (schedule s hs) Γ) {X Y : ℕ} + (h : P.Bounded X Y) (k : ℕ) : (iterateEmbedding N s hs P k).Bounded X Y := by + induction k with + | zero => exact h + | succ k ih => exact nextEmbedding_bounded _ _ _ ih + +theorem iterate_degree (N : ℚ) (s : State) (hs : Valid s) {d : ℕ} (h3 : 3≤d) + (hd : ∀ v, qmaGraphDegree (graph s hs).left (graph s hs).right v≤d) (k : ℕ) : + ∀ v, qmaGraphDegree (graph (iterate N k s) (iterate_valid N s hs k)).left + (graph (iterate N k s) (iterate_valid N s hs k)).right v≤d := by + induction k with + | zero => exact hd + | succ k ih => exact value_degree _ _ h3 ih + +theorem realize {N : ℚ} (hN : 0 iterate_complete N s hD _ (List.get_mem _ e)) + · exact iterate_degree N s hs h3 hd D + · exact iterate_size N s D + · exact iterate_energy_error hN s hs D + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRelabel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9c084596ea8941c61b99f5f38ebb148a47faf04 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleRelabel.lean @@ -0,0 +1,43 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPathRelabelingIteration +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleRealization + +namespace OAI + +/-! The emitted schedule has exactly the canonical subdivided coordinates, +up to its explicit finite vertex and edge permutations. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open scoped Classical + +def iterateRelabel (N : ℚ) (s : State) (hs : Valid s) : (k : ℕ) → + QMAPathRelabeling (schedule (iterate N k s) (iterate_valid N s hs k)) + ((schedule s hs).iterate N k) + | 0 => QMAPathRelabeling.refl _ + | k+1 => (nextRelabel (N,iterate N k s) (iterate_valid N s hs k)).trans + ((iterateRelabel N s hs k).next N) + +theorem iterateRelabel_geometry {Γ : SimpleGraph (ℕ × ℕ)} + (N : ℚ) (s : State) (hs : Valid s) (P : QMAPathEmbedding (schedule s hs) Γ) (k : ℕ) : + (∀ v, (P.iterate N k).position ((iterateRelabel N s hs k).vertex v)= + (iterateEmbedding N s hs P k).position v) ∧ + (∀ e j, (P.iterate N k).point ((iterateRelabel N s hs k).edge e) j= + (iterateEmbedding N s hs P k).point e j) := by + induction k with + | zero => exact ⟨fun _ => rfl,fun _ _ => rfl⟩ + | succ k ih => + let E := iterateRelabel N s hs k + let F := nextRelabel (N,iterate N k s) (iterate_valid N s hs k) + constructor + · intro v + exact (E.next_position (iterateEmbedding N s hs P k) (P.iterate N k) + ih.1 ih.2 N (F.vertex v)).trans (by rfl) + · intro e j + exact (E.next_point (iterateEmbedding N s hs P k) (P.iterate N k) + ih.2 N (F.edge e) j).trans (by rfl) + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleScale.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..87296e988e17ef68dd42abd9604aed3968beefc0 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleScale.lean @@ -0,0 +1,77 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleGeometry + +namespace OAI + +/-! Exact calibration equality between the literal selected-weight sums and +the finite graph's rational subdivision scale. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open scoped BigOperators Classical + +private theorem univ_eq {α : Type} (a b : Fintype α) : + @Finset.univ α a = @Finset.univ α b := + congrArg (fun i : Fintype α => @Finset.univ α i) (Subsingleton.elim a b) + +theorem partition_sum (b : Bool) (xs : List Entry) (f : Entry → ℚ) : + ((partition b xs).map f).sum = ∑ i : Fin (partition b xs).length, f ((partition b xs).get i) := by + have h : List.ofFn (fun i => f ((partition b xs).get i))=(partition b xs).map f := by + simpa only [List.get_eq_getElem] using List.ofFn_getElem_eq_map (partition b xs) f + rw [← h,List.sum_ofFn] + +theorem active_sum (s : State) (hs : Valid s) (f : Entry → ℚ) : + (∑ i : Fin (partition true s.2.2).length, f ((partition true s.2.2).get i)) = + ∑ j : Fin (schedule s hs).active.card, + f (s.2.2.get (qmaSelectedIndex (schedule s hs).active j)) := by + have h := (activePermutation s hs).sum_comp + (fun j => f (s.2.2.get (qmaSelectedIndex (schedule s hs).active j))) + simpa only [active_source] using h + +theorem retained_sum (s : State) (hs : Valid s) (f : Entry → ℚ) : + (∑ i : Fin (partition false s.2.2).length, f ((partition false s.2.2).get i)) = + ∑ j : {j : (graph s hs).Edge // j ∉ (schedule s hs).active}, f (s.2.2.get j.val) := by + have h := (retainedEquiv s hs).sum_comp (fun j => f (s.2.2.get j.val)) + simpa only [retained_source] using h + +theorem scale_eq (N : ℚ) (s : State) (hs : Valid s) : + (QuantumListPathStep.parameters (stepInput (N,s))).2.2 = + (graph s hs).pathScale (schedule s hs).active N := by + let S := (schedule s hs).active + let p := QuantumListPathStep.scaleInput (stepInput (N,s)) + let A : ℚ := 3*(∑ j : Fin S.card, (1+2*|(graph s hs).weight (qmaSelectedIndex S j)|)) + let B : ℚ := 3*(∑ j : {j : (graph s hs).Edge // j ∉ S}, |(graph s hs).weight j.val|)+|(graph s hs).constant| + let D : ℚ := B+4*(∑ j : Fin S.card, (1+|(graph s hs).weight (qmaSelectedIndex S j)|)^2) + have ha : QuantumPathScaleProgram.active p=A := by + have h := congrArg (fun z : ℚ => 3*z) + ((partition_sum true s.2.2 (fun e => 1+2*|e.2.2.2|)).trans + (active_sum s hs (fun e => 1+2*|e.2.2.2|))) + simpa only [A,S,graph,QuantumPathScaleProgram.active,p,QuantumListPathStep.scaleInput,stepInput, + erase,List.map_map,Function.comp_def,QuantumPathScaleProgram.linearCost] using h + have hb : QuantumPathScaleProgram.base p=B := by + have h := congrArg (fun z : ℚ => 3*z+|s.2.1|) + ((partition_sum false s.2.2 (fun e => |e.2.2.2|)).trans + (retained_sum s hs (fun e => |e.2.2.2|))) + simpa only [B,S,graph,QuantumPathScaleProgram.base,p,QuantumListPathStep.scaleInput,stepInput, + erase,List.map_map,Function.comp_def] using h + have hsq : (p.2.2.map QuantumPathScaleProgram.squareCost).sum = + ∑ j : Fin S.card, (1+|(graph s hs).weight (qmaSelectedIndex S j)|)^2 := by + have h := (partition_sum true s.2.2 (fun e => (1+|e.2.2.2|)^2)).trans + (active_sum s hs (fun e => (1+|e.2.2.2|)^2)) + simpa only [S,graph,p,QuantumListPathStep.scaleInput,stepInput,erase,List.map_map, + Function.comp_def,QuantumPathScaleProgram.squareCost] using h + have hd : QuantumPathScaleProgram.correction p=D := by + change QuantumPathScaleProgram.base p+4*(p.2.2.map QuantumPathScaleProgram.squareCost).sum=D + rw [hb,hsq] + change QuantumPathScaleProgram.value p = _ + unfold QuantumPathScaleProgram.value + rw [ha,hd] + simp only [A,B,D,S,p,QuantumListPathStep.scaleInput,stepInput, + QMARationalExchangeGraph.pathScale,graph] + congr! + all_goals first | (cases ‹HEq _ _›; rfl) | apply univ_eq + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleWeights.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..d18580b3a5c745c01db2b49b59c09a513adf9c40 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumListScheduleWeights.lean @@ -0,0 +1,83 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListScheduleScale +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumListRouteNextPoint + +namespace OAI + +/-! Exact coefficients and scalar offset of the literal scheduled subdivision. +The edge labels agree with the geometry relabeling. -/ + +noncomputable section +namespace ContinuumCoulomb.QuantumListSchedule +open scoped BigOperators Classical + +private theorem selected_bond (x : Input) (i : Fin (partition true x.2.2.2).length) : + blockBondInput (indexed (i.val,x)) = + (QuantumListPathStep.parameters (stepInput x),i.val,((partition true x.2.2.2).get i).2) := by + have h : (indexed (i.val,x)).2.2=(partition true x.2.2.2).get i := by + change ((partition true x.2.2.2).drop i.val).headD zeroEntry = _ + rw [List.headD_eq_head?_getD,List.head?_drop,List.getElem?_eq_getElem i.isLt] + rfl + change (QuantumListPathStep.parameters (stepInput x),i.val,(indexed (i.val,x)).2.2.2) = _ + rw [h] + +theorem next_weight_tag (N : ℚ) (s : State) (hs : Valid s) (t : Tags (N,s)) : + (graph (value (N,s)) (value_valid (N,s) hs)).weight ((tagEquiv (N,s)).symm t) = + ((schedule s hs).next N).graph.weight (tagEdge (N,s) hs t) := by + change ((value (N,s)).2.2.get ((tagEquiv (N,s)).symm t)).2.2.2 = _ + rw [tagEquiv_get,Equiv.apply_symm_apply] + rcases t with i | ⟨i,k⟩ + · exact (congrArg (fun e : Entry => e.2.2.2) (retained_source s hs i)).symm + · change QuantumListPathProgram.coefficient (blockBondInput (indexed (i.val,(N,s)))) k.castSucc = _ + unfold QuantumListPathProgram.coefficient + rw [selected_bond] + simp only [QuantumListPathStep.parameters,stepInput] + change QuantumPathCode.coefficients (false, + (QuantumListPathStep.parameters (stepInput (N,s))).2.2, + ((partition true s.2.2).get i).2.2.2) k.castSucc = _ + rw [scale_eq N s hs] + have he := congrArg (fun e : Entry => e.2.2.2) (active_source s hs i) + rw [← he] + fin_cases k <;> rfl + +theorem next_weight (N : ℚ) (s : State) (hs : Valid s) + (i : Fin (value (N,s)).2.2.length) : + (graph (value (N,s)) (value_valid (N,s) hs)).weight i = + ((schedule s hs).next N).graph.weight (nextEdge (N,s) hs i) := by + have h := next_weight_tag N s hs (tagEquiv (N,s) i) + have hi : (tagEquiv (N,s)).symm (tagEquiv (N,s) i)=i := Equiv.symm_apply_apply _ _ + have he := nextEdge_tag (N,s) hs (tagEquiv (N,s) i) + exact (congrArg (graph (value (N,s)) (value_valid (N,s) hs)).weight hi).symm.trans + (h.trans (congrArg ((schedule s hs).next N).graph.weight + ((congrArg (nextEdge (N,s) hs) hi).symm.trans he).symm)) + +theorem next_constant (N : ℚ) (s : State) (hs : Valid s) : + (graph (value (N,s)) (value_valid (N,s) hs)).constant = + ((schedule s hs).next N).graph.constant := by + let R := (graph s hs).pathScale (schedule s hs).active N + have hsum := (partition_sum true s.2.2 + (fun e => (3/4:ℚ)+3*e.2.2.2^2+3*R^2)).trans + (active_sum s hs (fun e => (3/4:ℚ)+3*e.2.2.2^2+3*R^2)) + change s.2.1+QuantumListPathProgram.familyOffset + (QuantumListPathStep.parameters (stepInput (N,s)),erase (partition true s.2.2)) = _ + unfold QuantumListPathProgram.familyOffset QuantumListPathProgram.offset + QuantumListPathProgram.coefficient + simp only [erase,List.map_map,Function.comp_def] + change s.2.1+((partition true s.2.2).map (fun e => + (3/4:ℚ)+3*e.2.2.2^2+3*(QuantumListPathStep.parameters (stepInput (N,s))).2.2^2)).sum = _ + rw [scale_eq N s hs] + change s.2.1+((partition true s.2.2).map (fun e => (3/4:ℚ)+3*e.2.2.2^2+3*R^2)).sum = _ + rw [hsum,Finset.sum_add_distrib] + simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] + change s.2.1+((∑ i : Fin (schedule s hs).active.card, + ((3/4:ℚ)+3*(s.2.2.get (qmaSelectedIndex (schedule s hs).active i)).2.2.2^2))+ + (schedule s hs).active.card*(3*R^2)) = _ + change _ = (s.2.1+∑ i : Fin (schedule s hs).active.card, + ((3/4:ℚ)+3*(s.2.2.get (qmaSelectedIndex (schedule s hs).active i)).2.2.2^2))+ + 3*(schedule s hs).active.card*R^2 + ring + +end ContinuumCoulomb.QuantumListSchedule + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalAction.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cdf4f6b2930c655a96bf528f3bb7d78c4b13854 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalAction.lean @@ -0,0 +1,71 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalCoordinates + +namespace OAI + +/-! Actions of local flips and spectator-identity tensor factors. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def qmaBitFlip (i : ι) (s : ι → Fin 2) : ι → Fin 2 := + Function.update s i (Equiv.swap (0:Fin 2) 1 (s i)) + +omit [Fintype ι] in +theorem qmaBitFlip_involutive (i : ι) : Function.Involutive (qmaBitFlip i) := by + intro s + funext j + by_cases h : j = i + · subst j + simp [qmaBitFlip] + · simp [qmaBitFlip,h] + +def qmaBitFlipMatrix (i : ι) : Matrix (ι → Fin 2) (ι → Fin 2) ℂ := + fun s t => if s = qmaBitFlip i t then 1 else 0 + +theorem qmaBitFlipMatrix_local (i : ι) : QMALocalOn {i} (qmaBitFlipMatrix i) := by + apply qmaLocalOn_permutation {i} (qmaBitFlip i) + (fun s j => Equiv.swap (0:Fin 2) 1 (s j)) + · intro s + funext j + have hj : j.val = i := Finset.mem_singleton.mp j.property + simp [qmaSupportSplit,Equiv.piEquivPiSubtypeProd,qmaBitFlip,hj] + · intro s + funext j + have hj : j.val ≠ i := by simpa using j.property + simp [qmaSupportSplit,Equiv.piEquivPiSubtypeProd,qmaBitFlip,hj] + +theorem qmaBitFlipMatrix_mulVec (i : ι) (u : (ι → Fin 2) → ℂ) (s : ι → Fin 2) : + (qmaBitFlipMatrix i).mulVec u s = u (qmaBitFlip i s) := by + change (∑ t, (if s = qmaBitFlip i t then (1:ℂ) else 0)*u t) = _ + have he (t : ι → Fin 2) : s = qmaBitFlip i t ↔ t = qmaBitFlip i s := by + constructor + · intro h + rw [h,qmaBitFlip_involutive] + · intro h + rw [h,qmaBitFlip_involutive] + simp only [he,ite_mul,one_mul,zero_mul] + simp + +theorem qmaJoinMatrix_one_left_mulVec {κ : Type*} [Fintype κ] [DecidableEq κ] + (A : Matrix (κ → Fin 2) (κ → Fin 2) ℂ) (u : (ι ⊕ κ → Fin 2) → ℂ) + (s : ι ⊕ κ → Fin 2) : + (qmaJoinMatrix (ι := ι) 1 A).mulVec u s = + A.mulVec (fun b => u (Sum.elim (s ∘ Sum.inl) b)) (s ∘ Sum.inr) := by + let e := Equiv.sumArrowEquivProdArrow ι κ (Fin 2) + change (∑ t, qmaJoinMatrix 1 A s t*u t) = _ + rw [←e.symm.sum_comp (fun t => qmaJoinMatrix 1 A s t*u t),Fintype.sum_prod_type] + change (∑ a, ∑ b, (if (s ∘ Sum.inl) = a then (1:ℂ) else 0)* + A (s ∘ Sum.inr) b*u (Sum.elim a b)) = _ + simp only [ite_mul,one_mul,zero_mul,Finset.sum_ite_irrel,Finset.sum_const_zero] + simp only [eq_comm,Finset.sum_ite_eq',Finset.mem_univ,ite_true] + rfl + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCoordinates.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..949e37b32834df7e8e944826539b8c26979e822c --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCoordinates.lean @@ -0,0 +1,87 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalEnlarge + +namespace OAI + +/-! Diagonal controls and changes between explicit qubit coordinate sets. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Classical Kronecker + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem qmaLocalOn_diagonal (S : Finset ι) (d : (ι → Fin 2) → ℂ) + (hd : ∀ s t, (∀ i ∈ S, s i = t i) → d s = d t) : + QMALocalOn S (Matrix.diagonal d) := by + refine ⟨Matrix.diagonal (fun u => d (qmaSupportExtend S u)),?_⟩ + ext s t + rw [qmaLocalLift_apply] + by_cases hs : (fun i : {i // i ∈ S} => s i.val) = (fun i : {i // i ∈ S} => t i.val) + · by_cases hr : (fun i : {i // i ∉ S} => s i.val) = (fun i : {i // i ∉ S} => t i.val) + · have hst : s = t := by + funext i + by_cases hi : i ∈ S + · exact congrFun hs ⟨i,hi⟩ + · exact congrFun hr ⟨i,hi⟩ + subst t + simp only [Matrix.diagonal_apply_eq,ite_true,mul_one] + apply hd + intro i hi + simp [qmaSupportExtend,hi] + · have hst : s ≠ t := by intro h; apply hr; rw [h] + simp only [Matrix.diagonal_apply_ne _ hst,ite_eq_right hr,mul_zero] + · have hst : s ≠ t := by intro h; apply hs; rw [h] + simp only [Matrix.diagonal_apply_ne _ hst,Matrix.diagonal_apply_ne _ hs,zero_mul] + +def qmaJoinMatrix {κ : Type*} [Fintype κ] [DecidableEq κ] + (A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) + (B : Matrix (κ → Fin 2) (κ → Fin 2) ℂ) : + Matrix (ι ⊕ κ → Fin 2) (ι ⊕ κ → Fin 2) ℂ := + (A ⊗ₖ B).submatrix (Equiv.sumArrowEquivProdArrow ι κ (Fin 2)) + (Equiv.sumArrowEquivProdArrow ι κ (Fin 2)) + +theorem QMALocalOn.joinRight {κ : Type*} [Fintype κ] [DecidableEq κ] + {S : Finset κ} {A : Matrix (κ → Fin 2) (κ → Fin 2) ℂ} + (hA : QMALocalOn S A) : + QMALocalOn (S.map (Function.Embedding.inr : κ ↪ ι ⊕ κ)) (qmaJoinMatrix (ι := ι) 1 A) := by + obtain ⟨B,rfl⟩ := hA + let T := S.map (Function.Embedding.inr : κ ↪ ι ⊕ κ) + let k : {i // i ∈ S} → {i // i ∈ T} := fun i => + ⟨Sum.inr i.val,Finset.mem_map.mpr ⟨i.val,i.property,rfl⟩⟩ + refine ⟨(fun u v => B (u ∘ k) (v ∘ k)),?_⟩ + ext s t + change (if (s ∘ Sum.inl) = (t ∘ Sum.inl) then (1:ℂ) else 0)* + (B (fun i => s (Sum.inr i.val)) (fun i => t (Sum.inr i.val))* + if (fun i : {i // i ∉ S} => s (Sum.inr i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inr i.val)) then 1 else 0) = + B (fun i => s (Sum.inr i.val)) (fun i => t (Sum.inr i.val))* + if (fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val) then 1 else 0 + have he : ((fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val)) ↔ + (s ∘ Sum.inl) = (t ∘ Sum.inl) ∧ + (fun i : {i // i ∉ S} => s (Sum.inr i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inr i.val)) := by + constructor + · intro h + constructor + · funext i + exact congrFun h ⟨Sum.inl i,by simp [T]⟩ + · funext i + exact congrFun h ⟨Sum.inr i.val,by simpa [T] using i.property⟩ + · rintro ⟨hl,hr⟩ + funext i + rcases i with ⟨i,hi⟩ + cases i with + | inl j => exact congrFun hl j + | inr j => exact congrFun hr ⟨j,by simpa [T] using hi⟩ + by_cases hl : (s ∘ Sum.inl) = (t ∘ Sum.inl) + <;> by_cases hr : (fun i : {i // i ∉ S} => s (Sum.inr i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inr i.val)) + <;> simp only [he,hl,hr,and_self,and_false,false_and,ite_true,ite_false,mul_one, + one_mul,zero_mul,mul_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCore.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f106a9145ea523f98b8a367bd409b375fbd0a58 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalCore.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPauliReal + +namespace OAI + +/-! The small support matrix is recovered canonically by fixing every +spectator qubit to zero, preserving real entries and Hermiticity. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def qmaLocalCore (S : Finset ι) (A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) : + Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ := + A.submatrix (qmaSupportExtend S) (qmaSupportExtend S) + +theorem qmaLocalCore_lift (S : Finset ι) + (B : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalCore S (qmaLocalLift S B) = B := by + ext u v + change qmaLocalLift S B (qmaSupportExtend S u) (qmaSupportExtend S v) = B u v + rw [qmaLocalLift_apply] + have hs (u : QMASupportBasis S) : + (fun i : {i // i ∈ S} => qmaSupportExtend S u i.val) = u := by + funext i + simp [qmaSupportExtend,i.property] + have hr : (fun i : {i // i ∉ S} => qmaSupportExtend S u i.val) = + (fun i : {i // i ∉ S} => qmaSupportExtend S v i.val) := by + funext i + simp [qmaSupportExtend,i.property] + rw [hs,hs,ite_eq_left hr,mul_one] + +theorem QMALocalOn.core_lift {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) : qmaLocalLift S (qmaLocalCore S A) = A := by + obtain ⟨B,rfl⟩ := hA + rw [qmaLocalCore_lift] + +omit [Fintype ι] in +theorem qmaLocalCore_hermitian (S : Finset ι) (A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) + (hA : A.IsHermitian) : (qmaLocalCore S A).IsHermitian := + hA.submatrix (qmaSupportExtend S) + +omit [Fintype ι] in +theorem qmaLocalCore_real (S : Finset ι) (A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) + (hA : ∀ s t, (A s t).im = 0) (u v : QMASupportBasis S) : + (qmaLocalCore S A u v).im = 0 := hA _ _ + +theorem qmaLocalLift_zero (S : Finset ι) : + qmaLocalLift S (0 : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) = 0 := by + ext s t + simp [qmaLocalLift_apply] + +theorem qmaLocalLift_sum {κ : Type*} [Fintype κ] (S : Finset ι) + (B : κ → Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalLift S (∑ i, B i) = ∑ i, qmaLocalLift S (B i) := by + have hs (s : Finset κ) : qmaLocalLift S (∑ i ∈ s, B i) = ∑ i ∈ s, qmaLocalLift S (B i) := by + induction s using Finset.induction_on with + | empty => simp [qmaLocalLift_zero] + | @insert a s ha ih => simp only [Finset.sum_insert ha,qmaLocalLift_add,ih] + exact hs Finset.univ + +theorem QMALocalOn.pauli_expansion {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) (hH : A.IsHermitian) : + (∑ w : {i // i ∈ S} → Fin 4, + ((qmaPauliCoefficient (qmaLocalCore S A) w).re : ℂ) • + qmaLocalLift S (qmaPauliWord w)) = A := by + have he := qmaPauli_real_expansion (qmaLocalCore S A) (qmaLocalCore_hermitian S A hH) + have h := congrArg (qmaLocalLift S) he + rw [qmaLocalLift_sum] at h + simp only [qmaLocalLift_smul] at h + exact h.trans hA.core_lift + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalDecomposition.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalDecomposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa95eba9499ccb79dcb11fc5e5f012e53ec6d960 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalDecomposition.lean @@ -0,0 +1,143 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumPropagationAction +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalPenalties + +namespace OAI + +/-! Exact sum of finite-support terms for the full unary-clock Hamiltonian. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaSubmatrix_add {α β γ δ : Type*} (A B : Matrix α β ℂ) + (f : γ → α) (g : δ → β) : (A+B).submatrix f g = A.submatrix f g+B.submatrix f g := rfl + +theorem qmaSubmatrix_smul {α β γ δ : Type*} (z : ℂ) (A : Matrix α β ℂ) + (f : γ → α) (g : δ → β) : (z • A).submatrix f g = z • A.submatrix f g := rfl + +theorem qmaOfReal_ite (p : Prop) [Decidable p] (a b : ℝ) : + ((if p then a else b : ℝ) : ℂ) = if p then (a:ℂ) else (b:ℂ) := by + split <;> rfl + +def qmaQubitHamiltonian (c : QMACircuit) : + Matrix (QMACircuitQubit c → Fin 2) (QMACircuitQubit c → Fin 2) ℂ := + (qmaUnaryHamiltonian c).submatrix (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) + +theorem qmaUnaryPropagationGram_reindex (c : QMACircuit) : + ((qmaUnaryPropagationMatrix c).conjTranspose*qmaUnaryPropagationMatrix c).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = + ∑ t : Fin c.gates.length, + (qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t := by + have hs (t : Fin c.gates.length) : + (qmaPropagationSlice c t).submatrix (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = + qmaLocalPropagationDelta c t := by + rw [qmaPropagationSlice_eq] + ext s r + simp only [Matrix.submatrix_apply,Equiv.symm_apply_apply] + calc + _ = ∑ t : Fin c.gates.length, + ((qmaPropagationSlice c t).conjTranspose*qmaPropagationSlice c t).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) := by + ext s r + simp only [qmaUnaryPropagationGram_sum,Matrix.submatrix_apply,Matrix.sum_apply] + _ = _ := by + apply Finset.sum_congr rfl + intro t _ + rw [←Matrix.submatrix_mul_equiv _ _ (qmaCircuitQubitSplit c) + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c),←Matrix.conjTranspose_submatrix,hs] + +theorem qmaUnaryClockDiagonal_reindex (c : QMACircuit) : + (Matrix.diagonal (fun p => (qmaUnaryClockDiagonal c p : ℂ))).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = + (∑ i : Fin (c.gates.length+1), qmaClockFaultTerm c i)+qmaClockLeftTerm c+qmaClockRightTerm c := by + rw [Matrix.submatrix_diagonal_equiv] + ext s r + by_cases h : s = r + · subst r + simp only [Matrix.add_apply,Matrix.sum_apply,qmaClockFaultTerm,qmaPairDiagonal, + qmaClockLeftTerm,qmaClockRightTerm,qmaBitDiagonal,Matrix.diagonal_apply_eq] + change ((qmaPinnedClockPenalty c.gates.length (s ∘ Sum.inl) : ℝ) : ℂ) = + (∑ i : Fin (c.gates.length+1), if s (Sum.inl i.castSucc) = 0 ∧ + s (Sum.inl i.succ) = 1 then (1:ℂ) else 0)+ + (if s (Sum.inl 0) = 1 then 0 else 1)+ + (if s (Sum.inl (Fin.last (c.gates.length+1))) = 0 then 0 else 1) + unfold qmaPinnedClockPenalty qmaClockFaultCount + rw [Complex.ofReal_add,Complex.ofReal_add,Complex.ofReal_sum] + congr 2 + · apply Finset.sum_congr rfl + intro i _ + by_cases hi : s (Sum.inl i.castSucc) = 0 ∧ s (Sum.inl i.succ) = 1 + · simp [hi] + · simp [hi] + · by_cases hl : s (Sum.inl 0) = 1 <;> simp [Function.comp_apply,hl] + · by_cases hr : s (Sum.inl (Fin.last (c.gates.length+1))) = 0 + <;> simp [Function.comp_apply,hr] + · simp [h,Matrix.sum_apply,qmaClockFaultTerm,qmaPairDiagonal, + qmaClockLeftTerm,qmaClockRightTerm,qmaBitDiagonal] + +theorem qmaUnaryInputDiagonal_reindex (c : QMACircuit) : + ((7:ℂ) • Matrix.diagonal (fun p => (qmaUnaryInputDiagonal c p : ℂ))).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = + ∑ i : Fin (c.work+1), qmaInputTerm c i := by + rw [qmaSubmatrix_smul,Matrix.submatrix_diagonal_equiv] + ext s r + by_cases h : s = r + · subst r + simp only [Matrix.smul_apply,smul_eq_mul,Matrix.sum_apply,qmaInputTerm,qmaPairDiagonal, + Matrix.diagonal_apply_eq] + change (7:ℂ)*(if s (Sum.inl (qmaInputMarker c)) = 0 then + (qmaAncillaCount c (s ∘ Sum.inr) : ℝ) else 0) = + ∑ i : Fin (c.work+1), if s (Sum.inl (qmaInputMarker c)) = 0 then + if c.witness ≤ i.val ∧ s (Sum.inr i) ≠ 0 then (7:ℂ) else 0 else 0 + by_cases hm : s (Sum.inl (qmaInputMarker c)) = 0 + · simp only [hm,ite_true,qmaAncillaCount,Complex.ofReal_sum,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + by_cases hi : c.witness ≤ i.val ∧ s (Sum.inr i) ≠ 0 + · simp [hi] + · simp [hi] + · simp [hm] + · simp [Matrix.smul_apply,h,Matrix.sum_apply,qmaInputTerm,qmaPairDiagonal] + +theorem qmaUnaryOutputDiagonal_reindex (c : QMACircuit) : + (Matrix.diagonal (fun p => (qmaUnaryOutputDiagonal c p : ℂ))).submatrix + (qmaCircuitQubitSplit c) (qmaCircuitQubitSplit c) = qmaOutputTerm c := by + rw [Matrix.submatrix_diagonal_equiv] + ext s r + by_cases h : s = r + · subst r + simp only [qmaOutputTerm,qmaPairDiagonal,Matrix.diagonal_apply_eq] + change Complex.ofReal (qmaUnaryOutputDiagonal c (qmaCircuitQubitSplit c s)) = _ + unfold qmaUnaryOutputDiagonal + by_cases ho : s (Sum.inl (qmaOutputMarker c)) = 1 ∧ s (Sum.inr (Fin.last c.work)) ≠ 1 + · have ho' : (qmaCircuitQubitSplit c s).1 (qmaOutputMarker c) = 1 ∧ + (qmaCircuitQubitSplit c s).2 (Fin.last c.work) ≠ 1 := ho + calc + _ = Complex.ofReal 1 := congrArg Complex.ofReal (ite_eq_left ho') + _ = 1 := by norm_num + _ = _ := (ite_eq_left ho).symm + · have ho' : ¬((qmaCircuitQubitSplit c s).1 (qmaOutputMarker c) = 1 ∧ + (qmaCircuitQubitSplit c s).2 (Fin.last c.work) ≠ 1) := ho + calc + _ = Complex.ofReal 0 := congrArg Complex.ofReal (ite_eq_right ho') + _ = 0 := by norm_num + _ = _ := (ite_eq_right ho).symm + · simp [h,qmaOutputTerm,qmaPairDiagonal] + +theorem qmaQubitHamiltonian_decomposition (c : QMACircuit) : + qmaQubitHamiltonian c = + ((∑ i : Fin (c.gates.length+1), qmaClockFaultTerm c i)+qmaClockLeftTerm c+qmaClockRightTerm c)+ + qmaOutputTerm c+(∑ i : Fin (c.work+1), qmaInputTerm c i)+ + (8*c.gates.length:ℂ) • ∑ t : Fin c.gates.length, + (qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t := by + unfold qmaQubitHamiltonian qmaUnaryHamiltonian + simp only [qmaSubmatrix_add] + rw [qmaUnaryClockDiagonal_reindex,qmaUnaryOutputDiagonal_reindex, + qmaUnaryInputDiagonal_reindex,qmaSubmatrix_smul,qmaUnaryPropagationGram_reindex] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalEnlarge.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalEnlarge.lean new file mode 100644 index 0000000000000000000000000000000000000000..acdb8838be9e4cc292ba5dc358504630cac405b8 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalEnlarge.lean @@ -0,0 +1,62 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumGateLocality + +namespace OAI + +/-! Enlarging an explicit operator support introduces only identity factors. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def qmaSupportExtend (S : Finset ι) (u : QMASupportBasis S) : ι → Fin 2 := + fun i => if hi : i ∈ S then u ⟨i,hi⟩ else 0 + +theorem QMALocalOn.mono {S T : Finset ι} (hST : S ⊆ T) + {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} (hA : QMALocalOn S A) : QMALocalOn T A := by + obtain ⟨B,rfl⟩ := hA + refine ⟨(fun u v => qmaLocalLift S B (qmaSupportExtend T u) (qmaSupportExtend T v)),?_⟩ + ext s t + have hc (v : ι → Fin 2) : + (fun i : {i // i ∈ S} => qmaSupportExtend T (fun j => v j.val) i.val) = + (fun i : {i // i ∈ S} => v i.val) := by + funext i + simp only [qmaSupportExtend,dite_eq_left (hST i.property)] + change B (fun i => s i.val) (fun i => t i.val)* + (if (fun i : {i // i ∉ S} => s i.val) = (fun i : {i // i ∉ S} => t i.val) then 1 else 0) = + (B (fun i : {i // i ∈ S} => qmaSupportExtend T (fun j => s j.val) i.val) + (fun i : {i // i ∈ S} => qmaSupportExtend T (fun j => t j.val) i.val)* + (if (fun i : {i // i ∉ S} => qmaSupportExtend T (fun j => s j.val) i.val) = + (fun i : {i // i ∉ S} => qmaSupportExtend T (fun j => t j.val) i.val) then 1 else 0))* + (if (fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val) then 1 else 0) + rw [hc,hc] + by_cases hr : (fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val) + · have he : + ((fun i : {i // i ∉ S} => qmaSupportExtend T (fun j => s j.val) i.val) = + (fun i : {i // i ∉ S} => qmaSupportExtend T (fun j => t j.val) i.val)) ↔ + ((fun i : {i // i ∉ S} => s i.val) = (fun i : {i // i ∉ S} => t i.val)) := by + constructor + · intro h + funext i + by_cases hi : i.val ∈ T + · simpa only [qmaSupportExtend,dite_eq_left hi] using congrFun h i + · exact congrFun hr ⟨i.val,hi⟩ + · intro h + funext i + by_cases hi : i.val ∈ T + · simpa only [qmaSupportExtend,dite_eq_left hi] using congrFun h i + · simp only [qmaSupportExtend,dite_eq_right hi] + simp only [ite_eq_left hr,mul_one,he] + · have hs : (fun i : {i // i ∉ S} => s i.val) ≠ (fun i : {i // i ∉ S} => t i.val) := by + intro h + apply hr + funext i + exact congrFun h ⟨i.val,fun hi => i.property (hST hi)⟩ + rw [ite_eq_right hr,ite_eq_right hs,mul_zero,mul_zero] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalError.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalError.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ca7c366922e908fb06b7d645587073ebd2266d9 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalError.lean @@ -0,0 +1,67 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumMatrixError + +namespace OAI + +/-! Local matrix errors are bounded independently of the number of +spectator qubits, including on entangled states. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical Kronecker + +theorem qmaKronecker_one_action {α β : Type*} [Fintype α] [Fintype β] [DecidableEq β] + (A : Matrix α α ℂ) (u : α × β → ℂ) (p : α × β) : + (A ⊗ₖ (1 : Matrix β β ℂ)).mulVec u p = A.mulVec (fun i => u (i,p.2)) p.1 := by + simp [Matrix.mulVec,dotProduct,Fintype.sum_prod_type,Matrix.one_apply, + mul_ite,ite_mul] + +theorem qmaKronecker_one_quadratic {α β : Type*} [Fintype α] [Fintype β] [DecidableEq β] + (A : Matrix α α ℂ) (u : α × β → ℂ) : + qmaQuadratic (A ⊗ₖ (1 : Matrix β β ℂ)) u = ∑ j : β, qmaQuadratic A (fun i => u (i,j)) := by + simp only [qmaQuadratic,qmaKronecker_one_action,dotProduct,Fintype.sum_prod_type, + Pi.star_apply,Complex.re_sum] + rw [Finset.sum_comm] + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem qmaLocalLift_quadratic (S : Finset ι) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) (u : (ι → Fin 2) → ℂ) : + qmaQuadratic (qmaLocalLift S A) u = + ∑ r : QMASpectatorBasis S, qmaQuadratic A (fun s => u ((qmaSupportSplit S).symm (s,r))) := by + let e := qmaSupportSplit S + let v := u ∘ e.symm + have he : v ∘ e = u := by funext i; simp [v] + have h := qmaQuadratic_reindex e (A ⊗ₖ (1 : Matrix (QMASpectatorBasis S) (QMASpectatorBasis S) ℂ)) v + rw [he,qmaKronecker_one_quadratic] at h + exact h + +theorem qmaLocalLift_entry_bound (S : Finset ι) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) (B : ℝ) (hB : 0 ≤ B) + (hA : ∀ i j, ‖A i j‖ ≤ B) (u : (ι → Fin 2) → ℂ) : + |qmaQuadratic (qmaLocalLift S A) u| ≤ (2:ℝ)^S.card*B*(∑ i, ‖u i‖^2) := by + rw [qmaLocalLift_quadratic] + have hc : (Fintype.card (QMASupportBasis S):ℝ) = (2:ℝ)^S.card := by + simp only [QMASupportBasis,Fintype.card_fun,Fintype.card_fin,Fintype.card_coe,Nat.cast_pow,Nat.cast_ofNat] + have hm : (∑ r : QMASpectatorBasis S, ∑ s : QMASupportBasis S, + ‖u ((qmaSupportSplit S).symm (s,r))‖^2) = ∑ i, ‖u i‖^2 := by + rw [Finset.sum_comm] + have h := (qmaSupportSplit S).symm.sum_comp (fun i => ‖u i‖^2) + simpa only [Fintype.sum_prod_type] using h + calc + _ ≤ ∑ r : QMASpectatorBasis S, + |qmaQuadratic A (fun s => u ((qmaSupportSplit S).symm (s,r)))| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ r : QMASpectatorBasis S, (2:ℝ)^S.card*B* + (∑ s : QMASupportBasis S, ‖u ((qmaSupportSplit S).symm (s,r))‖^2) := by + apply Finset.sum_le_sum + intro r _ + simpa only [hc] using qmaQuadratic_entry_bound A B hB hA + (fun s => u ((qmaSupportSplit S).symm (s,r))) + _ = _ := by rw [←Finset.mul_sum,hm] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalFamily.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..9831b43ffbd9b81910f4ac66339e8e136eff11c4 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalFamily.lean @@ -0,0 +1,98 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalDecomposition + +namespace OAI + +/-! A linear-size explicit interaction family for the verified circuit +Hamiltonian. Its supports contain at most five qubits. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +abbrev QMACircuitTerm (c : QMACircuit) := + Fin (c.gates.length+1) ⊕ (Fin 2 ⊕ (Fin (c.work+1) ⊕ (Unit ⊕ Fin c.gates.length))) + +def qmaCircuitTermSites (c : QMACircuit) : QMACircuitTerm c → Finset (QMACircuitQubit c) + | .inl i => {Sum.inl i.castSucc,Sum.inl i.succ} + | .inr (.inl b) => if b = 0 then {Sum.inl 0} else {Sum.inl (Fin.last (c.gates.length+1))} + | .inr (.inr (.inl i)) => {Sum.inl (qmaInputMarker c),Sum.inr i} + | .inr (.inr (.inr (.inl _))) => {Sum.inl (qmaOutputMarker c),Sum.inr (Fin.last c.work)} + | .inr (.inr (.inr (.inr t))) => qmaPropagationSites c t + +def qmaCircuitTermMatrix (c : QMACircuit) : QMACircuitTerm c → + Matrix (QMACircuitQubit c → Fin 2) (QMACircuitQubit c → Fin 2) ℂ + | .inl i => qmaClockFaultTerm c i + | .inr (.inl b) => if b = 0 then qmaClockLeftTerm c else qmaClockRightTerm c + | .inr (.inr (.inl i)) => qmaInputTerm c i + | .inr (.inr (.inr (.inl _))) => qmaOutputTerm c + | .inr (.inr (.inr (.inr t))) => + (8*c.gates.length:ℂ) • ((qmaLocalPropagationDelta c t).conjTranspose*qmaLocalPropagationDelta c t) + +theorem qmaCircuitTerm_card (c : QMACircuit) : + Fintype.card (QMACircuitTerm c) = 2*c.gates.length+c.work+5 := by + simp only [QMACircuitTerm,Fintype.card_sum,Fintype.card_fin,Fintype.card_unit] + omega + +theorem qmaCircuitTerm_local (c : QMACircuit) (i : QMACircuitTerm c) : + QMALocalOn (qmaCircuitTermSites c i) (qmaCircuitTermMatrix c i) := by + rcases i with i | (b | (i | (u | t))) + · exact qmaClockFaultTerm_local c i + · fin_cases b + · exact qmaClockLeftTerm_local c + · exact qmaClockRightTerm_local c + · exact qmaInputTerm_local c i + · exact qmaOutputTerm_local c + · exact (qmaLocalPropagationGram_local c t).smul _ + +theorem qmaCircuitTerm_support_card (c : QMACircuit) (i : QMACircuitTerm c) : + (qmaCircuitTermSites c i).card ≤ 5 := by + have hp (a b : QMACircuitQubit c) : ({a,b} : Finset (QMACircuitQubit c)).card ≤ 2 := by + have h := Finset.card_insert_le a ({b} : Finset (QMACircuitQubit c)) + simpa only [Finset.card_singleton] using h + rcases i with i | (b | (i | (u | t))) + · exact le_trans (hp _ _) (by norm_num : (2:ℕ) ≤ 5) + · fin_cases b <;> simp [qmaCircuitTermSites] + · exact le_trans (hp _ _) (by norm_num : (2:ℕ) ≤ 5) + · exact le_trans (hp _ _) (by norm_num : (2:ℕ) ≤ 5) + · exact qmaPropagationSites_card c t + +theorem qmaCircuitTerm_sum (c : QMACircuit) : + (∑ i : QMACircuitTerm c, qmaCircuitTermMatrix c i) = qmaQubitHamiltonian c := by + rw [qmaQubitHamiltonian_decomposition] + have h10 : (1:Fin 2) ≠ 0 := by decide + simp only [Fintype.sum_sum_type,qmaCircuitTermMatrix,Fin.sum_univ_two, + Fin.isValue,ite_true,h10,ite_false,Finset.univ_unique,Finset.sum_singleton, + ←Finset.smul_sum] + ext s t + simp only [Matrix.add_apply,Matrix.smul_apply,smul_eq_mul] + ring + +theorem qmaCircuitTerm_hermitian (c : QMACircuit) (i : QMACircuitTerm c) : + (qmaCircuitTermMatrix c i).IsHermitian := by + have hd (f : (QMACircuitQubit c → Fin 2) → ℂ) + (hf : ∀ s, star (f s) = f s) : (Matrix.diagonal f).IsHermitian := by + apply Matrix.isHermitian_diagonal_iff.mpr + intro s + exact hf s + rcases i with i | (b | (i | (u | t))) + · apply hd + intro s + dsimp only + split_ifs <;> simp + · fin_cases b <;> apply hd <;> intro s <;> dsimp only <;> split_ifs <;> simp + · apply hd + intro s + dsimp only + split_ifs <;> simp + · apply hd + intro s + dsimp only + split_ifs <;> simp + · exact (Matrix.isHermitian_conjTranspose_mul_self _).smul (by simp [isSelfAdjoint_iff]) + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalInput.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..80c2dc5dc3ef76909777e471c85aa339b2cdb9f5 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalInput.lean @@ -0,0 +1,69 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumAncillaCount + +namespace OAI + +/-! The history input energy as a sum of individual ancilla projectors. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +theorem qmaQuadratic_diagonal_real {ι : Type*} [Fintype ι] [DecidableEq ι] + (d : ι → ℝ) (u : ι → ℂ) : + qmaQuadratic (Matrix.diagonal (fun i => (d i : ℂ))) u = + ∑ i, d i*Complex.normSq (u i) := by + simp only [qmaQuadratic,dotProduct,Matrix.mulVec_diagonal,Complex.re_sum,Pi.star_apply] + apply Finset.sum_congr rfl + intro i _ + simp [Complex.mul_re,Complex.normSq_apply] + ring + +def qmaInitialCountDiagonal (c : QMACircuit) (k : QMAHistoryBasis c) : ℝ := + if k.1.val = 0 then qmaAncillaCount c k.2 else 0 + +theorem qmaInitialCountDiagonal_ge (c : QMACircuit) (k : QMAHistoryBasis c) : + (if k.1.val = 0 ∧ ¬QMAAncillaZero c k.2 then (1:ℝ) else 0) ≤ + qmaInitialCountDiagonal c k := by + by_cases ht : k.1.val = 0 + · by_cases hs : QMAAncillaZero c k.2 + · simpa [qmaInitialCountDiagonal,ht,hs] using qmaAncillaCount_nonneg c k.2 + · simpa [qmaInitialCountDiagonal,ht,hs] using qmaAncillaCount_one_le c k.2 hs + · simp [qmaInitialCountDiagonal,ht] + +theorem qmaInitialCountDiagonal_energy_ge (c : QMACircuit) (u : QMAHistoryBasis c → ℂ) : + qmaQuadratic (Matrix.diagonal (qmaInitialDiagonal c)) u ≤ + qmaQuadratic (Matrix.diagonal (fun k => (qmaInitialCountDiagonal c k : ℂ))) u := by + have hleft : qmaQuadratic (Matrix.diagonal (qmaInitialDiagonal c)) u = + ∑ k : QMAHistoryBasis c, + (if k.1.val = 0 ∧ ¬QMAAncillaZero c k.2 then (1:ℝ) else 0)*Complex.normSq (u k) := by + convert qmaQuadratic_diagonal_real (fun k : QMAHistoryBasis c => + if k.1.val = 0 ∧ ¬QMAAncillaZero c k.2 then (1:ℝ) else 0) u using 1 + congr 2 + funext k + by_cases hk : k.1.val = 0 ∧ ¬QMAAncillaZero c k.2 + · simp only [qmaInitialDiagonal,ite_eq_left hk,Complex.ofReal_one] + · simp only [qmaInitialDiagonal,ite_eq_right hk,Complex.ofReal_zero] + rw [hleft,qmaQuadratic_diagonal_real] + exact Finset.sum_le_sum fun k _ => + mul_le_mul_of_nonneg_right (qmaInitialCountDiagonal_ge c k) (Complex.normSq_nonneg _) + +theorem qmaInitialCountDiagonal_ideal_zero (c : QMACircuit) (hc : c.WellFormed) + (psi : EuclideanSpace ℂ (SourceSpinBasis c.witness)) : + qmaQuadratic (Matrix.diagonal (fun k => (qmaInitialCountDiagonal c k : ℂ))) + (fun k => qmaHistoryVector c (qmaIdealHistory c hc psi) k) = 0 := by + rw [qmaQuadratic_diagonal_real] + apply Finset.sum_eq_zero + intro k _ + by_cases ht : k.1.val = 0 + · by_cases hs : QMAAncillaZero c k.2 + · simp [qmaInitialCountDiagonal,ht,qmaAncillaCount_zero c k.2 hs] + · have hs' : ¬∀ i : Fin (c.work+1), c.witness ≤ i.val → k.2 i = 0 := hs + simp [qmaHistoryVector,qmaIdealHistory,ht,qmaInputVector,qmaInitialState,hs'] + · simp [qmaInitialCountDiagonal,ht] + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalJoin.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalJoin.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bd9d0e185eb66628e283ca678a30bd2d25a35e3 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalJoin.lean @@ -0,0 +1,79 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalCore + +namespace OAI + +/-! Tensoring with fresh mediators adds precisely their explicit supports. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Kronecker Classical +variable {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + +theorem QMALocalOn.joinLeft {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) : + QMALocalOn (S.map (Function.Embedding.inl : ι ↪ ι ⊕ κ)) (qmaJoinMatrix A (κ := κ) 1) := by + obtain ⟨B,rfl⟩ := hA + let T := S.map (Function.Embedding.inl : ι ↪ ι ⊕ κ) + let k : {i // i ∈ S} → {i // i ∈ T} := fun i => + ⟨Sum.inl i.val,Finset.mem_map.mpr ⟨i.val,i.property,rfl⟩⟩ + refine ⟨(fun u v => B (u ∘ k) (v ∘ k)),?_⟩ + ext s t + change (B (fun i => s (Sum.inl i.val)) (fun i => t (Sum.inl i.val))* + if (fun i : {i // i ∉ S} => s (Sum.inl i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inl i.val)) then 1 else 0)* + (if (s ∘ Sum.inr) = (t ∘ Sum.inr) then (1:ℂ) else 0) = + B (fun i => s (Sum.inl i.val)) (fun i => t (Sum.inl i.val))* + if (fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val) then 1 else 0 + have he : ((fun i : {i // i ∉ T} => s i.val) = (fun i : {i // i ∉ T} => t i.val)) ↔ + (fun i : {i // i ∉ S} => s (Sum.inl i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inl i.val)) ∧ (s ∘ Sum.inr) = (t ∘ Sum.inr) := by + constructor + · intro h + constructor + · funext i + exact congrFun h ⟨Sum.inl i.val,by simpa [T] using i.property⟩ + · funext i + exact congrFun h ⟨Sum.inr i,by simp [T]⟩ + · rintro ⟨hl,hr⟩ + funext i + rcases i with ⟨i,hi⟩ + cases i with + | inl j => exact congrFun hl ⟨j,by simpa [T] using hi⟩ + | inr j => exact congrFun hr j + by_cases hl : (fun i : {i // i ∉ S} => s (Sum.inl i.val)) = + (fun i : {i // i ∉ S} => t (Sum.inl i.val)) + <;> by_cases hr : (s ∘ Sum.inr) = (t ∘ Sum.inr) + <;> simp only [he,hl,hr,and_self,and_false,false_and,ite_true,ite_false,mul_one,mul_zero] + +theorem qmaJoinMatrix_mul (A B : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) + (C D : Matrix (κ → Fin 2) (κ → Fin 2) ℂ) : + qmaJoinMatrix (A*B) (C*D) = qmaJoinMatrix A C*qmaJoinMatrix B D := by + unfold qmaJoinMatrix + rw [Matrix.submatrix_mul_equiv,← Matrix.mul_kronecker_mul] + +theorem QMALocalOn.join {S : Finset ι} {T : Finset κ} + {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} {B : Matrix (κ → Fin 2) (κ → Fin 2) ℂ} + (hA : QMALocalOn S A) (hB : QMALocalOn T B) : + QMALocalOn (S.map Function.Embedding.inl ∪ T.map Function.Embedding.inr) (qmaJoinMatrix A B) := by + have he : qmaJoinMatrix A B = qmaJoinMatrix A (κ := κ) 1*qmaJoinMatrix (ι := ι) 1 B := by + rw [← qmaJoinMatrix_mul,mul_one,one_mul] + rw [he] + exact (hA.joinLeft.mono Finset.subset_union_left).mul + (hB.joinRight.mono Finset.subset_union_right) + +theorem qmaJoin_two_local {S : Finset ι} {T : Finset κ} + {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} {B : Matrix (κ → Fin 2) (κ → Fin 2) ℂ} + (hA : QMALocalOn S A) (hB : QMALocalOn T B) (hS : S.card ≤ 1) (hT : T.card ≤ 1) : + ∃ U : Finset (ι ⊕ κ), U.card ≤ 2 ∧ QMALocalOn U (qmaJoinMatrix A B) := by + refine ⟨_,?_,hA.join hB⟩ + have hc := Finset.card_union_le (S.map (Function.Embedding.inl : ι ↪ ι ⊕ κ)) + (T.map (Function.Embedding.inr : κ ↪ ι ⊕ κ)) + simp only [Finset.card_map] at hc + omega + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalLift.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4b58b441a8532ed751d0762f72c83595acca055 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalLift.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumRealCircuit +import Mathlib.LinearAlgebra.Matrix.Kronecker + +namespace OAI + +/-! Exact tensor-local operators, with explicit finite supports. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped Kronecker + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +abbrev QMASupportBasis (S : Finset ι) := (i : {i // i ∈ S}) → Fin 2 +abbrev QMASpectatorBasis (S : Finset ι) := (i : {i // i ∉ S}) → Fin 2 + +def qmaSupportSplit (S : Finset ι) : + (ι → Fin 2) ≃ QMASupportBasis S × QMASpectatorBasis S := + Equiv.piEquivPiSubtypeProd (fun i => i ∈ S) (fun _ => Fin 2) + +def qmaLocalLift (S : Finset ι) (A : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + Matrix (ι → Fin 2) (ι → Fin 2) ℂ := + (A ⊗ₖ (1 : Matrix (QMASpectatorBasis S) (QMASpectatorBasis S) ℂ)).submatrix + (qmaSupportSplit S) (qmaSupportSplit S) + +def QMALocalOn (S : Finset ι) (A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ) : Prop := + ∃ B : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ, A = qmaLocalLift S B + +theorem qmaLocalLift_add (S : Finset ι) (A B : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalLift S (A+B) = qmaLocalLift S A+qmaLocalLift S B := by + simp [qmaLocalLift,Matrix.add_kronecker,Matrix.submatrix_add] + +theorem qmaLocalLift_smul (S : Finset ι) (a : ℂ) + (A : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalLift S (a • A) = a • qmaLocalLift S A := by + simp [qmaLocalLift,Matrix.smul_kronecker,Matrix.submatrix_smul] + +theorem qmaLocalLift_mul (S : Finset ι) (A B : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalLift S (A*B) = qmaLocalLift S A*qmaLocalLift S B := by + unfold qmaLocalLift + rw [Matrix.submatrix_mul_equiv,←Matrix.mul_kronecker_mul,one_mul] + +theorem qmaLocalLift_adjoint (S : Finset ι) (A : Matrix (QMASupportBasis S) (QMASupportBasis S) ℂ) : + qmaLocalLift S A.conjTranspose = (qmaLocalLift S A).conjTranspose := by + simp [qmaLocalLift,Matrix.conjTranspose_kronecker,Matrix.conjTranspose_submatrix] + +theorem qmaLocalLift_one (S : Finset ι) : qmaLocalLift S 1 = 1 := by + unfold qmaLocalLift + rw [Matrix.one_kronecker_one,Matrix.submatrix_one_equiv] + +theorem QMALocalOn.add {S : Finset ι} {A B : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) (hB : QMALocalOn S B) : QMALocalOn S (A+B) := by + obtain ⟨a,rfl⟩ := hA + obtain ⟨b,rfl⟩ := hB + exact ⟨a+b,(qmaLocalLift_add S a b).symm⟩ + +theorem QMALocalOn.mul {S : Finset ι} {A B : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) (hB : QMALocalOn S B) : QMALocalOn S (A*B) := by + obtain ⟨a,rfl⟩ := hA + obtain ⟨b,rfl⟩ := hB + exact ⟨a*b,(qmaLocalLift_mul S a b).symm⟩ + +theorem QMALocalOn.smul {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) (z : ℂ) : QMALocalOn S (z • A) := by + obtain ⟨a,rfl⟩ := hA + exact ⟨z • a,(qmaLocalLift_smul S z a).symm⟩ + +theorem QMALocalOn.adjoint {S : Finset ι} {A : Matrix (ι → Fin 2) (ι → Fin 2) ℂ} + (hA : QMALocalOn S A) : QMALocalOn S A.conjTranspose := by + obtain ⟨a,rfl⟩ := hA + exact ⟨a.conjTranspose,(qmaLocalLift_adjoint S a).symm⟩ + +end ContinuumCoulomb + +end + +end OAI diff --git a/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalModel.lean b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..8897514fde25021fd0ffa545661f94684d204f76 --- /dev/null +++ b/lean/OAI/MathematicalPhysics/ContinuumCoulomb/Quantum/QuantumLocalModel.lean @@ -0,0 +1,78 @@ +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalSubdivision +import OAI.MathematicalPhysics.ContinuumCoulomb.Quantum.QuantumLocalThird + +namespace OAI + +/-! Finite real local families and the three gadget stages used by the +circuit-to-spin reduction. This records mathematical families, not a compiler. -/ + +noncomputable section +namespace ContinuumCoulomb +open Matrix +open scoped BigOperators Classical + +structure QMARealLocalModel (d : ℕ) where + Q : Type + Term : Type + [qFinite : Fintype Q] + [qDecidable : DecidableEq Q] + [termFinite : Fintype Term] + matrix : Term → Matrix (Q → Fin 2) (Q → Fin 2) ℂ + sites : Term → Finset Q + localOn : ∀ a, QMALocalOn (sites a) (matrix a) + card : ∀ a, (sites a).card ≤ d + hermitian : ∀ a, (matrix a).IsHermitian + real : ∀ a, QMAEntryParity false (matrix a) + +attribute [instance] QMARealLocalModel.qFinite QMARealLocalModel.qDecidable QMARealLocalModel.termFinite + +def QMARealLocalModel.energy {d : ℕ} (M : QMARealLocalModel d) : ℝ := + MediatorGraph.normalizedBottom (∑ a, M.matrix a) + +def QMARealLocalModel.qubits {d : ℕ} (M : QMARealLocalModel d) : ℕ := Fintype.card M.Q + +def QMARealLocalModel.terms {d : ℕ} (M : QMARealLocalModel d) : ℕ := Fintype.card M.Term + +theorem QMARealLocalModel.subdivision {d : ℕ} (M : QMARealLocalModel (2*d)) {N : ℝ} (hN : 1 ≤ N) : + ∃ G : QMARealLocalModel (d+1), |G.energy-M.energy| ≤ 1/N ∧ + G.qubits ≤ M.qubits+4^(2*d)*M.terms ∧ G.terms ≤ 4*4^(2*d)*M.terms := by + obtain ⟨G,hGH,hGR,hGS,hGE⟩ := qmaLocalSubdivision_exists M.matrix M.sites M.card + M.localOn M.hermitian M.real hN + choose S hScard hSlocal using hGS + refine ⟨⟨M.Q ⊕ QMALocalEvenPauliTerm M.sites,QMALocalEvenPauliTerm M.sites × Fin 4, + G,S,hSlocal,hScard,hGH,hGR⟩,hGE,?_⟩ + exact qmaLocalSubdivision_size M.sites M.card + +theorem QMARealLocalModel.third (M : QMARealLocalModel 3) {N : ℝ} (hN : 1 ≤ N) : + ∃ G : QMARealLocalModel 2, |G.energy-M.energy| ≤ 1/N ∧ + G.qubits ≤ M.qubits+64*M.terms ∧ G.terms ≤ 448*M.terms := by + obtain ⟨G,hGH,hGR,hGS,hGE⟩ := qmaLocalThird_exists M.matrix M.sites M.card + M.localOn M.hermitian M.real hN + choose S hScard hSlocal using hGS + refine ⟨⟨M.Q ⊕ QMALocalEvenPauliTerm M.sites,QMALocalEvenPauliTerm M.sites × Fin 7, + G,S,hSlocal,hScard,hGH,hGR⟩,hGE,?_⟩ + exact qmaLocalThird_size M.sites M.card + +theorem QMARealLocalModel.six_to_two (M : QMARealLocalModel 6) {N : ℝ} (hN : 1 ≤ N) : + ∃ G : QMARealLocalModel 2, |G.energy-M.energy| ≤ 1/N ∧ + G.qubits ≤ M.qubits+1077940224*M.terms ∧ G.terms ≤ 7516192768*M.terms := by + have h3N : 1 ≤ 3*N := by linarith + obtain ⟨M4,h4,hq4,ht4⟩ := M.subdivision (d := 3) h3N + obtain ⟨M3,h3,hq3,ht3⟩ := M4.subdivision (d := 2) h3N + obtain ⟨M2,h2,hq2,ht2⟩ := M3.third h3N + refine ⟨M2,?_,?_,?_⟩ + · have ht := (abs_sub_le M2.energy M3.energy M.energy).trans + (add_le_add le_rfl (abs_sub_le M3.energy M4.energy M.energy)) + have hN0 : N ≠ 0 := by linarith + have he : 1/(3*N)+1/(3*N)+1/(3*N) = 1/N := by field_simp; ring + linarith + · norm_num only [show (4:ℕ)^6 = 4096 by norm_num,show (4:ℕ)^4 = 256 by norm_num] at hq4 ht4 hq3 ht3 + omega + · norm_num only [show (4:ℕ)^6 = 4096 by norm_num,show (4:ℕ)^4 = 256 by norm_num] at ht4 ht3 + omega + +end ContinuumCoulomb + +end + +end OAI