简体   繁体   English

为什么这不是agda中依赖函数类型的有效定义?

[英]Why is this not a valid definition of dependent function types in agda?

I was watching a lecture where the lecturer said that it was impossible, or at least very difficult to define Pi types in Agda. 我正在看一个演讲,讲师说这是不可能的,或者至少很难在Agda中定义Pi类型。 But I'm convinced there has to be a way. 但是我坚信必须有一种方法。 Given a type in a universe and a family from the type to the universe, any function from the type to some type in the family will be of the Pi type. 给定Universe中的类型和从该类型到Universe的族,则从该类型到族中某个类型的任何函数都将是Pi类型。 So I thought it would make sense to use a lambda: 所以我认为使用lambda会很有意义:

data Pi (A : Set) (B : A -> Set) : Set where
  \ (a : A) -> (b : B a) : Pi A B

When I try to load this it gives me a parse error. 当我尝试加载此文件时,它给了我一个解析错误。 I'm not sure why, perhaps it doesn't want \\ to be a type constructor, but it kind of makes sense to consider a lambda to be a type constructor of a function type. 我不确定为什么,也许不希望\\成为类型构造函数,但是将lambda视为函数类型的类型构造函数有点有意义。 Note that I am using the latex feature for Agda in Emacs but I don't think I can write latex in stack overflow. 请注意,我在Emacs中为Agda使用了乳胶功能,但是我不认为我可以在堆栈溢出中编写乳胶。 That being said, I tried replacing the lowercase lambda with an uppercase one to see if it wanted a unique type constructor, but to no avail. 话虽如此,我尝试用大写的lambda替换小写的lambda,以查看它是否需要唯一的类型构造函数,但无济于事。

You can use the uppercase lambda after fixing the typo in : Pi AB , that is 修正错字后,您可以使用大写lambda : Pi AB ,即

data Pi (A : Set) (B : A -> Set) : Set where
  Λ : ((a : A) -> B a) -> Pi A B

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM