From 7524b11ef5f24d40d43156e2437260c55e507ceb Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Tue, 4 Oct 2022 09:02:58 +0200 Subject: [PATCH 01/24] Initial commit of ReadMe.md for MCP-0027 --- RationaleMCP/0027/ReadMe.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 RationaleMCP/0027/ReadMe.md diff --git a/RationaleMCP/0027/ReadMe.md b/RationaleMCP/0027/ReadMe.md new file mode 100644 index 000000000..6d604d515 --- /dev/null +++ b/RationaleMCP/0027/ReadMe.md @@ -0,0 +1,34 @@ +# Modelica Change Proposal MCP-0027
Units of Literal Constants +Francesco Casella, Henrik Tidefelt + +**(In Development)** + +## Summary +The purpose of this MCP is to allow more unit errors to be detected by giving more expressions the unit `"1"` instead of having an undefined unit. +The problem with undefined unit is that it gets in the way of carrying out checking of units (which tools tend to deal with by not checking units at all where this happens). + +## Revisions +| Date | Description | +| --- | --- | +| 2022-10-04 | Henrik Tidefelt. Filling this document with initial content. | + +## Contributor License Agreement +All authors of this MCP or their organizations have signed the "Modelica Contributor License Agreement". + +## Rationale +FIXME + +## Backwards Compatibility +As current Modelica doesn't clearly reject some models with non-sensical combination of units, this MCP will break backwards compatibility by turning at least some of these invalid. + +## Tool Implementation +None, so far. + +### Experience with Prototype +N/A + +## Required Patents +To the best of our knowledge, there are no patents that would conflict with the incorporation of this MCP. + +## References +(None.) From a762fc79b49cba3db5754ff8aa706aecc748b182 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Tue, 25 Oct 2022 18:23:40 +0200 Subject: [PATCH 02/24] Added "four-line" proposal for units of literals --- chapters/lexicalstructure.tex | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 57566e5f3..a551e00d0 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -247,6 +247,44 @@ \subsection{Strings}\label{strings} \end{lstlisting} \end{nonnormative} +\subsection{Units of Literal Constants}\label{units-literal-constants} + +Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed +to have \lstinline!unit = "1"! if they appear in expressions containing variables, +parameters, or constants that have a non-empty \lstinline!unit! attribute string. +The inputs of transcendental built-in functions such as \lstinline!sin()!, +\lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit +(e.g., "1" or "rad") if they involve expressions containing variables, +parameters, or constants that have a non-empty unit attribute string; their +outputs are implicitly assumed to have unit "1" if they are called within +expressions containing variables, parameters, or constants that have a non-empty +\lstinline!unit! attribute string. + +\begin{nonnormative} +Rationale: unit attributes allow to check dimensional consistency of expressions +and equations, as long as all the involved terms have a non-empty \lstinline!unit! +attribute. Non-dimensional literal factors, e.g., \lstinline!2! in +\lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are +always meant to be dimensionless, so they should be cosidered as such by giving +them \lstinline!unit = "1"!. This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! +is dimensionally inconsistent (hence most likely wrong), because it has unit +"m/s" on the LHS and unit "m0.5" on the RHS, which are not consistent. +Without this rule, \lstinline!2! would have the default \lstinline!unit = ""!, +of \lstinline!Real!, making it impossible to determine the RHS unit. + +On the other hand, literal constants showing up in expressions containing only +literal constants should be left with the default \lstinline!unit = ""! +attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, +equations such as \lstinline!L = 2.0! and function calls such as +\lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! +would be erroneously flagged as dimensionally inconsistent. + +The rules involving built-in transcendental functions extend the scope of this +concept to also allow determining that equations such as +\lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally +inconsistent. +\end{nonnormative} + \section{Operator Symbols}\label{operator-symbols} The predefined operator symbols are formally defined on page \pageref{lexical-conventions} and From bdbea3b1d3222e7d5c1a3091798759dff6ea4888 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Wed, 26 Oct 2022 23:13:45 +0200 Subject: [PATCH 03/24] Reformatted to use sentence-based line breaks. Added inline codes for units. Fixed typos --- chapters/lexicalstructure.tex | 44 ++++++++++------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index a551e00d0..9dbbe7fd8 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -249,40 +249,20 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} -Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed -to have \lstinline!unit = "1"! if they appear in expressions containing variables, -parameters, or constants that have a non-empty \lstinline!unit! attribute string. -The inputs of transcendental built-in functions such as \lstinline!sin()!, -\lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit -(e.g., "1" or "rad") if they involve expressions containing variables, -parameters, or constants that have a non-empty unit attribute string; their -outputs are implicitly assumed to have unit "1" if they are called within -expressions containing variables, parameters, or constants that have a non-empty -\lstinline!unit! attribute string. +Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have \lstinline!unit = "1"! if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. + +The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"| or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. +Their outputs are implicitly assumed to have unit \lstinline!"1"! if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. \begin{nonnormative} -Rationale: unit attributes allow to check dimensional consistency of expressions -and equations, as long as all the involved terms have a non-empty \lstinline!unit! -attribute. Non-dimensional literal factors, e.g., \lstinline!2! in -\lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are -always meant to be dimensionless, so they should be cosidered as such by giving -them \lstinline!unit = "1"!. This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! -is dimensionally inconsistent (hence most likely wrong), because it has unit -"m/s" on the LHS and unit "m0.5" on the RHS, which are not consistent. -Without this rule, \lstinline!2! would have the default \lstinline!unit = ""!, -of \lstinline!Real!, making it impossible to determine the RHS unit. - -On the other hand, literal constants showing up in expressions containing only -literal constants should be left with the default \lstinline!unit = ""! -attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, -equations such as \lstinline!L = 2.0! and function calls such as -\lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! -would be erroneously flagged as dimensionally inconsistent. - -The rules involving built-in transcendental functions extend the scope of this -concept to also allow determining that equations such as -\lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally -inconsistent. +Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute. +Non-dimensional literal factors, e.g., \lstinline!2! in \lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are always meant to be dimensionless, so they should be considered as such by giving them \lstinline!unit = "1"!. +This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the LHS and unit \lstinline!"m0.5"! on the RHS, which are not consistent. +Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the RHS unit. + +On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. + +The rules involving built-in transcendental functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. \end{nonnormative} \section{Operator Symbols}\label{operator-symbols} From eb116d78e54c44ea31550cf07548a94f66215902 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Wed, 26 Oct 2022 23:35:33 +0200 Subject: [PATCH 04/24] Wrote out LHS and RHS --- chapters/lexicalstructure.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 9dbbe7fd8..8781a7479 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -257,8 +257,8 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} \begin{nonnormative} Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute. Non-dimensional literal factors, e.g., \lstinline!2! in \lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are always meant to be dimensionless, so they should be considered as such by giving them \lstinline!unit = "1"!. -This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the LHS and unit \lstinline!"m0.5"! on the RHS, which are not consistent. -Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the RHS unit. +This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the left-hand side and unit \lstinline!"m0.5"! on the right-hand side, which are not consistent. +Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit. On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. From b676ad905c6bf7cb09790dcada517c0dc699d741 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 27 Oct 2022 01:00:48 +0200 Subject: [PATCH 05/24] Outputs of transcendental functions should be dimensionless Co-authored-by: Hans Olsson --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 8781a7479..18107c43e 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -252,7 +252,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have \lstinline!unit = "1"! if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"| or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. -Their outputs are implicitly assumed to have unit \lstinline!"1"! if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. +Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. \begin{nonnormative} Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute. From 11dc52d3c23c764ed6a5b00990712f299ccdd2a4 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 27 Oct 2022 23:22:31 +0200 Subject: [PATCH 06/24] Fixed type Co-authored-by: Henrik Tidefelt --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 18107c43e..35ebe2ce9 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -251,7 +251,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have \lstinline!unit = "1"! if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. -The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"| or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. +The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. \begin{nonnormative} From 9a1deda1f2773ee2ef03bc339429f481a51d8508 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Fri, 28 Oct 2022 18:24:32 +0200 Subject: [PATCH 07/24] Updated proposal --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 35ebe2ce9..c3c6b1ae8 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -262,7 +262,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. -The rules involving built-in transcendental functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. +The rules involving elementary mathematical functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. \end{nonnormative} \section{Operator Symbols}\label{operator-symbols} From df6242ba161bd12fb9df286c5ce0c32504952e10 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Wed, 2 Nov 2022 23:53:35 +0100 Subject: [PATCH 08/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index c3c6b1ae8..6481e2695 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -249,7 +249,7 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} -Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have \lstinline!unit = "1"! if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. +Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have a dimensionless unit if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string, or function calls that have a non-empty \lstinline!unit! attribute of the output variable. The same rule applies to function call inputs. The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. From 5d5f46669caf2b0cb964fce53afa6b6915ed6081 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Wed, 2 Nov 2022 23:57:39 +0100 Subject: [PATCH 09/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 6481e2695..7834d9306 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -251,7 +251,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have a dimensionless unit if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string, or function calls that have a non-empty \lstinline!unit! attribute of the output variable. The same rule applies to function call inputs. -The inputs of transcendental built-in functions such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if they involve expressions containing variables, parameters, or constants that have a non-empty unit attribute string. +The inputs of the elementary mathematical functions defined in \cref{built-in-mathematical-functions-and-external-built-in-functions} such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if the unit string of the input is non-empty. Function \lstinline!atan2(y,x)! should be treated as \lstinline!atan(x/y)! for dimensional consistency checking purposes. Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. \begin{nonnormative} From 398c013e29504300c9bef3cac55f80f3de21709b Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:07:08 +0100 Subject: [PATCH 10/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 7834d9306..a925c95a5 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -249,7 +249,11 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} -Literal \lstinline!Real! and \lstinline!Integer! constants are implicitly assumed to have a dimensionless unit if they appear in expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string, or function calls that have a non-empty \lstinline!unit! attribute of the output variable. The same rule applies to function call inputs. +The following rules apply: +- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is a variable with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. +- The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. +- The result of `x^L` shall have the \lstinline!unit! attribute string of `product(fill(x, L))` if L is a positive Integer, or the unit of `1/product(fill(x, L))` if L is a negative Integer +- If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. The inputs of the elementary mathematical functions defined in \cref{built-in-mathematical-functions-and-external-built-in-functions} such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if the unit string of the input is non-empty. Function \lstinline!atan2(y,x)! should be treated as \lstinline!atan(x/y)! for dimensional consistency checking purposes. Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. From 7a9f340981450d08717222b70ad6b524758f7c0e Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:07:31 +0100 Subject: [PATCH 11/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index a925c95a5..cec373ccd 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -256,7 +256,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. The inputs of the elementary mathematical functions defined in \cref{built-in-mathematical-functions-and-external-built-in-functions} such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if the unit string of the input is non-empty. Function \lstinline!atan2(y,x)! should be treated as \lstinline!atan(x/y)! for dimensional consistency checking purposes. -Their outputs are also implicitly assumed to have a dimensionless unit if they are called within expressions containing variables, parameters, or constants that have a non-empty \lstinline!unit! attribute string. +In that case, their outputs are also implicitly assumed to have a dimensionless unit. \begin{nonnormative} Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute. From 77eaae734100afbc0aa496c5bb50cd9eca55c2dd Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:07:47 +0100 Subject: [PATCH 12/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index cec373ccd..d265538e8 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -259,7 +259,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} In that case, their outputs are also implicitly assumed to have a dimensionless unit. \begin{nonnormative} -Rationale: unit attributes allow to check dimensional consistency of expressions and equations, as long as all the involved terms have a non-empty \lstinline!unit! attribute. +Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ Non-dimensional literal factors, e.g., \lstinline!2! in \lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are always meant to be dimensionless, so they should be considered as such by giving them \lstinline!unit = "1"!. This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the left-hand side and unit \lstinline!"m0.5"! on the right-hand side, which are not consistent. Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit. From 8916f6efcf5f76ce65746888821aed97075e4703 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:08:15 +0100 Subject: [PATCH 13/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 1 - 1 file changed, 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index d265538e8..9571cf510 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -260,7 +260,6 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} \begin{nonnormative} Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ -Non-dimensional literal factors, e.g., \lstinline!2! in \lstinline!v = sqrt(2*g*h)! in physical laws involving quantities with units are always meant to be dimensionless, so they should be considered as such by giving them \lstinline!unit = "1"!. This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the left-hand side and unit \lstinline!"m0.5"! on the right-hand side, which are not consistent. Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit. From 2c817dd7ab01b81fec9cfdec3721b6bb95ab2501 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:08:45 +0100 Subject: [PATCH 14/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 1 - 1 file changed, 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 9571cf510..a84b3b8fe 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -260,7 +260,6 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} \begin{nonnormative} Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ -This allows to find out that, e.g., \lstinline!v = sqrt(2*h)! is dimensionally inconsistent (hence most likely wrong), because it has unit \lstinline!"m/s"! on the left-hand side and unit \lstinline!"m0.5"! on the right-hand side, which are not consistent. Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit. On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. From 942776f3cdc0484abed4aa80ae2b16658ef936d0 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:09:26 +0100 Subject: [PATCH 15/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 1 - 1 file changed, 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index a84b3b8fe..eb70c03df 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -260,7 +260,6 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} \begin{nonnormative} Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ -Without this rule, \lstinline!2! would have the default \lstinline!unit = ""! of \lstinline!Real!, making it impossible to determine the right-hand side unit. On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. From b3e0dc132153ce636452cc7200dea382afe5f904 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 00:10:10 +0100 Subject: [PATCH 16/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 1 - 1 file changed, 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index eb70c03df..7010889b1 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -261,7 +261,6 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} \begin{nonnormative} Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ -On the other hand, literal constants showing up in expressions containing only literal constants should be left with the default \lstinline!unit = ""! attribute, otherwise declarations such as \lstinline!Real L(unit = "m") = 2.0!, equations such as \lstinline!L = 2.0! and function calls such as \lstinline!temperature_ph(1e5, 293.15)! or \lstinline!temperature_ph(1e5, 273.15 + 20)! would be erroneously flagged as dimensionally inconsistent. The rules involving elementary mathematical functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. \end{nonnormative} From 3370313c326a1cf016d29400c1edae76e9841004 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 16:16:30 +0100 Subject: [PATCH 17/24] Update lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 7010889b1..0754d5fd1 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -259,7 +259,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} In that case, their outputs are also implicitly assumed to have a dimensionless unit. \begin{nonnormative} -Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing to perform dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ +Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ The rules involving elementary mathematical functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. From 7539f1be33b85639ac55a66622cad206c790d5d4 Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Thu, 10 Nov 2022 16:18:51 +0100 Subject: [PATCH 18/24] Update lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 0754d5fd1..459d7ea31 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -250,7 +250,7 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: -- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is a variable with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. +- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. - The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. - The result of `x^L` shall have the \lstinline!unit! attribute string of `product(fill(x, L))` if L is a positive Integer, or the unit of `1/product(fill(x, L))` if L is a negative Integer - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. From 15bb5546e1175c8647cc4b9caf3a47a108856ab9 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 11 Nov 2022 10:19:09 +0100 Subject: [PATCH 19/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 459d7ea31..9fcc229de 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -251,7 +251,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: - The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. -- The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. +- The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. - The result of `x^L` shall have the \lstinline!unit! attribute string of `product(fill(x, L))` if L is a positive Integer, or the unit of `1/product(fill(x, L))` if L is a negative Integer - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. From 26bce834c00c68756dbbafc464e1b0a927e3d2c7 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 11 Nov 2022 10:32:14 +0100 Subject: [PATCH 20/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 9fcc229de..4b3e7548a 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -252,7 +252,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: - The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. - The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. -- The result of `x^L` shall have the \lstinline!unit! attribute string of `product(fill(x, L))` if L is a positive Integer, or the unit of `1/product(fill(x, L))` if L is a negative Integer +- The result of \lstinline!x^L! shall have the \lstinline!unit! attribute string of \lstinline!product(fill(x, L))! if L is a positive Integer, or the unit of \lstinline!1/product(fill(x, L))! if L is a negative Integer - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. The inputs of the elementary mathematical functions defined in \cref{built-in-mathematical-functions-and-external-built-in-functions} such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if the unit string of the input is non-empty. Function \lstinline!atan2(y,x)! should be treated as \lstinline!atan(x/y)! for dimensional consistency checking purposes. From ba23447d80713456325ca71fc43a2220b7abbc70 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 11 Nov 2022 11:22:37 +0100 Subject: [PATCH 21/24] Update chapters/lexicalstructure.tex to make latex work --- chapters/lexicalstructure.tex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 4b3e7548a..4293b939e 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -259,7 +259,10 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} In that case, their outputs are also implicitly assumed to have a dimensionless unit. \begin{nonnormative} -Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing dimensional consistency checking of equations that contain them. The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that `v = sqrt(2*g*h)` is dimensionally consistent, while `v = sqrt(2*g)` is dimensionally inconsistent, and thus most likely wrong. The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. For example, they allow to determine that `tau = L/(abs(v) + 1e-9)` is dimensionally consistent, while `tau = 1/(abs(v) + 1e-9)` is not.]_ +Rationale: by default, literal Real and Integer constants do not have a defined, non-empty \lstinline!unit! string attribute; hence they act as "unit wildcards", preventing dimensional consistency checking of equations that contain them. +The rules regarding multiplication and division prevent this effect, allowing, e.g., to determine that \lstinline!v = sqrt(2*g*h)! is dimensionally consistent, while \lstinline!v = sqrt(2*g)! is dimensionally inconsistent, and thus most likely wrong. +The rules regarding addition and subtraction instead allow to perform some basic unit inference in expressions containing mixed literal constants and variables (when there are no ambiguities in doing so), again expanding the scope for dimensional consistency checking. +For example, they allow to determine that \lstinline!tau = L/(abs(v) + 1e-9)! is dimensionally consistent, while \lstinline!tau = 1/(abs(v) + 1e-9)! is not. The rules involving elementary mathematical functions extend the scope of this concept to also allow determining that equations such as \lstinline!i = i0*exp(v/i0)! or \lstinline!i = v0*exp(i/i0)! are dimensionally inconsistent. From 4a7c94188f39c30f44dd666e647eb48bf7b18301 Mon Sep 17 00:00:00 2001 From: Hans Olsson Date: Fri, 11 Nov 2022 11:23:54 +0100 Subject: [PATCH 22/24] Update chapters/lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 4293b939e..eeefdb138 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -251,7 +251,7 @@ \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: - The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. -- The result of `L/x` shall the the \lstinline!unit! attribute string `1/()`. +- The result of `L/x` shall have the \lstinline!unit! attribute string `1/()`. - The result of \lstinline!x^L! shall have the \lstinline!unit! attribute string of \lstinline!product(fill(x, L))! if L is a positive Integer, or the unit of \lstinline!1/product(fill(x, L))! if L is a negative Integer - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. From 0f5c46a1b5abbd89e122d603ec35a5bd284b5f6f Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Tue, 15 Nov 2022 02:43:00 +0100 Subject: [PATCH 23/24] Update lexicalstructure.tex --- chapters/lexicalstructure.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index eeefdb138..7dae826f3 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -250,7 +250,7 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: -- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of `x`. +- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string as `x`. - The result of `L/x` shall have the \lstinline!unit! attribute string `1/()`. - The result of \lstinline!x^L! shall have the \lstinline!unit! attribute string of \lstinline!product(fill(x, L))! if L is a positive Integer, or the unit of \lstinline!1/product(fill(x, L))! if L is a negative Integer - If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. From e325f6f8b111afa3a1f87126a18d087ce6cd6d0b Mon Sep 17 00:00:00 2001 From: Francesco Casella Date: Tue, 15 Nov 2022 02:54:35 +0100 Subject: [PATCH 24/24] Used LaTeX instead of rST for itemized list --- chapters/lexicalstructure.tex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chapters/lexicalstructure.tex b/chapters/lexicalstructure.tex index 7dae826f3..9360d9a7b 100644 --- a/chapters/lexicalstructure.tex +++ b/chapters/lexicalstructure.tex @@ -250,10 +250,12 @@ \subsection{Strings}\label{strings} \subsection{Units of Literal Constants}\label{units-literal-constants} The following rules apply: -- The result of `x + L`, `L + x`, `x - L`, `L - x`, `x*L`, `L*x`, `x/L`, where `x` is an expression with non-empty \lstinline!unit! attribute string `` and `L` is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string as `x`. -- The result of `L/x` shall have the \lstinline!unit! attribute string `1/()`. -- The result of \lstinline!x^L! shall have the \lstinline!unit! attribute string of \lstinline!product(fill(x, L))! if L is a positive Integer, or the unit of \lstinline!1/product(fill(x, L))! if L is a negative Integer -- If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. +\begin{itemize} +\item The result of \lstinline!x + L!, \lstinline!L + x\lstinline!, \lstinline!x - L!, \lstinline!L - x!, \lstinline!x*L!, \lstinline!L*x!, \lstinline!x/L!, where \lstinline!x! is an expression with non-empty \lstinline!unit! attribute string `` and \lstinline!L! is an expression containing only literal constants, shall have the same \lstinline!unit! attribute string of \lstinline!x!. +\item The result of \lstinline!L/x\lstinline! shall have the \lstinline!unit! attribute string `1/()`. +\item The result of \lstinline!x^L! shall have the \lstinline!unit! attribute string of \lstinline!product(fill(x, L))! if L is a positive Integer, or the unit of \lstinline!1/product(fill(x, L))! if L is a negative Integer. +\item If either side of a relational operator is a literal constant, then it is assumed to have the same \lstinline!unit! attribute string of the other side, if that is well-defined. +\end{itemize} The inputs of the elementary mathematical functions defined in \cref{built-in-mathematical-functions-and-external-built-in-functions} such as \lstinline!sin()!, \lstinline!cos()!, \lstinline!exp()!, etc., should have a dimensionless unit (e.g., \lstinline!"1"! or \lstinline!"rad"!) if the unit string of the input is non-empty. Function \lstinline!atan2(y,x)! should be treated as \lstinline!atan(x/y)! for dimensional consistency checking purposes. In that case, their outputs are also implicitly assumed to have a dimensionless unit.