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
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,96 @@ def rectangle (row column : ℕ) : ℤ :=
theorem rectangle_eq (row column : ℕ) : rectangle row column = rectAreaZ row column := by
simp only [rectangle, contact_eq, eval_eq, rectAreaZ, rectLoZ, rectHiZ, rectHZ]

/-- Match the sign constructor before passing an integer to the next calculation. -/
def withInt (x : ℤ) (use : ℤ → α) : α :=
Int.casesOn x (fun n => use (Int.ofNat n)) (fun n => use (Int.negSucc n))

private theorem withInt_eq (x : ℤ) (use : ℤ → α) : withInt x use = use x := by
cases x <;> rfl

/-- Pass the four evaluated endpoints to the next step of an area sum. -/
def withContact (contact : SI × SI) (use : (SI × SI) → α) : α :=
withInt contact.1.lo fun xLo =>
withInt contact.1.hi fun xHi =>
withInt contact.2.lo fun yLo =>
withInt contact.2.hi fun yHi =>
use (⟨xLo, xHi⟩, ⟨yLo, yHi⟩)

private theorem withContact_eq (contact : SI × SI) (use : (SI × SI) → α) :
withContact contact use = use contact := by
rcases contact with ⟨⟨xLo, xHi⟩, ⟨yLo, yHi⟩⟩
simp only [withContact, withInt_eq]

/-- Traverse adjacent pairs, reusing the right contact as the next left contact. -/
def sumAdjacent (sample : ℕ → SI × SI) (area : ℕ → (SI × SI) → (SI × SI) → ℤ) :
(start : ℕ) → (left : SI × SI) → (length : ℕ) → ℤ
| _, _, 0 => 0
| start, left, length + 1 =>
withContact (sample (start + 1)) fun right =>
area start left right + sumAdjacent sample area (start + 1) right length

/-- The traversal adds the same terms as the independent evaluations. -/
theorem sumAdjacent_eq (sample : ℕ → SI × SI)
(area : ℕ → (SI × SI) → (SI × SI) → ℤ) (start length : ℕ) :
sumAdjacent sample area start (sample start) length =
((List.range' start length).map fun i => area i (sample i) (sample (i + 1))).sum := by
induction length generalizing start with
| zero => rfl
| succ length ih =>
simp only [sumAdjacent, withContact_eq, ih, List.range'_succ, List.map_cons, List.sum_cons]

/-- Compute a fan determinant using the contact points supplied by the traversal. -/
def crossFromContacts (center left right : SI × SI) : SI :=
sub (mul (sub left.1 center.1) (sub right.2 center.2))
(mul (sub left.2 center.2) (sub right.1 center.1))

/-- Sum the lower endpoints of a block of fan determinants. -/
def capBlock (start length : ℕ) : ℤ :=
withContact anchor fun center =>
withContact (fan start) fun left =>
sumAdjacent fan (fun _ left right => (crossFromContacts center left right).lo)
start left length

/-- The block sums the original lower endpoints. -/
theorem capBlock_eq (start length : ℕ) :
capBlock start length = ((List.range' start length).map fun i => (crossZ i).lo).sum := by
simp only [capBlock, withContact_eq, sumAdjacent_eq]
have terms : (fun i => (crossFromContacts anchor (fan i) (fan (i + 1))).lo) =
(fun i => (crossZ i).lo) := by
funext i
rw [← cross_eq]
rfl
rw [terms]

/-- Compute the area of a niche rectangle using its two supplied contacts. -/
def rectangleFromContacts (row index : ℕ) (left right : SI × SI) : ℤ :=
let lo := if rowFwd row then left.1.lo else right.1.lo
let hi := if rowFwd row then right.1.hi else left.1.hi
let height := imax (eval (stageOf (index + 1)) ⟨(ttZ index).lo, (ttZ (index + 1)).hi⟩
(rowKind row)).2.hi left.2.hi
imax 0 (hi - lo) * imax 0 height

/-- Sum an adjacent block of niche rectangles. -/
def nicheBlock (row start length : ℕ) : ℤ :=
let sample := fun column => contact (rowBase row column) (rowKind row)
withContact (sample start) fun left =>
sumAdjacent sample (fun column => rectangleFromContacts row (rowBase row column))
start left length

/-- The block sums the original covering rectangles. -/
theorem nicheBlock_eq (row start length : ℕ) :
nicheBlock row start length = ((List.range' start length).map (rectAreaZ row)).sum := by
simp only [nicheBlock, withContact_eq, sumAdjacent_eq]
have terms : (fun i => rectangleFromContacts row (rowBase row i)
(contact (rowBase row i) (rowKind row)) (contact (rowBase row (i + 1)) (rowKind row))) =
rectAreaZ row := by
funext i
rw [← rectangle_eq]
have next : rowBase row (i + 1) = rowBase row i + 1 := by
unfold rowBase
rw [Nat.add_assoc]
rw [next]
rfl
rw [terms]

end MovingSofa.GerverAreaCert.AreaReplay
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ private theorem replayLower_eq : replayLower = capLower := by
Decidable (blockSum capLower start length = expected) :=
decidable_of_iff (blockSum replayLower start length = expected) (by rw [replayLower_eq])

attribute [local instance 1100] decideBlock
@[instance_reducible] private def decideAdjacentBlock (start length : ℕ) (expected : ℤ) :
Decidable (blockSum capLower start length = expected) :=
decidable_of_iff (AreaReplay.capBlock start length = expected) (by
rw [AreaReplay.capBlock_eq]
rfl)

attribute [local instance 1100] decideAdjacentBlock

private theorem capBlock0 : blockSum capLower 0 64 = -333692128541 := by
decide +kernel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ private theorem rectangleBlockReplay_eq (row start length : ℕ) :
decidable_of_iff (rectangleBlockReplay row start length = expected)
(by rw [rectangleBlockReplay_eq])

attribute [local instance 1100] decideRectangleBlock
@[instance_reducible] private def decideAdjacentBlock (row start length : ℕ) (expected : ℤ) :
Decidable (rectangleBlock row start length = expected) :=
decidable_of_iff (AreaReplay.nicheBlock row start length = expected) (by
rw [AreaReplay.nicheBlock_eq]
rfl)

attribute [local instance 1100] decideAdjacentBlock

private theorem nicheRow0First : rectangleBlock 0 0 32 =
8845072297334670692780361894254852519218486529319646026 := by gerver_kernel_decide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch004`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch014`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch012`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch027`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch028`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch023`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch026`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch024`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch029`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch013`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch019`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch021`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch044`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch020`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch022`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch025`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch030`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch031`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch032`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch043`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch034`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public import LeanPool.MovingSofa.GerverSofa.KernelOnly.Core.Bundle005
* `GerverSofa.KernelOnly.PartE.Certificates.Batch035`.
-/

-- Replay closed rejections with the exact shift-based binary-grid evaluator.
-- Try the bounded Taylor evaluator before full interval replay.
attribute [local instance 1100]
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShiftedGrid.decidableRejected
GerverSofa.PartE.FixedPointResiduals.BinaryGrid.ShortTaylor.decidableRejected

@[expose] public section

Expand Down
Loading
Loading