Skip to content

Preserve Origins in Ternary Simplifications#231

Open
rcosta358 wants to merge 1 commit into
mainfrom
preserve-origins-ite
Open

Preserve Origins in Ternary Simplifications#231
rcosta358 wants to merge 1 commit into
mainfrom
preserve-origins-ite

Conversation

@rcosta358
Copy link
Copy Markdown
Collaborator

Description

This PR fixes a debug in the simplification of ternary predicates. Previously, variable propagation substituted values inside ite and parenthesized group expression nodes but dropped the child origin tree, and foldIte then folded the ternary condition without that origin. As a result, some origins were not shown in the derivation tree.

Example

@StateRefinement(
to ="mode == ImageWriteParam.MODE_EXPLICIT ?
     compressionExplicit(this) :
     startCompression(this)"
)
void setCompressionMode(int mode);

Before

{
  "value": "startCompression(param³³)",
  "origin": {
    "condition": {
      "value": false,
      "origin": {
        "op": "==",
        "left": {
          "value": 1,
          "origin": {
            "value": "ImageWriteParam.MODE_DEFAULT" // no origin
          }
        },
        "right": {
          "value": 2,
          "origin": {
            "value": "ImageWriteParam.MODE_EXPLICIT"
          }
        }
      }
    },
    "thenBranch": {
      "value": "compressionExplicit(param³³)"
    },
    "elseBranch": {
      "value": "startCompression(param³³)"
    }
  }
}

After

{
  "value": "startCompression(param³³)",
  "origin": {
    "condition": {
      "value": false,
      "origin": {
        "op": "==",
        "left": {
          "value": 1,
          "origin": {
            "value": "ImageWriteParam.MODE_DEFAULT",
            "origin": {
              "var": "mode³²" // with origin
            }
          }
        },
        "right": {
          "value": 2,
          "origin": {
            "value": "ImageWriteParam.MODE_EXPLICIT"
          }
        }
      }
    },
    "thenBranch": {
      "value": "compressionExplicit(param³³)"
    },
    "elseBranch": {
      "value": "startCompression(param³³)"
    }
  }
}

Related Issue

None.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Checklist

  • Added/updated tests in ExpressionSimplifierTest
  • mvn test passes locally
  • Updated docs/README if behavior or API changed

@rcosta358 rcosta358 requested a review from CatarinaGamboa May 22, 2026 14:20
@rcosta358 rcosta358 self-assigned this May 22, 2026
@rcosta358 rcosta358 added bug Something isn't working simplification Related to the simplification of expressions labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working simplification Related to the simplification of expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant