无法定义欧几里德的子集 space

Trouble defining a subset of Euclidean space

我正在使用 Lean 来尝试形式化欧几里德 space (R^n) 子集的概念。

我尝试了以下方法:

import analysis.real

def repeated_prod : ℕ → Type → Type
| 0 s := empty
| 1 s := s
| (n + 1) s := prod s (repeated_prod n s)

structure euclidean_space (n : ℕ) : Type :=
(space : set (repeated_prod n ℝ))

def euclidean_subset (M : Type) := ∃ n : ℕ, (set M) ⊆ (euclidean_space.mk n).space

尝试输入英文:

  1. 实数 (R) 在 mathlib 的分析分量中定义。
  2. 我们需要将其推广到 k 维,因此我们需要 R 与自身的笛卡尔积任意次数。
  3. repeated_prod 允许采用任意类型并多次应用笛卡尔积。
  4. euclidean_space 是对 R.
  5. 情况的特化
  6. 我们说它是 euclidean_subset 如果有一些欧几里德 space (注意:我试图避免提及维度所以它是 一些 R^n.) 集合 (M) 是其子集.

然而,这给出了错误:

euclidean.lean:11:52: error: failed to synthesize type class instance for
M : Type,
n : ℕ
⊢ has_subset Type
euclidean.lean:11:74: error: maximum class-instance resolution depth has been reached (the limit can be increased by setting option 'class.instance_max_depth') (the class-instance resolution trace can be visualized by setting option 'trace.class_instances')

虽然我确实不知道trace.class_instances的默认值是多少,但我把它设置为10000,时间有点长,还是报同样的错误信息,导致对我来说,那里的错误信息具有误导性。似乎无法找到很多关于这种语言的信息,包括我收到的错误消息,我们将不胜感激解决此错误的任何帮助。

您有两个编译错误,尽管其中一个不可见。首先,您不能按照您尝试的方式使用 mk 制作欧几里德 space。我建议暂时从结构更改为 def,因为您的结构只有一个字段:

def euclidean_space (n : ℕ) : Type := set (repeated_prod n ℝ)

那么维度 n 的欧几里德 space 就是 euclidean_space n.

其次,类型与集合不同,这就是精益无法为 has_subset Type 找到实例的原因。在构造微积分中,精益所基于的类型理论,类型不能 真正地 是面向对象编程意义上的其他类型的子类型 - 尽管您可以使用 "subtype types" and/or 强制模拟这个。所以这就是我改变你的代码要做的 - 而不是 euclidean_subset 谓词试图检查某物是否是一个子集,而是检查它是否是 euclidean space n 的子类型类型 euclidean space n =17=]:

def euclidean_subset (M : Type) := ∃ (n : ℕ) (P : euclidean_space n → Prop), M = subtype P