Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CompPoly/Bivariate/ToPoly.lean
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ theorem ofPoly_toPoly {R : Type*} [BEq R] [LawfulBEq R] [Nontrivial R] [Semiring
[DecidableEq R]
(p : R[X][Y]) : toPoly (ofPoly p) = p := by
induction p using Polynomial.induction_on'
· rw [ ofPoly_add, toPoly_add,
‹(ofPoly _).toPoly = _›, ‹(ofPoly _).toPoly = _› ]
· rename_i p q hp hq
rw [ofPoly_add, toPoly_add, hp, hq]
· rename_i n c
simp +decide [ ofPoly_monomial, toPoly_monomial ]
exact congr_arg _ ( CPolynomial.Raw.toPoly_toImpl )
Expand Down
10 changes: 7 additions & 3 deletions CompPoly/Univariate/NTTFast/Correctness/Radix4DIF.lean
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ private theorem butterflyDIFRadix4Blocks_eq_two_dif_blocks
(butterflyDIFInner_comm twiddlesHigh twiddlesLow (2 * q) q (j * (4 * q))
(2 * q) (i * (4 * q)) q (by
intro a ha b hb
refine ⟨?_, ?_, ?_, ?_⟩ <;> nlinarith) x)
have h := Nat.mul_le_mul_right (4 * q) (Nat.succ_le_of_lt hij)
rw [Nat.succ_mul] at h
refine ⟨?_, ?_, ?_, ?_⟩ <;> omega) x)
have hlow₂ (x' : Array R) :
highBlock j
(butterflyDIFInner twiddlesLow q 0 (2 * q + i * (4 * q))
Expand All @@ -514,7 +516,9 @@ private theorem butterflyDIFRadix4Blocks_eq_two_dif_blocks
(butterflyDIFInner_comm twiddlesHigh twiddlesLow (2 * q) q (j * (4 * q))
(2 * q) (2 * q + i * (4 * q)) q (by
intro a ha b hb
refine ⟨?_, ?_, ?_, ?_⟩ <;> nlinarith) x')
have h := Nat.mul_le_mul_right (4 * q) (Nat.succ_le_of_lt hij)
rw [Nat.succ_mul] at h
refine ⟨?_, ?_, ?_, ?_⟩ <;> omega) x')
simp only [lowBlock]
rw [← hlow₁]
rw [← hlow₂]
Expand All @@ -541,7 +545,7 @@ private theorem butterflyDIFRadix4Blocks_eq_two_dif_blocks
(((2 * block + 1) * (2 * q), (2 * block + 1) * (2 * q) + q,
2 * block * (2 * q), 2 * block * (2 * q) + q) :
Nat × Nat × Nat × Nat) by
ext <;> nlinarith)
ext <;> ring)
_ = List.foldl (fun acc block ↦ lowStep block acc)
(List.foldl (fun acc block ↦ highBlock block acc) acc (List.range blocks))
(List.range (2 * blocks)) := by
Expand Down
10 changes: 7 additions & 3 deletions CompPoly/Univariate/NTTFast/Correctness/Radix4DIT.lean
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ private theorem butterflyDITRadix4Blocks_eq_two_dit_blocks
(butterflyDITInner_comm twiddlesLow twiddlesHigh q (2 * q) (j * (4 * q))
q (i * (4 * q)) (2 * q) (by
intro a ha b hb
refine ⟨?_, ?_, ?_, ?_⟩ <;> nlinarith) x)
have h := Nat.mul_le_mul_right (4 * q) (Nat.succ_le_of_lt hij)
rw [Nat.succ_mul] at h
refine ⟨?_, ?_, ?_, ?_⟩ <;> omega) x)
have hlow₂ (x' : Array R) :
butterflyDITInner twiddlesLow q 0 (2 * q + j * (4 * q))
(2 * q + (j * (4 * q) + q)) (highBlock i x') =
Expand All @@ -524,7 +526,9 @@ private theorem butterflyDITRadix4Blocks_eq_two_dit_blocks
(butterflyDITInner_comm twiddlesLow twiddlesHigh q (2 * q)
(2 * q + j * (4 * q)) q (i * (4 * q)) (2 * q) (by
intro a ha b hb
refine ⟨?_, ?_, ?_, ?_⟩ <;> nlinarith) x')
have h := Nat.mul_le_mul_right (4 * q) (Nat.succ_le_of_lt hij)
rw [Nat.succ_mul] at h
refine ⟨?_, ?_, ?_, ?_⟩ <;> omega) x')
simp only [lowBlock]
rw [hlow₁]
exact hlow₂ _
Expand All @@ -549,7 +553,7 @@ private theorem butterflyDITRadix4Blocks_eq_two_dit_blocks
(((2 * block + 1) * (2 * q), (2 * block + 1) * (2 * q) + q,
2 * block * (2 * q), 2 * block * (2 * q) + q) :
Nat × Nat × Nat × Nat) by
ext <;> nlinarith)
ext <;> ring)
_ = List.foldl (fun acc block ↦ lowStep block acc) acc (List.range (2 * blocks)) := by
exact foldl_range_pair lowStep blocks acc
_ = butterflyDITBlocks twiddlesHigh (4 * q) (2 * q) blocks 0
Expand Down
8 changes: 3 additions & 5 deletions CompPoly/Univariate/Roots/LasVegas/Correctness/Odd.lean
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ theorem cantorZassenhausOddAttemptWith_child_proper {F : Type*}
simp only at htry
split at htry
next _hsize =>
injection htry with hchildren
subst children
obtain rfl := Option.some.inj htry
have hraw := mem_of_mem_eraseDups (by simpa using hmem)
exact proper_of_mem_nontrivialProperChildren (by simpa using hraw)
next _hsize =>
Expand All @@ -212,9 +211,8 @@ theorem cantorZassenhausOddAttemptWith_size_ge_two {F : Type*}
simp only at htry
split at htry
next hsize =>
injection htry with hchildren
subst children
simpa using hsize
obtain rfl := Option.some.inj htry
exact hsize
next _hsize =>
simp at htry

