feat(temperature): PositiveTemperature refactor#976
feat(temperature): PositiveTemperature refactor#976ichxorya wants to merge 20 commits intoleanprover-community:masterfrom
Conversation
|
Hey, when you are ready for this to be reviewed, could you unmark it as a draft? |
Yes I think it is ready, but I marked as draft since it's not ready to be merge. Can you please review this section first? I'd like to add the rest of the original Basic.lean but it would be too lengthy for now. |
|
Could we split the |
|
Do you actually use the results in the PosReal file in this PR? If so this file should be moved to the |
I guess we can, but since the beginning I though "Basic" was to store "base" data types. It would be done right away! Also, the PosReal type is defined for easier notation of R>0. I would move it to Math folder if it suits the project better! |
This is correct, it does in general store the |
…table directories (with minor reformat)
Thank you, I have pushed the new code to my PR following my understanding of your suggestion. |
| /-- `⟨a, ha⟩ ≤ ⟨b, hb⟩` if and only if `a ≤ b` in `Temperature`. -/ | ||
| @[simp] | ||
| lemma mk_le_mk {a b : Temperature} {ha : 0 < a.val} {hb : 0 < b.val} : | ||
| (⟨a, ha⟩ : PositiveTemperature) ≤ (⟨b, hb⟩ : PositiveTemperature) ↔ a ≤ b := Iff.rfl | ||
|
|
||
| /-- `⟨a, ha⟩ < ⟨b, hb⟩` if and only if `a < b` in `Temperature`. -/ | ||
| @[simp] | ||
| lemma mk_lt_mk {a b : Temperature} {ha : 0 < a.val} {hb : 0 < b.val} : | ||
| (⟨a, ha⟩ : PositiveTemperature) < (⟨b, hb⟩ : PositiveTemperature) ↔ a < b := Iff.rfl |
There was a problem hiding this comment.
Should we remove this and keep ofPosReal_le/lt only?
There was a problem hiding this comment.
how about something like StrictMono ofPosReal and StrictMono val or similar
| /-- `⟨a⟩ ≤ ⟨b⟩` if and only if `a ≤ b` in `ℝ≥0`. -/ | ||
| @[simp] | ||
| lemma mk_le_mk {a b : ℝ≥0} : Temperature.mk a ≤ Temperature.mk b ↔ a ≤ b := Iff.rfl | ||
|
|
||
| /-- Build a `Temperature` directly from a nonnegative real. -/ | ||
| @[simp] def ofNNReal (t : ℝ≥0) : Temperature := ⟨t⟩ | ||
| /-- `⟨a⟩ < ⟨b⟩` if and only if `a < b` in `ℝ≥0`. -/ | ||
| @[simp] | ||
| lemma mk_lt_mk {a b : ℝ≥0} : Temperature.mk a < Temperature.mk b ↔ a < b := Iff.rfl |
There was a problem hiding this comment.
Should we remove this and keep ofNNReal_le/lt only?
There was a problem hiding this comment.
StrictMono ofNNReal and StrictMono Temperature.mk?
|
FYI you can now use comments to add and remove labels on PRs. When you are ready for the next review you can make the comment |
feat: 20 of March PR to make the branch up-to-date
|
-awaiting-author Sorry for the wait, I was busy with my job search. Things might go back on track soon. @jstoobysmith can you review to see if I can implement the rest of the differentiations and limits, or should I further refine these existing definitions? |
|
This current PR looks good to me. |
|
awaiting-author |
Thank you. I'm on my way fixing the linter. But currently do we allows for unsuccessful build of the whole repository? Since this is being used by Canonical Ensemble, and (1) we hadn't add all diff/limits theories for PositiveTemperatur, and (2) Canonical Ensemble is currently using those definitions (but was in the "removed" definitions in Temperature). Thus |
|
awaiting-author Ok, thanks for explaining. Yeah we require that So let's add In general when making a PR I think it is good to think about what the logically independent changes are, and how they can be separated into different PRs. |
|
-awaiting-author If this commit pass, I think we are ready to review how CanonicalEnsemble should depend on the new PositiveTemperature proofs and definitions. |
jstoobysmith
left a comment
There was a problem hiding this comment.
Some similar comments throughout.
PhysLean/Thermodynamics/Temperature/PositiveTemperature/Calculus.lean
Outdated
Show resolved
Hide resolved
PhysLean/Thermodynamics/Temperature/PositiveTemperature/Calculus.lean
Outdated
Show resolved
Hide resolved
PhysLean/Thermodynamics/Temperature/PositiveTemperature/Convergence.lean
Outdated
Show resolved
Hide resolved
PhysLean/Thermodynamics/Temperature/PositiveTemperature/Convergence.lean
Outdated
Show resolved
Hide resolved
Thank you I will check them out later! |
|
@jstoobysmith I have refactored these lengthy proofs following your suggestions.
|
|
-awaiting-author |
|
Ok, I think we can go onto the CanonicalEnsemble stuff, if that is what is blocking the building |
…ll use Temperature, the Beta function is explicitly defined
|
There are 4 files in Canonical Ensemble to rework, but to be frank, my physics knowledge is not enough to figure out how to refactor (as Canonical Ensemble wasn't included in our general physics courses). In this Basic file, (with suggestions from Claude LLM), I converted some T into PositiveTemperature, while some still kept as T (but still have to invoke Beta function; which is resolved by... calling 1/kb*T). I don't know if they should be kept as Temperature or should I convert them into PositiveTemperature. @hungle0503 can you review this as well? |
At this first commit, I would follow the suggestion of @jstoobysmith to break the PR down into pieces. Hopefully this could be reviewed as a passing commit 😄
However, note that at this point, the Basic.lean file only contain:
For the rest (derivatives, limits, ect.), I have also proved them following the PositiveTemperature refactor here (https://github.com/SEhumantics/PhysLean/tree/feat/nghiabt/postemp/PhysLean/Thermodynamics/Temperature). However, I can only commit more until further acceptance from maintainer revisions!
Referred issues: #861 #860 - #892 (directly dependent on the Beta and Inverse Beta functions)