An expression is any mathematical formula that contains certain formal variables and operations to be executed in a specified order. In computer science, it is usually convenient to represent each expression in the form of an expression tree. Here, we consider only arithmetic expressions, i.e., those that contain only the four standard arithmetic operations: addition, subtraction, multiplication and division, alongside additive inversion. We first provide certain theoretical results concerning the equivalence of such expressions and then disclose a $\Theta(n^2)$ algorithm that computes the number of inequivalent arithmetic expressions on $n$ distinct variables.
翻译:表达式是包含特定形式变量及按指定顺序执行运算的数学公式。在计算机科学中,通常将每个表达式表示为表达式树的形式。本文仅考虑算术表达式,即仅包含四种标准算术运算(加法、减法、乘法、除法)以及加法逆元的表达式。我们首先给出关于此类表达式等价性的若干理论结果,随后提出一种计算$n$个不同变量上不等价算术表达式数目的$\Theta(n^2)$算法。