Commit 9e805d0b authored by Björn Brandenburg's avatar Björn Brandenburg

add EDF optimality argument

This patch adds the classic EDF optimality argument: by swapping
allocations, any schedule in which no job misses a deadline can be
transformed into an EDF schedule in which also no job misses a deadline.
parent f1879960
Pipeline #19175 passed with stages
in 6 minutes and 7 seconds
From rt.restructuring.model Require Export schedule.edf.
From rt.restructuring.analysis Require Import schedulability transform.facts.edf_opt.
(** This file contains the theorem that states the famous EDF
optimality result: if there is any way to meet all deadlines
(assuming an ideal uniprocessor), then there is also an EDF
schedule in which all deadlines are met. *)
Section Optimality.
(* For any given type of jobs... *)
Context {Job : JobType} `{JobCost Job} `{JobDeadline Job} `{JobArrival Job}.
(* ... and any valid job arrival sequence. *)
Variable arr_seq: arrival_sequence Job.
Hypothesis H_arr_seq_valid: valid_arrival_sequence arr_seq.
(* We observe that EDF is optimal in the sense that, if there exists
any schedule in which all jobs of arr_seq meet their deadline,
then there also exists an EDF schedule in which all deadlines are
met. *)
Theorem EDF_optimality:
(exists any_sched : schedule (ideal.processor_state Job),
valid_schedule any_sched arr_seq /\
all_deadlines_of_arrivals_met arr_seq any_sched) ->
exists edf_sched : schedule (ideal.processor_state Job),
valid_schedule edf_sched arr_seq /\
all_deadlines_of_arrivals_met arr_seq edf_sched /\
is_EDF_schedule edf_sched.
Proof.
move=> [sched [[COME [ARR COMP]] DL_ARR_MET]].
move: (all_deadlines_met_in_valid_schedule _ _ COME DL_ARR_MET) => DL_MET.
set sched' := edf_transform sched.
exists sched'. split; last split.
- by apply edf_schedule_is_valid.
- by apply edf_schedule_meets_all_deadlines_wrt_arrivals.
- by apply edf_transform_ensures_edf.
Qed.
End Optimality.
(** We further state a weaker notion of the above optimality claim
that avoids a dependency on a given arrival sequence. *)
Section WeakOptimality.
(* For any given type of jobs,... *)
Context {Job : JobType} `{JobCost Job} `{JobDeadline Job} `{JobArrival Job}.
(* ...if we have a well-behaved schedule in which no deadlines are missed,... *)
Variable any_sched: schedule (ideal.processor_state Job).
Hypothesis H_must_arrive: jobs_must_arrive_to_execute any_sched.
Hypothesis H_completed_dont_execute: completed_jobs_dont_execute any_sched.
Hypothesis H_all_deadlines_met: all_deadlines_met any_sched.
(* ...then there also exists a corresponding EDF schedule in which
no deadlines are missed (and in which exactly the same set of
jobs is scheduled, as ensured by the last clause). *)
Theorem weak_EDF_optimality:
exists edf_sched : schedule (ideal.processor_state Job),
jobs_must_arrive_to_execute edf_sched /\
completed_jobs_dont_execute edf_sched /\
all_deadlines_met edf_sched /\
is_EDF_schedule edf_sched /\
forall j,
(exists t, scheduled_at any_sched j t) <->
(exists t', scheduled_at edf_sched j t').
Proof.
set sched' := edf_transform any_sched.
exists sched'. repeat split.
- by apply edf_transform_jobs_must_arrive.
- by apply edf_transform_completed_jobs_dont_execute.
- by apply edf_transform_deadlines_met.
- by apply edf_transform_ensures_edf.
- by move=> [t SCHED_j]; apply edf_transform_job_scheduled' with (t0 := t).
- by move=> [t SCHED_j]; apply edf_transform_job_scheduled with (t0 := t).
Qed.
End WeakOptimality.
From rt.restructuring.analysis.transform Require Export prefix swap.
From rt.util Require Export search_arg.
(** In this file we define the "EDF-ification" of a schedule, the
operation at the core of the EDF optimality proof. *)
Section EDFTransformation.
(* Consider any given type of jobs... *)
Context {Job : JobType} `{JobCost Job} `{JobDeadline Job} `{JobArrival Job}.
(* ... and ideal uniprocessor schedules. *)
Let PState := ideal.processor_state Job.
Let SchedType := schedule (PState).
(* We say that a state s1 "has an earlier or equal deadline" than a
state s2 if the job scheduled in state s1 has has an earlier or
equal deadline than the job scheduled in state s2. This function
is never used on idle states, so the default values are
irrelevant. *)
Definition earlier_deadline (s1 s2: PState) :=
(oapp job_deadline 0 s1) <= (oapp job_deadline 0 s2).
(* We say that a state is relevant (for the purpose of the
transformation) if it is not idle and if the job scheduled in it
has arrived prior to some given reference time. *)
Definition relevant_pstate (reference_time: instant) (s: PState) :=
match s with
| None => false
| Some j' => job_arrival j' <= reference_time
end.
(* Next, we define a central element of the "EDF-ification"
procedure: given a job scheduled at a time t1, find a later time
t2 before the job's deadlineat which a job with an
earlier-or-equal deadline is scheduled. In other words, find a
job that causes the [EDF_at] property to be violated at time
t1. *)
Definition find_swap_candidate (sched: SchedType) (t1: instant) (j: Job) :=
if search_arg sched (relevant_pstate t1) earlier_deadline t1 (job_deadline j) is Some t
then t
else 0.
(* The point-wise EDF-ification procedure: given a schedule and a
time t1, ensure that the schedule satisfies [EDF_at] at time
t1. *)
Definition make_edf_at (sched: SchedType) (t1: instant): SchedType :=
match sched t1 with
| None => sched (* leave idle instants alone *)
| Some j =>
let
t2 := find_swap_candidate sched t1 j
in swapped sched t1 t2
end.
(* To transform a finite prefix of a given reference schedule, apply
[make_edf_at] to every point up to the given finite horizon. *)
Definition edf_transform_prefix (sched: SchedType) (horizon: instant): SchedType :=
prefix_map sched make_edf_at horizon.
(* Finally, a full EDF schedule (i.e., one that satisfies [EDF_at]
at any time) is obtained by first computing an EDF prefix up to
and including the requested time t, and by then looking at the
last point of the prefix. *)
Definition edf_transform (sched: SchedType) (t: instant): ideal.processor_state Job :=
let
edf_prefix := edf_transform_prefix sched t.+1
in edf_prefix t.
End EDFTransformation.
From mathcomp Require Import ssrnat ssrbool fintype.
From rt.restructuring.behavior Require Import schedule.ideal facts.all.
From rt.restructuring.model Require Export schedule.edf.
From rt.restructuring.analysis Require Export schedulability transform.edf_trans transform.facts.swaps.
From rt.util Require Import tactics nat.
(** This file contains the main argument of the EDF optimality proof,
starting with an analysis of the individual functions that drive
the "EDF-ication" of a given reference schedule and ending with
the proofs of individual properties of the obtained EDF
schedule. *)
(** We start by analyzing the helper function [find_swap_candidate],
which is a problem-specific wrapper around [search_arg]. *)
Section FindSwapCandidateFacts.
(* For any given type of jobs... *)
Context {Job : JobType} `{JobCost Job} `{JobDeadline Job} `{JobArrival Job}.
(* ...consider an ideal uniprocessor schedule... *)
Variable sched: schedule (ideal.processor_state Job).
(* ...that is well-behaved (i.e., in which jobs execute only after
having arrived and only if they are not yet complete). *)
Hypothesis H_jobs_must_arrive_to_execute: jobs_must_arrive_to_execute sched.
Hypothesis H_completed_jobs_dont_execute: completed_jobs_dont_execute sched.
(* Suppose we are given a job [j1]... *)
Variable j1: Job.
(* ...and a point in time [t1]... *)
Variable t1: instant.
(* ...at which [j1] is scheduled... *)
Hypothesis H_not_idle: scheduled_at sched j1 t1.
(* ...and that is before its deadline. *)
Hypothesis H_deadline_not_missed: t1 < job_deadline j1.
(* First, we observe that under these assumptions the processor
state at time [t1] is "relevant" according to the notion of
relevance underlying the EDF transformation, namely
[relevant_pstate]. *)
Lemma t1_relevant: relevant_pstate t1 (sched t1).
Proof.
move: H_not_idle. rewrite /scheduled_at => /eqP ->.
rewrite /relevant_pstate -/(has_arrived j1 t1).
move: (H_jobs_must_arrive_to_execute j1 t1) => SCHED_ARR.
by apply SCHED_ARR.
Qed.
(* Since [t1] is relevant, we conclude that a search for a relevant
state succeeds (if nothing else, it finds [t1]). *)
Lemma fsc_search_successful:
exists t, search_arg sched (relevant_pstate t1) earlier_deadline t1 (job_deadline j1) = Some t.
Proof.
apply search_arg_not_none.
exists t1. split.
- by apply /andP; split.
- by apply t1_relevant.
Qed.
(* For rewriting purposes, we observe that the [search_arg]
operation within [find_swap_candidate] yields the final result of
[find_swap_candidate]. *)
Corollary fsc_search_result:
search_arg sched (relevant_pstate t1) earlier_deadline t1 (job_deadline j1) = Some (find_swap_candidate sched t1 j1).
Proof.
move: fsc_search_successful => [t FOUND].
by rewrite /find_swap_candidate FOUND.
Qed.
(* There is a job that is scheduled at the time that
[find_swap_candidate] returns, and that job arrives no later than
at time [t1]. *)
Lemma fsc_not_idle:
exists j', (scheduled_at sched j' (find_swap_candidate sched t1 j1))
/\ job_arrival j' <= t1.
Proof.
move: fsc_search_successful => [t FOUND].
move: (search_arg_pred _ _ _ _ _ _ FOUND).
rewrite /relevant_pstate.
destruct (sched t) as [j'|] eqn:SCHED_t => // ARR_j'.
exists j'. split => //.
rewrite /find_swap_candidate FOUND.
rewrite /scheduled_at //.
by apply /eqP.
Qed.
(* Since we are considering a uniprocessor model, only one job is
scheduled at a time. Hence once we know that a job is scheduled
at the time that [find_swap_candidate] returns, we can conclude
that it arrives not later than at time t1. *)
Corollary fsc_found_job_arrival:
forall j2,
scheduled_at sched j2 (find_swap_candidate sched t1 j1) ->
job_arrival j2 <= t1.
Proof.
move=> j2 SCHED_j2.
move: fsc_not_idle => [j' [SCHED_j' ARR]].
by rewrite -(ideal_proc_model_is_a_uniprocessor_model _ _ _ _ SCHED_j' SCHED_j2).
Qed.
(* We observe that [find_swap_candidate] returns a value within a
known finite interval. *)
Lemma fsc_range:
t1 <= find_swap_candidate sched t1 j1 < job_deadline j1.
Proof. move: fsc_search_result. by apply search_arg_in_range. Qed.
(* For convenience, since we often only require the lower bound on
the interval, we re-state it as a corollary. *)
Corollary fsc_range1:
t1 <= find_swap_candidate sched t1 j1.
Proof. by move: fsc_range => /andP [LE _]. Qed.
(* The following lemma is a key step of the overall proof: the job
scheduled at the time found by [find_swap_candidate] has the
property that it has a deadline that is no later than that of any
other job in the window given by time [t1] and the deadline of
the job scheduled at time [t1]. *)
Lemma fsc_found_job_deadline:
forall j2,
scheduled_at sched j2 (find_swap_candidate sched t1 j1) ->
forall j t,
t1 <= t < job_deadline j1 ->
scheduled_at sched j t ->
job_arrival j <= t1 ->
job_deadline j2 <= job_deadline j.
Proof.
move=> j2 SCHED_j2 j t /andP [t1_le_t t_lt_dl1] SCHED_j ARR_j.
have TOTAL: total earlier_deadline
by rewrite /earlier_deadline => s1 s2; apply leq_total.
have TRANS: transitive earlier_deadline
by rewrite /earlier_deadline => s1 s2 s3; apply leq_trans.
have REFL: reflexive earlier_deadline
by rewrite /earlier_deadline => s; apply leqnn.
move: SCHED_j SCHED_j2. rewrite /scheduled_at => /eqP SCHED_j /eqP SCHED_j2.
have ED: earlier_deadline (sched (find_swap_candidate sched t1 j1)) (sched t).
{
move: (search_arg_extremum _ _ _ REFL TRANS TOTAL _ _ _ fsc_search_result) => MIN.
apply (MIN t).
- by apply /andP; split.
- by rewrite /relevant_pstate SCHED_j.
}
by move: ED; rewrite /earlier_deadline /oapp SCHED_j SCHED_j2.
Qed.
(* As a special case of the above lemma, we observe that the job
scheduled at the time given by [find_swap_candidate] in
particular has a deadline no later than the job scheduled at time
[t1]. *)
Corollary fsc_no_later_deadline:
forall j2,
scheduled_at sched j2 (find_swap_candidate sched t1 j1) ->
job_deadline j2 <= job_deadline j1.
Proof.
move=> j2 SCHED_j2.
apply fsc_found_job_deadline with (t := t1) => //.
- by apply /andP; split.
- by apply H_jobs_must_arrive_to_execute.
Qed.
End FindSwapCandidateFacts.
(** In the next section, we analyze properties of [make_edf_at], which
we abbreviate as "mea" in the following. *)
Section MakeEDFAtFacts.
(* For any given type of jobs... *)
Context {Job : JobType} `{JobCost Job} `{JobDeadline Job} `{JobArrival Job}.
(* ...consider an ideal uniprocessor schedule... *)
Variable sched: schedule (ideal.processor_state Job).
(* ...that is well-behaved... *)
Hypothesis H_jobs_must_arrive_to_execute: jobs_must_arrive_to_execute sched.
Hypothesis H_completed_jobs_dont_execute: completed_jobs_dont_execute sched.
(* ...and in which no scheduled job misses a deadline. *)
Hypothesis H_no_deadline_misses: all_deadlines_met sched.
(* Since we will require this fact repeatedly, we briefly observe
that, since no scheduled job misses its deadline, if a job is
scheduled at some time [t], then its deadline is later than
[t]. *)
Fact scheduled_job_in_sched_has_later_deadline:
forall j t,
scheduled_at sched j t ->
job_deadline j > t.
Proof.
move=> j t SCHED.
apply (scheduled_at_implies_later_deadline sched) => //.
- by apply ideal_proc_model_ensures_ideal_progress.
- by apply (H_no_deadline_misses _ t).
Qed.
(* We analyze [make_edf_at] applied to an arbitrary point in time,
which we denote [t_edf] in the following. *)
Variable t_edf: instant.
(* For brevity, let [sched'] denote the schedule obtained from
[make_edf_at] applied to [sched] at time [t_edf]. *)
Let sched' := make_edf_at sched t_edf.
(* First, we observe that in [sched'] jobs still don't execute past
completion. *)
Lemma mea_completed_jobs:
completed_jobs_dont_execute sched'.
Proof.
rewrite /sched' /make_edf_at.
destruct (sched t_edf) as [j_orig|] eqn:SCHED; last by done.
have SCHED': scheduled_at sched j_orig t_edf
by rewrite /scheduled_at; apply /eqP.
apply swapped_completed_jobs_dont_execute => //.
apply fsc_range1 => //.
by apply scheduled_job_in_sched_has_later_deadline.
Qed.
(* Importantly, [make_edf_at] does not introduce any deadline
misses, which is a crucial step in the EDF optimality
argument. *)
Lemma mea_no_deadline_misses:
all_deadlines_met sched'.
Proof.
move=> j t SCHED.
rewrite /sched' /make_edf_at.
destruct (sched t_edf) as [j_orig|] eqn:SCHED_orig; last first.
{
apply (H_no_deadline_misses _ t).
move: SCHED.
by rewrite /sched' /make_edf_at SCHED_orig.
}
{
have SCHED': scheduled_at sched j_orig t_edf
by rewrite /scheduled_at; apply /eqP.
move: (scheduled_job_in_sched_has_later_deadline _ _ SCHED') => DL_orig.
apply edf_swap_no_deadline_misses_introduced => //.
- by apply ideal_proc_model_ensures_ideal_progress.
- by apply fsc_range1 => //.
- move=> j1 j2 SCHED_j1 SCHED_j2.
apply: (fsc_found_job_deadline sched _ j_orig t_edf _ _ _ _ _ t_edf) => //.
+ by apply /andP; split.
+ by apply H_jobs_must_arrive_to_execute.
- move=> j1 SCHED_j1.
move: (fsc_not_idle sched H_jobs_must_arrive_to_execute j_orig t_edf SCHED' DL_orig) => [j' [SCHED_j' ARR_j']].
exists j'. split => //.
by apply scheduled_job_in_sched_has_later_deadline.
- have EX: (exists t', scheduled_at sched j t').
{
apply swap_job_scheduled with (t1 := t_edf) (t2 := find_swap_candidate sched t_edf j_orig) (t0 := t).
by move: SCHED; rewrite /sched' /make_edf_at SCHED_orig.
}
move: EX => [t' SCHED_t'].
by apply H_no_deadline_misses with (t := t').
}
Qed.
(* As a result, we may conclude that any job scheduled at a time t has a deadline later than t. *)
Corollary mea_scheduled_job_has_later_deadline:
forall j t,
scheduled_at sched' j t ->
job_deadline j > t.
Proof.
move=> j t SCHED.
apply (scheduled_at_implies_later_deadline sched') => //.
- by apply mea_completed_jobs.
- by apply ideal_proc_model_ensures_ideal_progress.
- by apply mea_no_deadline_misses with (t := t).
Qed.
(* Next comes a big step in the optimality proof: we observe that
[make_edf_at] indeed ensures that [EDF_at] holds at time [t_edf] in
sched'. As this is a larger argument, we proceed by case analysis and
first establish a couple of helper lemmas in the following section. *)
Section GuaranteeCaseAnalysis.
(* Let j_orig denote the job scheduled in sched at time t_edf, let j_edf
denote the job scheduled in sched' at time t_edf, and let j' denote any
job scheduled in sched' at some time t' after t_edf... *)
Variable j_orig j_edf j': Job.
Variable t': instant.
Hypothesis H_t_edf_le_t' : t_edf <= t'.
Hypothesis H_sched_orig: scheduled_at sched j_orig t_edf.
Hypothesis H_sched_edf: scheduled_at sched' j_edf t_edf.
Hypothesis H_sched': scheduled_at sched' j' t'.
(* ... and that arrives before time t_edf. *)
Hypothesis H_arrival_j' : job_arrival j' <= t_edf.
(* We begin by observing three simple facts that will be used repeatedly in
the case analysis. *)
(* First, the deadline of j_orig is later than t_edf. *)
Fact mea_guarantee_dl_orig: t_edf < job_deadline j_orig.
Proof. by apply (scheduled_job_in_sched_has_later_deadline j_orig t_edf H_sched_orig). Qed.
(* Second, by the definition of sched', j_edf is scheduled in sched at the time
returned by [find_swap_candidate]. *)
Fact mea_guarantee_fsc_is_j_edf: sched (find_swap_candidate sched t_edf j_orig) = Some j_edf.
Proof.
move: (H_sched_orig). rewrite /scheduled_at /scheduled_in /pstate_instance => /eqP SCHED.
move: (H_sched_edf). rewrite /sched' /make_edf_at /swapped /replace_at {1}SCHED //=.
destruct (find_swap_candidate sched t_edf j_orig == t_edf) eqn:FSC.
- by move: FSC => /eqP -> /eqP.
- by rewrite ifT // => /eqP.
Qed.
(* Third, the deadline of j_edf is no later than the deadline of j_orig. *)
Fact mea_guarantee_deadlines: job_deadline j_edf <= job_deadline j_orig.
Proof.
apply: (fsc_no_later_deadline sched _ _ t_edf) => //.
- by exact mea_guarantee_dl_orig.
- by rewrite /scheduled_at mea_guarantee_fsc_is_j_edf //=.
Qed.
(* With the setup in place, we are now ready to begin the case analysis. *)
(* First, we consider the simpler case where t' is no earlier than the
deadline of j_orig. This case is simpler because t' being no earlier
than j_orig's deadline implies that j' has deadline no earlier than
j_orig (since no scheduled job in sched misses a deadline), which in
turn has a deadline no earlier than j_edf. *)
Lemma mea_guarantee_case_t'_past_deadline:
job_deadline j_orig <= t' ->
job_deadline j_edf <= job_deadline j'.
Proof.
move: (mea_scheduled_job_has_later_deadline j' t' H_sched') => DL_j' BOUND_t'.
apply leq_trans with (n := job_deadline j_orig) => // ;
first by exact mea_guarantee_deadlines.
apply leq_trans with (n := t') => //.
by apply ltnW.
Qed.
(* Next, we consider the more difficult case, where t' is before the
deadline of j_orig. *)
Lemma mea_guarantee_case_t'_before_deadline:
t' < job_deadline j_orig ->
job_deadline j_edf <= job_deadline j'.
Proof.
move: (H_sched_orig). rewrite /scheduled_at /scheduled_in /pstate_instance => /eqP SCHED BOUND_t'.
move: (mea_guarantee_fsc_is_j_edf) => FSC.
have EX: (exists x, scheduled_at sched j' x /\ t_edf <= x < job_deadline j_orig).
{
case: (boolP(t_edf == t')) => [/eqP EQ| /eqP NEQ].
- exists (find_swap_candidate sched t_edf j_orig).
split; last by apply fsc_range => //; exact mea_guarantee_dl_orig.
subst. rewrite -(ideal_proc_model_is_a_uniprocessor_model _ _ _ _ H_sched_edf H_sched').
by rewrite /scheduled_at FSC //=.
- case: (boolP(find_swap_candidate sched t_edf j_orig == t')) => [/eqP EQ' | /eqP NEQ'].
+ exists t_edf.
split; last by apply /andP; split => //; exact mea_guarantee_dl_orig.
rewrite -(swap_job_scheduled_t2 _ _ (find_swap_candidate sched t_edf j_orig) _).
move: H_sched'. rewrite /sched' /make_edf_at SCHED.
by rewrite EQ'.
+ move: NEQ NEQ' => /eqP NEQ /eqP NEQ'. exists t'.
split; last by apply /andP; split.
rewrite -(swap_job_scheduled_other_times _ t_edf (find_swap_candidate sched t_edf j_orig)) //.
move: H_sched'.
by rewrite /sched' /make_edf_at SCHED.
}
move: EX => [t'' [SCHED'' RANGE]].
apply: (fsc_found_job_deadline sched _ j_orig t_edf _ _ _ _ _ t'') => // ;
first by exact mea_guarantee_dl_orig.
by rewrite /scheduled_at FSC //=.
Qed.
End GuaranteeCaseAnalysis.
(* Finally, putting the preceding case analysis together, we obtain the
result that [make_edf_at] establishes [EDF_at] at time [t_edf]. *)
Lemma make_edf_at_guarantee:
EDF_at sched' t_edf.
Proof.
move=> j_edf H_sched_edf t' j' t_edf_le_t' H_sched' H_arrival_j'.
destruct (sched t_edf) as [j_orig|] eqn:SCHED;
last by move: (H_sched_edf); rewrite /sched' /make_edf_at /scheduled_at => /eqP; rewrite !SCHED.
have H_sched: scheduled_at sched j_orig t_edf
by rewrite /scheduled_at; apply /eqP.
case: (boolP (t' < job_deadline j_orig)).
- by apply mea_guarantee_case_t'_before_deadline.
- rewrite -leqNgt => BOUND_t'.
by apply: (mea_guarantee_case_t'_past_deadline j_orig j_edf j' t').
Qed.
(* We observe that [make_edf_at] maintains the property that jobs must arrive
to execute. *)
Lemma mea_jobs_must_arrive:
jobs_must_arrive_to_execute sched'.
Proof.
move=> j t.
rewrite /has_arrived /sched' /make_edf_at.
destruct (sched t_edf) as [j_orig|] eqn:SCHED_orig;
last by move=> SCHED; by apply H_jobs_must_arrive_to_execute.
have SCHED': scheduled_at sched j_orig t_edf
by rewrite /scheduled_at; apply /eqP.
move: (scheduled_job_in_sched_has_later_deadline j_orig t_edf SCHED') => DL_orig.
rewrite /scheduled_at /scheduled_in /pstate_instance /swapped /replace_at.
case: (boolP((find_swap_candidate sched t_edf j_orig) == t)) => [/eqP EQ| /eqP NEQ].
- rewrite SCHED_orig => /eqP j_is_orig.
injection j_is_orig => <-.
apply leq_trans with (n := t_edf).
+ by apply H_jobs_must_arrive_to_execute.
+ by rewrite -EQ; apply fsc_range1.
- case (boolP(t_edf == t)) => [/eqP EQ'| /eqP NEQ'].
+ move=> SCHED_j.
have ARR_j: job_arrival j <= t_edf by apply fsc_found_job_arrival with (sched0 := sched) (j1 := j_orig) => //.
by rewrite -EQ'.
+ move=> SCHED_j.
apply H_jobs_must_arrive_to_execute.
by rewrite /scheduled_at /scheduled_in /pstate_instance.
Qed.
(* We connect the fact that a job is scheduled in [sched'] to the
fact that it must be scheduled somewhere in [sched], too, since
[make_edf_at] does not introduce any new jobs. *)
Lemma mea_job_scheduled:
forall j t,
scheduled_at sched' j t ->
exists t', scheduled_at sched j t'.
Proof.
rewrite /sched' /make_edf_at.
move=> j t SCHED_j.
destruct (sched t_edf) as [j_orig|] eqn:SCHED_orig; last by exists t.
eapply swap_job_scheduled.
by exact SCHED_j.
Qed.
(* Conversely, if a job is scheduled in [sched], it is also
scheduled somewhere in [sched'] since [make_edf_at] does not lose
any jobs. *)
Lemma mea_job_scheduled':
forall j t,
scheduled_at sched j t ->