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.
Defining dimensions #
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
The dimension corresponding to length.
Equations
- Dimension.Lπ = { length := 1, time := 0, mass := 0, charge := 0, temperature := 0 }
Instances For
The dimension corresponding to time.
Equations
- Dimension.Tπ = { length := 0, time := 1, mass := 0, charge := 0, temperature := 0 }
Instances For
The dimension corresponding to mass.
Equations
- Dimension.Mπ = { length := 0, time := 0, mass := 1, charge := 0, temperature := 0 }
Instances For
The dimension corresponding to charge.
Equations
- Dimension.Cπ = { length := 0, time := 0, mass := 0, charge := 1, temperature := 0 }
Instances For
The dimension corresponding to temperature.
Equations
- Dimension.Ξπ = { length := 0, time := 0, mass := 0, charge := 0, temperature := 1 }
Instances For
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
Given two choices of units u1
and u2
and a dimension d
, the
element of ββ₯0
corresponding to the scaling (by definition) of a quantity of dimension d
when changing from units u1
to u2
.
Equations
- One or more equations did not get rendered due to their size.
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
Dimensionful #
Given a type M
with a dimension d
, a dimensionful quantity is a
map from UnitChoices
to M
, which scales with the choice of unit according to d
.
See: https://leanprover.zulipchat.com/#narrow/channel/479953-PhysLean/topic/physical.20units/near/530520545
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 d f = β (u1 u2 : UnitChoices), f u2 = u1.dimScale u2 d β’ f u1
Instances For
The type of maps from UnitChoices
to M
which have dimension d
.
Equations
- Dimensionful d M = { f : UnitChoices β M // HasDimension d f }
Instances For
Applying an element of Dimensionful d M
to a unit choice gives an element of M
.
Equations
- Dimensionful.instCoeFunForallUnitChoices = { coe := fun (f : Dimensionful d M) => βf }
Equality lemmas #
MulAction #
Equations
- Dimensionful.instMulActionNNReal = { smul := fun (a : NNReal) (f : Dimensionful d M) => β¨fun (u : UnitChoices) => a β’ βf u, β―β©, one_smul := β―, mul_smul := β― }
Equations
- Dimensionful.instMulActionReal = { smul := fun (a : β) (f : Dimensionful d M) => β¨fun (u : UnitChoices) => a β’ βf u, β―β©, one_smul := β―, mul_smul := β― }
ofUnit #
The creation of an element f : Dimensionful d M
given a m : M
and a choice of
units u : UnitChoices
, defined such that f u = m
.
Equations
- Dimensionful.ofUnit d m u = β¨fun (u1 : UnitChoices) => u.dimScale u1 d β’ m, β―β©
Instances For
LE #
Equations
- Dimensionful.instLENNReal = { le := fun (f1 f2 : Dimensionful d NNReal) => β (u : UnitChoices), βf1 u β€ βf2 u }
Addition and module structure #
Equations
- Dimensionful.instAddZeroClass = { zero := β¨fun (x : UnitChoices) => 0, β―β©, add := fun (f1 f2 : Dimensionful d M) => β¨fun (u : UnitChoices) => βf1 u + βf2 u, β―β©, zero_add := β―, add_zero := β― }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Dimensionful.instModuleReal = { toMulAction := Dimensionful.instMulActionReal, smul_zero := β―, smul_add := β―, add_smul := β―, zero_smul := β― }
###Β Multiplication
Equations
- Dimensionful.instHMulRealHMulDimension = { hMul := fun (x : Dimensionful d1 β) (y : Dimensionful d2 β) => β¨fun (u : UnitChoices) => βx u * βy u, β―β© }
Division #
Equations
- Dimensionful.instHDivRealHMulDimensionInv = { hDiv := fun (x : Dimensionful d1 β) (y : Dimensionful d2 β) => β¨fun (u : UnitChoices) => βx u / βy u, β―β© }
Equations
- Dimensionful.instHDivRealInvDimension = { hDiv := fun (x : β) (y : Dimensionful d2 β) => β¨fun (u : UnitChoices) => x / βy u, β―β© }
SMul #
Equations
- Dimensionful.instHSMulRealHMulDimension = { hSMul := fun (x : Dimensionful d1 β) (y : Dimensionful d2 M) => β¨fun (u : UnitChoices) => βx u β’ βy u, β―β© }
Inner product #
We define the inner product in SI units.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Derivatives #
The derivative using dimensionalful quantities.
Equations
- Dimensionful.deriv f atLocation = β¨fun (u : UnitChoices) => β((fderiv β f atLocation) (Dimensionful.ofUnit d1 1 u)) u, β―β©
Instances For
valCast #
The casting of a quantity in Dimensionful 0 M
to its underlying element in M
.
Equations
- f.valCast hd = βf UnitChoices.SI
Instances For
Measured quantities #
We defined Measured d M
to be a type of measured quantity of type M
and of dimension d
,
the terms of Measured d M
are corresponds to values of the quantity in a given but arbitary
set of units.
If M
has the type of a vector space, then the type Measured d M
inherits this structure.
Likewise if M
has the type of an inner product space, then the type Measured d M
inherits this structure. However, note that the inner product space does not explicit track
the dimension, mapping down to β
. This is in theory fine, as it is still dimensionful, in the
sense that it scales with the choice of unit.
The type Measured d M
can be seen as a convienent way to work with and keep track of
dimensions. However, working with Measured d M
does not formally prove anything
about dimensions, which can only be done with Dimensionful d M
, or other
manifest considerations of UnitChoices
.
Basic instances carried from underlying type. #
Equations
- Measured.instHSMulUnitChoicesDimensionful = { hSMul := fun (m : Measured d M) (u : UnitChoices) => β¨fun (u1 : UnitChoices) => u.dimScale u1 d β’ m.val, β―β© }