Physlib

Physlib.Units.UnitDependent

Types which depend on dimensions

In addition to types which carry a dimension, we also have types whose elements depend on a choice of a units. For example a function `f : M1 → M2` between two types `M1` and `M2` which carry dimensions does not itself carry a dimensions, but is dependent on a choice of units.

We define three versions - `UnitDependent M` having a function `scaleUnit : UnitChoices → UnitChoices → M → M` subject to two conditions `scaleUnit_trans` and `scaleUnit_id` - `LinearUnitDependent M` extends `UnitDependent M` with additional linearity conditions on `scaleUnit`. - `ContinuousLinearUnitDependent M` extends `LinearUnitDependent M` with an additional continuity condition on `scaleUnit`.

## Basic properties of scaleUnit

### Variations on the map scaleUnit

Instances of the type classes

We construct instance of the `UnitDependent`, `LinearUnitDependent` and `ContinuousLinearUnitDependent` type classes based on `CarriesDimension` and functions.

Functions

isDimensionallyCorrect

Some type classes to help track dimensions

Dim Subtype

39 declarations

theorem

Scaling from u1u_1 to u2u_2 and back to u1u_1 is the Identity Map on MM

Let MM be a type whose elements depend on a choice of units (indicated by the `UnitDependent` typeclass). For any two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any element mMm \in M, scaling mm from the representation of u1u_1 to u2u_2 and then scaling the result back from u2u_2 to u1u_1 returns the original element mm. That is, scaleUnit(u2,u1,scaleUnit(u1,u2,m))=m.\text{scaleUnit}(u_2, u_1, \text{scaleUnit}(u_1, u_2, m)) = m.

theorem

Unit scaling is injective: scaleUnit(u1,u2,m1)=scaleUnit(u1,u2,m2)    m1=m2\text{scaleUnit}(u_1, u_2, m_1) = \text{scaleUnit}(u_1, u_2, m_2) \iff m_1 = m_2

Let MM be a type whose elements depend on a choice of units (indicated by the `UnitDependent` typeclass). For any two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any two elements m1,m2Mm_1, m_2 \in M, the results of scaling m1m_1 and m2m_2 from the representation of u1u_1 to u2u_2 are equal if and only if m1m_1 and m2m_2 are equal. That is, scaleUnit(u1,u2,m1)=scaleUnit(u1,u2,m2)    m1=m2.\text{scaleUnit}(u_1, u_2, m_1) = \text{scaleUnit}(u_1, u_2, m_2) \iff m_1 = m_2.

definition

Unit scaling equivalence from u1u_1 to u2u_2

For a type MM equipped with a `UnitDependent` instance and two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the function scaleUnit(u1,u2,)\text{scaleUnit}(u_1, u_2, \cdot) defines an equivalence (a bijective map) from MM to itself. The forward map converts an element from the representation corresponding to unit choice u1u_1 to that of u2u_2, and its inverse is given by the scaling map from u2u_2 back to u1u_1.

definition

The R\mathbb{R}-linear map scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2)

For a real vector space MM that carries a linear unit dependency, and given two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the function scaleUnit(u1,u2):MM\text{scaleUnit}(u_1, u_2): M \to M is defined as an R\mathbb{R}-linear map. This map transforms an element mMm \in M representing a physical quantity in the context of unit choice u1u_1 to its representation in unit choice u2u_2.

definition

The R\mathbb{R}-linear equivalence scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2)

For a real vector space MM that carries a linear unit dependency, and given two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the function scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2) is an R\mathbb{R}-linear equivalence (a linear isomorphism) from MM to itself. This map transforms an element mMm \in M from its representation under unit choice u1u_1 to its representation under unit choice u2u_2, with the inverse map being the scaling from u2u_2 back to u1u_1.

definition

The continuous R\mathbb{R}-linear map scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2)

For a topological vector space MM over R\mathbb{R} that carries a continuous linear unit dependency, and given two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the function scaleUnit(u1,u2):MM\text{scaleUnit}(u_1, u_2): M \to M is defined as a continuous R\mathbb{R}-linear map. This map transforms an element mMm \in M representing a physical quantity in the context of unit choice u1u_1 to its representation in unit choice u2u_2.

definition

The continuous R\mathbb{R}-linear equivalence scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2)

For a topological vector space MM over R\mathbb{R} that possesses a continuous linear unit dependency, and given two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the function scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2) is a continuous R\mathbb{R}-linear equivalence (a continuous linear isomorphism) from MM to itself. This map transforms an element mMm \in M from its representation under unit choice u1u_1 to its representation under unit choice u2u_2, such that both the transformation and its inverse are continuous and linear.

theorem

scaleUnitContLinearEquiv(u1,u2)(m)=scaleUnit(u1,u2,m)\text{scaleUnitContLinearEquiv}(u_1, u_2)(m) = \text{scaleUnit}(u_1, u_2, m)

Let MM be a topological vector space over R\mathbb{R} that possesses a continuous linear unit dependency. For any two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any element mMm \in M, the result of applying the continuous R\mathbb{R}-linear equivalence scaleUnitContLinearEquiv(u1,u2)\text{scaleUnitContLinearEquiv}(u_1, u_2) to mm is equal to the scaling function scaleUnit(u1,u2,m)\text{scaleUnit}(u_1, u_2, m).

theorem

The inverse of scaleUnitContLinearEquiv(u1,u2)\text{scaleUnitContLinearEquiv}(u_1, u_2) is scaleUnit(u2,u1)\text{scaleUnit}(u_2, u_1)

For a topological vector space MM over R\mathbb{R} that carries a continuous linear unit dependency, given any two sets of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and an element mMm \in M, the inverse of the continuous R\mathbb{R}-linear equivalence scaleUnitContLinearEquiv(u1,u2)\text{scaleUnitContLinearEquiv}(u_1, u_2) applied to mm is equal to the scaling operation from u2u_2 to u1u_1 applied to mm. That is, (scaleUnitContLinearEquiv(u1,u2))1(m)=scaleUnit(u2,u1,m) (\text{scaleUnitContLinearEquiv}(u_1, u_2))^{-1}(m) = \text{scaleUnit}(u_2, u_1, m) where scaleUnitContLinearEquiv(u1,u2)\text{scaleUnitContLinearEquiv}(u_1, u_2) is the continuous linear isomorphism that transforms representations of elements in MM from the unit system u1u_1 to u2u_2.

instance

`UnitChoices` is a `UnitDependent` type

The type `UnitChoices`, which represents a set of base units for physical dimensions (length, time, mass, charge, and temperature), is an instance of the `UnitDependent` type class. This is defined by a scaling function scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) that transforms a set of units uu based on a change of reference units from u1u_1 to u2u_2. The transformation is performed by scaling each base unit in uu by the ratio of the corresponding units in u2u_2 and u1u_1: scaleUnit(u1,u2,u)=(Lu2Lu1Lu,Tu2Tu1Tu,Mu2Mu1Mu,Qu2Qu1Qu,Θu2Θu1Θu) \text{scaleUnit}(u_1, u_2, u) = \left( \frac{L_{u_2}}{L_{u_1}} L_u, \frac{T_{u_2}}{T_{u_1}} T_u, \frac{M_{u_2}}{M_{u_1}} M_u, \frac{Q_{u_2}}{Q_{u_1}} Q_u, \frac{\Theta_{u_2}}{\Theta_{u_1}} \Theta_u \right) where L,T,M,Q,L, T, M, Q, and Θ\Theta represent the length, time, mass, charge, and temperature components of the unit choices, respectively.

theorem

scaleUnit(u1,u2,u1)=u2\text{scaleUnit}(u_1, u_2, u_1) = u_2

For any two sets of base units u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, scaling the unit choice u1u_1 based on a change of reference units from u1u_1 to u2u_2 results in u2u_2. That is, scaleUnit(u1,u2,u1)=u2 \text{scaleUnit}(u_1, u_2, u_1) = u_2 where UnitChoices\text{UnitChoices} represents a set of base units for physical dimensions (length, time, mass, charge, and temperature), and scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) is the transformation of a unit choice uu under the reference change from u1u_1 to u2u_2.

