Theorem: HMem.Trace.CostedProgram.splitTimeCost
Proof state before:
α : Type u_1
inst✝⁷ : Complexity.Coding α Memory
β : Type u_2
inst✝⁶ : Complexity.Encoding β Memory
f : α → β
tp : TracedProgram
γ δ : Type
inst✝⁵ : Complexity.Coding γ Memory
inst✝⁴ : Complexity.Encoding δ Memory
fs : γ → δ
cs : Complexity.CostFunction γ ℕ
inst✝³ : Complexity.Computable Encoding.Model fs
inst✝² : Complexity Encoding.Model fs cs
size : α → ℕ
fm : α → Option Memory
fcp : CostedProgram
hf : Program.sound (TracedProgram.toProgram (toTracedProgram fcp)) f size
dst✝ src✝ : Source
γ✝ δ✝ : Type
inst✝¹ : Complexity.Coding γ✝ Memory
inst✝ : Complexity.Encoding δ✝ Memory
fs✝ : γ✝ → δ✝
cs✝ : Complexity.CostFunction γ✝ ℕ
hcost : Complexity Encoding.Model fs✝ cs✝
next : CostedProgram
h : TracedProgram.sound' f size (toTracedProgram (subroutine' dst✝ src✝ inst✝¹ inst✝ fs✝ cs✝ hcost next)) fm
a : α
m : Memory
hm : m ∈ fm a
⊢ 1 ≤ Complexity.CostFunction.flatMap fm 1 a

α : Type u_1
inst✝⁷ : Complexity.Coding α Memory
β : Type u_2
inst✝⁶ : Complexity.Encoding β Memory
f : α → β
tp : TracedProgram
γ δ : Type
inst✝⁵ : Complexity.Coding γ Memory
inst✝⁴ : Complexity.Encoding δ Memory
fs : γ → δ
cs : Complexity.CostFunction γ ℕ
inst✝³ : Complexity.Computable Encoding.Model fs
inst✝² : Complexity Encoding.Model fs cs
size : α → ℕ
fm : α → Option Memory
fcp : CostedProgram
hf : Program.sound (TracedProgram.toProgram (toTracedProgram fcp)) f size
dst✝ src✝ : Source
γ✝ δ✝ : Type
inst✝¹ : Complexity.Coding γ✝ Memory
inst✝ : Complexity.Encoding δ✝ Memory
fs✝ : γ✝ → δ✝
cs✝ : Complexity.CostFunction γ✝ ℕ
hcost : Complexity Encoding.Model fs✝ cs✝
next : CostedProgram
h : TracedProgram.sound' f size (toTracedProgram (subroutine' dst✝ src✝ inst✝¹ inst✝ fs✝ cs✝ hcost next)) fm
a : α
m : Memory
hm : m ∈ fm a
⊢ (subroutineTimeCost
              (_ :
                TracedProgram.sound' f size (toTracedProgram next)
                  ((flip Option.bind fun m =>
                      Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                        (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                    fm)) +
            recurseTimeCost hf
              (_ :
                TracedProgram.sound' f size (toTracedProgram next)
                  ((flip Option.bind fun m =>
                      Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                        (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                    fm)) +
          localTimeCost
            (_ :
              TracedProgram.sound' f size (toTracedProgram next)
                ((flip Option.bind fun m =>
                    Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                      (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                  fm)))
        a +
      Complexity.ALE.bound Complexity.cost_ale
        (Option.get (Complexity.decode γ✝ (Memory.getms m src✝))
          (_ : Option.isSome (Complexity.decode γ✝ (Memory.getms m src✝)) = true)) ≤
    (subroutineTimeCost h + recurseTimeCost hf h) a +
      localTimeCost
        (_ :
          TracedProgram.sound' f size (toTracedProgram next)
            ((flip Option.bind fun m =>
                Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                  (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
              fm))
        a
Tactic:
apply (le_of_eq (Eq.symm (Complexity.CostFunction.flatMap_some hm _)))
Proof state after:
α : Type u_1
inst✝⁷ : Complexity.Coding α Memory
β : Type u_2
inst✝⁶ : Complexity.Encoding β Memory
f : α → β
tp : TracedProgram
γ δ : Type
inst✝⁵ : Complexity.Coding γ Memory
inst✝⁴ : Complexity.Encoding δ Memory
fs : γ → δ
cs : Complexity.CostFunction γ ℕ
inst✝³ : Complexity.Computable Encoding.Model fs
inst✝² : Complexity Encoding.Model fs cs
size : α → ℕ
fm : α → Option Memory
fcp : CostedProgram
hf : Program.sound (TracedProgram.toProgram (toTracedProgram fcp)) f size
dst✝ src✝ : Source
γ✝ δ✝ : Type
inst✝¹ : Complexity.Coding γ✝ Memory
inst✝ : Complexity.Encoding δ✝ Memory
fs✝ : γ✝ → δ✝
cs✝ : Complexity.CostFunction γ✝ ℕ
hcost : Complexity Encoding.Model fs✝ cs✝
next : CostedProgram
h : TracedProgram.sound' f size (toTracedProgram (subroutine' dst✝ src✝ inst✝¹ inst✝ fs✝ cs✝ hcost next)) fm
a : α
m : Memory
hm : m ∈ fm a
⊢ (subroutineTimeCost
              (_ :
                TracedProgram.sound' f size (toTracedProgram next)
                  ((flip Option.bind fun m =>
                      Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                        (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                    fm)) +
            recurseTimeCost hf
              (_ :
                TracedProgram.sound' f size (toTracedProgram next)
                  ((flip Option.bind fun m =>
                      Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                        (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                    fm)) +
          localTimeCost
            (_ :
              TracedProgram.sound' f size (toTracedProgram next)
                ((flip Option.bind fun m =>
                    Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                      (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
                  fm)))
        a +
      Complexity.ALE.bound Complexity.cost_ale
        (Option.get (Complexity.decode γ✝ (Memory.getms m src✝))
          (_ : Option.isSome (Complexity.decode γ✝ (Memory.getms m src✝)) = true)) ≤
    (subroutineTimeCost h + recurseTimeCost hf h) a +
      localTimeCost
        (_ :
          TracedProgram.sound' f size (toTracedProgram next)
            ((flip Option.bind fun m =>
                Option.map (Memory.setms m dst✝ ∘ Complexity.encode ∘ fs✝)
                  (Complexity.decode γ✝ (Memory.getms m src✝))) ∘
              fm))
        a