feat(Units): component lemmas for the Exponent power of a dimension - #1600
feat(Units): component lemmas for the Exponent power of a dimension#1600NicolasRouquette wants to merge 1 commit into
Conversation
`Pow (Dimension B) Exponent` is the default instance, so an unascribed numeric exponent — `d ^ 2`, `d ^ (1/2)` — elaborates to an `Exponent` power rather than to the `ℕ` one. The named component lemmas `npow_length`, `npow_time`, … match the `ℕ` power only, so `simp` could not reach a goal about the component of such a power. Add the `Exponent`-power twins `epow_length`, `epow_time`, `epow_mass`, `epow_charge`, `epow_temperature`, derived through a `component_epow` helper mirroring the existing `component_npow`. The `ℕ` power is unaffected. Closes leanprover-community#1580. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thank you for this pull-request (PR). If this is your first PR, welcome to the community! Below is what will happen next. Please read carefully if you are not familiar with the process. You may open other PRs while this one is being reviewed, and can stack PRs on top of each other, so don't let these steps slow you down.
Tip: The easiest way to get have a fast review is to submit a PR that is small and self-contained, and has clear documentation explaining why things are the way they are in your chages. If you have any problems or questions, please reach out to the community on the Zulip. |
jstoobysmith
left a comment
There was a problem hiding this comment.
One small comment from me
| _ = n • d.exponent b := npow_exponent d n b | ||
| _ = n • component d := congrArg (n • ·) (h _) | ||
|
|
||
| private lemma component_epow (component : Dimension LTMCTDimensionBase → Exponent) |
There was a problem hiding this comment.
Would make this not private
Closes #1580.
What this does
Adds
epow_length,epow_time,epow_mass,epow_charge,epow_temperature— theExponent-power twins of the existingnpow_*component lemmas — derived through acomponent_epowhelper that mirrorscomponent_npowline for line. One file, +41 lines,no existing declaration touched.
This is
Toy3from https://github.com/NicolasRouquette/PL1580, without the notation, asyou asked in #1580.
Why
Pow (Dimension B) Exponentcarries@[default_instance 10000], so an unascribed numericexponent elaborates to an
Exponentpower, not to theℕone. Thenpow_*lemmas match theℕpower only, so nothing in thesimpset reached the component of such a power. Removingthe five new lemmas from the
simpset recovers that state:Evidence
Every goal below is also true by
rfl, so a bareby simpwould demonstrate nothing aboutthe lemma. Each is paired instead:
simpcannot reach the goal on its own, and can with thelemma named.
lake buildandlake exe lint_allexit 0;./scripts/lint-style.shclean.Two things deliberately left out
d ^[1/2]notation (Toy3's Q3), per your call in Unascribed rational dimension exponents default toℕ, silently makingL𝓭 ^ (1/2)dimensionless #1580.qpow_*component lemmas. Theℚpower is never selected for an unascribed literal —only an explicit
q : ℚreaches it — so it needs no defaulting rescue, and five more@[simp]lemmas for it would be speculative. See the last section.I also gave
component_epowthe sameprivatevisibility ascomponent_npow.The reason:
LTMCTDimensionBaseis the only basis in Physlib with named componentprojections —
ISQDimensionBaseand theParametricDimensionExamplesbases go throughexponentdirectly, where the existing basis-genericepow_exponentalready applies — sothere is no caller for a public or basis-generic version today.
On deleting
Pow (Dimension B) ℚYou floated this in #1580. Having checked it: the instance is removable at very low cost, and
this PR does not depend on the answer either way.
Pow (Dimension B) ℚandPow (Dimension B) Exponenthave the same body, differing only inwhere
ofRatis applied (Physlib/Units/Dimension.lean):So the
ℚpower is definitionally theExponentpower atofRat:example (d : Dimension LTMCTDimensionBase) (q : ℚ) : d ^ q = d ^ (Dimension.Exponent.ofRat q) := rflInside Physlib, deleting it costs nothing at all. Not a survey: I deleted the instance
and
qpow_exponenttogether and ranlake build, which completed with exit 0 acrossPhyslib,PhyslibAlpha, andQuantumInfo. Nothing in the library raises aDimensiontoa ℚ-typed exponent, and
qpow_exponenthas no use outside its own declaration.Downstream, the port is mechanical but I can only speak for one case. A statement of the
shape
b.dim = a.dim ^ (p : ℚ)— a half-power certificate, say — restates asb.dim = a.dim ^ Exponent.ofRat pand is the same proposition byrfl, so the exponentstays rational in the signature and nothing weakens. I ported one such certificate in a
library of mine and it took two edits:
Exponent.ofRat pin the statement, andepow_exponentin place ofqpow_exponentin thesimp only. The rest of the proof wasuntouched. That is one data point, not a claim about every downstream user.
So the trade is: whoever holds a genuine
q : ℚwrites an extraExponent.ofRat, againstone fewer competing
Powinstance onDimension— which is most of what made #1580 hard toanswer in the first place. This looks favorable to me, but it is your call and it is not this
PR.
Either way
epow_*is what you asked for asToy3. These lemmas are about theExponentpower, which is the one unascribed literals actually select, and that is true whether the ℚ
instance stays or goes.