Zulip Chat Archive

Stream: new members

Topic: trinum proof with induction help


Joseph O (Nov 06 2022 at 01:24):

i have this theorem so far

import algebra.group_with_zero.units
import tactic.qify
import data.nat.parity

def sum' :   
  | 0 := 0
  | (n+1) := n + 1 + sum' n

lemma trinum :
   n : , n*(n-1)/2 = sum' n :=
begin
  intro n,
  let h : even (n * (n-1)) :=
  begin
    apply nat.even_mul_self_pred,
  end,
  rw nat.div_eq_iff_eq_mul_left,
  induction n,
  {
    rw zero_mul,
    have h : sum' 0 = 0 := rfl,
    rw h,
    rw zero_mul,
  },
  {
    rw nat.succ_sub_one,
    rw nat.succ_mul,
    sorry,
  },
  simp,
  exact even_iff_two_dvd.mp h,
end

and in my paper proof and lean proof, I'm not sure how to proceed to work with the sum' (succ n) in the goal for the block with sorry:

state:
case nat.succ
n_n : ,
n_ih : let h : even (n_n * (n_n - 1)) := _ in n_n * (n_n - 1) = sum' n_n * 2,
h : even (n_n.succ * (n_n.succ - 1)) := n_n.succ.even_mul_self_pred
 n_n * n_n + n_n = sum' n_n.succ * 2

NOTE: i don't want the full solution to the proof, just whatever answers the question. or, if my proof is completely bogus and stupid, you can let me know if i have to restart (and maybe with a hint as to what to do)

Patrick Johnson (Nov 06 2022 at 03:33):

  • Use have h instead of let h and move it after induction
  • Use induction n with n ih to make variable names nicer
  • At the sorry, use dunfold sum' and then rw [add_mul, ←ih]

Patrick Johnson (Nov 06 2022 at 03:37):

Note also that your statement is incorrect. It should be n * (n + 1) / 2.

Kevin Buzzard (Nov 06 2022 at 09:58):

Your statement is also morally incorrect in that it uses pathological functions like natural subtraction and division. Your sum' type should be taking values in rationals if you want to faithfully represent the mathematics.

Joseph O (Nov 06 2022 at 12:44):

Yeah sorry for the trouble, i just realized that
Patrick Johnson said:

  • Use have h instead of let h and move it after induction
  • Use induction n with n ih to make variable names nicer
  • At the sorry, use dunfold sum' and then rw [add_mul, ←ih]

Joseph O (Nov 06 2022 at 12:44):

also what does dunfolddo?

Kyle Miller (Nov 06 2022 at 12:55):

tactic#dunfold and tactic#unfold are for unfolding definitions. The difference is that dunfold will only unfold definitions that can be definitionally unfolded (it will only work whenever tactic#change would work)

Kyle Miller (Nov 06 2022 at 12:56):

It's like tactic#dsimp vs tactic#simp.

Kyle Miller (Nov 06 2022 at 12:57):

I think you can just use tactic#unfold and pretend tactic#dunfold doesn't exist (at least until you deal with more complicated dependent types where occasionally unfold doesn't work but dunfold does)

Joseph O (Nov 06 2022 at 13:06):

I see. Thank you, I was looking for this

Joseph O (Nov 06 2022 at 13:25):

@Kyle Miller i am unsure how to work with this goal

n: 
ih: even (n * (n + 1))  n * (n + 1) = sum' n * 2
h: even (n.succ * (n.succ + 1))
 n * (n + 1) + n + (n + 1).succ = (n + 1) * 2 + n * (n + 1)

Joseph O (Nov 06 2022 at 13:27):

how can i turn (n+1).succ into n+2?


Last updated: Dec 20 2023 at 11:08 UTC