diff --git a/_CoqProject b/_CoqProject index 0e5f1183e8db25d3387be6c04a5c61430b8a770b..5098d4b6a402e3b6d57c33c703837c494671d7f1 100644 --- a/_CoqProject +++ b/_CoqProject @@ -24,8 +24,6 @@ theories/lang/races.v theories/lang/tactics.v theories/lang/wp_tactics.v theories/typing/type.v -theories/typing/perm.v -theories/typing/typing.v theories/typing/lft_contexts.v theories/typing/type_context.v theories/typing/cont_context.v diff --git a/theories/typing/borrow.v b/theories/typing/borrow.v index ed84c7984ba42aa68813923686d737bf2d348f6c..5b1c1824b266a92a996adb36be58b9a373d14282 100644 --- a/theories/typing/borrow.v +++ b/theories/typing/borrow.v @@ -3,7 +3,7 @@ From iris.base_logic Require Import big_op. From lrust.lifetime Require Import reborrow frac_borrow. From lrust.lang Require Import heap. From lrust.typing Require Export uniq_bor shr_bor own. -From lrust.typing Require Import lft_contexts type_context perm typing programs. +From lrust.typing Require Import lft_contexts type_context programs. (** The rules for borrowing and derferencing borrowed non-Copy pointers are in a separate file so make sure that own.v and uniq_bor.v can be compiled diff --git a/theories/typing/perm.v b/theories/typing/perm.v deleted file mode 100644 index a09cc07bd93656b1d99aa8965cef38ef501273c9..0000000000000000000000000000000000000000 --- a/theories/typing/perm.v +++ /dev/null @@ -1,108 +0,0 @@ -From iris.proofmode Require Import tactics. -From lrust.typing Require Export type. -From lrust.lang Require Export proofmode notation. -From lrust.lifetime Require Import borrow frac_borrow. - -(* TODO: This is all still using the outdated type system. *) - -Section perm. - Context `{typeG Σ}. - - Definition perm {Σ} := na_inv_pool_name → iProp Σ. - - Fixpoint eval_expr (ν : expr) : option val := - match ν with - | BinOp OffsetOp e (Lit (LitInt n)) => - match eval_expr e with - | Some (#(LitLoc l)) => Some (#(shift_loc l n)) - | _ => None - end - | e => to_val e - end. - - Definition has_type (ν : expr) (ty : type) : perm := λ tid, - from_option (λ v, ty.(ty_own) tid [v]) False%I (eval_expr ν). - - Definition extract (κ : lft) (Ï : perm) : perm := - λ tid, ([†κ] ={↑lftN}=∗ Ï tid)%I. - - Definition tok (κ : lft) (q : Qp) : perm := - λ _, q.[κ]%I. - - - Definition killable (κ : lft) : perm := - λ _, (â–¡ (1.[κ] ={⊤,⊤∖↑lftN}â–·=∗ [†κ]))%I. - - Definition incl (κ κ' : lft) : perm := - λ _, (κ ⊑ κ')%I. - - Definition exist {A : Type} (P : A -> perm) : @perm Σ := - λ tid, (∃ x, P x tid)%I. - - Definition sep (Ï1 Ï2 : perm) : @perm Σ := - λ tid, (Ï1 tid ∗ Ï2 tid)%I. - - Global Instance top : Top (@perm Σ) := - λ _, True%I. -(* - Definition perm_incl (Ï1 Ï2 : perm) := - ∀ tid, lft_ctx -∗ Ï1 tid ={⊤}=∗ Ï2 tid. - - Global Instance perm_equiv : Equiv perm := - λ Ï1 Ï2, perm_incl Ï1 Ï2 ∧ perm_incl Ï2 Ï1. *) -End perm. - -Delimit Scope perm_scope with P. -Bind Scope perm_scope with perm. - -Notation "ν â— ty" := (has_type ν%E ty) - (at level 75, right associativity) : perm_scope. - -Notation "κ ∋ Ï" := (extract κ Ï) - (at level 75, right associativity) : perm_scope. - -Notation "q .[ κ ]" := (tok κ q) (format "q .[ κ ]", at level 0) : perm_scope. - -Notation "†κ" := (killable κ) (format "†κ", at level 75). - -Infix "⊑" := incl (at level 70) : perm_scope. - -Notation "∃ x .. y , P" := - (exist (λ x, .. (exist (λ y, P)) ..)) : perm_scope. - -Infix "∗" := sep (at level 80, right associativity) : perm_scope. -(* -Infix "⇒" := perm_incl (at level 95, no associativity) : C_scope. -Notation "(⇒)" := perm_incl (only parsing) : C_scope. - -Notation "Ï1 ⇔ Ï2" := (equiv (A:=perm) Ï1%P Ï2%P) - (at level 95, no associativity) : C_scope. -Notation "(⇔)" := (equiv (A:=perm)) (only parsing) : C_scope. -*) -Section has_type. - Context `{typeG Σ}. - - Lemma has_type_value (v : val) ty tid : - (v â— ty)%P tid ⊣⊢ ty.(ty_own) tid [v]. - Proof. - destruct v as [|f xl e ?]. done. - unfold has_type, eval_expr, of_val. - assert (Rec f xl e = RecV f xl e) as -> by done. by rewrite to_of_val. - Qed. - - Lemma has_type_wp E (ν : expr) ty tid (Φ : val -> iProp _) : - (ν â— ty)%P tid -∗ - (∀ (v : val), ⌜eval_expr ν = Some v⌠-∗ (v â— ty)%P tid ={E}=∗ Φ v) -∗ - WP ν @ E {{ Φ }}. - Proof. - iIntros "Hâ— HΦ". setoid_rewrite has_type_value. unfold has_type. - destruct (eval_expr ν) eqn:EQν; last by iDestruct "Hâ—" as "[]". - iMod ("HΦ" $! v with "[] Hâ—") as "HΦ". done. - iInduction ν as [| | |[] e ? [|[]| | | | | | | | | |] _| | | | | | | |] "IH" - forall (Φ v EQν); try done. - - inversion EQν. subst. wp_value. auto. - - wp_value. auto. - - wp_bind e. simpl in EQν. destruct (eval_expr e) as [[[|l|]|]|]; try done. - iApply ("IH" with "[] [HΦ]"). done. simpl. wp_op. inversion EQν. eauto. - Qed. -End has_type. diff --git a/theories/typing/typing.v b/theories/typing/typing.v deleted file mode 100644 index c2ade248eca4c1adbca74100df94b088752f7ed5..0000000000000000000000000000000000000000 --- a/theories/typing/typing.v +++ /dev/null @@ -1,22 +0,0 @@ -From iris.program_logic Require Import hoare. -From iris.base_logic Require Import big_op. -From lrust.lang Require Export notation memcpy. -From lrust.typing Require Export type. -From lrust.typing Require Import perm lft_contexts type_context cont_context. -From lrust.lang Require Import proofmode. -From lrust.lifetime Require Import frac_borrow reborrow borrow creation. - -(* TODO: This is all still using the outdated type system. *) - -Section typing. - Context `{typeG Σ}. - - (* TODO : good notations for [typed_step] and [typed_step_ty] ? *) - Definition typed_step (Ï : perm) e (θ : val → perm) := - ∀ tid, {{ heap_ctx ∗ lft_ctx ∗ Ï tid ∗ na_own tid ⊤ }} e - {{ v, θ v tid ∗ na_own tid ⊤ }}. - - Definition typed_step_ty (Ï : perm) e ty := - typed_step Ï e (λ ν, ν â— ty)%P. - -End typing.