You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lean4game/server/nng/NNG/MyNat/Definition.lean

38 lines
898 B
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--import Mathlib.Tactic.Basic
--import Mathlib.Tactic.Cases
/-- Our copy of the natural numbers called `MyNat`. -/
inductive MyNat where
| zero : MyNat
| succ : MyNat → MyNat
deriving BEq, DecidableEq, Inhabited
@[inherit_doc]
notation "" => MyNat
-- Note: as long as we do not import `Mathlib.Init.Data.Nat.Notation` this is fine.
namespace MyNat
instance : Inhabited MyNat where
default := MyNat.zero
def myNatFromNat (x : Nat) : MyNat :=
match x with
| Nat.zero => MyNat.zero
| Nat.succ b => MyNat.succ (myNatFromNat b)
def natFromMyNat (x : MyNat) : Nat :=
match x with
| MyNat.zero => Nat.zero
| MyNat.succ b => Nat.succ (natFromMyNat b)
instance ofNat {n : Nat} : OfNat MyNat n where
ofNat := myNatFromNat n
instance : ToString MyNat where
toString p := toString (natFromMyNat p)
theorem zero_eq_0 : MyNat.zero = 0 := rfl
def one : MyNat := MyNat.succ 0