Fold the clamped branch into the positive rule
On a clamped nonpositive begin the reference clamped rule `compactClamped` and the positive rule `compactPositive` coincide: the begin offset is nonpositive, so `residualB = 0`, and the reversed-truncated rule collapses to its no-skip case. So `closedForm` now dispatches on `1 ≤ r.begin.offset ∨ clampedNonpos r res` and drops `closedFormClamped`, `closedFormNonposRevTrunc` and `nonposRevReduced`, together with their bridges. `closedForm_eq` splits explicitly on the positive and clamped regions, using the new reference lemmas `ref_closedFormNonposRevTrunc_eq` and `ref_compactClamped_eq_compactPositive`. The headlines, their statements and the comparator inputs are unchanged.
This commit is contained in:
1 parent
efd1b323e7
commit
6cfdb13da1
3 files changed
+66
-99
No files matched your search
+16
-22
@@ -26,18 +26,18 @@ The closed form is a total, result-aware dispatch:
|
||||
|
||||
```
|
||||
closedForm r res =
|
||||
if res.keys = [] then emptyValue r
|
||||
else if 1 ≤ r.begin.offset then closedFormPositive r res
|
||||
else if clampedNonpos r res then closedFormClamped r res
|
||||
else closedFormCrossed r res
|
||||
if res.keys = [] then emptyValue r
|
||||
else if 1 ≤ r.begin.offset ∨ clampedNonpos r res then closedFormPositive r res
|
||||
else closedFormCrossed r res
|
||||
```
|
||||
|
||||
`emptyValue` handles the empty result. `closedFormPositive` and
|
||||
`closedFormClamped` dispatch through `closedFormSplit` on whether the result is
|
||||
complete and, when it is not, on the direction. `closedFormCrossed` is the
|
||||
residual: nonempty, nonpositive-begin reads outside the clamped case, handled by
|
||||
a priority table over complete results and the two `more = true` cases (forward
|
||||
and reversed), split by `reverse`, `end_.offset ≤ 1` and a few capacity tests.
|
||||
`emptyValue` handles the empty result. Positive begin offsets and clamped
|
||||
nonpositive begin offsets share one rule, `closedFormPositive`, which dispatches
|
||||
through `closedFormSplit` on whether the result is complete and, when it is not,
|
||||
on the direction. `closedFormCrossed` is the residual: nonempty,
|
||||
nonpositive-begin reads outside the clamped case, handled by a priority table
|
||||
over complete results and the two `more = true` cases (forward and reversed),
|
||||
split by `reverse`, `end_.offset ≤ 1` and a few capacity tests.
|
||||
Every leaf of the table is a literal half-open interval built from `begin.key`,
|
||||
`end_.key`, the reported head or last key, `keyAfter`, or `⊤`; there is no search
|
||||
and no oracle. That is the sense in which it is a *closed form*.
|
||||
@@ -686,12 +686,6 @@ def closedFormOffsetOneTotal (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
else completeClosed r res
|
||||
else closedFormOffsetOneUniversal r res
|
||||
|
||||
def nonposRevReduced (r : RangeRead) (res : Result) : RangeRead :=
|
||||
{ r with begin := { key := last res, offset := 1 } }
|
||||
|
||||
def closedFormNonposRevTrunc (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
closedFormOffsetOneTotal (nonposRevReduced r res) res
|
||||
|
||||
def closedFormZeroCrossEndOneLong (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
range (↑(leastReported r res)) r.begin.key
|
||||
|
||||
@@ -885,12 +879,12 @@ def closedFormReverseTruncated (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
|
||||
/-! ### Positive and clamped branches -/
|
||||
|
||||
/-- The non-crossed rule. It covers every nonempty result at a positive begin
|
||||
offset, and also every clamped nonpositive begin offset, where the begin clamps
|
||||
to the empty key and the reversed-truncated rule reduces to the no-skip case. -/
|
||||
def closedFormPositive (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
closedFormSplit closedFormReverseTruncated r res
|
||||
|
||||
def closedFormClamped (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
closedFormSplit closedFormNonposRevTrunc r res
|
||||
|
||||
/-! ### Crossed table -/
|
||||
|
||||
@[reducible] def overshoot (r : RangeRead) (res : Result) : Prop :=
|
||||
@@ -1111,11 +1105,11 @@ def closedFormCrossed (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
/-! ### Dispatch -/
|
||||
|
||||
/-- The closed form. The empty result is handled first, so every branch below
|
||||
is reached only with `res.keys ≠ []`. -/
|
||||
is reached only with `res.keys ≠ []`. Positive and clamped nonpositive begin
|
||||
offsets share the one rule `closedFormPositive`. -/
|
||||
def closedForm (r : RangeRead) (res : Result) : ConflictRange :=
|
||||
if res.keys = [] then emptyValue r
|
||||
else if 1 ≤ r.begin.offset then closedFormPositive r res
|
||||
else if clampedNonpos r res then closedFormClamped r res
|
||||
else if 1 ≤ r.begin.offset ∨ clampedNonpos r res then closedFormPositive r res
|
||||
else closedFormCrossed r res
|
||||
|
||||
/-! ## The headlines -/
|
||||
|
||||
Reference in new issue
Block a user