Skip to content
Snippets Groups Projects
Commit 58bfc65c authored by Ralf Jung's avatar Ralf Jung
Browse files

Merge branch 'jh/fn_notation' into 'master'

Improve notations for functions

See merge request !23
parents ec9fdf59 b234965c
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 68 deletions
...@@ -61,10 +61,14 @@ Notation "λ: xl , e" := (Lam xl%binder e%E) ...@@ -61,10 +61,14 @@ Notation "λ: xl , e" := (Lam xl%binder e%E)
Notation "λ: xl , e" := (locked (LamV xl%binder e%E)) Notation "λ: xl , e" := (locked (LamV xl%binder e%E))
(at level 102, xl at level 1, e at level 200) : val_scope. (at level 102, xl at level 1, e at level 200) : val_scope.
Notation "'funrec:' f xl := e" := (rec: f ("return"::xl) := e)%E Notation "'fnrec:' f xl := e" := (rec: f (BNamed "return"::xl) := e)%E
(only parsing, at level 102, f, xl at level 1, e at level 200) : expr_scope. (at level 102, f, xl at level 1, e at level 200) : expr_scope.
Notation "'funrec:' f xl := e" := (rec: f ("return"::xl) := e)%V Notation "'fnrec:' f xl := e" := (rec: f (BNamed "return"::xl) := e)%V
(only parsing, at level 102, f, xl at level 1, e at level 200) : val_scope. (at level 102, f, xl at level 1, e at level 200) : val_scope.
Notation "'fn:' xl := e" := (fnrec: <> xl := e)%E
(at level 102, xl at level 1, e at level 200) : expr_scope.
Notation "'fn:' xl := e" := (fnrec: <> xl := e)%V
(at level 102, xl at level 1, e at level 200) : val_scope.
Notation "'return:'" := "return" : expr_scope. Notation "'return:'" := "return" : expr_scope.
Notation "'let:' x := e1 'in' e2" := Notation "'let:' x := e1 'in' e2" :=
......
...@@ -6,7 +6,7 @@ Section get_x. ...@@ -6,7 +6,7 @@ Section get_x.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition get_x : val := Definition get_x : val :=
funrec: <> ["p"] := fn: ["p"] :=
let: "p'" := !"p" in let: "p'" := !"p" in
letalloc: "r" <- "p'" + #0 in letalloc: "r" <- "p'" + #0 in
delete [ #1; "p"] ;; return: ["r"]. delete [ #1; "p"] ;; return: ["r"].
......
...@@ -6,7 +6,7 @@ Section init_prod. ...@@ -6,7 +6,7 @@ Section init_prod.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition init_prod : val := Definition init_prod : val :=
funrec: <> ["x"; "y"] := fn: ["x"; "y"] :=
let: "x'" := !"x" in let: "y'" := !"y" in let: "x'" := !"x" in let: "y'" := !"y" in
let: "r" := new [ #2] in let: "r" := new [ #2] in
"r" + #0 <- "x'";; "r" + #1 <- "y'";; "r" + #0 <- "x'";; "r" + #1 <- "y'";;
......
...@@ -6,7 +6,7 @@ Section lazy_lft. ...@@ -6,7 +6,7 @@ Section lazy_lft.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition lazy_lft : val := Definition lazy_lft : val :=
funrec: <> [] := fn: [] :=
Newlft;; Newlft;;
let: "t" := new [ #2] in let: "f" := new [ #1] in let: "g" := new [ #1] in let: "t" := new [ #2] in let: "f" := new [ #1] in let: "g" := new [ #1] in
let: "42" := #42 in "f" <- "42";; let: "42" := #42 in "f" <- "42";;
......
...@@ -28,7 +28,7 @@ Section non_lexical. ...@@ -28,7 +28,7 @@ Section non_lexical.
typed_val insert (fn( α, ; &uniq{α} hashmap, K, V) option V). typed_val insert (fn( α, ; &uniq{α} hashmap, K, V) option V).
Definition get_default : val := Definition get_default : val :=
funrec: <> ["map"; "key"] := fn: ["map"; "key"] :=
let: "get_mut" := get_mut in let: "get_mut" := get_mut in
let: "map'" := !"map" in let: "map'" := !"map" in
......
...@@ -6,7 +6,7 @@ Section rebor. ...@@ -6,7 +6,7 @@ Section rebor.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition rebor : val := Definition rebor : val :=
funrec: <> ["t1"; "t2"] := fn: ["t1"; "t2"] :=
Newlft;; Newlft;;
letalloc: "x" <- "t1" in letalloc: "x" <- "t1" in
let: "x'" := !"x" in let: "y" := "x'" + #0 in let: "x'" := !"x" in let: "y" := "x'" + #0 in
......
...@@ -6,7 +6,7 @@ Section unbox. ...@@ -6,7 +6,7 @@ Section unbox.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition unbox : val := Definition unbox : val :=
funrec: <> ["b"] := fn: ["b"] :=
let: "b'" := !"b" in let: "bx" := !"b'" in let: "b'" := !"b" in let: "bx" := !"b'" in
letalloc: "r" <- "bx" + #0 in letalloc: "r" <- "bx" + #0 in
delete [ #1; "b"] ;; return: ["r"]. delete [ #1; "b"] ;; return: ["r"].
......
...@@ -404,7 +404,7 @@ Section typing. ...@@ -404,7 +404,7 @@ Section typing.
Lemma type_rec {A} E L fb (argsb : list binder) ef e n Lemma type_rec {A} E L fb (argsb : list binder) ef e n
(fp : A fn_params n) T `{!CopyC T, !SendC T, !Closed _ e} : (fp : A fn_params n) T `{!CopyC T, !SendC T, !Closed _ e} :
IntoVal ef (funrec: fb argsb := e) IntoVal ef (fnrec: fb argsb := e)
n = length argsb n = length argsb
( x ϝ (f : val) k (args : vec val (length argsb)), ( x ϝ (f : val) k (args : vec val (length argsb)),
typed_body ((fp x).(fp_E) ϝ) [ϝ []] typed_body ((fp x).(fp_E) ϝ) [ϝ []]
...@@ -427,7 +427,7 @@ Section typing. ...@@ -427,7 +427,7 @@ Section typing.
Lemma type_fn {A} E L (argsb : list binder) ef e n Lemma type_fn {A} E L (argsb : list binder) ef e n
(fp : A fn_params n) T `{!CopyC T, !SendC T, !Closed _ e} : (fp : A fn_params n) T `{!CopyC T, !SendC T, !Closed _ e} :
IntoVal ef (funrec: <> argsb := e) IntoVal ef (fn: argsb := e)
n = length argsb n = length argsb
( x ϝ k (args : vec val (length argsb)), ( x ϝ k (args : vec val (length argsb)),
typed_body ((fp x).(fp_E) ϝ) typed_body ((fp x).(fp_E) ϝ)
......
...@@ -328,7 +328,7 @@ Section arc. ...@@ -328,7 +328,7 @@ Section arc.
(* Code : constructors *) (* Code : constructors *)
Definition arc_new ty : val := Definition arc_new ty : val :=
funrec: <> ["x"] := fn: ["x"] :=
let: "arcbox" := new [ #(2 + ty.(ty_size))%nat ] in let: "arcbox" := new [ #(2 + ty.(ty_size))%nat ] in
let: "arc" := new [ #1 ] in let: "arc" := new [ #1 ] in
"arcbox" + #0 <- #1;; "arcbox" + #0 <- #1;;
...@@ -371,7 +371,7 @@ Section arc. ...@@ -371,7 +371,7 @@ Section arc.
Qed. Qed.
Definition weak_new ty : val := Definition weak_new ty : val :=
funrec: <> [] := fn: [] :=
let: "arcbox" := new [ #(2 + ty.(ty_size))%nat ] in let: "arcbox" := new [ #(2 + ty.(ty_size))%nat ] in
let: "w" := new [ #1 ] in let: "w" := new [ #1 ] in
"arcbox" + #0 <- #0;; "arcbox" + #0 <- #0;;
...@@ -414,7 +414,7 @@ Section arc. ...@@ -414,7 +414,7 @@ Section arc.
(* Code : deref *) (* Code : deref *)
Definition arc_deref : val := Definition arc_deref : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "x" := new [ #1 ] in let: "x" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
"x" <- (!"arc'" + #2);; "x" <- (!"arc'" + #2);;
...@@ -457,7 +457,7 @@ Section arc. ...@@ -457,7 +457,7 @@ Section arc.
(* Code : getters *) (* Code : getters *)
Definition arc_strong_count : val := Definition arc_strong_count : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
...@@ -500,7 +500,7 @@ Section arc. ...@@ -500,7 +500,7 @@ Section arc.
Qed. Qed.
Definition arc_weak_count : val := Definition arc_weak_count : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
...@@ -544,7 +544,7 @@ Section arc. ...@@ -544,7 +544,7 @@ Section arc.
(* Code : clone, [up/down]grade. *) (* Code : clone, [up/down]grade. *)
Definition arc_clone : val := Definition arc_clone : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
...@@ -588,7 +588,7 @@ Section arc. ...@@ -588,7 +588,7 @@ Section arc.
Qed. Qed.
Definition weak_clone : val := Definition weak_clone : val :=
funrec: <> ["w"] := fn: ["w"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "w'" := !"w" in let: "w'" := !"w" in
let: "w''" := !"w'" in let: "w''" := !"w'" in
...@@ -632,7 +632,7 @@ Section arc. ...@@ -632,7 +632,7 @@ Section arc.
Qed. Qed.
Definition downgrade : val := Definition downgrade : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
...@@ -676,7 +676,7 @@ Section arc. ...@@ -676,7 +676,7 @@ Section arc.
Qed. Qed.
Definition upgrade : val := Definition upgrade : val :=
funrec: <> ["w"] := fn: ["w"] :=
let: "r" := new [ #2 ] in let: "r" := new [ #2 ] in
let: "w'" := !"w" in let: "w'" := !"w" in
let: "w''" := !"w'" in let: "w''" := !"w'" in
...@@ -733,7 +733,7 @@ Section arc. ...@@ -733,7 +733,7 @@ Section arc.
(* Code : drop *) (* Code : drop *)
Definition arc_drop ty : val := Definition arc_drop ty : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #(option ty).(ty_size) ] in let: "r" := new [ #(option ty).(ty_size) ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
"r" <-{Σ none} ();; "r" <-{Σ none} ();;
...@@ -801,7 +801,7 @@ Section arc. ...@@ -801,7 +801,7 @@ Section arc.
Qed. Qed.
Definition weak_drop ty : val := Definition weak_drop ty : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #0] in let: "r" := new [ #0] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
(if: drop_weak ["arc'"] then delete [ #(2 + ty.(ty_size)); "arc'" ] (if: drop_weak ["arc'"] then delete [ #(2 + ty.(ty_size)); "arc'" ]
...@@ -837,7 +837,7 @@ Section arc. ...@@ -837,7 +837,7 @@ Section arc.
(* Code : other primitives *) (* Code : other primitives *)
Definition arc_try_unwrap ty : val := Definition arc_try_unwrap ty : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #(Σ[ ty; arc ty ]).(ty_size) ] in let: "r" := new [ #(Σ[ ty; arc ty ]).(ty_size) ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
if: try_unwrap ["arc'"] then if: try_unwrap ["arc'"] then
...@@ -912,7 +912,7 @@ Section arc. ...@@ -912,7 +912,7 @@ Section arc.
Qed. Qed.
Definition arc_get_mut : val := Definition arc_get_mut : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #2 ] in let: "r" := new [ #2 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
...@@ -975,7 +975,7 @@ Section arc. ...@@ -975,7 +975,7 @@ Section arc.
Qed. Qed.
Definition arc_make_mut (ty : type) (clone : val) : val := Definition arc_make_mut (ty : type) (clone : val) : val :=
funrec: <> ["arc"] := fn: ["arc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "arc'" := !"arc" in let: "arc'" := !"arc" in
let: "arc''" := !"arc'" in let: "arc''" := !"arc'" in
......
...@@ -150,7 +150,7 @@ Section brandedvec. ...@@ -150,7 +150,7 @@ Section brandedvec.
iIntros "Hn Hm". iIntros "Hn Hm".
iDestruct "Hn" as (γn) "(Hidx1 & Hn)". iDestruct "Hn" as (γn) "(Hidx1 & Hn)".
iDestruct "Hm" as (γm) "(Hidx2 & Hm)". iDestruct "Hm" as (γm) "(Hidx2 & Hm)".
iDestruct (lft_meta_agree with "Hidx1 Hidx2") as %<-. iDestruct (lft_meta_agree with "Hidx1 Hidx2") as %<-.
iDestruct (own_valid_2 with "Hn Hm") as %[?%max_nat_included ?]%auth_both_valid_discrete. iDestruct (own_valid_2 with "Hn Hm") as %[?%max_nat_included ?]%auth_both_valid_discrete.
iPureIntro. simpl in *. lia. iPureIntro. simpl in *. lia.
Qed. Qed.
...@@ -163,7 +163,7 @@ Section typing. ...@@ -163,7 +163,7 @@ Section typing.
Local Notation iProp := (iProp Σ). Local Notation iProp := (iProp Σ).
Definition brandvec_new (call_once : val) (R_F : type) : val := Definition brandvec_new (call_once : val) (R_F : type) : val :=
funrec: <> ["f"] := fn: ["f"] :=
let: "call_once" := call_once in let: "call_once" := call_once in
letalloc: "n" <- #0 in letalloc: "n" <- #0 in
letcall: "r" := "call_once" ["f";"n"]%E in letcall: "r" := "call_once" ["f";"n"]%E in
...@@ -233,7 +233,7 @@ Section typing. ...@@ -233,7 +233,7 @@ Section typing.
Qed. Qed.
Definition brandvec_get_index : val := Definition brandvec_get_index : val :=
funrec: <> ["v"; "i"] := fn: ["v"; "i"] :=
let: "r" := new [ #2 ] in let: "r" := new [ #2 ] in
let: "v'" := !"v" in let: "v'" := !"v" in
let: "i'" := !"i" in let: "i'" := !"i" in
...@@ -310,7 +310,7 @@ Section typing. ...@@ -310,7 +310,7 @@ Section typing.
Qed. Qed.
Definition brandidx_get : val := Definition brandidx_get : val :=
funrec: <> ["s";"c"] := fn: ["s";"c"] :=
let: "len" := !"s" in let: "len" := !"s" in
let: "idx" := !"c" in let: "idx" := !"c" in
delete [ #1; "s" ];; delete [ #1; "c" ];; delete [ #1; "s" ];; delete [ #1; "c" ];;
...@@ -360,7 +360,7 @@ Section typing. ...@@ -360,7 +360,7 @@ Section typing.
Qed. Qed.
Definition brandvec_push : val := Definition brandvec_push : val :=
funrec: <> ["s"] := fn: ["s"] :=
let: "n" := !"s" in let: "n" := !"s" in
delete [ #1; "s" ];; delete [ #1; "s" ];;
let: "r" := new [ #1] in let: "r" := new [ #1] in
......
...@@ -84,7 +84,7 @@ Section typing. ...@@ -84,7 +84,7 @@ Section typing.
(** The next couple functions essentially show owned-type equalities, as they (** The next couple functions essentially show owned-type equalities, as they
are all different types for the identity function. *) are all different types for the identity function. *)
(* Constructing a cell. *) (* Constructing a cell. *)
Definition cell_new : val := funrec: <> ["x"] := return: ["x"]. Definition cell_new : val := fn: ["x"] := return: ["x"].
Lemma cell_new_type ty `{!TyWf ty} : typed_val cell_new (fn(; ty) cell ty). Lemma cell_new_type ty `{!TyWf ty} : typed_val cell_new (fn(; ty) cell ty).
Proof. Proof.
...@@ -95,7 +95,7 @@ Section typing. ...@@ -95,7 +95,7 @@ Section typing.
Qed. Qed.
(* The other direction: getting ownership out of a cell. *) (* The other direction: getting ownership out of a cell. *)
Definition cell_into_inner : val := funrec: <> ["x"] := return: ["x"]. Definition cell_into_inner : val := fn: ["x"] := return: ["x"].
Lemma cell_into_inner_type ty `{!TyWf ty} : Lemma cell_into_inner_type ty `{!TyWf ty} :
typed_val cell_into_inner (fn(; cell ty) ty). typed_val cell_into_inner (fn(; cell ty) ty).
...@@ -107,7 +107,7 @@ Section typing. ...@@ -107,7 +107,7 @@ Section typing.
Qed. Qed.
Definition cell_get_mut : val := Definition cell_get_mut : val :=
funrec: <> ["x"] := return: ["x"]. fn: ["x"] := return: ["x"].
Lemma cell_get_mut_type ty `{!TyWf ty} : Lemma cell_get_mut_type ty `{!TyWf ty} :
typed_val cell_get_mut (fn( α, ; &uniq{α} (cell ty)) &uniq{α} ty). typed_val cell_get_mut (fn( α, ; &uniq{α} (cell ty)) &uniq{α} ty).
...@@ -119,7 +119,7 @@ Section typing. ...@@ -119,7 +119,7 @@ Section typing.
Qed. Qed.
Definition cell_from_mut : val := Definition cell_from_mut : val :=
funrec: <> ["x"] := return: ["x"]. fn: ["x"] := return: ["x"].
Lemma cell_from_mut_type ty `{!TyWf ty} : Lemma cell_from_mut_type ty `{!TyWf ty} :
typed_val cell_from_mut (fn( α, ; &uniq{α} ty) &uniq{α} (cell ty)). typed_val cell_from_mut (fn( α, ; &uniq{α} ty) &uniq{α} (cell ty)).
...@@ -131,7 +131,7 @@ Section typing. ...@@ -131,7 +131,7 @@ Section typing.
Qed. Qed.
Definition cell_into_box : val := Definition cell_into_box : val :=
funrec: <> ["x"] := return: ["x"]. fn: ["x"] := return: ["x"].
Lemma cell_into_box_type ty `{!TyWf ty} : Lemma cell_into_box_type ty `{!TyWf ty} :
typed_val cell_into_box (fn(;box (cell ty)) box ty). typed_val cell_into_box (fn(;box (cell ty)) box ty).
...@@ -143,7 +143,7 @@ Section typing. ...@@ -143,7 +143,7 @@ Section typing.
Qed. Qed.
Definition cell_from_box : val := Definition cell_from_box : val :=
funrec: <> ["x"] := return: ["x"]. fn: ["x"] := return: ["x"].
Lemma cell_from_box_type ty `{!TyWf ty} : Lemma cell_from_box_type ty `{!TyWf ty} :
typed_val cell_from_box (fn(; box ty) box (cell ty)). typed_val cell_from_box (fn(; box ty) box (cell ty)).
...@@ -156,7 +156,7 @@ Section typing. ...@@ -156,7 +156,7 @@ Section typing.
(** Reading from a cell *) (** Reading from a cell *)
Definition cell_get ty : val := Definition cell_get ty : val :=
funrec: <> ["x"] := fn: ["x"] :=
let: "x'" := !"x" in let: "x'" := !"x" in
letalloc: "r" <-{ty.(ty_size)} !"x'" in letalloc: "r" <-{ty.(ty_size)} !"x'" in
delete [ #1; "x"];; return: ["r"]. delete [ #1; "x"];; return: ["r"].
...@@ -177,7 +177,7 @@ Section typing. ...@@ -177,7 +177,7 @@ Section typing.
(** Writing to a cell *) (** Writing to a cell *)
Definition cell_replace ty : val := Definition cell_replace ty : val :=
funrec: <> ["c"; "x"] := fn: ["c"; "x"] :=
let: "c'" := !"c" in let: "c'" := !"c" in
letalloc: "r" <-{ty.(ty_size)} !"c'" in letalloc: "r" <-{ty.(ty_size)} !"c'" in
"c'" <-{ty.(ty_size)} !"x";; "c'" <-{ty.(ty_size)} !"x";;
...@@ -231,7 +231,7 @@ Section typing. ...@@ -231,7 +231,7 @@ Section typing.
Called alias::one in Rust. Called alias::one in Rust.
This is really just [cell_from_mut] followed by sharing. *) This is really just [cell_from_mut] followed by sharing. *)
Definition fake_shared_cell : val := Definition fake_shared_cell : val :=
funrec: <> ["x"] := fn: ["x"] :=
let: "x'" := !"x" in let: "x'" := !"x" in
letalloc: "r" <- "x'" in letalloc: "r" <- "x'" in
delete [ #1; "x"];; return: ["r"]. delete [ #1; "x"];; return: ["r"].
......
...@@ -9,7 +9,7 @@ Section diverging_static. ...@@ -9,7 +9,7 @@ Section diverging_static.
(* Show that we can convert any live borrow to 'static with an infinite (* Show that we can convert any live borrow to 'static with an infinite
loop. *) loop. *)
Definition diverging_static_loop (call_once : val) : val := Definition diverging_static_loop (call_once : val) : val :=
funrec: <> ["x"; "f"] := fn: ["x"; "f"] :=
let: "call_once" := call_once in let: "call_once" := call_once in
letcall: "ret" := "call_once" ["f"; "x"]%E in letcall: "ret" := "call_once" ["f"; "x"]%E in
withcont: "loop": withcont: "loop":
......
...@@ -6,7 +6,7 @@ Section fake_shared. ...@@ -6,7 +6,7 @@ Section fake_shared.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition fake_shared_box : val := Definition fake_shared_box : val :=
funrec: <> ["x"] := Skip ;; return: ["x"]. fn: ["x"] := Skip ;; return: ["x"].
Lemma fake_shared_box_type ty `{!TyWf ty} : Lemma fake_shared_box_type ty `{!TyWf ty} :
typed_val fake_shared_box typed_val fake_shared_box
...@@ -36,7 +36,7 @@ Section fake_shared. ...@@ -36,7 +36,7 @@ Section fake_shared.
Qed. Qed.
Definition fake_shared_uniq : val := Definition fake_shared_uniq : val :=
funrec: <> ["x"] := Skip ;; return: ["x"]. fn: ["x"] := Skip ;; return: ["x"].
Lemma fake_shared_uniq_type ty `{!TyWf ty} : Lemma fake_shared_uniq_type ty `{!TyWf ty} :
typed_val fake_shared_box typed_val fake_shared_box
......
...@@ -351,7 +351,7 @@ Section ghostcell. ...@@ -351,7 +351,7 @@ Section ghostcell.
Qed. Qed.
Definition ghosttoken_new (call_once : val) (R_F : type) : val := Definition ghosttoken_new (call_once : val) (R_F : type) : val :=
funrec: <> ["f"] := fn: ["f"] :=
let: "call_once" := call_once in let: "call_once" := call_once in
let: "n" := new [ #0] in let: "n" := new [ #0] in
letcall: "r" := "call_once" ["f";"n"]%E in letcall: "r" := "call_once" ["f";"n"]%E in
...@@ -406,7 +406,7 @@ Section ghostcell. ...@@ -406,7 +406,7 @@ Section ghostcell.
Qed. Qed.
Definition ghostcell_new : val := Definition ghostcell_new : val :=
funrec: <> ["n"] := fn: ["n"] :=
return: ["n"]. return: ["n"].
Lemma ghostcell_new_type `{!TyWf ty} : Lemma ghostcell_new_type `{!TyWf ty} :
...@@ -426,7 +426,7 @@ Section ghostcell. ...@@ -426,7 +426,7 @@ Section ghostcell.
Qed. Qed.
Definition ghostcell_borrow : val := Definition ghostcell_borrow : val :=
funrec: <> ["c";"s"] := fn: ["c";"s"] :=
(* Skips needed for laters *) (* Skips needed for laters *)
Skip ;; Skip ;; Skip ;; Skip ;;
return: ["c"]. return: ["c"].
...@@ -583,7 +583,7 @@ Section ghostcell. ...@@ -583,7 +583,7 @@ Section ghostcell.
Qed. Qed.
Definition ghostcell_borrow_mut : val := Definition ghostcell_borrow_mut : val :=
funrec: <> ["c";"s"] := fn: ["c";"s"] :=
(* Skips needed for laters *) (* Skips needed for laters *)
Skip ;; Skip ;; Skip ;; Skip ;;
return: ["c"]. return: ["c"].
...@@ -686,7 +686,7 @@ Section ghostcell. ...@@ -686,7 +686,7 @@ Section ghostcell.
Qed. Qed.
Definition ghostcell_as_mut : val := Definition ghostcell_as_mut : val :=
funrec: <> ["c"] := fn: ["c"] :=
return: ["c"]. return: ["c"].
Lemma ghostcell_as_mut_type `{!TyWf ty} : Lemma ghostcell_as_mut_type `{!TyWf ty} :
......
...@@ -14,7 +14,7 @@ Section join. ...@@ -14,7 +14,7 @@ Section join.
One of the closures is executed in another thread, and the One of the closures is executed in another thread, and the
closures can refer to on-stack data (no 'static' bound). *) closures can refer to on-stack data (no 'static' bound). *)
Definition join (call_once_A call_once_B : val) (R_A R_B : type) : val := Definition join (call_once_A call_once_B : val) (R_A R_B : type) : val :=
funrec: <> ["fA"; "fB"] := fn: ["fA"; "fB"] :=
let: "call_once_A" := call_once_A in let: "call_once_A" := call_once_A in
let: "call_once_B" := call_once_B in let: "call_once_B" := call_once_B in
let: "join" := spawn [λ: ["c"], let: "join" := spawn [λ: ["c"],
......
...@@ -129,7 +129,7 @@ Section code. ...@@ -129,7 +129,7 @@ Section code.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition mutex_new ty : val := Definition mutex_new ty : val :=
funrec: <> ["x"] := fn: ["x"] :=
let: "m" := new [ #(mutex ty).(ty_size) ] in let: "m" := new [ #(mutex ty).(ty_size) ] in
"m" + #1 <-{ty.(ty_size)} !"x";; "m" + #1 <-{ty.(ty_size)} !"x";;
mklock_unlocked ["m" + #0];; mklock_unlocked ["m" + #0];;
...@@ -169,7 +169,7 @@ Section code. ...@@ -169,7 +169,7 @@ Section code.
Qed. Qed.
Definition mutex_into_inner ty : val := Definition mutex_into_inner ty : val :=
funrec: <> ["m"] := fn: ["m"] :=
let: "x" := new [ #ty.(ty_size) ] in let: "x" := new [ #ty.(ty_size) ] in
"x" <-{ty.(ty_size)} !("m" + #1);; "x" <-{ty.(ty_size)} !("m" + #1);;
delete [ #(mutex ty).(ty_size); "m"];; return: ["x"]. delete [ #(mutex ty).(ty_size); "m"];; return: ["x"].
...@@ -208,7 +208,7 @@ Section code. ...@@ -208,7 +208,7 @@ Section code.
Qed. Qed.
Definition mutex_get_mut : val := Definition mutex_get_mut : val :=
funrec: <> ["m"] := fn: ["m"] :=
let: "m'" := !"m" in let: "m'" := !"m" in
"m" <- ("m'" + #1);; "m" <- ("m'" + #1);;
return: ["m"]. return: ["m"].
......
...@@ -160,7 +160,7 @@ Section code. ...@@ -160,7 +160,7 @@ Section code.
Qed. Qed.
Definition mutex_lock : val := Definition mutex_lock : val :=
funrec: <> ["mutex"] := fn: ["mutex"] :=
let: "m" := !"mutex" in let: "m" := !"mutex" in
let: "guard" := new [ #1 ] in let: "guard" := new [ #1 ] in
acquire ["m"];; acquire ["m"];;
...@@ -197,7 +197,7 @@ Section code. ...@@ -197,7 +197,7 @@ Section code.
Qed. Qed.
Definition mutexguard_derefmut : val := Definition mutexguard_derefmut : val :=
funrec: <> ["g"] := fn: ["g"] :=
let: "g'" := !"g" in let: "g'" := !"g" in
let: "m" := !"g'" in let: "m" := !"g'" in
letalloc: "r" <- ("m" + #1) in letalloc: "r" <- ("m" + #1) in
...@@ -283,7 +283,7 @@ Section code. ...@@ -283,7 +283,7 @@ Section code.
Qed. Qed.
Definition mutexguard_drop : val := Definition mutexguard_drop : val :=
funrec: <> ["g"] := fn: ["g"] :=
let: "m" := !"g" in let: "m" := !"g" in
release ["m"];; release ["m"];;
delete [ #1; "g" ];; delete [ #1; "g" ];;
......
...@@ -18,7 +18,7 @@ Section option. ...@@ -18,7 +18,7 @@ Section option.
Definition some := 1%nat. Definition some := 1%nat.
Definition option_as_mut : val := Definition option_as_mut : val :=
funrec: <> ["o"] := fn: ["o"] :=
let: "o'" := !"o" in let: "o'" := !"o" in
let: "r" := new [ #2 ] in let: "r" := new [ #2 ] in
withcont: "k": withcont: "k":
...@@ -50,7 +50,7 @@ Section option. ...@@ -50,7 +50,7 @@ Section option.
Qed. Qed.
Definition option_unwrap_or τ : val := Definition option_unwrap_or τ : val :=
funrec: <> ["o"; "def"] := fn: ["o"; "def"] :=
case: !"o" of case: !"o" of
[ delete [ #(S τ.(ty_size)); "o"];; [ delete [ #(S τ.(ty_size)); "o"];;
return: ["def"]; return: ["def"];
...@@ -74,7 +74,7 @@ Section option. ...@@ -74,7 +74,7 @@ Section option.
Qed. Qed.
Definition option_unwrap τ : val := Definition option_unwrap τ : val :=
funrec: <> ["o"] := fn: ["o"] :=
case: !"o" of case: !"o" of
[ let: "panic" := panic in [ let: "panic" := panic in
letcall: "emp" := "panic" [] in letcall: "emp" := "panic" [] in
......
...@@ -14,7 +14,7 @@ Section panic. ...@@ -14,7 +14,7 @@ Section panic.
Context `{!typeG Σ}. Context `{!typeG Σ}.
Definition panic : val := Definition panic : val :=
funrec: <> [] := #☠. fn: [] := #☠.
Lemma panic_type : typed_val panic (fn() ). Lemma panic_type : typed_val panic (fn() ).
Proof. Proof.
......
...@@ -383,7 +383,7 @@ Section code. ...@@ -383,7 +383,7 @@ Section code.
Qed. Qed.
Definition rc_strong_count : val := Definition rc_strong_count : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
let: "rc''" := !"rc'" in let: "rc''" := !"rc'" in
...@@ -440,7 +440,7 @@ Section code. ...@@ -440,7 +440,7 @@ Section code.
Qed. Qed.
Definition rc_weak_count : val := Definition rc_weak_count : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
let: "rc''" := !"rc'" in let: "rc''" := !"rc'" in
...@@ -501,7 +501,7 @@ Section code. ...@@ -501,7 +501,7 @@ Section code.
Qed. Qed.
Definition rc_new ty : val := Definition rc_new ty : val :=
funrec: <> ["x"] := fn: ["x"] :=
let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in
let: "rc" := new [ #1 ] in let: "rc" := new [ #1 ] in
"rcbox" + #0 <- #1;; "rcbox" + #0 <- #1;;
...@@ -544,7 +544,7 @@ Section code. ...@@ -544,7 +544,7 @@ Section code.
Qed. Qed.
Definition rc_clone : val := Definition rc_clone : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
let: "rc''" := !"rc'" in let: "rc''" := !"rc'" in
...@@ -609,7 +609,7 @@ Section code. ...@@ -609,7 +609,7 @@ Section code.
Qed. Qed.
Definition rc_deref : val := Definition rc_deref : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "x" := new [ #1 ] in let: "x" := new [ #1 ] in
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
"x" <- (!"rc'" + #2);; "x" <- (!"rc'" + #2);;
...@@ -651,7 +651,7 @@ Section code. ...@@ -651,7 +651,7 @@ Section code.
Qed. Qed.
Definition rc_try_unwrap ty : val := Definition rc_try_unwrap ty : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #(Σ[ ty; rc ty ]).(ty_size) ] in let: "r" := new [ #(Σ[ ty; rc ty ]).(ty_size) ] in
withcont: "k": withcont: "k":
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
...@@ -749,7 +749,7 @@ Section code. ...@@ -749,7 +749,7 @@ Section code.
Qed. Qed.
Definition rc_drop ty : val := Definition rc_drop ty : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #(option ty).(ty_size) ] in let: "r" := new [ #(option ty).(ty_size) ] in
withcont: "k": withcont: "k":
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
...@@ -843,7 +843,7 @@ Section code. ...@@ -843,7 +843,7 @@ Section code.
Qed. Qed.
Definition rc_get_mut : val := Definition rc_get_mut : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #2 ] in let: "r" := new [ #2 ] in
withcont: "k": withcont: "k":
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
...@@ -934,7 +934,7 @@ Section code. ...@@ -934,7 +934,7 @@ Section code.
(* TODO : it is not nice that we have to inline the definition of (* TODO : it is not nice that we have to inline the definition of
rc_new and of rc_deref. *) rc_new and of rc_deref. *)
Definition rc_make_mut (ty : type) (clone : val) : val := Definition rc_make_mut (ty : type) (clone : val) : val :=
funrec: <> ["rc"] := fn: ["rc"] :=
let: "r" := new [ #1 ] in let: "r" := new [ #1 ] in
withcont: "k": withcont: "k":
let: "rc'" := !"rc" in let: "rc'" := !"rc" in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment