Theorem: Int.odd_part_le_self_nat (ECTate/Algebra/EllipticCurve/Kronecker.lean)

State before:
x : ℕ
⊢ (val_bin_nat x).snd ≤ x
Tactic:
have acc : ∀ y, y ≤ x → (val_bin_nat y).2 ≤ x := by
  induction x with
  | zero =>
    intro y h
    rw [le_zero_eq] at h
    rw [h]
    exact Nat.zero_le 0
  | succ x ih =>
    intro y y_le_sx
    cases y_le_sx with
    | refl =>
      cases mod_two_eq_zero_or_one (Nat.succ x) with
      | inl even =>
        have h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 :=
        And.intro (zero_lt_succ x) even;
        show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
        else if 0 < Nat.succ x then
        (0, Nat.succ x)
        else
        (0, 0)).snd ≤ Nat.succ x
        rw [if_pos h]
        have h' := ih (Nat.succ x / 2) (div2_succ_le_self x);
        exact le_trans h' (le_succ x)
      | inr odd =>
        show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
        else if 0 < Nat.succ x then
        (0, Nat.succ x)
        else
        (0, 0)).snd ≤ Nat.succ x
        have not_even : Nat.succ x % 2 ≠ 0 := by
          rw [odd]
          simp;
        rw [if_neg (not_and_of_not_right (0 < Nat.succ x) not_even)]
        rw [if_pos (zero_lt_succ x)]
    | step y_le_x => exact le_trans (ih y y_le_x) (le_succ x);
State after:
x : ℕ
acc : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
⊢ (val_bin_nat x).snd ≤ x

State before:
x : ℕ
acc : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
⊢ (val_bin_nat x).snd ≤ x
Tactic:
exact acc x (le_refl x)
State after:
no goals

State before:
x : ℕ
⊢ ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
Tactic:
induction x with
| zero =>
  intro y h
  rw [le_zero_eq] at h
  rw [h]
  exact Nat.zero_le 0
| succ x ih =>
  intro y y_le_sx
  cases y_le_sx with
  | refl =>
    cases mod_two_eq_zero_or_one (Nat.succ x) with
    | inl even =>
      have h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 :=
      And.intro (zero_lt_succ x) even;
      show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
      let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then
      (0, Nat.succ x)
      else
      (0, 0)).snd ≤ Nat.succ x
      rw [if_pos h]
      have h' := ih (Nat.succ x / 2) (div2_succ_le_self x);
      exact le_trans h' (le_succ x)
    | inr odd =>
      show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
      let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then
      (0, Nat.succ x)
      else
      (0, 0)).snd ≤ Nat.succ x
      have not_even : Nat.succ x % 2 ≠ 0 := by
        rw [odd]
        simp;
      rw [if_neg (not_and_of_not_right (0 < Nat.succ x) not_even)]
      rw [if_pos (zero_lt_succ x)]
  | step y_le_x => exact le_trans (ih y y_le_x) (le_succ x);
State after:
no goals

State before:
case zero

⊢ ∀ (y : ℕ), y ≤ zero → (val_bin_nat y).snd ≤ zero
Tactic:
intro y h
State after:
case zero
y : ℕ
h : y ≤ zero
⊢ (val_bin_nat y).snd ≤ zero

State before:
case zero
y : ℕ
h : y ≤ zero
⊢ (val_bin_nat y).snd ≤ zero
Tactic:
rw [le_zero_eq] at h
State after:
case zero
y : ℕ
h : y = 0
⊢ (val_bin_nat y).snd ≤ zero

State before:
case zero
y : ℕ
h : y = 0
⊢ (val_bin_nat y).snd ≤ zero
Tactic:
rw [h]
State after:
case zero
y : ℕ
h : y = 0
⊢ (val_bin_nat 0).snd ≤ zero

State before:
case zero
y : ℕ
h : y = 0
⊢ (val_bin_nat 0).snd ≤ zero
Tactic:
exact Nat.zero_le 0
State after:
no goals

State before:
case succ
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
⊢ ∀ (y : ℕ), y ≤ Nat.succ x → (val_bin_nat y).snd ≤ Nat.succ x
Tactic:
intro y y_le_sx
State after:
case succ
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
y : ℕ
y_le_sx : y ≤ Nat.succ x
⊢ (val_bin_nat y).snd ≤ Nat.succ x

State before:
case succ
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
y : ℕ
y_le_sx : y ≤ Nat.succ x
⊢ (val_bin_nat y).snd ≤ Nat.succ x
Tactic:
cases y_le_sx with
| refl =>
  cases mod_two_eq_zero_or_one (Nat.succ x) with
  | inl even =>
    have h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 :=
    And.intro (zero_lt_succ x) even;
    show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
    let vbn_half := val_bin_nat (Nat.succ x / 2);
    (vbn_half.fst + 1, vbn_half.snd)
    else if 0 < Nat.succ x then
    (0, Nat.succ x)
    else
    (0, 0)).snd ≤ Nat.succ x
    rw [if_pos h]
    have h' := ih (Nat.succ x / 2) (div2_succ_le_self x);
    exact le_trans h' (le_succ x)
  | inr odd =>
    show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
    let vbn_half := val_bin_nat (Nat.succ x / 2);
    (vbn_half.fst + 1, vbn_half.snd)
    else if 0 < Nat.succ x then
    (0, Nat.succ x)
    else
    (0, 0)).snd ≤ Nat.succ x
    have not_even : Nat.succ x % 2 ≠ 0 := by
      rw [odd]
      simp;
    rw [if_neg (not_and_of_not_right (0 < Nat.succ x) not_even)]
    rw [if_pos (zero_lt_succ x)]
