Require Import List.
Import ListNotations.
Require Import Relations.
Require Import util.
Require Import specification.
Import SPEC.
Require Import plf.
Require Import PL.
Require Import PLFO.
Require Import PLO.
Refinement proof : PLO.sem o ⊆ SPEC.sem
Simulation relation between PLO state and SPEC states.
Inductive match_states :
PLOstate ->
SPEC.state ->
Prop :=
|
match_states_init :
forall oracle,
match_states (
INIT oracle)
(
STATE Usr MCU.init DEV.init)
|
match_states_usr :
forall oracle mcu dev dev'
chkpt,
forall (
WFINV:
DEV.equiv (
LOG.restore (
CHKPT.next_log chkpt))
dev)
(
EQUIV:
DEV.equiv dev dev'),
match_states (
USR oracle mcu dev chkpt)
(
STATE Usr mcu dev')
|
match_states_drv_fail :
forall oracle dev'
mcu dev l chkpt,
forall (
WFINV:
DEV.equiv (
LOG.restore l)
dev)
(
EQUIV:
DEV.equiv (
LOG.restore (
CHKPT.next_log chkpt))
dev')
(
ORACLE:
match oracle with
| (
false::
_) | [] =>
True
|
_ =>
False
end),
match_states (
DRV oracle mcu dev l chkpt)
(
STATE Usr (
CHKPT.next_mcu chkpt)
dev')
|
match_states_drv_success :
forall oracle mcu dev dev'
l chkpt,
forall (
WFINV:
DEV.equiv (
LOG.restore l)
dev)
(
EQUIV:
DEV.equiv dev dev'),
match_states (
DRV (
true::
oracle)
mcu dev l chkpt)
(
STATE Drv mcu dev')
|
match_states_pwr :
forall oracle chkpt dev,
forall (
WFINV:
DEV.equiv (
LOG.restore (
CHKPT.next_log chkpt))
dev),
match_states (
PWR oracle chkpt)
(
STATE Usr (
CHKPT.next_mcu chkpt)
dev)
|
match_states_off :
forall oracle chkpt dev,
forall (
WFINVLOG:
CHKPT.next_log chkpt =
CHKPT.last_log chkpt)
(
WFINVMCU:
CHKPT.next_mcu chkpt =
CHKPT.last_mcu chkpt)
(
DEV:
DEV.equiv (
LOG.restore (
CHKPT.next_log chkpt))
dev),
match_states (
OFF oracle chkpt)
(
STATE Usr (
CHKPT.next_mcu chkpt)
dev).
Star-simulation diagram between PLO and SPEC.
Lemma match_states_step:
forall s1 t s2,
forall (
STEP:
PLO.step s1 t s2)
as1
(
MATCH:
match_states s1 as1),
(
exists as2,
run SPEC.step as1 t as2 /\
match_states s2 as2).
Proof.
The simulation relation is preserved after any number of steps of
PLO.
Lemma match_states_star :
forall s1 t s2,
run PLO.step s1 t s2 ->
forall as1,
match_states s1 as1 ->
exists as2,
run SPEC.step as1 t as2 /\
match_states s2 as2.
Proof.
induction 1 ;
intros.
-
eapply match_states_step;
eauto.
-
exists as1;
split;
auto.
apply run_refl.
-
eapply IHrun1 in H1.
destruct H1 as [
as2 [
HSTEP HMATCH]].
eapply IHrun2 in HMATCH.
destruct HMATCH as [
as3 [
HSTEP2 HMATCH2]].
exists as3;
split;
eauto.
eapply run_trans;
eauto.
Qed.
Trace inclusion result between PLO and SPEC.
Theorem logging_correctness:
forall o t,
PLO.sem o t ->
SPEC.sem t.
Proof.