forked from logsem/iris-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpure.v
86 lines (72 loc) · 2.18 KB
/
pure.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From iris.base_logic Require Import upred iprop.
From iris.proofmode Require Import proofmode.
Section proofs.
Context {Σ : gFunctors}.
(**
Turnstyle can be used as a unary operator to ask whether a
proposition follows from the empty context. Here we locally specify
that we want to talk about Iris propositions over [Σ].
This is useful when stating lemmas that don't depend on generic Iris
propositions.
*)
Local Notation "⊢ P" := (⊢@{iPropI Σ} P).
(**
Coq propositions can be embedded into Iris using the pure modality
[⌜Φ⌝]. Such propositions can be introduced using [iPureIntro]. This
will exit the Iris proofmode, throwing away the Iris context. Pure
propositions can be eliminated using the introduction pattern "%_".
*)
Lemma eq_5_5 : ⊢ ⌜5 = 5⌝.
Proof.
iPureIntro.
reflexivity.
Qed.
Lemma eq_elm {A} (P : A → iProp Σ) (x y : A) : ⌜x = y⌝ -∗ P x -∗ P y.
Proof.
iIntros "%H HP".
rewrite -H.
iApply "HP".
Qed.
(**
Iris has a class of propositions we call pure.
These are the propositions [P] that are bi-entailed by [⌜Φ⌝] for
some Φ. Iris has two typeclasses, [IntoPure] and [FromPure], to
identify such propositions.
*)
Lemma true_intro : ⊢ True.
Proof.
iPureIntro. (* True is pure*)
constructor.
Qed.
Lemma and_pure : ⊢ ⌜5 = 5⌝ ∧ ⌜8 = 8⌝.
Proof.
iPureIntro. (* And preserves pureness *)
split; reflexivity.
Qed.
Lemma sep_pure : ⊢ ⌜5 = 5⌝ ∗ ⌜8 = 8⌝.
Proof.
iPureIntro. (* Separation preserves pureness *)
split; reflexivity.
Qed.
(**
The pure modality allows us to state an important property,
namely soundness.
Soundness is proved in the [uPred_primitive.pure_soundness] lemma
stating: [∀ φ, (True ⊢ ⌜φ⌝) → φ]
This means that anything proved inside the Iris logic is as true as
anything proved in Coq.
*)
(**
[⌜_⌝] turns Coq propositions into Iris propositions, while [⊢ _] turns
Iris propositions into Coq propositions. These operations are not
inverses, but they are related.
*)
Lemma pure_adj1 (φ : Prop) : φ → ⊢ ⌜φ⌝.
Proof.
(* exercise *)
Admitted.
Lemma pure_adj2 (P : iProp Σ) : ⌜⊢P⌝ -∗ P.
Proof.
(* exercise *)
Admitted.
End proofs.