Commit 10632f27 authored by Dan Frumin's avatar Dan Frumin

[F_mu_ref_conc] port FG_ and CG_ to tp tactics

parent cac30916
This diff is collapsed.
From iris_logrel.F_mu_ref_conc Require Import typing.
(* stack τ = μ x. ref (Unit + τ * x) *)
Definition FG_StackType τ :=
TRec (Tref (TSum TUnit (TProd τ.[ren (+1)] (TVar 0)))).
(* push st = λ x.
(λ stv. if (CAS(st, stv, ref (cons x stv)))
#()
(push st x)) (load st) *)
Definition FG_push (st : expr) : expr :=
Rec (App (Rec
(* try push *)
......@@ -28,6 +33,16 @@ Definition FG_pushV (st : expr) : val :=
(Load st.[ren (+2)]) (* read the stack pointer *)
).
(* pop st = λ (),
(λ str.
(λ x. match x with
| nil => InjL #()
| cons y ys =>
if CAS(st, str, ys)
(InjR y)
(pop st ()))
(load str))
(load st)*)
Definition FG_pop (st : expr) : expr :=
Rec (App (Rec
(App
......@@ -83,6 +98,10 @@ Definition FG_popV (st : expr) : val :=
(Unfold (Load st.[ren (+ 2)]))
).
(* iter f = λ st.
case (load st) of
| nil => #()
| cons y ys => f y ;; iter f ys *)
Definition FG_iter (f : expr) : expr :=
Rec
(Case (Load (Unfold (Var 1)))
......@@ -99,12 +118,15 @@ Definition FG_iterV (f : expr) : val :=
(App f.[ren (+3)] (Fst (Var 0)))
)
).
(* read_iter st := λf. iter f (load st) *)
Definition FG_read_iter (st : expr) : expr :=
Rec (App (FG_iter (Var 1)) (Load st.[ren (+2)])).
(* stack_body st = push st, pop st, read_iter st *)
Definition FG_stack_body (st : expr) : expr :=
Pair (Pair (FG_push st) (FG_pop st)) (FG_read_iter st).
(* stack = Λα. (λ (s : stack α). stack_body s) (ref (ref nil)) *)
Definition FG_stack : expr :=
TLam (App (Rec (FG_stack_body (Var 1)))
(Alloc (Fold (Alloc (InjL Unit))))).
......@@ -130,6 +152,8 @@ Section FG_stack.
(* The following assumption is simply ** WRONG ** *)
(* We assume it though to just be able to prove that the
stack we are implementing is /type-sane/ so to speak! *)
(* EqType (stack τ) would mean that we can compare two stacks for
equality, we need this for compare-and-swap *)
Context (HEQTP : τ, EqType (FG_StackType τ)).
Lemma FG_push_type st Γ τ :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment