Zulip Chat Archive

Stream: lean4

Topic: kernel err: non valid occurrence of the datatypes being decl


Yuri (Jul 03 2024 at 23:18):

Consider:

inductive Sig where
  | sum (l r : Sig)
  | empty
  | var
  | prod (l r : Sig)
  | fix

def decode : Sig  (Type × Type  Type)
  | .sum l r  => fun (αβ : Type × Type) => Sum ((decode l) αβ) ((decode r) αβ)
  | .empty    => fun (_  : Type × Type) => Empty
  | .var      => fun (αβ : Type × Type) => αβ.1
  | .prod l r => fun (αβ : Type × Type) => Prod ((decode l) αβ) ((decode r) αβ)
  | .fix      => fun (αβ : Type × Type) => αβ.2

inductive Mu (S : Sig) (A : Type) where -- <== ERROR HERE
  | fold : decode S (A, Mu S A)  Mu S A

I get the following error:

(kernel) arg #3 of 'Mu.fold' contains a non valid occurrence of the datatypes being declared

What is the problem here?

Shreyas Srinivas (Jul 03 2024 at 23:51):

you have a negative occurrence of S in fold

Shreyas Srinivas (Jul 03 2024 at 23:52):

The error message could be better though if the issue was caught before sending the code to the kernel.


Last updated: May 02 2025 at 03:31 UTC