internlm/Lean-Github huggingface dataset:
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
this : ∀ (b : Bool), f false b = b
⊢ (if true = true then n else 0) % 2 = if f false (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
simp [this]
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
this : ∀ (b : Bool), f false b = b
⊢ n % 2 = if n % 2 = 1 then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
this : ∀ (b : Bool), f false b = b
⊢ n % 2 = if n % 2 = 1 then 1 else 0
Tactic:
apply (n.mod_two_eq_zero_or_one).elim <;> intro h <;> simp [h]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
b : Bool
⊢ f false b = b
Tactic:
cases b
Proof state after:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false true = true
Theorem: Nat.bitwise_mod_two
Proof state before:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false true = true
Tactic:
exact f_stable
Proof state after:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false true = true
Theorem: Nat.bitwise_mod_two
Proof state before:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
n : Nat
hfft : f false true = true
⊢ f false true = true
Tactic:
exact hfft
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
⊢ bitwise f m n % 2 = if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
unfold bitwise
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
⊢ (if m = 0 then if f false true = true then n else 0
      else
        if n = 0 then if f true false = true then m else 0
        else
          let n' := m / 2;
          let m' := n / 2;
          let b₁ := m % 2 = 1;
          let b₂ := n % 2 = 1;
          let r := bitwise f n' m';
          if f (decide b₁) (decide b₂) = true then r + r + 1 else r + r) %
      2 =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
by_cases n = 0
Proof state after:
case pos
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
h✝ : n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0

case neg
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
h✝ : ¬n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
case pos hn =>
  cases hn; simp
  cases hftf : f true false
  case true =>
    have : ∀ b, f b false = b := λ b => by cases b; exact f_stable; exact hftf
    simp [this]
    apply m.mod_two_eq_zero_or_one.elim <;> intro h <;> simp [h]
  case false =>
    have : ∀ b, f b false = false := λ b => by cases b; exact f_stable; exact hftf
    simp [this]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : ¬n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
case neg hn =>
  rw [if_neg hn]
  rfl
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
cases hn
Proof state after:
case refl
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
⊢ (if 0 = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (0 % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (0 % 2 = 1)) = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
case refl
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
⊢ (if 0 = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (0 % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (0 % 2 = 1)) = true then 1 else 0
Tactic:
simp
Proof state after:
case refl
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
⊢ (if f true false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
case refl
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
⊢ (if f true false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
cases hftf : f true false
Proof state after:
case refl.false
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ (if false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0

case refl.true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ (if true = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ (if true = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
case true =>
  have : ∀ b, f b false = b := λ b => by cases b; exact f_stable; exact hftf
  simp [this]
  apply m.mod_two_eq_zero_or_one.elim <;> intro h <;> simp [h]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ (if false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
case false =>
  have : ∀ b, f b false = false := λ b => by cases b; exact f_stable; exact hftf
  simp [this]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ (if true = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
have : ∀ b, f b false = b := λ b => by cases b; exact f_stable; exact hftf
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
this : ∀ (b : Bool), f b false = b
⊢ (if true = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
this : ∀ (b : Bool), f b false = b
⊢ (if true = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
simp [this]
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
this : ∀ (b : Bool), f b false = b
⊢ m % 2 = if m % 2 = 1 then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
this : ∀ (b : Bool), f b false = b
⊢ m % 2 = if m % 2 = 1 then 1 else 0
Tactic:
apply m.mod_two_eq_zero_or_one.elim <;> intro h <;> simp [h]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
b : Bool
⊢ f b false = b
Tactic:
cases b
Proof state after:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f true false = true
Theorem: Nat.bitwise_mod_two
Proof state before:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f true false = true
Tactic:
exact f_stable
Proof state after:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f true false = true
Theorem: Nat.bitwise_mod_two
Proof state before:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = true
⊢ f true false = true
Tactic:
exact hftf
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ (if false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
have : ∀ b, f b false = false := λ b => by cases b; exact f_stable; exact hftf
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
this : ∀ (b : Bool), f b false = false
⊢ (if false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
this : ∀ (b : Bool), f b false = false
⊢ (if false = true then m % 2 else 0) = if f (decide (m % 2 = 1)) false = true then 1 else 0
Tactic:
simp [this]
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
b : Bool
⊢ f b false = false
Tactic:
cases b
Proof state after:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f true false = false
Theorem: Nat.bitwise_mod_two
Proof state before:
case false
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f false false = false

case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f true false = false
Tactic:
exact f_stable
Proof state after:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f true false = false
Theorem: Nat.bitwise_mod_two
Proof state before:
case true
f : Bool → Bool → Bool
f_stable : f false false = false
m : Nat
hm : ¬m = 0
hftf : f true false = false
⊢ f true false = false
Tactic:
exact hftf
Proof state after:
no goals
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : ¬n = 0
⊢ (if n = 0 then if f true false = true then m % 2 else 0
    else if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
rw [if_neg hn]
Proof state after:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : ¬n = 0
⊢ (if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Theorem: Nat.bitwise_mod_two
Proof state before:
f : Bool → Bool → Bool
f_stable : f false false = false
m n : Nat
hm : ¬m = 0
hn : ¬n = 0
⊢ (if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 % 2 else 0) =
    if f (decide (m % 2 = 1)) (decide (n % 2 = 1)) = true then 1 else 0
Tactic:
rfl
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
m n k : Nat
hmk : m < 2 ^ k
hnk : n < 2 ^ k
⊢ bitwise f m n < 2 ^ k
Tactic:
induction k generalizing m n
Proof state after:
case zero
f : Bool → Bool → Bool
m n : Nat
hmk : m < 2 ^ zero
hnk : n < 2 ^ zero
⊢ bitwise f m n < 2 ^ zero

case succ
f : Bool → Bool → Bool
n✝ : Nat
n_ih✝ : ∀ {m n : Nat}, m < 2 ^ n✝ → n < 2 ^ n✝ → bitwise f m n < 2 ^ n✝
m n : Nat
hmk : m < 2 ^ succ n✝
hnk : n < 2 ^ succ n✝
⊢ bitwise f m n < 2 ^ succ n✝
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
m n : Nat
hmk : m < 2 ^ zero
hnk : n < 2 ^ zero
⊢ bitwise f m n < 2 ^ zero
Tactic:
case zero =>
  cases m.eq_zero_of_lt_one hmk; cases n.eq_zero_of_lt_one hnk
  unfold bitwise; simp
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
⊢ bitwise f m n < 2 ^ succ k
Tactic:
case succ k h_ind =>
  by_cases m = 0
  case pos hm =>
    cases hm
    unfold bitwise; simp
    cases f false true <;> simp
    . exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
    . exact hnk
  case neg hm =>
    by_cases n = 0
    case pos hn =>
      cases hn
      unfold bitwise; simp [hm]
      cases f true false <;> simp
      . exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
      . exact hmk
    case neg hn =>
      unfold bitwise; simp [hm, hn]
      rw [←Nat.mul_two, Nat.pow_succ]
      have : m/2 < 2^k := (Nat.div_lt_iff_lt_mul (Nat.zero_lt_succ 1)).mpr hmk
      have : n/2 < 2^k := (Nat.div_lt_iff_lt_mul (Nat.zero_lt_succ 1)).mpr hnk
      cases f (m%2=1) (n%2=1) <;> simp
      . apply Nat.mul_lt_mul_of_pos_right ?_ (Nat.zero_lt_succ 1)
        exact h_ind ‹_› ‹_›
      . calc
        bitwise f (m/2) (n/2) * 2 + 1 
          < bitwise f (m/2) (n/2) * 2 + 2 := Nat.lt_succ_self _
        _ = (bitwise f (m/2) (n/2)) * 2 + 1*2 := rfl
        _ = (bitwise f (m/2) (n/2) + 1) * 2 := (Nat.add_mul _ _ 2).symm
        _ ≤ 2^k * 2 := Nat.mul_le_mul_right 2 (h_ind ‹m/2 < 2^k› ‹n/2 < 2^k›)
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
m n : Nat
hmk : m < 2 ^ zero
hnk : n < 2 ^ zero
⊢ bitwise f m n < 2 ^ zero
Tactic:
cases m.eq_zero_of_lt_one hmk
Proof state after:
case refl
f : Bool → Bool → Bool
n : Nat
hnk : n < 2 ^ zero
hmk : 0 < 2 ^ zero
⊢ bitwise f 0 n < 2 ^ zero
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl
f : Bool → Bool → Bool
n : Nat
hnk : n < 2 ^ zero
hmk : 0 < 2 ^ zero
⊢ bitwise f 0 n < 2 ^ zero
Tactic:
cases n.eq_zero_of_lt_one hnk
Proof state after:
case refl.refl
f : Bool → Bool → Bool
hmk hnk : 0 < 2 ^ zero
⊢ bitwise f 0 0 < 2 ^ zero
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.refl
f : Bool → Bool → Bool
hmk hnk : 0 < 2 ^ zero
⊢ bitwise f 0 0 < 2 ^ zero
Tactic:
unfold bitwise
Proof state after:
case refl.refl
f : Bool → Bool → Bool
hmk hnk : 0 < 2 ^ zero
⊢ (if 0 = 0 then if f false true = true then 0 else 0
    else
      if 0 = 0 then if f true false = true then 0 else 0
      else
        let n' := 0 / 2;
        let m' := 0 / 2;
        let b₁ := 0 % 2 = 1;
        let b₂ := 0 % 2 = 1;
        let r := bitwise f n' m';
        if f (decide b₁) (decide b₂) = true then r + r + 1 else r + r) <
    2 ^ zero
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.refl
f : Bool → Bool → Bool
hmk hnk : 0 < 2 ^ zero
⊢ (if 0 = 0 then if f false true = true then 0 else 0
    else
      if 0 = 0 then if f true false = true then 0 else 0
      else
        let n' := 0 / 2;
        let m' := 0 / 2;
        let b₁ := 0 % 2 = 1;
        let b₂ := 0 % 2 = 1;
        let r := bitwise f n' m';
        if f (decide b₁) (decide b₂) = true then r + r + 1 else r + r) <
    2 ^ zero
Tactic:
simp
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
⊢ bitwise f m n < 2 ^ succ k
Tactic:
by_cases m = 0
Proof state after:
case pos
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
h✝ : m = 0
⊢ bitwise f m n < 2 ^ succ k

case neg
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
h✝ : ¬m = 0
⊢ bitwise f m n < 2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
hm : m = 0
⊢ bitwise f m n < 2 ^ succ k
Tactic:
case pos hm =>
  cases hm
  unfold bitwise; simp
  cases f false true <;> simp
  . exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
  . exact hnk
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
hm : ¬m = 0
⊢ bitwise f m n < 2 ^ succ k
Tactic:
case neg hm =>
  by_cases n = 0
  case pos hn =>
    cases hn
    unfold bitwise; simp [hm]
    cases f true false <;> simp
    . exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
    . exact hmk
  case neg hn =>
    unfold bitwise; simp [hm, hn]
    rw [←Nat.mul_two, Nat.pow_succ]
    have : m/2 < 2^k := (Nat.div_lt_iff_lt_mul (Nat.zero_lt_succ 1)).mpr hmk
    have : n/2 < 2^k := (Nat.div_lt_iff_lt_mul (Nat.zero_lt_succ 1)).mpr hnk
    cases f (m%2=1) (n%2=1) <;> simp
    . apply Nat.mul_lt_mul_of_pos_right ?_ (Nat.zero_lt_succ 1)
      exact h_ind ‹_› ‹_›
    . calc
      bitwise f (m/2) (n/2) * 2 + 1 
        < bitwise f (m/2) (n/2) * 2 + 2 := Nat.lt_succ_self _
      _ = (bitwise f (m/2) (n/2)) * 2 + 1*2 := rfl
      _ = (bitwise f (m/2) (n/2) + 1) * 2 := (Nat.add_mul _ _ 2).symm
      _ ≤ 2^k * 2 := Nat.mul_le_mul_right 2 (h_ind ‹m/2 < 2^k› ‹n/2 < 2^k›)
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
m n : Nat
hmk : m < 2 ^ succ k
hnk : n < 2 ^ succ k
hm : m = 0
⊢ bitwise f m n < 2 ^ succ k
Tactic:
cases hm
Proof state after:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ bitwise f 0 n < 2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ bitwise f 0 n < 2 ^ succ k
Tactic:
unfold bitwise
Proof state after:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ (if 0 = 0 then if f false true = true then n else 0
    else
      if n = 0 then if f true false = true then 0 else 0
      else
        let n' := 0 / 2;
        let m' := n / 2;
        let b₁ := 0 % 2 = 1;
        let b₂ := n % 2 = 1;
        let r := bitwise f n' m';
        if f (decide b₁) (decide b₂) = true then r + r + 1 else r + r) <
    2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ (if 0 = 0 then if f false true = true then n else 0
    else
      if n = 0 then if f true false = true then 0 else 0
      else
        let n' := 0 / 2;
        let m' := n / 2;
        let b₁ := 0 % 2 = 1;
        let b₂ := n % 2 = 1;
        let r := bitwise f n' m';
        if f (decide b₁) (decide b₂) = true then r + r + 1 else r + r) <
    2 ^ succ k
Tactic:
simp
Proof state after:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ (if f false true = true then n else 0) < 2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ (if f false true = true then n else 0) < 2 ^ succ k
Tactic:
cases f false true <;> simp
Proof state after:
case refl.false
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ 0 < 2 ^ succ k

case refl.true
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ n < 2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.false
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ 0 < 2 ^ succ k

case refl.true
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ n < 2 ^ succ k
Tactic:
. exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
Proof state after:
case refl.true
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ n < 2 ^ succ k
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.true
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ n < 2 ^ succ k
Tactic:
. exact hnk
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.false
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ 0 < 2 ^ succ k
Tactic:
exact Nat.pos_pow_of_pos k.succ (Nat.zero_lt_succ 1)
Proof state after:
no goals
Theorem: Nat.bitwise_lt_exp2
Proof state before:
case refl.true
f : Bool → Bool → Bool
k : Nat
h_ind : ∀ {m n : Nat}, m < 2 ^ k → n < 2 ^ k → bitwise f m n < 2 ^ k
n : Nat
hnk : n < 2 ^ succ k
hmk : 0 < 2 ^ succ k
⊢ n < 2 ^ succ k
Tactic:
exact hnk
Proof state after:
no goals