lean4-htt/tests/elab/grind_11086.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

49 lines
2 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.

open Sum Function
-- This needs to be in the library!
-- https://github.com/leanprover/lean4/pull/11085
attribute [grind =] Prod.map_fst Prod.map_snd
-- Copy the definition of `Equiv` from Mathlib.
structure Equiv (α : Sort _) (β : Sort _) where
protected toFun : α → β
protected invFun : β → α
protected left_inv : LeftInverse invFun toFun := by intro; first | rfl | ext <;> rfl
protected right_inv : RightInverse invFun toFun := by intro; first | rfl | ext <;> rfl
infixl:25 " ≃ " => Equiv
def sumProdDistrib (α β γ) : (α ⊕ β) × γα × γ ⊕ β × γ :=
⟨fun p => p.1.map (fun x => (x, p.2)) fun x => (x, p.2),
fun s => s.elim (Prod.map inl id) (Prod.map inr id), by
rintro ⟨_ | _, _⟩ <;> rfl, by
rintro (⟨_, _⟩ | ⟨_, _⟩)
· grind
· grind⟩
def sumProdDistrib' (α β γ) : (α ⊕ β) × γα × γ ⊕ β × γ :=
⟨fun p => p.1.map (fun x => (x, p.2)) fun x => (x, p.2),
fun s => s.elim (Prod.map inl id) (Prod.map inr id), by
rintro ⟨_ | _, _⟩ <;> rfl, by
rintro (⟨_, _⟩ | ⟨_, _⟩)
· grind +abstractProof
· grind +abstractProof⟩
def sumProdDistrib'' (α β γ) : (α ⊕ β) × γα × γ ⊕ β × γ :=
⟨fun p => p.1.map (fun x => (x, p.2)) fun x => (x, p.2),
fun s => s.elim (Prod.map inl id) (Prod.map inr id), by
rintro ⟨_ | _, _⟩ <;> rfl, by
rintro (⟨_, _⟩ | ⟨_, _⟩)
· grind?
· grind?⟩
example (α β γ) (fst : α) (snd : γ) :
(fun p : (α ⊕ β) × γ ↦ Sum.map (fun x ↦ (x, p.snd)) (fun x ↦ (x, p.snd)) p.fst)
((fun s ↦ Sum.elim (Prod.map inl id) (Prod.map inr id) s) (inl (fst, snd))) =
inl (fst, snd) := by
grind
example (α β γ) :
RightInverse (fun s : α × γ ⊕ β × γ ↦ Sum.elim (Prod.map inl id) (Prod.map inr id) s) fun p ↦
Sum.map (fun x ↦ (x, p.snd)) (fun x ↦ (x, p.snd)) p.fst := by
rintro (⟨_, _⟩ | ⟨_, _⟩) <;> grind