{"name": "CallElimCorrect.substOldPostSubset", "source": "strata", "statement": "open OldExpressions in\ntheorem substOldPostSubset:\n (Imperative.HasVarsPure.getVars (P:=Expression)\n (substOld h2 (Lambda.LExpr.fvar m h1 ty) post)).Subset\n (Imperative.HasVarsPure.getVars (P:=Expression) post ++ [h1])", "src": "open OldExpressions in\ntheorem substOldPostSubset:\n (Imperative.HasVarsPure.getVars (P:=Expression)\n (substOld h2 (Lambda.LExpr.fvar m h1 ty) post)).Subset\n (Imperative.HasVarsPure.getVars (P:=Expression) post ++ [h1]) := by\n induction post <;> simp [substOld]\n case fvar =>\n intros x Hin\n rename_i m name ty2\n simp at m\n simp at name\n simp at ty2\n\n simp_all\n case op =>\n intros x Hin\n rename_i m name ty2\n simp at m\n simp at name\n simp at ty2\n simp_all\n case const =>\n intros x Hin\n rename_i m name\n simp at m\n simp_all\n case bvar =>\n intros x Hin\n rename_i m d\n simp at m\n simp_all\n case abs ih =>\n exact ih\n case ite cih tih eih =>\n simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n apply List.Subset.app\n . apply List.Subset.trans\n apply cih <;> assumption\n intros x Hin\n simp_all\n cases Hin <;> simp_all\n apply List.Subset.app\n . apply List.Subset.trans\n apply tih <;> assumption\n intros x Hin\n simp_all\n cases Hin <;> simp_all\n . apply List.Subset.trans\n apply eih <;> assumption\n intros x Hin\n simp_all\n case app ih1 ih2 =>\n split\n . split\n . simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n intros x Hin\n simp_all\n . simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n intros x Hin\n simp_all\n . simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n apply List.Subset.app\n . apply List.Subset.trans\n apply ih1 <;> assumption\n intros x Hin\n simp_all\n cases Hin <;> simp_all\n . apply List.Subset.trans\n apply ih2 <;> assumption\n intros x Hin\n simp_all\n case quant trih eih =>\n simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n apply List.Subset.app\n . apply List.Subset.trans\n apply trih <;> assumption\n intros x Hin\n rename_i m1 k1 ty1 trigger1 e1\n have assoc := List.append_assoc (Lambda.LExpr.LExpr.getVars trigger1) (Lambda.LExpr.LExpr.getVars e1) [h1]\n simp_all\n cases Hin <;> simp_all\n . apply List.Subset.trans\n apply eih <;> assumption\n intros x Hin\n simp_all\n case eq ih1 ih2 =>\n simp [Imperative.HasVarsPure.getVars, Lambda.LExpr.LExpr.getVars] at *\n apply List.Subset.app\n . apply List.Subset.trans\n apply ih1 <;> assumption\n intros x Hin\n simp_all\n cases Hin <;> simp_all\n . apply List.Subset.trans\n apply ih2 <;> assumption\n intros x Hin\n simp_all", "proof_length": 313, "num_lines": 97, "header": "", "file_path": "Strata/Transform/CallElimCorrect.lean", "url": "https://github.com/strata-org/Strata", "start_line": 2964, "end_line": 3060, "version_info": [{"v4.26.0": "451e5f047bafa010d178856db76c00029bfa4d7f"}]} {"name": "CallElimCorrect.extractedOldExprInVars", "source": "strata", "statement": "open OldExpressions in\ntheorem extractedOldExprInVars :\n NormalizedOldExpr post →\n (extractOldExprVars post).Subset\n (Imperative.HasVarsPure.getVars post)", "src": "open OldExpressions in\ntheorem extractedOldExprInVars :\n NormalizedOldExpr post →\n (extractOldExprVars post).Subset\n (Imperative.HasVarsPure.getVars post) := by\n intros Hnorm\n induction post <;>\n simp [Imperative.HasVarsPure.getVars, extractOldExprVars,\n Lambda.LExpr.LExpr.getVars] at * <;>\n try simp_all\n case app fn e fn_ih e_ih =>\n unfold extractOldExprVars\n split\n . simp [Lambda.LExpr.LExpr.getVars]\n intros x Hin\n exact Hin\n . next Hfalse =>\n cases Hnorm with\n | app H1 H2 Hn =>\n exfalso\n specialize Hn ?_\n constructor\n cases Hn\n apply Hfalse\n rfl\n . cases Hnorm with\n | app H1 H2 Hn =>\n apply List.Subset.app\n . apply List.Subset.trans\n apply fn_ih\n exact H1\n intros x Hin\n simp_all\n . apply List.Subset.trans\n apply e_ih\n exact H2\n intros x Hin\n simp_all\n case abs ih =>\n cases Hnorm\n apply ih <;> assumption\n case quant trih eih =>\n cases Hnorm\n rename_i e_normalized\n rename_i tr_normalized\n rename_i tr e ty k\n apply List.Subset.app\n . apply List.Subset.trans\n apply trih <;> assumption\n intros x Hin\n simp_all\n . apply List.Subset.trans\n apply eih <;> assumption\n intros x Hin\n simp_all\n case ite cih tih eih =>\n cases Hnorm\n apply List.Subset.app\n . apply List.Subset.trans\n apply cih <;> assumption\n intros x Hin\n simp_all\n apply List.Subset.app\n . apply List.Subset.trans\n apply tih <;> assumption\n intros x Hin\n simp_all\n . apply List.Subset.trans\n apply eih <;> assumption\n intros x Hin\n simp_all\n case eq ih1 ih2 =>\n cases Hnorm\n apply List.Subset.app\n . apply List.Subset.trans\n apply ih1 <;> assumption\n intros x Hin\n simp_all\n . apply List.Subset.trans\n apply ih2 <;> assumption\n intros x Hin\n simp_all", "proof_length": 222, "num_lines": 82, "header": "", "file_path": "Strata/Transform/CallElimCorrect.lean", "url": "https://github.com/strata-org/Strata", "start_line": 2733, "end_line": 2814, "version_info": [{"v4.26.0": "451e5f047bafa010d178856db76c00029bfa4d7f"}]} {"name": "Core.InitsUpdatesComm", "source": "strata", "statement": "theorem InitsUpdatesComm\n {P : PureExpr} {σ σ' σ'' : SemanticStore P}\n {ks ks' : List P.Ident} {vs vs' : List P.Expr} :\n UpdateStates σ ks vs σ' →\n InitStates σ' ks' vs' σ'' →\n ∃ σ₁,\n σ₁ = (updatedStates σ ks' vs') ∧\n InitStates σ ks' vs' σ₁ ∧\n UpdateStates σ₁ ks vs σ''", "src": "theorem InitsUpdatesComm\n {P : PureExpr} {σ σ' σ'' : SemanticStore P}\n {ks ks' : List P.Ident} {vs vs' : List P.Expr} :\n UpdateStates σ ks vs σ' →\n InitStates σ' ks' vs' σ'' →\n ∃ σ₁,\n σ₁ = (updatedStates σ ks' vs') ∧\n InitStates σ ks' vs' σ₁ ∧\n UpdateStates σ₁ ks vs σ'' := by\n intros Hup Hinit\n exists (updatedStates σ ks' vs')\n have Hk : (isDefined σ' ks) := UpdateStatesDefined Hup\n have Hlen1 := InitStatesLength Hinit\n have Hlen2 := UpdateStatesLength Hup\n induction Hup generalizing σ''\n case update_none =>\n simp_all\n apply And.intro\n refine updatedStatesInit Hlen1 ?_ ?_\n exact InitStatesNotDefined Hinit\n exact InitStatesNodup Hinit\n simp [InitStatesUpdated Hinit]\n constructor\n case update_some σ x v σ₀ xs vs σ₁ Hup Hups ih =>\n refine ⟨rfl, ?_, ?_⟩\n . apply updatedStatesInit Hlen1\n apply UpdateStateNotDefMonotone' ?_ Hup\n apply UpdateStatesNotDefMonotone' ?_ Hups\n exact InitStatesNotDefined Hinit\n exact InitStatesNodup Hinit\n . apply UpdateStates.update_some (σ':=updatedStates σ₀ ks' vs')\n . simp [UpdateStateUpdated Hup, updatedStates]\n rw [← updatedStateComm']\n . have Hdef := UpdateStateDefined' Hup\n simp [isDefined, Option.isSome] at Hdef\n split at Hdef <;> simp_all\n next val heq =>\n apply updatedStateUpdate (v':=val)\n apply InitStatesSomeMonotone heq\n apply updatedStatesInit\n . simp_all\n . apply UpdateStateNotDefMonotone' ?_ Hup\n apply UpdateStatesNotDefMonotone' ?_ Hups\n apply InitStatesNotDefined Hinit\n . exact InitStatesNodup Hinit\n . rw [List.unzip_zip] <;> simp_all\n have Hnd := InitStatesNotDefined Hinit\n simp [isNotDefined, isDefined] at *\n apply Not.intro\n intros Hin\n specialize Hnd _ Hin\n simp_all\n . apply (ih Hinit ?_ ?_).2.2\n . simp [isDefined] at * <;> simp_all\n . simp_all", "proof_length": 224, "num_lines": 55, "header": "", "file_path": "Strata/Languages/Core/StatementSemanticsProps.lean", "url": "https://github.com/strata-org/Strata", "start_line": 950, "end_line": 1004, "version_info": [{"v4.29.1": "384e22374e0872095ad9c6f74c5998c09cfd93a9"}, {"v4.27.0": "4348c65a93a3b57b1a4541991ed2d2fcdd9fa35d"}, {"v4.26.0": "451e5f047bafa010d178856db76c00029bfa4d7f"}]} {"name": "fundamental_theorem_of_variational_calculus'", "source": "physlib", "statement": "lemma fundamental_theorem_of_variational_calculus' {f : Y → V}\n (μ : Measure Y) [IsFiniteMeasureOnCompacts μ] [μ.IsOpenPosMeasure]\n [OpensMeasurableSpace Y]\n (hf : Continuous f) (hg : ∀ g, IsTestFunction g → ∫ x, ⟪f x, g x⟫_ℝ ∂μ = 0) :\n f = 0", "src": "lemma fundamental_theorem_of_variational_calculus' {f : Y → V}\n (μ : Measure Y) [IsFiniteMeasureOnCompacts μ] [μ.IsOpenPosMeasure]\n [OpensMeasurableSpace Y]\n (hf : Continuous f) (hg : ∀ g, IsTestFunction g → ∫ x, ⟪f x, g x⟫_ℝ ∂μ = 0) :\n f = 0 := by\n -- assume ¬(f = 0)\n rw [funext_iff]; by_contra h₀\n obtain ⟨x₀, hx0⟩ := not_forall.1 h₀\n simp at hx0 -- hx0 : f x₀ ≠ 0\n\n -- [1] Proof that `f` is continuous at `x₀`.\n -- Embed into the true IP-space `WithLp 2 V`.\n let f₂ : Y → WithLp 2 V := toL2 ℝ ∘ f\n let x₂ := f₂ x₀\n -- x₂ ≠ 0 because `fromL2 (toL2 (f x₀)) = f x₀`\n have hx2 : x₂ ≠ 0 := by\n intro h; apply hx0; exact congrArg (fromL2 ℝ) h\n -- continuity of f₂ at x₀\n have hcont₂ : ContinuousAt f₂ x₀ := ((toL2 ℝ).continuous.comp hf).continuousAt\n\n -- [2] find open neighborhood guaranteeing positive inner product with the center, based on\n -- which the test function `g` will be constructed.\n -- pick δ₂ so that on B(x₀, δ₂), ‖f₂ x - x₂‖ < ‖x₂‖/2\n obtain ⟨δ₂, hδ₂_pos, hδ₂⟩ :=\n Metric.continuousAt_iff.mp hcont₂ (‖x₂‖ / 2)\n (by simpa [half_pos] using (norm_pos_iff.mpr hx2))\n -- now the usual “add & subtract” proof inside WithLp 2 V\n have inner_pos₂ : ∀ x (hx : x ∈ Metric.ball x₀ δ₂), 0 < (⟪f₂ x, x₂⟫_ℝ : ℝ) := by\n intros x hx\n -- hx : x ∈ ball x₀ δ₂, so dist x x₀ < δ₂, hence\n -- this is |⟪u,v⟫| ≤ ‖u‖ * ‖v‖, in the genuine InnerProductSpace on WithLp 2 V\n have hclose : ‖f₂ x - x₂‖ < ‖x₂‖ / 2 := by\n convert hδ₂ hx using 1\n exact mem_sphere_iff_norm.mp rfl\n have hself : ⟪x₂, x₂⟫_ℝ = ‖x₂‖^2 := real_inner_self_eq_norm_sq (x₂ : WithLp 2 V)\n -- Cauchy–Schwarz in `WithLp 2 V` bounds the cross term from below\n have hcs : -(‖f₂ x - x₂‖ * ‖x₂‖) ≤ ⟪f₂ x - x₂, x₂⟫_ℝ :=\n neg_le_of_abs_le (abs_real_inner_le_norm _ _)\n have hxp : 0 < ‖x₂‖ := norm_pos_iff.mpr hx2\n have inner_eq_self_add_diff : ⟪f₂ x, x₂⟫_ℝ = ⟪x₂, x₂⟫_ℝ + ⟪f₂ x - x₂, x₂⟫_ℝ := by\n rw [← inner_add_left]; simp\n nlinarith [inner_eq_self_add_diff, hcs, hself, hclose, hxp,\n mul_lt_mul_of_pos_right hclose hxp]\n -- pull `inner_pos₂` back to V via `fromL2`:\n have inner_pos_V : ∀ x ∈ Metric.ball x₀ δ₂, 0 < ⟪f x, f x₀⟫_ℝ := fun x hx => inner_pos₂ x hx\n -- now we have a genuine positive integrand on a set of positive measure.\n\n -- [3] `g` construction using bump function.\n have bump_exists : ∃ φ : Y → ℝ, IsTestFunction φ ∧ φ x₀ > 0 ∧\n (∀ x ∈ Function.support φ, 0 ≤ φ x) ∧\n Function.support φ ⊆ Metric.ball x₀ (δ₂/2) ∧\n (∀ x ∈ Metric.closedBall x₀ (δ₂/4), 0 < φ x) := by\n -- use `hasContDiffBump_of_innerProductSpace`, leveraging `[innerProductSpace Y]`\n haveI : HasContDiffBump Y := hasContDiffBump_of_innerProductSpace Y\n let φ1 : ContDiffBump x₀ :=\n ⟨δ₂ / 4, δ₂ / 2, by positivity, by linarith⟩\n refine ⟨φ1.toFun, ⟨φ1.contDiff, φ1.hasCompactSupport⟩,\n φ1.pos_of_mem_ball (Metric.mem_ball_self φ1.rOut_pos), fun x _ => φ1.nonneg,\n by rw [ContDiffBump.support_eq], fun x hx => φ1.pos_of_mem_ball ?_⟩\n -- the closed ball of radius `δ₂/4` lies in the open ball of radius `rOut = δ₂/2`\n rw [Metric.mem_closedBall] at hx\n exact Metric.mem_ball.mpr (lt_of_le_of_lt hx (by show δ₂ / 4 < δ₂ / 2; linarith))\n obtain ⟨φ, hφ_testfun, hφ_pos_x₀, hφ_non_neg, hφ_support_subset, hφ_pos_inner⟩ :=\n bump_exists\n -- Define test function g(x) = φ(x) * f(x₀)\n let g : Y → V := fun x => φ x • f x₀\n -- Show that g is a test function: `φ` is a test function and `f x₀` is smooth (constant)\n have hg_test : IsTestFunction g := IsTestFunction.smul_right hφ_testfun contDiff_const\n\n -- [4] Derive contradiction. First compute the integral ∫ ⟪f x, g x⟫\n -- [4.1] ∫ φ x * ⟪f x, f x₀⟫ = 0\n have key_integral := hg g hg_test\n -- linearity of inner product in the second argument turns the integrand into `φ x * ⟪f x, f x₀⟫`\n simp only [g, inner_smul_right'] at key_integral\n\n -- [4.2] 0 < ∫ x, φ x * ⟪f x, f x₀⟫_ℝ ∂μ. Sketch: on the support of φ (which is contained in\n -- B(x₀, δ/2) ⊆ B(x₀, δ)), we have ⟪f x, f x₀⟫ > ‖f x₀‖²/2 > 0 by our choice of δ.\n -- Since φ is nonnegative on its support and positive somewhere, this gives the contradiction.\n\n -- [4.2.1] Integrability of the integrand: `integrable_prod` .\n have support_subset : Function.support φ ⊆ Metric.ball x₀ δ₂ :=\n hφ_support_subset.trans (Metric.ball_subset_ball (by linarith))\n have supp_subset2 : Function.support (fun x => φ x * ⟪f x, f x₀⟫_ℝ) ⊆ Function.support φ := by\n intro x hprod hφ0\n -- if φ x = 0 then φ x * inner = 0, contradiction\n simp [hφ0] at hprod\n have hinner_cont : Continuous (fun x => ⟪f x, f x₀⟫_ℝ) :=\n Continuous.inner' (f : Y → V) (fun _ => f x₀) hf continuous_const\n have integrable_prod :\n Integrable (fun x => φ x * ⟪f x, f x₀⟫_ℝ) μ :=\n -- (i) build a `HasCompactSupport` witness for the product\n (Continuous.mul hφ_testfun.smooth.continuous hinner_cont).integrable_of_hasCompactSupport\n (hφ_testfun.supp.mono supp_subset2)\n\n -- [4.2.2] Nonnegativity everywhere (`h_nonneg`)\n have h_nonneg : ∀ x, 0 ≤ φ x * ⟪f x, f x₀⟫_ℝ := by\n intro x\n by_cases hx : x ∈ Function.support φ\n · -- on the support, φ ≥ 0 and ⟪f x, f x₀⟫ > 0\n exact mul_nonneg (hφ_non_neg x hx) (inner_pos_V x (support_subset hx)).le\n · -- off the support, φ x = 0 so the product is 0\n simp [Function.notMem_support.mp hx]\n\n -- [4.2.3] That closed ball has positive measure, and is contained in the support\n -- every nonempty open set has positive measure\n have hμ_ball : 0 < μ (Metric.ball x₀ (δ₂/4)) :=\n Metric.isOpen_ball.measure_pos μ (Metric.nonempty_ball.mpr (by linarith))\n have hμ : 0 < μ (Metric.closedBall x₀ (δ₂/4)) :=\n lt_of_lt_of_le hμ_ball (measure_mono Metric.ball_subset_closedBall)\n have closedBall_subset_support :\n Metric.closedBall x₀ (δ₂/4)\n ⊆ Function.support (fun x => φ x * ⟪f x, f x₀⟫_ℝ) := by\n intro x hx\n have hφx := hφ_pos_inner x hx\n have hin : 0 < ⟪f x, f x₀⟫_ℝ :=\n inner_pos_V x (Metric.closedBall_subset_ball (by linarith) hx)\n simp only [Function.support_mul, Set.mem_inter_iff, Function.mem_support, ne_eq]\n constructor\n · linarith\n · linarith\n\n -- [4.2.4] putting everything together: positivity contradicts `key_integral : ∫ ... = 0`\n have integral_pos : 0 < ∫ x, φ x * ⟪f x, f x₀⟫_ℝ ∂μ :=\n (integral_pos_iff_support_of_nonneg h_nonneg integrable_prod).mpr\n (lt_of_lt_of_le hμ (measure_mono closedBall_subset_support))\n linarith", "proof_length": 851, "num_lines": 126, "header": "", "file_path": "Physlib/Mathematics/VariationalCalculus/Basic.lean", "url": "https://github.com/leanprover-community/physlib", "start_line": 99, "end_line": 224, "version_info": [{"v4.32.0": "c48433678e8fb6306ebcd48453300c8e16058a62"}]} {"name": "Electromagnetism.ElectromagneticPotential.time_deriv_time_deriv_electricField_of_isExtrema", "source": "physlib", "statement": "lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPotential d}\n {𝓕 : FreeSpace}\n (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d)\n (hJ : ContDiff ℝ ∞ J) (h : IsExtrema 𝓕 A J)\n (t : Time) (x : Space d) (i : Fin d) :\n ∂ₜ (∂ₜ (A.electricField 𝓕.c · x i)) t =\n 𝓕.c ^ 2 * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) -\n 𝓕.c ^ 2 / 𝓕.ε₀ * ∂[i] (J.chargeDensity 𝓕.c t ·) x -\n 𝓕.c ^ 2 * 𝓕.μ₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t", "src": "lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPotential d}\n {𝓕 : FreeSpace}\n (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d)\n (hJ : ContDiff ℝ ∞ J) (h : IsExtrema 𝓕 A J)\n (t : Time) (x : Space d) (i : Fin d) :\n ∂ₜ (∂ₜ (A.electricField 𝓕.c · x i)) t =\n 𝓕.c ^ 2 * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) -\n 𝓕.c ^ 2 / 𝓕.ε₀ * ∂[i] (J.chargeDensity 𝓕.c t ·) x -\n 𝓕.c ^ 2 * 𝓕.μ₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n have hEs : ∀ j, ContDiff ℝ 2 (fun y => A.electricField 𝓕.c t y j) :=\n fun j => electricField_apply_contDiff_space (i := j) (hA.of_le (right_eq_inf.mp rfl)) t\n have hEd : ∀ j k, Differentiable ℝ (∂[k] (fun y => A.electricField 𝓕.c t y j)) :=\n fun j k => Space.deriv_differentiable (hEs j) k\n have hBt : ∀ j, Differentiable ℝ\n (fun s => ∂[j] (fun y => A.magneticFieldMatrix 𝓕.c s y (j, i)) x) :=\n fun j => Space.space_deriv_differentiable_time (i := j)\n (magneticFieldMatrix_contDiff _ (hA.of_le (right_eq_inf.mp rfl)) (j, i)) x\n have hJt : Differentiable ℝ (fun s => J.currentDensity 𝓕.c s x i) :=\n LorentzCurrentDensity.currentDensity_apply_differentiable_time (hJ.differentiable (by simp)) x i\n calc _\n _= ∂ₜ (fun t =>\n 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, Space.deriv j (fun x => magneticFieldMatrix 𝓕.c A t x (j, i)) x -\n 1 / 𝓕.ε₀ * LorentzCurrentDensity.currentDensity 𝓕.c J t x i) t := by\n conv_lhs =>\n enter [1]\n change fun t => ∂ₜ (A.electricField 𝓕.c · x i) t\n enter [t]\n rw [Time.deriv_euclid (electricField_differentiable_time\n (hA.of_le (right_eq_inf.mp rfl)) _),\n time_deriv_electricField_of_isExtrema hA J hJ h]\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∂ₜ (fun t => ∑ j, ∂[j] (A.magneticFieldMatrix 𝓕.c t · (j, i)) x) t -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n rw [Time.deriv_eq]\n rw [fderiv_fun_sub]\n simp only [one_div, mul_inv_rev, FunLike.coe_sub, Pi.sub_apply]\n rw [fderiv_const_mul (Differentiable.fun_sum fun j _ => hBt j).differentiableAt]\n rw [fderiv_const_mul hJt.differentiableAt]\n simp [Time.deriv_eq]\n · exact ((Differentiable.fun_sum fun j _ => hBt j).const_mul _).differentiableAt\n · exact hJt.differentiableAt.const_mul _\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ((∑ j, ∂ₜ (fun t => ∂[j] (A.magneticFieldMatrix 𝓕.c t · (j, i)) x)) t) -\n 1 / 𝓕.ε₀ * (∂ₜ (J.currentDensity 𝓕.c · x i) t) := by\n congr\n rw [Time.deriv_eq]\n rw [fderiv_fun_sum fun i _ => (hBt i).differentiableAt]\n simp only [FunLike.coe_sum, Finset.sum_apply]\n rfl\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∑ j, ∂[j] (fun x => ∂ₜ (A.magneticFieldMatrix 𝓕.c · x (j, i)) t)) x -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr\n simp only [Finset.sum_apply]\n congr\n funext k\n rw [Space.time_deriv_comm_space_deriv]\n apply magneticFieldMatrix_contDiff\n apply hA.of_le (right_eq_inf.mp rfl)\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) *(∑ j, ∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x -\n ∂[i] (A.electricField 𝓕.c t · j) x)) x -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr\n simp only [Finset.sum_apply]\n congr\n funext k\n congr\n funext x\n rw [time_deriv_magneticFieldMatrix _ (hA.of_le (ENat.LEInfty.out))]\n _ = (1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x -\n ∂[j] (fun x => ∂[i] (A.electricField 𝓕.c t · j) x) x)) -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr\n simp only [Finset.sum_apply]\n congr\n funext j\n rw [Space.deriv_eq_fderiv_basis]\n rw [fderiv_fun_sub (hEd _ _).differentiableAt (hEd _ _).differentiableAt]\n simp [← Space.deriv_eq_fderiv_basis]\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x) -\n 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[i] (A.electricField 𝓕.c t · j) x) x) -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by simp [mul_sub]\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x) -\n 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[i] (fun x => ∂[j] (A.electricField 𝓕.c t · j) x) x) -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr\n funext j\n rw [Space.deriv_commute _ (hEs _), Space.deriv_eq_fderiv_basis]\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x) -\n 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∂[i] (fun x => ∑ j, ∂[j] (A.electricField 𝓕.c t · j) x) x) -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr\n rw [Space.deriv_eq_fderiv_basis]\n rw [fderiv_fun_sum]\n simp [← Space.deriv_eq_fderiv_basis]\n intro j _\n exact (hEd j j).differentiableAt\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x) -\n 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∂[i] (fun x => (∇ ⬝ (A.electricField 𝓕.c t)) x) x) -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n rfl\n _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) -\n 1 / (𝓕.μ₀ * 𝓕.ε₀ ^ 2) * ∂[i] (J.chargeDensity 𝓕.c t ·) x -\n 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n congr 2\n rw [isExtrema_iff_gauss_ampere_magneticFieldMatrix] at h\n\n conv_lhs =>\n enter [2, 2, x]\n rw [(h t x).1]\n trans 1 / (𝓕.μ₀ * 𝓕.ε₀) * Space.deriv i\n (fun x => (1/ 𝓕.ε₀) * LorentzCurrentDensity.chargeDensity 𝓕.c J t x) x\n · congr\n funext x\n ring\n · rw [Space.deriv_eq_fderiv_basis]\n rw [fderiv_const_mul]\n simp [← Space.deriv_eq_fderiv_basis]\n field_simp\n apply Differentiable.differentiableAt\n apply LorentzCurrentDensity.chargeDensity_differentiable_space\n exact hJ.differentiable (by simp)\n · exact hA\n · exact hJ\n _ = 𝓕.c ^ 2 * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) -\n 𝓕.c ^ 2 / 𝓕.ε₀ * ∂[i] (J.chargeDensity 𝓕.c t ·) x -\n 𝓕.c ^ 2 * 𝓕.μ₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by\n simp [FreeSpace.c_sq]\n field_simp", "proof_length": 1372, "num_lines": 126, "header": "", "file_path": "Physlib/Electromagnetism/Dynamics/IsExtrema.lean", "url": "https://github.com/leanprover-community/physlib", "start_line": 376, "end_line": 501, "version_info": [{"v4.32.0": "c48433678e8fb6306ebcd48453300c8e16058a62"}]} {"name": "FieldSpecification.WickAlgebra.ι_timeOrderF_superCommuteF_eq_time", "source": "physlib", "statement": "lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp}\n (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.FieldOpFreeAlgebra) :\n ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) =\n ι ([ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * 𝓣ᶠ(a * b))", "src": "lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp}\n (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.FieldOpFreeAlgebra) :\n ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) =\n ι ([ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * 𝓣ᶠ(a * b)) := by\n let pb (b : 𝓕.FieldOpFreeAlgebra) (hc : b ∈ Submodule.span ℂ (Set.range ofCrAnListFBasis)) :\n Prop := ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) =\n ι ([ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * 𝓣ᶠ(a * b))\n change pb b (Basis.mem_span _ b)\n apply Submodule.span_induction\n · rintro x ⟨φs, rfl⟩\n simp only [ofListBasis_eq_ofList, map_mul, pb]\n let pa (a : 𝓕.FieldOpFreeAlgebra) (hc : a ∈ Submodule.span ℂ (Set.range ofCrAnListFBasis)) :\n Prop := ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * ofCrAnListF φs) =\n ι ([ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * 𝓣ᶠ(a* ofCrAnListF φs))\n change pa a (Basis.mem_span _ a)\n apply Submodule.span_induction\n · rintro x ⟨φs', rfl⟩\n simp only [ofListBasis_eq_ofList, map_mul, pa]\n calc _\n /- Split the commutator. -/\n _ = crAnTimeOrderSign (φs' ++ φ :: ψ :: φs) •\n ι (ofCrAnListF (crAnTimeOrderList (φs' ++ φ :: ψ :: φs))) -\n crAnTimeOrderSign (φs' ++ ψ :: φ :: φs) •\n 𝓢(𝓕.crAnStatistics φ, 𝓕.crAnStatistics ψ) •\n ι (ofCrAnListF (crAnTimeOrderList (φs' ++ ψ :: φ :: φs))) := by\n conv_lhs =>\n rw [← ofCrAnListF_singleton, ← ofCrAnListF_singleton,\n superCommuteF_ofCrAnListF_ofCrAnListF]\n simp [mul_sub, sub_mul, ← ofCrAnListF_append]\n rw [timeOrderF_ofCrAnListF, timeOrderF_ofCrAnListF]\n simp only [map_smul, sub_right_inj]\n module\n /- Simplify the signs. -/\n _ = crAnTimeOrderSign (φs' ++ φ :: ψ :: φs) •\n (ι (ofCrAnListF (crAnTimeOrderList (φs' ++ φ :: ψ :: φs))) -\n 𝓢(𝓕.crAnStatistics φ, 𝓕.crAnStatistics ψ) •\n ι (ofCrAnListF (crAnTimeOrderList (φs' ++ ψ :: φ :: φs)))) := by\n rw [crAnTimeOrderSign_swap_eq_time hφψ hψφ]\n module\n /- Splitting the time-ordered lists. -/\n _ = crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) •\n (ι (ofCrAnListF (List.takeWhile (fun c => ¬crAnTimeOrderRel φ c)\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) *\n ι (ofCrAnListF (List.filter (fun c =>\n (crAnTimeOrderRel φ c ∧ crAnTimeOrderRel c φ)) φs')) *\n ι (ofCrAnListF [φ, ψ]) *\n ι (ofCrAnListF (List.filter (fun c =>\n (crAnTimeOrderRel φ c ∧ crAnTimeOrderRel c φ)) φs)) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧ ¬crAnTimeOrderRel c φ))\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) -\n 𝓢(𝓕.crAnStatistics φ, 𝓕.crAnStatistics ψ) •\n ι (ofCrAnListF (List.takeWhile (fun c => ¬crAnTimeOrderRel φ c)\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) *\n ι (ofCrAnListF (List.filter (fun c =>\n (crAnTimeOrderRel φ c ∧ crAnTimeOrderRel c φ)) φs')) *\n ι (ofCrAnListF [ψ, φ]) *\n ι (ofCrAnListF (List.filter (fun c =>\n (crAnTimeOrderRel φ c ∧ crAnTimeOrderRel c φ)) φs)) *\n ι (ofCrAnListF\n (List.filter (fun c => decide (crAnTimeOrderRel φ c ∧ ¬crAnTimeOrderRel c φ))\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs))))) := by\n have h1 := insertionSort_of_eq_list 𝓕.crAnTimeOrderRel φ φs' [φ, ψ] φs\n (by simp_all)\n rw [crAnTimeOrderList, show φs' ++ φ :: ψ :: φs = φs' ++ [φ, ψ] ++ φs by simp, h1]\n have h2 := insertionSort_of_eq_list 𝓕.crAnTimeOrderRel φ φs' [ψ, φ] φs\n (by simp_all)\n rw [crAnTimeOrderList, show φs' ++ ψ :: φ :: φs = φs' ++ [ψ, φ] ++ φs by simp, h2]\n repeat rw [ofCrAnListF_append]\n simp\n _ = crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) •\n (ι (ofCrAnListF (List.takeWhile (fun c => ¬crAnTimeOrderRel φ c)\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧\n crAnTimeOrderRel c φ)) φs')) *\n (ι (ofCrAnListF [φ, ψ]) - 𝓢(𝓕.crAnStatistics φ, 𝓕.crAnStatistics ψ) •\n ι (ofCrAnListF [ψ, φ])) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧\n crAnTimeOrderRel c φ)) φs)) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧ ¬crAnTimeOrderRel c φ))\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs))))) := by\n simp [mul_sub, sub_mul]\n _ = crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) •\n (ι (ofCrAnListF (List.takeWhile (fun c => ¬crAnTimeOrderRel φ c)\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧\n crAnTimeOrderRel c φ)) φs')) *\n ι [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧\n crAnTimeOrderRel c φ)) φs)) *\n ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧ ¬crAnTimeOrderRel c φ))\n (List.insertionSort crAnTimeOrderRel (φs' ++ φs))))) := by\n congr\n rw [superCommuteF_ofCrAnOpF_ofCrAnOpF, ← ofCrAnListF_singleton,\n ← ofCrAnListF_singleton]\n simp [← ofCrAnListF_append]\n rw [Subalgebra.mem_center_iff.mp (ι_superCommuteF_ofCrAnOpF_ofCrAnOpF_mem_center φ ψ)]\n repeat rw [mul_assoc]\n rw [← map_mul, ← map_mul, ← map_mul, ← ofCrAnListF_append, ← ofCrAnListF_append,\n ← ofCrAnListF_append]\n have h1 := insertionSort_of_takeWhile_filter 𝓕.crAnTimeOrderRel φ φs' φs\n simp [decide_not, Bool.decide_and, List.append_assoc, List.cons_append] at h1 ⊢\n rw [← h1, ← crAnTimeOrderList]\n by_cases hq : (𝓕 |>ₛ φ) ≠ (𝓕 |>ₛ ψ)\n · simp [ι_superCommuteF_of_diff_statistic hq]\n · rw [crAnTimeOrderSign, Wick.koszulSign_eq_rel_eq_stat _ _ hφψ hψφ (by simp_all),\n ← crAnTimeOrderSign, ← ofCrAnListF_append, timeOrderF_ofCrAnListF]\n simp only [map_smul, Algebra.mul_smul_comm]\n · simp only [map_mul, zero_mul, map_zero, mul_zero, pa]\n · intro x y hx hy hpx hpy\n simp_all [pa,mul_add, add_mul]\n · intro x hx hpx\n simp_all [pa]\n · simp only [map_mul, mul_zero, map_zero, pb]\n · intro x y hx hy hpx hpy\n simp_all [pb,mul_add]\n · intro x hx hpx\n simp_all [pb]", "proof_length": 1217, "num_lines": 117, "header": "", "file_path": "Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean", "url": "https://github.com/leanprover-community/physlib", "start_line": 162, "end_line": 278, "version_info": [{"v4.32.0": "c48433678e8fb6306ebcd48453300c8e16058a62"}]} {"name": "Cslib.LambdaCalculus.LocallyNameless.Fsub.Typing.progress", "source": "cslib", "statement": "lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t'", "src": "lemma Typing.progress (der : Typing [] t τ) : t.Value ∨ ∃ t', t ⭢βᵛ t' := by\n generalize eq : [] = Γ at der\n have der' : Typing Γ t τ := der\n induction der <;> subst eq\n case var mem => grind\n case app t₁ _ _ t₂ l r ih_l ih_r =>\n right\n cases ih_l rfl l with\n | inl val_l =>\n cases ih_r rfl r with\n | inl val_r =>\n have ⟨σ, t₁, eq⟩ := l.canonical_form_abs val_l\n exists t₁ ^ᵗᵗ t₂\n grind\n | inr red_r =>\n obtain ⟨t₂', _⟩ := red_r\n exists t₁.app t₂'\n grind\n | inr red_l =>\n obtain ⟨t₁', _⟩ := red_l\n exists t₁'.app t₂\n grind\n case tapp σ' der _ ih =>\n right\n specialize ih rfl der\n cases ih with\n | inl val =>\n obtain ⟨_, t, _⟩ := der.canonical_form_tabs val\n exists t ^ᵗᵞ σ'\n grind\n | inr red =>\n obtain ⟨t', _⟩ := red\n exists .tapp t' σ'\n grind\n case let' t₁ σ t₂ τ L der _ ih _ =>\n right\n cases ih rfl der with\n | inl _ =>\n exists t₂ ^ᵗᵗ t₁\n grind\n | inr red =>\n obtain ⟨t₁', _⟩ := red\n exists t₁'.let' t₂\n grind\n case inl der _ ih =>\n cases (ih rfl der) with\n | inl val => grind\n | inr red =>\n right\n obtain ⟨t', _⟩ := red\n exists .inl t'\n grind\n case inr der _ ih =>\n cases (ih rfl der) with\n | inl val => grind\n | inr red =>\n right\n obtain ⟨t', _⟩ := red\n exists .inr t'\n grind\n case case t₁ _ _ t₂ _ t₃ _ der _ _ ih _ _ =>\n right\n cases ih rfl der with\n | inl val =>\n have ⟨t₁, lr⟩ := der.canonical_form_sum val\n cases lr <;> [exists t₂ ^ᵗᵗ t₁; exists t₃ ^ᵗᵗ t₁] <;> grind\n | inr red =>\n obtain ⟨t₁', _⟩ := red\n exists t₁'.case t₂ t₃\n grind\n case sub => grind\n case abs σ _ τ L _ _=>\n left\n constructor\n apply LC.abs L\n · grind only [→ wf, cases Term.LC]\n · grind only [→ wf]\n case tabs L _ _=>\n left\n constructor\n apply LC.tabs L\n · grind only [→ wf, cases Term.LC]\n · grind only [→ wf]", "proof_length": 408, "num_lines": 83, "header": "", "file_path": "Cslib/Languages/LambdaCalculus/LocallyNameless/Fsub/Safety.lean", "url": "https://github.com/leanprover/cslib", "start_line": 76, "end_line": 158, "version_info": [{"v4.33.0-rc2": "3aa9d4416c185e0b9faeb72bbd65abe85b95dbcc"}, {"v4.32.0": "197a7be621263b84c67ca4f803f69205b36d06df"}, {"v4.31.0": "8ea71c8df91acd63285515a04da952b23b78d266"}]} {"name": "Cslib.SKI.parallelReduction_diamond", "source": "cslib", "statement": "theorem parallelReduction_diamond : Diamond ParallelReduction", "src": "theorem parallelReduction_diamond : Diamond ParallelReduction := by\n intro a a₁ a₂ h₁ h₂\n cases h₁\n case refl => exact ⟨a₂, h₂, .refl a₂⟩\n case par a a' b b' ha' hb' =>\n cases h₂\n case refl =>\n use a' ⬝ b'\n exact ⟨.refl (a' ⬝ b'), .par ha' hb'⟩\n case par a'' b'' ha'' hb'' =>\n let ⟨a₃, ha⟩ := parallelReduction_diamond ha' ha''\n let ⟨b₃, hb⟩ := parallelReduction_diamond hb' hb''\n use a₃ ⬝ b₃\n constructor\n · exact .par ha.1 hb.1\n · exact .par ha.2 hb.2\n case red_I =>\n rw [I_irreducible a' ha']\n use b', .red_I b'\n case red_K =>\n let ⟨a₂', ha₂'⟩ := Ka_irreducible a₂ a' ha'\n rw [ha₂'.2]\n use a₂'\n exact ⟨.red_K a₂' b', ha₂'.1⟩\n case red_S a c =>\n let ⟨a'', c', h⟩ := Sab_irreducible a c a' ha'\n rw [h.2.2]\n use a'' ⬝ b' ⬝ (c' ⬝ b'), .red_S a'' c' b'\n apply ParallelReduction.par <;>\n apply ParallelReduction.par <;>\n grind\n case red_I =>\n cases h₂\n case refl => use a₁; exact ⟨.refl a₁, .red_I a₁⟩\n case par c a₁' hc ha =>\n rw [I_irreducible c hc]\n use a₁'\n exact ⟨ha, .red_I a₁'⟩\n case red_I => use a₁; exact ⟨.refl a₁, .refl a₁⟩\n case red_K c =>\n cases h₂\n case refl => use a₁; exact ⟨.refl a₁, .red_K a₁ c⟩\n case par a' c' ha hc =>\n let ⟨a₁', h'⟩ := Ka_irreducible a₁ a' ha\n rw [h'.2]\n use a₁'\n exact ⟨h'.1, .red_K a₁' c'⟩\n case red_K =>\n use a₁; exact ⟨.refl a₁, .refl a₁⟩\n case red_S a b c =>\n cases h₂\n case refl =>\n use a ⬝ c ⬝ (b ⬝ c)\n exact ⟨.refl _, .red_S ..⟩\n case par d c' hd hc =>\n let ⟨a', b', h⟩ := Sab_irreducible a b d hd\n rw [h.2.2]\n use a' ⬝ c' ⬝ (b' ⬝ c')\n constructor\n · apply ParallelReduction.par\n · exact .par h.left hc\n · exact .par h.2.1 hc\n · exact .red_S ..\n case red_S => exact ⟨a ⬝ c ⬝ (b ⬝ c), .refl _, .refl _,⟩", "proof_length": 407, "num_lines": 64, "header": "", "file_path": "Cslib/Languages/CombinatoryLogic/Confluence.lean", "url": "https://github.com/leanprover/cslib", "start_line": 142, "end_line": 205, "version_info": [{"v4.33.0-rc2": "3aa9d4416c185e0b9faeb72bbd65abe85b95dbcc"}, {"v4.32.0": "197a7be621263b84c67ca4f803f69205b36d06df"}, {"v4.31.0": "8ea71c8df91acd63285515a04da952b23b78d266"}, {"v4.30.0": "c7944a9fb44c3298f1a960a5e574ab23a6ab8ed5"}]} {"name": "Cslib.CCS.bisimilarity_congr_choice", "source": "cslib", "statement": "theorem bisimilarity_congr_choice :\n (p ~[lts (defs := defs)] q) → (choice p r) ~[lts (defs := defs)] (choice q r)", "src": "theorem bisimilarity_congr_choice :\n (p ~[lts (defs := defs)] q) → (choice p r) ~[lts (defs := defs)] (choice q r) := by\n intro h\n exists @ChoiceBisim _ _ defs\n constructor\n · constructor; assumption\n intro s1 s2 r μ\n constructor\n case left =>\n intro s1' htr\n cases r\n case choice p q r hbisim =>\n obtain ⟨rel, hr, hb⟩ := hbisim\n cases htr\n case choiceL a b c htr =>\n obtain ⟨s2', htr2, hr2⟩ := hb.follow_fst hr htr\n exists s2'\n constructor\n · apply Tr.choiceL htr2\n · constructor\n apply hb.le_bisimilarity _ _ hr2\n case choiceR a b c htr =>\n exists s1'\n constructor\n · apply Tr.choiceR htr\n · constructor\n apply HomBisimilarity.refl\n case bisim hbisim =>\n obtain ⟨rel, hr, hb⟩ := hbisim\n obtain ⟨s2', htr2, hr2⟩ := hb.follow_fst hr htr\n exists s2'\n constructor\n · assumption\n constructor\n apply hb.le_bisimilarity _ _ hr2\n case right =>\n intro s2' htr\n cases r\n case choice p q r hbisim =>\n obtain ⟨rel, hr, hb⟩ := hbisim\n cases htr\n case choiceL a b c htr =>\n obtain ⟨s1', htr1, hr1⟩ := hb.follow_snd hr htr\n exists s1'\n constructor\n · apply Tr.choiceL htr1\n · constructor\n apply hb.le_bisimilarity _ _ hr1\n case choiceR a b c htr =>\n exists s2'\n constructor\n · apply Tr.choiceR htr\n · constructor\n apply HomBisimilarity.refl\n case bisim hbisim =>\n obtain ⟨rel, hr, hb⟩ := hbisim\n obtain ⟨s1', htr1, hr1⟩ := hb.follow_snd hr htr\n exists s1'\n constructor\n · assumption\n · constructor\n apply hb.le_bisimilarity _ _ hr1", "proof_length": 251, "num_lines": 62, "header": "", "file_path": "Cslib/Languages/CCS/BehaviouralTheory.lean", "url": "https://github.com/leanprover/cslib", "start_line": 311, "end_line": 372, "version_info": [{"v4.33.0-rc2": "3aa9d4416c185e0b9faeb72bbd65abe85b95dbcc"}, {"v4.32.0": "197a7be621263b84c67ca4f803f69205b36d06df"}, {"v4.31.0": "8ea71c8df91acd63285515a04da952b23b78d266"}]} {"name": "Binius.BinaryBasefold.fiberwise_dist_lt_imp_dist_lt_unique_decoding_radius", "source": "arklib", "statement": "theorem fiberwise_dist_lt_imp_dist_lt_unique_decoding_radius (i : Fin ℓ) (steps : ℕ)\n [NeZero steps] (h_i_add_steps : i.val + steps ≤ ℓ)\n (f : OracleFunction 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i, by omega⟩)\n (h_fw_dist_lt : fiberwiseClose 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate)\n (i := i) (steps := steps) (h_i_add_steps := h_i_add_steps) (f := f)) :\n hammingClose 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i, by omega⟩ f", "src": "theorem fiberwise_dist_lt_imp_dist_lt_unique_decoding_radius (i : Fin ℓ) (steps : ℕ)\n [NeZero steps] (h_i_add_steps : i.val + steps ≤ ℓ)\n (f : OracleFunction 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i, by omega⟩)\n (h_fw_dist_lt : fiberwiseClose 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate)\n (i := i) (steps := steps) (h_i_add_steps := h_i_add_steps) (f := f)) :\n hammingClose 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i, by omega⟩ f := by\n unfold fiberwiseClose at h_fw_dist_lt\n unfold hammingClose\n -- 2 * Δ₀(f, ↑(BBF_Code 𝔽q β ⟨↑i, ⋯⟩)) < ↑(BBF_CodeDistance ℓ 𝓡 ⟨↑i, ⋯⟩)\n let d_fw := fiberwiseDistance 𝔽q β (i := i) steps h_i_add_steps f\n let C_i := (BBF_Code 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i, by omega⟩)\n let d_H := Code.distFromCode f C_i\n let d_i := BBF_CodeDistance ℓ 𝓡 (⟨i, by omega⟩)\n let d_i_plus_steps := BBF_CodeDistance ℓ 𝓡 ⟨i.val + steps, by omega⟩\n\n have h_d_i_gt_0 : d_i > 0 := by\n dsimp [d_i, BBF_CodeDistance] -- ⊢ 2 ^ (ℓ + 𝓡 - ↑i) - 2 ^ (ℓ - ↑i) + 1 > 0\n have h_exp_lt : ℓ - i.val < ℓ + 𝓡 - i.val := by\n exact Nat.sub_lt_sub_right (a := ℓ) (b := ℓ + 𝓡) (c := i.val) (by omega) (by\n apply Nat.lt_add_of_pos_right; exact pos_of_neZero 𝓡)\n have h_pow_lt : 2 ^ (ℓ - i.val) < 2 ^ (ℓ + 𝓡 - i.val) := by\n exact Nat.pow_lt_pow_right (by norm_num) h_exp_lt\n omega\n\n have h_C_i_nonempty : Nonempty C_i := by\n simp only [nonempty_subtype, C_i]\n exact Submodule.nonempty (BBF_Code 𝔽q β (h_ℓ_add_R_rate := h_ℓ_add_R_rate) ⟨i.val, by omega⟩)\n\n -- 1. Relate Hamming distance `d_H` to fiber-wise distance `d_fw`.\n obtain ⟨g', h_g'_mem, h_g'_min_card⟩ : ∃ g' ∈ C_i, d_fw\n = (fiberwiseDisagreementSet 𝔽q β i steps h_i_add_steps f g').ncard := by\n -- Let `S` be the set of all possible fiber-wise disagreement sizes.\n let S := (fun (g : C_i) => (fiberwiseDisagreementSet 𝔽q β i steps h_i_add_steps\n f g).ncard) '' Set.univ\n -- The code `C_i` (a submodule) is non-empty, so `S` is also non-empty.\n have hS_nonempty : S.Nonempty := by\n refine Set.image_nonempty.mpr ?_\n\n exact Set.univ_nonempty\n -- For a non-empty set of natural numbers, `sInf` is an element of the set.\n have h_sInf_mem : sInf S ∈ S := Nat.sInf_mem hS_nonempty\n -- By definition, `d_fw = sInf S`.\n unfold d_fw at h_sInf_mem\n -- Since `sInf S` is in the image set `S`, there must be an element `g_subtype` in the domain\n -- (`C_i`) that maps to it. This `g_subtype` is the codeword we're looking for.\n rw [Set.mem_image] at h_sInf_mem\n rcases h_sInf_mem with ⟨g_subtype, _, h_eq⟩\n -- Extract the codeword and its membership proof.\n exact ⟨g_subtype.val, g_subtype.property, by exact id (Eq.symm h_eq)⟩\n\n -- The Hamming distance to any codeword `g'` is bounded by `d_fw * 2 ^ steps`.\n have h_dist_le_fw_dist_times_fiber_size : (hammingDist f g' : ℕ∞) ≤ d_fw * 2 ^ steps := by\n -- This proves `dist f g' ≤ (fiberwiseDisagreementSet ... f g').ncard * 2 ^ steps`\n -- and lifts to ℕ∞. We prove the `Nat` version `hammingDist f g' ≤ ...`,\n -- which is equivalent.\n change (Δ₀(f, g') : ℕ∞) ≤ ↑d_fw * ((2 ^ steps : ℕ) : ℕ∞)\n rw [←ENat.coe_mul, ENat.coe_le_coe, h_g'_min_card]\n -- Let ΔH be the finset of actually bad x points where f and g' disagree.\n set ΔH := Finset.filter (fun x => f x ≠ g' x) Finset.univ\n have h_dist_eq_card : hammingDist f g' = ΔH.card := by\n simp only [hammingDist, ne_eq, ΔH]\n rw [h_dist_eq_card]\n -- Y_bad is the set of quotient points y that THERE EXISTS a bad fiber point x\n set Y_bad := fiberwiseDisagreementSet 𝔽q β i steps h_i_add_steps f g'\n simp only at * -- simplify domain indices everywhere\n\n -- ⊢ #ΔH ≤ Y_bad.ncard * 2 ^ steps\n\n have hFinType_Y_bad : Fintype Y_bad := by exact Fintype.ofFinite ↑Y_bad\n -- Every point of disagreement `x` must belong to a fiber over some `y` in `Y_bad`,\n -- BY DEFINITION of `Y_bad`. Therefore, `ΔH` is a subset of the union of the fibers\n -- of `Y_bad`\n have h_ΔH_subset_bad_fiber_points : ΔH ⊆ Finset.biUnion Y_bad.toFinset\n (t := fun y => ((qMap_total_fiber 𝔽q β (i := ⟨i, by omega⟩) (steps := steps)\n (h_i_add_steps := by apply Nat.lt_add_of_pos_right_of_le; omega) (y := y)) ''\n (Finset.univ : Finset (Fin ((2:ℕ)^steps)))).toFinset) := by\n -- ⊢ If any x ∈ ΔH, then x ∈ Union(qMap_total_fiber(y), ∀ y ∈ Y_bad)\n intro x hx_in_ΔH; -- ⊢ x ∈ Union(qMap_total_fiber(y), ∀ y ∈ Y_bad)\n simp only [ΔH, Finset.mem_filter] at hx_in_ΔH\n -- Now we actually apply iterated qMap into x to get y_of_x,\n -- then x ∈ qMap_total_fiber(y_of_x) by definition\n let y_of_x := iteratedQuotientMap 𝔽q β h_ℓ_add_R_rate i steps h_i_add_steps x\n apply Finset.mem_biUnion.mpr; use y_of_x\n -- ⊢ y_of_x ∈ Y_bad.toFinset ∧ x ∈ qMap_total_fiber(y_of_x)\n have h_elemenet_Y_bad : y_of_x ∈ Y_bad.toFinset := by\n -- ⊢ y ∈ Y_bad.toFinset\n simp only [fiberwiseDisagreementSet, iteratedQuotientMap, ne_eq, Subtype.exists,\n Set.toFinset_setOf, mem_filter, mem_univ, true_and, Y_bad]\n -- one bad fiber point of y_of_x is x itself\n let X := x.val\n have h_X_in_source : X ∈ sDomain 𝔽q β h_ℓ_add_R_rate (i := ⟨i, by omega⟩) := by\n exact Submodule.coe_mem x\n use X\n use h_X_in_source\n -- ⊢ Ŵ_steps⁽ⁱ⁾(X) = y (iterated quotient map) ∧ ¬f ⟨X, ⋯⟩ = g' ⟨X, ⋯⟩\n have h_forward_iterated_qmap : Polynomial.eval X\n (intermediateNormVpoly 𝔽q β h_ℓ_add_R_rate ⟨↑i, by omega⟩\n ⟨steps, by simp only; omega⟩) = y_of_x := by\n simp only [iteratedQuotientMap, X, y_of_x];\n have h_eval_diff : f ⟨X, by omega⟩ ≠ g' ⟨X, by omega⟩ := by\n unfold X\n simp only [Subtype.coe_eta, ne_eq, hx_in_ΔH, not_false_eq_true]\n simp only [h_forward_iterated_qmap, Subtype.coe_eta, h_eval_diff,\n not_false_eq_true, and_self]\n simp only [h_elemenet_Y_bad, true_and]\n\n set qMapFiber := qMap_total_fiber 𝔽q β (i := ⟨i, by omega⟩) (steps := steps)\n (h_i_add_steps := by apply Nat.lt_add_of_pos_right_of_le; omega) (y := y_of_x)\n simp only [coe_univ, Set.image_univ, Set.toFinset_range, mem_image, mem_univ, true_and]\n use (pointToIterateQuotientIndex (i := ⟨i, by omega⟩) (steps := steps)\n (h_i_add_steps := by omega) (x := x))\n have h_res := is_fiber_iff_generates_quotient_point 𝔽q β i steps (by omega)\n (x := x) (y := y_of_x).mp (by rfl)\n exact h_res\n -- ⊢ #ΔH ≤ Y_bad.ncard * 2 ^ steps\n -- The cardinality of a subset is at most the cardinality of the superset.\n apply (Finset.card_le_card h_ΔH_subset_bad_fiber_points).trans\n -- The cardinality of a disjoint union is the sum of cardinalities.\n rw [Finset.card_biUnion]\n · -- The size of the sum is the number of bad fibers (`Y_bad.ncard`) times\n -- the size of each fiber (`2 ^ steps`).\n simp only [Set.toFinset_card]\n have h_card_fiber_per_quotient_point := card_qMap_total_fiber 𝔽q β\n (h_ℓ_add_R_rate := h_ℓ_add_R_rate) i steps h_i_add_steps\n simp only [Set.image_univ, Fintype.card_ofFinset,\n Subtype.forall] at h_card_fiber_per_quotient_point\n have h_card_fiber_of_each_y : ∀ y ∈ Y_bad.toFinset,\n Fintype.card ((qMap_total_fiber 𝔽q β (i := ⟨↑i, by omega⟩) (steps := steps)\n (h_i_add_steps := by apply Nat.lt_add_of_pos_right_of_le; omega) (y := y)) ''\n ↑(Finset.univ : Finset (Fin ((2:ℕ)^steps)))) = 2 ^ steps := by\n intro y hy_in_Y_bad\n have hy_card_fiber_of_y := h_card_fiber_per_quotient_point (a := y) (b := by\n exact Submodule.coe_mem y)\n simp only [coe_univ, Set.image_univ, Fintype.card_ofFinset, hy_card_fiber_of_y]\n rw [Finset.sum_congr rfl h_card_fiber_of_each_y]\n -- ⊢ ∑ x ∈ Y_bad.toFinset, 2 ^ steps ≤ Y_bad.encard.toNat * 2 ^ steps\n simp only [sum_const, Set.toFinset_card, smul_eq_mul, ofNat_pos, pow_pos,\n _root_.mul_le_mul_right, ge_iff_le]\n conv_rhs => rw [←_root_.Nat.card_coe_set_eq] -- convert .ncard back to .card\n -- ⊢ Fintype.card ↑Y_bad ≤ Nat.card ↑Y_bad\n simp only [card_eq_fintype_card, le_refl]\n · -- Prove that the fibers for distinct quotient points y₁, y₂ are disjoint.\n intro y₁ hy₁ y₂ hy₂ hy_ne\n have h_disjoint := qMap_total_fiber_disjoint (i := ⟨↑i, by omega⟩) (steps := steps)\n (h_i_add_steps := by omega) (y₁ := y₁) (y₂ := y₂) (hy_ne := hy_ne)\n simp only [Function.onFun, coe_univ]\n exact h_disjoint\n\n -- The minimum distance `d_H` is bounded by the distance to this specific `g'`.\n have h_dist_bridge : d_H ≤ d_fw * 2 ^ steps := by\n -- exact h_dist_le_fw_dist_times_fiber_size\n apply le_trans (a := d_H) (c := d_fw * 2 ^ steps) (b := hammingDist f g')\n · -- ⊢ d_H ≤ ↑Δ₀(f, g')\n simp only [distFromCode, SetLike.mem_coe, hammingDist, ne_eq, d_H];\n -- ⊢ Δ₀(f, C_i) ≤ ↑Δ₀(f, g')\n -- ⊢ sInf {d | ∃ v ∈ C_i, ↑(#{i | f i ≠ v i}) ≤ d} ≤ ↑(#{i | f i ≠ g' i})\n apply sInf_le\n use g'\n · exact h_dist_le_fw_dist_times_fiber_size\n\n -- 2. Use the premise : `2 * d_fw < d_{i+steps}`.\n -- As a `Nat` inequality, this is equivalent to `2 * d_fw ≤ d_{i+steps} - 1`.\n have h_fw_bound : 2 * d_fw ≤ d_i_plus_steps - 1 := by\n -- Convert the ENat inequality to a Nat inequality using `a < b ↔ a + 1 ≤ b`.\n exact Nat.le_of_lt_succ (WithTop.coe_lt_coe.1 h_fw_dist_lt)\n\n -- 3. The Algebraic Identity.\n -- The core of the proof is the identity : `(d_{i+steps} - 1) * 2 ^ steps = d_i - 1`.\n have h_algebraic_identity : (d_i_plus_steps - 1) * 2 ^ steps = d_i - 1 := by\n dsimp [d_i, d_i_plus_steps, BBF_CodeDistance]\n rw [Nat.sub_mul, ←Nat.pow_add, ←Nat.pow_add];\n have h1 : ℓ + 𝓡 - (↑i + steps) + steps = ℓ + 𝓡 - i := by\n rw [Nat.sub_add_eq_sub_sub_rev (h1 := by omega) (h2 := by omega),\n Nat.add_sub_cancel (n := i) (m := steps)]\n have h2 : (ℓ - (↑i + steps) + steps) = ℓ - i := by\n rw [Nat.sub_add_eq_sub_sub_rev (h1 := by omega) (h2 := by omega),\n Nat.add_sub_cancel (n := i) (m := steps)]\n rw [h1, h2]\n\n -- 4. Conclusion : Chain the inequalities to prove `2 * d_H < d_i`.\n -- We know `d_H` is finite, since `C_i` is nonempty.\n have h_dH_ne_top : d_H ≠ ⊤ := by\n simp only [ne_eq, d_H]\n rw [Code.distFromCode_eq_top_iff_empty f C_i]\n exact Set.nonempty_iff_ne_empty'.mp h_C_i_nonempty\n\n -- We can now work with the `Nat` value of `d_H`.\n let d_H_nat := ENat.toNat d_H\n have h_dH_eq : d_H = d_H_nat := (ENat.coe_toNat h_dH_ne_top).symm\n\n -- The calculation is now done entirely in `Nat`.\n have h_final_inequality : 2 * d_H_nat ≤ d_i - 1 := by\n have h_bridge_nat : d_H_nat ≤ d_fw * 2 ^ steps := by\n rw [←ENat.coe_le_coe]\n exact le_of_eq_of_le (id (Eq.symm h_dH_eq)) h_dist_bridge\n calc 2 * d_H_nat\n _ ≤ 2 * (d_fw * 2 ^ steps) := by gcongr\n _ = (2 * d_fw) * 2 ^ steps := by rw [mul_assoc]\n _ ≤ (d_i_plus_steps - 1) * 2 ^ steps := by gcongr;\n _ = d_i - 1 := h_algebraic_identity\n\n simp only [d_H, d_H_nat] at h_dH_eq\n -- This final line is equivalent to the goal statement.\n rw [h_dH_eq]\n -- ⊢ 2 * ↑Δ₀(f, C_i).toNat < ↑(BBF_CodeDistance ℓ 𝓡 ⟨↑i, ⋯⟩)\n change ((2 : ℕ) : ℕ∞) * ↑Δ₀(f, C_i).toNat < ↑(BBF_CodeDistance ℓ 𝓡 ⟨↑i, by omega⟩)\n rw [←ENat.coe_mul, ENat.coe_lt_coe]\n apply Nat.lt_of_le_pred (n := 2 * Δ₀(f, C_i).toNat) (m := d_i) (h := h_d_i_gt_0)\n (h_final_inequality)", "proof_length": 1463, "num_lines": 209, "header": "", "file_path": "ArkLib/ProofSystem/Binius/BinaryBasefold/Prelude.lean", "url": "https://github.com/Verified-zkEVM/ArkLib", "start_line": 1265, "end_line": 1473, "version_info": [{"v4.31.0": "c1712f6c496d0aef04f09bae42aec13811b3273f"}, {"v4.30.0": "e6d77b18ca1334a91faf4d1ccf9f96d854d58ba4"}, {"v4.29.0": "de71a9dfd2f5a343e8895517b7efe857d9f1ce5c"}, {"v4.28.0": "673fa440714eb1949b8b50a28f2a4f52b1837e9b"}]} {"name": "Binius.BinaryBasefold.fold_advances_evaluation_poly", "source": "arklib", "statement": "theorem fold_advances_evaluation_poly\n (i : Fin (ℓ)) (h_i_succ_lt : i + 1 < ℓ + 𝓡)\n (coeffs : Fin (2 ^ (ℓ - ↑i)) → L) (r_chal : L) :\n let P_i : L[X] := intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i, by\n exact Nat.lt_trans (n := i) (k := ℓ+1) (m := ℓ) (h₁ := i.isLt) (by exact Nat.lt_add_one ℓ)\n ⟩) coeffs\n let f_i := fun (x : (sDomain 𝔽q β h_ℓ_add_R_rate)\n ⟨i, by exact Nat.lt_trans (n := i) (k := r) (m := ℓ) (h₁ := by omega) (by omega)⟩) =>\n P_i.eval (x.val : L)\n let f_i_plus_1 := fold (i := ⟨i, by omega⟩) (h_i := by omega) (f := f_i) (r_chal := r_chal)\n let new_coeffs := fun j : Fin (2^(ℓ - (i + 1))) =>\n (1 - r_chal) * (coeffs ⟨j.val * 2, by\n rw [←Nat.add_zero (j.val * 2)]\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 0) (by omega) (by omega)\n ⟩) +\n r_chal * (coeffs ⟨j.val * 2 + 1, by\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 1) (by omega) (by omega)\n ⟩)\n let P_i_plus_1 :=\n intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i+1, by omega⟩) new_coeffs\n ∀ (y : (sDomain 𝔽q β h_ℓ_add_R_rate)\n ⟨i+1, by omega⟩), f_i_plus_1 y = P_i_plus_1.eval y.val", "src": "theorem fold_advances_evaluation_poly\n (i : Fin (ℓ)) (h_i_succ_lt : i + 1 < ℓ + 𝓡)\n (coeffs : Fin (2 ^ (ℓ - ↑i)) → L) (r_chal : L) :\n let P_i : L[X] := intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i, by\n exact Nat.lt_trans (n := i) (k := ℓ+1) (m := ℓ) (h₁ := i.isLt) (by exact Nat.lt_add_one ℓ)\n ⟩) coeffs\n let f_i := fun (x : (sDomain 𝔽q β h_ℓ_add_R_rate)\n ⟨i, by exact Nat.lt_trans (n := i) (k := r) (m := ℓ) (h₁ := by omega) (by omega)⟩) =>\n P_i.eval (x.val : L)\n let f_i_plus_1 := fold (i := ⟨i, by omega⟩) (h_i := by omega) (f := f_i) (r_chal := r_chal)\n let new_coeffs := fun j : Fin (2^(ℓ - (i + 1))) =>\n (1 - r_chal) * (coeffs ⟨j.val * 2, by\n rw [←Nat.add_zero (j.val * 2)]\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 0) (by omega) (by omega)\n ⟩) +\n r_chal * (coeffs ⟨j.val * 2 + 1, by\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 1) (by omega) (by omega)\n ⟩)\n let P_i_plus_1 :=\n intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i+1, by omega⟩) new_coeffs\n ∀ (y : (sDomain 𝔽q β h_ℓ_add_R_rate)\n ⟨i+1, by omega⟩), f_i_plus_1 y = P_i_plus_1.eval y.val := by\n simp only\n intro y\n set fiberMap := qMap_total_fiber 𝔽q β (i := ⟨i, by omega⟩) (steps := 1)\n (h_i_add_steps := by simp only; omega) (y := y)\n set x₀ := fiberMap 0\n set x₁ := fiberMap 1\n set P_i := intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i, by omega⟩) coeffs\n set new_coeffs := fun j : Fin (2^(ℓ - (i + 1))) =>\n (1 - r_chal) * (coeffs ⟨j.val * 2, by\n have h : j.val * 2 < 2^(ℓ - (i + 1)) * 2 := by omega\n have h2 : 2^(ℓ - i) = 2^(ℓ - (i + 1)) * 2 := by\n conv_rhs => enter[2]; rw [←Nat.pow_one 2]\n rw [←pow_add]; congr\n rw [Nat.sub_add_eq_sub_sub_rev (h1 := by omega) (h2 := by omega)]\n -- ⊢ ℓ - ↑i = ℓ - (↑i + 1 - 1)\n rw [Nat.add_sub_cancel (n := i) (m := 1)]\n omega\n ⟩) +\n r_chal * (coeffs ⟨j.val * 2 + 1, by\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1)) (i := 1)\n · omega\n · omega\n ⟩)\n have h_eval_qMap_x₀ : (AdditiveNTT.qMap 𝔽q β ⟨i, by omega⟩).eval x₀.val = y := by\n have h := iteratedQuotientMap_k_eq_1_is_qMap 𝔽q β h_ℓ_add_R_rate i (by omega) x₀\n simp only [Subtype.eq_iff] at h\n rw [h.symm]\n have h_res := is_fiber_iff_generates_quotient_point 𝔽q β i (steps := 1) (by omega)\n (x := x₀) (y := y).mpr (by rw [pointToIterateQuotientIndex_qMap_total_fiber_eq_self])\n rw [h_res]\n -- exact qMap_eval_fiber_eq_self ⟦L⟧ ⟨i + 1, by omega⟩ (by simp only; omega) h_i_succ_lt y 0\n have h_eval_qMap_x₁ : (AdditiveNTT.qMap 𝔽q β ⟨i, by omega⟩).eval x₁.val = y := by\n have h := iteratedQuotientMap_k_eq_1_is_qMap 𝔽q β h_ℓ_add_R_rate i (by omega) x₁\n simp only [Subtype.eq_iff] at h\n rw [h.symm]\n have h_res := is_fiber_iff_generates_quotient_point 𝔽q β i (steps := 1) (by omega)\n (x := x₁) (y := y).mpr (by rw [pointToIterateQuotientIndex_qMap_total_fiber_eq_self])\n rw [h_res]\n have hx₀ := qMap_total_fiber_basis_sum_repr 𝔽q β i (steps := 1)\n (h_i_add_steps := by omega) y 0\n have hx₁ := qMap_total_fiber_basis_sum_repr 𝔽q β i (steps := 1)\n (h_i_add_steps := by omega) y 1\n simp only [Fin.isValue] at hx₀ hx₁\n\n have h_fiber_diff : x₁.val - x₀.val = 1 := by\n simp only [Fin.isValue, x₁, x₀, fiberMap]\n rw [hx₁, hx₀]\n simp only [Fin.isValue, AddSubmonoidClass.coe_finset_sum, SetLike.val_smul]\n have h_index : ℓ + 𝓡 - i = (ℓ + 𝓡 - (i.val + 1)) + 1 := by omega\n rw! (castMode := .all) [h_index]\n rw [Fin.sum_univ_succ, Fin.sum_univ_succ] -- (free_term + y_repr) - (free_term + y_repr) = 1\n -- First, simplify the free terms\n simp only [fiber_coeff, eqRec_eq_cast, lt_one_iff, reducePow, Fin.isValue,\n Fin.coe_ofNat_eq_mod, mod_succ, dite_smul, ite_smul, zero_smul, one_smul, zero_mod]\n have h_cast_0 :\n (cast (Eq.symm h_index ▸ rfl : Fin (ℓ + 𝓡 - (↑i + 1) + 1) = Fin (ℓ + 𝓡 - ↑i)) 0).val =\n 0 := by\n rw [←Fin.cast_eq_cast (h := by omega)]\n rw [Fin.cast_val_eq_val (h_eq := by omega)]\n simp only [Fin.coe_ofNat_eq_mod, mod_succ_eq_iff_lt, succ_eq_add_one, lt_add_iff_pos_left]\n omega\n have h_cast_1 :\n (cast (Eq.symm h_index ▸ rfl : Fin (ℓ + 𝓡 - (↑i + 1) + 1) = Fin (ℓ + 𝓡 - ↑i)) 1).val =\n 1 := by\n rw [←Fin.cast_eq_cast (h := by omega)]\n rw [Fin.cast_val_eq_val (h_eq := by omega)]\n simp only [Fin.coe_ofNat_eq_mod, mod_succ_eq_iff_lt, succ_eq_add_one,\n lt_add_iff_pos_left, tsub_pos_iff_lt]\n omega\n simp only [h_cast_0, ↓reduceDIte]\n have h_getBit_0_of_0 : Nat.getBit (k := 0) (n := 0) = 0 := by\n simp only [getBit, shiftRight_zero, and_one_is_mod, zero_mod]\n have h_getBit_0_of_1 : Nat.getBit (k := 0) (n := 1) = 1 := by\n simp only [getBit, shiftRight_zero, Nat.and_self]\n simp only [h_getBit_0_of_1, one_ne_zero, ↓reduceIte, h_getBit_0_of_0, zero_add]\n rw! (castMode := .all) [←h_index]\n rw [cast_eq]\n simp only [get_sDomain_basis, Fin.coe_ofNat_eq_mod, zero_mod, add_zero, cast_eq]\n rw [normalizedWᵢ_eval_βᵢ_eq_1 𝔽q β]\n ring_nf\n conv_rhs => rw [←add_zero (a := 1)]\n rw [add_sub_assoc]\n congr 1\n rw [sub_eq_zero]\n apply Finset.sum_congr (h := by rfl)\n simp only [mem_univ, congr_eqRec, Fin.val_succ, Nat.add_eq_zero, one_ne_zero, and_false,\n ↓reduceDIte, add_tsub_cancel_right, Fin.eta, imp_self, implies_true]\n set P_i_plus_1 :=\n intermediateEvaluationPoly 𝔽q β h_ℓ_add_R_rate (i := ⟨i+1, by omega⟩) new_coeffs\n -- Set up the even and odd refinement polynomials\n set P₀_coeffs := fun j : Fin (2^(ℓ - (i + 1))) => coeffs ⟨j.val * 2, by\n have h1 : ℓ - (i + 1) + 1 = ℓ - i := by omega\n have h2 : 2^(ℓ - (i + 1) + 1) = 2^(ℓ - i) := by rw [h1]\n have h3 : 2^(ℓ - (i + 1)) * 2 = 2^(ℓ - (i + 1) + 1) := by rw [pow_succ]\n rw [← h2, ← h3]; omega⟩\n set P₁_coeffs := fun j : Fin (2^(ℓ - (i + 1))) => coeffs ⟨j.val * 2 + 1, by\n have h1 : ℓ - (i + 1) + 1 = ℓ - i := by omega\n have h2 : 2^(ℓ - (i + 1) + 1) = 2^(ℓ - i) := by rw [h1]\n have h3 : 2^(ℓ - (i + 1)) * 2 = 2^(ℓ - (i + 1) + 1) := by rw [pow_succ]\n rw [← h2, ← h3]; omega⟩\n set P₀ := evenRefinement 𝔽q β h_ℓ_add_R_rate i coeffs\n set P₁ := oddRefinement 𝔽q β h_ℓ_add_R_rate i coeffs\n have h_P_i_eval := evaluation_poly_split_identity 𝔽q β h_ℓ_add_R_rate ⟨i, by omega⟩ coeffs\n -- Equation 39 : P^(i)(X) = P₀^(i+1)(q^(i)(X)) + X · P₁^(i+1)(q^(i)(X))\n have h_equation_39_x₀ : P_i.eval x₀.val = P₀.eval y.val + x₀.val * P₁.eval y.val := by\n simp only [h_P_i_eval, Fin.eta, Polynomial.eval_add, eval_comp,\n h_eval_qMap_x₀, Polynomial.eval_mul, Polynomial.eval_X, P_i, P₀, P₁]\n have h_equation_39_x₁ : P_i.eval x₁.val = P₀.eval y.val + x₁.val * P₁.eval y.val := by\n simp only [h_P_i_eval, Fin.eta, Polynomial.eval_add, eval_comp,\n h_eval_qMap_x₁, Polynomial.eval_mul, Polynomial.eval_X, P_i, P₀, P₁]\n set f_i := fun (x : (sDomain 𝔽q β h_ℓ_add_R_rate) ⟨i, by omega⟩) => P_i.eval (x.val : L)\n set f_i_plus_1 := fold (i := ⟨i, by omega⟩) (h_i := by omega) (f := f_i) (r_chal := r_chal)\n -- Unfold the definition of f_i_plus_1 using the fold function\n have h_fold_def : f_i_plus_1 y =\n f_i x₀ * ((1 - r_chal) * x₁.val - r_chal) +\n f_i x₁ * (r_chal - (1 - r_chal) * x₀.val) := rfl\n -- Main calculation following the outline\n calc f_i_plus_1 y\n = f_i x₀ * ((1 - r_chal) * x₁.val - r_chal) +\n f_i x₁ * (r_chal - (1 - r_chal) * x₀.val) := h_fold_def\n _ = P_i.eval x₀.val * ((1 - r_chal) * x₁.val - r_chal) +\n P_i.eval x₁.val * (r_chal - (1 - r_chal) * x₀.val) := by simp only [f_i]\n _ = (P₀.eval y.val + x₀.val * P₁.eval y.val) * ((1 - r_chal) * x₁.val - r_chal) +\n (P₀.eval y.val + x₁.val * P₁.eval y.val) * (r_chal - (1 - r_chal) * x₀.val) := by\n rw [h_equation_39_x₀, h_equation_39_x₁]\n _ = P₀.eval y.val * ((1 - r_chal) * x₁.val - r_chal + r_chal - (1 - r_chal) * x₀.val) +\n P₁.eval y.val * (x₀.val * ((1 - r_chal) * x₁.val - r_chal) +\n x₁.val * (r_chal - (1 - r_chal) * x₀.val)) := by ring\n _ = P₀.eval y.val * ((1 - r_chal) * (x₁.val - x₀.val)) +\n P₁.eval y.val * ((x₁.val - x₀.val) * r_chal) := by ring\n _ = P₀.eval y.val * (1 - r_chal) + P₁.eval y.val * r_chal := by rw [h_fiber_diff]; ring\n _ = P_i_plus_1.eval y.val := by\n simp only [P_i_plus_1, P₀, P₁, new_coeffs, evenRefinement, oddRefinement,\n intermediateEvaluationPoly]\n conv_lhs => enter [1]; rw [mul_comm, ←Polynomial.eval_C_mul]\n conv_lhs => enter [2]; rw [mul_comm, ←Polynomial.eval_C_mul]\n -- ⊢ eval y (C (1-r) * ∑...) + eval y (C r * ∑...) = eval y (∑...)\n rw [←Polynomial.eval_add]\n -- ⊢ poly_left.eval y = poly_right.eval y\n congr\n simp_rw [mul_sum, ←Finset.sum_add_distrib]\n -- We now prove that the terms inside the sums are equal for each index.\n apply Finset.sum_congr rfl\n intro j hj\n have h_j_lt : j.val < 2 ^ (ℓ - (↑i + 1)) := by\n rw [Nat.sub_add_eq]\n omega\n conv_lhs => enter [1]; rw [mul_comm (a := Polynomial.C (coeffs ⟨j.val * 2, by\n rw [←Nat.add_zero (j.val * 2)]\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 0) (by omega) (by omega)⟩)), ←mul_assoc,\n mul_comm (a := Polynomial.C (1 - r_chal))]; rw [mul_assoc]\n conv_lhs => enter [2]; rw [mul_comm (a := Polynomial.C (coeffs ⟨j.val * 2 + 1, by\n apply mul_two_add_bit_lt_two_pow (c := ℓ - i) (a := j) (b := ℓ - (↑i + 1))\n (i := 1) (by omega) (by omega)⟩)), ←mul_assoc,\n mul_comm (a := Polynomial.C r_chal)]; rw [mul_assoc]\n conv_rhs => rw [mul_comm]\n rw [←mul_add]\n congr\n simp only [←Polynomial.C_mul, ←Polynomial.C_add]", "proof_length": 1906, "num_lines": 184, "header": "", "file_path": "ArkLib/ProofSystem/Binius/BinaryBasefold/Prelude.lean", "url": "https://github.com/Verified-zkEVM/ArkLib", "start_line": 815, "end_line": 998, "version_info": [{"v4.31.0": "c1712f6c496d0aef04f09bae42aec13811b3273f"}, {"v4.30.0": "e6d77b18ca1334a91faf4d1ccf9f96d854d58ba4"}, {"v4.29.0": "de71a9dfd2f5a343e8895517b7efe857d9f1ce5c"}]} {"name": "interleaved_affine_gaps_imply_tensor_gaps", "source": "arklib", "statement": "theorem interleaved_affine_gaps_imply_tensor_gaps\n (hC_proximityGapAffineLines : e_ε_correlatedAgreementAffineLinesNat\n (F := F) (A := A) (ι := ι) (C := MC) (e := e) (ε := ε))\n (h_interleaved_gaps : ∀ m : ℕ, m ≥ 1 →\n e_ε_correlatedAgreementAffineLinesNat (F := F)\n (A := InterleavedSymbol A (Fin m)) (ι := ι) (C := MC ^⋈ (Fin m)) e ε) :\n ∀ (ϑ : ℕ), (hϑ_gt_0 : ϑ > 0) → δ_ε_multilinearCorrelatedAgreement_Nat (F := F) (A := A)\n (ι := ι) (C := MC) (ϑ := ϑ) (e := e) (ε := ε)", "src": "theorem interleaved_affine_gaps_imply_tensor_gaps\n (hC_proximityGapAffineLines : e_ε_correlatedAgreementAffineLinesNat\n (F := F) (A := A) (ι := ι) (C := MC) (e := e) (ε := ε))\n (h_interleaved_gaps : ∀ m : ℕ, m ≥ 1 →\n e_ε_correlatedAgreementAffineLinesNat (F := F)\n (A := InterleavedSymbol A (Fin m)) (ι := ι) (C := MC ^⋈ (Fin m)) e ε) :\n ∀ (ϑ : ℕ), (hϑ_gt_0 : ϑ > 0) → δ_ε_multilinearCorrelatedAgreement_Nat (F := F) (A := A)\n (ι := ι) (C := MC) (ϑ := ϑ) (e := e) (ε := ε) := by\n classical\n intro ϑ\n induction ϑ with\n | zero =>\n intro u\n contradiction\n | succ ϑ_sub_1 ih =>\n cases ϑ_sub_1 with\n | zero =>\n -- `ϑ = 1`\n simp only [zero_add, gt_iff_lt, zero_lt_one, ModuleCode, forall_const]\n intro u\n let toAffineLineEval := multilinearCombine₁_eq_affineLineEvaluation (F := F) (u := u)\n intro hprob_gt\n simp_rw [toAffineLineEval] at hprob_gt\n let prob_eq := prob_uniform_singleton_finFun_eq (F := F)\n (P := fun r => Δ₀(affineLineEvaluation (u 0) (u 1) r, MC) ≤ e)\n -- Convert sampling (r ← (Fin 1 → F)) into sampling (r ← F)\n simp_rw [prob_eq, Nat.cast_one, ENNReal.coe_one, one_mul] at hprob_gt\n have h_correlated_agreement := hC_proximityGapAffineLines (u 0) (u 1) hprob_gt\n simp only [jointProximityNat₂, Fin.isValue] at h_correlated_agreement\n have h_u_eq: u = finMapTwoWords (u 0) (u 1) := by\n funext rowIdx\n match rowIdx with\n | 0 => rfl\n | 1 => rfl\n rw [h_u_eq.symm] at h_correlated_agreement\n exact h_correlated_agreement\n | succ ϑ_sub_2 =>\n intro hϑ_gt_0 u hP_multilinearCombine_close_gt\n -- `ϑ ≥ 2`\n -- set ϑ_sub_1 := ϑ_sub_2 + 1\n let ϑ := ϑ_sub_2 + 1 + 1\n have hϑ : ϑ = ϑ_sub_2 + 1 + 1 := by rfl\n -- have hfinϑ : Fin ϑ = Fin (ϑ_sub_2 + 1 + 1) := by rfl\n set U₀ : Fin (2 ^ (ϑ_sub_2 + 1)) → Word A ι :=\n (splitHalfRowWiseInterleavedWords (ϑ := ϑ_sub_2 + 1) u).1\n set U₁ : Fin (2 ^ (ϑ_sub_2 + 1)) → Word A ι :=\n (splitHalfRowWiseInterleavedWords (ϑ := ϑ_sub_2 + 1) u).2\n unfold jointProximityNat\n simp only\n -- intro hP_multilinearCombine_close_gt\n have h_finsnoc_eq_r: ∀ r: Fin (ϑ_sub_2 + 1 + 1) → F,\n Fin.snoc (fun (i : Fin (ϑ_sub_2 + 1)) ↦ r i.castSucc)\n (r (Fin.last (ϑ_sub_2 + 1))) = r := fun r => by\n funext i\n have hi_le_lt := i.isLt\n by_cases h : i = Fin.last (ϑ_sub_2 + 1)\n · simp only [h, Fin.snoc_last]\n · have h_i_ne_last: i ≠ Fin.last (ϑ_sub_2 + 1) := by omega\n have h_i_ne_last_val: i.val ≠ Fin.last (ϑ_sub_2 + 1) := by omega\n rw [Fin.val_last] at h_i_ne_last_val\n have h_i_lt: i.val < (ϑ_sub_2 + 1) := by omega\n simp only [Fin.snoc, Fin.castSucc_castLT, cast_eq, dite_eq_ite, ite_eq_left_iff, not_lt]\n simp only [isEmpty_Prop, not_le, h_i_lt, IsEmpty.forall_iff]\n let P : F → (Fin (ϑ_sub_2 + 1) → F) → Prop := fun r_last r_init =>\n Δ₀(multilinearCombine (u:=u) (r:=Fin.snoc r_init r_last), MC) ≤ e\n let hP_split_r_last := prob_split_last_uniform_sampling_of_finFun\n (ϑ := ϑ_sub_2 + 1) (F := F) (P := P)\n unfold P at hP_split_r_last\n simp_rw [h_finsnoc_eq_r] at hP_split_r_last\n rw [hP_split_r_last] at hP_multilinearCombine_close_gt\n -- Now we have two randomness sampling in hP_multilinearCombine_close_gt :\n -- `((ϑ_sub_2 + 1 + 1) * ε) / |𝔽|\n -- < Pr_{ r_last; r_init }[ Δ₀((Fin.snoc r_init r_last)|⨂|u, ↑MC) ≤ ↑e)) ]` (0)\n -- We need to achieve the upperbound for hP_multilinearCombine_close_gt probability by:\n -- i.e. `Pr_{ r_last; r_init }[ Δ₀((Fin.snoc r_init r_last)|⨂|u, ↑MC) ≤ ↑e)) ]`\n -- `= Pr_{ r_last; r_init }[ Δ₀((r_init)|⨂|affineCombine(U₀, U₁, r_last), ↑MC) ≤ ↑e)) ]`\n -- `= PR_{ r_last }[ r_init; Δ₀((r_init)|⨂|affineCombine(U₀, U₁, r_last), ↑MC) ≤ ↑e)) ]`\n -- Divide into two cases: r_last ∈ R* and r_last ∉ R*\n -- `= Pr_{ r_last }[ r_last ∈ R* ∧\n -- Pr_{ r_init }[ Δ₀((r_init)|⨂|affineCombine(U₀, U₁, r_last), ↑MC) ≤ ↑e)) ]` (1)\n -- `+ Pr_{ r_last }[ r_last ∉ R* ∧\n -- Pr_{ r_init }[ Δ₀((r_init)|⨂|affineCombine(U₀, U₁, r_last), ↑MC) ≤ ↑e)) ]` (2)\n -- `(1) = Pr_{ r_last }[ r_last ∈ R* ]` (3)\n -- `(2): ∀ r ∉ R*, it's trivial that the probability\n -- ≤ ((ϑ_sub_2 + 1) * ε) / |𝔽|, due to definition of membership of R*` (4)\n\n -- Combine (0), (3), (4): we have `Pr_{ r_last }[ r_last ∈ R* ] > ε/|𝔽|` (5)\n\n -- Applying `correlatedAgreement_of_mem_R_star_tensor` to (5), we get\n -- `Δ₀((r_last)|⨂|affineCombine(U₀, U₁, r_last), ↑MC) ≤ ↑e)) ] > ε/|𝔽|` (6)\n -- This is premise for affineProxmityGaps of interleaved code (`h_interleaved_gaps`)\n -- for `m = 2^{ϑ_sub_2 + 1}`, which directly leads to Q.E.D.\n let ϑ_pred := ϑ_sub_2 + 1\n have h_ϑ_pred : ϑ_pred = ϑ_sub_2 + 1 := by rfl\n have h_ϑ : ϑ = ϑ_pred + 1 := by rfl\n -- Step 1: Apply multilinearCombine recursive form\n -- We need the lemma `multilinearCombine u r = multilinearCombine`\n -- `(affineLineEvaluation U₀ U₁ r_last) r_init` where `r = Fin.snoc r_init r_last`\n have multilinearCombine_snoc_eq_multilinearCombine_affine\n (r_init : Fin ϑ_pred → F) (r_last : F) : multilinearCombine u (Fin.snoc r_init r_last) =\n multilinearCombine (affineLineEvaluation U₀ U₁ r_last) r_init := by\n rw [multilinearCombine_recursive_form]\n simp only [Fin.snoc_last, Fin.init_snoc]\n rfl\n -- Rewrite the probability using this identity\n simp_rw [multilinearCombine_snoc_eq_multilinearCombine_affine]\n at hP_multilinearCombine_close_gt\n -- hP_multilinearCombine_close_gt now looks like:\n -- Pr_{ r_last ← $ᵖ F; r_init ← $ᵖ (Fin ϑ_pred → F) }[ Δ₀(multilinearCombine\n -- (affineLineEvaluation U₀ U₁ r_last) r_init, ↑MC) ≤ ↑e ] > ↑(↑ϑ * ↑ε) / q\n -- Step 2 & 3: Define R* and apply Law of Total Probability\n let R_star_set := R_star_tensor MC (m:=ϑ_pred) (e:=e) (ε:=ε) U₀ U₁\n -- Step 5: Show Pr[R*] > ε / q\n have h_prob_Rstar_gt_eps_div_q : Pr_{ let r ← $ᵖ F }[ r ∈ R_star_set ]\n > (↑ε : ENNReal) / (Fintype.card F : ENNReal) := by\n let res := prob_R_star_gt_threshold (MC := MC) (ε := ε) (ϑ := ϑ_sub_2 + 1) (u := u)\n (e := e) (hP_multilinearCombine_close_gt)\n exact res\n -- Convert Pr_{}[] to cardinality\n have h_R_star_card_gt_eps : R_star_set.card > ε := by\n rw [prob_uniform_eq_card_filter_div_card] at h_prob_Rstar_gt_eps_div_q -- Needs NNReal\n simp only [ENNReal.coe_natCast] at h_prob_Rstar_gt_eps_div_q\n rw [gt_iff_lt] at h_prob_Rstar_gt_eps_div_q\n have h_cancel_q_denom := ENNReal.div_lt_div_iff_left\n (a := (ε : ENNReal))\n (b := (#(filter (fun r => r ∈ R_star_set) Finset.univ)))\n (c := (Fintype.card F : ENNReal)) (hc₀ := by simp only [ne_eq,\n Nat.cast_eq_zero, Fintype.card_ne_zero, not_false_eq_true]) (hc := by simp only [ne_eq,\n ENNReal.natCast_ne_top, not_false_eq_true])\n rw [h_cancel_q_denom] at h_prob_Rstar_gt_eps_div_q\n simp only [filter_univ_mem, Nat.cast_lt] at h_prob_Rstar_gt_eps_div_q\n exact h_prob_Rstar_gt_eps_div_q\n -- Step 6: Apply Inductive Hypothesis for r_last ∈ R*\n have h_line_close_to_C_m : ∀ (r : R_star_set),\n jointProximityNat (u := affineLineEvaluation U₀ U₁ r.val) (e := e) (C := MC) := by\n intro r_in_Rstar\n -- Use the lemma proven earlier\n apply correlatedAgreement_of_mem_R_star_tensor\n (ih := fun u_prev => ih (by omega) u_prev ) (u := u)\n -- Step 7: Apply Affine Gap of Interleaved Code C^(m = 2^(ϑ_sub_2 + 1))\n have h_C_m_gap := h_interleaved_gaps (2^(ϑ_sub_2 + 1)) (Nat.one_le_two_pow)\n -- Need the hypothesis Pr[...] > ε/q for h_C_m_gap\n have h_prob_line_gt_eps_div_q :\n Pr_{ let r ← $ᵖ F }[\n Δ₀(affineLineEvaluation (u₀ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₀))\n (u₁ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₁)) (r := r),\n ((MC ^⋈ (Fin (2 ^ (ϑ_sub_2 + 1)))))) ≤ e\n ] > (↑ε : ENNReal) / (Fintype.card F : ENNReal) := by\n -- This is implied by h_prob_Rstar_gt_eps_div_q becuz R* is a subset of the success set\n apply lt_of_le_of_lt' _ h_prob_Rstar_gt_eps_div_q\n have h_r_implies: ∀ (r : F), r ∈ R_star_set →\n Δ₀(affineLineEvaluation\n (u₀ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₀))\n (u₁ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₁)) (r := r),\n ((MC ^⋈ (Fin (2 ^ (ϑ_sub_2 + 1)))))) ≤ e := by\n intro r hr_in_Rstar\n specialize h_line_close_to_C_m ⟨r, hr_in_Rstar⟩\n unfold jointProximityNat at h_line_close_to_C_m\n exact h_line_close_to_C_m\n let Pr_le := Pr_le_Pr_of_implies (D := $ᵖ F)\n (g := fun r => Δ₀(affineLineEvaluation\n (u₀ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₀))\n (u₁ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₁)) (r := r),\n ((MC ^⋈ (Fin (2 ^ (ϑ_sub_2 + 1)))))) ≤ e)\n (f := fun r => r ∈ R_star_set) (h_imp := h_r_implies)\n simp only at Pr_le\n exact Pr_le\n -- Apply the gap property of C^m\n have h_final_gap : jointProximityNat₂\n (u₀ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₀))\n (u₁ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₁)) (e := e)\n (C := (MC ^⋈ (Fin (2^(ϑ_sub_2 + 1))))) := by\n apply h_C_m_gap (u₀ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₀))\n (u₁ := ⋈|(show WordStack A (Fin (2 ^ (ϑ_sub_2 + 1))) ι from U₁))\n (h_prob_line_gt_eps_div_q)\n apply CA_split_rowwise_implies_CA (u := u) (e := e)\n exact h_final_gap", "proof_length": 1353, "num_lines": 177, "header": "", "file_path": "ArkLib/Data/CodingTheory/ProximityGap/DG25/MainResults.lean", "url": "https://github.com/Verified-zkEVM/ArkLib", "start_line": 1207, "end_line": 1383, "version_info": [{"v4.31.0": "c1712f6c496d0aef04f09bae42aec13811b3273f"}, {"v4.30.0": "e6d77b18ca1334a91faf4d1ccf9f96d854d58ba4"}, {"v4.29.0": "de71a9dfd2f5a343e8895517b7efe857d9f1ce5c"}]} {"name": "putnam_1964_a4", "source": "putnambench", "statement": "theorem putnam_1964_a4\n(u : ℕ → ℤ)\n(boundedu : ∃ B T : ℤ, ∀ n : ℕ, B ≤ u n ∧ u n ≤ T)\n(hu : ∀ n ≥ 4, u n = ((u (n - 1) + u (n - 2) + u (n - 3) * u (n - 4)) : ℝ) / (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ∧ (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ≠ 0)\n: (∃ N c : ℕ, c > 0 ∧ ∀ n ≥ N, u (n + c) = u n)", "src": "theorem putnam_1964_a4\n(u : ℕ → ℤ)\n(boundedu : ∃ B T : ℤ, ∀ n : ℕ, B ≤ u n ∧ u n ≤ T)\n(hu : ∀ n ≥ 4, u n = ((u (n - 1) + u (n - 2) + u (n - 3) * u (n - 4)) : ℝ) / (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ∧ (u (n - 1) * u (n - 2) + u (n - 3) + u (n - 4)) ≠ 0)\n: (∃ N c : ℕ, c > 0 ∧ ∀ n ≥ N, u (n + c) = u n) := by \n have h_main : ∃ (i j : ℕ), i < j ∧ (u i = u j ∧ u (i + 1) = u (j + 1) ∧ u (i + 2) = u (j + 2) ∧ u (i + 3) = u (j + 3)) := by\n obtain ⟨B, T, hB⟩ := boundedu\n have h₁ : ∃ (i j : ℕ), i < j ∧ (u i = u j ∧ u (i + 1) = u (j + 1) ∧ u (i + 2) = u (j + 2) ∧ u (i + 3) = u (j + 3)) := by\n \n classical\n \n let f : ℕ → (ℤ × ℤ × ℤ × ℤ) := fun n => (u n, u (n + 1), u (n + 2), u (n + 3))\n have h₂ : Set.Finite (Set.range f) := by\n have h₃ : Set.range f ⊆ Set.Icc (B, B, B, B) (T, T, T, T) := by\n intro x hx\n rcases hx with ⟨n, rfl⟩\n have h₄ := hB n\n have h₅ := hB (n + 1)\n have h₆ := hB (n + 2)\n have h₇ := hB (n + 3)\n simp only [Set.mem_Icc, Prod.le_def] at h₄ h₅ h₆ h₇ ⊢\n constructor <;>\n (try constructor) <;>\n (try constructor) <;>\n (try constructor) <;>\n (try simp_all [f]) <;>\n (try nlinarith)\n \n have h₄ : Set.Finite (Set.Icc (B, B, B, B) (T, T, T, T)) := by\n apply Set.Finite.subset (Set.finite_mem_finset (Finset.Icc (B, B, B, B) (T, T, T, T)))\n intro x hx\n simp_all [Set.mem_Icc]\n <;>\n (try aesop)\n exact Set.Finite.subset h₄ h₃\n \n have h₃ : ∃ (i j : ℕ), i < j ∧ f i = f j := by\n by_contra! h₄\n have h₅ : Function.Injective f := by\n intro i j h₆\n by_cases h₇ : i = j\n · exact h₇\n · have h₈ : i < j ∨ j < i := by omega\n cases h₈ with\n | inl h₈ =>\n have h₉ := h₄ i j h₈\n simp_all\n | inr h₈ =>\n have h₉ := h₄ j i h₈\n simp_all\n have h₆ : Set.Infinite (Set.range f) := Set.infinite_range_of_injective h₅\n exact Set.not_infinite.mpr h₂ h₆\n \n obtain ⟨i, j, h₄, h₅⟩ := h₃\n refine' ⟨i, j, h₄, _⟩\n simp [f] at h₅ ⊢\n <;>\n (try simp_all [Prod.ext_iff]) <;>\n (try omega) <;>\n (try aesop)\n exact h₁\n \n have h_periodic : ∃ N c : ℕ, c > 0 ∧ ∀ n ≥ N, u (n + c) = u n := by\n obtain ⟨i, j, hij, h_eq⟩ := h_main\n have h₁ : ∀ m : ℕ, u (i + m) = u (j + m) := by\n intro m\n have h₂ : ∀ m : ℕ, u (i + m) = u (j + m) := by\n intro m\n induction m using Nat.strong_induction_on with\n | h m ih =>\n match m with\n | 0 =>\n have h₃ := h_eq.1\n simp at h₃ ⊢\n <;> simp_all [add_assoc]\n | 1 =>\n have h₃ := h_eq.2.1\n simp at h₃ ⊢\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | 2 =>\n have h₃ := h_eq.2.2.1\n simp at h₃ ⊢\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | 3 =>\n have h₃ := h_eq.2.2.2\n simp at h₃ ⊢\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> omega\n | m + 4 =>\n have h₃ : i + (m + 4) ≥ 4 := by\n have h₄ : i ≥ 0 := by linarith\n omega\n have h₄ : u (i + (m + 4)) = ((u (i + (m + 4) - 1) + u (i + (m + 4) - 2) + u (i + (m + 4) - 3) * u (i + (m + 4) - 4)) : ℝ) / (u (i + (m + 4) - 1) * u (i + (m + 4) - 2) + u (i + (m + 4) - 3) + u (i + (m + 4) - 4)) := by\n have h₅ := hu (i + (m + 4)) (by omega)\n have h₆ := h₅.1\n norm_cast at h₆ ⊢\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> norm_num at *\n <;> linarith\n have h₅ : u (j + (m + 4)) = ((u (j + (m + 4) - 1) + u (j + (m + 4) - 2) + u (j + (m + 4) - 3) * u (j + (m + 4) - 4)) : ℝ) / (u (j + (m + 4) - 1) * u (j + (m + 4) - 2) + u (j + (m + 4) - 3) + u (j + (m + 4) - 4)) := by\n have h₆ := hu (j + (m + 4)) (by\n have h₇ : j ≥ i + 1 := by omega\n omega\n )\n have h₇ := h₆.1\n norm_cast at h₇ ⊢\n <;> simp_all [add_assoc]\n <;> ring_nf at *\n <;> norm_num at *\n <;> linarith\n have h₆ : (i + (m + 4) - 1 : ℕ) = i + (m + 3) := by\n omega\n have h₇ : (i + (m + 4) - 2 : ℕ) = i + (m + 2) := by\n omega\n have h₈ : (i + (m + 4) - 3 : ℕ) = i + (m + 1) := by\n omega\n have h₉ : (i + (m + 4) - 4 : ℕ) = i + m := by\n omega\n have h₁₀ : (j + (m + 4) - 1 : ℕ) = j + (m + 3) := by\n omega\n have h₁₁ : (j + (m + 4) - 2 : ℕ) = j + (m + 2) := by\n omega\n have h₁₂ : (j + (m + 4) - 3 : ℕ) = j + (m + 1) := by\n omega\n have h₁₃ : (j + (m + 4) - 4 : ℕ) = j + m := by\n omega\n have h₁₄ : u (i + (m + 3)) = u (j + (m + 3)) := by\n have h₁₅ := ih (m + 3) (by omega)\n simp [add_assoc] at h₁₅ ⊢\n <;> omega\n have h₁₅ : u (i + (m + 2)) = u (j + (m + 2)) := by\n have h₁₆ := ih (m + 2) (by omega)\n simp [add_assoc] at h₁₆ ⊢\n <;> omega\n have h₁₆ : u (i + (m + 1)) = u (j + (m + 1)) := by\n have h₁₇ := ih (m + 1) (by omega)\n simp [add_assoc] at h₁₇ ⊢\n <;> omega\n have h₁₇ : u (i + m) = u (j + m) := by\n have h₁₈ := ih m (by omega)\n simp [add_assoc] at h₁₈ ⊢\n <;> omega\n have h₁₈ : (u (i + (m + 4)) : ℝ) = (u (j + (m + 4)) : ℝ) := by\n rw [h₄, h₅]\n simp [h₆, h₇, h₈, h₉, h₁₀, h₁₁, h₁₂, h₁₃] at *\n norm_cast at *\n <;>\n (try simp_all [h₁₄, h₁₅, h₁₆, h₁₇]) <;>\n (try ring_nf at *) <;>\n (try field_simp at *) <;>\n (try norm_cast at *) <;>\n (try linarith)\n norm_cast at h₁₈ ⊢\n <;>\n (try simp_all) <;>\n (try linarith)\n exact h₂ m\n have h₂ : ∃ N c : ℕ, c > 0 ∧ ∀ n ≥ N, u (n + c) = u n := by\n use i, (j - i)\n have h₃ : j - i > 0 := by\n omega\n constructor\n · exact h₃\n · intro n hn\n have h₄ : u (n + (j - i)) = u n := by\n have h₅ : u (i + (n - i)) = u (j + (n - i)) := by\n have h₆ := h₁ (n - i)\n simp [add_assoc] at h₆ ⊢\n <;> omega\n have h₆ : i + (n - i) = n := by\n omega\n have h₇ : j + (n - i) = n + (j - i) := by\n omega\n rw [h₆] at h₅\n rw [h₇] at h₅\n linarith\n exact h₄\n exact h₂\n \n exact h_periodic", "proof_length": 1769, "num_lines": 186, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Set Function\n\n\n", "file_path": "", "url": "", "version_info": [{"v4.25.0": "1ccd71f89cbbd82ae7d097723ce1722ca7b01c33"}, {"v4.26.0": "2df2f0150c275ad53cb3c90f7c98ec15a56a1a67"}, {"v4.27.0": "a3a10db0e9d66acbebf76c5e6a135066525ac900"}]} {"name": "putnam_1964_b2", "source": "putnambench", "statement": "theorem putnam_1964_b2\n(S : Type*) [Fintype S] [Nonempty S]\n(P : Finset (Set S))\n(hPP : ∀ T ∈ P, ∀ U ∈ P, T ∩ U ≠ ∅)\n(hPS : ¬∃ T : Set S, T ∉ P ∧ (∀ U ∈ P, T ∩ U ≠ ∅))\n: (P.card = 2 ^ (Fintype.card S - 1))", "src": "theorem putnam_1964_b2\n(S : Type*) [Fintype S] [Nonempty S]\n(P : Finset (Set S))\n(hPP : ∀ T ∈ P, ∀ U ∈ P, T ∩ U ≠ ∅)\n(hPS : ¬∃ T : Set S, T ∉ P ∧ (∀ U ∈ P, T ∩ U ≠ ∅))\n: (P.card = 2 ^ (Fintype.card S - 1)) := by \n have h_no_empty : ∀ (T : Set S), T ∈ P → T.Nonempty := by\n intro T hT\n have h₁ : T ∩ T ≠ ∅ := hPP T hT T hT\n have h₂ : T ∩ T = T := by simp [Set.ext_iff]\n rw [h₂] at h₁\n exact Set.nonempty_iff_ne_empty.mpr h₁\n \n have h_subset_or_compl : ∀ (A : Set S), A ∈ P ∨ Aᶜ ∈ P := by\n intro A\n by_contra! h\n have h₁ : A ∉ P := h.1\n have h₂ : Aᶜ ∉ P := h.2\n \n have h₃ : ∃ (U : Set S), U ∈ P ∧ A ∩ U = ∅ := by\n have h₄ : ¬(A ∉ P ∧ ∀ (U : Set S), U ∈ P → A ∩ U ≠ ∅) := by\n intro h₅\n have h₆ : ∃ (T : Set S), T ∉ P ∧ (∀ U ∈ P, T ∩ U ≠ ∅) := by\n refine' ⟨A, _⟩\n constructor\n · exact h₅.1\n · intro U hU\n have h₇ := h₅.2 U hU\n have h₈ : A ∩ U ≠ ∅ := h₇\n have h₉ : A ∩ U = U ∩ A := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₁₀ : U ∩ A ≠ ∅ := by\n intro h₁₁\n apply h₈\n simp_all [Set.ext_iff]\n <;> aesop\n simpa [Set.inter_comm] using h₁₀\n exact hPS h₆\n by_cases h₅ : A ∉ P\n · have h₆ : ¬(∀ (U : Set S), U ∈ P → A ∩ U ≠ ∅) := by\n intro h₇\n exact h₄ ⟨h₅, h₇⟩\n push_neg at h₆\n obtain ⟨U, hU, h₈⟩ := h₆\n refine' ⟨U, hU, _⟩\n have h₉ : A ∩ U = ∅ := by\n by_contra h₁₀\n have h₁₁ : A ∩ U ≠ ∅ := h₁₀\n simp_all [Set.ext_iff]\n <;> aesop\n exact h₉\n · exfalso\n simp_all\n \n have h₄ : ∃ (V : Set S), V ∈ P ∧ Aᶜ ∩ V = ∅ := by\n have h₅ : ¬(Aᶜ ∉ P ∧ ∀ (U : Set S), U ∈ P → Aᶜ ∩ U ≠ ∅) := by\n intro h₆\n have h₇ : ∃ (T : Set S), T ∉ P ∧ (∀ U ∈ P, T ∩ U ≠ ∅) := by\n refine' ⟨Aᶜ, _⟩\n constructor\n · exact h₆.1\n · intro U hU\n have h₈ := h₆.2 U hU\n have h₉ : Aᶜ ∩ U ≠ ∅ := h₈\n have h₁₀ : Aᶜ ∩ U = U ∩ Aᶜ := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₁₁ : U ∩ Aᶜ ≠ ∅ := by\n intro h₁₂\n apply h₉\n simp_all [Set.ext_iff]\n <;> aesop\n simpa [Set.inter_comm] using h₁₁\n exact hPS h₇\n by_cases h₆ : Aᶜ ∉ P\n · have h₇ : ¬(∀ (U : Set S), U ∈ P → Aᶜ ∩ U ≠ ∅) := by\n intro h₈\n exact h₅ ⟨h₆, h₈⟩\n push_neg at h₇\n obtain ⟨V, hV, h₈⟩ := h₇\n refine' ⟨V, hV, _⟩\n have h₉ : Aᶜ ∩ V = ∅ := by\n by_contra h₁₀\n have h₁₁ : Aᶜ ∩ V ≠ ∅ := h₁₀\n simp_all [Set.ext_iff]\n <;> aesop\n exact h₉\n · exfalso\n simp_all\n \n obtain ⟨U, hU, hU'⟩ := h₃\n obtain ⟨V, hV, hV'⟩ := h₄\n \n have h₅ : U ⊆ Aᶜ := by\n intro x hx\n by_contra h₆\n have h₇ : x ∈ A := by simp_all [Set.mem_compl_iff]\n have h₈ : x ∈ A ∩ U := Set.mem_inter h₇ hx\n rw [hU'] at h₈\n simp at h₈\n <;> aesop\n have h₆ : V ⊆ A := by\n intro x hx\n by_contra h₇\n have h₈ : x ∈ Aᶜ := by simp_all [Set.mem_compl_iff]\n have h₉ : x ∈ Aᶜ ∩ V := Set.mem_inter h₈ hx\n rw [hV'] at h₉\n simp at h₉\n <;> aesop\n \n have h₇ : U ∩ V = ∅ := by\n apply Set.eq_empty_of_forall_not_mem\n intro x hx\n have h₈ : x ∈ U := Set.mem_of_mem_inter_left hx\n have h₉ : x ∈ V := Set.mem_of_mem_inter_right hx\n have h₁₀ : x ∈ Aᶜ := h₅ h₈\n have h₁₁ : x ∈ A := h₆ h₉\n simp_all [Set.mem_compl_iff]\n <;> aesop\n \n have h₈ : U ∩ V ≠ ∅ := hPP U hU V hV\n simp_all [Set.ext_iff]\n <;> aesop\n \n have h_not_both : ∀ (A : Set S), A ∈ P → Aᶜ ∉ P := by\n intro A hA\n by_contra h\n have h₁ : Aᶜ ∈ P := h\n have h₂ : A ∩ Aᶜ = ∅ := by\n ext x\n simp [Set.mem_inter_iff]\n <;> tauto\n have h₃ : A ∩ Aᶜ ≠ ∅ := hPP A hA Aᶜ h₁\n rw [h₂] at h₃\n contradiction\n \n have h_card : P.card = 2 ^ (Fintype.card S - 1) := by\n classical\n \n let Q : Finset (Set S) := (Finset.univ : Finset (Set S)) \\ P\n \n have h₁ : P.card = Q.card := by\n \n have h₂ : ∀ (A : Set S), A ∈ P → Aᶜ ∈ Q := by\n intro A hA\n have h₃ : Aᶜ ∈ (Finset.univ : Finset (Set S)) := Finset.mem_univ _\n have h₄ : Aᶜ ∉ P := h_not_both A hA\n simp only [Q, Finset.mem_sdiff] at *\n tauto\n have h₃ : ∀ (A : Set S), A ∈ Q → Aᶜ ∈ P := by\n intro A hA\n have h₄ : A ∈ (Finset.univ : Finset (Set S)) := by\n simp only [Q, Finset.mem_sdiff] at hA\n tauto\n have h₅ : A ∉ P := by\n simp only [Q, Finset.mem_sdiff] at hA\n tauto\n have h₆ : A ∈ (Finset.univ : Finset (Set S)) := by tauto\n have h₇ : A ∈ P ∨ Aᶜ ∈ P := h_subset_or_compl A\n cases h₇ with\n | inl h₈ =>\n exfalso\n tauto\n | inr h₈ =>\n exact h₈\n \n have h₄ : P.card = Q.card := by\n \n have h₅ : P.card = Q.card := by\n \n have h₆ : ∀ (A : Set S), A ∈ P → Aᶜ ∈ Q := h₂\n have h₇ : ∀ (A : Set S), A ∈ Q → Aᶜ ∈ P := h₃\n \n have h₈ : P.card = Q.card := by\n \n apply Finset.card_bij' (fun A _ => Aᶜ) (fun A _ => Aᶜ)\n <;> simp_all [Set.ext_iff]\n <;>\n (try\n {\n aesop\n })\n <;>\n (try\n {\n tauto\n })\n <;>\n (try\n {\n intros\n <;>\n simp_all [Set.ext_iff]\n <;>\n tauto\n })\n <;>\n (try\n {\n intros\n <;>\n simp_all [Set.ext_iff]\n <;>\n tauto\n })\n exact h₈\n exact h₅\n exact h₄\n \n have h₂ : P.card + Q.card = 2 ^ Fintype.card S := by\n have h₃ : P.card + Q.card = (Finset.univ : Finset (Set S)).card := by\n have h₄ : Disjoint P Q := by\n rw [Finset.disjoint_left]\n intro A hA hA'\n simp only [Q, Finset.mem_sdiff] at hA'\n tauto\n have h₅ : P ∪ Q = (Finset.univ : Finset (Set S)) := by\n apply Finset.ext\n intro A\n simp only [Q, Finset.mem_union, Finset.mem_sdiff, Finset.mem_univ, true_and]\n <;>\n by_cases h₆ : A ∈ P <;> simp_all [h_subset_or_compl]\n <;>\n (try tauto)\n <;>\n (try\n {\n have h₇ := h_subset_or_compl A\n cases h₇ with\n | inl h₈ => tauto\n | inr h₈ =>\n have h₉ : Aᶜ ∈ P := h₈\n have h₁₀ : A ∈ P ∨ Aᶜ ∈ P := by tauto\n tauto\n })\n have h₆ : P.card + Q.card = (P ∪ Q).card := by\n rw [← Finset.card_union_add_card_inter P Q]\n have h₇ : P ∩ Q = ∅ := Finset.disjoint_iff_inter_eq_empty.mp h₄\n rw [h₇]\n simp\n rw [h₅] at h₆\n exact h₆\n have h₄ : (Finset.univ : Finset (Set S)).card = 2 ^ Fintype.card S := by\n simp [Fintype.card_fun]\n <;>\n simp_all [Fintype.card_fun]\n <;>\n ring_nf\n <;>\n simp_all [Fintype.card_fun]\n <;>\n norm_num\n <;>\n aesop\n linarith\n \n have h₃ : P.card * 2 = 2 ^ Fintype.card S := by\n have h₄ : P.card + Q.card = 2 ^ Fintype.card S := h₂\n have h₅ : P.card = Q.card := h₁\n linarith\n \n have h₄ : Fintype.card S ≥ 1 := by\n have h₅ : Nonempty S := inferInstance\n have h₆ : 0 < Fintype.card S := by\n apply Fintype.card_pos_iff.mpr\n exact ⟨Classical.choice h₅⟩\n omega\n have h₅ : P.card = 2 ^ (Fintype.card S - 1) := by\n have h₆ : P.card * 2 = 2 ^ Fintype.card S := h₃\n have h₇ : Fintype.card S ≥ 1 := h₄\n have h₈ : 2 ^ (Fintype.card S - 1) * 2 = 2 ^ Fintype.card S := by\n have h₉ : Fintype.card S - 1 + 1 = Fintype.card S := by\n have h₁₀ : Fintype.card S ≥ 1 := h₄\n omega\n calc\n 2 ^ (Fintype.card S - 1) * 2 = 2 ^ (Fintype.card S - 1) * 2 ^ 1 := by norm_num\n _ = 2 ^ ((Fintype.card S - 1) + 1) := by\n rw [← pow_add]\n _ = 2 ^ Fintype.card S := by\n rw [h₉]\n <;> simp [add_comm]\n have h₉ : P.card = 2 ^ (Fintype.card S - 1) := by\n have h₁₀ : P.card * 2 = 2 ^ Fintype.card S := h₃\n have h₁₁ : 2 ^ (Fintype.card S - 1) * 2 = 2 ^ Fintype.card S := h₈\n have h₁₂ : P.card = 2 ^ (Fintype.card S - 1) := by\n nlinarith\n exact h₁₂\n exact h₉\n exact h₅\n \n exact h_card", "proof_length": 1754, "num_lines": 294, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Set Function Filter Topology\n\n\n", "file_path": "", "url": "", "version_info": [{"v4.25.0": "1ccd71f89cbbd82ae7d097723ce1722ca7b01c33"}, {"v4.26.0": "2df2f0150c275ad53cb3c90f7c98ec15a56a1a67"}]} {"name": "putnam_1995_a3", "source": "putnambench", "statement": "theorem putnam_1995_a3\n(relation : (Fin 9 → ℤ) → (Fin 9 → ℤ) → Prop)\n(digits_to_num : (Fin 9 → ℤ) → ℤ)\n(hdigits_to_num : digits_to_num = fun dig => ∑ i : Fin 9, (dig i) * 10^i.1)\n(hrelation : ∀ d e : (Fin 9 → ℤ), relation d e ↔ (∀ i : Fin 9, d i < 10 ∧ d i ≥ 0 ∧ e i < 10 ∧ e i ≥ 0) ∧ (∀ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))))\n: ∀ d e f : (Fin 9 → ℤ), ((relation d e) ∧ (relation e f)) → (∀ i : Fin 9, 7 ∣ d i - f i)", "src": "theorem putnam_1995_a3\n(relation : (Fin 9 → ℤ) → (Fin 9 → ℤ) → Prop)\n(digits_to_num : (Fin 9 → ℤ) → ℤ)\n(hdigits_to_num : digits_to_num = fun dig => ∑ i : Fin 9, (dig i) * 10^i.1)\n(hrelation : ∀ d e : (Fin 9 → ℤ), relation d e ↔ (∀ i : Fin 9, d i < 10 ∧ d i ≥ 0 ∧ e i < 10 ∧ e i ≥ 0) ∧ (∀ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))))\n: ∀ d e f : (Fin 9 → ℤ), ((relation d e) ∧ (relation e f)) → (∀ i : Fin 9, 7 ∣ d i - f i) := by \n have h_main : ∀ (d e f : (Fin 9 → ℤ)), ((relation d e) ∧ (relation e f)) → (∀ i : Fin 9, 7 ∣ d i - f i) := by\n intro d e f h\n have h₁ : relation d e := h.1\n have h₂ : relation e f := h.2\n have h₃ : ∀ (i : Fin 9), 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) := by\n have h₄ : (∀ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j))) := (hrelation d e).mp h₁ |>.2\n exact h₄\n have h₄ : ∀ (i : Fin 9), 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) := by\n have h₅ : (∀ i : Fin 9, 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j))) := (hrelation e f).mp h₂ |>.2\n exact h₅\n \n have h₅ : ∀ (i : Fin 9), 7 ∣ (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d := by\n intro i\n have h₆ : 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) := h₃ i\n have h₇ : (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) = digits_to_num d + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n (digits_to_num (fun j : Fin 9 => if j = i then e j else d j)) = ∑ j : Fin 9, (if j = i then e j else d j) * (10 : ℤ) ^ (j : ℕ) := by\n simp [hdigits_to_num]\n <;>\n rfl\n _ = ∑ j : Fin 9, (if j = i then e j else d j) * (10 : ℤ) ^ (j : ℕ) := rfl\n _ = (∑ j : Fin 9, d j * (10 : ℤ) ^ (j : ℕ)) + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n (∑ j : Fin 9, (if j = i then e j else d j) * (10 : ℤ) ^ (j : ℕ)) = ∑ j : Fin 9, (d j * (10 : ℤ) ^ (j : ℕ) + (if j = i then (e j - d j) else 0) * (10 : ℤ) ^ (j : ℕ)) := by\n apply Finset.sum_congr rfl\n intro j _\n by_cases h : j = i\n · simp [h]\n <;> ring\n · simp [h]\n <;> ring\n _ = (∑ j : Fin 9, d j * (10 : ℤ) ^ (j : ℕ)) + ∑ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : ℤ) ^ (j : ℕ) := by\n rw [Finset.sum_add_distrib]\n _ = (∑ j : Fin 9, d j * (10 : ℤ) ^ (j : ℕ)) + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n have h₈ : ∑ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : ℤ) ^ (j : ℕ) = (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n _ = ∑ j : Fin 9, (if j = i then (e j - d j) else 0) * (10 : ℤ) ^ (j : ℕ) := rfl\n _ = (if i = i then (e i - d i) else 0) * (10 : ℤ) ^ (i : ℕ) := by\n \n simp [Finset.sum_ite_eq', Finset.mem_univ, i.is_lt]\n _ = (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by simp\n rw [h₈]\n <;> simp [hdigits_to_num]\n <;>\n rfl\n _ = digits_to_num d + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have h₈ : 7 ∣ digits_to_num d + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n rw [h₇] at h₆\n exact h₆\n \n have h₉ : 7 ∣ (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d := by\n \n have h₁₀ : (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d = digits_to_num d + (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by ring\n rw [h₁₀]\n exact h₈\n exact h₉\n \n have h₆ : ∀ (i : Fin 9), 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e := by\n intro i\n have h₇ : 7 ∣ (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) := h₄ i\n have h₈ : (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) = digits_to_num e + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n (digits_to_num (fun j : Fin 9 => if j = i then f j else e j)) = ∑ j : Fin 9, (if j = i then f j else e j) * (10 : ℤ) ^ (j : ℕ) := by\n simp [hdigits_to_num]\n <;>\n rfl\n _ = ∑ j : Fin 9, (if j = i then f j else e j) * (10 : ℤ) ^ (j : ℕ) := rfl\n _ = (∑ j : Fin 9, e j * (10 : ℤ) ^ (j : ℕ)) + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n (∑ j : Fin 9, (if j = i then f j else e j) * (10 : ℤ) ^ (j : ℕ)) = ∑ j : Fin 9, (e j * (10 : ℤ) ^ (j : ℕ) + (if j = i then (f j - e j) else 0) * (10 : ℤ) ^ (j : ℕ)) := by\n apply Finset.sum_congr rfl\n intro j _\n by_cases h : j = i\n · simp [h]\n <;> ring\n · simp [h]\n <;> ring\n _ = (∑ j : Fin 9, e j * (10 : ℤ) ^ (j : ℕ)) + ∑ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : ℤ) ^ (j : ℕ) := by\n rw [Finset.sum_add_distrib]\n _ = (∑ j : Fin 9, e j * (10 : ℤ) ^ (j : ℕ)) + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n have h₉ : ∑ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : ℤ) ^ (j : ℕ) = (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n _ = ∑ j : Fin 9, (if j = i then (f j - e j) else 0) * (10 : ℤ) ^ (j : ℕ) := rfl\n _ = (if i = i then (f i - e i) else 0) * (10 : ℤ) ^ (i : ℕ) := by\n \n simp [Finset.sum_ite_eq', Finset.mem_univ, i.is_lt]\n _ = (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by simp\n rw [h₉]\n <;> simp [hdigits_to_num]\n <;>\n rfl\n _ = digits_to_num e + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have h₉ : 7 ∣ digits_to_num e + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by\n rw [h₈] at h₇\n exact h₇\n \n have h₁₀ : 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e := by\n \n have h₁₁ : (f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e = digits_to_num e + (f i - e i) * (10 : ℤ) ^ (i : ℕ) := by ring\n rw [h₁₁]\n exact h₉\n exact h₁₀\n \n have h₇ : 7 ∣ digits_to_num e + digits_to_num d := by\n have h₈ : digits_to_num e = digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n calc\n digits_to_num e = ∑ i : Fin 9, e i * (10 : ℤ) ^ (i : ℕ) := by simp [hdigits_to_num]\n _ = ∑ i : Fin 9, (d i + (e i - d i)) * (10 : ℤ) ^ (i : ℕ) := by\n apply Finset.sum_congr rfl\n intro i _\n ring\n _ = ∑ i : Fin 9, (d i * (10 : ℤ) ^ (i : ℕ) + (e i - d i) * (10 : ℤ) ^ (i : ℕ)) := by\n apply Finset.sum_congr rfl\n intro i _\n ring\n _ = (∑ i : Fin 9, d i * (10 : ℤ) ^ (i : ℕ)) + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n rw [Finset.sum_add_distrib]\n _ = digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n simp [hdigits_to_num]\n <;>\n rfl\n have h₉ : ∀ i : Fin 9, 7 ∣ (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d := h₅\n have h₁₀ : 7 ∣ ∑ i : Fin 9, ((e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d) := by\n apply Finset.dvd_sum\n intro i _\n exact h₉ i\n have h₁₁ : ∑ i : Fin 9, ((e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d) = ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + 9 * digits_to_num d := by\n calc\n ∑ i : Fin 9, ((e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d) = ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + ∑ i : Fin 9, digits_to_num d := by\n rw [Finset.sum_add_distrib]\n _ = ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + 9 * digits_to_num d := by\n simp [Finset.sum_const, Finset.card_fin]\n <;> ring\n <;> norm_num\n have h₁₂ : 7 ∣ ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + 9 * digits_to_num d := by\n rw [h₁₁] at h₁₀\n exact h₁₀\n have h₁₃ : 7 ∣ digits_to_num e + digits_to_num d := by\n have h₁₄ : digits_to_num e + digits_to_num d = 2 * digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n linarith\n rw [h₁₄]\n have h₁₅ : 7 ∣ 2 * digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n have h₁₆ : 7 ∣ ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + 9 * digits_to_num d := h₁₂\n have h₁₇ : 7 ∣ 2 * digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n \n have h₁₈ : (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) + 9 * digits_to_num d) = (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 9 * digits_to_num d := by ring\n rw [h₁₈] at h₁₆\n \n \n \n \n \n \n have h₁₉ : 7 ∣ (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 2 * digits_to_num d := by\n \n \n \n have h₂₀ : 7 ∣ (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 9 * digits_to_num d := h₁₆\n have h₂₁ : 7 ∣ 7 * digits_to_num d := by\n use digits_to_num d\n <;> ring\n have h₂₂ : 7 ∣ (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 2 * digits_to_num d := by\n \n have h₂₃ : (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 2 * digits_to_num d = ((∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 9 * digits_to_num d) - 7 * digits_to_num d := by ring\n rw [h₂₃]\n exact dvd_sub h₂₀ h₂₁\n exact h₂₂\n \n have h₂₀ : 7 ∣ 2 * digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n \n have h₂₁ : 2 * digits_to_num d + ∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ) = (∑ i : Fin 9, (e i - d i) * (10 : ℤ) ^ (i : ℕ)) + 2 * digits_to_num d := by ring\n rw [h₂₁]\n exact h₁₉\n exact h₂₀\n exact h₁₇\n exact h₁₅\n exact h₁₃\n \n have h₈ : ∀ (i : Fin 9), 7 ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n intro i\n have h₉ : 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e := h₆ i\n have h₁₀ : 7 ∣ (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d := h₅ i\n have h₁₁ : 7 ∣ digits_to_num e + digits_to_num d := h₇\n \n have h₁₂ : 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) - digits_to_num d := by\n \n \n have h₁₃ : 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e := h₆ i\n have h₁₄ : 7 ∣ digits_to_num e + digits_to_num d := h₇\n \n have h₁₅ : 7 ∣ ((f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e) - (digits_to_num e + digits_to_num d) := by\n exact dvd_sub h₁₃ h₁₄\n \n have h₁₆ : ((f i - e i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num e) - (digits_to_num e + digits_to_num d) = (f i - e i) * (10 : ℤ) ^ (i : ℕ) - digits_to_num d := by\n ring\n rw [h₁₆] at h₁₅\n exact h₁₅\n \n have h₁₃ : 7 ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n have h₁₄ : 7 ∣ (f i - e i) * (10 : ℤ) ^ (i : ℕ) - digits_to_num d := h₁₂\n have h₁₅ : 7 ∣ (e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d := h₅ i\n \n have h₁₆ : 7 ∣ ((f i - e i) * (10 : ℤ) ^ (i : ℕ) - digits_to_num d) + ((e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d) := by\n exact dvd_add h₁₄ h₁₅\n \n have h₁₇ : ((f i - e i) * (10 : ℤ) ^ (i : ℕ) - digits_to_num d) + ((e i - d i) * (10 : ℤ) ^ (i : ℕ) + digits_to_num d) = (f i - d i) * (10 : ℤ) ^ (i : ℕ) := by\n ring\n rw [h₁₇] at h₁₆\n exact h₁₆\n exact h₁₃\n \n have h₉ : ∀ (i : Fin 9), 7 ∣ d i - f i := by\n intro i\n have h₁₀ : 7 ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := h₈ i\n have h₁₁ : 7 ∣ (f i - d i) := by\n \n have h₁₂ : (7 : ℤ) ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := h₁₀\n \n have h₁₃ : (7 : ℕ).Prime := by decide\n have h₁₄ : ¬(7 : ℤ) ∣ (10 : ℤ) ^ (i : ℕ) := by\n \n intro h\n have h₁₅ : (7 : ℕ) ∣ (10 : ℕ) ^ (i : ℕ) := by\n norm_cast at h ⊢\n <;> simpa [Int.coe_nat_dvd_left] using h\n have h₁₆ : (7 : ℕ) ∣ 10 := by\n \n exact Nat.Prime.dvd_of_dvd_pow h₁₃ h₁₅\n norm_num at h₁₆\n <;> contradiction\n \n have h₁₅ : (7 : ℤ) ∣ (f i - d i) := by\n \n have h₁₆ : (7 : ℤ) ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := h₁₂\n have h₁₇ : ¬(7 : ℤ) ∣ (10 : ℤ) ^ (i : ℕ) := h₁₄\n \n have h₁₈ : (7 : ℤ) ∣ (f i - d i) := by\n \n have h₁₉ : (7 : ℤ) ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := h₁₂\n have h₂₀ : (7 : ℕ).Prime := by decide\n have h₂₁ : (7 : ℤ) ∣ (f i - d i) ∨ (7 : ℤ) ∣ (10 : ℤ) ^ (i : ℕ) := by\n \n have h₂₂ : (7 : ℤ) ∣ (f i - d i) * (10 : ℤ) ^ (i : ℕ) := h₁₂\n have h₂₃ : (7 : ℤ) ∣ (f i - d i) ∨ (7 : ℤ) ∣ (10 : ℤ) ^ (i : ℕ) := by\n \n apply (Int.prime_iff_natAbs_prime.mpr (by decide)).dvd_mul.mp\n exact h₂₂\n exact h₂₃\n cases h₂₁ with\n | inl h₂₁ =>\n exact h₂₁\n | inr h₂₁ =>\n exfalso\n exact h₁₄ h₂₁\n exact h₁₈\n exact h₁₅\n \n have h₁₂ : 7 ∣ d i - f i := by\n have h₁₃ : 7 ∣ (f i - d i) := h₁₁\n have h₁₄ : 7 ∣ -(f i - d i) := by\n exact dvd_neg.mpr h₁₃\n have h₁₅ : -(f i - d i) = d i - f i := by ring\n rw [h₁₅] at h₁₄\n exact h₁₄\n exact h₁₂\n \n intro i\n have h₁₀ : 7 ∣ d i - f i := h₉ i\n exact h₁₀\n exact h_main", "proof_length": 4085, "num_lines": 282, "header": "import Mathlib\nimport Aesop\n\nset_option maxHeartbeats 0\n\nopen Filter Topology Real\n\n\n", "file_path": "", "url": "", "version_info": [{"v4.25.0": "1ccd71f89cbbd82ae7d097723ce1722ca7b01c33"}, {"v4.26.0": "2df2f0150c275ad53cb3c90f7c98ec15a56a1a67"}, {"v4.27.0": "a3a10db0e9d66acbebf76c5e6a135066525ac900"}]}