theorem

dimScale(u,scaleUnit(u1,u2,u),d)=dimScale(u1,u2,d)\text{dimScale}(u, \text{scaleUnit}(u_1, u_2, u), d) = \text{dimScale}(u_1, u_2, d)

For any physical dimension dDimensiond \in \text{Dimension} and any sets of base units u,u1,u2UnitChoicesu, u_1, u_2 \in \text{UnitChoices}, the scaling factor for dimension dd between uu and the transformed unit system scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) is equal to the scaling factor for dimension dd between u1u_1 and u2u_2: dimScale(u,scaleUnit(u1,u2,u),d)=dimScale(u1,u2,d) \text{dimScale}(u, \text{scaleUnit}(u_1, u_2, u), d) = \text{dimScale}(u_1, u_2, d) Here, dimScale(uA,uB,d)\text{dimScale}(u_A, u_B, d) is the factor used to convert a quantity of dimension dd from unit system uAu_A to uBu_B, and scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) scales the base units of uu by the ratios of the corresponding base units in u2u_2 to u1u_1.

theorem

c(scaleUnit(u1,u2,u))=dimScale(u1,u2,dimM)c(u)c(\text{scaleUnit}(u_1, u_2, u)) = \text{dimScale}(u_1, u_2, \text{dim} M) \cdot c(u)

Let MM be a type that carries a physical dimension d=dimMd = \text{dim} M. Let cc be a dimensionful quantity of type MM, which is a function c:UnitChoicesMc: \text{UnitChoices} \to M that scales consistently with the dimension dd. For any sets of unit choices u,u1,u2UnitChoicesu, u_1, u_2 \in \text{UnitChoices}, the value of cc evaluated at the scaled unit system scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) satisfies: c(scaleUnit(u1,u2,u))=dimScale(u1,u2,d)c(u)c(\text{scaleUnit}(u_1, u_2, u)) = \text{dimScale}(u_1, u_2, d) \cdot c(u) where scaleUnit(u1,u2,u)\text{scaleUnit}(u_1, u_2, u) is the transformation of the unit choice uu by the ratios of base units in u2u_2 relative to u1u_1, and dimScale(u1,u2,d)\text{dimScale}(u_1, u_2, d) is the scaling factor for dimension dd transitioning from u1u_1 to u2u_2.

instance

Multiplicative unit dependence for types carrying a dimension MM

Let MM be a type that carries a physical dimension d=dimMd = \text{dim} M. This instance provides a multiplicative unit-dependent structure (`MulUnitDependent`) for MM. For any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling function scaleUnit:UnitChoicesUnitChoicesMM\text{scaleUnit}: \text{UnitChoices} \to \text{UnitChoices} \to M \to M is defined by: scaleUnit(u1,u2,m)=dimScale(u1,u2,d)m\text{scaleUnit}(u_1, u_2, m) = \text{dimScale}(u_1, u_2, d) \cdot m where mMm \in M and dimScale(u1,u2,d)\text{dimScale}(u_1, u_2, d) is the scaling factor for dimension dd when transitioning from unit choice u1u_1 to u2u_2. This definition ensures that scaling is consistent with the physical dimension of MM and satisfies required properties such as transitivity, identity, and commutation with multiplication.

theorem

scaleUnit(u1,u2,m)=dimScale(u1,u2,dim M)m\text{scaleUnit}(u_1, u_2, m) = \text{dimScale}(u_1, u_2, \text{dim } M) \cdot m

Let MM be a type that carries a physical dimension d=dim Md = \text{dim } M. For any two systems of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any element mMm \in M, the scaling of mm according to the change in units from u1u_1 to u2u_2 is given by: scaleUnit(u1,u2,m)=dimScale(u1,u2,d)m\text{scaleUnit}(u_1, u_2, m) = \text{dimScale}(u_1, u_2, d) \cdot m where dimScale(u1,u2,d)R0\text{dimScale}(u_1, u_2, d) \in \mathbb{R}_{\ge 0} is the scaling factor for dimension dd when transitioning from unit system u1u_1 to u2u_2, and the multiplication denotes the action of non-negative reals on MM.

