diff --git a/chapters/operatorsandexpressions.tex b/chapters/operatorsandexpressions.tex index 24cda4c38..2af64dd44 100644 --- a/chapters/operatorsandexpressions.tex +++ b/chapters/operatorsandexpressions.tex @@ -1457,16 +1457,6 @@ \subsection{Discrete-Time Expressions}\label{discrete-time-expressions} Expressions in functions behave as though they were discrete-time expressions. \end{itemize} -For an equation \lstinline!expr1 = expr2! where neither expression is of base type -\lstinline!Real!, both expressions must be discrete-time expressions. For record -equations the equation is split into basic types before applying this -test. - -\begin{nonnormative} -This restriction guarantees that \lstinline!noEvent! cannot be applied to \lstinline!Boolean!, \lstinline!Integer!, \lstinline!String!, or \lstinline!enumeration! -equations outside of a \lstinline!when!-clause, because then one of the two expressions is not discrete-time. -\end{nonnormative} - Inside an if-expression, \lstinline!if!-clause, \lstinline!while!-statement or \lstinline!for!-clause, that is controlled by a non-discrete-time (that is continuous-time, but not discrete-time) switching expression and not in the body of a @@ -1479,6 +1469,20 @@ \subsection{Discrete-Time Expressions}\label{discrete-time-expressions} functions do not become active between events. \end{nonnormative} +\begin{nonnormative} +For a scalar equation \lstinline!expr1 = expr2! where neither expression is of base type \lstinline!Real!, both expressions must be discrete-time expressions. + +The rule follows from the observation that a discrete-valued equation does not provide sufficient information to solve for a continuous-valued variable. +Hence, and according to the perfect matching rule (see \cref{synchronous-data-flow-principle-and-single-assignment-rule}), such an equation must be used to solve for a discrete-valued variable. +By the interpretation of \eqref{eq:dae-discrete-valued} in \cref{modelica-dae-representation}, it follows that one of \lstinline!expr1! and \lstinline!expr2! must be the variable, and the other expression its solution. +Since a discrete-valued variable is a discrete-time variable, it follows that its solution on the other side of the equation must have at most discrete-time variability. +That is, both sides of the equation are discrete-time expressions. + +The rule is equally applicable to the scalar components of a non-scalar equation. + +For example, this rule shows that (outside of a \lstinline!when!-clause) \lstinline!noEvent! cannot be applied to either side of a \lstinline!Boolean!, \lstinline!Integer!, \lstinline!String!, or \lstinline!enumeration! equation, as this would result in a non-discrete-time expression. +\end{nonnormative} + \begin{example} The (underdetermined) model \lstinline!Test! below illustrates two kinds of consequences due to variability constraints. First, it contains variability errors for declaration equations and assignments.