P857_T1_LeftLoopBudgetTransition

Lean checked

Statement

This explanation was written alongside the formalization to describe the statement and its reasoning.

Lemma · Left-loop budget transition

For every j\in\mathbb N, p,q\in\mathbb Z, and z,z'\in\mathbb N, assume -324\le p\le0 and the seven implications in this table:
\begin{array}{c|c} \text{condition}&\text{bound}\\ p\le-19&18j-p\le324\\ -18\le p\le-2&j\le17\\ p=-1,\ z<7&j\le18\\ p=-1,\ z\ge7&j\le19\\ p=0,\ z\le2&j\le19\\ p=0,\ 3\le z<5&j\le20\\ p=0,\ z\ge5&j\le21. \end{array}
Assume also the correlated transition clauses
\begin{aligned} p\le-19&\implies q=p+18\ \text{or}\ q=p+19,\\ -18\le p<0&\implies q\in\{-1,0\},\\ p=-1,\ q=-1&\implies z'\ge7,\\ p=-1,\ z\ge7&\implies q=0,\ z'\ge5,\\ p=0&\implies z<5,\ q=0,\ (z\le2\implies z'\ge3),\ (z\ge3\implies z'\ge5). \end{aligned}
Then both of the following hold. The current state belongs to at least one of the seven regimes
\begin{gathered} (p\le-19,\ j\le16),\quad (-18\le p\le-2,\ j\le17),\\ (p=-1,\ z<7,\ j\le18),\quad(p=-1,\ z\ge7,\ j\le19),\\ (p=0,\ z\le2,\ j\le19),\quad (p=0,\ 3\le z<5,\ j\le20),\quad (p=0,\ z\ge5,\ j\le21). \end{gathered}
Moreover all seven implications in the table hold after simultaneously replacing (j,p,z) by (j+1,q,z').

Lean statement

Trellis authored these statements and proofs. Lean checks the formal proofs; the assumptions used by each proof are listed below.

import Tablet.Preamble
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P857_T1_LeftLoopBudgetTransition]
theorem P857_T1_LeftLoopBudgetTransition (j : Nat) (p q : Int) (z z' : Nat)
    (hpLo : -324 ≤ p) (hpHi : p ≤ 0)
    (hb1 : p ≤ -19 → 18 * (j : Int) - p ≤ 324)
    (hb2 : -18 ≤ p → p ≤ -2 → j ≤ 17)
    (hb3 : p = -1 → z < 7 → j ≤ 18)
    (hb4 : p = -1 → 7 ≤ z → j ≤ 19)
    (hb5 : p = 0 → z ≤ 2 → j ≤ 19)
    (hb6 : p = 0 → 3 ≤ z → z < 5 → j ≤ 20)
    (hb7 : p = 0 → 5 ≤ z → j ≤ 21)
    (hlarge : p ≤ -19 → q = p + 18 ∨ q = p + 19)
    (hsmall : -18 ≤ p → p < 0 → q = -1 ∨ q = 0)
    (hminus : p = -1 → q = -1 → 7 ≤ z')
    (hminusLarge : p = -1 → 7 ≤ z → q = 0 ∧ 5 ≤ z')
    (hzero : p = 0 → z < 5 ∧ q = 0 ∧
      (z ≤ 2 → 3 ≤ z') ∧ (3 ≤ z → 5 ≤ z')) :
    ((p ≤ -19 ∧ j ≤ 16) ∨
      (-18 ≤ p ∧ p ≤ -2 ∧ j ≤ 17) ∨
      (p = -1 ∧ z < 7 ∧ j ≤ 18) ∨
      (p = -1 ∧ 7 ≤ z ∧ j ≤ 19) ∨
      (p = 0 ∧ z ≤ 2 ∧ j ≤ 19) ∨
      (p = 0 ∧ 3 ≤ z ∧ z < 5 ∧ j ≤ 20) ∨
      (p = 0 ∧ 5 ≤ z ∧ j ≤ 21)) ∧
    ((q ≤ -19 → 18 * ((j + 1 : Nat) : Int) - q ≤ 324) ∧
      (-18 ≤ q → q ≤ -2 → j + 1 ≤ 17) ∧
      (q = -1 → z' < 7 → j + 1 ≤ 18) ∧
      (q = -1 → 7 ≤ z' → j + 1 ≤ 19) ∧
      (q = 0 → z' ≤ 2 → j + 1 ≤ 19) ∧
      (q = 0 → 3 ≤ z' → z' < 5 → j + 1 ≤ 20) ∧
      (q = 0 → 5 ≤ z' → j + 1 ≤ 21)) := by
Proof

Natural-language proof

The status above describes the Lean proof. Its explanatory prose may remain a sketch after that proof closes.

Explanatory prose status

Prose retained as authored. The explanatory prose is preserved as it stood when captured.

Proof

Split the interval -324\le p\le0 at -19,-2,-1,0, and split the natural head at the displayed thresholds. In the first regime, 18j\le324+p\le305, hence j\le16. Every other regime's bound is exactly its assumed budget. This proves the asserted disjunction.
Consider these seven source regimes in order. In the first, 18(j+1)-q is 18j-p or 18j-p-1, so its successor first budget holds; also j+1\le17, sufficient for every other successor budget. In the second, q=-1 or 0 and j+1\le18. The first two successor conditions are impossible, and every other bound is at least 18. In the third, j+1\le19 and again q=-1 or 0. If q=-1, its head is at least seven, excluding the budget of 18; all remaining applicable budgets permit at least 19. In the fourth, q=0, z'\ge5 and j+1\le20, so only the last successor condition can hold, with permitted bound 21. In the fifth, q=0, z'\ge3 and j+1\le20, so only the last two successor conditions can hold, permitting 20 and 21. In the sixth, q=0, z'\ge5 and j+1\le21, giving the last budget and excluding all other successor conditions. The seventh source regime is impossible under the continuation clauses: at p=0 they require z<5. These cases prove all seven successor implications, as well as retaining the source disjunction.

Lean proof


  have hsource :
      (p ≤ -19 ∧ j ≤ 16) ∨
      (-18 ≤ p ∧ p ≤ -2 ∧ j ≤ 17) ∨
      (p = -1 ∧ z < 7 ∧ j ≤ 18) ∨
      (p = -1 ∧ 7 ≤ z ∧ j ≤ 19) ∨
      (p = 0 ∧ z ≤ 2 ∧ j ≤ 19) ∨
      (p = 0 ∧ 3 ≤ z ∧ z < 5 ∧ j ≤ 20) ∨
      (p = 0 ∧ 5 ≤ z ∧ j ≤ 21) := by
    by_cases hp : p ≤ -19
    · have h := hb1 hp
      exact Or.inl ⟨hp, by omega⟩
    · by_cases hpm : p ≤ -2
      · exact Or.inr (Or.inl ⟨by omega, hpm, hb2 (by omega) hpm⟩)
      · by_cases hm : p = -1
        · by_cases hz : z < 7
          · exact Or.inr (Or.inr (Or.inl ⟨hm, hz, hb3 hm hz⟩))
          · exact Or.inr (Or.inr (Or.inr (Or.inl
              ⟨hm, by omega, hb4 hm (by omega)⟩)))
        · have hp0 : p = 0 := by omega
          by_cases hz2 : z ≤ 2
          · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inl
              ⟨hp0, hz2, hb5 hp0 hz2⟩))))
          · by_cases hz5 : 5 ≤ z
            · right; right; right; right; right; right
              exact ⟨hp0, hz5, hb7 hp0 hz5⟩
            · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl
                ⟨hp0, by omega, by omega, hb6 hp0 (by omega) (by omega)⟩)))))
  refine ⟨hsource, ?_⟩
  rcases hsource with ⟨hp, hj⟩ | ⟨hplo, hphi, hj⟩ |
    ⟨hp, hz, hj⟩ | ⟨hp, hz, hj⟩ | ⟨hp, hz, hj⟩ |
    ⟨hp, hzlo, hzhi, hj⟩ | ⟨hp, hz, hj⟩
  · have hnext := hlarge hp
    have hbudget := hb1 hp
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hsmall hplo (by omega)
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hsmall (by omega) (by omega)
    have hhead := hminus hp
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨hq, hz'⟩ := hminusLarge hp hz
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨_, hq, hsmallHead, _⟩ := hzero hp
    have hz' := hsmallHead hz
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨_, hq, _, hlargeHead⟩ := hzero hp
    have hz' := hlargeHead hzlo
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hzero hp
    omega

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.Preamble
set_option autoImplicit false
namespace dec2flt_model

