chars int64 40 24k | content_type stringclasses 9
values | id stringlengths 13 64 | source stringclasses 5
values | subset stringclasses 31
values | text stringlengths 40 24k |
|---|---|---|---|---|---|
355 | leanexplore_declaration | leanexplore:387219 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem append_append_ωSequence : ∀ (l₁ l₂ : List α) (s : ωSequence α),
l₁ ++ l₂ ++ω s = l₁ ++ω (l₂ ++ω s)
| [], _, _ => rfl
| List.cons a l₁, l₂, s => by
rw [List.cons_append, cons_append_ωSequence, cons_append_ωSequence, append_append_ωSequence l₁]
lemma get_append_left (h : n < x... |
238 | leanexplore_declaration | leanexplore:387220 | leanexplore_sqlite | leanexplore_declarations | lemma get_append_left (h : n < x.length) : (x ++ω a) n = x[n] := by
induction x generalizing n with
| nil => simp at h
| cons b x ih =>
rcases n with (_ | n)
· simp
· simp [ih n (by simpa using h), cons_append_ωSequence] |
149 | leanexplore_declaration | leanexplore:387221 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma get_append_right : (x ++ω a) (x.length + n) = a n := by
induction x <;> simp [Nat.succ_add, *, cons_append_ωSequence] |
274 | leanexplore_declaration | leanexplore:387222 | leanexplore_sqlite | leanexplore_declarations | theorem get_append_right' {xl : List α} {xs : ωSequence α} {k : ℕ} (h : xl.length ≤ k) :
(xl ++ω xs) k = xs (k - xl.length) := by
obtain ⟨n, rfl⟩ := show ∃ n, k = xl.length + n by use (k - xl.length); omega
simp only [Nat.add_sub_cancel_left]; apply get_append_right |
100 | leanexplore_declaration | leanexplore:387223 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma get_append_length : (x ++ω a) x.length = a 0 := get_append_right 0 x a |
142 | leanexplore_declaration | leanexplore:387224 | leanexplore_sqlite | leanexplore_declarations | lemma append_right_injective (h : x ++ω a = x ++ω b) : a = b := by
ext n; replace h := congr_arg (fun a ↦ a (x.length + n)) h; simpa using h |
131 | leanexplore_declaration | leanexplore:387225 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma append_right_inj : x ++ω a = x ++ω b ↔ a = b :=
⟨append_right_injective x a b, by simp +contextual⟩ |
176 | leanexplore_declaration | leanexplore:387226 | leanexplore_sqlite | leanexplore_declarations | lemma append_left_injective (h : x ++ω a = y ++ω b) (hl : x.length = y.length) : x = y := by
apply List.ext_getElem hl
intros
rw [← get_append_left, ← get_append_left, h] |
223 | leanexplore_declaration | leanexplore:387227 | leanexplore_sqlite | leanexplore_declarations | theorem append_left_right_injective (l1 l2 : List α) (s1 s2 : ωSequence α)
(h1 : l1 ++ω s1 = l2 ++ω s2) (h2 : l1.length = l2.length) : l1 = l2 ∧ s1 = s2 := by
have h3 := append_left_injective l1 l2 s1 s2 h1 h2
grind |
278 | leanexplore_declaration | leanexplore:387228 | leanexplore_sqlite | leanexplore_declarations | theorem map_append_ωSequence (f : α → β) :
∀ (l : List α) (s : ωSequence α), map f (l ++ω s) = List.map f l ++ω map f s
| [], _ => rfl
| List.cons a l, s => by
rw [cons_append_ωSequence, List.map_cons, map_cons,
cons_append_ωSequence, map_append_ωSequence f l] |
235 | leanexplore_declaration | leanexplore:387229 | leanexplore_sqlite | leanexplore_declarations | theorem drop_append_ωSequence : ∀ (l : List α) (s : ωSequence α), drop l.length (l ++ω s) = s
| [], s => rfl
| List.cons a l, s => by
rw [List.length_cons, drop_succ, cons_append_ωSequence, tail_cons, drop_append_ωSequence l s] |
91 | leanexplore_declaration | leanexplore:387230 | leanexplore_sqlite | leanexplore_declarations | theorem append_ωSequence_head_tail (s : ωSequence α) : [head s] ++ω tail s = s := by
simp |
84 | leanexplore_declaration | leanexplore:387231 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem take_zero (s : ωSequence α) : take 0 s = [] :=
rfl |
98 | leanexplore_declaration | leanexplore:387232 | leanexplore_sqlite | leanexplore_declarations | theorem take_succ (n : ℕ) (s : ωSequence α) : take (succ n) s = head s :: take n (tail s) :=
rfl |
130 | leanexplore_declaration | leanexplore:387233 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem take_succ_cons {a : α} (n : ℕ) (s : ωSequence α) :
take (n+1) (a ::ω s) = a :: take n s := rfl |
175 | leanexplore_declaration | leanexplore:387234 | leanexplore_sqlite | leanexplore_declarations | theorem take_succ' {s : ωSequence α} : ∀ n, s.take (n+1) = s.take n ++ [s n]
| 0 => rfl
| n+1 => by rw [take_succ, take_succ' n, ← List.cons_append, ← take_succ, get_tail] |
109 | leanexplore_declaration | leanexplore:387235 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem take_one {xs : ωSequence α} :
xs.take 1 = [xs 0] := by
simp [take_succ] |
152 | leanexplore_declaration | leanexplore:387236 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem length_take (n : ℕ) (s : ωSequence α) : (take n s).length = n := by
induction n generalizing s <;> simp [*, take_succ] |
437 | leanexplore_declaration | leanexplore:387237 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem take_take {s : ωSequence α} : ∀ {m n}, (s.take n).take m = s.take (min n m)
| 0, n => by rw [Nat.min_zero, List.take_zero, take_zero]
| m, 0 => by rw [Nat.zero_min, take_zero, List.take_nil]
| m+1, n+1 => by rw [take_succ, List.take_succ_cons, Nat.succ_min_succ, take_succ, take_tak... |
135 | leanexplore_declaration | leanexplore:387238 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem concat_take_get {n : ℕ} {s : ωSequence α} : s.take n ++ [s n] = s.take (n + 1) :=
(take_succ' n).symm |
290 | leanexplore_declaration | leanexplore:387239 | leanexplore_sqlite | leanexplore_declarations | theorem getElem?_take {s : ωSequence α} : ∀ {k n}, k < n → (s.take n)[k]? = s k
| 0, _+1, _ => by simp only [length_take, zero_lt_succ, List.getElem?_eq_getElem]; rfl
| k+1, n+1, h => by
rw [take_succ, List.getElem?_cons_succ, getElem?_take (Nat.lt_of_succ_lt_succ h), get_succ k s] |
133 | leanexplore_declaration | leanexplore:387240 | leanexplore_sqlite | leanexplore_declarations | theorem getElem?_take_succ (n : ℕ) (s : ωSequence α) :
(take (succ n) s)[n]? = some (s n) :=
getElem?_take (Nat.lt_succ_self n) |
246 | leanexplore_declaration | leanexplore:387241 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem dropLast_take {n : ℕ} {xs : ωSequence α} :
(ωSequence.take n xs).dropLast = ωSequence.take (n-1) xs := by
cases n with
| zero => simp
| succ n => rw [take_succ', List.dropLast_concat, Nat.add_one_sub_one] |
267 | leanexplore_declaration | leanexplore:387242 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem append_take_drop (n : ℕ) (s : ωSequence α) : appendωSequence (take n s) (drop n s) = s := by
induction n generalizing s with
| zero => rfl
| succ n ih =>rw [take_succ, drop_succ, cons_append_ωSequence, ih (tail s), ωSequence.eta] |
143 | leanexplore_declaration | leanexplore:387243 | leanexplore_sqlite | leanexplore_declarations | lemma append_take : x ++ (a.take n) = (x ++ω a).take (x.length + n) := by
induction x <;> simp [take, Nat.add_comm, cons_append_ωSequence, *] |
152 | leanexplore_declaration | leanexplore:387244 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma take_get (h : m < (a.take n).length) : (a.take n)[m] = a m := by
nth_rw 2 [← append_take_drop n a]; rw [get_append_left] |
195 | leanexplore_declaration | leanexplore:387245 | leanexplore_sqlite | leanexplore_declarations | theorem take_append_of_le_length (h : n ≤ x.length) :
(x ++ω a).take n = x.take n := by
apply List.ext_getElem (by simp [h])
intro _ _ _; rw [List.getElem_take, take_get, get_append_left] |
167 | leanexplore_declaration | leanexplore:387246 | leanexplore_sqlite | leanexplore_declarations | lemma take_add : a.take (m + n) = a.take m ++ (a.drop m).take n := by
apply append_left_injective _ _ (a.drop (m + n)) ((a.drop m).drop n) <;>
simp [- drop_drop] |
144 | leanexplore_declaration | leanexplore:387248 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
lemma take_prefix : a.take m <+: a.take n ↔ m ≤ n :=
⟨fun h ↦ by simpa using h.length_le, take_prefix_take_left m n a⟩ |
455 | leanexplore_declaration | leanexplore:387251 | leanexplore_sqlite | leanexplore_declarations | lemma drop_append_of_le_length (h : n ≤ x.length) :
(x ++ω a).drop n = x.drop n ++ω a := by
obtain ⟨m, hm⟩ := Nat.exists_eq_add_of_le h
ext k; rcases lt_or_ge k m with _ | hk
· rw [get_drop, get_append_left, get_append_left, List.getElem_drop]; simpa [hm]
· obtain ⟨p, rfl⟩ := Nat.exists_eq_add_of_le hk
... |
231 | leanexplore_declaration | leanexplore:387252 | leanexplore_sqlite | leanexplore_declarations | theorem drop_append_of_ge_length {xl : List α} {xs : ωSequence α} {n : ℕ} (h : xl.length ≤ n) :
(xl ++ω xs).drop n = xs.drop (n - xl.length) := by
ext k; simp (disch := omega) only [get_drop, get_append_right']
congr; omega |
321 | leanexplore_declaration | leanexplore:387253 | leanexplore_sqlite | leanexplore_declarations | theorem take_theorem (s₁ s₂ : ωSequence α) (h : ∀ n : ℕ, take n s₁ = take n s₂) : s₁ = s₂ := by
ext n
induction n with
| zero => simpa [take] using h 1
| succ n =>
have h₁ : some (s₁ (succ n)) = some (s₂ (succ n)) := by
rw [← getElem?_take_succ, ← getElem?_take_succ, h (succ (succ n))]
injection h... |
117 | leanexplore_declaration | leanexplore:387254 | leanexplore_sqlite | leanexplore_declarations | theorem extract_eq_drop_take {xs : ωSequence α} {m n : ℕ} :
xs.extract m n = take (n - m) (xs.drop m) := by
rfl |
216 | leanexplore_declaration | leanexplore:387255 | leanexplore_sqlite | leanexplore_declarations | theorem extract_eq_ofFn {xs : ωSequence α} {m n : ℕ} :
xs.extract m n = List.ofFn (fun k : Fin (n - m) ↦ xs (m + k)) := by
ext k; cases Decidable.em (k < n - m) <;>
grind [extract_eq_drop_take, getElem?_take] |
337 | leanexplore_declaration | leanexplore:387256 | leanexplore_sqlite | leanexplore_declarations | theorem extract_eq_extract {xs xs' : ωSequence α} {m n m' n' : ℕ}
(h : xs.extract m n = xs'.extract m' n') :
n - m = n' - m' ∧ ∀ k < n - m, xs (m + k) = xs' (m' + k) := by
simp only [extract_eq_ofFn, List.ofFn_inj', Sigma.mk.injEq] at h
obtain ⟨h_eq, h_fun⟩ := h
rw [← h_eq] at h_fun
simp_all [funext_iff... |
119 | leanexplore_declaration | leanexplore:387257 | leanexplore_sqlite | leanexplore_declarations | theorem extract_eq_take {xs : ωSequence α} {n : ℕ} :
xs.extract 0 n = xs.take n := by
simp [extract_eq_drop_take] |
171 | leanexplore_declaration | leanexplore:387258 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem append_extract_drop {xs : ωSequence α} {n : ℕ} :
(xs.extract 0 n) ++ω (xs.drop n) = xs := by
simp [extract_eq_take, append_take_drop] |
235 | leanexplore_declaration | leanexplore:387259 | leanexplore_sqlite | leanexplore_declarations | theorem extract_append_right_right {xl : List α} {xs : ωSequence α} {m n : ℕ} (h : xl.length ≤ m) :
(xl ++ω xs).extract m n = xs.extract (m - xl.length) (n - xl.length) := by
grind [extract_eq_drop_take, drop_append_of_ge_length] |
281 | leanexplore_declaration | leanexplore:387260 | leanexplore_sqlite | leanexplore_declarations | theorem extract_append_zero_right {xl : List α} {xs : ωSequence α} {n : ℕ} (h : xl.length ≤ n) :
(xl ++ω xs).extract 0 n = xl ++ (xs.extract 0 (n - xl.length)) := by
obtain ⟨k, rfl⟩ : ∃ k, n = xl.length + k := ⟨n - xl.length, by omega⟩
simp [extract_eq_take, ← append_take] |
147 | leanexplore_declaration | leanexplore:387261 | leanexplore_sqlite | leanexplore_declarations | theorem extract_drop {xs : ωSequence α} {k m n : ℕ} :
(xs.drop k).extract m n = xs.extract (k + m) (k + n) := by
grind [extract_eq_drop_take] |
149 | leanexplore_declaration | leanexplore:387262 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem length_extract {xs : ωSequence α} {m n : ℕ} :
(xs.extract m n).length = n - m := by
simp [extract_eq_drop_take] |
135 | leanexplore_declaration | leanexplore:387263 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem extract_eq_nil {xs : ωSequence α} {n : ℕ} :
xs.extract n n = [] := by
simp [extract_eq_drop_take] |
183 | leanexplore_declaration | leanexplore:387264 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem extract_eq_nil_iff {xs : ωSequence α} {m n : ℕ} :
xs.extract m n = [] ↔ m ≥ n := by
rw [← List.length_eq_zero_iff]
grind [extract_eq_drop_take] |
179 | leanexplore_declaration | leanexplore:387265 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem get_extract {xs : ωSequence α} {m n k : ℕ} (h : k < n - m) :
(xs.extract m n)[k]'(by simp [h]) = xs (m + k) := by
simp [extract_eq_drop_take] |
245 | leanexplore_declaration | leanexplore:387266 | leanexplore_sqlite | leanexplore_declarations | theorem append_extract_extract {xs : ωSequence α} {k m n : ℕ} (h_km : k ≤ m) (h_mn : m ≤ n) :
(xs.extract k m) ++ (xs.extract m n) = xs.extract k n := by
have : n - k = (m - k) + (n - m) := by grind
grind [extract_eq_drop_take, take_add] |
242 | leanexplore_declaration | leanexplore:387267 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
theorem extract_succ_right {xs : ωSequence α} {m n : ℕ} (h_mn : m ≤ n) :
xs.extract m (n + 1) = xs.extract m n ++ [xs n] := by
rw [← append_extract_extract h_mn] <;>
grind [extract_eq_drop_take, add_tsub_cancel_left] |
241 | leanexplore_declaration | leanexplore:387268 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem extract_lu_extract_lu {xs : ωSequence α} {m n i j : ℕ} (h : j ≤ n - m) :
(xs.extract m n).extract i j = xs.extract (m + i) (m + j) := by
ext k
cases Decidable.em (k < j - i) <;> grind [extract_eq_ofFn] |
156 | leanexplore_declaration | leanexplore:387269 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
theorem extract_0u_extract_lu {xs : ωSequence α} {n i j : ℕ} (h : j ≤ n) :
(xs.extract 0 n).extract i j = xs.extract i j := by
grind |
139 | leanexplore_declaration | leanexplore:387270 | leanexplore_sqlite | leanexplore_declarations | @[scoped grind =]
theorem extract_0u_extract_l {xs : ωSequence α} {n i : ℕ} :
(xs.extract 0 n).extract i = xs.extract i n := by
grind |
204 | leanexplore_declaration | leanexplore:387271 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem take_extract {xs : ωSequence α} {m n k : ℕ} (h : k ≤ n - m) :
(xs.extract m n).take k = xs.extract m (m + k) := by
grind [extract_lu_extract_lu (xs := xs) (i := 0) h] |
276 | leanexplore_declaration | leanexplore:387272 | leanexplore_sqlite | leanexplore_declarations | @[simp, scoped grind =]
theorem drop_extract {xs : ωSequence α} {m n k : ℕ} (h : k ≤ n - m) :
(xs.extract m n).drop k = xs.extract (m + k) n := by
have := extract_lu_extract_lu (xs := xs) (m := m) (n := n) (i := k) (j := n - m)
grind [length_extract, List.take_length] |
213 | leanexplore_declaration | leanexplore:387273 | leanexplore_sqlite | leanexplore_declarations | /-- `Step p q` means that whenever `p` holds at a position in `xs`, `q` holds at the next position
in `xs`. -/
@[scoped grind =]
def Step (xs : ωSequence α) (p q : Set α) : Prop :=
∀ k, xs k ∈ p → xs (k + 1) ∈ q |
245 | leanexplore_declaration | leanexplore:387274 | leanexplore_sqlite | leanexplore_declarations | /-- "`p` leads to `q`" means that whenever `p` holds at a position in `xs`, `q` holds at the same
or a later position in `xs`. -/
@[scoped grind =]
def LeadsTo (xs : ωSequence α) (p q : Set α) : Prop :=
∀ k, xs k ∈ p → ∃ k', k ≤ k' ∧ xs k' ∈ q |
116 | leanexplore_declaration | leanexplore:387275 | leanexplore_sqlite | leanexplore_declarations | /-- `Step` implies `LeadsTo`. -/
theorem step_leadsTo {p q : Set α} (h : xs.Step p q) : xs.LeadsTo p q := by
grind |
148 | leanexplore_declaration | leanexplore:387276 | leanexplore_sqlite | leanexplore_declarations | /-- `LeadsTo` is transitive. -/
theorem leadsTo_trans {p q r : Set α}
(h1 : xs.LeadsTo p q) (h2 : xs.LeadsTo q r) : xs.LeadsTo p r := by
grind |
225 | leanexplore_declaration | leanexplore:387277 | leanexplore_sqlite | leanexplore_declarations | /-- If `p ∩ q` leads to `r` and `p ∩ qᶜ` leads to `s`, then `p` leads to `r ∪ s`. -/
theorem leadsTo_cases_or {p q r s : Set α}
(h1 : xs.LeadsTo (p ∩ q) r) (h2 : xs.LeadsTo (p ∩ qᶜ) s) : xs.LeadsTo p (r ∪ s) := by
grind |
421 | leanexplore_declaration | leanexplore:387278 | leanexplore_sqlite | leanexplore_declarations | /-- If `p` holds until `q` and `p` fails infinitely often, then `p` leads to `q`. -/
theorem until_frequently_not_leadsTo {p q : Set α}
(h1 : xs.Step (p ∩ qᶜ) p) (h2 : ∃ᶠ k in atTop, xs k ∉ p) : xs.LeadsTo p q := by
intro k h_p
by_contra! h_q
suffices ∀ k' ≥ k, xs k' ∈ p by
have := frequently_atTop.mp h2 ... |
439 | leanexplore_declaration | leanexplore:387279 | leanexplore_sqlite | leanexplore_declarations | /-- If `p` holds until `q` and `q` holds infinite often, then `p` leads to `p ∩ q`. -/
theorem until_frequently_leadsTo_and {p q : Set α}
(h1 : xs.Step (p ∩ qᶜ) p) (h2 : ∃ᶠ k in atTop, xs k ∈ q) : xs.LeadsTo p (p ∩ q) := by
intro k h_p
by_contra! h_not_pq
suffices ∀ k' ≥ k, xs k' ∈ p ∩ qᶜ by
have := frequ... |
305 | leanexplore_declaration | leanexplore:387280 | leanexplore_sqlite | leanexplore_declarations | /-- If `p` holds infinitely often and `p` leads to `q`, then `q` holds infinite often as well. -/
theorem frequently_leadsTo_frequently {p q : Set α}
(h1 : ∃ᶠ k in atTop, xs k ∈ p) (h2 : xs.LeadsTo p q) : ∃ᶠ k in atTop, xs k ∈ q := by
rw [frequently_atTop] at h1 ⊢
intro k0
have := h1 k0
grind |
287 | leanexplore_declaration | leanexplore:387281 | leanexplore_sqlite | leanexplore_declarations | theorem drop_frequently_iff_frequently {p : Set α} (n : ℕ) :
(∃ᶠ k in atTop, (xs.drop n) k ∈ p) ↔ (∃ᶠ k in atTop, xs k ∈ p) := by
simp only [frequently_atTop, get_drop]
constructor
· intro h m
grind [h m]
· intro h m
obtain ⟨k, _⟩ := h (m + n)
use k - n
grind |
433 | leanexplore_declaration | leanexplore:387282 | leanexplore_sqlite | leanexplore_declarations | /--
A relation `r` relates two elements of `α` in `n` steps
if there is a chain of `n` pairs `(t_i, t_{i+1})` such that `r t_i t_{i+1}` for each `i`,
starting from the first element and ending at the second.
-/
inductive RelatesInSteps (r : α → α → Prop) : α → α → ℕ → Prop
| refl (a : α) : RelatesInSteps r a a 0
| ... |
115 | leanexplore_declaration | leanexplore:387284 | leanexplore_sqlite | leanexplore_declarations | | tail (t t' t'' : α) (n : ℕ) (h₁ : RelatesInSteps r t t' n) (h₂ : r t' t'') :
RelatesInSteps r t t'' (n + 1) |
168 | leanexplore_declaration | leanexplore:387285 | leanexplore_sqlite | leanexplore_declarations | theorem RelatesInSteps.reflTransGen (h : RelatesInSteps r a b n) : ReflTransGen r a b := by
induction h with
| refl => rfl
| tail _ _ _ _ h ih => exact .tail ih h |
234 | leanexplore_declaration | leanexplore:387286 | leanexplore_sqlite | leanexplore_declarations | theorem ReflTransGen.relatesInSteps (h : ReflTransGen r a b) : ∃ n, RelatesInSteps r a b n := by
induction h with
| refl => exact ⟨0, .refl a⟩
| tail _ _ ih =>
obtain ⟨n, _⟩ := ih
exact ⟨n + 1, by grind [RelatesInSteps]⟩ |
103 | leanexplore_declaration | leanexplore:387287 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.single {a b : α} (h : r a b) : RelatesInSteps r a b 1 :=
tail a a b 0 (refl a) h |
255 | leanexplore_declaration | leanexplore:387288 | leanexplore_sqlite | leanexplore_declarations | theorem RelatesInSteps.head (t t' t'' : α) (n : ℕ) (h₁ : r t t')
(h₂ : RelatesInSteps r t' t'' n) : RelatesInSteps r t t'' (n+1) := by
induction h₂ with
| refl =>
exact single h₁
| tail _ _ n _ hcd hac =>
exact tail _ _ _ (n + 1) hac hcd |
544 | leanexplore_declaration | leanexplore:387289 | leanexplore_sqlite | leanexplore_declarations | @[elab_as_elim]
theorem RelatesInSteps.head_induction_on {motive : ∀ (a : α) (n : ℕ), RelatesInSteps r a b n → Prop}
{a : α} {n : ℕ} (h : RelatesInSteps r a b n) (hrefl : motive b 0 (.refl b))
(hhead : ∀ {a c n} (h' : r a c) (h : RelatesInSteps r c b n),
motive c n h → motive a (n + 1) (h.head a c b n h')... |
94 | leanexplore_declaration | leanexplore:387290 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.zero {a b : α} (h : RelatesInSteps r a b 0) : a = b := by
cases h
rfl |
176 | leanexplore_declaration | leanexplore:387291 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma RelatesInSteps.zero_iff {a b : α} : RelatesInSteps r a b 0 ↔ a = b := by
constructor
· exact RelatesInSteps.zero
· intro rfl
exact RelatesInSteps.refl a |
321 | leanexplore_declaration | leanexplore:387292 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.trans {a b c : α} {n m : ℕ}
(h₁ : RelatesInSteps r a b n) (h₂ : RelatesInSteps r b c m) :
RelatesInSteps r a c (n + m) := by
induction h₂ generalizing a n with
| refl => simp [h₁]
| tail t' t'' k hsteps hstep ih =>
rw [← Nat.add_assoc]
exact .tail _ t' t'' (n + k) (ih h₁) hste... |
192 | leanexplore_declaration | leanexplore:387293 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.succ {n : ℕ} (h : RelatesInSteps r a b (n + 1)) :
∃ t', RelatesInSteps r a t' n ∧ r t' b := by
cases h with
| tail t' _ _ hsteps hstep => exact ⟨t', hsteps, hstep⟩ |
244 | leanexplore_declaration | leanexplore:387294 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.succ_iff {a b : α} {n : ℕ} :
RelatesInSteps r a b (n + 1) ↔ ∃ t', RelatesInSteps r a t' n ∧ r t' b := by
constructor
· exact RelatesInSteps.succ
· rintro ⟨t', h_steps, h_red⟩
exact .tail _ t' b n h_steps h_red |
413 | leanexplore_declaration | leanexplore:387295 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.succ' {a b : α} : ∀ {n : ℕ}, RelatesInSteps r a b (n + 1) →
∃ t', r a t' ∧ RelatesInSteps r t' b n := by
intro n h
obtain ⟨t', hsteps, hstep⟩ := succ h
cases n with
| zero =>
rw [zero_iff] at hsteps
subst hsteps
exact ⟨b, hstep, .refl _⟩
| succ k' =>
obtain ⟨t''', h_re... |
230 | leanexplore_declaration | leanexplore:387296 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesInSteps.succ'_iff {a b : α} {n : ℕ} :
RelatesInSteps r a b (n + 1) ↔ ∃ t', r a t' ∧ RelatesInSteps r t' b n := by
constructor
· exact succ'
· rintro ⟨t', h_red, h_steps⟩
exact h_steps.head a t' b n h_red |
450 | leanexplore_declaration | leanexplore:387297 | leanexplore_sqlite | leanexplore_declarations | /--
If `h : α → ℕ` increases by at most 1 on each step of `r`,
then the value of `h` at the output is at most `h` at the input plus the number of steps.
-/
lemma RelatesInSteps.apply_le_apply_add {a b : α} {m : ℕ} (hevals : RelatesInSteps r a b m)
(h : α → ℕ) (h_step : ∀ a b, r a b → h b ≤ h a + 1) :
h b ≤ h a ... |
528 | leanexplore_declaration | leanexplore:387298 | leanexplore_sqlite | leanexplore_declarations | /--
If `g` is a homomorphism from `r` to `r'` (i.e., it preserves the reduction relation),
then `RelatesInSteps` is preserved under `g`.
-/
lemma RelatesInSteps.map {α α' : Type*}
{r : α → α → Prop} {r' : α' → α' → Prop}
(g : α → α') (hg : ∀ a b, r a b → r' (g a) (g b))
{a b : α} {n : ℕ} (h : RelatesInSteps... |
253 | leanexplore_declaration | leanexplore:387299 | leanexplore_sqlite | leanexplore_declarations | /--
`RelatesWithinSteps` is a variant of `RelatesInSteps` that allows for a loose bound.
It states that `a` relates to `b` in *at most* `n` steps.
-/
def RelatesWithinSteps (r : α → α → Prop) (a b : α) (n : ℕ) : Prop :=
∃ m ≤ n, RelatesInSteps r a b m |
223 | leanexplore_declaration | leanexplore:387300 | leanexplore_sqlite | leanexplore_declarations | /-- `RelatesInSteps` implies `RelatesWithinSteps` with the same bound. -/
lemma RelatesWithinSteps.of_relatesInSteps {a b : α} {n : ℕ} (h : RelatesInSteps r a b n) :
RelatesWithinSteps r a b n :=
⟨n, Nat.le_refl n, h⟩ |
132 | leanexplore_declaration | leanexplore:387301 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesWithinSteps.refl (a : α) : RelatesWithinSteps r a a 0 :=
RelatesWithinSteps.of_relatesInSteps (RelatesInSteps.refl a) |
150 | leanexplore_declaration | leanexplore:387302 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesWithinSteps.single {a b : α} (h : r a b) : RelatesWithinSteps r a b 1 :=
RelatesWithinSteps.of_relatesInSteps (RelatesInSteps.single h) |
200 | leanexplore_declaration | leanexplore:387303 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesWithinSteps.zero {a b : α} (h : RelatesWithinSteps r a b 0) : a = b := by
obtain ⟨m, hm, hevals⟩ := h
have : m = 0 := Nat.le_zero.mp hm
subst this
exact RelatesInSteps.zero hevals |
202 | leanexplore_declaration | leanexplore:387304 | leanexplore_sqlite | leanexplore_declarations | @[simp]
lemma RelatesWithinSteps.zero_iff {a b : α} : RelatesWithinSteps r a b 0 ↔ a = b := by
constructor
· exact RelatesWithinSteps.zero
· intro h
subst h
exact RelatesWithinSteps.refl a |
410 | leanexplore_declaration | leanexplore:387305 | leanexplore_sqlite | leanexplore_declarations | /-- Transitivity of `RelatesWithinSteps` in the sum of the step bounds. -/
@[trans]
lemma RelatesWithinSteps.trans {a b c : α} {n₁ n₂ : ℕ}
(h₁ : RelatesWithinSteps r a b n₁) (h₂ : RelatesWithinSteps r b c n₂) :
RelatesWithinSteps r a c (n₁ + n₂) := by
obtain ⟨m₁, hm₁, hevals₁⟩ := h₁
obtain ⟨m₂, hm₂, hevals₂... |
215 | leanexplore_declaration | leanexplore:387306 | leanexplore_sqlite | leanexplore_declarations | lemma RelatesWithinSteps.of_le {a b : α} {n₁ n₂ : ℕ}
(h : RelatesWithinSteps r a b n₁) (hn : n₁ ≤ n₂) :
RelatesWithinSteps r a b n₂ := by
obtain ⟨m, hm, hevals⟩ := h
exact ⟨m, Nat.le_trans hm hn, hevals⟩ |
441 | leanexplore_declaration | leanexplore:387307 | leanexplore_sqlite | leanexplore_declarations | /-- If `h : α → ℕ` increases by at most 1 on each step of `r`,
then the value of `h` at the output is at most `h` at the input plus the step bound. -/
lemma RelatesWithinSteps.apply_le_apply_add {a b : α} {m : ℕ} (hevals : RelatesWithinSteps r a b m)
(h : α → ℕ) (h_step : ∀ a b, r a b → h b ≤ h a + 1)
:
h b... |
463 | leanexplore_declaration | leanexplore:387308 | leanexplore_sqlite | leanexplore_declarations | /--
If `g` is a homomorphism from `r` to `r'` (i.e., it preserves the reduction relation),
then `RelatesWithinSteps` is preserved under `g`.
-/
lemma RelatesWithinSteps.map {α α' : Type*} {r : α → α → Prop} {r' : α' → α' → Prop}
(g : α → α') (hg : ∀ a b, r a b → r' (g a) (g b))
{a b : α} {n : ℕ} (h : RelatesWit... |
164 | leanexplore_declaration | leanexplore:387309 | leanexplore_sqlite | leanexplore_declarations | theorem WellFounded.ofTransGen (trans_wf : WellFounded (Relation.TransGen r)) : WellFounded r := by
grind [WellFounded.wellFounded_iff_has_min, Relation.TransGen] |
129 | leanexplore_declaration | leanexplore:387310 | leanexplore_sqlite | leanexplore_declarations | @[simp, grind =]
theorem WellFounded.iff_transGen : WellFounded (Relation.TransGen r) ↔ WellFounded r :=
⟨ofTransGen, transGen⟩ |
168 | leanexplore_declaration | leanexplore:387311 | leanexplore_sqlite | leanexplore_declarations | /-- The empty (heterogeneous) relation, which always returns `False`. -/
@[nolint unusedArguments]
def emptyHRelation {α : Sort u} {β : Sort v} (_ : α) (_ : β) := False |
90 | leanexplore_declaration | leanexplore:387312 | leanexplore_sqlite | leanexplore_declarations | theorem ReflGen.to_eqvGen (h : ReflGen r a b) : EqvGen r a b := by
induction h <;> grind |
92 | leanexplore_declaration | leanexplore:387313 | leanexplore_sqlite | leanexplore_declarations | theorem TransGen.to_eqvGen (h : TransGen r a b) : EqvGen r a b := by
induction h <;> grind |
100 | leanexplore_declaration | leanexplore:387314 | leanexplore_sqlite | leanexplore_declarations | theorem ReflTransGen.to_eqvGen (h : ReflTransGen r a b) : EqvGen r a b := by
induction h <;> grind |
90 | leanexplore_declaration | leanexplore:387315 | leanexplore_sqlite | leanexplore_declarations | theorem SymmGen.to_eqvGen (h : SymmGen r a b) : EqvGen r a b := by
induction h <;> grind |
200 | leanexplore_declaration | leanexplore:387316 | leanexplore_sqlite | leanexplore_declarations | /-- The join of the reflexive transitive closure. This is not named in Mathlib, but see
`#loogle Relation.Join (Relation.ReflTransGen ?r)` -/
abbrev MJoin (r : α → α → Prop) := Join (ReflTransGen r) |
54 | leanexplore_declaration | leanexplore:387317 | leanexplore_sqlite | leanexplore_declarations | theorem MJoin.refl (a : α) : MJoin r a a := by
use a |
67 | leanexplore_declaration | leanexplore:387318 | leanexplore_sqlite | leanexplore_declarations | theorem MJoin.symm : Symmetric (MJoin r) := Relation.symmetric_join |
73 | leanexplore_declaration | leanexplore:387319 | leanexplore_sqlite | leanexplore_declarations | theorem MJoin.single (h : ReflTransGen r a b) : MJoin r a b := by
use b |
115 | leanexplore_declaration | leanexplore:387320 | leanexplore_sqlite | leanexplore_declarations | /-- The relation `r` 'up to' the relation `s`. -/
def UpTo (r s : α → α → Prop) : α → α → Prop := Comp s (Comp r s) |
175 | leanexplore_declaration | leanexplore:387321 | leanexplore_sqlite | leanexplore_declarations | /-- A relation has the diamond property when all reductions with a common origin are joinable -/
abbrev Diamond (r : α → α → Prop) := ∀ {a b c : α}, r a b → r a c → Join r b c |
158 | leanexplore_declaration | leanexplore:387322 | leanexplore_sqlite | leanexplore_declarations | /-- A relation is confluent when its reflexive transitive closure has the diamond property. -/
abbrev Confluent (r : α → α → Prop) := Diamond (ReflTransGen r) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.