lean4-htt/tests/lean/run/issue11449.lean
Leonardo de Moura 0173444d24
feat: heterogeneous contructor injectivity in grind (#11491)
This PR implements heterogeneous contructor injectivity in `grind`.

Example:
```lean
opaque double : Nat → Nat

inductive Parity : Nat -> Type
  | even (n) : Parity (double n)
  | odd  (n) : Parity (Nat.succ (double n))

opaque q : Nat → Nat → Prop
axiom qax : q a b → double a = double b
attribute [grind →] qax

example
  (motive : (x : Nat) → Parity x → Sort u_1)
  (h_2 : (j : Nat) → motive (double j) (Parity.even j))
  (j n : Nat)
  (heq_1 : q j n) -- Implies that `double j = double n`
  (heq_2 : Parity.even n ≍ Parity.even j):
  h_2 n ≍ h_2 j := by
grind
```

Closes #11449
2025-12-03 04:01:19 +00:00

26 lines
672 B
Text

opaque double : Nat → Nat
inductive Parity : Nat -> Type
| even (n) : Parity (double n)
| odd (n) : Parity (Nat.succ (double n))
example
(motive : (x : Nat) → Parity x → Sort u_1)
(h_2 : (j : Nat) → motive (double j) (Parity.even j))
(j n : Nat)
(heq_1 : double n = double j)
(heq_2 : Parity.even n ≍ Parity.even j):
h_2 n ≍ h_2 j := by
grind
example
(motive : (x : Nat) → Parity x → Sort u_1)
(h_2 : (j : Nat) → motive (double j) (Parity.even j))
(j n : Nat)
(heq_1 : double n = double j)
(heq_2 : Parity.even n ≍ Parity.even j):
h_2 n ≍ h_2 j := by
apply Parity.noConfusion heq_1 heq_2
intro hnj
subst hnj
rfl