MoSeL: A General, Extensible Modal Framework for Interactive Proofs - - PowerPoint PPT Presentation

mosel a general extensible modal framework for
SMART_READER_LITE
LIVE PREVIEW

MoSeL: A General, Extensible Modal Framework for Interactive Proofs - - PowerPoint PPT Presentation

MoSeL: A General, Extensible Modal Framework for Interactive Proofs in Separation Logic Robbert Krebbers 1 Delft University of Technology, The Netherlands October 9, 2018 @ Types Meeting, Aarhus, Denmark 1 MoSeL is joint work with Jacques-Henri


slide-1
SLIDE 1

1

MoSeL: A General, Extensible Modal Framework for Interactive Proofs in Separation Logic

Robbert Krebbers1

Delft University of Technology, The Netherlands

October 9, 2018 @ Types Meeting, Aarhus, Denmark

1MoSeL is joint work with Jacques-Henri Jourdan, Ralf Jung, Joseph Tassarotti, Jan-Oliver Kaiser,

Amin Timany, Arthur Chargu´ eraud, and Derek Dreyer

slide-2
SLIDE 2

2

Separation logic [O’Hearn, Reynolds, and Yang, 2001]

Propositions P, Q denote ownership of resources Separating conjunction P ∗ Q: The resources consists of separate parts satisfying P and Q Basic example: {x → v1 ∗ y → v2}swap(x, y){x → v2 ∗ y → v1} the ∗ ensures that x and y are different memory locations

slide-3
SLIDE 3

3

Why is separation logic useful?

Separation logic is very useful: ◮ It provides a high level of modularity ◮ It scales to fancy PL features like concurrency Just in Coq, there is an ever growing collection of separation logics: ◮ Bedrock ◮ CFML ◮ Charge! ◮ CHL ◮ FCSL ◮ Iris ◮ VST ◮ . . .

* ⊣⊢

slide-4
SLIDE 4

4

The challenge

When developing a new separation logic in a proof assistant, one has to:

  • 1. Prove soundness
  • 2. Develop tactics to carry out proofs
slide-5
SLIDE 5

4

The challenge

When developing a new separation logic in a proof assistant, one has to:

  • 1. Prove soundness
  • 2. Develop tactics to carry out proofs

These steps are tedious, can we simplify them?

slide-6
SLIDE 6

5

In prior work, we proposed solutions for both problems:

  • 1. Proving soundness: Iris [POPL’15, ICFP’16, ESOP’17, JFP’18]
  • 2. Tactics: Iris Proof Mode [POPL’17]
slide-7
SLIDE 7

6

Iris [POPL’15, ICFP’16, ESOP’17, JFP’18]

A general, language-independent, framework for modeling your own domain specific higher-order separation logics

slide-8
SLIDE 8

6

Iris [POPL’15, ICFP’16, ESOP’17, JFP’18]

A general, language-independent, framework for modeling your own domain specific higher-order separation logics ◮ General: unifies the reasoning principles in many other logics

slide-9
SLIDE 9

6

Iris [POPL’15, ICFP’16, ESOP’17, JFP’18]

A general, language-independent, framework for modeling your own domain specific higher-order separation logics ◮ General: unifies the reasoning principles in many other logics ◮ Language-independent: parameterized by the language

slide-10
SLIDE 10

6

Iris [POPL’15, ICFP’16, ESOP’17, JFP’18]

A general, language-independent, framework for modeling your own domain specific higher-order separation logics ◮ General: unifies the reasoning principles in many other logics ◮ Language-independent: parameterized by the language ◮ Modeling logics: can be used to model domain specific logics

◮ iGPS for weak memory [ECOOP’17] ◮ RustBelt’s lifetime logic [POPL’18] ◮ ReLoC for program refinements [LICS’18] ◮ Iron for resource management [manuscript]

slide-11
SLIDE 11

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

slide-12
SLIDE 12

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

Lemma in the Iris logic

