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

[RFC] Implement Boolean-to-Prop coercion using Bool.asProp #2043

Open
gebner opened this issue Jan 18, 2023 · 1 comment · May be fixed by #2060
Open

[RFC] Implement Boolean-to-Prop coercion using Bool.asProp #2043

gebner opened this issue Jan 18, 2023 · 1 comment · May be fixed by #2060
Labels
RFC Request for comments

Comments

@gebner
Copy link
Member

gebner commented Jan 18, 2023

A while ago, Sebastian suggested[1] that we should redefine the Boolean-to-Prop coercion using a dedicated function. This recently came up again[3] because we're porting material about List.filter, which is now defined on Booleans and thus exercises the coercion heavily.

def Bool.asProp (b : Bool) : Prop :=
  b = true

instance : Coe Bool Prop where
  coe := Bool.asProp

Pros:

  1. No accidental simplification of ¬ b = true to b = false (which requires duplication of simp lemmas).
  2. decide b = b is defeq (after Make Decidable a subtype of Bool #2038)
  3. Pretty-printing and norm_cast work out-of-the-box.

Cons:

  1. simp only [h] no longer works as well for a hypothesis h : b with b : Bool.

Original proposal: [1] https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/rfc.3A.20theorem.20names/near/240161960
Other threads:
[2] https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/BEq.20Subtype/near/296650727
[3] https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Prop.20-.3E.20Bool.20regression/near/321996465

@gebner gebner added RFC Request for comments dev meeting It will be discussed at the (next) dev meeting labels Jan 18, 2023
@gebner
Copy link
Member Author

gebner commented Jan 23, 2023

Additional proposal:

  • Make simp [h] add show b = true from h to the simp set if h : Bool.asProp b.

@Kha Kha added depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it and removed dev meeting It will be discussed at the (next) dev meeting labels Jan 23, 2023
@gebner gebner linked a pull request Jan 24, 2023 that will close this issue
@gebner gebner removed the depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it label Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants