From 512b3f99bc34b8bc17dd8612ab034b4b173ac0ca Mon Sep 17 00:00:00 2001 From: Robbert Krebbers <mail@robbertkrebbers.nl> Date: Fri, 11 Jan 2019 14:39:20 +0100 Subject: [PATCH] `tc_to_bool P` to turn a type class into a Boolean that represents if there is an instance. --- theories/base.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/theories/base.v b/theories/base.v index 3043b473..403948dd 100644 --- a/theories/base.v +++ b/theories/base.v @@ -145,6 +145,12 @@ Inductive TCDiag {A} (C : A → Prop) : A → A → Prop := Existing Class TCDiag. Existing Instance TCDiag_diag. +(** Given a proposition [P] that is a type class, [tc_to_bool P] will return +[true] iff there is an instance of [P]. It is often useful in Ltac programming, +where one can do [lazymatch tc_to_bool P with true => .. | false => .. end]. *) +Definition tc_to_bool (P : Prop) + {p : bool} `{TCIf P (TCEq p true) (TCEq p false)} : bool := p. + (** Throughout this development we use [stdpp_scope] for all general purpose notations that do not belong to a more specific scope. *) Delimit Scope stdpp_scope with stdpp. -- GitLab