instance

Linear unit dependence for a dimensionful vector space MM

Let MM be a real vector space (specifically, an additive commutative monoid and a module over R\mathbb{R}) that carries a physical dimension d=dimMd = \text{dim} M. This instance provides a linear unit-dependent structure (`LinearUnitDependent`) for MM. For any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling function scaleUnit(u1,u2):MM\text{scaleUnit}(u_1, u_2): M \to M is linear, satisfying: 1. scaleUnit(u1,u2,m1+m2)=scaleUnit(u1,u2,m1)+scaleUnit(u1,u2,m2)\text{scaleUnit}(u_1, u_2, m_1 + m_2) = \text{scaleUnit}(u_1, u_2, m_1) + \text{scaleUnit}(u_1, u_2, m_2) 2. scaleUnit(u1,u2,rm)=rscaleUnit(u1,u2,m)\text{scaleUnit}(u_1, u_2, r \cdot m) = r \cdot \text{scaleUnit}(u_1, u_2, m) for all m,m1,m2Mm, m_1, m_2 \in M and rRr \in \mathbb{R}. This linearity holds because the scaling operation is defined by multiplication by the real-valued factor dimScale(u1,u2,d)\text{dimScale}(u_1, u_2, d) associated with the dimension of MM.

instance

Continuous linear unit dependence for a dimensionful topological vector space MM

Let MM be a topological real vector space (formally, an additive commutative monoid and a module over R\mathbb{R} equipped with a topology) such that scalar multiplication by constants is continuous. If MM carries a physical dimension d=dim Md = \text{dim } M, then MM possesses a continuous linear unit-dependent structure (`ContinuousLinearUnitDependent`). For any two systems of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling operation scaleUnit(u1,u2):MM\text{scaleUnit}(u_1, u_2) : M \to M is defined by: scaleUnit(u1,u2,m)=dimScale(u1,u2,d)m\text{scaleUnit}(u_1, u_2, m) = \text{dimScale}(u_1, u_2, d) \cdot m where dimScale(u1,u2,d)R\text{dimScale}(u_1, u_2, d) \in \mathbb{R} is the scaling factor associated with the dimension dd. This map is linear and continuous because it is defined as the action of a constant scalar on MM.

instance

Unit dependency of the function type M1M2M_1 \to M_2

If a type M2M_2 is unit-dependent, then the type of functions M1M2M_1 \to M_2 is also unit-dependent for any type M1M_1. For a function f:M1M2f: M_1 \to M_2 and unit choices u1,u2u_1, u_2, the scaling operation scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2) on the function ff is defined pointwise: (scaleUnit(u1,u2)(f))(m)=scaleUnit(u1,u2)(f(m))(\text{scaleUnit}(u_1, u_2)(f))(m) = \text{scaleUnit}(u_1, u_2)(f(m)) for all mM1m \in M_1.

theorem

Unit scaling of functions is pointwise

Let M1M_1 be a type and M2M_2 be a unit-dependent type. For any two unit choices u1,u2u_1, u_2, any function f:M1M2f: M_1 \to M_2, and any element m1M1m_1 \in M_1, the result of applying the scaled function scaleUnit(u1,u2)f\text{scaleUnit}(u_1, u_2) f to m1m_1 is equal to scaling the value f(m1)f(m_1) by the same unit choices. That is, (scaleUnit(u1,u2)f)(m1)=scaleUnit(u1,u2)(f(m1)).(\text{scaleUnit}(u_1, u_2) f)(m_1) = \text{scaleUnit}(u_1, u_2) (f(m_1)). This confirms that the unit scaling for the function type M1M2M_1 \to M_2 is defined pointwise.

instance

Linear unit-dependence of M1RM2M_1 \to_{\mathbb{R}} M_2 induced by codomain scaling

Suppose M1M_1 and M2M_2 are modules over R\mathbb{R}. If M2M_2 carries a linear unit-dependent structure, then the space of R\mathbb{R}-linear maps M1RM2M_1 \to_{\mathbb{R}} M_2 is also linear unit-dependent. For a linear map f:M1RM2f: M_1 \to_{\mathbb{R}} M_2 and two choices of units u1u_1 and u2u_2, the scaling operation scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2) on ff is defined pointwise: (scaleUnit(u1,u2)f)(m)=scaleUnit(u1,u2)(f(m))(\text{scaleUnit}(u_1, u_2)f)(m) = \text{scaleUnit}(u_1, u_2)(f(m)) for all mM1m \in M_1.

instance

Continuous linear unit-dependence of $M_1 \toL[\mathbb{R}] M_2$ induced by codomain scaling

Let M1M_1 and M2M_2 be topological vector spaces over R\mathbb{R} (where M2M_2 is a topological additive group with continuous scalar multiplication). If M2M_2 possesses a continuous linear unit-dependent structure, then the space of continuous R\mathbb{R}-linear maps $M_1 \toL[\mathbb{R}] M_2$ is also a continuous linear unit-dependent type. For a continuous linear map $f: M_1 \toL[\mathbb{R}] M_2$ and any two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling operation scaleUnit(u1,u2)\text{scaleUnit}(u_1, u_2) is defined by post-composing ff with the scaling map of the codomain. That is, (scaleUnit(u1,u2)f)(m)=scaleUnit(u1,u2)(f(m))(\text{scaleUnit}(u_1, u_2) f)(m) = \text{scaleUnit}(u_1, u_2) (f(m)) for all mM1m \in M_1.

instance

Unit dependence for M1M2M_1 \to M_2 induced by domain scaling

Given a unit-dependent type M1M_1 and any type M2M_2, the space of functions M1M2M_1 \to M_2 is unit-dependent. For a function f:M1M2f: M_1 \to M_2 and two choices of units u1u_1 and u2u_2, the scaled function is defined by applying ff to the input scaled in the reverse direction: (scaleUnit(u1,u2,f))(m1)=f(scaleUnit(u2,u1,m1))(\text{scaleUnit}(u_1, u_2, f))(m_1) = f(\text{scaleUnit}(u_2, u_1, m_1)) for all m1M1m_1 \in M_1.

theorem

(scaleUnit u1,u2,f)(m1)=f(scaleUnit u2,u1,m1)(\text{scaleUnit } u_1, u_2, f)(m_1) = f(\text{scaleUnit } u_2, u_1, m_1)

Let M1M_1 and M2M_2 be types, where M1M_1 is unit-dependent. For any two choices of units u1u_1 and u2u_2, any function f:M1M2f: M_1 \to M_2, and any element m1M1m_1 \in M_1, the evaluation of the unit-scaled function scaleUnit(u1,u2,f)\text{scaleUnit}(u_1, u_2, f) at the point m1m_1 is given by: (scaleUnit(u1,u2,f))(m1)=f(scaleUnit(u2,u1,m1))(\text{scaleUnit}(u_1, u_2, f))(m_1) = f(\text{scaleUnit}(u_2, u_1, m_1)) where scaleUnit(ua,ub,)\text{scaleUnit}(u_a, u_b, \cdot) denotes the transformation of an element from unit choice uau_a to unit choice ubu_b.

instance

Unit dependence for M1M2M_1 \to M_2 induced by domain and codomain scaling

Given two unit-dependent types M1M_1 and M2M_2, the space of functions M1M2M_1 \to M_2 inherits a unit-dependent structure. For a function f:M1M2f: M_1 \to M_2 and two choices of units u1u_1 and u2u_2, the scaled function scaleUnit(u1,u2,f)\text{scaleUnit}(u_1, u_2, f) is defined by transforming the input from u2u_2 back to u1u_1, applying the function ff, and then transforming the result from u1u_1 to u2u_2: (scaleUnit(u1,u2,f))(m1)=scaleUnit(u1,u2,f(scaleUnit(u2,u1,m1)))(\text{scaleUnit}(u_1, u_2, f))(m_1) = \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m_1))) for all m1M1m_1 \in M_1.