-- [TABLET NODE: P857_T1_LeftLoopBudgetTransition]
theorem P857_T1_LeftLoopBudgetTransition (j : Nat) (p q : Int) (z z' : Nat)
    (hpLo : -324 ≤ p) (hpHi : p ≤ 0)
    (hb1 : p ≤ -19 → 18 * (j : Int) - p ≤ 324)
    (hb2 : -18 ≤ p → p ≤ -2 → j ≤ 17)
    (hb3 : p = -1 → z < 7 → j ≤ 18)
    (hb4 : p = -1 → 7 ≤ z → j ≤ 19)
    (hb5 : p = 0 → z ≤ 2 → j ≤ 19)
    (hb6 : p = 0 → 3 ≤ z → z < 5 → j ≤ 20)
    (hb7 : p = 0 → 5 ≤ z → j ≤ 21)
    (hlarge : p ≤ -19 → q = p + 18 ∨ q = p + 19)
    (hsmall : -18 ≤ p → p < 0 → q = -1 ∨ q = 0)
    (hminus : p = -1 → q = -1 → 7 ≤ z')
    (hminusLarge : p = -1 → 7 ≤ z → q = 0 ∧ 5 ≤ z')
    (hzero : p = 0 → z < 5 ∧ q = 0 ∧
      (z ≤ 2 → 3 ≤ z') ∧ (3 ≤ z → 5 ≤ z')) :
    ((p ≤ -19 ∧ j ≤ 16) ∨
      (-18 ≤ p ∧ p ≤ -2 ∧ j ≤ 17) ∨
      (p = -1 ∧ z < 7 ∧ j ≤ 18) ∨
      (p = -1 ∧ 7 ≤ z ∧ j ≤ 19) ∨
      (p = 0 ∧ z ≤ 2 ∧ j ≤ 19) ∨
      (p = 0 ∧ 3 ≤ z ∧ z < 5 ∧ j ≤ 20) ∨
      (p = 0 ∧ 5 ≤ z ∧ j ≤ 21)) ∧
    ((q ≤ -19 → 18 * ((j + 1 : Nat) : Int) - q ≤ 324) ∧
      (-18 ≤ q → q ≤ -2 → j + 1 ≤ 17) ∧
      (q = -1 → z' < 7 → j + 1 ≤ 18) ∧
      (q = -1 → 7 ≤ z' → j + 1 ≤ 19) ∧
      (q = 0 → z' ≤ 2 → j + 1 ≤ 19) ∧
      (q = 0 → 3 ≤ z' → z' < 5 → j + 1 ≤ 20) ∧
      (q = 0 → 5 ≤ z' → j + 1 ≤ 21)) := by
-- BODY
  have hsource :
      (p ≤ -19 ∧ j ≤ 16) ∨
      (-18 ≤ p ∧ p ≤ -2 ∧ j ≤ 17) ∨
      (p = -1 ∧ z < 7 ∧ j ≤ 18) ∨
      (p = -1 ∧ 7 ≤ z ∧ j ≤ 19) ∨
      (p = 0 ∧ z ≤ 2 ∧ j ≤ 19) ∨
      (p = 0 ∧ 3 ≤ z ∧ z < 5 ∧ j ≤ 20) ∨
      (p = 0 ∧ 5 ≤ z ∧ j ≤ 21) := by
    by_cases hp : p ≤ -19
    · have h := hb1 hp
      exact Or.inl ⟨hp, by omega⟩
    · by_cases hpm : p ≤ -2
      · exact Or.inr (Or.inl ⟨by omega, hpm, hb2 (by omega) hpm⟩)
      · by_cases hm : p = -1
        · by_cases hz : z < 7
          · exact Or.inr (Or.inr (Or.inl ⟨hm, hz, hb3 hm hz⟩))
          · exact Or.inr (Or.inr (Or.inr (Or.inl
              ⟨hm, by omega, hb4 hm (by omega)⟩)))
        · have hp0 : p = 0 := by omega
          by_cases hz2 : z ≤ 2
          · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inl
              ⟨hp0, hz2, hb5 hp0 hz2⟩))))
          · by_cases hz5 : 5 ≤ z
            · right; right; right; right; right; right
              exact ⟨hp0, hz5, hb7 hp0 hz5⟩
            · exact Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl
                ⟨hp0, by omega, by omega, hb6 hp0 (by omega) (by omega)⟩)))))
  refine ⟨hsource, ?_⟩
  rcases hsource with ⟨hp, hj⟩ | ⟨hplo, hphi, hj⟩ |
    ⟨hp, hz, hj⟩ | ⟨hp, hz, hj⟩ | ⟨hp, hz, hj⟩ |
    ⟨hp, hzlo, hzhi, hj⟩ | ⟨hp, hz, hj⟩
  · have hnext := hlarge hp
    have hbudget := hb1 hp
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hsmall hplo (by omega)
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hsmall (by omega) (by omega)
    have hhead := hminus hp
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨hq, hz'⟩ := hminusLarge hp hz
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨_, hq, hsmallHead, _⟩ := hzero hp
    have hz' := hsmallHead hz
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · obtain ⟨_, hq, _, hlargeHead⟩ := hzero hp
    have hz' := hlargeHead hzlo
    refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ <;> intros <;> omega
  · have hnext := hzero hp
    omega

