plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Fix `isEssentiallyWorkFree`

Open effectfully opened this issue 5 months ago • 1 comments

UntypedPlutusCore.Transform.FloatDelay.isEssentiallyWorkFree doesn't make any sense:

isEssentiallyWorkFree :: Term name uni fun a -> Bool
isEssentiallyWorkFree = \case
  LamAbs{}   -> True
  Constant{} -> True
  Delay{}    -> True
  Constr{}   -> True
  Builtin{}  -> True
  Var{}      -> False
  Force{}    -> False
  -- Unsaturated builtin applications should also be essentially work-free,
  -- but this is currently not implemented for UPLC.
  -- `UntypedPlutusCore.Transform.Inline.isPure` has the same problem.
  Apply{}    -> False
  Case{}     -> False
  Error{}    -> False

Why do we consider any Constr node to be essentially work-free if it may literally contain arbitrary computations?

And unsaturated builtin applications should get better treatment, as per the comment (I don't think the part about isPure is correct though, but not sure).

This issue is for fixing all of that, most likely simply by moving to isWorkFree.

effectfully avatar Jul 09 '25 07:07 effectfully

I like the name of this function.

SeungheonOh avatar Jul 11 '25 18:07 SeungheonOh