lean4-htt/tests/lean/run/grind_11086.lean
Leonardo de Moura f401f8b46e
fix: universe meta-variable support in grind (#11099)
This PR improves the support for universe-metavariables in `grind`.

Closes #11086
2025-11-06 03:38:59 +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