Skip to main content

🍬 Michelson_v1_primitives.v


See code, Gitlab , OCaml

Require Import CoqOfOCaml.CoqOfOCaml.
Require Import CoqOfOCaml.Settings.

Require Import TezosOfOCaml.Proto_alpha.Environment.
Require TezosOfOCaml.Proto_alpha.Michelson_v1_primitives.

Require TezosOfOCaml.Proto_alpha.Environment.Proofs.Data_encoding.

Definition prim_encoding_eq (prim1 prim2 : Michelson_v1_primitives.prim)
  : bool :=
    (Michelson_v1_primitives.string_of_prim prim1)
    (Michelson_v1_primitives.string_of_prim prim2).

Lemma prim_encoding_eq_implies_eq prim1 prim2
  : prim_encoding_eq prim1 prim2 = true
    prim1 = prim2.
  destruct prim1, prim2; cbv; congruence.

We use the decidable equality on [prim] in order to have a proof which is fast to build.
Lemma prim_encoding_is_valid
  : Data_encoding.Valid.t (fun _True) Michelson_v1_primitives.prim_encoding.
  eapply Data_encoding.Valid.implies.
  unfold Michelson_v1_primitives.prim_encoding.
  apply Data_encoding.Valid.def.
  apply Data_encoding.Valid.string_enum_dec;
    try apply prim_encoding_eq_implies_eq;
    try reflexivity.
  intros x H; cbv beta; simpl
  destruct x; reflexivity.
#[global] Hint Resolve prim_encoding_is_valid : Data_encoding_db.