Expand Down
29 changes: 11 additions & 18 deletions CompPoly/Univariate/Roots/LasVegas/Probability/EvenTrace.lean
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ theorem fallbackAfterEvenTraceAttempts_probability_le_geometric_of_uniformProbe
exact evenTraceTrial_success_probability_ge_half M D traceCtx enumeration g (offset + i)
hfield (hrootProduct.hasTwoDistinctRoots hdegree) hdegree

set_option maxHeartbeats 1600000 in
/--
Bridge to the executable trace retry loop: the deterministic
`tryEvenTraceSplitAttemptsWith`, driven by a probe table whose entries are
Expand All @@ -471,27 +470,21 @@ theorem tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric {F : Type*}
tryEvenTraceSplitAttemptsWith M D traceCtx q (tableProbeFamily table) g
attempts 0 = none} ≤
((2 : ℝ≥0∞)⁻¹) ^ attempts := by
have hfailset : ((fun h : CPolynomial F ↦
(match cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 with
| some children => TrialResult.split children
| none => TrialResult.failed)) ⁻¹'
{trial : TrialResult F | ¬ trial.IsSuccess}) =
{h : CPolynomial F | cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 = none} := by
ext h
cases h0 : cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 <;>
simp [h0, TrialResult.IsSuccess]
-- The failure event is read off `evenTraceTrialPMF`'s own function. Restating its `match`
-- here would create a second matcher constant, and unifying the two unfolds the root
-- finder.
have hfail : (uniformProbePMF enumeration coefficientCount).toOuterMeasure
{h : CPolynomial F | cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 = none} ≤
(2 : ℝ≥0∞)⁻¹ := by
rw [← hfailset, ← PMF.toOuterMeasure_map_apply]
have hhalf := trialFailureProbability_le_half_of_success
(evenTraceTrialPMF M D traceCtx enumeration q coefficientCount g 0) hstep
rw [eventProbability, evenTraceTrialPMF] at hhalf
exact hhalf
rw [eventProbability, evenTraceTrialPMF, PMF.toOuterMeasure_map_apply] at hhalf
refine le_trans (le_of_eq (congrArg _ ?_)) hhalf
ext h
cases h0 : cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 <;>
simp [h0, TrialResult.IsSuccess]
intro attempts
induction attempts with
| zero =>
Expand Down Expand Up @@ -544,7 +537,7 @@ theorem tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric {F : Type*}
by_cases h0 : cantorZassenhausEvenTraceAttemptWith M D traceCtx q
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 = none
· rw [ite_eq_left h0]
congr 1
refine congrArg _ ?_
ext rest
rw [Set.mem_preimage, Set.mem_ofPred_eq, Set.mem_ofPred_eq, hsection h rest]
simp [h0]
Expand Down Expand Up @@ -585,7 +578,7 @@ theorem tryEvenTraceSplitAttemptsWith_uniformTable_none_le_geometric {F : Type*}
({ probe := fun _q _factor _attempt ↦ h } : ProbeFamily F) g 0 = none} *
((2 : ℝ≥0∞)⁻¹) ^ attempts := by
rw [ENNReal.tsum_mul_right]
congr 1
refine congrArg (· * ((2 : ℝ≥0∞)⁻¹) ^ attempts) ?_
rw [PMF.toOuterMeasure_apply]
apply tsum_congr
intro h
Expand Down
Loading