我经常想尝试总结多维数据集的每个维度及其表示的内容,因此我将对此进行一下介绍。λ
但是首先,人们可能应该尝试解决各种问题。Coq互动定理证明者基于一种基础类型理论,有时也被称为具有宇宙的归纳结构的演算。您会注意到,这不仅仅是简单的“构造演算”,而且确实有很多东西,而不仅仅是CoC。特别是,我认为您对CoC固有的确切功能感到困惑。特别是,集合/属性区别和Universe不会出现在CoC中。
在这里,我不会对Pure Type系统进行完整的概述,但是重要的规则(对于像CoC这样的功能性PTS)如下:
Γ⊢A:sΓ,x:A⊢B:kΓ⊢Πx:A.B : k (s,k)∈R
其中是一组固定的元件小号的种类,以及一对(小号,ķ )是在一组固定的- [R对的小号,叫做规则。s,kS(s,k)RS
关键的见解是,仔细选择和[R做出什么样的产品类型差异巨大Π X :一。B实际上代表!SRΠx:A.B
特别地,在构造的演算中,排序集为
{ ∗ ,◻ },
通常称为Prop and Type(尽管由于我稍后将要讨论的原因,该术语对Coq用户有点混乱),以及一组规则:
R = { (* ,∗ ),(◻ ,◻ ),(◻ ,∗ ),(∗ ,◻ )}S
{∗,□}
R={(∗,∗),(□,□),(□,∗),(∗,□)}
因此,我们有4条规则,分别对应4个不同的目的:
:功能类型(∗,∗)
(□,□)
(□,∗)
(∗,□)
我将更详细地解释每一个。
A→BΠx:A.BxB
∗natboolx=yxy∗
listlist:∗→∗listnat,listbool∗→∗(□,□)
Πt:∗. t→t
λ(t:∗)(x:t).xΠt:∗._(□,∗)t→t(∗ ,∗ )
甲∧ 乙:= Π 吨:* 。(A → B → t )→ t
甲∨ 乙:= Π 吨:* 。(A → t )→ (B → t )→ t
⊥ := Π 吨:* 。Ť
⊤ := Π 吨:* 。t → t
∃x:A. P(x):=Πt:∗. (Πy:A. P(y)→t)→t
(∗,□)
∗∗) has some restrictions: no large eliminations, and datatypes should live in Set or Type, which don't have the analogue of the (□,∗) rule. Prop without large eliminations is consistent with the law of excluded middle.
Useful to note: in the presence of (□,□), you can even write things like:
Πc:∗→∗. c nat→c nat
if you like, which is useful for, say, writing generic code over a monad, as often happens in Haskell.
Dependent types: This is how you get the propositions-as-types paradigm to work. Indeed, you want to have a type that represents all possible proofs of, say 0=1. To make sense of this, you want equality to be of type
= : nat→nat→∗
or you might want to be polymorphic
= : Πt:∗. t→t→∗
In any case, you can't write
nat→nat→∗ without the rule
(∗,□).
Ok, but what about universes? It turns out that in the CoC, you can't actually write things like □→□, because there are no types to give □ and a fortiori no rules involving those types. A pretty natural thing to do is to index □ by a natural number, getting □i for i=1,2,3,… and having □i:□i+1.
What rules do we want for this? One natural rule is (□i,□i), but that rule isn't very useful in the absence of the subsumption rule
Γ⊢A:□iΓ⊢A:□j i≤j
With these extra sorts and rules, you get something that is not a PTS, but something close. This is (almost) the Extended Calculus of Constructions, which is closer to the basis of Coq. The big missing piece here is the inductive types, which I won't discuss here.
Edit: There's a rather nice reference that describes various features of programing languages in the framework of PTSes, by describing a PTS which is a good candidate for an intermediate representation of a functional programing language:
Henk: A Typed Intermediate Language, S. P. Jones & E. Meijer.
soft-question
。我在这里没有看到实际的技术问题。也许您可以更具体地询问您的要求?