Physlib

Physlib.Units.WithDim.Basic

WithDim

WithDim is the type `M` which carrying the dimension `d`.

Division

Casting

24 declarations

theorem

x1.val=x2.val    x1=x2x_1.\text{val} = x_2.\text{val} \implies x_1 = x_2 in WithDim(d,M)\text{WithDim}(d, M)

Let dd be a physical dimension and MM be a type. For any two elements x1,x2x_1, x_2 of the type WithDim(d,M)\text{WithDim}(d, M), if their underlying values in MM are equal (i.e., x1.val=x2.valx_1.\text{val} = x_2.\text{val}), then x1=x2x_1 = x_2.

instance

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

For any dimension dd and any type MM, the type WithDim(d,M)\text{WithDim}(d, M) is equipped with an instance of the `HasDim` typeclass, which assigns it the physical dimension dd.

theorem

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

For any physical dimension dd and any type MM, the dimension of the type WithDim(d,M)\text{WithDim}(d, M) is equal to dd, expressed as dim(WithDim(d,M))=d\text{dim}(\text{WithDim}(d, M)) = d.

instance

Scalar action of R0\mathbb{R}_{\ge 0} on WithDim(d,M)\text{WithDim}(d, M)

Given a physical dimension dd and a type MM that possesses a scalar action by the non-negative real numbers R0\mathbb{R}_{\ge 0}, the type WithDim(d,M)\text{WithDim}(d, M) (representing values of type MM associated with dimension dd) also inherits a scalar action by R0\mathbb{R}_{\ge 0}. For any scalar aR0a \in \mathbb{R}_{\ge 0} and any dimensioned quantity mWithDim(d,M)m \in \text{WithDim}(d, M), the resulting value is obtained by applying the scalar action to the underlying value of mm.

theorem

(am).val=am.val(a \cdot m).\text{val} = a \cdot m.\text{val} for scalar action on dimensioned quantities

Let dd be a physical dimension and MM be a type equipped with a scalar action by the non-negative real numbers R0\mathbb{R}_{\ge 0}. For any scalar aR0a \in \mathbb{R}_{\ge 0} and any dimensioned quantity mWithDim(d,M)m \in \text{WithDim}(d, M), the underlying numerical value of the scalar product ama \cdot m is equal to the scalar action of aa on the numerical value of mm, expressed as (am).val=am.val(a \cdot m).\text{val} = a \cdot m.\text{val}.

instance

Multiplication of real quantities with dimensions d1d_1 and d2d_2 resulting in dimension d1d2d_1 \cdot d_2

Given two physical dimensions d1,d2Dimensiond_1, d_2 \in \text{Dimension}, let m1m_1 be a real quantity with dimension d1d_1 (of type WithDim d1R\text{WithDim } d_1 \, \mathbb{R}) and m2m_2 be a real quantity with dimension d2d_2 (of type WithDim d2R\text{WithDim } d_2 \, \mathbb{R}). This definition provides the multiplication operation m1m2m_1 \cdot m_2, which results in a real quantity with the product dimension d1d2d_1 \cdot d_2. The numerical value of the result is the product of the numerical values of m1m_1 and m2m_2.

theorem

(m1m2).val=m1.valm2.val(m_1 \cdot m_2).\text{val} = m_1.\text{val} \cdot m_2.\text{val}

Let d1d_1 and d2d_2 be physical dimensions. For any real-valued physical quantities m1m_1 with dimension d1d_1 and m2m_2 with dimension d2d_2, the numerical value of their product m1m2m_1 \cdot m_2 (which has dimension d1d2d_1 \cdot d_2) is equal to the product of their individual numerical values. That is, (m1m2).val=m1.valm2.val(m_1 \cdot m_2).\text{val} = m_1.\text{val} \cdot m_2.\text{val} where the `.val` operator extracts the underlying real number from the dimension-carrying type.

instance

Multiplication of real quantities with dimensions d1d_1 and d2d_2 resulting in dimension d1d2d_1 \cdot d_2

