Zulip Chat Archive
Stream: general
Topic: Strange "synthesize placeholder" error
Michael Stoll (Sep 16 2022 at 16:05):
import tactic
def weight (n d : ℕ) : Type := fin n.succ → ℕ
open_locale big_operators
variables {n d : ℕ}
def wsum (w : weight n d) : ℕ := ∑ j, w j
#check ∀ (w : weight n d) (σ : equiv.perm (fin n.succ)), wsum (w ∘ σ) = wsum w -- no problem here
example : ∀ (w : weight n d) (σ : equiv.perm (fin n.succ)), wsum (w ∘ σ) = wsum w := sorry
gives an error (at "wsum"):
don't know how to synthesize placeholder
context:
n d : ℕ,
w : weight n d,
σ : equiv.perm (fin n.succ)
⊢ ℕ
What is going on here?
Note that removing all ds leads to something that does typecheck... :confused:
Michael Stoll (Sep 16 2022 at 16:09):
I can do
lemma test : ∀ (w : weight n d) (σ : equiv.perm (fin n.succ)),
let w' : weight n d := w ∘ σ in wsum w' = wsum w := sorry
but then I don't know how I can use the lemma -- rw test or simp [test] does not work.
Junyan Xu (Sep 16 2022 at 16:15):
You probably need to make d explicit in wsum. When you do w ∘ σ, the type of w gets unfolded to a fin n.succ → ℕ and d can no longer be inferred.
Eric Rodriguez (Sep 16 2022 at 16:16):
(I don't see why removing the d causes issues, if I do it locally it seems fine)
Eric Rodriguez (Sep 16 2022 at 16:18):
example : ∀ (w : weight n d) (σ : equiv.perm (fin n.succ)), @wsum n d (w ∘ σ) = wsum w := sorry also works, or maybe also a weight.comp method that preserves d by definition
Kyle Miller (Sep 16 2022 at 16:18):
I'd expect
example : ∀ (w : weight n d) (σ : equiv.perm (fin n.succ)), wsum (w ∘ σ : weight n d) = wsum w := sorry
to work
Eric Rodriguez (Sep 16 2022 at 16:19):
it doesn't, that is the show X, from _ vs (_ : X) issue again Kyle
Kyle Miller (Sep 16 2022 at 16:20):
Oh well, too bad type ascriptions don't act as hints when elaborating function arguments...
Kyle Miller (Sep 16 2022 at 16:21):
Depending on what the intent is, one potential solution is to define a custom composition function, like wsum.perm, that returns weight n d.
Kyle Miller (Sep 16 2022 at 16:22):
Another is to change wsum to not take a weight n d, but a fin n -> nat
Kyle Miller (Sep 16 2022 at 16:22):
and yet another is to turn weight into a structure so that d cannot be erased from the type through unfolding
Michael Stoll (Sep 16 2022 at 17:17):
OK, thanks. I can live with the @ variant.
Last updated: May 02 2025 at 03:31 UTC