slide-13
SLIDE 13

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) "H1" : P "H2" : Ψ x "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q ∗ (∃ a : A, P ∗ Ψ a)

slide-14
SLIDE 14

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) "H1" : P "H2" : Ψ x "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q ∗ (∃ a : A, P ∗ Ψ a)

∗ means: resources should be split

slide-15
SLIDE 15

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) "H1" : P "H2" : Ψ x "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q ∗ (∃ a : A, P ∗ Ψ a)

∗ means: resources should be split The hypotheses for the left conjunct

slide-16
SLIDE 16

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

2 subgoals A : Type P, Q : iProp Ψ : A → iProp x : A (1/2) "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q (2/2) "H1" : P "H2" : Ψ x − − − − − − − − − − − − − − − − − − − − − −∗ ∃ a : A, P ∗ Ψ a

The hypotheses for the left conjunct

slide-17
SLIDE 17

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

slide-18
SLIDE 18

7

Iris Proof Mode [Krebbers et al.,POPL’17]: Coq tactics for Iris

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". by iFrame. Qed.

No more subgoals.

We can also solve this lemma automatically

slide-19
SLIDE 19

8

The good things about Iris Proof Mode

It enabled mechanized proofs in many papers because: ◮ Proofs have the look and feel of ordinary Coq proofs For many Coq tactics tac, it has a variant iTac

slide-20
SLIDE 20

8

The good things about Iris Proof Mode

It enabled mechanized proofs in many papers because: ◮ Proofs have the look and feel of ordinary Coq proofs For many Coq tactics tac, it has a variant iTac ◮ Support for advanced features of separation logic Higher-order quantification, invariants, ghost state, later ⊲ modality, . . .

slide-21
SLIDE 21

8

The good things about Iris Proof Mode

It enabled mechanized proofs in many papers because: ◮ Proofs have the look and feel of ordinary Coq proofs For many Coq tactics tac, it has a variant iTac ◮ Support for advanced features of separation logic Higher-order quantification, invariants, ghost state, later ⊲ modality, . . . ◮ Integration with tactics for proving programs Symbolic execution tactics for weakest preconditions

slide-22
SLIDE 22

8

The good things about Iris Proof Mode

It enabled mechanized proofs in many papers because: ◮ Proofs have the look and feel of ordinary Coq proofs For many Coq tactics tac, it has a variant iTac ◮ Support for advanced features of separation logic Higher-order quantification, invariants, ghost state, later ⊲ modality, . . . ◮ Integration with tactics for proving programs Symbolic execution tactics for weakest preconditions ◮ Usable in practice Used for any project involving Iris today

slide-23
SLIDE 23

9

The bad thing about Iris Proof Mode

The implementation is tied to Iris

Iris Proof Mode

slide-24
SLIDE 24

10

Making Iris Proof Mode independent of Iris It sounds easy [Krebbers et al., POPL’17]:

[. . . ] we believe that our proof mode is very generic, and can be applied to a variety of different embedded logics [. . . ]

slide-25
SLIDE 25

10

Making Iris Proof Mode independent of Iris It sounds easy [Krebbers et al., POPL’17]:

[. . . ] we believe that our proof mode is very generic, and can be applied to a variety of different embedded logics [. . . ]

But doing it generally will be be more challenging

slide-26
SLIDE 26

11

Problem #1: Iris propositions are affine

In Iris you may “forget” about resources:

{ℓ1 → v1 ∗ ℓ2 → v2} ℓ2 := ! ℓ1 {ℓ2 → v1}

slide-27
SLIDE 27

11

Problem #1: Iris propositions are affine

In Iris you may “forget” about resources:

{ℓ1 → v1 ∗ ℓ2 → v2} ℓ2 := ! ℓ1 {ℓ2 → v1}

Due to the affinity axiom P ∗ Q ⊢ Q, which is hard-wired into many tactics:

iClear

Π Q Π, P Q

iAssumption

Π, P P

slide-28
SLIDE 28

11

