From 1c1a121ae0434e5dc6cb05bbafa6e8c2fa3cbf35 Mon Sep 17 00:00:00 2001 From: Brian Campbell Date: Mon, 25 Jun 2018 15:44:45 +0100 Subject: Coq: automatic cast introduction --- lib/coq/Sail2_operators_mwords.v | 3 +++ lib/vector_dec.sail | 2 +- lib/vector_inc.sail | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/coq/Sail2_operators_mwords.v b/lib/coq/Sail2_operators_mwords.v index 25a643e7..ee98c94e 100644 --- a/lib/coq/Sail2_operators_mwords.v +++ b/lib/coq/Sail2_operators_mwords.v @@ -27,6 +27,9 @@ Qed. Definition autocast {m n} (x : mword m) `{H:ArithFact (m = n)} : mword n := cast_mword x (use_ArithFact H). +Definition autocast_m {rv e m n} (x : monad rv (mword m) e) `{H:ArithFact (m = n)} : monad rv (mword n) e := + x >>= fun x => returnm (cast_mword x (use_ArithFact H)). + Definition cast_word {m n} (x : Word.word m) (eq : m = n) : Word.word n. rewrite <- eq. exact x. diff --git a/lib/vector_dec.sail b/lib/vector_dec.sail index 1d528cf6..86bbe601 100644 --- a/lib/vector_dec.sail +++ b/lib/vector_dec.sail @@ -112,7 +112,7 @@ val vector_subrange = { c: "vector_subrange", coq: "subrange_vec_dec" } : forall ('n : Int) ('m : Int) ('o : Int), 0 <= 'o <= 'm < 'n. - (bits('n), atom('m), atom('o)) -> bits('m - ('o - 1)) + (bits('n), atom('m), atom('o)) -> bits('m - 'o + 1) val vector_update_subrange = { ocaml: "update_subrange", diff --git a/lib/vector_inc.sail b/lib/vector_inc.sail index 873d2d33..b295c92c 100644 --- a/lib/vector_inc.sail +++ b/lib/vector_inc.sail @@ -106,7 +106,7 @@ val vector_subrange = { c: "vector_subrange", coq: "subrange_vec_inc" } : forall ('n : Int) ('m : Int) ('o : Int), 0 <= 'm <= 'o < 'n. - (bits('n), atom('m), atom('o)) -> bits('o - ('m - 1)) + (bits('n), atom('m), atom('o)) -> bits('o - 'm + 1) val vector_update_subrange = { ocaml: "update_subrange", -- cgit v1.2.3