Theorem: FinInt.addfull_toUint (MLIR/Util/FinInt.lean)

State before:
sz : ℕ
n m : FinInt sz
⊢ toUint (addfull n m) = toUint n + toUint m
Tactic:
revert n m
State after:
sz : ℕ
⊢ ∀ (n m : FinInt sz), toUint (addfull n m) = toUint n + toUint m

State before:
sz : ℕ
⊢ ∀ (n m : FinInt sz), toUint (addfull n m) = toUint n + toUint m
Tactic:
induction sz <;> intros n m
State after:
case zero
n m : FinInt Nat.zero
⊢ toUint (addfull n m) = toUint n + toUint m

case succ
n✝ : ℕ
n_ih✝ : ∀ (n m : FinInt n✝), toUint (addfull n m) = toUint n + toUint m
n m : FinInt (Nat.succ n✝)
⊢ toUint (addfull n m) = toUint n + toUint m

State before:
n m : FinInt Nat.zero
⊢ toUint (addfull n m) = toUint n + toUint m
Tactic:
case zero =>
  cases n; cases m; simp [addfull]
State after:
no goals

State before:
sz : ℕ
ih : ∀ (n m : FinInt sz), toUint (addfull n m) = toUint n + toUint m
n m : FinInt (Nat.succ sz)
⊢ toUint (addfull n m) = toUint n + toUint m
Tactic:
case succ sz ih =>
  cases n; case next sz dn n' =>
  cases m; case next dm m' =>
  simp [addfull]
  split
  case h_1 r h =>
    have h': r.toUint = n'.toUint + m'.toUint := by
      rw [←ih n' m']; simp [h]
    simp at h'
    cases dn <;> cases dm <;> simp [FinInt.toUint, h']
    <;> sorry_arith
  case h_2 r h =>
    have h': r.toUint = n'.toUint + m'.toUint - 2^sz := by
      rw [←ih n' m']
      simp [h, Int.add_comm, toSint]
    simp at h'
    cases dn <;> cases dm <;> simp [FinInt.toUint, h', toSint]
    <;> sorry_arith
State after:
no goals

State before:
n m : FinInt Nat.zero
⊢ toUint (addfull n m) = toUint n + toUint m
Tactic:
cases n
State after:
case nil
m : FinInt Nat.zero
⊢ toUint (addfull nil m) = toUint nil + toUint m

State before:
case nil
m : FinInt Nat.zero
⊢ toUint (addfull nil m) = toUint nil + toUint m
Tactic:
cases m
State after:
case nil.nil

⊢ toUint (addfull nil nil) = toUint nil + toUint nil

State before:
case nil.nil

⊢ toUint (addfull nil nil) = toUint nil + toUint nil
Tactic:
simp [addfull]
State after:
no goals

State before:
sz : ℕ
ih : ∀ (n m : FinInt sz), toUint (addfull n m) = toUint n + toUint m
n m : FinInt (Nat.succ sz)
⊢ toUint (addfull n m) = toUint n + toUint m
Tactic:
cases n
State after:
case next
n✝ : ℕ
a✝¹ : Bool
a✝ : FinInt n✝
ih : ∀ (n m : FinInt (Nat.add n✝ 0)), toUint (addfull n m) = toUint n + toUint m
m : FinInt (Nat.succ (Nat.add n✝ 0))
⊢ toUint (addfull (next a✝¹ a✝) m) = toUint (next a✝¹ a✝) + toUint m

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
m : FinInt (Nat.succ (Nat.add sz 0))
⊢ toUint (addfull (next dn n') m) = toUint (next dn n') + toUint m
Tactic:
case next sz dn n' =>
cases m; case next dm m' =>
simp [addfull]
split
case h_1 r h =>
have h': r.toUint = n'.toUint + m'.toUint := by
rw [←ih n' m']; simp [h]
simp at h'
cases dn <;> cases dm <;> simp [FinInt.toUint, h']
<;> sorry_arith
case h_2 r h =>
have h': r.toUint = n'.toUint + m'.toUint - 2^sz := by
rw [←ih n' m']
simp [h, Int.add_comm, toSint]
simp at h'
cases dn <;> cases dm <;> simp [FinInt.toUint, h', toSint]
<;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
m : FinInt (Nat.succ (Nat.add sz 0))
⊢ toUint (addfull (next dn n') m) = toUint (next dn n') + toUint m
Tactic:
cases m
State after:
case next
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
a✝¹ : Bool
a✝ : FinInt sz
⊢ toUint (addfull (next dn n') (next a✝¹ a✝)) = toUint (next dn n') + toUint (next a✝¹ a✝)

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
⊢ toUint (addfull (next dn n') (next dm m')) = toUint (next dn n') + toUint (next dm m')
Tactic:
case next dm m' =>
simp [addfull]
split
case h_1 r h =>
have h': r.toUint = n'.toUint + m'.toUint := by
rw [←ih n' m']; simp [h]
simp at h'
cases dn <;> cases dm <;> simp [FinInt.toUint, h']
<;> sorry_arith
case h_2 r h =>
have h': r.toUint = n'.toUint + m'.toUint - 2^sz := by
rw [←ih n' m']
simp [h, Int.add_comm, toSint]
simp at h'
cases dn <;> cases dm <;> simp [FinInt.toUint, h', toSint]
<;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
⊢ toUint (addfull (next dn n') (next dm m')) = toUint (next dn n') + toUint (next dm m')
Tactic:
simp [addfull]
State after:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
⊢ toUint
      (match addfull n' m' with
      | next false r => next (dn && dm) (next (dn != dm) r)
      | next true r => next (dn || dm) (next (dn == dm) r)) =
    toUint (next dn n') + toUint (next dm m')

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
⊢ toUint
      (match addfull n' m' with
      | next false r => next (dn && dm) (next (dn != dm) r)
      | next true r => next (dn || dm) (next (dn == dm) r)) =
    toUint (next dn n') + toUint (next dm m')
Tactic:
split
State after:
case h_1
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
m✝ : FinInt (sz + 0)
heq✝ : addfull n' m' = next false m✝
⊢ toUint (next (dn && dm) (next (dn != dm) m✝)) = toUint (next dn n') + toUint (next dm m')

case h_2
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
m✝ : FinInt (sz + 0)
heq✝ : addfull n' m' = next true m✝
⊢ toUint (next (dn || dm) (next (dn == dm) m✝)) = toUint (next dn n') + toUint (next dm m')

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
⊢ toUint (next (dn && dm) (next (dn != dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
case h_1 r h =>
  have h': r.toUint = n'.toUint + m'.toUint := by
    rw [←ih n' m']; simp [h]
  simp at h'
  cases dn <;> cases dm <;> simp [FinInt.toUint, h']
  <;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
⊢ toUint (next (dn || dm) (next (dn == dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
case h_2 r h =>
  have h': r.toUint = n'.toUint + m'.toUint - 2^sz := by
    rw [←ih n' m']
    simp [h, Int.add_comm, toSint]
  simp at h'
  cases dn <;> cases dm <;> simp [FinInt.toUint, h', toSint]
  <;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
⊢ toUint (next (dn && dm) (next (dn != dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
have h': r.toUint = n'.toUint + m'.toUint := by
  rw [←ih n' m']; simp [h]
State after:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
h' : toUint r = toUint n' + toUint m'
⊢ toUint (next (dn && dm) (next (dn != dm) r)) = toUint (next dn n') + toUint (next dm m')

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
h' : toUint r = toUint n' + toUint m'
⊢ toUint (next (dn && dm) (next (dn != dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
cases dn <;> cases dm <;> simp [FinInt.toUint, h']
<;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
⊢ toUint r = toUint n' + toUint m'
Tactic:
rw [←ih n' m']
State after:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
⊢ toUint r = toUint (addfull n' m')

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next false r
⊢ toUint r = toUint (addfull n' m')
Tactic:
simp [h]
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
⊢ toUint (next (dn || dm) (next (dn == dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
have h': r.toUint = n'.toUint + m'.toUint - 2^sz := by
  rw [←ih n' m']
  simp [h, Int.add_comm, toSint]
State after:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
h' : toUint r = toUint n' + toUint m' - 2 ^ sz
⊢ toUint (next (dn || dm) (next (dn == dm) r)) = toUint (next dn n') + toUint (next dm m')

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
h' : toUint r = toUint n' + toUint m' - 2 ^ sz
⊢ toUint (next (dn || dm) (next (dn == dm) r)) = toUint (next dn n') + toUint (next dm m')
Tactic:
cases dn <;> cases dm <;> simp [FinInt.toUint, h', toSint]
<;> sorry_arith
State after:
no goals

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
⊢ toUint r = toUint n' + toUint m' - 2 ^ sz
Tactic:
rw [←ih n' m']
State after:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
⊢ toUint r = toUint (addfull n' m') - 2 ^ sz

State before:
sz : ℕ
dn : Bool
n' : FinInt sz
ih : ∀ (n m : FinInt (Nat.add sz 0)), toUint (addfull n m) = toUint n + toUint m
dm : Bool
m' : FinInt sz
n✝ : FinInt (sz + 0 + 1)
r : FinInt (sz + 0)
h : addfull n' m' = next true r
⊢ toUint r = toUint (addfull n' m') - 2 ^ sz
Tactic:
simp [h, Int.add_comm, toSint]
State after:
no goals