Skip to content

Commit cff8acf

Browse files
kim-emKim Morrison
authored andcommitted
feat(interval): certify a bounded raster graph
1 parent d927928 commit cff8acf

6 files changed

Lines changed: 550 additions & 1 deletion

File tree

HexInterval/SPEC/hex-interval.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,18 @@ bytes plus a certified mask or classification table; a small checker validates
33053305
that the bytes encode that table. Kernel replay proves the coverage/disjointness
33063306
theorem from shared interval derivations, not from the PNG decoder.
33073307

3308+
The bounded prototype fixes this proof boundary concretely. `VerifiedRaster`
3309+
defines a finite row-major mask of exact dyadic rectangles and `Correct` as the
3310+
pair of coverage and blank-disjointness propositions. Its 2-by-2 conformance
3311+
fixture runs the opaque centered-function package on `[0,1]`, replays the live
3312+
`[0,1/4]` range event through the generic proof emitter, and certifies the mask
3313+
over `[0,1] × [0,1/2]`. Internal cuts are assigned exactly: the left column
3314+
and upper row are open at their shared boundary, while the right column and
3315+
lower row are closed there. The two lower pixels are marked and the two upper
3316+
pixels are proved blank. This prototype deliberately stops at the finite mask;
3317+
adaptive column refinement and validation that external raster bytes encode
3318+
that mask remain renderer work rather than assumptions of the Lean theorem.
3319+
33083320
The ordinary framework supplies all required search mechanisms: arbitrary
33093321
function propagators bound the range; instantiation introduces centered forms,
33103322
range reductions, derivatives, or continuity witnesses when useful; local
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/-
2+
Copyright (c) 2026 Lean FRO, LLC. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Kim Morrison
5+
-/
6+
7+
module
8+
9+
public import HexIntervalMathlib.Experiment.DyadicInterval
10+
11+
@[expose] public section
12+
13+
/-!
14+
# Proof objects for conservative raster graphs
15+
16+
This module states what a verified rasterizer must prove. It does not know
17+
which functions the interval engine supports, how search chooses subdivisions,
18+
or how a bitmap is encoded. A function package supplies interval theorems; a
19+
raster assembly proves that every graph point over the horizontal viewport is
20+
inside a marked pixel and that every blank pixel is disjoint from the graph.
21+
22+
Marked pixels are deliberately allowed to be conservative: `Correct` does not
23+
claim that every marked pixel is hit. A PNG or other image is an untrusted
24+
rendering of the finite `Raster.cells` mask, not part of the proof boundary.
25+
-/
26+
27+
namespace Hex.Interval.Experiment.VerifiedRaster
28+
29+
open DyadicInterval
30+
31+
/-- One rectangular pixel, with exact open or closed boundaries inherited
32+
from its dyadic interval facts. -/
33+
structure Pixel where
34+
x : Fact
35+
y : Fact
36+
marked : Bool
37+
deriving DecidableEq
38+
39+
/-- Exact membership in one pixel rectangle. -/
40+
def Pixel.Contains (pixel : Pixel) (x y : ℝ) : Prop :=
41+
pixel.x.Contains x ∧ pixel.y.Contains y
42+
43+
/-- A finite row-major mask and its exact mathematical viewport. `shape`
44+
binds the flat mask to its declared dimensions; rendering may choose any
45+
external image format which preserves this order and the `marked` bits. -/
46+
structure Raster where
47+
width : Nat
48+
height : Nat
49+
xViewport : Fact
50+
yViewport : Fact
51+
cells : List Pixel
52+
shape : cells.length = width * height
53+
54+
/-- Every graph point over the horizontal viewport is enclosed by at least one
55+
marked pixel. This stronger form also proves that the graph stays inside the
56+
vertical viewport whenever all listed pixels do. -/
57+
def Covers (raster : Raster) (f : ℝ → ℝ) : Prop :=
58+
∀ x, raster.xViewport.Contains x →
59+
∃ pixel, pixel ∈ raster.cells ∧ pixel.marked = true ∧
60+
pixel.Contains x (f x)
61+
62+
/-- Every pixel rendered blank is disjoint from the graph. The horizontal
63+
premise is local to the pixel, so this property remains useful even when a
64+
raster covers only part of a larger function domain. -/
65+
def Excludes (raster : Raster) (f : ℝ → ℝ) : Prop :=
66+
∀ pixel, pixel ∈ raster.cells → pixel.marked = false →
67+
∀ x, pixel.x.Contains x → ¬pixel.y.Contains (f x)
68+
69+
/-- Every rendered cell lies within the declared viewport. This prevents the
70+
finite mask from proving a graph enclosure over one rectangle while labelling
71+
it as an unrelated viewport. -/
72+
def Contained (raster : Raster) : Prop :=
73+
∀ pixel, pixel ∈ raster.cells → ∀ x y, pixel.Contains x y →
74+
raster.xViewport.Contains x ∧ raster.yViewport.Contains y
75+
76+
/-- Sound conservative graph rendering. It intentionally omits the stronger
77+
and usually false assertion that every marked pixel contains a graph point. -/
78+
structure Correct (raster : Raster) (f : ℝ → ℝ) : Prop where
79+
contained : Contained raster
80+
covers : Covers raster f
81+
excludes : Excludes raster f
82+
83+
end Hex.Interval.Experiment.VerifiedRaster

0 commit comments

Comments
 (0)