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
Units
directory, 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,
- columbs,
- 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
CarriesDimension
for a type carrying an instance ofMulAction ℝ≥0 M
ModuleCarriesDimension
for a type carrying an instance ofModule ℝ M
.
The latter is need to prevent a typeclass dimond.
A module M
carries a dimension d
if every element of M
is supposed to have
this dimension.
This is defined in additon to CarriesDimension
to prevent a type-casting dimond.
- d : Dimension
The dimension carried by a module
M
.
Instances
Equations
- instCarriesDimensionOfModuleCarriesDimension = { toMulAction := NNReal.instMulActionOfReal, d := ModuleCarriesDimension.d M }
Terms of the current dimension #
Given a type M
which carries a dimension d
,
we are intrested in elements of M
which depend on a choice of units, i.e. functions
UnitChoices → M
.
We define both a proposition
HasDimension f
which says thatf
scales correctly with units, and a typeDimensionful M
which 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) (CarriesDimension.d 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, ⋯⟩, one_smul := ⋯, mul_smul := ⋯ }
For M
carying 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.