@@ -120,9 +120,7 @@ void testSimpleComparison() {
120120 ValDerivationNode trueFromOr = new ValDerivationNode (new LiteralBoolean (true ), orFalseTrue );
121121
122122 // !true = false
123- ValDerivationNode valTrue2 = new ValDerivationNode (new LiteralBoolean (true ), null );
124- UnaryDerivationNode notOp = new UnaryDerivationNode (valTrue2 , "!" );
125- ValDerivationNode falseFromNot = new ValDerivationNode (new LiteralBoolean (false ), notOp );
123+ ValDerivationNode falseFromNot = new ValDerivationNode (new LiteralBoolean (false ), null );
126124
127125 // true && false = false
128126 BinaryDerivationNode andTrueFalse = new BinaryDerivationNode (trueFromOr , falseFromNot , "&&" );
@@ -187,10 +185,8 @@ void testArithmeticWithConstants() {
187185 BinaryDerivationNode div6By2 = new BinaryDerivationNode (val6 , val2 , "/" );
188186 ValDerivationNode val3 = new ValDerivationNode (new LiteralInt (3 ), div6By2 );
189187
190- // -5 from unary negation of 5
191- ValDerivationNode val5 = new ValDerivationNode (new LiteralInt (5 ), null );
192- UnaryDerivationNode unaryNeg5 = new UnaryDerivationNode (val5 , "-" );
193- ValDerivationNode valNeg5 = new ValDerivationNode (new LiteralInt (-5 ), unaryNeg5 );
188+ // -5 is a literal with no origin
189+ ValDerivationNode valNeg5 = new ValDerivationNode (new LiteralInt (-5 ), null );
194190
195191 // 3 + (-5) = -2
196192 BinaryDerivationNode add3AndNeg5 = new BinaryDerivationNode (val3 , valNeg5 , "+" );
@@ -580,6 +576,29 @@ void testShouldNotOversimplifyToTrue() {
580576 "Should stop simplification before collapsing to true" );
581577 }
582578
579+ @ Test
580+ void testNoSimplificationHasNoOrigin () {
581+ // Given: x > 0 && y >= -128 && y <= 127
582+ // Expected: same expression with no origin (nothing to simplify)
583+
584+ Expression varX = new Var ("x" );
585+ Expression varY = new Var ("y" );
586+ Expression xGreater0 = new BinaryExpression (varX , ">" , new LiteralInt (0 ));
587+ Expression yGeMinus128 = new BinaryExpression (varY , ">=" , new UnaryExpression ("-" , new LiteralInt (128 )));
588+ Expression yLe127 = new BinaryExpression (varY , "<=" , new LiteralInt (127 ));
589+ Expression firstAnd = new BinaryExpression (xGreater0 , "&&" , yGeMinus128 );
590+ Expression fullExpression = new BinaryExpression (firstAnd , "&&" , yLe127 );
591+
592+ // When
593+ ValDerivationNode result = ExpressionSimplifier .simplify (fullExpression );
594+
595+ // Then
596+ assertNotNull (result , "Result should not be null" );
597+ assertEquals ("x > 0 && y >= -128 && y <= 127" , result .getValue ().toString (),
598+ "Expression should remain unchanged" );
599+ assertNull (result .getOrigin (), "No origin should be present when nothing was simplified" );
600+ }
601+
583602 /**
584603 * Helper method to compare two derivation nodes recursively
585604 */
0 commit comments