theorem

Evaluation rule for unit-scaled functions (scaleUnit u1,u2,f)(m1)(\text{scaleUnit } u_1, u_2, f)(m_1)

Let M1M_1 and M2M_2 be unit-dependent types, and let u1u_1 and u2u_2 be two choices of units. For any function f:M1M2f: M_1 \to M_2 and any element m1M1m_1 \in M_1, the evaluation of the unit-scaled function scaleUnit(u1,u2,f)\text{scaleUnit}(u_1, u_2, f) at m1m_1 is given by: (scaleUnit(u1,u2,f))(m1)=scaleUnit(u1,u2,f(scaleUnit(u2,u1,m1)))(\text{scaleUnit}(u_1, u_2, f))(m_1) = \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m_1))) where scaleUnit(ua,ub,)\text{scaleUnit}(u_a, u_b, \cdot) denotes the transformation of an element from unit choice uau_a to unit choice ubu_b.

instance

Multiplicative unit-dependent structure for function spaces M1M2M_1 \to M_2

Given a unit-dependent type M1M_1 and a type M2M_2 that is multiplicatively unit-dependent (equipped with a scalar action by the non-negative real numbers R0\mathbb{R}_{\ge 0}), the space of functions M1M2M_1 \to M_2 inherits a multiplicatively unit-dependent structure. For a function f:M1M2f: M_1 \to M_2 and two unit choices u1,u2u_1, u_2, the scaled function scaleUnit(u1,u2,f)\text{scaleUnit}(u_1, u_2, f) evaluated at an element m1M1m_1 \in M_1 is defined by: (scaleUnit(u1,u2,f))(m1)=scaleUnit(u1,u2,f(scaleUnit(u2,u1,m1)))(\text{scaleUnit}(u_1, u_2, f))(m_1) = \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m_1))) This definition ensures that the transformation of the function space correctly accounts for the unit scaling of both the domain and the codomain while remaining compatible with the scalar action of R0\mathbb{R}_{\ge 0} on M2M_2.

instance

Continuous linear unit-dependent structure for M1L[R]M2M_1 \to L[\mathbb{R}] M_2

For any two topological vector spaces M1M_1 and M2M_2 over R\mathbb{R} that possess continuous linear unit-dependent structures, the space of continuous linear maps M1L[R]M2M_1 \to L[\mathbb{R}] M_2 (the set of continuous R\mathbb{R}-linear maps from M1M_1 to M2M_2) is also continuous linear unit-dependent. Given two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the transformation of a continuous linear map f:M1L[R]M2f: M_1 \to L[\mathbb{R}] M_2 is defined by: scaleUnit(u1,u2,f)=SM2(u1,u2)fSM1(u2,u1)\text{scaleUnit}(u_1, u_2, f) = \mathcal{S}_{M_2}(u_1, u_2) \circ f \circ \mathcal{S}_{M_1}(u_2, u_1) where SMi(u,u)\mathcal{S}_{M_i}(u, u') represents the continuous linear equivalence on MiM_i that scales an element from its representation in unit choice uu to its representation in unit choice uu'. This construction ensures that the unit scaling is compatible with the linear and topological structures of the map space.

theorem

Unit scaling of continuous linear map application: (scaleUnit u1u2f)(m1)=scaleUnit u1u2(f(scaleUnit u2u1m1))(\text{scaleUnit } u_1 \, u_2 \, f)(m_1) = \text{scaleUnit } u_1 \, u_2 \, (f (\text{scaleUnit } u_2 \, u_1 \, m_1))

Let M1M_1 and M2M_2 be topological vector spaces over R\mathbb{R} equipped with continuous linear unit-dependent structures. For any continuous linear map f:M1L[R]M2f: M_1 \to L[\mathbb{R}] M_2, any two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, and any element m1M1m_1 \in M_1, the application of the scaled function to m1m_1 satisfies: scaleUnit(u1,u2,f)(m1)=scaleUnit(u1,u2,f(scaleUnit(u2,u1,m1)))\text{scaleUnit}(u_1, u_2, f)(m_1) = \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m_1))) Here, scaleUnit(u,u,)\text{scaleUnit}(u, u', \cdot) denotes the transformation of an element or map from its representation in unit choice uu' to its representation in unit choice uu.

definition

Dimensional correctness of mm

For a type MM with a defined unit dependency, an element mMm \in M is **dimensionally correct** if its value is invariant under a change of unit systems. Formally, for any two systems of units u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling function scaleUnit\text{scaleUnit} must satisfy: scaleUnit(u1,u2,m)=m \text{scaleUnit}(u_1, u_2, m) = m This property indicates that the element mm (which could represent a value, a function, or a proposition) does not depend on the specific units chosen to represent it.

theorem

mm is dimensionally correct     \iff scaleUnit(u1,u2,m)=m\text{scaleUnit}(u_1, u_2, m) = m

Let MM be a unit-dependent type and mm be an element of MM. Then mm is **dimensionally correct** if and only if for all systems of units u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling function scaleUnit\text{scaleUnit} leaves mm invariant: scaleUnit(u1,u2,m)=m \text{scaleUnit}(u_1, u_2, m) = m This means that an element is dimensionally correct precisely when its value does not depend on the specific choice of units used to represent it.

theorem

ff is dimensionally correct     scaleUnit(u1,u2,f(scaleUnit(u2,u1,m)))=f(m)\iff \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m))) = f(m)

