1515import liquidjava .rj_language .ast .UnaryExpression ;
1616
1717/**
18- * Simplifies VCImplication chains by applying arithmetic identities inside refinements.
18+ * Simplifies VCImplication chains by applying arithmetic identities inside refinements
1919 */
2020public class VCArithmeticSimplification {
2121
2222 /**
23- * Applies the first arithmetic simplification available in a VC chain.
23+ * Applies the first arithmetic simplification available in a VC chain
2424 */
2525 public static VCImplication apply (VCImplication implication ) {
2626 if (implication == null )
@@ -55,7 +55,7 @@ private static VCImplication apply(VCImplication implication, List<Expression> n
5555 }
5656
5757 /**
58- * Simplifies the first arithmetic identity found inside an expression.
58+ * Simplifies the first arithmetic identity found inside an expression
5959 */
6060 private static Expression simplify (Expression expression , List <Expression > nonZeroExpressions ) {
6161 if (expression instanceof BinaryExpression binary )
@@ -70,7 +70,7 @@ private static Expression simplify(Expression expression, List<Expression> nonZe
7070 }
7171
7272 /**
73- * Simplifies a binary expression by visiting operands before the current node.
73+ * Simplifies a binary expression by visiting operands before the current node
7474 */
7575 private static Expression simplifyBinary (BinaryExpression binary , List <Expression > nonZeroExpressions ) {
7676 Expression left = binary .getFirstOperand ();
@@ -91,7 +91,7 @@ private static Expression simplifyBinary(BinaryExpression binary, List<Expressio
9191 }
9292
9393 /**
94- * Simplifies a unary expression by visiting its operand before the current node.
94+ * Simplifies a unary expression by visiting its operand before the current node
9595 */
9696 private static Expression simplifyUnary (UnaryExpression unary , List <Expression > nonZeroExpressions ) {
9797 Expression operand = unary .getExpression ();
@@ -107,7 +107,7 @@ private static Expression simplifyUnary(UnaryExpression unary, List<Expression>
107107 }
108108
109109 /**
110- * Simplifies a ternary expression by visiting condition, then branch, and else branch.
110+ * Simplifies a ternary expression by visiting condition, then branch, and else branch
111111 */
112112 private static Expression simplifyIte (Ite ite , List <Expression > nonZeroExpressions ) {
113113 Expression condition = ite .getCondition ();
@@ -129,7 +129,7 @@ private static Expression simplifyIte(Ite ite, List<Expression> nonZeroExpressio
129129 }
130130
131131 /**
132- * Simplifies an expression wrapped in parentheses while preserving the group node.
132+ * Simplifies an expression wrapped in parentheses while preserving the group node
133133 */
134134 private static Expression simplifyGroup (GroupExpression group , List <Expression > nonZeroExpressions ) {
135135 Expression expression = group .getExpression ();
@@ -140,7 +140,7 @@ private static Expression simplifyGroup(GroupExpression group, List<Expression>
140140 }
141141
142142 /**
143- * Dispatches a local binary arithmetic identity by operator.
143+ * Dispatches a local binary arithmetic identity by operator
144144 */
145145 private static Expression simplifyLocalBinary (Expression left , Expression right , String op ,
146146 List <Expression > nonZeroExpressions ) {
@@ -155,7 +155,7 @@ private static Expression simplifyLocalBinary(Expression left, Expression right,
155155 }
156156
157157 /**
158- * Applies addition identities involving zero and unary negation.
158+ * Applies addition identities involving zero and unary negation
159159 */
160160 private static Expression simplifyAddition (Expression left , Expression right ) {
161161 // x + 0 -> x
@@ -177,7 +177,7 @@ private static Expression simplifyAddition(Expression left, Expression right) {
177177 }
178178
179179 /**
180- * Applies subtraction identities involving zero, same operands, and unary negation.
180+ * Applies subtraction identities involving zero, same operands, and unary negation
181181 */
182182 private static Expression simplifySubtraction (Expression left , Expression right ) {
183183 // x - 0 -> x
@@ -196,7 +196,7 @@ private static Expression simplifySubtraction(Expression left, Expression right)
196196 }
197197
198198 /**
199- * Applies multiplication identities involving one and zero.
199+ * Applies multiplication identities involving one and zero
200200 */
201201 private static Expression simplifyMultiplication (Expression left , Expression right ) {
202202 // x * 1 -> x
@@ -215,7 +215,7 @@ private static Expression simplifyMultiplication(Expression left, Expression rig
215215 }
216216
217217 /**
218- * Applies division identities, using prior non-zero premises when needed.
218+ * Applies division identities, using prior non-zero premises when needed
219219 */
220220 private static Expression simplifyDivision (Expression left , Expression right , List <Expression > nonZeroExpressions ) {
221221 // x / 1 -> x
@@ -231,7 +231,7 @@ private static Expression simplifyDivision(Expression left, Expression right, Li
231231 }
232232
233233 /**
234- * Applies modulo identities, using prior non-zero premises when needed.
234+ * Applies modulo identities, using prior non-zero premises when needed
235235 */
236236 private static Expression simplifyModulo (Expression left , Expression right , List <Expression > nonZeroExpressions ) {
237237 // x % 1 -> 0
@@ -244,7 +244,7 @@ private static Expression simplifyModulo(Expression left, Expression right, List
244244 }
245245
246246 /**
247- * Records direct non-zero premises shaped as expr != 0 or 0 != expr.
247+ * Records direct non-zero premises shaped as x != 0 or 0 != x
248248 */
249249 private static void addNonZeroExpression (Expression expression , List <Expression > nonZeroExpressions ) {
250250 if (!(expression instanceof BinaryExpression binary ) || !"!=" .equals (binary .getOperator ()))
@@ -259,14 +259,14 @@ private static void addNonZeroExpression(Expression expression, List<Expression>
259259 }
260260
261261 /**
262- * Checks whether a previous premise recorded an expression as non-zero.
262+ * Checks whether a previous premise recorded an expression as non-zero
263263 */
264264 private static boolean isNonZero (Expression expression , List <Expression > nonZeroExpressions ) {
265265 return nonZeroExpressions .stream ().anyMatch (e -> e .equals (expression ));
266266 }
267267
268268 /**
269- * Checks whether an expression is a numeric zero literal.
269+ * Checks whether an expression is a numeric zero literal
270270 */
271271 private static boolean isZero (Expression expression ) {
272272 if (expression instanceof LiteralInt literal )
@@ -277,7 +277,7 @@ private static boolean isZero(Expression expression) {
277277 }
278278
279279 /**
280- * Checks whether an expression is a numeric one literal.
280+ * Checks whether an expression is a numeric one literal
281281 */
282282 private static boolean isOne (Expression expression ) {
283283 if (expression instanceof LiteralInt literal )
@@ -288,14 +288,14 @@ private static boolean isOne(Expression expression) {
288288 }
289289
290290 /**
291- * Checks whether an expression is unary negation.
291+ * Checks whether an expression is unary negation
292292 */
293293 private static boolean isNegation (Expression expression ) {
294294 return expression instanceof UnaryExpression unary && "-" .equals (unary .getOp ());
295295 }
296296
297297 /**
298- * Reads the operand of a unary negation expression.
298+ * Returns the operand of a unary negation expression
299299 */
300300 private static Expression negatedExpression (Expression expression ) {
301301 return ((UnaryExpression ) expression ).getExpression ();
0 commit comments