feat(library/init/core): eagerly expanding Decidable.toBool seems to be a bad idea

After we erase types and proofs, `Decidable.toBool` can be replaced with
the identity function since `Decidable A` and `Bool` have the same
runtime representation. By eagerly expanding `toBool`, we introduce
unnecessary `cases` expressions.
This commit is contained in:
Leonardo de Moura 2019-03-25 15:24:51 -07:00
parent 5679a17603
commit 7db4f60e50
2 changed files with 5 additions and 1 deletions

View file

@ -846,7 +846,7 @@ Exists.rec h₂ h₁
/- Decidable -/
@[macroInline] def Decidable.toBool (p : Prop) [h : Decidable p] : Bool :=
@[inlineIfReduce, nospecialize] def Decidable.toBool (p : Prop) [h : Decidable p] : Bool :=
Decidable.casesOn h (λ h₁, false) (λ h₂, true)
instance beqOfEq {α : Type u} [DecidableEq α] : HasBeq α :=

View file

@ -342,6 +342,10 @@ class erase_irrelevant_fn {
return visit_quot_mk(args);
} else if (fn == get_quot_lift_name()) {
return visit_quot_lift(args);
} else if (fn == get_decidable_to_bool_name() && args.size() == 2) {
/* Decidable.toBool is the "identify" function since Decidable and Bool have
the same runtime representation. */
return args[1];
}
}
return visit_app_default(f, args);