l3lab/ntp-mathlib huggingface dataset:
theorem pred'_to_nat : ∀ n, (pred' n : ℕ) = Nat.pred n
  | 1 => rfl
  | bit0 n =>
    have : Nat.succ ↑(pred' n) = ↑n := by
      rw [pred'_to_nat n, Nat.succ_pred_eq_of_pos (to_nat_pos n)]
    match (motive :=
        ∀ k : Num, Nat.succ ↑k = ↑n → ↑(Num.casesOn k 1 bit1 : PosNum) = Nat.pred (_root_.bit0 n))
      pred' n, this with
    | 0, (h : ((1 : Num) : ℕ) = n) => by rw [← to_nat_inj.1 h]; rfl
    | Num.pos p, (h : Nat.succ ↑p = n) => by 

Proof state:
α : Type u_1
n : PosNum
this : Nat.succ ↑(pred' n) = ↑n
p : PosNum
h : Nat.succ ↑p = ↑n
⊢ ↑(Num.casesOn (pos p) 1 bit1) = Nat.pred (_root_.bit0 ↑n)

Next tactic:
rw [← h]
theorem pred'_to_nat : ∀ n, (pred' n : ℕ) = Nat.pred n
  | 1 => rfl
  | bit0 n =>
    have : Nat.succ ↑(pred' n) = ↑n := by
      rw [pred'_to_nat n, Nat.succ_pred_eq_of_pos (to_nat_pos n)]
    match (motive :=
        ∀ k : Num, Nat.succ ↑k = ↑n → ↑(Num.casesOn k 1 bit1 : PosNum) = Nat.pred (_root_.bit0 n))
      pred' n, this with
    | 0, (h : ((1 : Num) : ℕ) = n) => by rw [← to_nat_inj.1 h]; rfl
    | Num.pos p, (h : Nat.succ ↑p = n) => by rw [← h]; 

Proof state:
α : Type u_1
n : PosNum
this : Nat.succ ↑(pred' n) = ↑n
p : PosNum
h : Nat.succ ↑p = ↑n
⊢ ↑(Num.casesOn (pos p) 1 bit1) = Nat.pred (_root_.bit0 (Nat.succ ↑p))

Next tactic:
exact (Nat.succ_add p p).symm
@[simp]
theorem pred'_succ' (n) : pred' (succ' n) = n :=
  Num.to_nat_inj.1 <| by 

Proof state:
α : Type u_1
n : Num
⊢ ↑(pred' (succ' n)) = ↑n

Next tactic:
rw [pred'_to_nat, succ'_to_nat, Nat.add_one, Nat.pred_succ]
@[simp]
theorem succ'_pred' (n) : succ' (pred' n) = n :=
  to_nat_inj.1 <| by
    

Proof state:
α : Type u_1
n : PosNum
⊢ ↑(succ' (pred' n)) = ↑n

Next tactic:
rw [succ'_to_nat, pred'_to_nat, Nat.add_one, Nat.succ_pred_eq_of_pos (to_nat_pos _)]
theorem size_to_nat : ∀ n, (size n : ℕ) = Nat.size n
  | 1 => Nat.size_one.symm
  | bit0 n => by
    

Proof state:
α : Type u_1
n : PosNum
⊢ ↑(size (bit0 n)) = Nat.size ↑(bit0 n)

Next tactic:
rw [size, succ_to_nat, size_to_nat n, cast_bit0, Nat.size_bit0 <| ne_of_gt <| to_nat_pos n]
theorem size_to_nat : ∀ n, (size n : ℕ) = Nat.size n
  | 1 => Nat.size_one.symm
  | bit0 n => by
    rw [size, succ_to_nat, size_to_nat n, cast_bit0, Nat.size_bit0 <| ne_of_gt <| to_nat_pos n]
  | bit1 n => by 

Proof state:
α : Type u_1
n : PosNum
⊢ ↑(size (bit1 n)) = Nat.size ↑(bit1 n)

Next tactic:
rw [size, succ_to_nat, size_to_nat n, cast_bit1, Nat.size_bit1]
theorem size_eq_natSize : ∀ n, (size n : ℕ) = natSize n
  | 1 => rfl
  | bit0 n => by 

Proof state:
α : Type u_1
n : PosNum
⊢ ↑(size (bit0 n)) = natSize (bit0 n)

Next tactic:
rw [size, succ_to_nat, natSize, size_eq_natSize n]
theorem size_eq_natSize : ∀ n, (size n : ℕ) = natSize n
  | 1 => rfl
  | bit0 n => by rw [size, succ_to_nat, natSize, size_eq_natSize n]
  | bit1 n => by 

Proof state:
α : Type u_1
n : PosNum
⊢ ↑(size (bit1 n)) = natSize (bit1 n)

Next tactic:
rw [size, succ_to_nat, natSize, size_eq_natSize n]
theorem natSize_to_nat (n) : natSize n = Nat.size n := by 

Proof state:
α : Type u_1
n : PosNum
⊢ natSize n = Nat.size ↑n

Next tactic:
rw [← size_eq_natSize, size_to_nat]
theorem natSize_pos (n) : 0 < natSize n := by 

Proof state:
α : Type u_1
n : PosNum
⊢ 0 < natSize n

Next tactic:
cases n
theorem natSize_pos (n) : 0 < natSize n := by cases n <;> 

Proof state:
case one
α : Type u_1
⊢ 0 < natSize one

Next tactic:
apply Nat.succ_pos
theorem natSize_pos (n) : 0 < natSize n := by cases n <;> 

Proof state:
case bit1
α : Type u_1
a✝ : PosNum
⊢ 0 < natSize (bit1 a✝)

Next tactic:
apply Nat.succ_pos
theorem natSize_pos (n) : 0 < natSize n := by cases n <;> 

Proof state:
case bit0
α : Type u_1
a✝ : PosNum
⊢ 0 < natSize (bit0 a✝)

Next tactic:
apply Nat.succ_pos
instance addCommSemigroup : AddCommSemigroup PosNum := by
  

Proof state:
α : Type u_1
⊢ AddCommSemigroup PosNum

Next tactic:
refine' { add := (· + ·).. }
instance addCommSemigroup : AddCommSemigroup PosNum := by
  refine' { add := (· + ·).. } <;> 

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a + b + c = a + (b + c)

Next tactic:
transfer
instance addCommSemigroup : AddCommSemigroup PosNum := by
  refine' { add := (· + ·).. } <;> 

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a b : PosNum), a + b = b + a

Next tactic:
transfer
instance commMonoid : CommMonoid PosNum := by
  

Proof state:
α : Type u_1
⊢ CommMonoid PosNum

Next tactic:
refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a * b * c = a * (b * c)

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a * b * c = a * (b * c)

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a * b * c = a * (b * c)

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_1
α : Type u_1
a✝ b✝ c✝ : PosNum
⊢ a✝ * b✝ * c✝ = a✝ * (b✝ * c✝)

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a : PosNum), 1 * a = a

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a : PosNum), 1 * a = a

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a : PosNum), 1 * a = a

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_2
α : Type u_1
a✝ : PosNum
⊢ 1 * a✝ = a✝

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_3
α : Type u_1
⊢ ∀ (a : PosNum), a * 1 = a

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_3
α : Type u_1
⊢ ∀ (a : PosNum), a * 1 = a

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_3
α : Type u_1
⊢ ∀ (a : PosNum), a * 1 = a

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_3
α : Type u_1
a✝ : PosNum
⊢ a✝ * 1 = a✝

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_4
α : Type u_1
⊢ ∀ (x : PosNum), npowRec 0 x = 1

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_4
α : Type u_1
⊢ ∀ (x : PosNum), npowRec 0 x = 1

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_4
α : Type u_1
⊢ ∀ (x : PosNum), npowRec 0 x = 1

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_4
α : Type u_1
x✝ : PosNum
⊢ npowRec 0 x✝ = 1

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_5
α : Type u_1
⊢ ∀ (n : ℕ) (x : PosNum), npowRec (n + 1) x = x * npowRec n x

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_5
α : Type u_1
⊢ ∀ (n : ℕ) (x : PosNum), npowRec (n + 1) x = x * npowRec n x

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_5
α : Type u_1
⊢ ∀ (n : ℕ) (x : PosNum), npowRec (n + 1) x = x * npowRec n x

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_5
α : Type u_1
n✝ : ℕ
x✝ : PosNum
⊢ npowRec (n✝ + 1) x✝ = x✝ * npowRec n✝ x✝

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  

Proof state:
case refine'_6
α : Type u_1
⊢ ∀ (a b : PosNum), a * b = b * a

Next tactic:
try { intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try 

Proof state:
case refine'_6
α : Type u_1
⊢ ∀ (a b : PosNum), a * b = b * a

Next tactic:
{ intros; rfl }
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { 

Proof state:
case refine'_6
α : Type u_1
⊢ ∀ (a b : PosNum), a * b = b * a

Next tactic:
intros
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; 

Proof state:
case refine'_6
α : Type u_1
a✝ b✝ : PosNum
⊢ a✝ * b✝ = b✝ * a✝

Next tactic:
rfl
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; rfl } <;>
  

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a * b * c = a * (b * c)

Next tactic:
transfer
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; rfl } <;>
  

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a : PosNum), 1 * a = a

Next tactic:
transfer
instance commMonoid : CommMonoid PosNum := by
  refine'
    { mul := (· * ·)
      one := (1 : PosNum)
      npow := @npowRec PosNum ⟨1⟩ ⟨(· * ·)⟩,.. } <;>
  try { intros; rfl } <;>
  

Proof state:
case refine'_6
α : Type u_1
⊢ ∀ (a b : PosNum), a * b = b * a

Next tactic:
transfer
instance distrib : Distrib PosNum := by
  

Proof state:
α : Type u_1
⊢ Distrib PosNum

Next tactic:
refine'
    { add := (· + ·)
      mul := (· * ·).. }
instance distrib : Distrib PosNum := by
  refine'
    { add := (· + ·)
      mul := (· * ·).. } <;>
  (

Proof state:
case refine'_1
α : Type u_1
⊢ ∀ (a b c : PosNum), a * (b + c) = a * b + a * c

Next tactic:
transfer
instance distrib : Distrib PosNum := by
  refine'
    { add := (· + ·)
      mul := (· * ·).. } <;>
  (transfer
   

Proof state:
case refine'_1
α : Type u_1
a✝ b✝ c✝ : PosNum
⊢ ↑a✝ * (↑b✝ + ↑c✝) = ↑a✝ * ↑b✝ + ↑a✝ * ↑c✝

Next tactic:
simp [mul_add, mul_comm]
instance distrib : Distrib PosNum := by
  refine'
    { add := (· + ·)
      mul := (· * ·).. } <;>
  (

Proof state:
case refine'_2
α : Type u_1
⊢ ∀ (a b c : PosNum), (a + b) * c = a * c + b * c

Next tactic:
transfer
instance distrib : Distrib PosNum := by
  refine'
    { add := (· + ·)
      mul := (· * ·).. } <;>
  (transfer
   

Proof state:
case refine'_2
α : Type u_1
a✝ b✝ c✝ : PosNum
⊢ ↑c✝ * (↑a✝ + ↑b✝) = ↑a✝ * ↑c✝ + ↑b✝ * ↑c✝

Next tactic:
simp [mul_add, mul_comm]
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by 

Proof state:
α : Type u_1
⊢ ∀ (a : PosNum), a ≤ a

Next tactic:
transfer
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    

Proof state:
α : Type u_1
⊢ ∀ (a b c : PosNum), a ≤ b → b ≤ c → a ≤ c

Next tactic:
intro a b c
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    

Proof state:
α : Type u_1
a b c : PosNum
⊢ a ≤ b → b ≤ c → a ≤ c

Next tactic:
transfer_rw
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    

Proof state:
α : Type u_1
a b c : PosNum
⊢ ↑a ≤ ↑b → ↑b ≤ ↑c → ↑a ≤ ↑c

Next tactic:
apply le_trans
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    

Proof state:
α : Type u_1
⊢ ∀ (a b : PosNum), a < b ↔ a ≤ b ∧ ¬b ≤ a

Next tactic:
intro a b
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    

Proof state:
α : Type u_1
a b : PosNum
⊢ a < b ↔ a ≤ b ∧ ¬b ≤ a

Next tactic:
transfer_rw
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    

Proof state:
α : Type u_1
a b : PosNum
⊢ ↑a < ↑b ↔ ↑a ≤ ↑b ∧ ¬↑b ≤ ↑a

Next tactic:
apply lt_iff_le_not_le
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    

Proof state:
α : Type u_1
⊢ ∀ (a b : PosNum), a ≤ b → b ≤ a → a = b

Next tactic:
intro a b
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    

Proof state:
α : Type u_1
a b : PosNum
⊢ a ≤ b → b ≤ a → a = b

Next tactic:
transfer_rw
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    

Proof state:
α : Type u_1
a b : PosNum
⊢ ↑a ≤ ↑b → ↑b ≤ ↑a → ↑a = ↑b

Next tactic:
apply le_antisymm
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    

Proof state:
α : Type u_1
⊢ ∀ (a b : PosNum), a ≤ b ∨ b ≤ a

Next tactic:
intro a b
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    intro a b
    

Proof state:
α : Type u_1
a b : PosNum
⊢ a ≤ b ∨ b ≤ a

Next tactic:
transfer_rw
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    intro a b
    transfer_rw
    

Proof state:
α : Type u_1
a b : PosNum
⊢ ↑a ≤ ↑b ∨ ↑b ≤ ↑a

Next tactic:
apply le_total
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    intro a b
    transfer_rw
    apply le_total
  decidableLT := by infer_instance
  decidableLE := by 

Proof state:
α : Type u_1
⊢ DecidableRel fun x x_1 => x ≤ x_1

Next tactic:
infer_instance
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    intro a b
    transfer_rw
    apply le_total
  decidableLT := by infer_instance
  decidableLE := by infer_instance
  decidableEq := by 

Proof state:
α : Type u_1
⊢ DecidableEq PosNum

Next tactic:
infer_instance
instance linearOrder : LinearOrder PosNum where
  lt := (· < ·)
  lt_iff_le_not_le := by
    intro a b
    transfer_rw
    apply lt_iff_le_not_le
  le := (· ≤ ·)
  le_refl := by transfer
  le_trans := by
    intro a b c
    transfer_rw
    apply le_trans
  le_antisymm := by
    intro a b
    transfer_rw
    apply le_antisymm
  le_total := by
    intro a b
    transfer_rw
    apply le_total
  decidableLT := by 

Proof state:
α : Type u_1
⊢ DecidableRel fun x x_1 => x < x_1

Next tactic:
infer_instance
@[simp]
theorem cast_to_num (n : PosNum) : ↑n = Num.pos n := by 

Proof state:
α : Type u_1
n : PosNum
⊢ ↑n = pos n

Next tactic:
rw [← cast_to_nat, ← of_to_nat n]
@[simp, norm_cast]
theorem bit_to_nat (b n) : (bit b n : ℕ) = Nat.bit b n := by 

Proof state:
α : Type u_1
b : Bool
n : PosNum
⊢ ↑(bit b n) = Nat.bit b ↑n

Next tactic:
cases b
@[simp, norm_cast]
theorem bit_to_nat (b n) : (bit b n : ℕ) = Nat.bit b n := by cases b <;> 

Proof state:
case false
α : Type u_1
n : PosNum
⊢ ↑(bit false n) = Nat.bit false ↑n

Next tactic:
rfl
@[simp, norm_cast]
theorem bit_to_nat (b n) : (bit b n : ℕ) = Nat.bit b n := by cases b <;> 

Proof state:
case true
α : Type u_1
n : PosNum
⊢ ↑(bit true n) = Nat.bit true ↑n

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_add [AddMonoidWithOne α] (m n) : ((m + n : PosNum) : α) = m + n := by
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
m n : PosNum
⊢ ↑(m + n) = ↑m + ↑n

Next tactic:
rw [← cast_to_nat, add_to_nat, Nat.cast_add, cast_to_nat, cast_to_nat]
@[simp 500, norm_cast]
theorem cast_succ [AddMonoidWithOne α] (n : PosNum) : (succ n : α) = n + 1 := by
  

Proof state:
α : Type u_1
inst✝ : AddMonoidWithOne α
n : PosNum
⊢ ↑(succ n) = ↑n + 1

Next tactic:
rw [← add_one, cast_add, cast_one]
@[simp, norm_cast]
theorem cast_inj [AddMonoidWithOne α] [CharZero α] {m n : PosNum} : (m : α) = n ↔ m = n := by
  

Proof state:
α : Type u_1
inst✝¹ : AddMonoidWithOne α
inst✝ : CharZero α
m n : PosNum
⊢ ↑m = ↑n ↔ m = n

Next tactic:
rw [← cast_to_nat m, ← cast_to_nat n, Nat.cast_inj, to_nat_inj]
@[simp]
theorem one_le_cast [LinearOrderedSemiring α] (n : PosNum) : (1 : α) ≤ n := by
  

Proof state:
α : Type u_1
inst✝ : LinearOrderedSemiring α
n : PosNum
⊢ 1 ≤ ↑n

Next tactic:
rw [← cast_to_nat, ← Nat.cast_one, Nat.cast_le (α := α)]
@[simp]
theorem one_le_cast [LinearOrderedSemiring α] (n : PosNum) : (1 : α) ≤ n := by
  rw [← cast_to_nat, ← Nat.cast_one, Nat.cast_le (α := α)]; 

Proof state:
α : Type u_1
inst✝ : LinearOrderedSemiring α
n : PosNum
⊢ 1 ≤ ↑n

Next tactic:
apply to_nat_pos
@[simp, norm_cast]
theorem cast_mul [Semiring α] (m n) : ((m * n : PosNum) : α) = m * n := by
  

Proof state:
α : Type u_1
inst✝ : Semiring α
m n : PosNum
⊢ ↑(m * n) = ↑m * ↑n

Next tactic:
rw [← cast_to_nat, mul_to_nat, Nat.cast_mul, cast_to_nat, cast_to_nat]
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  

Proof state:
α : Type u_1
m n : PosNum
⊢ cmp m n = Ordering.eq ↔ m = n

Next tactic:
have := cmp_to_nat m n
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  

Proof state:
α : Type u_1
m n : PosNum
this : Ordering.casesOn (cmp m n) (↑m < ↑n) (m = n) (↑n < ↑m)
⊢ cmp m n = Ordering.eq ↔ m = n

Next tactic:
revert this
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; 

Proof state:
α : Type u_1
m n : PosNum
⊢ Ordering.casesOn (cmp m n) (↑m < ↑n) (m = n) (↑n < ↑m) → (cmp m n = Ordering.eq ↔ m = n)

Next tactic:
cases cmp m n
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; cases cmp m n <;> 

Proof state:
case lt
α : Type u_1
m n : PosNum
⊢ Ordering.casesOn Ordering.lt (↑m < ↑n) (m = n) (↑n < ↑m) → (Ordering.lt = Ordering.eq ↔ m = n)

Next tactic:
intro this
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; cases cmp m n <;> 

Proof state:
case eq
α : Type u_1
m n : PosNum
⊢ Ordering.casesOn Ordering.eq (↑m < ↑n) (m = n) (↑n < ↑m) → (Ordering.eq = Ordering.eq ↔ m = n)

Next tactic:
intro this
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; cases cmp m n <;> 

Proof state:
case gt
α : Type u_1
m n : PosNum
⊢ Ordering.casesOn Ordering.gt (↑m < ↑n) (m = n) (↑n < ↑m) → (Ordering.gt = Ordering.eq ↔ m = n)

Next tactic:
intro this
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; cases cmp m n <;> intro this <;> 

Proof state:
case lt
α : Type u_1
m n : PosNum
this : Ordering.casesOn Ordering.lt (↑m < ↑n) (m = n) (↑n < ↑m)
⊢ Ordering.lt = Ordering.eq ↔ m = n

Next tactic:
simp at this ⊢
@[simp]
theorem cmp_eq (m n) : cmp m n = Ordering.eq ↔ m = n := by
  have := cmp_to_nat m n
  -- Porting note: `cases` didn't rewrite at `this`, so `revert` & `intro` are required.
  revert this; cases cmp m n <;> intro this <;> 

Proof state:
case eq
α : Type u_1
m n : PosNum
this : Ordering.casesOn Ordering.eq (↑m < ↑n) (m = n) (↑n < ↑m)
⊢ Ordering.eq = Ordering.eq ↔ m = n

Next tactic:
simp at this ⊢