给定一个自定义类型来表示从类型 b 到 a 的嵌入:
inductive Embedding (b a:Sort u) : Sort u
| Embed : forall (j:b -> a), (forall (x y:b), j x = j y -> x = y) -> Embedding
我正在尝试定义一个restrict
给定关系的函数,r:a -> a -> Prop
并且嵌入e:Embedding b a
返回一个关系b
def restrict {a b:Sort u} (r:a -> a -> Prop) (e:Embedding b a) (x y: b) : Prop :=
begin
destruct e, -- error
end
我无法解构我的嵌入以访问底层注入。
destruct tactic failed, recursor 'Embedding.cases_on' can only eliminate into Prop
在 Coq 中做同样的事情效果很好:
(* There is an injection j:b -> a, i.e. b is a subset of a *)
Inductive Embedding (b a:Type) : Type :=
| Embed : forall (j:b -> a), (forall (x y:b), j x = j y -> x = y) -> Embedding b a
.
Arguments Embed {b} {a}.
(* Restricting relation r on a to subset b *)
Definition restrict (a b:Type) (r:a -> a -> Prop) (e:Embedding b a) (x y:b)
: Prop :=
match e with
| Embed j _ => r (j x) (j y)
end.
Arguments restrict {a} {b}.
如果有人能提出一些解决这个问题的建议,我将不胜感激。Prop
我熟悉 Coq 的限制,即当目标为 Sort Set
or时无法解构 sort 的术语Type i
,因此可以理解 Lean 中的类似限制,但这似乎是这里的问题。我试图做Embedding
一个归纳谓词(所以返回Prop
而不是Sort u
),但这并没有解决错误。
我热衷于将我的 Coq 开发转化为学习精益的一种方式,因此我很乐意打破这个障碍 :)