Library liblayers.logic.Language
Language definitions
Require Export liblayers.logic.Modules.
Require Export liblayers.logic.Layers.
Require Export liblayers.logic.Semantics.
Layer logic
Class LayerLogicOps {layerdata simrel} ident F primsem V module layer
`{sem_ops: SemanticsOps layerdata ident F primsem V module layer} :=
{
ll_vdash {D1 D2} :> Vdash2 (layer D1) (simrel D2 D1) module (layer D2)
}.
Class LayerLogic {layerdata simrel} ident F primsem V module layer
`{ll_ops: LayerLogicOps layerdata simrel ident F primsem V module layer}
`{rg_ops: !CategoryOps layerdata simrel}
`{primsem_sim: !Sim simrel primsem}
`{layer_sim: !Sim simrel layer} :=
{
empty_rule D (L: layer D):
L ⊢ (id, ∅) : L;
var_rule D (L: layer D) i τ:
L ⊢ (id, i ↦ τ) : i ↦ τ;
vcomp_rule D1 D2 D3 (R: simrel D2 D1) (S: simrel D3 D2) L1 L2 L3 M N:
layer_wf L1 →
L1 ⊢ (R, M) : L2 →
L2 ⊢ (S, N) : L3 →
L1 ⊢ (R ∘ S, M ⊕ N) : L3;
hcomp_rule D D' (R: simrel D' D) L M1 M2 (L1 L2: layer D'):
layer_wf L →
L ⊢ (R, M1) : L1 →
L ⊢ (R, M2) : L2 →
L ⊢ (R, M1 ⊕ M2) : L1 ⊕ L2;
conseq_rule {D1 D2 D3 D4} R21 R32 R43 L1 L2 L3 L4 M:
layer_wf L1 →
simRR D2 D1 R21 L2 L1 →
simRR D4 D3 R43 L4 L3 →
L2 ⊢ (R32, M) : L3 →
L1 ⊢ (R21 ∘ R32 ∘ R43, M) : L4;
vdash_module_le D1 D2 (R: simrel D2 D1) L1 L2 M N:
layer_wf L1 →
M ≤ N →
L1 ⊢ (R, M) : L2 →
L1 ⊢ (R, N) : L2;
vdash_rel_equiv D1 D2 (R S: simrel D2 D1) L1 L2 M:
R ≡ S →
L1 ⊢ (R, M) : L2 →
L1 ⊢ (S, M) : L2
}.
Section DERIVED_RULES.
Context `{Hll: LayerLogic}.
Context `{Hld: !Category layerdata simrel}.
Context `{Hmodule: !Modules ident F V module}.
Context `{Hlayer: !Layers ident primsem V layer}.
Context `{fsem_ops: !FunctionSemanticsOps ident F primsem V module layer}.
Context `{Hsem: !Semantics ident F primsem V module layer}.
The following specialized versions of the consequence rule are
easier to apply depending on situation, since you don't have to
rewrite the relation involved to account for identities.
Lemma conseq_le_sim {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4:
layer_wf L1 →
L2 ⊢ (id, M) : L3 →
L2 ≤ L1 →
sim R L4 L3 →
L1 ⊢ (R, M) : L4.
Proof.
intros HL1 HM HL21 HL43.
eapply (vdash_rel_equiv _ _ (id ∘ id ∘ R)).
- rewrite cat_compose_id_left.
rewrite cat_compose_id_left.
reflexivity.
- eapply conseq_rule; eassumption.
Qed.
Lemma conseq_sim_le {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4:
layer_wf L1 →
L2 ⊢ (id, M) : L3 →
sim R L2 L1 →
L4 ≤ L3 →
L1 ⊢ (R, M) : L4.
Proof.
intros HL1 HM HL21 HL43.
eapply (vdash_rel_equiv _ _ (R ∘ id ∘ id)).
- rewrite cat_compose_id_right.
rewrite cat_compose_id_right.
reflexivity.
- eapply conseq_rule; eassumption.
Qed.
Lemma conseq_le_le {D1 D2} (R: simrel D2 D1) M L1 L2 L3 L4:
layer_wf L1 →
L2 ⊢ (R, M) : L3 →
L2 ≤ L1 →
L4 ≤ L3 →
L1 ⊢ (R, M) : L4.
Proof.
intros HL1 HM HL21 HL43.
eapply (vdash_rel_equiv _ _ (id ∘ R ∘ id)).
- rewrite cat_compose_id_right.
rewrite cat_compose_id_left.
reflexivity.
- eapply conseq_rule; eassumption.
Qed.
Lemma conseq_le_left {D1 D2} (R: simrel D1 D2) M L1 L1' L2:
layer_wf L1' →
L1 ⊢ (R, M) : L2 →
L1 ≤ L1' →
L1' ⊢ (R, M) : L2.
Proof.
intros HL1' HM HL1.
eapply conseq_le_le; eauto.
reflexivity.
Qed.
Lemma conseq_le_right {D1 D2} (R: simrel D1 D2) M L1 L2 L2':
layer_wf L1 →
L1 ⊢ (R, M) : L2 →
L2' ≤ L2 →
L1 ⊢ (R, M) : L2'.
Proof.
intros HL1 HM HL2.
eapply conseq_le_le; eauto.
reflexivity.
Qed.
The frame rule can be proved from horizontal composition and
some consequence rules.
Not sure how to fit layers_disjoint in though <
Lemma frame_rule D D' (R: simrel D' D) L1 L2 M1 M2 L1' L2':
L1 ⊢ (R, M1) : L1' ->
L2 ⊢ (R, M2) : L2' ->
L1 ⊕ L2 ⊢ (R, M1 ⊕ M2) : L1' ⊕ L2'.
Proof.
intros H1 H2.
apply hcomp_rule.
* eapply conseq_le_left; try eassumption.
apply left_upper_bound.
* eapply conseq_le_left; try eassumption.
apply right_upper_bound.
Qed.
>