Problem #1: Iris propositions are affine

In Iris you may “forget” about resources:

{ℓ1 → v1 ∗ ℓ2 → v2} ℓ2 := ! ℓ1 {ℓ2 → v1}

Due to the affinity axiom P ∗ Q ⊢ Q, which is hard-wired into many tactics:

iClear

Π Q Π, P Q

iAssumption

Π, P P Not having the affinity axiom is useful: precise accounting of resources (recall Aleˇ s’s talk) Challenge: How to disentangle the affinity axiom from the Iris tactics?

slide-29
SLIDE 29

12

Problem #2: No tactical support for derived logics

Coq (Prop) Iris (iProp)

propositions defined in terms of

Proof using standard Coq tactics Proof using Iris tactics

slide-30
SLIDE 30

12

Problem #2: No tactical support for derived logics

Coq (Prop) Iris (iProp) Derived logic (e.g. iGpsProp)

propositions defined in terms of propositions defined in terms of, iGpsProp View mon − − − → iProp

Proof using standard Coq tactics Proof using Iris tactics

slide-31
SLIDE 31

12

Problem #2: No tactical support for derived logics

Coq (Prop) Iris (iProp) Derived logic (e.g. iGpsProp)

propositions defined in terms of propositions defined in terms of, iGpsProp View mon − − − → iProp

Proof using standard Coq tactics Proof using Iris tactics Proof using ???

slide-32
SLIDE 32

12

Problem #2: No tactical support for derived logics

Coq (Prop) Iris (iProp) Derived logic (e.g. iGpsProp)

propositions defined in terms of propositions defined in terms of, iGpsProp View mon − − − → iProp

Proof using standard Coq tactics Proof using Iris tactics Proof using ??? Challenge: How to reason in logics defined in terms of another

slide-33
SLIDE 33
slide-34
SLIDE 34

14

Contributions MoSeL: A General, Extensible Modal Framework for Interactive Proofs in Separation Logic in Coq

[Krebbers et al.,ICFP’18]

Contributions: ◮ MoSeL is parameterized by a general abstraction of separation logic ◮ MoSeL supports general and affine separation logics, and combinations thereof ◮ MoSeL supports reasoning in derived separation logics ◮ MoSeL can be fine-tuned for each logic using type classes

2Not in the ICFP’18 paper

slide-35
SLIDE 35

14

Contributions MoSeL: A General, Extensible Modal Framework for Interactive Proofs in Separation Logic in Coq

[Krebbers et al.,ICFP’18]

Contributions: ◮ MoSeL is parameterized by a general abstraction of separation logic ◮ MoSeL supports general and affine separation logics, and combinations thereof ◮ MoSeL supports reasoning in derived separation logics ◮ MoSeL can be fine-tuned for each logic using type classes MoSeL is usable in practice: we used it on 6 very different existing separation logics CFML CHL Fairis iGPS Iris Iron2

2Not in the ICFP’18 paper

slide-36
SLIDE 36

15

Implementation of tactics in IPM/MoSeL

slide-37
SLIDE 37

16

Separation logic entailments in Coq

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

slide-38
SLIDE 38

16

Separation logic entailments in Coq

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3".

  • iAssumption.
  • iExists x.

iFrame. Qed.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) "H1" : P "H2" : Ψ x "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q ∗ (∃ a : A, P ∗ Ψ a)

slide-39
SLIDE 39

16

Separation logic entailments in Coq

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". Set Printing All.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) "H1" : P "H2" : Ψ x "H3" : Q − − − − − − − − − − − − − − − − − − − − − −∗ Q ∗ (∃ a : A, P ∗ Ψ a)

Notation for deeply embedded context

slide-40
SLIDE 40

16

Separation logic entailments in Coq

Lemma test {A} (P Q : iProp) (Ψ : A → iProp) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". Set Printing All.

