Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dependent type 在Idris中如何证明一个类型的布尔不等式及其自身是不存在的?_Dependent Type_Idris - Fatal编程技术网

Dependent type 在Idris中如何证明一个类型的布尔不等式及其自身是不存在的?

Dependent type 在Idris中如何证明一个类型的布尔不等式及其自身是不存在的?,dependent-type,idris,Dependent Type,Idris,我想知道如何证明(所以(不是(y==y))是无人居住的一个例子,我不知道该怎么做。它在Idris中是可证明的,还是由于y可能会出现奇怪的Eq实现而不可证明?Shersh是正确的:你不能。(==)的实现不能保证是自反的,因此它可能不是真的 您可以限制y的类型,以便证明(==)的特定实现的属性,但我怀疑您希望使用decEq和(=)而不是so和(==)。很容易显示Not(y=y)无人居住。该Eq接口不需要实现来遵循正常的平等法则。但是,我们可以定义一个扩展的LawfulEq接口,它可以: %defau

我想知道如何证明
(所以(不是(y==y))
无人居住的一个例子,我不知道该怎么做。它在Idris中是可证明的,还是由于y可能会出现奇怪的
Eq
实现而不可证明?

Shersh是正确的:你不能。
(==)
的实现不能保证是自反的,因此它可能不是真的


您可以限制
y
的类型,以便证明
(==)
的特定实现的属性,但我怀疑您希望使用
decEq
(=)
而不是
so
(==)
。很容易显示
Not(y=y)
无人居住。

Eq
接口不需要实现来遵循正常的平等法则。但是,我们可以定义一个扩展的
LawfulEq
接口,它可以:

%default total

is_reflexive : (t -> t -> Bool) -> Type
is_reflexive {t} rel = (x : t) -> rel x x = True

is_symmetric : (t -> t -> Bool) -> Type
is_symmetric {t} rel = (x : t) -> (y : t) -> rel x y = rel y x

is_transitive : (t -> t -> Bool) -> Type
is_transitive {t} rel = (x : t) -> (y : t) -> (z : t) -> rel x y = True -> rel x z = rel y z

interface Eq t => LawfulEq t where
  eq_is_reflexive : is_reflexive {t} (==)
  eq_is_symmetric : is_symmetric {t} (==)
  eq_is_transitive : is_transitive {t} (==)
问题中要求的结果可用于类型
Bool

so_false_is_void : So False -> Void
so_false_is_void Oh impossible

so_not_y_eq_y_is_void : (y : Bool) -> So (not (y == y)) -> Void
so_not_y_eq_y_is_void False = so_false_is_void
so_not_y_eq_y_is_void True = so_false_is_void
对于以下
wird
类型,可以证明结果不正确:

data Weird = W

Eq Weird where
  W == W = False

weird_so_not_y_eq_y : (y : Weird) -> So (not (y == y))
weird_so_not_y_eq_y W = Oh
Weird(=)
可以显示为非自反,因此不可能实现
LawfulEq-Weird

weird_eq_not_reflexive : is_reflexive {t=Weird} (==) -> Void
weird_eq_not_reflexive is_reflexive_eq = 
  let w_eq_w_is_true = is_reflexive_eq W in
    trueNotFalse $ trans (sym w_eq_w_is_true) (the (W == W = False) Refl)
可能相关:我会说你不能证明这些事情。至少在一般情况下是这样的,因为您现在不需要为每种类型实现
(==)