Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] how many type indexes for a particular type?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] how many type indexes for a particular type?


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] how many type indexes for a particular type?
  • Date: Wed, 20 Jul 2016 17:04:28 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f174.google.com
  • Ironport-phdr: 9a23:1eWWxB9IqqO7cP9uRHKM819IXTAuvvDOBiVQ1KB90O8cTK2v8tzYMVDF4r011RmSDN2dtqkP0reM+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2WVTerzWI4CIIHV2nbEwud7yzR9WZ1pntn8mJuLTrKz1SgzS8Zb4gZD6Xli728vcsvI15N6wqwQHIqHYbM85fxGdvOE7B102kvpT4r9Zf9HFbvOtk/MpdW437eb45RPpWFmcIKWcwse/ssxDfTQKJrl8RU3sblAYAVwrC6hD5U5P8vwP1s+N83G+ROsigHuN8Yiir86o+EEygsywALTNsqGw=



On 07/20/2016 04:45 PM, Jonathan Leivent wrote:


On 07/20/2016 04:37 PM, Jason Gross wrote:
Here is a way to distinguish based on the results of typechecking:
Inductive eq : forall {A}, A -> A -> Prop := eq_refl A x : @eq A x x.
Inductive eq' {A} (x : A) : A -> Prop := eq_refl' : @eq' A x x.
Check fun A x y (p : @eq A x y) => match p in (@eq A' x' y') with _ => I
end.
Fail Check fun A x y (p : @eq' A x y) => match p in (@eq' A' x' y') with _
=> I end. (* Error: The parameters do not bind in patterns; they must be
replaced by '_'. *)

I wish you luck in making this work in general; it seems that the [in]
clause does special name-resolution and ignores ltac-variables.

Here's another way that may prove more fruitful:

Goal forall A x y, @eq A x y -> True.
intros ??? p.
case p. (* forall A0 : Type, A0 -> True *)
Abort.
Goal forall A x y, @eq' A x y -> True.
intros ??? p.
case p. (* True *)
Abort.

Using case this way looks promising. So, the number of intros will be the number of non-index parameter.
I'll try making a tactic that uses that...

On second thought - that doesn't work. We're confusing ctor fields with indexes. Of course case will produce intros for the fields.

-- Jonathan


Thanks!

-- Jonathan


On Wed, Jul 20, 2016 at 1:25 PM Jonathan Leivent
<jonikelee AT gmail.com>
wrote:

Is there any way accessible via Ltac that one can get the count of the
number of indexes for a particular inductive type? Not the total number
of parameters - just the indexes.

Examining the inductive type doesn't tell you which of that type's args
are indexes or just parameters.

Examining the constructors usually helps some, because the point where
the args of the constructors differ from each other or the args of the
type indicates that there are no more non-indexes after that point.
But, there may be indexes that don't vary. Hence, in:

Inductive Foo : nat -> Set := foo(n : nat) : Foo n.

Inductive Bar(n : nat) : Set := bar.

Foo and Bar have the same type nat -> Set, and their constructors foo
and bar have similar type structure as well (modulo Foo/Bar). Yet, Foo
has a type index while Bar doesn't.

-- Jonathan








Archive powered by MHonArc 2.6.18.

Top of Page