1 subgoal A : Type P, Q : iProp Ψ : A → iProp x : A (1/1) envs entails (Envs Enil (Esnoc (Esnoc (Esnoc Enil (String (Ascii false false false true false false true false) (String (Ascii true false false false true true false false) EmptyString)) P) . . .

slide-41
SLIDE 41

17

How to embed separation logic entailments into Coq?

Visible goal (with pretty printing):

  • x :

φ Variables and pure Coq hypotheses Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

slide-42
SLIDE 42

17

How to embed separation logic entailments into Coq?

Visible goal (with pretty printing):

  • x :

φ Variables and pure Coq hypotheses Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing):

  • x :

φ Π Q

Where: Π Q ∗Π ⊢ Q

slide-43
SLIDE 43

18

Implementation of the iSplitL/iSplitR tactic

Tactics implemented by reflection as mere lemmas:

Lemma tac sep split Π Π1 Π2 lr js Q1 Q2 : envs split lr js Π = Some (Π1,Π2) → (Π1 ⊢ Q1 ) → (Π2 ⊢ Q2 ) → Π ⊢ Q1 ∗ Q2 .

Π1 Q1 Π2 Q2 Π1, Π2 Q1 ∗ Q2

slide-44
SLIDE 44

18

Implementation of the iSplitL/iSplitR tactic

Tactics implemented by reflection as mere lemmas:

Lemma tac sep split Π Π1 Π2 lr js Q1 Q2 : envs split lr js Π = Some (Π1,Π2) → (Π1 ⊢ Q1 ) → (Π2 ⊢ Q2 ) → Π ⊢ Q1 ∗ Q2 .

Π1 Q1 Π2 Q2 Π1, Π2 Q1 ∗ Q2 Context splitting implemented as a computable Coq function

slide-45
SLIDE 45

18

Implementation of the iSplitL/iSplitR tactic

Tactics implemented by reflection as mere lemmas:

Lemma tac sep split Π Π1 Π2 lr js Q1 Q2 : envs split lr js Π = Some (Π1,Π2) → (Π1 ⊢ Q1 ) → (Π2 ⊢ Q2 ) → Π ⊢ Q1 ∗ Q2 .

Π1 Q1 Π2 Q2 Π1, Π2 Q1 ∗ Q2 Context splitting implemented as a computable Coq function Ltac wrappers around the reflective tactic:

Tactic Notation "iSplitL" constr(Hs) := let Hs := words Hs in let Hs := eval vm compute in (INamed <$ > Hs) in eapply tac sep split with Left Hs ; [pm reflexivity | | fail "iSplitL: hypotheses" Hs "not found" | (* goal 1 *) | (* goal 2 *) ] .

slide-46
SLIDE 46

18

Implementation of the iSplitL/iSplitR tactic

Tactics implemented by reflection as mere lemmas:

Lemma tac sep split Π Π1 Π2 lr js Q1 Q2 : envs split lr js Π = Some (Π1,Π2) → (Π1 ⊢ Q1 ) → (Π2 ⊢ Q2 ) → Π ⊢ Q1 ∗ Q2 .

Π1 Q1 Π2 Q2 Π1, Π2 Q1 ∗ Q2 Context splitting implemented as a computable Coq function Ltac wrappers around the reflective tactic:

Tactic Notation "iSplitL" constr(Hs) := let Hs := words Hs in let Hs := eval vm compute in (INamed <$ > Hs) in eapply tac sep split with Left Hs ; [pm reflexivity | | fail "iSplitL: hypotheses" Hs "not found" | (* goal 1 *) | (* goal 2 *) ] .

Report sensible error to the user

slide-47
SLIDE 47

19

Making MoSeL separation logic independent

Instance of a separation logic abstraction Type class instances to fine tune tactics MoSeL’s tactics

slide-48
SLIDE 48

19

Making MoSeL separation logic independent

Instance of a separation logic abstraction Type class instances to fine tune tactics MoSeL’s tactics

slide-49
SLIDE 49

20

How to abstract over separation logics?

slide-50
SLIDE 50

21

BI logics: An abstract interface for separation logics

A Bunched Implications (BI) logic [O’Hearn&Pym,99] is a preorder (Prop, ⊢) with: ◮ Operations True, False, ∧, ∨, ⇒, ∀, ∃ satisfying the axioms of intuitionistic logic ◮ Operations emp, ∗, − ∗ satisfying: emp ∗ P ⊣⊢ P P ∗ Q ⊢ Q ∗ P (P ∗ Q) ∗ R ⊢ P ∗ (Q ∗ R) P1 ⊢ Q1 P2 ⊢ Q2 P1 ∗ P2 ⊢ Q1 ∗ Q2 P ∗ Q ⊢ R P ⊢ Q − ∗ R

slide-51
SLIDE 51

21

BI logics: An abstract interface for separation logics

A Bunched Implications (BI) logic [O’Hearn&Pym,99] is a preorder (Prop, ⊢) with: ◮ Operations True, False, ∧, ∨, ⇒, ∀, ∃ satisfying the axioms of intuitionistic logic ◮ Operations emp, ∗, − ∗ satisfying: emp ∗ P ⊣⊢ P P ∗ Q ⊢ Q ∗ P (P ∗ Q) ∗ R ⊢ P ∗ (Q ∗ R) P1 ⊢ Q1 P2 ⊢ Q2 P1 ∗ P2 ⊢ Q1 ∗ Q2 P ∗ Q ⊢ R P ⊢ Q − ∗ R

Structure bi := Bi { bi car :> Type; bi entails : bi car → bi car → Prop; bi forall : ∀ A, (A → bi car) → bi car; bi sep : bi car → bi car → bi car; (* other separation logic operators and axioms *) }.

slide-52
SLIDE 52

22

Proofs in MoSeL

Proofs in a specific logic:

Lemma test {A} (P Q : iGpsProp) (Ψ: A → iGpsProp) : P ∗ (∃ a,Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

Proofs for all logics:

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ: A → PROP) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

slide-53
SLIDE 53

22

Proofs in MoSeL

Proofs in a specific logic:

Lemma test {A} (P Q : iGpsProp) (Ψ: A → iGpsProp) : P ∗ (∃ a,Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

Proofs for all logics:

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ: A → PROP) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

Lemma for another logic than Iris

slide-54
SLIDE 54

22

Proofs in MoSeL

Proofs in a specific logic:

Lemma test {A} (P Q : iGpsProp) (Ψ: A → iGpsProp) : P ∗ (∃ a,Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

Proofs for all logics:

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ: A → PROP) : P ∗ (∃ a, Ψ a) ∗ Q −∗ Q ∗ ∃ a, P ∗ Ψ a. Proof. iIntros "[H1 [H2 H3]]". iDestruct "H2" as (x) "H2". iSplitL "H3". − iAssumption. − iExists x. iFrame. Qed.

Lemma for another logic than Iris Lemma universally quantified in the BI logic

slide-55
SLIDE 55

23

Addressing challenge #1: Disentangling the affinity axiom

P ∗ Q ⊢ Q

slide-56
SLIDE 56

24

A poor man’s solution

Make two versions of the tactics

  • 1. For affine logics (like Iris and iGPS)
  • 2. For non-affine logics (like CFML and CHL)
slide-57
SLIDE 57

24

A poor man’s solution

Make two versions of the tactics

  • 1. For affine logics (like Iris and iGPS)
  • 2. For non-affine logics (like CFML and CHL)

Problems: ◮ Duplicate work/maintenance ◮ Some logics mix affine and non-affine propositions, for example: GC locations (affine) Non-GC locations (not affine) ℓ →gc v ℓ → v (Another example in [Tassarotti et al., ESOP’17])

slide-58
SLIDE 58

25

Key idea ◮ Don’t: classify whether the whole logic is affine ◮ Do: classify whether individual propositions are affine

slide-59
SLIDE 59

26

Classifying whether propositions are affine

Affine propositions: affine(P) P ⊢ emp (propositions that can be “thrown away”) The new tactics:

iClear

Π Q affine(P) Π, P Q

iAssumption

affine(Π) Π, Q Q

slide-60
SLIDE 60

27

Classifying whether propositions are affine in Coq

A new type class:

Class Affine {PROP : bi} (Q : PROP) := affine : Q ⊢ emp.

Instances: ◮ Tell MoSeL that specific connectives are affine:

Instance mapsto gc affine l v : Affine (l →gc v).

◮ Capture that affine propositions are closed under most connectives:

Instance sep affine {PROP : bi} (P Q : bi) : Affine P → Affine Q → Affine (P ∗ Q).

slide-61
SLIDE 61

28

MoSeL: A General, Extensible Modal Framework for Interactive Proofs in Separation Logic in Coq

What about modalities?

slide-62
SLIDE 62

29

The affine modality

The affine modality: affine P

  • P ∧ emp

≈ “P holds using just affine resources” This modality is useful for reasoning about affinity

slide-63
SLIDE 63

29

The affine modality

The affine modality: affine P

  • P ∧ emp

≈ “P holds using just affine resources” This modality is useful for reasoning about affinity ◮ Can be used to turn any proposition into an affine version, e.g. A wand that can be dropped affine (P − ∗ Q)

slide-64
SLIDE 64

29

The affine modality

The affine modality: affine P

  • P ∧ emp

≈ “P holds using just affine resources” This modality is useful for reasoning about affinity ◮ Can be used to turn any proposition into an affine version, e.g. A wand that can be dropped affine (P − ∗ Q) ◮ Commutes with most operators, e.g. affine (P ∨ Q) ⊣⊢ affine P ∨ affine Q

slide-65
SLIDE 65

29

The affine modality

The affine modality: affine P

  • P ∧ emp

≈ “P holds using just affine resources” This modality is useful for reasoning about affinity ◮ Can be used to turn any proposition into an affine version, e.g. A wand that can be dropped affine (P − ∗ Q) ◮ Commutes with most operators, e.g. affine (P ∨ Q) ⊣⊢ affine P ∨ affine Q ◮ Gives rise to an alternative classification of affine propositions affine(P) iff P ⊢ affine P

slide-66
SLIDE 66

30

The idea of carving out classes of propositions and defining their corresponding modalities is widely applicable:

◮ Persistent propositions

  • ◮ Intuitionistic propositions
  • ◮ Absorbing propositions

absorb ◮ Timeless propositions (in step-indexed logics) ⊲, ⋄ ◮ Objective propositions (in iGPS)

  • bj , subj

◮ Normal propositions (in CFML) normal ◮ . . .

The paper shows how to modularly deal with such classes and use them in general tactics

slide-67
SLIDE 67

30

The idea of carving out classes of propositions and defining their corresponding modalities is widely applicable:

◮ Persistent propositions

  • ◮ Intuitionistic propositions
  • ◮ Absorbing propositions

absorb ◮ Timeless propositions (in step-indexed logics) ⊲, ⋄ ◮ Objective propositions (in iGPS)

  • bj , subj

◮ Normal propositions (in CFML) normal ◮ . . .

The paper shows how to modularly deal with such classes and use them in general tactics, we discuss two

slide-68
SLIDE 68

31

Persistent and intuitionistic propositions

Not droppable Droppable Not duplicable Any Affine Duplicable Persistent Intuitionistic = (affine & persistent)

slide-69
SLIDE 69

31

Persistent and intuitionistic propositions

Not droppable Droppable Not duplicable Any Affine Duplicable Persistent Intuitionistic = (affine & persistent) Intuitionistic propositions: ◮ Widely used in practice, e.g. for reasoning about persistent (and garbage collected) data structures ◮ MoSeL has special support for them

slide-70
SLIDE 70

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

slide-71
SLIDE 71

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

Intuitionistic modality

slide-72
SLIDE 72

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

1 subgoal PROP : bi A : Type P, Q : PROP Ψ : A → PROP (1/1) "H2" : ∃ a : A, Ψ a − − − − − − − − − − − − − − − − − − − − − − "H1" : P − − − − − − − − − − − − − − − − − − − − − −∗ ∃ a : A, Ψ a ∗ (P ∗ Ψ a)

Moves hypothesis to intuitionistic context

slide-73
SLIDE 73

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

1 subgoal PROP : bi A : Type P, Q : PROP Ψ : A → PROP x : A (1/1) "H2" : Ψ x − − − − − − − − − − − − − − − − − − − − − − "H1" : P − − − − − − − − − − − − − − − − − − − − − −∗ ∃ a : A, Ψ a ∗ (P ∗ Ψ a)

slide-74
SLIDE 74

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

1 subgoal PROP : bi A : Type P, Q : PROP Ψ : A → PROP x : A (1/1) "H2" : Ψ x − − − − − − − − − − − − − − − − − − − − − − "H1" : P − − − − − − − − − − − − − − − − − − − − − −∗ Ψ x ∗ (P ∗ Ψ x)

Do not need to split intuitionistic context

slide-75
SLIDE 75

32

Intuitionistic propositions in MoSeL

Lemma test {PROP : bi} {A} (P Q : PROP) (Ψ : A → PROP) : P ∗ (∃ a, Ψ a) −∗ ∃ a, Ψ a ∗ (P ∗ Ψ a) . Proof. iIntros "[H1 #H2]". iDestruct "H2" as (x) "H2". iExists x. iSplitL "H2". − iAssumption. − by iFrame. Qed.

2 subgoals PROP : bi A : Type P, Q : PROP Ψ : A → PROP x : A (1/2) "H2" : Ψ x − − − − − − − − − − − − − − − − − − − − − − Ψ x (2/2) "H2" : Ψ x − − − − − − − − − − − − − − − − − − − − − − "H1" : P − − − − − − − − − − − − − − − − − − − − − −∗ P ∗ Ψ x

slide-76
SLIDE 76

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

slide-77
SLIDE 77

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing): Γ; Π Q

  • Γ

∗Π

  • ⊢ Q
slide-78
SLIDE 78

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing): Γ; Π Q

  • Γ

