Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anonymous ctor notation fails on constructors of type families with explicit params #6555

Open
3 tasks done
cppio opened this issue Jan 6, 2025 · 3 comments
Open
3 tasks done
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@cppio
Copy link
Contributor

cppio commented Jan 6, 2025

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The anonymous constructor notation ⟨...⟩ fails to pass parameters to the constructor when the constructor requires that parameters be passed explicitly.

Steps to Reproduce

inductive Pointed : TypeType
  | mk α : α → Pointed α

example : Pointed Bool := ⟨false⟩
example : Pointed (String × Nat) := ⟨"", 0

Expected behavior: The code should succeed with no errors, as it does when α is an implicit parameter to mk.

Actual behavior: The code results in the following errors:

application type mismatch
  Pointed.mk false
argument
  false
has type
  Bool : Type
but is expected to have type
  Type : Type 1

invalid constructor ⟨...⟩, expected type must be an inductive type 
  Type

Versions

Lean 4.16.0-nightly-2025-01-06
Appears in Lean 4.0.0-m5, though I did not check before this.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@cppio cppio added the bug Something isn't working label Jan 6, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 6, 2025

With the explicit parameter I'd have expected

example : Pointed Bool := ⟨Bool, false⟩

to work, but that doesn't work.

NB: your example works with

inductive Pointed : Type → Type
  | mk {α} : α → Pointed α

Is that a suitable workaround for you?

@cppio
Copy link
Contributor Author

cppio commented Jan 6, 2025

The current implementation and error messages mention explicit fields rather than parameters, but it would be fine either way. I would expect one of ⟨⟩ and ⟨_⟩ to work in place of rfl.

@nomeata
Copy link
Collaborator

nomeata commented Jan 6, 2025

Is it maybe the case that the implementation assumes a structure, as in

structure Pointed (α : Type) : Type where
 val : α

/-- info: Pointed.mk {α : Type} (val : α) : Pointed α -/
#guard_msgs in
#check Pointed.mk

example : Pointed Bool := ⟨false⟩
example : Pointed (String × Nat) := ⟨"", 0⟩

and the fact that it even supports non-structures is the oversight here?

Ah, but https://lean-lang.org/doc/reference/latest/The-Type-System/Inductive-Types/#anonymous-constructor-syntax is pretty explicit that this feature should work for inductive as well.

If we take the reference manual at the source of truth, then I’d say that

example : Pointed Bool := ⟨Bool, false⟩

should work.

@Kha Kha changed the title anonymous ctor notation fails on constructors with explicit params anonymous ctor notation fails on constructors of type families with explicit params Jan 10, 2025
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low We are not planning to work on this issue
Projects
None yet
Development

No branches or pull requests

3 participants