Dimensions and unit #
A unit in physics arises from choice of something in physics which is non-canonical.
An example is the choice of translationally-invariant metric on the time manifold TimeMan.
A dimension is a property of a quantity related to how it changes with respect to a change in the unit.
The fundamental choices one has in physics are related to:
- Time
- Length
- Mass
- Charge
- Temperature
(In fact temperature is not really a fundamental choice, however we leave this as a TODO.)
From these fundamental choices one can construct all other units and dimensions.
Implementation details #
Units within PhysLean are implemented with the following convention:
- The fundamental units, and the choices they correspond to, are defined within the appropriate physics directory, in particular:
- In this
Unitsdirectory, we define the necessary structures and properties to work derived units and dimensions.
References #
Zulip chats discussing units:
- https://leanprover.zulipchat.com/#narrow/channel/479953-PhysLean/topic/physical.20units
- https://leanprover.zulipchat.com/#narrow/channel/116395-maths/topic/Dimensional.20Analysis.20Revisited/with/530238303
Note #
A lot of the results around units is still experimental and should be adapted based on needs.
Other implementations of units #
There are other implementations of units in Lean, in particular:
- https://github.com/ATOMSLab/LeanDimensionalAnalysis/tree/main
- https://github.com/teorth/analysis/blob/main/analysis/Analysis/Misc/SI.lean
- https://github.com/ecyrbe/lean-units
Each of these have their own advantages and specific use-cases.
For example both (1) and (3) allow for or work in Floats, allowing computability and the use
of
#eval. This is currently not possible with the more theoretical implementation here in PhysLean which is based exclusively on Reals.
Units #
The choice of units.
- length : LengthUnit
The length unit.
- time : TimeUnit
The time unit.
- mass : MassUnit
The mass unit.
- charge : ChargeUnit
The charge unit.
- temperature : TemperatureUnit
The temperature unit.
Instances For
The choice of units corresponding to SI units, that is
- meters,
- seconds,
- kilograms,
- coulombs,
- kelvin.
Equations
- UnitChoices.SI = { length := LengthUnit.meters, time := TimeUnit.seconds, mass := MassUnit.kilograms, charge := ChargeUnit.coulombs, temperature := TemperatureUnit.kelvin }
Instances For
A UnitChoices which is related to SI by a prime scaling of each
of the underlying units. This is useful in proving that a result is not
dimensionally correct.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Types carrying dimensions #
Dimensions are assigned to types with the following type-classes
HasDimfor any typeMwith an associated dimensionCarriesDimensionfor a type that also has an instance ofMulAction ℝ≥0 M
Terms of the current dimension #
Given a type M which carries a dimension d,
we are interested in elements of M which depend on a choice of units, i.e. functions
UnitChoices → M.
We define both a proposition
HasDimension fwhich says thatfscales correctly with units, and a typeDimensionful Mwhich is the subtype of functions whichHasDimension.
A quantity of type M which depends on a choice of units UnitChoices is said to be
of dimension d if it scales by UnitChoices.dimScale u1 u2 d under a change in units.
Equations
- HasDimension f = ∀ (u1 u2 : UnitChoices), f u2 = (u1.dimScale u2) (dim M) • f u1
Instances For
The subtype of functions UnitChoices → M, for which M carries a dimension,
which HasDimension.
Equations
Instances For
Equations
Equations
- instMulActionNNRealDimensionful = { smul := fun (a : NNReal) (f : Dimensionful M) => ⟨fun (u : UnitChoices) => a • ↑f u, ⋯⟩, mul_smul := ⋯, one_smul := ⋯ }
For M carrying a dimension d, the equivalence between M and Dimension M,
given a choice of units.
Equations
- One or more equations did not get rendered due to their size.