-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Clause.lean
theorem ofArray_eq (arr : Array (Literal (PosFin n)))
    (arrNodup : ∀ i : Fin arr.size, ∀ j : Fin arr.size, i.1 ≠ j.1 → arr[i] ≠ arr[j])
    (c : DefaultClause n) :
    ofArray arr = some c → toList c = Array.toList arr

Proof state:
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
c' : DefaultClause n
heq : empty = c'
hsize : List.length c'.clause = arr.size - arr.size
⊢ ∃ hsize,
    ∀ (i : Fin (List.length c'.clause)),
      let_fun idx_in_bounds := ⋯;
      List.get c'.clause i = arr[arr.size + ↑i]

Tactic:
apply Exists.intro hsize

Result:
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
c' : DefaultClause n
heq : empty = c'
hsize : List.length c'.clause = arr.size - arr.size
⊢ ∀ (i : Fin (List.length c'.clause)),
    let_fun idx_in_bounds := ⋯;
    List.get c'.clause i = arr[arr.size + ↑i]

Proof state:
case intro
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
h_base : motive arr.size (some empty)
fold_fn : Literal (PosFin n) → Option (DefaultClause n) → Option (DefaultClause n) :=
  fun l acc =>
    match acc with
    | none => none
    | some acc => acc.insert l
idx : Fin arr.size
idx_add_one_le_arr_size : ↑idx + 1 ≤ arr.size
c' : DefaultClause n
acc✝ : Option (DefaultClause n)
acc : DefaultClause n
hsize : List.length acc.clause = arr.size - (↑idx + 1)
h✝ : ¬List.contains acc.clause (arr[↑idx].fst, !arr[↑idx].snd) = true
h_dup : List.elem arr[↑idx] acc.clause = true
heq : some acc = some c'
j : Fin (List.length acc.clause)
hj : List.get acc.clause j = arr[↑idx]
ih : arr[↑idx] = arr[↑idx + 1 + ↑j]
⊢ False

Tactic:
have idx_add_one_add_j_in_bounds : idx.1 + 1 + j.1 < arr.size := by
  omega

Result:
case intro
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
h_base : motive arr.size (some empty)
fold_fn : Literal (PosFin n) → Option (DefaultClause n) → Option (DefaultClause n) :=
  fun l acc =>
    match acc with
    | none => none
    | some acc => acc.insert l
idx : Fin arr.size
idx_add_one_le_arr_size : ↑idx + 1 ≤ arr.size
c' : DefaultClause n
acc✝ : Option (DefaultClause n)
acc : DefaultClause n
hsize : List.length acc.clause = arr.size - (↑idx + 1)
h✝ : ¬List.contains acc.clause (arr[↑idx].fst, !arr[↑idx].snd) = true
h_dup : List.elem arr[↑idx] acc.clause = true
heq : some acc = some c'
j : Fin (List.length acc.clause)
hj : List.get acc.clause j = arr[↑idx]
ih : arr[↑idx] = arr[↑idx + 1 + ↑j]
idx_add_one_add_j_in_bounds : ↑idx + 1 + ↑j < arr.size
⊢ False

Proof state:
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
h_base : motive arr.size (some empty)
⊢ c.clause = arr.toList

Tactic:
let fold_fn (l : Literal (PosFin n)) (acc : Option (DefaultClause n)) : Option (DefaultClause n) :=
  match acc with
  | none => none
  | some acc => acc.insert l

Result:
n : Nat
arr : Array (Literal (PosFin n))
arrNodup : ∀ (i j : Fin arr.size), ↑i ≠ ↑j → arr[i] ≠ arr[j]
c : DefaultClause n
h :
  Array.foldr
      (fun l acc =>
        match acc with
        | none => none
        | some acc => acc.insert l)
      (some empty) arr =
    some c
motive : Nat → Option (DefaultClause n) → Prop :=
  fun idx acc =>
    ∃ idx_le_arr_size,
      ∀ (c' : DefaultClause n),
        acc = some c' →
          ∃ hsize,
            ∀ (i : Fin (List.length c'.clause)),
              let_fun idx_in_bounds := ⋯;
              List.get c'.clause i = arr[idx + ↑i]
h_base : motive arr.size (some empty)
fold_fn : Literal (PosFin n) → Option (DefaultClause n) → Option (DefaultClause n) :=
  fun l acc =>
    match acc with
    | none => none
    | some acc => acc.insert l
⊢ c.clause = arr.toList