From 5346dd7017e2f856fd05d759cb713ebc40d23628 Mon Sep 17 00:00:00 2001
From: Tej Chajed <tchajed@mit.edu>
Date: Fri, 1 May 2020 09:10:27 -0500
Subject: [PATCH] Add Countable instances for byte

---
 CHANGELOG.md       | 3 ++-
 theories/strings.v | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e873810..3b982a91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,8 @@ API-breaking change is listed.
   exported by the prelude. This is a breaking change if one only
   imports `list.v`, but not the prelude.
 - Rename `drop_insert` into `drop_insert_gt` and add `drop_insert_le`.
-- Added `Countable` instance for `Ascii.ascii`.
+- Added `Countable` instances for `Ascii.ascii` and `Byte.byte` from the Coq
+  standard library.
 - Make lemma `list_find_Some` more apply friendly.
 
 ## std++ 1.3 (released 2020-03-18)
diff --git a/theories/strings.v b/theories/strings.v
index a9f2bcc5..0f94448e 100644
--- a/theories/strings.v
+++ b/theories/strings.v
@@ -1,4 +1,5 @@
 From Coq Require Import Ascii.
+From Coq Require Import Init.Byte.
 From Coq Require Export String.
 From stdpp Require Export list.
 From stdpp Require Import countable.
@@ -18,6 +19,7 @@ Arguments String.append : simpl never.
 
 (** * Decision of equality *)
 Instance ascii_eq_dec : EqDecision ascii := ascii_dec.
+Instance byte_eq_dec : EqDecision byte := Byte.byte_eq_dec.
 Instance string_eq_dec : EqDecision string.
 Proof. solve_decision. Defined.
 Instance string_app_inj : Inj (=) (=) (String.append s1).
@@ -119,3 +121,5 @@ Lemma ascii_of_to_digits a : ascii_of_digits (ascii_to_digits a) = a.
 Proof. by destruct a as [[][][][][][][][]]. Qed.
 Instance ascii_countable : Countable ascii :=
   inj_countable' ascii_to_digits ascii_of_digits ascii_of_to_digits.
+Instance byte_countable : Countable byte :=
+  inj_countable Byte.to_N Byte.of_N Byte.of_to_N.
-- 
GitLab