| step y_le_x => exact le_trans (ih y y_le_x) (le_succ x);
State after:
no goals

State before:
case succ.refl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
⊢ (val_bin_nat (Nat.succ x)).snd ≤ Nat.succ x
Tactic:
cases mod_two_eq_zero_or_one (Nat.succ x) with
| inl even =>
  have h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 :=
  And.intro (zero_lt_succ x) even;
  show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
  let vbn_half := val_bin_nat (Nat.succ x / 2);
  (vbn_half.fst + 1, vbn_half.snd)
  else if 0 < Nat.succ x then
  (0, Nat.succ x)
  else
  (0, 0)).snd ≤ Nat.succ x
  rw [if_pos h]
  have h' := ih (Nat.succ x / 2) (div2_succ_le_self x);
  exact le_trans h' (le_succ x)
| inr odd =>
  show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
  let vbn_half := val_bin_nat (Nat.succ x / 2);
  (vbn_half.fst + 1, vbn_half.snd)
  else if 0 < Nat.succ x then
  (0, Nat.succ x)
  else
  (0, 0)).snd ≤ Nat.succ x
  have not_even : Nat.succ x % 2 ≠ 0 := by
    rw [odd]
    simp;
  rw [if_neg (not_and_of_not_right (0 < Nat.succ x) not_even)]
  rw [if_pos (zero_lt_succ x)]
State after:
no goals

State before:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
⊢ (val_bin_nat (Nat.succ x)).snd ≤ Nat.succ x
Tactic:
have h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 :=
And.intro (zero_lt_succ x) even
State after:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (val_bin_nat (Nat.succ x)).snd ≤ Nat.succ x

State before:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (val_bin_nat (Nat.succ x)).snd ≤ Nat.succ x
Tactic:
show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
let vbn_half := val_bin_nat (Nat.succ x / 2);
(vbn_half.fst + 1, vbn_half.snd)
else if 0 < Nat.succ x then
(0, Nat.succ x)
else
(0, 0)).snd ≤ Nat.succ x
State after:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x

State before:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x
Tactic:
rw [if_pos h]
State after:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)).snd ≤
    Nat.succ x

State before:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
⊢ (let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)).snd ≤
    Nat.succ x
Tactic:
have h' := ih (Nat.succ x / 2) (div2_succ_le_self x)
State after:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
h' : (val_bin_nat (Nat.succ x / 2)).snd ≤ x
⊢ (let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)).snd ≤
    Nat.succ x

State before:
case succ.refl.inl
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
even : Nat.succ x % 2 = 0
h : 0 < Nat.succ x ∧ Nat.succ x % 2 = 0
h' : (val_bin_nat (Nat.succ x / 2)).snd ≤ x
⊢ (let vbn_half := val_bin_nat (Nat.succ x / 2);
      (vbn_half.fst + 1, vbn_half.snd)).snd ≤
    Nat.succ x
Tactic:
exact le_trans h' (le_succ x)
State after:
no goals

State before:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ (val_bin_nat (Nat.succ x)).snd ≤ Nat.succ x
Tactic:
show (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
let vbn_half := val_bin_nat (Nat.succ x / 2);
(vbn_half.fst + 1, vbn_half.snd)
else if 0 < Nat.succ x then
(0, Nat.succ x)
else
(0, 0)).snd ≤ Nat.succ x
State after:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x

State before:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x
Tactic:
have not_even : Nat.succ x % 2 ≠ 0 := by
  rw [odd]
  simp;
State after:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
not_even : Nat.succ x % 2 ≠ 0
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x

State before:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
not_even : Nat.succ x % 2 ≠ 0
⊢ (if 0 < Nat.succ x ∧ Nat.succ x % 2 = 0 then
        let vbn_half := val_bin_nat (Nat.succ x / 2);
        (vbn_half.fst + 1, vbn_half.snd)
      else if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤
    Nat.succ x
Tactic:
rw [if_neg (not_and_of_not_right (0 < Nat.succ x) not_even)]
State after:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
not_even : Nat.succ x % 2 ≠ 0
⊢ (if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤ Nat.succ x

State before:
case succ.refl.inr
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
not_even : Nat.succ x % 2 ≠ 0
⊢ (if 0 < Nat.succ x then (0, Nat.succ x) else (0, 0)).snd ≤ Nat.succ x
Tactic:
rw [if_pos (zero_lt_succ x)]
State after:
no goals

State before:
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ Nat.succ x % 2 ≠ 0
Tactic:
rw [odd]
State after:
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ 1 ≠ 0

State before:
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
odd : Nat.succ x % 2 = 1
⊢ 1 ≠ 0
Tactic:
simp
State after:
no goals

State before:
case succ.step
x : ℕ
ih : ∀ (y : ℕ), y ≤ x → (val_bin_nat y).snd ≤ x
y : ℕ
y_le_x : Nat.le y x
⊢ (val_bin_nat y).snd ≤ Nat.succ x
Tactic:
exact le_trans (ih y y_le_x) (le_succ x)
State after:
no goals