From ChargeCore.Logics Require Import ILogic ILEmbed.
Set Implicit Arguments.
Unset Strict Implicit.
Set Maximal Implicit Insertion.
Section BILogic.
Definition BILogicType := Type.
Context {A : BILogicType}.
Context {HILOp: ILogicOps A}.
Class BILogicOps (A : BILogicType) : Type := {
empSP  : A;
sepSP  : A -> A -> A;
wandSP : A -> A -> A
}.
Class BILogic {BILOp: BILogicOps A} : Type := {
bilil :> ILogic A;
sepSPC1 P Q : sepSP P Q |-- sepSP Q P;
sepSPA1 P Q R : sepSP (sepSP P Q) R |-- sepSP P (sepSP Q R);
wandSepSPAdj P Q R : sepSP P Q |-- R <-> P |-- wandSP Q R;
bilsep P Q R : P |-- Q -> sepSP P R |-- sepSP Q R;
empSPR P : sepSP P empSP -|- P
}.
End BILogic.
Arguments BILogic _ {BILOp HILOp} : rename.
Notation "a '**' b"  := (sepSP a b)
(at level 58, right associativity).
Notation "a '-*' b"  := (wandSP a b)
(at level 60, right associativity).
Section CoreInferenceRules.
Context {A T : Type} `{HBIL: BILogic A}.

(* Specifications: *)
Lemma wandSPAdj P Q C (HSep: C ** P |-- Q) : C |-- P -* Q.
Lemma wandSPAdj' P Q C (HSep: P ** C |-- Q) : C |-- P -* Q.
Lemma sepSPAdj P Q C (HWand: C |-- P -* Q) : C ** P |-- Q.
Lemma sepSPAdj' P Q C (HWand: C |-- P -* Q) : P ** C |-- Q.
Lemma sepSPC (P Q : A) : P ** Q -|- Q ** P.
Lemma sepSPA2 (P Q R : A) : P ** (Q ** R) |-- (P ** Q) ** R.
Lemma sepSPA (P Q R : A) : (P ** Q) ** R -|- P ** (Q ** R).
Lemma wandSPI (P Q R : A) (HQ : P ** Q |-- R) : (P |-- Q -* R).
Lemma wandSPE (P Q R S : A) (HQR: Q |-- S -* R) (HP : P |-- Q ** S) : P |-- R.
Lemma empSPL P : empSP ** P -|- P.
Lemma bilexistsscR1 (P : A) (f : T -> A):
Exists x : T, P ** f x |-- P ** lexists f.
Lemma bilexistsscR2 (P : A) (f : T -> A):
Exists x : T, f x ** P |-- lexists f ** P.
Lemma bilexistsscL1 (P : A) (f : T -> A) :
P ** lexists f |-- Exists x : T, P ** f x.
Lemma bilexistsscL2 (P : A) (f : T -> A) :
lexists f ** P |-- Exists x : T, f x ** P.
Lemma bilexistssc (P : A) (Q : T -> A) :
Exists x : T, P ** Q x -|- P ** lexists Q.
Lemma bilforallscR (P : A) (Q : T -> A) :
P ** lforall Q |-- Forall x : T, P ** Q x.
Lemma bilandscDL (P Q R : A) : (P //\\ Q) ** R |-- (P ** R) //\\ (Q ** R).
Lemma bilorscDL (P Q R : A) : (P \\// Q) ** R -|- (P ** R) \\// (Q ** R).
End CoreInferenceRules.