Skip to content

Commit

Permalink
library fix for libcrux ci
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikbhargavan committed May 6, 2024
1 parent 5bb39d3 commit 16a77ca
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions proof-libs/fstar/rust_primitives/Rust_primitives.Hax.fst
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ class update_at_tc self idx = {

open Core.Slice

instance impl__index t l n: t_Index (t_Array t l) (int_t n)
= { f_Output = t;
f_index_pre = (fun (s: t_Array t l) (i: int_t n) -> v i >= 0 && v i < v l);
f_index_post = (fun _ _ _ -> true);
f_index = (fun s i -> Seq.index s (v i));
}

instance update_at_tc_array t l n: update_at_tc (t_Array t l) (int_t n) = {
super_index = FStar.Tactics.Typeclasses.solve <: t_Index (t_Array t l) (int_t n);
update_at = (fun arr i x -> FStar.Seq.upd arr (v i) x);
}

/// We have an instance for `int_t n`, but we often work with refined
/// `int_t n`, and F* typeclass inference doesn't support subtyping
/// well, hence the instance below.
Expand All @@ -47,6 +35,18 @@ instance update_at_tc_array_refined t l n r: update_at_tc (t_Array t l) (x: int_
update_at = (fun arr i x -> FStar.Seq.upd arr (v i) x);
}

instance impl__index t l n: t_Index (t_Array t l) (int_t n)
= { f_Output = t;
f_index_pre = (fun (s: t_Array t l) (i: int_t n) -> v i >= 0 && v i < v l);
f_index_post = (fun _ _ _ -> true);
f_index = (fun s i -> Seq.index s (v i));
}

instance update_at_tc_array t l n: update_at_tc (t_Array t l) (int_t n) = {
super_index = FStar.Tactics.Typeclasses.solve <: t_Index (t_Array t l) (int_t n);
update_at = (fun arr i x -> FStar.Seq.upd arr (v i) x);
}

let (.[]<-) #self #idx {| update_at_tc self idx |} (s: self) (i: idx {f_index_pre s i})
= update_at s i

Expand Down

0 comments on commit 16a77ca

Please sign in to comment.