∗Π

  • ⊢ Q

Properties of the intuitionistic context Γ: ◮ Hypotheses can be duplicated (by tactics like iSplitL)

slide-79
SLIDE 79

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing): Γ; Π Q

  • Γ

∗Π

  • ⊢ Q

Properties of the intuitionistic context Γ: ◮ Hypotheses can be duplicated (by tactics like iSplitL) ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption)

slide-80
SLIDE 80

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing): Γ; Π Q

  • Γ

∗Π

  • ⊢ Q

Properties of the intuitionistic context Γ: ◮ Hypotheses can be duplicated (by tactics like iSplitL) ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) ◮ Hypotheses can be moved to the spatial context Π (by tactics like iAssumption)

slide-81
SLIDE 81

33

Formal treatment of the intuitionistic context

Visible Coq goal (with pretty printing):

Γ Intuitionistic separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − Π Spatial separation logic hypotheses − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − −∗ R Separation logic goal

Actual Coq goal (without pretty printing): Γ; Π Q

  • Γ

∗Π

  • ⊢ Q

Properties of the intuitionistic context Γ: ◮ Hypotheses can be duplicated (by tactics like iSplitL) ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) ◮ Hypotheses can be moved to the spatial context Π (by tactics like iAssumption) ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . .

slide-82
SLIDE 82