Given two physical dimensions d1,d2Dimensiond_1, d_2 \in \text{Dimension}, let m1m_1 be a real quantity with dimension d1d_1 (of type WithDim d1R\text{WithDim } d_1 \, \mathbb{R}) and m2m_2 be a real quantity with dimension d2d_2 (of type WithDim d2R\text{WithDim } d_2 \, \mathbb{R}). This definition provides the multiplication operation m1m2m_1 \cdot m_2, which results in a real quantity with the product dimension d1d2d_1 \cdot d_2. The numerical value of the result corresponds to the product of the numerical values of m1m_1 and m2m_2, while the physical dimension is updated to d1d2d_1 \cdot d_2.

theorem

m1.valm2.val=(m1m2).valm_1.\text{val} \cdot m_2.\text{val} = (m_1 \cdot m_2).\text{val}

Let d1d_1 and d2d_2 be physical dimensions. For any real-valued physical quantities m1m_1 with dimension d1d_1 (of type WithDim d1R\text{WithDim } d_1 \, \mathbb{R}) and m2m_2 with dimension d2d_2 (of type WithDim d2R\text{WithDim } d_2 \, \mathbb{R}), the product of their numerical values is equal to the numerical value of their physical product: m1.valm2.val=(m1m2).valm_1.\text{val} \cdot m_2.\text{val} = (m_1 \cdot m_2).\text{val} where m1m2m_1 \cdot m_2 is the quantity with dimension d1d2d_1 \cdot d_2 resulting from the multiplication of m1m_1 and m2m_2.

theorem

m1.val2=(m1m1).valm_1.\text{val}^2 = (m_1 \cdot m_1).\text{val}

For any physical dimension d1d_1 and any real-valued physical quantity m1m_1 with dimension d1d_1 (of type WithDim d1R\text{WithDim } d_1 \, \mathbb{R}), the square of the numerical value of m1m_1 is equal to the numerical value of the product of m1m_1 with itself, denoted as m1.val2=(m1m1).valm_1.\text{val}^2 = (m_1 \cdot m_1).\text{val}.

theorem

Unit scaling preserves equality of numerical values: (scaleUnitu1u2m1).val=(scaleUnitu1u2m2).val    m1.val=m2.val(\text{scaleUnit} \, u_1 \, u_2 \, m_1).\text{val} = (\text{scaleUnit} \, u_1 \, u_2 \, m_2).\text{val} \iff m_1.\text{val} = m_2.\text{val}

Let dd be a physical dimension and MM be a type equipped with a scalar action of the non-negative real numbers R0\mathbb{R}_{\ge 0}. For any two choices of unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any two dimensioned quantities m1,m2WithDim(d,M)m_1, m_2 \in \text{WithDim}(d, M), the numerical values of the quantities after scaling from u1u_1 to u2u_2 are equal if and only if their original numerical values are equal: (scaleUnit(u1,u2,m1)).val=(scaleUnit(u1,u2,m2)).val    m1.val=m2.val(\text{scaleUnit}(u_1, u_2, m_1)).\text{val} = (\text{scaleUnit}(u_1, u_2, m_2)).\text{val} \iff m_1.\text{val} = m_2.\text{val} Where WithDim(d,M)\text{WithDim}(d, M) denotes the type MM carrying the dimension dd, m.valm.\text{val} is the underlying numerical value of the quantity mm, and scaleUnit\text{scaleUnit} is the transformation function for transitioning a quantity between unit systems.

theorem

val(scaleUnit(u1,u2,m1))=dimScale(u1,u2,d)val(m1)\text{val}(\text{scaleUnit}(u_1, u_2, m_1)) = \text{dimScale}(u_1, u_2, d) \cdot \text{val}(m_1)

Let dd be a physical dimension and MM be a type equipped with a scalar action by the non-negative real numbers R0\mathbb{R}_{\ge 0}. For any two unit choices u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} and any quantity m1m_1 with dimension dd (of type WithDim dM\text{WithDim } d \, M), the numerical value of the quantity after scaling from unit system u1u_1 to u2u_2 is equal to the scaling factor for dimension dd between these unit systems applied to the original numerical value of m1m_1. That is: val(scaleUnit(u1,u2,m1))=dimScale(u1,u2,d)val(m1)\text{val}(\text{scaleUnit}(u_1, u_2, m_1)) = \text{dimScale}(u_1, u_2, d) \cdot \text{val}(m_1) where val(m)\text{val}(m) denotes the underlying value of the dimensioned quantity mm, and the operation on the right is the scalar action of R0\mathbb{R}_{\ge 0} on MM.

instance

Division of real quantities with dimensions d1d_1 and d2d_2 results in dimension d1d21d_1 \cdot d_2^{-1}

For any two physical dimensions d1,d2Dimensiond_1, d_2 \in \text{Dimension}, the division of a real-valued quantity m1m_1 of dimension d1d_1 by a real-valued quantity m2m_2 of dimension d2d_2 is defined. The resulting quantity m1/m2m_1 / m_2 has the dimension d1d21d_1 \cdot d_2^{-1} and its numerical value is the quotient of the values of m1m_1 and m2m_2, namely val(m1/m2)=val(m1)/val(m2)\text{val}(m_1 / m_2) = \text{val}(m_1) / \text{val}(m_2).

theorem

val(m1)/val(m2)=val(m1/m2)\text{val}(m_1) / \text{val}(m_2) = \text{val}(m_1 / m_2)

For any physical dimensions d1,d2Dimensiond_1, d_2 \in \text{Dimension} and any real-valued quantities m1m_1 with dimension d1d_1 and m2m_2 with dimension d2d_2, the quotient of their numerical values val(m1)/val(m2)\text{val}(m_1) / \text{val}(m_2) is equal to the numerical value of their dimensional quotient val(m1/m2)\text{val}(m_1 / m_2). That is: val(m1)val(m2)=val(m1m2)\frac{\text{val}(m_1)}{\text{val}(m_2)} = \text{val}\left(\frac{m_1}{m_2}\right) where val(m)\text{val}(m) denotes the underlying real value of a quantity mm carrying a dimension.

theorem

scaleUnit\text{scaleUnit} commutes with division of dimensioned quantities

For any physical dimensions d1,d2Dimensiond_1, d_2 \in \text{Dimension} and any real-valued quantities m1WithDim(d1,R)m_1 \in \text{WithDim}(d_1, \mathbb{R}) and m2WithDim(d2,R)m_2 \in \text{WithDim}(d_2, \mathbb{R}), let u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices} be two systems of units. The division of the quantities after scaling them from unit system u1u_1 to u2u_2 is equal to the result of scaling their quotient from u1u_1 to u2u_2. That is: scaleUnit(u1,u2,m1)scaleUnit(u1,u2,m2)=scaleUnit(u1,u2,m1m2)\frac{\text{scaleUnit}(u_1, u_2, m_1)}{\text{scaleUnit}(u_1, u_2, m_2)} = \text{scaleUnit}\left(u_1, u_2, \frac{m_1}{m_2}\right) 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, and the quotient m1/m2m_1 / m_2 on the right-hand side carries the dimension d1d21d_1 \cdot d_2^{-1}.

theorem

Casting to the same dimension is the identity: cast m rfl=m\text{cast } m \text{ rfl} = m

For any dimension dd and any type MM, let mm be a quantity of type MM carrying the dimension dd. Casting mm to the same dimension dd (using the reflexivity of equality d=dd = d) results in the original quantity mm. That is, cast m rfl=m\text{cast } m \text{ rfl} = m.

theorem

scaleUnit\text{scaleUnit} commutes with cast\text{cast}

