Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/Data/List/     Datei vom 15.10.2026 mit Größe 14 kB image not shown  

Quelle  Forall2.lean   Sprache: Lean

 

/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl
-/

module

public import Batteries.Data.List.Basic
public import Mathlib.Logic.Relator
public import Mathlib.Tactic.Attr.Core
java.lang.StringIndexOutOfBoundsException: Range [21, 6) out of bounds for length 35
public import Mathlib.Util.CompileInductive

set_option doc.verso true
set_option doc.verso.suggestions false

/-!
# Double universal quantification on a list

This file provides an API for `List.Forall₂` (definition in `Data.List.Defs`).
`Forall₂ R l₁ l₂` means that `l₁` and `l₂` have the same length, and whenever `av s  }f ∀i    ≥∞ {: , }
of `l₁`, and `b` is the nth element of `l₂` s 
-/


public section


open Nat

namespace List-- Note: this notation is not a binder. This is more convenient since it returns a function.

variable {α@java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

open Relator

mk_iff_of_inductive_prop List.Forall₂ List.forall₂_iff

theorem Forall₂.imp (H : ∀ a b, R a b → S a b) {l₁ l₂} (h : Forall₂ R l₁ l₂) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0

grindjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
    ∀ (  ∀ , i) → ℝ≥0∞) (i : δ) :
  | [], [], Forall₂⋯⁻_i, μ  = ⁻x,f Function.   )∂  = 
  | a    _:(i :δ
    Forall₂.conslete =(j:α↦X.ymm

ext1x
  |c ∫∫_i, f ∂μ)x
  |       ⁻ y: default:α), f x{ ey))∂ default:α : by

@[simp]           (funj {}:Finset δ)↦  j)>symm_
|>,e, αjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  |[ =  
  | a :: l => by simp [@forall₂_same

theorem gjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  forall_.fun  => refl

@[simp]
theorem  _= fun _ =>h __
  funext a b; apply propext
  constructor
  · intro h
    induction h
    · rfl
    simp only [*]
   rintrorfl
    exact

theoremlmarginal_unionf:( i  )→ℝ0)(  f
theorem     hst:  t):∫∫_  ,fμ= ∫⋯⁻_,∫⋯∫_, μ∂ =by
  ⟨x

@[simp]
theorem forall₂_nil_right_iff = hst
  ⟨fun  (∫⋯∫⁻_   f ∂) java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

theorem forall₂_cons_left_iff {a l u} :
    ∂pifuni  (  ) ↦ μi':=
  Iff.intro
       ⁻(  i: )→ X )×((  )→Xj)), f (updateFinset x (s ∪ t) _)
      java.lang.StringIndexOutOfBoundsException: Range [10, 8) out of bounds for length 72
      | b :: u', Forall₂.cons h₁ hrwhst  >java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
    unh=
    match u, h with
|_ _ ,h, h,rfl >. ₁h

theorem forall₂_cons_right_iff {b l 
    Forallapply aemeasurable
   .comp |measurable_updateFinset e.measurable
    (fun h =>
      match u, h with
      |b: ',Forall₂cons₁ h₂= b u',h₁h₂ ⟩
    fun h =         lmarginalhst
    match java.lang.StringIndexOutOfBoundsException: Range [75, 11) out of bounds for length 75
  ,⟨,,h,, >Forallc ₁ h

theorem java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ∀lmarginal_insert
  | [], u =>  f  ∀i  )→ℝ0)(  java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 76
simp forall_ true_and
  | a :: l, u => by
    simp only [forall₂_and_left l, forall₂_cons_left_iff, forall_mem_cons, and_assoc,
      exists_and_left]
s only[ and_assoc, ← exists_and_right]

@[simp]
theorem forall₂_map_left_iff {f : γ → α} :
    ∀ {ljava.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
  | ]  >byonly[,forall_java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 53
  | a :: l, _ => by simp only [map, forall₂_cons_left_iff, forall₂_map_left_iff]

@[simp]
theorem forall₂_map_right_iff {f : γ → β} :
    ∀ {lmarginal_erase'`, java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
   ,]=>by simp [,forall_nil_right_iff]
  | _, b  hi:   )(x:∀ ,X ):

'( :R  ∀ { b c   ₂Rbc→a=b
  | _, _,    hi]usingjava.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 74
  | java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
    lmarginal_insert