34

Where does the modality come from?

slide-83
SLIDE 83

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . .

slide-84
SLIDE 84

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) P ⊣⊢ P ∗ P ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . .

slide-85
SLIDE 85

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) P ⊣⊢ P ∗ P ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) P ⊢ emp ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . .

slide-86
SLIDE 86

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) P ⊣⊢ P ∗ P ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) P ⊢ emp ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) P ⊢ P ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . .

slide-87
SLIDE 87

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) P ⊣⊢ P ∗ P ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) P ⊢ emp ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) P ⊢ P ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . . (∃x. P) ⊢ (∃x. P) and (∀x. P) ⊢ (∀x. P)

slide-88
SLIDE 88

35

The properties of that are needed

◮ Hypotheses can be duplicated (by tactics like iSplitL) P ⊣⊢ P ∗ P ◮ Hypotheses can be dropped (by tactics like iClear and iAssumption) P ⊢ emp ◮ Hypotheses can be moved to the spatial context (by tactics like iAssumption) P ⊢ P ◮ Closed under elimination of ∨, ∧, ∃, ∀, . . . (∃x. P) ⊢ (∃x. P) and (∀x. P) ⊢ (∀x. P) Problem: The modality cannot be defined in terms of just the BI connectives for some logics (e.g. Iris) [Bizjak&Birkedal,MFPS’17]