Let M1M_1 and M2M_2 be unit-dependent types. A function f:M1M2f: M_1 \to M_2 is **dimensionally correct** if and only if for all systems of units u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and all mM1m \in M_1, the following condition is satisfied: scaleUnit(u1,u2,f(scaleUnit(u2,u1,m)))=f(m) \text{scaleUnit}(u_1, u_2, f(\text{scaleUnit}(u_2, u_1, m))) = f(m) This signifies that the function ff is dimensionally correct when its output, after scaling the input to a different unit system and then scaling the result back, remains identical to the original output.

theorem

ff is dimensionally correct iff f(scaleUnit(u2,u1,m))=f(m)f(\text{scaleUnit}(u_2, u_1, m)) = f(m)

Let M1M_1 be a unit-dependent type and M2M_2 be any type. A function f:M1M2f: M_1 \to M_2 is **dimensionally correct** if and only if for all unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and all mM1m \in M_1, the function satisfies: f(scaleUnit(u2,u1,m))=f(m) f(\text{scaleUnit}(u_2, u_1, m)) = f(m) This property states that ff is dimensionally correct if its output remains invariant when its input is scaled according to a change in unit systems.

theorem

ff is dimensionally correct iff scaleUnit(u1,u2,f(m))=f(m)\text{scaleUnit}(u_1, u_2, f(m)) = f(m)

Let M1M_1 be a type and M2M_2 be a unit-dependent type. A function f:M1M2f: M_1 \to M_2 is **dimensionally correct** if and only if for all unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and for all mM1m \in M_1, the scaling operation satisfies: scaleUnit(u1,u2,f(m))=f(m) \text{scaleUnit}(u_1, u_2, f(m)) = f(m) This means that a function into a unit-dependent type is dimensionally correct if and only if its output values f(m)f(m) are themselves invariant under any change of unit systems.

theorem

Scaling unit choices distributes over dimensionful multiplication

Let M1,M2M_1, M_2, and M3M_3 be types that carry physical dimensions, and let there be a dimensionful multiplication operation :M1×M2M3* : M_1 \times M_2 \to M_3. For any elements m1M1m_1 \in M_1 and m2M2m_2 \in M_2, and any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the product of the elements scaled from u1u_1 to u2u_2 is equal to the scaling of their product: scaleUnit(u1,u2,m1)scaleUnit(u1,u2,m2)=scaleUnit(u1,u2,m1m2)\text{scaleUnit}(u_1, u_2, m_1) * \text{scaleUnit}(u_1, u_2, m_2) = \text{scaleUnit}(u_1, u_2, m_1 * m_2) where scaleUnit(u1,u2,m)\text{scaleUnit}(u_1, u_2, m) denotes the conversion of a quantity mm from unit system u1u_1 to u2u_2 according to its physical dimension.

