lean4-htt/tests/elab/monotone.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

34 lines
1.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Preorder (α : Type u) extends LE α where
le_refl (a : α) : a ≤ a
le_trans {a b c : α} : a ≤ b → b ≤ c → a ≤ c
instance {α : Type u} {β : α → Type v} [(a : α) → Preorder (β a)] : Preorder ((a : α) → β a) where
le f g := ∀ a, f a ≤ g a
le_refl f := fun a => Preorder.le_refl (f a)
le_trans := fun h₁ h₂ a => Preorder.le_trans (h₁ a) (h₂ a)
-- In Lean 3, we defined `monotone` using the strict implicit notation `{{ ... }}`.
-- Implicit lambdas in Lean 4 allow us to use the regular `{...}`
def Monotone [Preorder α] [Preorder β] (f : α → β) :=
∀ {a b}, a ≤ b → f a ≤ f b
theorem monotone_id [Preorder α] : Monotone (α := α) id :=
fun h => h
theorem monotone_id' [Preorder α] : Monotone (α := α) id :=
@fun a b h => h -- `@` disables implicit lambdas
theorem monotone_id'' [Preorder α] : Monotone (α := α) id :=
fun {a b} (h : a ≤ b) => h -- `{a b}` disables implicit lambdas
theorem monotone_const [Preorder α] [Preorder β] (b : β) : Monotone (fun a : α => b) :=
fun _ => Preorder.le_refl b
theorem monotone_comp [Preorder α] [Preorder β] [Preorder γ] {g : β → γ} {f : α → β} (m_g : Monotone g) (m_f : Monotone f) : Monotone (g ∘ f) :=
fun h => m_g (m_f h)
theorem monotone_fun {α : Type u} {β : Type v} [Preorder α] [Preorder γ] {f : α → β → γ} (m : (b : β) → Monotone (fun a => f a b)) : Monotone f :=
fun h b => m b h
theorem ex [Preorder α] {f g h : αα} (m_h : Monotone h) (m_g : Monotone g) (m_f : Monotone f) : Monotone (h ∘ g ∘ f) :=
monotone_comp m_h (monotone_comp m_g m_f) -- implicit lambdas in action here