Skip to content

Commit

Permalink
Merge PR coq#19949: EqDec instance for option
Browse files Browse the repository at this point in the history
Reviewed-by: andres-erbsen
Ack-by: SkySkimmer
Ack-by: ppedrot
Co-authored-by: andres-erbsen <[email protected]>
  • Loading branch information
coqbot-app[bot] and andres-erbsen authored Dec 27, 2024
2 parents 78b2bf4 + d68e31c commit 03dd829
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/changelog/11-standard-library/19949-option-eqdec.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- **Added:** :g:`EqDec` instance for :g:`option`
(`#19949 <https://github.com/coq/coq/pull/19949>`_,
by Daniil Iaitskov).
6 changes: 6 additions & 0 deletions stdlib/test-suite/success/EquivDec.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
From Stdlib Require Import EquivDec.

Example test_None_eqb_None: None ==b None = true. Proof. reflexivity. Qed.
Example test_None_eqb_Some: None ==b Some true = false. Proof. reflexivity. Qed.
Example test_Some_eqb_Some: Some 1 ==b Some 1 = true. Proof. reflexivity. Qed.
Example test_Some_neqb_Some: Some 0 ==b Some 1 = false. Proof. reflexivity. Qed.
19 changes: 19 additions & 0 deletions stdlib/theories/Classes/EquivDec.v
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,22 @@ Program Instance list_eqdec `(eqa : EqDec A eq) : EqDec (list A) eq :=

Solve Obligations with unfold equiv, complement in * ;
program_simpl ; intuition (discriminate || eauto).

#[export]
Program Instance option_eqdec `(eqa : EqDec A eq) : EqDec (option A) eq :=
{ equiv_dec (x y : option A) :=
match x, y with
| None, None => in_left
| Some s, Some s' =>
if s == s' then in_left else in_right
| _, _ => in_right
end
}.

Next Obligation.
match goal with y : option _ |- _ => destruct y end ;
unfold not in *; eauto.
Defined.

Solve Obligations with unfold equiv, complement in * ;
program_simpl; intuition (discriminate || eauto).

0 comments on commit 03dd829

Please sign in to comment.