end dec2flt_model

Proof structure

Follow the declared dependencies to read the supporting statements and proofs.

Explore this dependency tree

Inspect related source (44)
More program dependencies (11)
Standard-library dependencies (30)

Related source and models come from the extraction records and declared dependencies.

Proof assumptions and review

Lean checks the formal proof. Trellis also reviews how the statement corresponds to the intended requirement.

Transitive assumptions

This list combines the assumptions recorded for this declaration and its dependencies. It may include assumptions used by auxiliary declarations in those modules.

Helper theorems included
Technical checking records
Local closure summary
{
  "node": "P857_T1_LeftLoopBudgetTransition",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "fc1a426c218af024dce7b7a1b7374bb99d14f8d10f03c518b16491a6ad7bf8cd",
  "active_statement_hash": "0290e40e805b232ab23d06d78620a8fe3866640c7900afd3f666ae4d965103fd",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "576e6bf9480cfd32f53c309c7ac8fb115c1ba6e413f299ed5ff9fa7c647e6769",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-198",
  "boundary_theorems": {},
  "strict_theorem_deps": {},
  "strict_definition_deps": {}
}
Prose assessment
{
  "label": "Lean proof closed; predictive prose review no longer required",
  "assessment_status": null,
  "fingerprint_relation": "unknown",
  "assessment_fingerprint": null,
  "current_fingerprint": "sound-v2:c12a1e40480365a84a006c3b3867ca95b347883a129f4c8066e38a49fd66f502",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass"
}