Let dd and d2d_2 be physical dimensions, and let MM be a type equipped with a scalar action of the non-negative real numbers R0\mathbb{R}_{\ge 0}. For any quantity mWithDim(d,M)m \in \text{WithDim}(d, M) and any two unit systems u1,u2UnitChoicesu_1, u_2 \in \text{UnitChoices}, if d=d2d = d_2 (denoted by the proof hh), then casting the scaled quantity to dimension d2d_2 is equivalent to scaling the quantity after it has been cast to dimension d2d_2. That is, cast(scaleUnit(u1,u2,m),h)=scaleUnit(u1,u2,cast(m,h)).\text{cast}(\text{scaleUnit}(u_1, u_2, m), h) = \text{scaleUnit}(u_1, u_2, \text{cast}(m, h)).

instance

Additive commutative group structure on WithDim(d,M)\text{WithDim}(d, M) inherited from MM

For any physical dimension dd and any type MM that forms an additive commutative group, the type WithDim(d,M)\text{WithDim}(d, M) (representing values of type MM carrying the dimension dd) also forms an additive commutative group. The group operations, such as addition, negation, and the zero element, are inherited from the underlying operations of MM.

instance

\le relation on WithDim(d,M)\text{WithDim}(d, M)

For any physical dimension dd and any type MM equipped with a less-than-or-equal-to relation \le, the type WithDim(d,M)\text{WithDim}(d, M) (which represents values of type MM carrying the dimension dd) also possesses a less-than-or-equal-to relation \le. This relation is inherited from MM, meaning for any m1,m2WithDim(d,M)m_1, m_2 \in \text{WithDim}(d, M), m1m2m_1 \le m_2 holds if and only if their underlying values in MM satisfy the relation.

theorem

m1m2m1.valm2.valm_1 \le m_2 \leftrightarrow m_1.\text{val} \le m_2.\text{val} for `WithDim` types

For any physical dimension dd and any type MM equipped with a less-than-or-equal-to relation \le, let m1m_1 and m2m_2 be elements of the type WithDim(d,M)\text{WithDim}(d, M), which represents values of type MM carrying the dimension dd. Then m1m2m_1 \le m_2 holds if and only if their underlying values in MM satisfy m1.valm2.valm_1.\text{val} \le m_2.\text{val}.

instance

Strict inequality << on `WithDim` types

Given a dimension dd and a type MM equipped with a strict inequality relation <<, this instance defines the strict inequality relation for the type WithDim d M\text{WithDim} \ d \ M. For any two elements m1,m2WithDim d Mm_1, m_2 \in \text{WithDim} \ d \ M, the relation m1<m2m_1 < m_2 holds if and only if their underlying values satisfy the relation m1.val<m2.valm_1.\text{val} < m_2.\text{val} in MM.

theorem

m1<m2    m1.val<m2.valm_1 < m_2 \iff m_1.\text{val} < m_2.\text{val} for WithDim\text{WithDim} types

Let dd be a dimension and MM be a type equipped with a strict inequality relation <<. For any elements m1,m2m_1, m_2 of type WithDim d M\text{WithDim} \ d \ M, the relation m1<m2m_1 < m_2 holds if and only if their underlying values satisfy m1.val<m2.valm_1.\text{val} < m_2.\text{val} in MM.

instance

Preorder structure on WithDim(d,M)\text{WithDim}(d, M)

For any physical dimension dd and any type MM equipped with a preorder structure, the type WithDim(d,M)\text{WithDim}(d, M) (representing values of type MM carrying the dimension dd) also forms a preorder. This structure is inherited from MM, where the relations \le and << between two elements m1,m2WithDim(d,M)m_1, m_2 \in \text{WithDim}(d, M) are defined by the relations between their underlying values in MM.

instance

Partial order structure on WithDim(d,M)\text{WithDim}(d, M)

For any physical dimension dd and any type MM equipped with a partial order structure, the type WithDim(d,M)\text{WithDim}(d, M) (representing values of type MM carrying the dimension dd) also forms a partial order. This structure is inherited from MM, where the relations \le and << between two elements m1,m2WithDim(d,M)m_1, m_2 \in \text{WithDim}(d, M) are defined by the corresponding relations between their underlying values m1.valm_1.\text{val} and m2.valm_2.\text{val} in MM.