You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR changes the definition of `Decidable p` to a structure
containing a `Bool` and a proof of either `p` or `¬p`.
This is basically the approach proposed by @kmill in leanprover#2038.
Due to bugs in the old compiler, this was previously not possible;
however, now that the new compiler is enabled, this works perfectly
fine.
Using `Bool` in the definition of `Decidable` has several advantages, in
particular
- There are many more definitional equalities, e.g.
```lean
variable (a b : Bool)
#check (rfl : decide (a = true) = a)
#check (rfl : decide (a = false) = !a)
#check (rfl : decide (a = true ∧ b = true) = a && b)
#check (rfl : decide (a = true ∨ b = true) = a || b)
#check (rfl : decide (¬a) = !a)
#check (rfl : decide (a = true ↔ b = true) = (a == b))
```
- The `decide` tactic no longer needs to carry proofs with it, improving
performance for well-written `Decidable` instances.
- `LawfulBEq` and `DecidableEq` are now compatible: When using the
`DecidableEq` instance provided by `LawfulBEq`, `decide (a = b)` is
definitionally equivalent to `a == b`.
- `Decidable` no longer needs special casing in the compiler.
In order to take full advantage from these changes, it is recommended to
use the `decidable_of_bool` and `decidable_of_iff` functions to
construct `Decidable` instances.
This is a breaking change, but in part due to `Decidable.isTrue` and
`Decidable.isFalse` remaining as `match_pattern`s, surprisingly few
(meta-)programs break.
---------
Co-authored-by: Julia Markus Himmel <2065352+TwoFX@users.noreply.github.com>
0 commit comments