. refine' .inr ∘ .inr $ lenOne_complete _ _
  cases' h_stmt with h h <;> rw [h] <;> rfl
case zero.zero.zero
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
⊢ stmt { index := Nat.zero } { index := Nat.zero } Nat.zero ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.zero + Nat.zero + Nat.zero)) ∨
    stmt { index := Nat.zero } { index := Nat.zero } Nat.zero ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2)
              (Finset.product (ofLen ↑x) (ofLen (Nat.zero + Nat.zero + Nat.zero - ↑x))))
          (Finset.attach (Finset.range (Nat.zero + Nat.zero + Nat.zero))) ∨
      stmt { index := Nat.zero } { index := Nat.zero } Nat.zero ∈ baseProgram (Nat.zero + Nat.zero + Nat.zero + 1)

case zero.zero.succ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
n' : ℕ
⊢ stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.zero + Nat.zero + Nat.succ n')) ∨
    stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2)
              (Finset.product (ofLen ↑x) (ofLen (Nat.zero + Nat.zero + Nat.succ n' - ↑x))))
          (Finset.attach (Finset.range (Nat.zero + Nat.zero + Nat.succ n'))) ∨
      stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
        baseProgram (Nat.zero + Nat.zero + Nat.succ n' + 1)

case zero.succ
n : ℕ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
y' : ℕ
⊢ stmt { index := Nat.zero } { index := Nat.succ y' } n ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.zero + Nat.succ y' + n)) ∨
    stmt { index := Nat.zero } { index := Nat.succ y' } n ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2)
              (Finset.product (ofLen ↑x) (ofLen (Nat.zero + Nat.succ y' + n - ↑x))))
          (Finset.attach (Finset.range (Nat.zero + Nat.succ y' + n))) ∨
      stmt { index := Nat.zero } { index := Nat.succ y' } n ∈ baseProgram (Nat.zero + Nat.succ y' + n + 1)

case succ
y n : ℕ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
x' : ℕ
⊢ stmt { index := Nat.succ x' } { index := y } n ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.succ x' + y + n)) ∨
    stmt { index := Nat.succ x' } { index := y } n ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2) (Finset.product (ofLen ↑x) (ofLen (Nat.succ x' + y + n - ↑x))))
          (Finset.attach (Finset.range (Nat.succ x' + y + n))) ∨
      stmt { index := Nat.succ x' } { index := y } n ∈ baseProgram (Nat.succ x' + y + n + 1)
case zero.zero.succ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
n' : ℕ
⊢ stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.zero + Nat.zero + Nat.succ n')) ∨
    stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2)
              (Finset.product (ofLen ↑x) (ofLen (Nat.zero + Nat.zero + Nat.succ n' - ↑x))))
          (Finset.attach (Finset.range (Nat.zero + Nat.zero + Nat.succ n'))) ∨
      stmt { index := Nat.zero } { index := Nat.zero } (Nat.succ n') ∈
        baseProgram (Nat.zero + Nat.zero + Nat.succ n' + 1)

case zero.succ
n : ℕ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
y' : ℕ
⊢ stmt { index := Nat.zero } { index := Nat.succ y' } n ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.zero + Nat.succ y' + n)) ∨
    stmt { index := Nat.zero } { index := Nat.succ y' } n ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2)
              (Finset.product (ofLen ↑x) (ofLen (Nat.zero + Nat.succ y' + n - ↑x))))
          (Finset.attach (Finset.range (Nat.zero + Nat.succ y' + n))) ∨
      stmt { index := Nat.zero } { index := Nat.succ y' } n ∈ baseProgram (Nat.zero + Nat.succ y' + n + 1)

case succ
y n : ℕ
stmt : Variable → Variable → ℕ → LoopProgram
h_stmt : stmt = add ∨ stmt = sub
x' : ℕ
⊢ stmt { index := Nat.succ x' } { index := y } n ∈
      Finset.fold (fun a b => a ∪ b) ∅ extendLenOne (ofLen (Nat.succ x' + y + n)) ∨
    stmt { index := Nat.succ x' } { index := y } n ∈
        Finset.fold (fun x x_1 => x ∪ x_1) ∅
          (fun x =>
            Finset.image (fun x => concat x.1 x.2) (Finset.product (ofLen ↑x) (ofLen (Nat.succ x' + y + n - ↑x))))
          (Finset.attach (Finset.range (Nat.succ x' + y + n))) ∨
      stmt { index := Nat.succ x' } { index := y } n ∈ baseProgram (Nat.succ x' + y + n + 1)