Skip to content

Logic / and mod don´t match Haskell's div and mod. #2547

Open
@ninioArtillero

Description

@ninioArtillero

Logic / and mod (from liquid-fixpoint) don´t match Haskell's div and mod behavior, as they should given that the former is used to define the latter in src/GHC/Real_LHAssumptions.hs.

{-@
...

define div x y        = (x / y)
define mod x y        = (x mod y)

...
@-}

As a consequence, in the next example both functions fail verification but should not:

{-@exampleHaskellDiv :: {x:Int | x = 2} @-}
exampleHaskellDiv :: Int
exampleHaskellDiv = div (-5) (-2)

{-@ exampleHaskellMod :: {x:Int | x = -1} @-}
exampleHaskellMod :: Int
exampleHaskellMod = mod (-5) (-2)

On the other hand, this is ok:

{-@ exampleLogicDiv :: { 3 = (-5) / (-2)} @-}
exampleLogicDiv :: ()
exampleLogicDiv = ()

{-@ exampleLogicMod :: { 1 = (-5) mod (-2)} @-}
exampleLogicMod :: ()
exampleLogicMod = ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions