leanprover / leanprover/lean4

default value of structure which is not produced by a tactic

Open
#4,736 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Description

constructor of structure does not accept defalut value of field whose type is not Prop.

structure NonEmptyString where
  value : String
  another_value : Int := 0
  ev : value.length > 0 := by decide
deriving Repr

-- works
def eg : NonEmptyString := { value := "hello" }

-- does not work
def eg' : NonEmptyString := NonEmptyString.mk "hello"

-- default value of `another_value` is missing
/-
NonEmptyString.mk (value : String) (another_value : Int) (ev : value.length > 0 := by decide) : NonEmptyString
-/
#check NonEmptyString.mk
Steps to Reproduce

Expected behavior: accept defalut value for all types

Actual behavior: accept only Prop-value

Versions

nightly

Additional Information

reported on Zulip: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/default.20value.20of.20structure.20fields

Impact

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the NonEmptyString example and inspect how structure constructors handle default-valued fields. Confirm the fix by checking that NonEmptyString.mk "hello" accepts the non-Prop default and that the existing Prop default still works.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.