slide-89
SLIDE 89

36

We will extend BI logics with a new modality

slide-90
SLIDE 90

37

Persistent and intuitionistic propositions

Recall: Not droppable Droppable Not duplicable Any Affine affine Duplicable Persistent

  • Intuitionistic = (affine & persistent)
slide-91
SLIDE 91

37

Persistent and intuitionistic propositions

Recall: Not droppable Droppable Not duplicable Any Affine affine Duplicable Persistent

  • Intuitionistic = (affine & persistent)
  • The intuitionistic modality

◮ Widely used in practice ◮ We do not know how to axiomatize it using a small set of axioms

slide-92
SLIDE 92

37

Persistent and intuitionistic propositions

Recall: Not droppable Droppable Not duplicable Any Affine affine Duplicable Persistent

  • Intuitionistic = (affine & persistent)
  • The intuitionistic modality

◮ Widely used in practice ◮ We do not know how to axiomatize it using a small set of axioms The persistent modality ◮ Can be axiomatized using a small set of axioms ◮ Can be used to define the modality and derive its laws

slide-93
SLIDE 93

38

MoBIs: BIs with a persistence modality

The persistence modality: P

  • “P holds without ownership of non-exclusive resources”

MoBI BI + + additional axioms

slide-94
SLIDE 94

