chore: Nat.ltWf => Nat.lt_wf
This commit is contained in:
parent
ab8627d929
commit
9bb5d4dc93
3 changed files with 8 additions and 8 deletions
|
|
@ -16,12 +16,12 @@ private def div.F (x : Nat) (f : ∀ x₁, x₁ < x → Nat → Nat) (y : Nat) :
|
|||
|
||||
@[extern "lean_nat_div"]
|
||||
protected def div (a b : @& Nat) : Nat :=
|
||||
WellFounded.fix ltWf div.F a b
|
||||
WellFounded.fix lt_wf div.F a b
|
||||
|
||||
instance : Div Nat := ⟨Nat.div⟩
|
||||
|
||||
private theorem div_eq_aux (x y : Nat) : x / y = if h : 0 < y ∧ y ≤ x then (x - y) / y + 1 else 0 :=
|
||||
congrFun (WellFounded.fix_eq ltWf div.F x) y
|
||||
congrFun (WellFounded.fix_eq lt_wf div.F x) y
|
||||
|
||||
theorem div_eq (x y : Nat) : x / y = if 0 < y ∧ y ≤ x then (x - y) / y + 1 else 0 :=
|
||||
dif_eq_if (0 < y ∧ y ≤ x) ((x - y) / y + 1) 0 ▸ div_eq_aux x y
|
||||
|
|
@ -39,19 +39,19 @@ theorem div.inductionOn.{u}
|
|||
(ind : ∀ x y, 0 < y ∧ y ≤ x → motive (x - y) y → motive x y)
|
||||
(base : ∀ x y, ¬(0 < y ∧ y ≤ x) → motive x y)
|
||||
: motive x y :=
|
||||
WellFounded.fix Nat.ltWf (div.induction.F motive ind base) x y
|
||||
WellFounded.fix Nat.lt_wf (div.induction.F motive ind base) x y
|
||||
|
||||
private def mod.F (x : Nat) (f : ∀ x₁, x₁ < x → Nat → Nat) (y : Nat) : Nat :=
|
||||
if h : 0 < y ∧ y ≤ x then f (x - y) (div_rec_lemma h) y else x
|
||||
|
||||
@[extern "lean_nat_mod"]
|
||||
protected def mod (a b : @& Nat) : Nat :=
|
||||
WellFounded.fix ltWf mod.F a b
|
||||
WellFounded.fix lt_wf mod.F a b
|
||||
|
||||
instance : Mod Nat := ⟨Nat.mod⟩
|
||||
|
||||
private theorem mod_eq_aux (x y : Nat) : x % y = if h : 0 < y ∧ y ≤ x then (x - y) % y else x :=
|
||||
congrFun (WellFounded.fix_eq ltWf mod.F x) y
|
||||
congrFun (WellFounded.fix_eq lt_wf mod.F x) y
|
||||
|
||||
theorem mod_eq (x y : Nat) : x % y = if 0 < y ∧ y ≤ x then (x - y) % y else x :=
|
||||
dif_eq_if (0 < y ∧ y ≤ x) ((x - y) % y) x ▸ mod_eq_aux x y
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ private def gcdF (x : Nat) : (∀ x₁, x₁ < x → Nat → Nat) → Nat → Na
|
|||
|
||||
@[extern "lean_nat_gcd"]
|
||||
def gcd (a b : @& Nat) : Nat :=
|
||||
WellFounded.fix ltWf gcdF a b
|
||||
WellFounded.fix lt_wf gcdF a b
|
||||
|
||||
@[simp] theorem gcd_zero_left (y : Nat) : gcd 0 y = y :=
|
||||
rfl
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ def wf (h : WellFounded r) : WellFounded (TC r) :=
|
|||
end TC
|
||||
|
||||
-- less-than is well-founded
|
||||
def Nat.ltWf : WellFounded Nat.lt := by
|
||||
def Nat.lt_wf : WellFounded Nat.lt := by
|
||||
apply WellFounded.intro
|
||||
intro n
|
||||
induction n with
|
||||
|
|
@ -164,7 +164,7 @@ def measure {α : Sort u} : (α → Nat) → α → α → Prop :=
|
|||
InvImage (fun a b => a < b)
|
||||
|
||||
def measureWf {α : Sort u} (f : α → Nat) : WellFounded (measure f) :=
|
||||
InvImage.wf f Nat.ltWf
|
||||
InvImage.wf f Nat.lt_wf
|
||||
|
||||
def sizeofMeasure (α : Sort u) [SizeOf α] : α → α → Prop :=
|
||||
measure sizeOf
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue