Plutonomicon / Shrinker

Shrink Plutus scripts
Apache License 2.0
6 stars 3 forks source link

Incomplete substitutions #8

Open blamario opened 2 years ago

blamario commented 2 years ago

When I feed shrinkScript this UPLC:"(program 1.0.0 ((\i0 -> force i1 (\i0 -> \i0 -> \i0 -> i2)) ((\i0 -> \i0 -> \i0 -> (\i0 -> \i0 -> i2 i4 6 \"Hello\") (\i0 -> \i0 -> \i0 -> delay (\i0 -> i1 i4 i3 i2)) (\i0 -> i1)) (delay (\i0 -> \i0 -> i2)) (delay (\i0 -> \i0 -> i1)) (\i0 -> i1))))"`

I get "(program 1.0.0 (force ((\\i0 -> delay (\\i0 -> i1 (delay (\\i0 -> \\i0 -> i1)) 6 i2)) \"Hello\") (\\i0 -> \\i0 -> \\i0 -> i2)))"

but there's obvious opportunity to reduce it further: (\\i0 -> delay (\\i0 -> i1 (delay (\\i0 -> \\i0 -> i1)) 6 i2)) \"Hello\") ==> (delay (\\i0 -> i1 (delay (\\i0 -> \\i0 -> i1)) 6 \"Hello\")))

blamario commented 2 years ago

It's the last test in this test suite: https://github.com/blamario/plutarch-with-ghc-8.10.7/blob/6b1133423b7b268b7a0fbfe619357b108b9529f4/test/Spec.hs

blamario commented 2 years ago

I worked around the problem by running the shrinker thrice:

printShrunkCode :: CompiledCode a -> String
printShrunkCode = printScript . shrink . shrink . shrink . fromCompiledCode
  where
    shrink = shrinkScriptSp (withoutTactics ["strongUnsubs", "weakUnsubs"])