Library prosa.analysis.facts.model.uniprocessor

This file serves to collect basic facts about uniprocessors.
Consider any type of jobs.
  Context {Job : JobType}.

Assume a processor model with exactly one core.
  Context {PState : ProcessorState Job}.
  Hypothesis H_uni : uniprocessor_model PState.

A uniprocessor has at least one core.
  Lemma uniprocessor_has_positive_core_count :
    0 < #|Core|.
  Proof. by rewrite H_uni. Qed.

All core identifiers refer to the same core.
  Lemma uniprocessor_core_unique :
    ∀ c1 c2 : Core,
      c1 = c2.
  Proof.
    move⇒ c1 c2.
    have /card_le1_eqP UNIQUE : #|Core| ≤ 1 by rewrite H_uni.
    by apply: UNIQUE; rewrite inE.
  Qed.

If two jobs satisfy scheduled_in, then they are equal.
  Lemma uniprocessor_scheduled_in_unique :
    ∀ (j1 j2 : Job) (s : PState),
      scheduled_in j1 s →
      scheduled_in j2 s →
      j1 = j2.
  Proof.
    move⇒ j1 j2 s /existsP[c1 /eqP SCHED1] /existsP[c2 /eqP SCHED2].
    have EQ : c1 = c2 by apply: uniprocessor_core_unique.
    by move: SCHED1; rewrite EQ SCHED2 ⇒ [[]].
  Qed.

Similarly, if two jobs satisfy scheduled_at, then they are equal.
  Lemma uniprocessor_scheduled_at_unique :
    ∀ (j1 j2 : Job) (sched : schedule PState) t,
      scheduled_at sched j1 t →
      scheduled_at sched j2 t →
      j1 = j2.
  Proof. move⇒ j1 j2 sched t; exact: uniprocessor_scheduled_in_unique. Qed.

Next, consider any schedule.
  Variable sched : schedule PState.

Consequently, if one job is scheduled, then every distinct job is not scheduled at the same time.
  Lemma scheduled_job_at_neq :
      ∀ j j' t,
        j != j' →
        scheduled_at sched j t →
        ~~ scheduled_at sched j' t.
  Proof.
    move⇒ j j' t /eqP NEQ SCHED; apply/negP ⇒ SCHED'.
    by have: j = j' by apply: uniprocessor_scheduled_at_unique.
  Qed.

End UniquenessOfTheScheduledJob.

Global Hint Resolve uniprocessor_has_positive_core_count : basic_rt_facts.