命题不等于的等价物是什么?

What is the equivalent of propositional not equals?

我最近 and resolved the issue with a some applications of the rewrite tactic. I then decided to look back at one of my other questions 在代码审查中要求审查我对形式化希尔伯特(基于欧几里得)几何的尝试。

从第一个问题,我了解到命题相等和布尔相等和命题相等之间是有区别的。回顾我为希尔伯特平面写的一些公理,我广泛地使用了布尔相等性。虽然我不是 100% 确定,但根据我收到的答复,我怀疑我不想使用布尔相等。

例如,采用这个公理:

  -- There exists 3 non-colinear points.
  three_non_colinear_pts : (a : point ** b : point ** c : point ** 
                           (colinear a b c = False, 
                           (a /= b) = True, 
                           (b /= c) = True, 
                           (a /= c) = True))

我尝试重写它以不涉及 = True:

  -- There exists 3 non-colinear points.
  three_non_colinear_pts : (a : point ** b : point ** c : point ** 
                           (colinear a b c = False, 
                           (a /= b), 
                           (b /= c), 
                           (a /= c)))

总而言之,我从 codereview 上的问题中提取了代码,删除了 == 并删除了 = True:

interface Plane line point where 
  -- Abstract notion for saying three points lie on the same line.
  colinear : point -> point -> point -> Bool
  coplanar : point -> point -> point -> Bool
  contains : line -> point -> Bool

  -- Intersection between two lines
  intersects_at : line -> line -> point -> Bool

  -- If two lines l and m contain a point a, they intersect at that point.
  intersection_criterion : (l : line) -> 
                           (m : line) ->
                           (a : point) ->
                           (contains l a = True) -> 
                           (contains m a = True) -> 
                           (intersects_at l m a = True)

  -- If l and m intersect at a point a, then they both contain a.
  intersection_result : (l : line) ->
                        (m : line) ->
                        (a : point) ->
                        (intersects_at l m a = True) ->
                        (contains l a = True, contains m a = True)

  -- For any two distinct points there is a line that contains them.
  line_contains_two_points : (a :point) -> 
                             (b : point) ->
                             (a /= b) ->
                             (l : line ** (contains l a = True, contains l b = True ))

  -- If two points are contained by l and m then l = m
  two_pts_define_line : (l : line) ->
                        (m : line) ->
                        (a : point) ->
                        (b : point) ->
                        (a /= b) ->
                        contains l a = True ->
                        contains l b = True ->
                        contains m a = True -> 
                        contains m b = True -> 
                        (l = m)

  same_line_same_pts : (l : line) ->
                       (m : line) ->
                       (a : point) ->
                       (b : point) ->
                       (l /= m) ->
                       contains l a = True ->
                       contains l b = True ->
                       contains m a = True ->
                       contains m b = True ->
                       (a = b)

  -- There exists 3 non-colinear points.
  three_non_colinear_pts : (a : point ** b : point ** c : point ** 
                           (colinear a b c = False, 
                           (a /= b), 
                           (b /= c), 
                           (a /= c)))

  -- Any line contains at least two points.
  contain_two_pts : (l : line) ->
                    (a : point ** b : point ** 
                    (contains l a = True, contains l b = True))

-- If two lines intersect at a point and they are not identical, that is the o-
-- nly point they intersect at.
intersect_at_most_one_point : Plane line point =>
  (l : line) -> (m : line) -> (a : point) -> (b : point) ->
  (l /= m) ->
  (intersects_at l m a = True) ->
  (intersects_at l m b = True) ->
  (a = b)

intersect_at_most_one_point l m a b l_not_m int_at_a int_at_b =
  same_line_same_pts
  l
  m
  a
  b
  l_not_m
  (fst (intersection_result l m a int_at_a))
  (fst (intersection_result l m b int_at_b))
  (snd (intersection_result l m a int_at_a))
  (snd (intersection_result l m b int_at_b))

这给出了错误:

  |
1 | interface Plane line point where
  |           ~~~~~~~~~~~~~~~~
When checking type of Main.line_contains_two_points:
Type mismatch between
        Bool (Type of _ /= _)
and
        Type (Expected type)

/home/dair/scratch/hilbert.idr:68:29:
   |
68 | intersect_at_most_one_point : Plane line point =>
   |                             ^
When checking type of Main.intersect_at_most_one_point:
No such variable Plane

所以,/= 似乎只适用于布尔值。我一直找不到 "propositional" /= 像:

data (/=) : a -> b -> Type where

命题不等于存在吗?还是我想从布尔值变为命题相等是错误的?

与布尔值 a /= b 等价的命题是 a = b -> VoidVoid 是没有构造函数的类型。因此,每当您有 contra : Void 时,就会出现问题。所以a = b -> Void就是理解为:如果你有一个a = b,就有矛盾了。通常写成Not (a = b),也就是shorthand (Not a = a -> Void).

你改成命题相等是对的。您甚至可以将 contains : line -> point -> Bool 等布尔属性更改为 Contains : line -> point -> Type。随后 contains l p = TrueContains l p,以及 contains l p = FalseNot (Contains l p)

这是 boolean blindness 的情况,即 prf : contains l p = True,我们唯一知道的是 contains l pTrue(编译器需要采取查看 contains 来猜测为什么是 True)。另一方面,使用 prf : Contains l p 你有一个构造证明 prf 为什么 命题 Contains l p 成立。