theorem
proved
toNat_add
show as:
view math explainer →
open explainer
Generate a durable explainer page for this declaration.
open lean source
IndisputableMonolith.Foundation.ArithmeticFromLogic on GitHub at line 261.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
used by
formal source
258
259/-- **Recovery theorem (addition)**: the addition `LogicNat` carries
260agrees with `Nat` addition under the equivalence. -/
261theorem toNat_add (a b : LogicNat) :
262 toNat (a + b) = toNat a + toNat b := by
263 induction b with
264 | identity =>
265 show toNat (a + zero) = toNat a + toNat zero
266 rw [add_zero, toNat_zero, Nat.add_zero]
267 | step b ih =>
268 show toNat (a + succ b) = toNat a + toNat (succ b)
269 rw [add_succ, toNat_succ, toNat_succ, ih, Nat.add_succ]
270
271/-- **Recovery theorem (multiplication)**: the multiplication
272`LogicNat` carries agrees with `Nat` multiplication under the
273equivalence. -/
274theorem toNat_mul (a b : LogicNat) :
275 toNat (a * b) = toNat a * toNat b := by
276 induction b with
277 | identity =>
278 show toNat (a * zero) = toNat a * toNat zero
279 rw [mul_zero, toNat_zero, Nat.mul_zero]
280 | step b ih =>
281 show toNat (a * succ b) = toNat a * toNat (succ b)
282 rw [mul_succ, toNat_succ, toNat_add, ih, Nat.mul_succ]
283
284/-- Left cancellation: `a + b = a + c ⇒ b = c`. Proved by transferring
285to `Nat` via the recovery isomorphism. -/
286theorem add_left_cancel {a b c : LogicNat} (h : a + b = a + c) : b = c := by
287 have hcast := congrArg toNat h
288 rw [toNat_add, toNat_add] at hcast
289 have hnat : toNat b = toNat c := by omega
290 have := congrArg fromNat hnat
291 rw [fromNat_toNat, fromNat_toNat] at this