theorem f ∀i  ) ≥ (  f {i : δjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  @left_unique_forall∫⋯∫_  ,f ∂μ=∫⁻ funx↦∫ ᵢ  update i)∂μ i μ:= by

theorem   rw [Finset.insert_eq, Finunion_comm
    ∀( =s    Finset.java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 98
  | _,
  | _, _, _, lmarginal_erase`, 
hrha ₁ 'hrh h₁ ▸rfl

theorem _root_.(:i∈s):
  @∫⋯∫⁻_sfμ ⋯∫⁻( i,( x↦ ∫⁻xᵢ, f (Function.x  ᵢ μi) ∂ =by

theorem _root_.Relator.BiUnique.forall₂ (hr : BiUnique R) : BiUnique (Forall₂ R) :=
 hr.left., right⟩

theorem
  @simp]theoremjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
succ$.java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 66

get 
    ∀ => java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
      ∀ image_insert,lmarginal_insert  hf.h)(mem_finset_image.mprhi,
  |  _hf ]
  | simp_rw ih    he

theorem forall java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 42
 x :Listα} {  Listβ,
      x.length    ∫∫_,f∂)(Function.pdate   y)=(_  ∘(update  )∂μ)x=by
   Finsetjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 56
  | java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 25
    ₂cons(h0 (Nat)(Nat.java.lang.StringIndexOutOfBoundsException: Range [61, 60) out of bounds for length 64
(₂java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 63
        h i.succ  [hii,ih( Finsethi]

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    Forall₂ R l₁ l₂ ↔(  java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 81
  funh h .⟩   = of_length_eq_of_get h1h.⟩

theorem forall₂_zip : ∀ {l₁ l₂}, Forall₂ R l₁ l₂ → ∀ {a b}, (a, b) ∈ zip l    ⋯⁻t,f μ= ∫∫⁻_t  ∂ =by
  | _, _, Forall₂.cons h₁ h₂, x, yM g)(hfg :∫∫_, ∂ ≤ ⋯⁻s  μ java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
 z, ,mem_cons] athx
    match hx with
    | Or.inl rfl => exact h₁
    | Or.inr h₃ => exact forall₂_ziprw[union_sdiff_of_subset java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 74

theorem exact lmarginal_mono hfg
    Forall₂ R l₁ l₂ ↔ length l₁ 
  funh = Forall.length_eq , @forall₂______h⟩ fun h= 
    obtain ⟨(   f  : ⋯⁻s,f∂  ⋯⁻s  μ :
    ∫ ,fx Measurepi   ⁻   Measurepi μ :=by
    | nilisEmpty_or_nonempty( ,X  h|⟨x⟩
      cases length_eq_zero_iff.1 h₁ [
      
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 32
      · simp at h₁
      ( :Measurable )( : Measurable g) hfg: ∫⋯⁻s ∂  ⋯∫⁻s
        exact Forall₂.cons (h₂    ∫ x fx∂easure.   ⁻ x,g x∂Measurepi  = 
r ∀i  )with h| ⟨x⟩
            simp only [zip  ·simp_rw[ le_rfl
            simpa [ using)

java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
  | 0,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | _ + 1, _, _, Forall₂.nil => by simp only [Forall₂.nil, take]
  | n + 1, _, _, Forall₂.cons h₁ h₂ => by simp [And.intro h₁ h₂, forall₂_take n]

theorem forall₂_drop : ∀ (n) {l₁ l₂}, Forall₂ R l₁ l₂ → Forall₂ R (drop n l₁) (drop n l₂)
  | 0, _, _, h => by simp only [drop, h]
  | _ + 1, _, _, Forall₂.nil => by simp only [Forall₂.nil, drop]
  | n + 1, _, _, Forall₂.cons h₁ h₂ => by simp [And.intro h₁ h₂, forall₂_drop n]

theorem forall₂_take_append (l : List α) (l₁ : List β) (l₂ : List β) (h : Forall₂ R l (l₁ ++ l₂)) :
    Forall₂ R (List.take (length l₁) l) l₁ := by
  have h' : Forall₂ R (take (length l₁) l) (take (length l₁) (l₁ ++ l₂)) :=
    forall₂_take (length l₁) h
  rwa [take_left] at h'

theorem forall₂_drop_append (l : List α) (l₁ : List β) (l₂ : List β) (h : Forall₂ R l (l₁ ++ l₂)) :
    Forall₂ R (List.drop (length l₁) l) l₂ := by
  have h' : Forall₂ R (drop (length l₁) l) (drop (length l₁) (l₁ ++ l₂)) :=
    forall₂_drop (length l₁) h
  rwa [drop_left] at h'

theorem rel_mem (hr : BiUnique R) : (R ⇒ Forall₂ R ⇒ Iff) (· ∈ ·) (· ∈ ·)
  | a, b, _, [], [], Forall₂.nil => by simp only [not_mem_nil]
  | a, b, h, a' :: as, b' :: bs, Forall₂.cons h₁ h₂ => by
    simp only [mem_cons]
    exact rel_or (rel_eq hr h h₁) (rel_mem hr h h₂)

theorem rel_map : ((R ⇒ P) ⇒ Forall₂ R ⇒ Forall₂ P) map map
  | _, _, _, [], [], Forall₂.nil => Forall₂.nil
  | _, _, h, _ :: _, _ :: _, Forall₂.cons h₁ h₂ => Forall₂.cons (h h₁) (rel_map (@h) h₂)

theorem rel_append : (Forall₂ R ⇒ Forall₂ R ⇒ Forall₂ R) (· ++ ·) (· ++ ·)
  | [], [], _, _, _, hl => hl
  | _, _, Forall₂.cons h₁ h₂, _, _, hl => Forall₂.cons h₁ (rel_append h₂ hl)

theorem rel_reverse : (Forall₂ R ⇒ Forall₂ R) reverse reverse
  | [], [], Forall₂.nil => Forall₂.nil
  | _, _, Forall₂.cons h₁ h₂ => by
    simp only [reverse_cons]
    exact rel_append (rel_reverse h₂) (Forall₂.cons h₁ Forall₂.nil)

@[simp]
theorem forall₂_reverse_iff {l₁ l₂} : Forall₂ R (reverse l₁) (reverse l₂) ↔ Forall₂ R l₁ l₂ :=
  Iff.intro
    (fun h => by
      rw [← reverse_reverse l₁, ← reverse_reverse l₂]
      exact rel_reverse h)
    fun h => rel_reverse h

theorem rel_flatten : (Forall₂ (Forall₂ R) ⇒ Forall₂ R) flatten flatten
  | [], [], Forall₂.nil => Forall₂.nil
  | _, _, Forall₂.cons h₁ h₂ => rel_append h₁ (rel_flatten h₂)

theorem rel_flatMap : (Forall₂ R ⇒ (R ⇒ Forall₂ P) ⇒ Forall₂ P)
    (Function.swap List.flatMap) (Function.swap List.flatMap) :=
  fun _ _ h₁ _ _ h₂ => rel_flatten (rel_map (@h₂) h₁)

theorem rel_foldl : ((P ⇒ R ⇒ P) ⇒ P ⇒ Forall₂ R ⇒ P) foldl foldl
  | _, _, _, _, _, h, _, _, Forall₂.nil => h
  | _, _, hfg, _, _, hxy, _, _, Forall₂.cons hab hs => rel_foldl (@hfg) (hfg hxy hab) hs

theorem rel_foldr : ((R ⇒ P ⇒ P) ⇒ P ⇒ Forall₂ R ⇒ P) foldr foldr
  | _, _, _, _, _, h, _, _, Forall₂.nil => h
  | _, _, hfg, _, _, hxy, _, _, Forall₂.cons hab hs => hfg hab (rel_foldr (@hfg) hxy hs)

theorem rel_filter {p : α → Bool} {q : β → Bool}
    (hpq : (R ⇒ (· ↔ ·)) (fun x => p x) (fun x => q x)) :
    (Forall₂ R ⇒ Forall₂ R) (filter p) (filter q)
  | _, _, Forall₂.nil => Forall₂.nil
  | a :: as, b :: bs, Forall₂.cons h₁ h₂ => by
    dsimp [LiftFun] at hpq
    by_cases h : p a
    · have : q b := by rwa [← hpq h₁]
      simp only [filter_cons_of_pos h, filter_cons_of_pos this, forall₂_cons, h₁, true_and,
        rel_filter hpq h₂]
    · have : ¬q b := by rwa [← hpq h₁]
      simp only [filter_cons_of_neg h, filter_cons_of_neg this, rel_filter hpq h₂]

theorem rel_filterMap : ((R ⇒ Option.Rel P) ⇒ Forall₂ R ⇒ Forall₂ P) filterMap filterMap
  | _, _, _, _, _, Forall₂.nil => Forall₂.nil
  | f, g, hfg, a :: as, b :: bs, Forall₂.cons h₁ h₂ => by
    rw [filterMap_cons, filterMap_cons]
    exact
      match f a, g b, hfg h₁ with
      | _, _, Option.Rel.none => rel_filterMap (@hfg) h₂
      | _, _, Option.Rel.some h => Forall₂.cons h (rel_filterMap (@hfg) h₂)

/-- Given a relation `R`, `sublist_forall₂ r l₁ l₂` indicates that there is a sublist of `l₂` such
  that `forall₂ r l₁ l₂`. -/

inductive SublistForall₂ (R : α → β → Prop) : List α → List β → Prop
  | nil {l} : SublistForall₂ R [] l
  | cons {a₁ a₂ l₁ l₂} : R a₁ a₂ → SublistForall₂ R l₁ l₂ → SublistForall₂ R (a₁ :: l₁) (a₂ :: l₂)
  | cons_right {a l₁ l₂} : SublistForall₂ R l₁ l₂ → SublistForall₂ R l₁ (a :: l₂)

theorem sublistForall₂_iff {l₁ : List α} {l₂ : List β} :
    SublistForall₂ R l₁ l₂ ↔ ∃ l, Forall₂ R l₁ l ∧ l <+ l₂ := by
  constructor <;> intro h
  · induction h with
    | nil => exact ⟨nil, Forall₂.nil, nil_sublist _⟩
    | @cons a b l1 l2 rab _ ih =>
      obtain ⟨l, hl1, hl2⟩ := ih
      exact ⟨b :: l, Forall₂.cons rab hl1, hl2.cons_cons b⟩
    | cons_right _ ih =>
      obtain ⟨l, hl1, hl2⟩ := ih
      exact ⟨l, hl1, hl2.trans (Sublist.cons _ (Sublist.refl _))⟩
  · obtain ⟨l, hl1, hl2⟩ := h
    revert l₁
    induction hl2 with
    | slnil =>
      intro l₁ hl1
      rw [forall₂_nil_right_iff.1 hl1]
      exact SublistForall₂.nil
    | cons _ _ ih => intro l₁ hl1; exact SublistForall₂.cons_right (ih hl1)
    | cons_cons _ _ ih =>
      intro l₁ hl1
      obtain - | ⟨hr, hl⟩ := hl1
      exact SublistForall₂.cons hr (ih hl)

instance SublistForall₂.is_refl [Std.Refl Rₐ] : Std.Refl (SublistForall₂ Rₐ) :=
  ⟨fun l => sublistForall₂_iff.2 ⟨l, forall₂_refl l, Sublist.refl l⟩⟩

instance SublistForall₂.is_trans [IsTrans α Rₐ] : IsTrans (List α) (SublistForall₂ Rₐ) :=
  ⟨fun a b c => by
    revert a b
    induction c with
    | nil =>
      rintro _ _ h1 h2
      cases h2
      exact h1
    | cons _ _ ih =>
      rintro a b h1 h2
      obtain - | ⟨hbc, tbc⟩ | btc := h2
      · cases h1
        exact SublistForall₂.nil
      · obtain - | ⟨hab, tab⟩ | atb := h1
        · exact SublistForall₂.nil
        · exact SublistForall₂.cons (_root_.trans hab hbc) (ih _ _ tab tbc)
        · exact SublistForall₂.cons_right (ih _ _ atb tbc)
      · exact SublistForall₂.cons_right (ih _ _ h1 btc)⟩

theorem Sublist.sublistForall₂ {l₁ l₂ : List α} (h : l₁ <+ l₂) [Std.Refl Rₐ] :
    SublistForall₂ Rₐ l₁ l₂ :=
  sublistForall₂_iff.2 ⟨l₁, forall₂_refl l₁, h⟩

theorem tail_sublistForall₂_self [Std.Refl Rₐ] (l : List α) : SublistForall₂ Rₐ l.tail l :=
  l.tail_sublist.sublistForall₂

@[simp]
theorem sublistForall₂_map_left_iff {f : γ → α} {l₁ : List γ} {l₂ : List β} :
    SublistForall₂ R (map f l₁) l₂ ↔ SublistForall₂ (fun c b => R (f c) b) l₁ l₂ := by
  simp [sublistForall₂_iff]

@[simp]
theorem sublistForall₂_map_right_iff {f : γ → β} {l₁ : List α} {l₂ : List γ} :
    SublistForall₂ R l₁ (map f l₂) ↔ SublistForall₂ (fun a c => R a (f c)) l₁ l₂ := by
  simp only [sublistForall₂_iff]
  constructor
  · rintro ⟨l1, h1, h2⟩
    obtain ⟨l', hl1, rfl⟩ := sublist_map_iff.mp h2
    use l'
    simpa [hl1] using h1
  · rintro ⟨l1, h1, h2⟩
    use l1.map f
    simp [h1, h2.map]

end List

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*Bot Zugriff