tweag / pirouette

Language-generic workbench for building static analysis
MIT License
47 stars 2 forks source link

Transformation for removing `/\ dead . T` from the code #125

Closed VictorCMiraldo closed 2 years ago

VictorCMiraldo commented 2 years ago

When working with PlutusIR, the code is infested with things of type /\ dead : * . T where dead doesn't occur in T. We should develop a simple transformation to remove those:

removeAbsDead [|
   (if @(/\ dead : * . Integer) cond 
   then (abs dead : * . 42)
   else (abs dead : * . 0)) 
      @(all dead : * . dead) |]
==> if @Integer cond then 42 else 0
VictorCMiraldo commented 2 years ago

Turns out removeExcessiveDestrArgs was almost enough, https://github.com/tweag/pirouette/pull/123/commits/8726dd73cb1fbfa771f198acb926661afd88069c made it through. Once #123 is merged this issue will be closed.

VictorCMiraldo commented 2 years ago

The actual solution happens to be avoiding builtin booleans and relying on Bool_match, this is handed properly by removeExcessiveDestrArgs. This https://github.com/tweag/plutus-libs/pull/133#issuecomment-1182932751 explains that decision in a little more detail.