Library probsa.rt.analysis.work_bound

From prosa.classic Require Export util.list.

From probsa.rt.analysis Require Export nth_cost arrivals completion_time.
From probsa.rt.model.assumptions Require Export pr_cost.

Section PrTaskWorkloadBoundedNthCost.

  Context {Ω} {μ : measure Ω}.

  Context {Task : TaskType}.
  Context {Job : finType}
          {job_cost : JobCostRV Job Ω μ}
          {job_arrival : JobArrivalRV Job Ω μ}
          {job_task : JobTask Job Task}.

  Hypothesis H_arrivals_consistent : arr_seq_job_arrival_consistent.
  Hypothesis H_arrival_sequence_uniq : pr_arrival_sequence_uniq.

  Variable tsk : Task.

  Lemma nth_cost_sum_monotone :
     (k : work) (n_small n_big : nat),
      (n_small n_big)%nat
      <μ>{[ ∑[rv]_{i < n_big} nth_cost tsk i ⟨<=⟩ k ]}
       <μ>{[ ∑[rv]_{i < n_small} nth_cost tsk i ⟨<=⟩ k ]}.

We assume job costs are independent of the probabilistic arrival sequence.
Next, assume that job costs are IID.
  Hypothesis H_job_costs_independent : independent [seq job_cost j | j <- index_enum Job].
  Hypothesis H_job_costs_identically_distr :
     j1 j2, job_task j1 = job_task j2 odflt0 (job_cost j1) odflt0 (job_cost j2).

If at most n jobs of task tsk arrive in an interval [t1, t2) for arrival sequence ξ, then the probability that the sum of the first n job costs of tsk is at most k is less than or equal to the conditional probability that the actual workload in [t1, t2) is at most k.
Equivalently: the sum of nth_cost terms stochastically dominates (upper- bounds) the actual workload conditioned on arrival sequence ξ.
This inequality allows us to bound workload probabilities using a fixed-size sum of nth_cost terms, even though the actual number of arrivals is random.