:LiquidHaskell:没有,我有麻烦证明下列法律与LiquidHaskell德·摩根定律
这是被称为(之一)德·摩根定律,并简单地指出的or
否定荷兰国际集团的两个值必须与每个的否定相同。它已被证明很长一段时间,并且是LiquidHaskell's tutorial中的一个例子。我沿着教程以下,但未能得到下面的代码经过:
-- Test.hs
module Main where
main :: IO()
main = return()
(==>) :: Bool -> Bool -> Bool
False ==> False = True
False ==> True = True
True ==> True = True
True ==> False = False
(<=>) :: Bool -> Bool -> Bool
False <=> False = True
False <=> True = False
True <=> True = True
True <=> False = False
{[email protected] type TRUE = {v:Bool | Prop v} @-}
{[email protected] type FALSE = {v:Bool | not (Prop v)} @-}
{[email protected] deMorgan :: Bool -> Bool -> TRUE @-}
deMorgan :: Bool -> Bool -> Bool
deMorgan a b = not (a || b) <=> (not a && not b)
当运行liquid Test.hs
,我得到下面的输出:
LiquidHaskell Copyright 2009-15 Regents of the University of California. All Rights Reserved.
**** DONE: Parsed All Specifications ******************************************
**** DONE: Loaded Targets *****************************************************
**** DONE: Extracted Core using GHC *******************************************
Working 0% [.................................................................]
Done solving.
**** DONE: solve **************************************************************
**** DONE: annotate ***********************************************************
**** RESULT: UNSAFE ************************************************************
Test.hs:23:16-48: Error: Liquid Type Mismatch
23 | deMorgan a b = not (a || b) <=> (not a && not b)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Inferred type
VV : Bool
not a subtype of Required type
VV : {VV : Bool | Prop VV}
In Context
现在,我决不是一个LiquidHaskell专家,但我敢肯定,有些事情一定是错的。我说服自己,身份持有几年前,而是要确保我叫用所有可能的输入功能,并最终跑到
λ: :l Test.hs
λ: import Test.QuickCheck
λ: quickCheck deMorgan
>>> +++ OK, passed 100 tests.
所以我不似乎有在Haskell代码一个错字,错误必须存在于LiquidHaskell规范中。看来,LiquidHaskell不能推断导致Bool
严格TRUE
:
Inferred type
VV : Bool
not a subtype of Required type
VV : {VV : Bool | Prop VV}
什么是我的错吗?任何帮助表示赞赏!
PS:我使用z3
解算器,并运行GHC 7.10.3。 LiquidHaskell版本是2009-15
。
我想知道,也许这是一个更合适的液体哈斯克尔问题。 但是,这些可能是目前在stackoverflow上可用的最近的标签。 –
不幸的是,没有液体哈斯克尔标签,我需要更多的声望来创建一个。我希望那些传达这个想法。 –
dfeuer:感谢您的标签! –