Cairn · module

Cairn.Layout.Check

lean/Cairn/Layout/Check.lean

Checking Pressable by evaluation

Pressable w l (Bridge.lean) is stated with Laid.Everywhere, an inductive Prop, so it can't be decided directly. This file gives each condition a Bool twin and proves the twin sound, so for a concrete view, window and metrics an app proves every control pressable with by decide +kernel (the kernel evaluates the layout; no compiler, no extra axiom):

theorem pressable : ∀ t ∈ targets (layout m w v), hitTest (layout m w v) t.visible.center = some t.control :=
  hitTest_center_of_check (by decide +kernel)

Imports Cairn.Layout.Bridge

Order

Definitions 10

def

Cairn.Layout.insideB

lean/Cairn/Layout/Check.lean:21
insideB (r o : Rect) : Bool
def

Cairn.Layout.padB

lean/Cairn/Layout/Check.lean:25
padB (p : Insets) : Bool
def

Cairn.Layout.fitsB

lean/Cairn/Layout/Check.lean:28
fitsB : Laid → Bool
def

Cairn.Layout.stackTopB

lean/Cairn/Layout/Check.lean:42
stackTopB : Laid → Bool
def

Cairn.Layout.controlLeafB

lean/Cairn/Layout/Check.lean:46
controlLeafB : Laid → Bool
def

Cairn.Layout.allB

lean/Cairn/Layout/Check.lean:52
allB (p : Laid → Bool) : Laid → Bool

p holds at every node.

def

Cairn.Layout.allListB

lean/Cairn/Layout/Check.lean:56
allListB (p : Laid → Bool) : List Laid → Bool
def

Cairn.Layout.checkPressable

lean/Cairn/Layout/Check.lean:62
checkPressable (w : Size) (l : Laid) : Bool

Every condition of Pressable, evaluated.

def

Cairn.Layout.controlsNonempty

lean/Cairn/Layout/Check.lean:66
controlsNonempty (l : Laid) : Bool

Every control's visible part (rect ∩ clip) is nonempty.

def

Cairn.Layout.controlRectsNonempty

lean/Cairn/Layout/Check.lean:72
controlRectsNonempty (l : Laid) : Bool

Every control's rect is nonempty. Its visible part may still be empty under a scroll box (scrolled out of view), where the fuzzer checks only the controls it can see; anywhere else a tree that passes checkPressable shows each control whole (visible_eq_rect).

Theorems 8

theorem

Cairn.Layout.inside_of_insideB

provedlean/Cairn/Layout/Check.lean:77
inside_of_insideB {r o : Rect} (h : insideB r o = true) : r.inside o
theorem

Cairn.Layout.everywhere_of_allB

provedlean/Cairn/Layout/Check.lean:82
everywhere_of_allB {p : Laid → Bool} {P : Laid → Prop}
  (hp : ∀ (l : Laid), p l = true → P l) (l : Laid) : allB p l = true → Laid.Everywhere P l
theorem

Cairn.Layout.everywhere_of_allListB

provedlean/Cairn/Layout/Check.lean:89
everywhere_of_allListB {p : Laid → Bool} {P : Laid → Prop}
  (hp : ∀ (l : Laid), p l = true → P l) (ks : List Laid) :
  allListB p ks = true → ∀ (k : Laid), k ∈ ks → Laid.Everywhere P k
theorem

Cairn.Layout.fits_of_fitsB

provedlean/Cairn/Layout/Check.lean:99
fits_of_fitsB (l : Laid) : fitsB l = true → Fits l
theorem

Cairn.Layout.stackTop_of_stackTopB

provedlean/Cairn/Layout/Check.lean:113
stackTop_of_stackTopB (l : Laid) : stackTopB l = true → StackTop l
theorem

Cairn.Layout.controlLeaf_of_controlLeafB

provedlean/Cairn/Layout/Check.lean:124
controlLeaf_of_controlLeafB (l : Laid) : controlLeafB l = true → ControlLeaf l
theorem

Cairn.Layout.pressable_of_check

provedlean/Cairn/Layout/Check.lean:132
pressable_of_check {w : Size} {l : Laid} (h : checkPressable w l = true) :
  Pressable w l

The checker is sound.

theorem

Cairn.Layout.hitTest_center_of_check

provedlean/Cairn/Layout/Check.lean:141
hitTest_center_of_check {m : TextMetrics} {w : Size} {n : Node}
  (h : (checkPressable w (layout m w n) && controlsNonempty (layout m w n)) = true)
  (t : Runtime.Target) :
  t ∈ Runtime.targets (layout m w n) →
    Runtime.hitTest (layout m w n) t.visible.center = some t.control

Every control is pressable at its centre, for a laid-out view the checker accepts: the centre of its visible part, which the checker asks to be nonempty.