Why does Coq use unnamed parameters in Inductive Types of Propositions?

浪子不回头ぞ 提交于 2019-12-11 21:52:21

问题


I was looking at IndProp and I saw:

Fail Inductive wrong_ev (n : nat) : Prop :=
| wrong_ev_0 : wrong_ev 0
| wrong_ev_SS : ∀ n, wrong_ev n → wrong_ev (S (S n)).
(* ===> Error: A parameter of an inductive type n is not
        allowed to be used as a bound variable in the type
        of its constructor. *)

except that it seems to behave exactly as if it was taking an argument but it seems to throw an error. Why is this?

The text provides some explanation but I don't understand it:

what I don't understand specifically it. The part I don't understand is the part it says:

it is allowed to take different values in the types

why is it saying "in the types"? Types are NOT the input, values are. Why is it saying this? It seems extremely confusing. I know (extremely vaguely) that there is such a thing as "dependent types" but is that what it's referring too? Shouldn't it be arguments? Don't constructors take value or "stuff" and return an object of some type?

Why does it seem that the signature of the Inductive type (which really I just view it as a function that builds things are returns objects of some type) missing the arguments?


More context from text where explanation seems to appear:

This definition is different in one crucial respect from previous uses of Inductive: its result is not a Type, but rather a function from nat to Prop — that is, a property of numbers. Note that we've already seen other inductive definitions that result in functions, such as list, whose type is Type → Type. What is new here is that, because the nat argument of ev appears unnamed, to the right of the colon, it is allowed to take different values in the types of different constructors: 0 in the type of ev_0 and S (S n) in the type of ev_SS. In contrast, the definition of list names the X parameter globally, to the left of the colon, forcing the result of nil and cons to be the same (list X). Had we tried to bring nat to the left in defining ev, we would have seen an error ... We can think of the definition of ev as defining a Coq property ev : nat → Prop, together with primitive theorems ev_0 : ev 0 and ev_SS : ∀n, ev n → ev (S (S n)). Such "constructor theorems" have the same status as proven theorems.


回答1:


why is it saying "in the types"? Types are NOT the input, values are

You need to read the whole expression: "in the types of different constructors". And, indeed, the natural number is different in the return type of the two constructors:

  • It is 0 for ev_0
  • And it is S (S n) for ev_SS


来源:https://stackoverflow.com/questions/53807507/why-does-coq-use-unnamed-parameters-in-inductive-types-of-propositions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!