PositiveScaleErrorTransport

Lean checked

Statement

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

Lemma · Positive-scale error and comparison transport

Let s,X,V,V',\eta,u,\rho be real numbers satisfying
s>0,\qquad X=V+\eta,\qquad V'=sV-\rho, \qquad 0\le\eta<u,\qquad 0\le\rho.
Set \eta'=\rho+s\eta and u'=\rho+su. Then
sX=V'+\eta',\quad 0\le\eta'<u',\quad V'+u'=s(V+u),
and
0<\eta'\quad\Longleftrightarrow\quad 0<\rho\ \text{ or }\ 0<\eta.
For every real H, multiplication by s also preserves and reflects all three comparisons: X<H, X=H, and H<X.

Lean statement

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

import Tablet.DecimalGoalVocabularyDefault
import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: PositiveScaleErrorTransport]
theorem PositiveScaleErrorTransport
    (s X V V' eta u rho : Real)
    (hs : 0 < s)
    (hX : X = V + eta)
    (hV' : V' = s * V - rho)
    (heta0 : 0 <= eta)
    (hetau : eta < u)
    (hrho0 : 0 <= rho) :
    let eta' := rho + s * eta
    let u' := rho + s * u
    s * X = V' + eta' /\
      0 <= eta' /\ eta' < u' /\
      V' + u' = s * (V + u) /\
      (0 < eta' <-> 0 < rho \/ 0 < eta) /\
      (forall H : Real,
        (X < H <-> s * X < s * H) /\
        (X = H <-> s * X = s * H) /\
        (H < X <-> s * H < s * X)) := 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

Substitution of X=V+\eta and V'=sV-\rho gives
V'+\eta'=sV-\rho+\rho+s\eta=s(V+\eta)=sX
and
V'+u'=sV-\rho+\rho+su=s(V+u).
Both terms in \eta'=\rho+s\eta are nonnegative, because \rho,\eta are nonnegative and s is positive. Thus 0\le\eta'. Multiplying \eta<u by s>0 and adding \rho gives \eta'<u'.
If \eta'>0 while neither \rho nor \eta is positive, their nonnegativity forces \rho=\eta=0, contradicting \eta'>0. Conversely, \rho>0 makes the first nonnegative summand of \eta' positive, and \eta>0 makes s\eta>0; either case gives \eta'>0.
Finally, if X<H, then H-X>0, so s(H-X)>0 and hence sX<sH. Conversely, if sX<sH but X\not<H, then X-H\ge0, whence s(X-H)\ge0, a contradiction. The proof for H<X is the same with X and H interchanged. Equality is preserved by congruence, and reflected because sX=sH with s>0 implies s(X-H)=0 and therefore X-H=0.

Lean proof


  dsimp
  constructor
  · rw [hX, hV']
    ring
  constructor
  · positivity
  constructor
  · nlinarith
  constructor
  · rw [hV']
    ring
  constructor
  · constructor
    · intro h
      by_contra hn
      push Not at hn
      nlinarith
    · rintro (h | h)
      · nlinarith
      · nlinarith
  · intro H
    constructor
    · constructor
      · intro h
        have hp : 0 < s * (H - X) := mul_pos hs (sub_pos.mpr h)
        nlinarith
      · intro h
        by_contra hn
        have hp : 0 <= s * (X - H) :=
          mul_nonneg hs.le (sub_nonneg.mpr (le_of_not_gt hn))
        nlinarith
    constructor
    · constructor
      · intro h
        simpa [h]
      · intro h
        nlinarith
    · constructor
      · intro h
        have hp : 0 < s * (X - H) := mul_pos hs (sub_pos.mpr h)
        nlinarith
      · intro h
        by_contra hn
        have hp : 0 <= s * (H - X) :=
          mul_nonneg hs.le (sub_nonneg.mpr (le_of_not_gt hn))
        nlinarith

end dec2flt_model

Download Lean source · Download TeX source

Complete Lean module
import Tablet.DecimalGoalVocabularyDefault
import Tablet.Preamble

open Aeneas Aeneas.Std Result ControlFlow Error
set_option autoImplicit false

namespace dec2flt_model

-- [TABLET NODE: PositiveScaleErrorTransport]
theorem PositiveScaleErrorTransport
    (s X V V' eta u rho : Real)
    (hs : 0 < s)
    (hX : X = V + eta)
    (hV' : V' = s * V - rho)
    (heta0 : 0 <= eta)
    (hetau : eta < u)
    (hrho0 : 0 <= rho) :
    let eta' := rho + s * eta
    let u' := rho + s * u
    s * X = V' + eta' /\
      0 <= eta' /\ eta' < u' /\
      V' + u' = s * (V + u) /\
      (0 < eta' <-> 0 < rho \/ 0 < eta) /\
      (forall H : Real,
        (X < H <-> s * X < s * H) /\
        (X = H <-> s * X = s * H) /\
        (H < X <-> s * H < s * X)) := by
-- BODY
  dsimp
  constructor
  · rw [hX, hV']
    ring
  constructor
  · positivity
  constructor
  · nlinarith
  constructor
  · rw [hV']
    ring
  constructor
  · constructor
    · intro h
      by_contra hn
      push Not at hn
      nlinarith
    · rintro (h | h)
      · nlinarith
      · nlinarith
  · intro H
    constructor
    · constructor
      · intro h
        have hp : 0 < s * (H - X) := mul_pos hs (sub_pos.mpr h)
        nlinarith
      · intro h
        by_contra hn
        have hp : 0 <= s * (X - H) :=
          mul_nonneg hs.le (sub_nonneg.mpr (le_of_not_gt hn))
        nlinarith
    constructor
    · constructor
      · intro h
        simpa [h]
      · intro h
        nlinarith
    · constructor
      · intro h
        have hp : 0 < s * (X - H) := mul_pos hs (sub_pos.mpr h)
        nlinarith
      · intro h
        by_contra hn
        have hp : 0 <= s * (H - X) :=
          mul_nonneg hs.le (sub_nonneg.mpr (le_of_not_gt hn))
        nlinarith

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": "PositiveScaleErrorTransport",
  "closure_version": "patch_c_v1",
  "active_decl_hash": "7b443deb29e5aef77a40bfd26ee5143fe9a5f7148e33d0bef67785e3fdc6085b",
  "active_statement_hash": "5f3937d6bce325f6ccedae40c3d433b4a64f13cbb6af0c2e3d22e63ce0dcc808",
  "kernel_axioms": [
    "Classical.choice",
    "Quot.sound",
    "propext"
  ],
  "toolchain_hash": "ce4c4e3d87434b9663f46de25ce34b48a0cf0d392e0a320a0787b4674a2d7b61",
  "lean_executable_hash": "3e0d0d3d801675359f2d4cf9815bfdb417b20b92fdd9d48b3b14c95bbae28bbf",
  "checker_script_hash": "c8e4a03273e23b9a8f2e141020652a4e0b7b0a8ab0883366ea9d031ca3f37aa1",
  "approved_axioms_hash": "ab64d13f256386ee0e494a5abcc6a5db49512cf3d90bbdfcabd6327793a31f95",
  "axcheck_status": "Agreed",
  "accepted_at_snapshot_id": "worker-result-local-closure-issuance-cycle-155",
  "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:64070a5e787f999eb1fa8dc9ce7ae6ba9deb79639d4d960f8e26a31763a0a9b7",
  "superseded_for_theorem_closure": false
}
Review verdicts
{
  "corr_status": "Pass",
  "substantiveness_status": "Pass"
}