diff --git a/theories/proofmode/base.v b/theories/proofmode/base.v index 1e185e2cdf4d4b2852b6c2b4b043b47a538d128c..4ff779335013ce517652eda6467683823c1948ec 100644 --- a/theories/proofmode/base.v +++ b/theories/proofmode/base.v @@ -49,3 +49,37 @@ Qed. Lemma string_beq_reflect s1 s2 : reflect (s1 = s2) (string_beq s1 s2). Proof. apply iff_reflect. by rewrite string_beq_true. Qed. + +Module Export ident. +Inductive ident := + | IAnon : positive → ident + | INamed :> string → ident. +End ident. + +Instance maybe_IAnon : Maybe IAnon := λ i, + match i with IAnon n => Some n | _ => None end. +Instance maybe_INamed : Maybe INamed := λ i, + match i with INamed s => Some s | _ => None end. + +Instance beq_eq_dec : EqDecision ident. +Proof. solve_decision. Defined. + +Definition positive_beq := Eval compute in Pos.eqb. + +Lemma positive_beq_true x y : positive_beq x y = true ↔ x = y. +Proof. apply Pos.eqb_eq. Qed. + +Definition ident_beq (i1 i2 : ident) : bool := + match i1, i2 with + | IAnon n1, IAnon n2 => positive_beq n1 n2 + | INamed s1, INamed s2 => string_beq s1 s2 + | _, _ => false + end. + +Lemma ident_beq_true i1 i2 : ident_beq i1 i2 = true ↔ i1 = i2. +Proof. + destruct i1, i2; rewrite /= ?string_beq_true ?positive_beq_true; naive_solver. +Qed. + +Lemma ident_beq_reflect i1 i2 : reflect (i1 = i2) (ident_beq i1 i2). +Proof. apply iff_reflect. by rewrite ident_beq_true. Qed.