Skip to content

feat(temperature): PositiveTemperature refactor#976

Open
ichxorya wants to merge 3 commits intoleanprover-community:masterfrom
SEhumantics:0503-positivetemperature
Open

feat(temperature): PositiveTemperature refactor#976
ichxorya wants to merge 3 commits intoleanprover-community:masterfrom
SEhumantics:0503-positivetemperature

Conversation

@ichxorya
Copy link
Contributor

@ichxorya ichxorya commented Mar 5, 2026

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:

  • Temperature and PositiveTemperature definitions: type conversions, ext lemma, linear order and relevant order/comparison lemmas.
  • Beta and Inverse Beta (ofBeta) was moved from Temperature to PositiveTemperature, with additional lemmas in their antimonotonicity (T1 > T2 <=> Beta T1 < Beta T2, ect.)

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)

@ichxorya ichxorya marked this pull request as ready for review March 6, 2026 03:31
@ichxorya ichxorya marked this pull request as draft March 6, 2026 03:31
@jstoobysmith
Copy link
Member

Hey, when you are ready for this to be reviewed, could you unmark it as a draft?

@ichxorya
Copy link
Contributor Author

ichxorya commented Mar 6, 2026

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.

@ichxorya ichxorya marked this pull request as ready for review March 7, 2026 14:49
@jstoobysmith
Copy link
Member

Could we split the PositiveTemperature results into their own file?

@jstoobysmith jstoobysmith added t-thermodynamics Thermodynamics awaiting-author A reviewer has asked the author a question or requested changes labels Mar 9, 2026
@jstoobysmith
Copy link
Member

Do you actually use the results in the PosReal file in this PR? If so this file should be moved to the mathematics folder, if not it could be removed from this PR.

@ichxorya
Copy link
Contributor Author

ichxorya commented Mar 9, 2026

Could we split the PositiveTemperature results into their own file?

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!

@jstoobysmith
Copy link
Member

I guess we can, but since the beginning I though "Basic" was to store "base" data types. It would be done right away!

This is correct, it does in general store the basic data types, but I think where there becomes two main data types involved, Temperature and PositiveTemperature in this case, it becomes easier to split them up.

@ichxorya
Copy link
Contributor Author

ichxorya commented Mar 9, 2026

I guess we can, but since the beginning I though "Basic" was to store "base" data types. It would be done right away!

This is correct, it does in general store the basic data types, but I think where there becomes two main data types involved, Temperature and PositiveTemperature in this case, it becomes easier to split them up.

Thank you, I have pushed the new code to my PR following my understanding of your suggestion.

It wraps a nonnegative real number, which is the `val` field of the structure.
-/
structure Temperature where
/-- The nonnegative real value of the temperature. -/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need this doc-string for the linters

/-!
## Extensionality for `Temperature`
-/
namespace Temperature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to end and restart namespace here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise with below

/-!
## Extensionality for `PositiveTemperature`
-/
namespace PositiveTemperature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again no need to to end and restart namespaces

noncomputable def ofβ (β : ℝ>0) : PositiveTemperature :=
⟨1 / (kB * β), by
apply div_nonneg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the tactic positivity work here?

exact h_T₁_le_T₂

/-- The thermodynamic beta strictly reverses strict inequalities. -/
lemma β_strictAnti {T₁ T₂ : PositiveTemperature} : T₁ < T₂ ↔ β T₂ < β T₁ := by
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use [StrictAnti](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Order/Monotone/Defs.html#StrictAnti) directly here, and similar for the above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes t-thermodynamics Thermodynamics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants