-
Notifications
You must be signed in to change notification settings - Fork 345
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
Make Decidable
a subtype of Bool
#2038
base: master
Are you sure you want to change the base?
Conversation
-/ | ||
return false | ||
/- | ||
TODO: remove this hack after we refactor `Decidable` as suggested by Gabriel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this TODO can now be removed, right? Or is the return false
still a hack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, the return false
here is about instances that have more than one exit point, i.e., if c then { a := 42 } else { a := 1 }
. We still allow that and I didn't remove class inductive
either.
This PR is blocked by what I can only assume to be a miscompilation. Running stage1 immediately segfaults in the Diffing the IR code is hard because we generate lots of |
Regarding the explosion of join points (which perhaps is triggering the bug), I think the old compiler is very reliant on @[macro_inline] def dite {α : Sort u} (c : Prop) [h : Decidable c] (t : c → α) (e : Not c → α) : α :=
h.decide.casesOn
(fun h => e (nomatch h.2 ·))
(fun h => t (h.1 (.refl _)))
h.decide_iff
@[macro_inline] def ite {α : Sort u} (c : Prop) [Decidable c] (t e : α) : α :=
dite c (fun _ => t) (fun _ => e) doesn't really help because the overapplication of |
Without this change, we would not inline anything inside let x_42 := casesOn x_3 fun .. => ... here ...
Rebasing onto #2060 seemed to fix the compilation errors. !bench |
!bench |
Here are the benchmark results for commit 6cdf707. Benchmark Metric Change
===================================================
- binarytrees task-clock 3.9% (10.5 σ)
- stdlib instructions 2.1% (1236.2 σ)
- stdlib maxrss 1.4% (140.2 σ)
- stdlib task-clock 1.5% (19.4 σ)
- stdlib wall-clock 1.3% (67.3 σ)
- stdlib size bytes .olean 2.2%
- workspaceSymbols maxrss 1.4% (15.2 σ)
+ workspaceSymbols task-clock -4.0% (-20.8 σ)
+ workspaceSymbols wall-clock -4.0% (-20.8 σ) |
Just a ping in eager anticipation of progress on this PR! |
Something that might be a less invasive change is this:
In my limited testing, you don't need to touch pre-existing match patterns, which would be great if that meant downstream projects don't need to be updated. However, this does need a modification to |
@kmill I tried your definition on current version of Lean4, then @[macro_inline] def dite {α : Sort u} (c : Prop) [h : Decidable c] (t : c → α) (e : Not c → α) : α :=
match h with
| .isTrue h => t h
| .isFalse h => e h says "'unreachable' code was reached". UPD: I see that the assertion in |
This resolves the diamond between
Decidable
andBEq
, which is starting to cause lots of headaches in mathlib.