Incomplete requirements for nested inductive types

未关闭
#409 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞

调研方向

从 issue 中链接的 Nested Inductive Types 部分开始,并结合提供的示例检查现有的需求列表。查看 lean4#6371 以了解关于参数位置的附加限制。当文档涵盖缺失的两个限制和更广泛的严格正性条件,并在可能的情况下明确说明确切的接受标准时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

The section on Nested Inductive Types, and in particular, the list of requirements nested recursive occurrences must satisfy, is incomplete.

Nested recursive occurrences must satisfy the following requirements:

  • They must be nested directly under an inductive type's type constructor. Terms that reduce to such nested occurrences are not accepted.
  • Local variables such as the constructor's parameters may not occur in the arguments to the nested occurrence.
  • The nested occurrences must occur strictly positively.

In what way is the content incorrect?

The list of requirements misses on two known requirements that must be satisfied in order for a nested inductive type to be correctly translated.

  • A nested occurrence may not be used inside the rest of the constructor in a way that would have it rely explicitly on the type it's nested in, as that could lead to the construction of an inductive-recursive type. e.g
def Option.IsNone : Option α → Type := Option.rec Unit (fun _ => Empty)
inductive Foo where
  | foo : (l : Option Foo) → l.IsNone → Foo

Would need to be translated as the following inductive-recursive type to be well-formed:

mutual
  inductive Foo where
    | foo : OptionFoo → Foo
  inductive OptionFoo where
    | none
    | some : Foo → Option Foo
  def OptionFoo.IsNone : OptionFoo → Type
    | none => Unit
    | some _ => Empty
end

Instead, lean tries the naive mutual translation, and errors out when checking the translated constructors.

  • A nested recursive occurrence may not appear in a parameter position that an index of the inductive type it's nested in may depend on. This one is further documented at lean4#6371, and also fails during translation instead of giving a good early error.

Furthermore, it should probably be noted that, in order for the translation to give rise to a strictly positive type, it is not only necessary that the nested recursive occurrence appear strictly positively inside another inductive type's type constructor (as pointed out in the list of requirements), but also that the type constructors the nested occurrences appear in appear themselves in a strictly positive manner. e.g in the following code, the recursive occurrence Foo appears strictly positively in Option Foo, but Option Foo itself does not appear strictly positively in the constructor, and is thus not accepted.

inductive Foo where
  | foo : (Option Foo → Nat) → Foo

Lastly, this is more of a suggestion, but Lean, might benefit from making explicit the exact positivity criteria(s) the system allows for, similarly to Rocq's presentation on the matter.

主要语言
Lean
星标
147
派生
72
平均合并
1 天 17 小时
30 天内合并 PR
23

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

leanprover/reference-manual 的其他 Issue

查看 leanprover/reference-manual 的全部 Issue

相似的 Issue

更多 Compilers Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。