38

MoBIs: BIs with a persistence modality

The persistence modality: P

  • “P holds without ownership of non-exclusive resources”

MoBI BI + + additional axioms ◮ We can now define: persistent(P) P ⊢ P intuitionistic(P) P ⊢ P P affine ( P)

slide-95
SLIDE 95

38

MoBIs: BIs with a persistence modality

The persistence modality: P

  • “P holds without ownership of non-exclusive resources”

MoBI BI + + additional axioms ◮ We can now define: persistent(P) P ⊢ P intuitionistic(P) P ⊢ P P affine ( P) ◮ The axioms are generalized from Iris’s to general (non-affine) BI P ⊢ Q P ⊢ Q P ⊢ ( P) emp ⊢ emp (∀x. P) ⊢ (∀x. P) (∃x. P) ⊢ (∃x. P) ( P)∗Q ⊢ P

slide-96
SLIDE 96

39

What’s more in the MoSeL paper [Krebbers et al.,ICFP’18]?

◮ Instantiations of MoSeL using 5 very different existing logics Iris, Fairis, iGPS, CFML, and CHL ◮ An Instantiation of MoSeL using a new logic Based on ordered resource algebras—a general model for MoBIs ◮ Semi-automated tactics using MoSeL for CFML and CHL For example, to support read-only permissions in CFML

slide-97
SLIDE 97
slide-98
SLIDE 98

41

Thank you!

Download MoSeL at http://iris-project.org/

  • Advertisement. I am currently looking for:

◮ A PhD student (4 years) ◮ A post-doc (1 year) Topics: Separation logics for multilingual programs, asynchronous I/O, non-functional properties, verified compilation, . . . Interested/Know someone? Get in touch!

*