Lean 4 · 8
declarations statementsfull
noncomputable def metric (I : RationalMetricInput) : PseudoMetricSpace (Fin I.pointCount) where body · 4 lines
dist x y := I.distance x y
dist_self x := by exact_mod_cast I.distance_self x
dist_comm x y := by exact_mod_cast I.distance_symm x y
dist_triangle x y z := by exact_mod_cast I.distance_triangle x y zlemma cast_inf' {V : Type*} (S : Finset V) (hS : S.Nonempty) (f : V → ℚ) :
((S.inf' hS f:ℚ):ℝ) = S.inf' hS (fun x => (f x:ℝ)) := by proof · 5 lines
apply le_antisymm
· exact Finset.le_inf' hS _ (fun i hi => by exact_mod_cast Finset.inf'_le f hi)
· obtain ⟨i,hi,he⟩ := Finset.exists_mem_eq_inf' hS f
rw [he]
exact Finset.inf'_le _ hilemma metric_cost (I : RationalMetricInput) (S : Finset (Fin I.pointCount)) :
@LocalSearch.cost _ I.metric I.clients S = (I.cost S:ℝ) := by proof · 7 lines
by_cases hS : S.Nonempty
· simp only [cost,LocalSearch.cost,LocalSearch.connection,dite_eq_left hS,Rat.cast_sum]
apply Finset.sum_congr rfl
intro p _
exact (cast_inf' S hS (I.distance p)).symm
· simp only [cost,LocalSearch.cost,LocalSearch.connection,dite_eq_right hS,
Finset.sum_const_zero,Rat.cast_zero]lemma metric_optimum (I : RationalMetricInput) :
@LocalSearch.optimum _ I.metric I.facilities I.clients I.budget = (I.optimum:ℝ) := by proof · 6 lines
let := I.metric
have h : (LocalSearch.feasibleSets I.facilities I.budget).Nonempty :=
LocalSearch.feasibleSets_nonempty _ I.facilities_nonempty _ I.budget_pos
have hf : LocalSearch.cost I.clients = fun S => (I.cost S:ℝ) := funext (metric_cost I)
rw [LocalSearch.optimum,dite_eq_left h,hf,optimum,cast_inf']
rfllemma cost_nonneg (I : RationalMetricInput) (S : Finset (Fin I.pointCount)) : 0 ≤ I.cost S := by proof · 3 lines
have h := @LocalSearch.cost_nonneg _ I.metric I.clients S
rw [metric_cost] at h
exact_mod_cast hlemma optimum_nonneg (I : RationalMetricInput) : 0 ≤ I.optimum := by proof · 3 lines
have h := @LocalSearch.optimum_nonneg _ I.metric I.facilities I.clients I.budget
rw [metric_optimum] at h
exact_mod_cast hdef outputBits (I : RationalMetricInput) (S : Finset (Fin I.pointCount)) : List Bool := body · 1 line
List.ofFn (fun i : Fin I.pointCount => decide (i ∈ S))lemma decode_outputBits (I : RationalMetricInput) (S : Finset (Fin I.pointCount)) (hSF : S ⊆ I.facilities) :
I.decodeOutput (I.outputBits S) = S := by proof · 4 lines
ext i
simp only [decodeOutput,outputBits,Finset.mem_filter,List.getElem?_ofFn,i.isLt,
dite_true,Option.getD_some,Fin.eta,decide_eq_true_eq]
exact and_iff_right_of_imp (fun hi => hSF hi)Outline
Xet Storage Details
- Size:
- 2.73 kB
- Xet hash:
- 7e713e61c92305ab5115b682f478b6751c8d5e6b60a3a18092002b7eab9b687a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.