Plutonomicon / plutarch-plutus

Typed eDSL for writing UPLC /ˈpluː.tɑːk/
MIT License
123 stars 63 forks source link

Bug in `pcontains` #705

Open peter-mlabs opened 1 month ago

peter-mlabs commented 1 month ago

It appears that pcontains is not working properly.

ghci> i1
Interval {ivFrom = LowerBound (Finite (POSIXTime {getPOSIXTime = 120})) True, ivTo = UpperBound (Finite (POSIXTime {getPOSIXTime = 129})) False}
ghci> i2
Interval {ivFrom = LowerBound (Finite (POSIXTime {getPOSIXTime = 120})) True, ivTo = UpperBound (Finite (POSIXTime {getPOSIXTime = 129})) True}
ghci> contains i2 i1
True
ghci> plift $ pcontains # pconstant i2 # pconstant i1
False

As far as I can tell, it works when the upper bound for both are closed, but not when one is open. We should have the $[120, 129) \subseteq [120, 129]$, but we don't.

peter-mlabs commented 1 month ago

Note that this is particularly an issue because of this.

Also, we should probably indicate that "gotcha" in the Interval module and haddock comments.

L-as commented 1 month ago

Following that comment, if it isn't supported in Plutus, why support it in Plutarch at all?

peter-mlabs commented 1 month ago

@L-as Its support in plutus-ledger-api, so I think it does make sense for compatibility reasons.

But I still think that we should have a separate library that actually does what PLA "means" and not what it "does"

L-as commented 1 month ago

plutus-ledger-api

Fair reason, but arguably even then you should never use it. You could mark it as deprecated but still fix it.