Skip to content

Commit e5dd7bc

Browse files
committed
Made Permissions.of_list call of_list_bool
1 parent 6d2906a commit e5dd7bc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

theories/Morello/Capabilities.v

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ Proof.
8484
+ intro H. rewrite H. done.
8585
Qed.
8686

87+
(* Permissions bits are represented in the same order of significance as in the full capability (eg, 1%bv encodes the Global permission) *)
8788
Module Permissions <: PERMISSIONS.
88-
Definition len:N := 18. (* CAP_PERMS_NUM_BITS = 16 bits of actual perms + 2 bits for Executive and Global *)
89+
Definition len:N := 18. (* CAP_PERMS_NUM_BITS = 16 bits of actual perms + 2 bits for Executive and Global. *)
8990
Definition t := bv len.
9091

9192
Definition to_Z (perms:t) : Z := bv_to_Z_unsigned perms.
@@ -95,6 +96,13 @@ Module Permissions <: PERMISSIONS.
9596
Program Definition of_list_bool (l:list bool) `{(N.of_nat (List.length l) = len)%N} : t :=
9697
MachineWord.N_to_word (List.length l) (Ascii.N_of_digits l).
9798
Next Obligation. auto. Defined.
99+
100+
Program Definition of_list (l : list bool) : option t :=
101+
match (Nat.eq_dec (List.length l) (N.to_nat len)) with
102+
| left eq => Some (@of_list_bool l _)
103+
| right _ => None
104+
end.
105+
Next Obligation. intros. rewrite eq. done. Defined.
98106

99107
Definition user_perms_len:nat := 4.
100108

@@ -379,11 +387,6 @@ Module Permissions <: PERMISSIONS.
379387

380388
Definition of_raw (z:Z) : t := of_Z z.
381389

382-
Definition of_list (l : list bool) : option t :=
383-
if ((List.length l) <? (N.to_nat len))%nat then
384-
None
385-
else
386-
Some (@mword_to_bv (Z.of_N len) (of_bools (List.rev (List.firstn (N.to_nat len) l)))).
387390

388391
Definition to_list (perms:t) : list bool :=
389392
bv_to_list_bool perms.

0 commit comments

Comments
 (0)