Zulip Chat Archive

Stream: new members

Topic: tactic


Alex Zhang (Jul 16 2021 at 09:32):

I want to prove p or q, is there any tactic that changes the stage to having not p in the context and q as the goal?

example (p q : Prop) : p  q :=
begin

end

Alex Zhang (Jul 16 2021 at 09:34):

I can use by_cases p. Is there any one step tactic?

Mario Carneiro (Jul 16 2021 at 09:35):

there's always a one step tactic if the step is refine

Mario Carneiro (Jul 16 2021 at 09:36):

import logic.basic

example (p q : Prop) : p  q :=
begin
  refine or_iff_not_imp_left.2 (λ h, _),
end

Alex Zhang (Jul 23 2021 at 19:46):

Suppose I have four goals in the info view, does Lean have any feature that allows me to use some tactic, say rw [h], to only certain goals, say goals 2 and 3 only.

Alex J. Best (Jul 23 2021 at 19:59):

One way (if the rewrite only applies to those goals) is to use tactic#any_goals as any_goals { rw h } (or do all_goals { try { rw [h] }}) otherwise there have been some discussions, and example tactics doing this https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/work_on_goals.3F/near/193204723 and https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/work_on_goals/near/220310832. I'm not sure if either of them were ever PRed @Eric Wieser ?

Eric Rodriguez (Jul 23 2021 at 20:09):

Something I use a lot is the or else combiner, <|>. This does left tactic unless it fails, then it does right tactic

Eric Rodriguez (Jul 23 2021 at 20:10):

So all_goals { rw h orelse simp} usually works well for this sort of thing (sorry for formatting, on mobile)

Alex Zhang (Jul 23 2021 at 20:12):

If the other goals actually don't have h, will all_goals { try { rw [h] }} fail?

Eric Wieser (Jul 23 2021 at 20:33):

I ended up PRing improvements to tactic#case instead of any of the tactics in that thread.

Yakov Pechersky (Jul 23 2021 at 20:59):

No, it will not fail. You should use any_goals instead for that purpose, without the try.

Parivash (Feb 22 2022 at 21:17):

import analysis.specific_limits
import data.real.basic

lemma some_name (θ :   ) (a b C P q A V₀ Vads x : )
  (h1 :  k, θ k = C * x ^ k * θ 0) (hA : A = ∑' k, θ k)
  (hVads : Vads = V₀ * ∑' k : , k * θ k) (hq : q = Vads / A):
  q = a * P / ((1 - b * P) * (1 - b * P + C * P)) :=
begin
  simp only [h1] at hA {single_pass := tt},
  rw hA at hq,
  simp only [h1] at hVads {single_pass := tt},
  rw hVads at hq,

end

I want to taking out θ0&C \theta_{0} \& C from inside the summation in hq and cancel them, which tactic works here?

Kevin Buzzard (Feb 22 2022 at 22:18):

That's not a tactic you're looking for, you need a lemma. You are going to come unstuck soon because you have no hypotheses about anything converging and Lean defines any divergent sum to be 0. The lemmas you'll need are tsum_mul_right and tsum_mul_left.

Parivash (Feb 22 2022 at 22:26):

(deleted)

Parivash (Feb 27 2022 at 15:29):

lemma some_name (θ :   )(a b C P q A V₀ Vads x :  )
  (h1 :  k, θ k = C * x ^ k * θ 0) (hA : A = ∑' k, θ k)
  (hVads : Vads = V₀ * ∑' k : , k * θ k) (hq : q = Vads / A):
  q = a * P / ((1 - b * P) * (1 - b * P + C * P)) :=
begin
  simp only [h1] at hA {single_pass := tt},
  rw hA at hq,
  simp only [h1] at hVads {single_pass := tt},
  rw hVads at hq,
  /- rw tsum_mul_left at hVads,-/
  have h4 :  V₀ *  ∑' k : , k * ( C * x ^ k * θ 0 )= (V₀ * C * θ 0  *∑' k : , k * x ^ k ) := sorry,
  rw h4 at hq,
  have h5 :  ∑' k : ,( C * x ^ k * θ 0 )= (C * θ 0  *∑' k : , x ^ k ) := sorry,
  /- rw tsum_mul_left at hA,-/
  rw h5 at hq,
  /- rw int.mul_div_mul_of_pos,-/  /- to cancel θ 0 and C at hq -/
end

Why tsum_mul_left & rw int.mul_div_mul_of_ops doesn't work here!

Eric Wieser (Feb 27 2022 at 22:06):

What do the error messages say?

Parivash (Feb 28 2022 at 16:48):

@Eric Wieser
rewrite tactic failed, did not find instance of the pattern in the target expression
∑' (x : ?m_1), ?m_2 * ?m_3 x

Eric Wieser (Feb 28 2022 at 16:50):

What does the _full_ error message say?

Eric Wieser (Feb 28 2022 at 16:50):

(including the goal state)

Parivash (Feb 28 2022 at 17:20):

rewrite tactic failed, did not find instance of the pattern in the target expression
∑' (x : ?m_1), ?m_2 * ?m_3 x
state:
θ : ℕ → ℝ≥0,
a b C P q A V₀ Vads x : ℝ≥0,
h1 : ∀ (k : ℕ), θ k = C * x ^ k * θ 0,
hA : A = ∑' (k : ℕ), C * x ^ k * θ 0,
hVads : Vads = V₀ * ∑' (k : ℕ), ↑k * (C * x ^ k * θ 0),
hq : q = (V₀ * ∑' (k : ℕ), ↑k * (C * x ^ k * θ 0)) / ∑' (k : ℕ), C * x ^ k * θ 0
⊢ Vads = V₀ * C * θ 0 * ∑' (k : ℕ), ↑k * x ^ k

Yaël Dillies (Feb 28 2022 at 17:24):

I can't find the instance either. In ∑' (k : ℕ), ↑k * x ^ k, both sides of the * depend on k.

Parivash (Feb 28 2022 at 17:32):

Actually, I want to take out θ0andC \theta 0 and C which are constants from summation at hq and the cancel them. I want to change hq to this format: Ci=1+ixi(1+Ci=1+xi) \frac{C*\sum_{i=1}^{+\infty}i*x^{i}}{(1+C*\sum_{i=1}^{+\infty}x^{i})}

Yaël Dillies (Feb 28 2022 at 17:42):

Click on the inside of the sum in the tactic state. You'll see that C * x ^ k * θ 0 means (C * x ^ k) * θ 0, not C * (x ^ k * θ 0). You can turn one into the other using docs#mul_assoc.

Parivash (Feb 28 2022 at 18:12):

@Yaël Dillies
I cannot find what you mentioned inside the sum in tactic state!


Last updated: Dec 20 2023 at 11:08 UTC