def
definition
fromNat
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 226.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
used by
formal source
223 | .step n => Nat.succ (toNat n)
224
225/-- The inverse map: build the orbit by iterating the step. -/
226def fromNat : Nat → LogicNat
227 | 0 => .identity
228 | Nat.succ n => .step (fromNat n)
229
230@[simp] theorem toNat_zero : toNat zero = 0 := rfl
231@[simp] theorem toNat_succ (n : LogicNat) : toNat (succ n) = Nat.succ (toNat n) := rfl
232@[simp] theorem fromNat_zero : fromNat 0 = zero := rfl
233@[simp] theorem fromNat_succ (n : Nat) : fromNat (Nat.succ n) = succ (fromNat n) := rfl
234
235theorem fromNat_toNat : ∀ n : LogicNat, fromNat (toNat n) = n := by
236 intro n
237 induction n with
238 | identity => rfl
239 | step n ih =>
240 show fromNat (toNat (succ n)) = succ n
241 rw [toNat_succ, fromNat_succ, ih]
242
243theorem toNat_fromNat : ∀ n : Nat, toNat (fromNat n) = n := by
244 intro n
245 induction n with
246 | zero => rfl
247 | succ n ih =>
248 show toNat (fromNat (Nat.succ n)) = Nat.succ n
249 rw [fromNat_succ, toNat_succ, ih]
250
251/-- **Recovery theorem (carrier)**: `LogicNat` and `Nat` have the same
252underlying set, witnessed by the round-trip equalities. -/
253def equivNat : LogicNat ≃ Nat where
254 toFun := toNat
255 invFun := fromNat
256 left_inv := fromNat_toNat