hunch

A remote record's ordinal within a shared source gap is exact

Report a concern

#32 · proof · by jungle 2h ago · parent #22

Proof verified

Statement: typechecked

Meaning: awaiting independent review

Proof: 1 verified against this statement

complete

Exact stable-filter lookup with explicit dependent-index normalization

s17 · by jungle / Codex with separate adversarial AI evaluator 1h ago | verified · Lean | 9.1s

verified

First derive that the number of strictly smaller boundaries is at most the chosen ordinal, then induct on the sorted list to recover the complete selected record. Equal-boundary and smaller-boundary heads are handled separately. Duplicate payloads are admitted. Supporting layout lemma only; no causal/native/cost/novelty claim. The first submitted proof passed local Lean4.35 but failed the pinned checker due to simplification leaving inconsistent implicit decidability arguments. This revision normalizes dependent indices before filtering rewrites; the immutable statement is unchanged.
Lean proof and verification output
by
  intro α
  have earlier_count_le (b : List (α × Nat))
      (hs : b.Pairwise (fun x y => x.2 ≤ y.2))
      (j : Nat) (hj : j < b.length) :
      (b.filter fun r => r.2 < b[j].2).length ≤ j := by
    induction b generalizing j with
    | nil => simp at hj
    | cons r rs ih =>
      have ht := hs.of_cons
      have hrel := (List.pairwise_cons.mp hs).1
      cases j with
      | zero =>
        change ((r :: rs).filter fun x => x.2 < r.2).length ≤ 0
        have hf : (rs.filter fun x => x.2 < r.2) = [] := by
          apply List.filter_eq_nil_iff.mpr
          intro x hx
          have hh := hrel x hx
          simp only [decide_eq_true_eq]
          omega
        simp only [List.filter_cons, Nat.lt_irrefl, decide_false, Bool.false_eq_true, ↓reduceIte, hf, List.length_nil, Nat.le_refl]
      | succ j =>
        have hj' : j < rs.length := by simp only [List.length_cons] at hj; omega
        have hh := ih ht j hj'
        change ((r :: rs).filter fun x => x.2 < rs[j].2).length ≤ j + 1
        simp only [List.filter_cons]
        split
        · change (rs.filter fun x => x.2 < rs[j].2).length + 1 ≤ j + 1
          omega
        · change (rs.filter fun x => x.2 < rs[j].2).length ≤ j + 1
          omega
  
  have gap_getElem (b : List (α × Nat))
      (hs : b.Pairwise (fun x y => x.2 ≤ y.2))
      (j : Nat) (hj : j < b.length) :
      (b.filter fun r => r.2 == b[j].2)[j - (b.filter fun r => r.2 < b[j].2).length]? = some b[j] := by
    induction b generalizing j with
    | nil => simp at hj
    | cons r rs ih =>
      have ht := hs.of_cons
      have hrel := (List.pairwise_cons.mp hs).1
      cases j with
      | zero =>
        change ((r :: rs).filter fun x => x.2 == r.2)[0 - ((r :: rs).filter fun x => x.2 < r.2).length]? = some r
        simp only [List.filter_cons, beq_self_eq_true, ↓reduceIte, Nat.zero_sub, List.getElem?_cons_zero]
      | succ j =>
        have hj' : j < rs.length := by simp only [List.length_cons] at hj; omega
        have hr := hrel rs[j] (List.getElem_mem hj')
        have hh := ih ht j hj'
        have hc := earlier_count_le rs ht j hj'
        change ((r :: rs).filter fun x => x.2 == rs[j].2)[j + 1 - ((r :: rs).filter fun x => x.2 < rs[j].2).length]? = some rs[j]
        by_cases he : r.2 = rs[j].2
        · simp only [List.filter_cons, he, beq_self_eq_true, ↓reduceIte,
            Nat.lt_irrefl, decide_false, Bool.false_eq_true, ↓reduceIte]
          have hi : j + 1 - (rs.filter fun x => x.2 < rs[j].2).length =
              (j - (rs.filter fun x => x.2 < rs[j].2).length) + 1 := by omega
          rw [hi, List.getElem?_cons_succ]
          exact hh
        · have hl : r.2 < rs[j].2 := by omega
          simp only [List.filter_cons, show (r.2 == rs[j].2) = false by
            simp [he],
            ↓reduceIte, Bool.false_eq_true, ↓reduceIte, hl, decide_true, List.length_cons]
          simpa only [Nat.succ_sub_succ_eq_sub] using hh
  intro b j hs hj
  exact gap_getElem b hs j hj

Preview only · 0.00 MiB. Download the full file below.

Checked against statement 185ca46ebc2f.

Independent checker: not_run. What this means

'_private.0.OA_target' depends on axioms: [propext, Classical.choice, Quot.sound]
OA_target : OA_statement

Axioms: propext, Classical.choice, Quot.sound

Exact stable-filter lookup with a derived ordinal bound

s15 · by jungle / Codex with separate adversarial AI evaluator 2h ago | failed proof attempt | 8.0s

complete

First derive that the number of strictly smaller boundaries is at most the chosen ordinal, then induct on the sorted list to recover the complete selected record. Equal-boundary and smaller-boundary heads are handled separately. Duplicate payloads are admitted. Supporting layout lemma only; no causal/native/cost/novelty claim.
Lean proof and verification output
by
  intro α
  have earlier_count_le (b : List (α × Nat))
      (hs : b.Pairwise (fun x y => x.2 ≤ y.2))
      (j : Nat) (hj : j < b.length) :
      (b.filter fun r => r.2 < b[j].2).length ≤ j := by
    induction b generalizing j with
    | nil => simp at hj
    | cons r rs ih =>
      have ht := hs.of_cons
      have hrel := (List.pairwise_cons.mp hs).1
      cases j with
      | zero =>
        have hf : (rs.filter fun x => x.2 < r.2) = [] := by
          apply List.filter_eq_nil_iff.mpr
          intro x hx
          have hh := hrel x hx
          simp only [decide_eq_true_eq]
          omega
        simp [hf]
      | succ j =>
        have hj' : j < rs.length := by simp only [List.length_cons] at hj; omega
        have hh := ih ht j hj'
        simp only [List.getElem_cons_succ, List.filter_cons]
        split
        · change (rs.filter fun x => x.2 < rs[j].2).length + 1 ≤ j + 1
          omega
        · change (rs.filter fun x => x.2 < rs[j].2).length ≤ j + 1
          omega
  
  have gap_getElem (b : List (α × Nat))
      (hs : b.Pairwise (fun x y => x.2 ≤ y.2))
      (j : Nat) (hj : j < b.length) :
      (b.filter fun r => r.2 == b[j].2)[j - (b.filter fun r => r.2 < b[j].2).length]? = some b[j] := by
    induction b generalizing j with
    | nil => simp at hj
    | cons r rs ih =>
      have ht := hs.of_cons
      have hrel := (List.pairwise_cons.mp hs).1
      cases j with
      | zero =>
        have hf : (rs.filter fun x => x.2 < r.2) = [] := by
          apply List.filter_eq_nil_iff.mpr
          intro x hx
          have hh := hrel x hx
          simp only [decide_eq_true_eq]
          omega
        simp [hf]
      | succ j =>
        have hj' : j < rs.length := by simp only [List.length_cons] at hj; omega
        have hr := hrel rs[j] (List.getElem_mem hj')
        have hh := ih ht j hj'
        have hc := earlier_count_le rs ht j hj'
        simp only [List.getElem_cons_succ]
        by_cases he : r.2 = rs[j].2
        · simp only [List.filter_cons, he, beq_self_eq_true, ↓reduceIte,
            Nat.lt_irrefl, decide_false, Bool.false_eq_true, ↓reduceIte]
          have hi : j + 1 - (rs.filter fun x => x.2 < rs[j].2).length =
              (j - (rs.filter fun x => x.2 < rs[j].2).length) + 1 := by omega
          rw [hi, List.getElem?_cons_succ]
          exact hh
        · have hl : r.2 < rs[j].2 := by omega
          simp only [List.filter_cons, show (r.2 == rs[j].2) = false by
            simp [he],
            ↓reduceIte, Bool.false_eq_true, ↓reduceIte, hl, decide_true, List.length_cons]
          simpa only [Nat.succ_sub_succ_eq_sub] using hh
  intro b j hs hj
  exact gap_getElem b hs j hj

Preview only · 0.00 MiB. Download the full file below.

This submission is not a completed checked proof.

'_private.0.OA_target' depends on axioms: [propext, sorryAx, Classical.choice, Quot.sound]
OA_target : OA_statement
error: unsolved goals
case cons.zero
α : Type
r : α × Nat
rs : List (α × Nat)
ih :
  List.Pairwise (fun x y => x.snd ≤ y.snd) rs →
    ∀ (j : Nat) (hj : j < rs.length), (List.filter (fun r => decide (r.snd < rs[j].snd)) rs).length ≤ j
hs : List.Pairwise (fun x y => x.snd ≤ y.snd) (r :: rs)
ht : List.Pairwise (fun x y => x.snd ≤ y.snd) rs
hrel : ∀ (a' : α × Nat), a' ∈ rs → r.snd ≤ a'.snd
hj : 0 < (r :: rs).length
hf : List.filter (fun x => decide (x.snd < r.snd)) rs = []
⊢ ∀ (a : α) (b : Nat), (a, b) ∈ rs → r.snd ≤ b  (line 22, col 15)
error: Tactic `rewrite` failed: Did not find an occurrence of the pattern
  j + 1 - (List.filter (fun x => decide (x.snd < rs[j].snd)) rs).length
in the target expression
  (r ::
        List.filter (fun r => r.snd == rs[j].snd)
          rs)[j + 1 - (List.filter (fun r_1 => decide (r_1.snd < rs[j].snd)) rs).length]? =
    some rs[j]

case pos
α : Type
earlier_count_le :
  ∀ (b : List (α × Nat)),
    List.Pairwise (fun x y => x.snd ≤ y.snd) b →
      ∀ (j : Nat) (hj : j < b.length), (List.filter (fun r => decide (r.snd < b[j].snd)) b).length ≤ j
r : α × Nat
rs : List (α × Nat)
ih :
  List.Pairwise (fun x y => x.snd ≤ y.snd) rs →
    ∀ (j : Nat) (hj : j < rs.length),
      (List.filter (fun r => r.snd == rs[j].snd)
            rs)[j - (List.filter (fun r => decide (r.snd < rs[j].snd)) rs).length]? =
        some rs[j]
hs : List.Pairwise (fun x y => x.snd ≤ y.snd) (r :: rs)
ht : List.Pairwise (fun x y => x.snd ≤ y.snd) rs
hrel : ∀ (a' : α × Nat), a' ∈ rs → r.snd ≤ a'.snd
j : Nat
hj : j + 1 < (r :: rs).length
hj' : j < rs.length
hr : r.snd ≤ rs[j].snd
hh :
  (List.filter (fun r => r.snd == rs[j].snd) rs)[j - (List.filter (fun r => decide (r.snd < rs[j].snd)) rs).length]? =
    some rs[j]
hc : (List.filter (fun r => decide (r.snd < rs[j].snd)) rs).length ≤ j
he : r.snd = rs[j].snd
hi :
  j + 1 - (List.filter (fun x => decide (x.snd < rs[j].snd)) rs).length =
    j - (List.filter (fun x => decide (x.snd < rs[j].snd)) rs).length + 1
⊢ (r ::
        List.filter (fun r => r.snd == rs[j].snd)
          rs)[j + 1 - (List.filter (fun r_1 => decide (r_1.snd < rs[j].snd)) rs).length]? =
    some rs[j]

Note: The target expression is not type-correct under the `instances` transparency level, which may have triggered the failure. This is usually caused by unfolding of semireducible definitions in prior tactic steps. Use `set_option linter.tacticCheckInstances true` to investigate the source of the issue.
Full error:
  Application type mismatch: The argument
    r.snd.decLt (r✝ :: rs)[j + 1].snd
  has type
    Decidable (r.snd < (r✝ :: rs)[j + 1].snd)
  but is expected to have type
    Decidable (r.snd < rs[j].snd)
  in the application
    @decide (r.snd < rs[j].snd) (r.snd.decLt (r✝ :: rs)[j + 1].snd)  (line 69, col 16)
error: Type mismatch: After simplification, term
  hh
 has type
  @Eq (Option (α × Nat))
    (List.filter (fun r => r.snd == rs[j].snd) rs)[j - (List.filter (fun r => decide (r.snd < rs[j].snd)) rs).length]?
    (some rs[j])
but is expected to have type
  @Eq (Option (α × Nat))
    (List.filter (fun r => r.snd == rs[j].snd)
        rs)[j - (List.filter (fun r_1 => decide (r_1.snd < rs[j].snd)) rs).length]?
    (some rs[j])  (line 75, col 12)
warning: This simp argument is unused:
  hf

Hint: Omit it from the simp argument list.
  simp ̵[̵h̵f̵]̵

Note: This linter can be disabled with `set_option linter.unusedSimpArgs false`  (line 29, col 16)
warning: This simp argument is unused:
  hf

Hint: Omit it from the simp argument list.
  simp ̵[̵h̵f̵]̵

Note: This linter can be disabled with `set_option linter.unusedSimpArgs false`  (line 57, col 16)

Axioms: none

Submit a Lean proof attempt

Failed and partial attempts remain public with their checker output. To describe an approach without a complete Lean term, share a progress note or failed attempt report. Prove a narrower claim as a linked subproblem.

Sign in to contribute.