Zulip Chat Archive

Stream: general

Topic: Invalid occurrence of datatype being declared


nrs (Oct 14 2024 at 15:35):

structure Signature where
  symbols : Type
  arity : symbols -> Nat

inductive Vect (α : Type u) : Nat  Type u where
   | nil : Vect α 0
   | cons : α  Vect α n  Vect α (n + 1)

def semF (σ : Signature) (α : Type) : Type := Sigma (fun x => Vect α (σ.arity x))

inductive μ : (σ : Signature) -> Type _
| mk : semF σ (μ σ) -> μ σ

how come the above produces (kernel) arg #2 of 'μ.mk' contains a non valid occurrence of the datatypes being declared?

nrs (Oct 14 2024 at 15:35):

It works if we use unsafe inductive μ (σ : Signature)

nrs (Oct 14 2024 at 15:39):

I've also tried replacing occurrence of Type in semF by Type _

Mario Carneiro (Oct 14 2024 at 15:41):

because nested inductive types only work through other inductives

nrs (Oct 14 2024 at 15:42):

Mario Carneiro said:

because nested inductive types only work through other inductives

i.e. semF should be inductive for this to work?

Mario Carneiro (Oct 14 2024 at 15:43):

If you inline the definition of semF it appears to work

nrs (Oct 14 2024 at 15:45):

Mario Carneiro said:

If you inline the definition of semF it appears to work

ah thank you very much! I'm adding that to my heuristics. First: check whether you need to change parameters ordering. Second, check whether universe level is right. Now adding third: try inlining.

nrs (Oct 14 2024 at 15:46):

in this case this happened because semF was not inductive right?

Mario Carneiro (Oct 14 2024 at 15:52):

yes

nrs (Oct 14 2024 at 15:52):

noted, tyvm for help!!

Mario Carneiro (Oct 14 2024 at 15:53):

specifically, try inlining any functions which use the type being defined, here μ σ


Last updated: May 02 2025 at 03:31 UTC