我怎样才能在 Idris 中创建不同的变量?

How can I go about creating distinct variables in Idris?

我正在尝试在 Idris 中重建希尔伯特几何的公理。我想出了以下代码来表示他的公理:

interface (Eq point) => Plane line point where
  colinear : point -> point -> point -> Bool
  contains : line -> point -> point -> Bool
  axiom1a : (a,b : point) -> (a /= b) = True -> (l : line ** (contains l a b = True))
  axiom1b : contains l a b = True -> contains m a b = True -> l = m
  axiom2 : (a : point ** (colinear a b c = False) && (a /= b) = True && (b /= c) = True && (a /= c) = True)
  axiom3 : (l : line) -> (a ** (contains l a b = True))

axiom2 应该读作 "There exists 3 distinct non-colinear points." 我收到以下错误:

When checking type of Main.axiom2:
When checking argument P to type constructor Builtins.DPair:
        Type mismatch between
                Bool (Type of _ && _)
        and
                Type (Expected type)

如果我删除 && (a /= b) = True && (b /= c) = True && (a /= c) = True 代码会运行,但公理中 "distinct" 的限定条件将丢失。任何帮助将不胜感激。

colinear a b c = FalseType,不是 Bool。同样适用于 (a /= b) = True(b /= c) = True(a /= c) = True.

您必须使用 "type-level &&",即元组,而不是使用 &&

axiom2 : (a : point ** (colinear a b c = False, (a /= b) = True, (b /= c) = True, (a /= c) = True))

然而,这将显示为 "There exists a point a that is not colinear with any two other distinct points",但情况并非总是如此。你可以这样写:

axiom2 : (a : point ** (b : point ** (c : point ** (colinear a b c = False, (a /= b) = True, (b /= c) = True, (a /= c) = True))))

那就是 "There exist three distinct points that are not colinear"。我不确定是否可以让它看起来更好看,比如 (a, b, c : point ** ....