definition

The set of elements in MM with dimension dd

Given a type MM equipped with a scalar action of the non-negative real numbers R0\mathbb{R}_{\ge 0} and a unit-dependent structure, and a physical dimension dDimensiond \in \text{Dimension}, the set DimSet(M,d)\text{DimSet}(M, d) is the collection of elements mMm \in M that scale according to the dimension dd under a change of units. Specifically, an element mm belongs to this set if for any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling operation satisfies: scaleUnit(u1,u2,m)=σ(u1,u2,d)m\text{scaleUnit}(u_1, u_2, m) = \sigma(u_1, u_2, d) \cdot m where σ(u1,u2,d)R0\sigma(u_1, u_2, d) \in \mathbb{R}_{\ge 0} is the scaling factor associated with the dimension dd when converting from unit choice u1u_1 to u2u_2.

instance

R0\mathbb{R}_{\ge 0}-action on the set of elements with dimension dd

Given a type MM equipped with a multiplicative action of non-negative real numbers R0\mathbb{R}_{\ge 0} and a unit-dependent structure, the subset DimSet(M,d)\text{DimSet}(M, d) consisting of elements with physical dimension dd is also equipped with a multiplicative action of R0\mathbb{R}_{\ge 0}. Specifically, for any αR0\alpha \in \mathbb{R}_{\ge 0} and mDimSet(M,d)m \in \text{DimSet}(M, d), the scalar product αm\alpha \cdot m remains an element of DimSet(M,d)\text{DimSet}(M, d), as it scales correctly according to dimension dd under a change of units.

instance

The physical dimension of DimSet(M,d)\text{DimSet}(M, d) is dd

Let MM be a type equipped with a multiplicative action of the non-negative real numbers R0\mathbb{R}_{\ge 0} and a unit-dependent structure. For any physical dimension dDimensiond \in \text{Dimension}, the set DimSet(M,d)\text{DimSet}(M, d), which consists of elements mMm \in M that scale according to dd under a change of units, is assigned the physical dimension dd.

theorem

Scaling in DimSet(M,d)\text{DimSet}(M, d) is consistent with scaling in MM

Let MM be a type equipped with a multiplicative action of the non-negative real numbers R0\mathbb{R}_{\ge 0} and a unit-dependent structure. For any physical dimension dDimensiond \in \text{Dimension}, let DimSet(M,d)\text{DimSet}(M, d) be the set of elements in MM that scale according to dd under a change of units. For any element mDimSet(M,d)m \in \text{DimSet}(M, d) and any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the underlying value in MM of the scaled element scaleUnit(u1,u2,m)\text{scaleUnit}(u_1, u_2, m) is equal to the scaling of the underlying value mvalm_{val} directly in MM: (scaleUnit(u1,u2,m))val=scaleUnit(u1,u2,mval)(\text{scaleUnit}(u_1, u_2, m))_{val} = \text{scaleUnit}(u_1, u_2, m_{val})

theorem

mDimSet(M,d)m \in \text{DimSet}(M, d) iff its scaling matches the dimension dd scale factor

Let MM be a type equipped with a scalar action of the non-negative real numbers R0\mathbb{R}_{\ge 0} and a unit-dependent structure. For any physical dimension dDimensiond \in \text{Dimension} and any element mMm \in M, mm belongs to the set DimSet(M,d)\text{DimSet}(M, d) if and only if for all pairs of unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, the scaling operation satisfies: scaleUnit(u1,u2,m)=σ(u1,u2,d)m\text{scaleUnit}(u_1, u_2, m) = \sigma(u_1, u_2, d) \cdot m where σ(u1,u2,d)\sigma(u_1, u_2, d) is the scaling factor for dimension dd between unit choices u1u_1 and u2u_2.