不能使类型类在精益中工作

时间:2016-06-18 13:51:44

标签: formal-methods lean

我无法理解如何通过精益触发类型类的使用。这是一个小例子的尝试:

section the_section
structure toto [class] (A : Type) := (rel : A → A → Prop) (Hall : ∀ a, rel a a)

definition P A := exists (a : A), forall x, x = a
parameter A : Type
variable HA : P A

lemma T [instance] {B : Type} [HPB : P B] : toto B := toto.mk (λ x y, x = y) (λ x, rfl)

include HA
example : toto A := _
-- this gives the error: don't know how to infer placeholder toto A

end the_section

关键是我希望Lean看到它可以使用HA从引理T中推导出来。我缺少什么?

1 个答案:

答案 0 :(得分:1)

再次,我不得不发布问题以找到答案。希望这有助于其他人。

P需要是一个类,所以我们实际上需要改变

definition P A := exists (a : A), forall x, x = a

definition P [class] A := exists (a : A), forall x, x = a