2023-11-22 08:26:49 +00:00
|
|
|
|
import Game.Tactic.LabelAttr -- MyNat_decide attribute
|
|
|
|
|
|
|
2023-08-04 01:49:06 +01:00
|
|
|
|
/-- Our copy of the natural numbers called `MyNat`, with notation `ℕ`. -/
|
2023-04-25 18:37:27 +02:00
|
|
|
|
inductive MyNat where
|
|
|
|
|
|
| zero : MyNat
|
|
|
|
|
|
| succ : MyNat → MyNat
|
|
|
|
|
|
-- deriving BEq, DecidableEq, Inhabited
|
|
|
|
|
|
|
2025-09-28 09:40:24 +01:00
|
|
|
|
attribute [pp_nodot] MyNat.succ
|
|
|
|
|
|
|
2023-04-25 18:37:27 +02:00
|
|
|
|
@[inherit_doc]
|
2023-08-04 17:14:49 +02:00
|
|
|
|
notation (name := MyNatNotation) (priority := 1000000) "ℕ" => MyNat
|
2023-04-25 18:37:27 +02:00
|
|
|
|
-- 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
|
|
|
|
|
|
|
2023-11-22 08:26:49 +00:00
|
|
|
|
@[MyNat_decide]
|
|
|
|
|
|
def ofNat (x : Nat) : MyNat :=
|
2023-04-25 18:37:27 +02:00
|
|
|
|
match x with
|
|
|
|
|
|
| Nat.zero => MyNat.zero
|
2023-11-22 08:26:49 +00:00
|
|
|
|
| Nat.succ b => MyNat.succ (ofNat b)
|
2023-04-25 18:37:27 +02:00
|
|
|
|
|
2023-11-22 08:26:49 +00:00
|
|
|
|
@[MyNat_decide]
|
|
|
|
|
|
def toNat (x : MyNat) : Nat :=
|
2023-04-25 18:37:27 +02:00
|
|
|
|
match x with
|
|
|
|
|
|
| MyNat.zero => Nat.zero
|
2023-11-22 08:26:49 +00:00
|
|
|
|
| MyNat.succ b => Nat.succ (toNat b)
|
2023-04-25 18:37:27 +02:00
|
|
|
|
|
2023-11-22 08:26:49 +00:00
|
|
|
|
instance instofNat {n : Nat} : OfNat MyNat n where
|
|
|
|
|
|
ofNat := ofNat n
|
2023-04-25 18:37:27 +02:00
|
|
|
|
|
|
|
|
|
|
instance : ToString MyNat where
|
2023-11-22 08:26:49 +00:00
|
|
|
|
toString p := toString (toNat p)
|
2023-04-25 18:37:27 +02:00
|
|
|
|
|
2023-11-22 08:26:49 +00:00
|
|
|
|
@[MyNat_decide]
|
2023-04-25 18:37:27 +02:00
|
|
|
|
theorem zero_eq_0 : MyNat.zero = 0 := rfl
|
|
|
|
|
|
|
|
|
|
|
|
def one : MyNat := MyNat.succ 0
|