derived_connectives.v 4.57 KB
Newer Older
1
2
3
4
5
From iris.bi Require Export interface.
From iris.algebra Require Import monoid.

Definition bi_iff {PROP : bi} (P Q : PROP) : PROP := ((P  Q)  (Q  P))%I.
Arguments bi_iff {_} _%I _%I : simpl never.
6
Instance: Params (@bi_iff) 1 := {}.
7
8
9
10
11
Infix "↔" := bi_iff : bi_scope.

Definition bi_wand_iff {PROP : bi} (P Q : PROP) : PROP :=
  ((P - Q)  (Q - P))%I.
Arguments bi_wand_iff {_} _%I _%I : simpl never.
12
Instance: Params (@bi_wand_iff) 1 := {}.
13
Infix "∗-∗" := bi_wand_iff : bi_scope.
14

15
Class Persistent {PROP : bi} (P : PROP) := persistent : P  <pers> P.
16
17
18
Arguments Persistent {_} _%I : simpl never.
Arguments persistent {_} _%I {_}.
Hint Mode Persistent + ! : typeclass_instances.
19
Instance: Params (@Persistent) 1 := {}.
20
21
22

Definition bi_affinely {PROP : bi} (P : PROP) : PROP := (emp  P)%I.
Arguments bi_affinely {_} _%I : simpl never.
23
Instance: Params (@bi_affinely) 1 := {}.
24
Typeclasses Opaque bi_affinely.
25
Notation "'<affine>' P" := (bi_affinely P) : bi_scope.
26

27
28
29
30
31
32
Class Affine {PROP : bi} (Q : PROP) := affine : Q  emp.
Arguments Affine {_} _%I : simpl never.
Arguments affine {_} _%I {_}.
Hint Mode Affine + ! : typeclass_instances.

Class BiAffine (PROP : bi) := absorbing_bi (Q : PROP) : Affine Q.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
33
Hint Mode BiAffine ! : typeclass_instances.
34
35
36
Existing Instance absorbing_bi | 0.

Class BiPositive (PROP : bi) :=
37
  bi_positive (P Q : PROP) : <affine> (P  Q)  <affine> P  Q.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
38
Hint Mode BiPositive ! : typeclass_instances.
39
40
41

Definition bi_absorbingly {PROP : bi} (P : PROP) : PROP := (True  P)%I.
Arguments bi_absorbingly {_} _%I : simpl never.
42
Instance: Params (@bi_absorbingly) 1 := {}.
43
Typeclasses Opaque bi_absorbingly.
44
Notation "'<absorb>' P" := (bi_absorbingly P) : bi_scope.
45

46
Class Absorbing {PROP : bi} (P : PROP) := absorbing : <absorb> P  P.
47
48
Arguments Absorbing {_} _%I : simpl never.
Arguments absorbing {_} _%I.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
49
Hint Mode Absorbing + ! : typeclass_instances.
50
51

Definition bi_persistently_if {PROP : bi} (p : bool) (P : PROP) : PROP :=
52
  (if p then <pers> P else P)%I.
53
Arguments bi_persistently_if {_} !_ _%I /.
54
Instance: Params (@bi_persistently_if) 2 := {}.
55
Typeclasses Opaque bi_persistently_if.
56
Notation "'<pers>?' p P" := (bi_persistently_if p P) : bi_scope.
57
58

Definition bi_affinely_if {PROP : bi} (p : bool) (P : PROP) : PROP :=
59
  (if p then <affine> P else P)%I.
60
Arguments bi_affinely_if {_} !_ _%I /.
61
Instance: Params (@bi_affinely_if) 2 := {}.
62
Typeclasses Opaque bi_affinely_if.
63
Notation "'<affine>?' p P" := (bi_affinely_if p P) : bi_scope.
64

65
66
67
68
69
70
71
Definition bi_absorbingly_if {PROP : bi} (p : bool) (P : PROP) : PROP :=
  (if p then <absorb> P else P)%I.
Arguments bi_absorbingly_if {_} !_ _%I /.
Instance: Params (@bi_absorbingly_if) 2 := {}.
Typeclasses Opaque bi_absorbingly_if.
Notation "'<absorb>?' p P" := (bi_absorbingly_if p P) : bi_scope.

72
73
74
Definition bi_intuitionistically {PROP : bi} (P : PROP) : PROP :=
  (<affine> <pers> P)%I.
Arguments bi_intuitionistically {_} _%I : simpl never.
75
Instance: Params (@bi_intuitionistically) 1 := {}.
76
Typeclasses Opaque bi_intuitionistically.
77
Notation "□ P" := (bi_intuitionistically P) : bi_scope.
78
79
80
81

Definition bi_intuitionistically_if {PROP : bi} (p : bool) (P : PROP) : PROP :=
  (if p then  P else P)%I.
Arguments bi_intuitionistically_if {_} !_ _%I /.
82
Instance: Params (@bi_intuitionistically_if) 2 := {}.
83
Typeclasses Opaque bi_intuitionistically_if.
84
Notation "'□?' p P" := (bi_intuitionistically_if p P) : bi_scope.
85

86
87
88
89
90
Fixpoint sbi_laterN {PROP : sbi} (n : nat) (P : PROP) : PROP :=
  match n with
  | O => P
  | S n' =>  sbi_laterN n' P
  end%I.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
91
Arguments sbi_laterN {_} !_%nat_scope _%I.
92
Instance: Params (@sbi_laterN) 2 := {}.
93
94
Notation "▷^ n P" := (sbi_laterN n P) : bi_scope.
Notation "▷? p P" := (sbi_laterN (Nat.b2n p) P) : bi_scope.
95

Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
96
97
Definition sbi_except_0 {PROP : sbi} (P : PROP) : PROP := ( False  P)%I.
Arguments sbi_except_0 {_} _%I : simpl never.
98
Notation "◇ P" := (sbi_except_0 P) : bi_scope.
99
Instance: Params (@sbi_except_0) 1 := {}.
Jacques-Henri Jourdan's avatar
Jacques-Henri Jourdan committed
100
Typeclasses Opaque sbi_except_0.
101
102
103
104
105

Class Timeless {PROP : sbi} (P : PROP) := timeless :  P   P.
Arguments Timeless {_} _%I : simpl never.
Arguments timeless {_} _%I {_}.
Hint Mode Timeless + ! : typeclass_instances.
106
Instance: Params (@Timeless) 1 := {}.
107
108
109
110
111
112
113
114
115
116
117
118

(** An optional precondition [mP] to [Q].
    TODO: We may actually consider generalizing this to a list of preconditions,
    and e.g. also using it for texan triples. *)
Definition bi_wandM {PROP : bi} (mP : option PROP) (Q : PROP) : PROP :=
  match mP with
  | None => Q
  | Some P => (P - Q)%I
  end.
Arguments bi_wandM {_} !_%I _%I /.
Notation "mP -∗? Q" := (bi_wandM mP Q)
  (at level 99, Q at level 200, right associativity) : bi_scope.