Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

docs: issue with tactic_writing.md #901

Closed

Description

@holtzermann17

I see this error:

don’t know how to synthesize placeholder
context:
a b c : ℤ,
hyp : a = b
⊢ Type ?

Code below extracted from the file tactic_writing.md is designed to reproduce the error. Other examples from the file work fine, or else have some narration explaining why they don't work.

open tactic.interactive («have»)
open tactic (get_local infer_type)
open interactive (parse)
open lean.parser (ident)
open lean.parser (tk)
open interactive (loc.ns)
open interactive.types (texpr location)

meta def mul_left (q : parse texpr) : parse location → tactic unit
| (loc.ns [some h]) := do
   e ← tactic.i_to_expr q,
   H ← get_local h,
   `(%%l = %%r) ← infer_type H,
   «have» h ``(%%e*%%l = %%e*%%r)
            ``(congr_arg (λ x, %%e*x) %%H),
            tactic.clear H
| _ := tactic.fail "mul_left takes exactly one location"

-- it gives me an error, why?
example (a b c : ℤ) (hyp : a = b) : c*a = c*b :=
begin
  mul_left c at hyp,
  exact hyp
end

Activity

  1. minchaowu commented on Apr 8, 2019

    @minchaowu
    Collaborator

    @holtzermann17 It's because the mul_left should be in the tactic.interactive namespace. See #902

  2. holtzermann17 commented on Apr 10, 2019

    @holtzermann17
    Author

    I can confirm #902 fixes the problem, but it would probably be good to include some commentary elaborating on why it is that

    mul_left should be in the tactic.interactive namespace

    and why the previous tactics defined in the file don't have to be.

    Update: Oh wait, many of the previous tactics are in that namespace. And I guess that is explained with the somewhat confusing sentence near the top:

    Such functions are either called by other tactics---those are
    typically in the tactic namespace---or called interactively by users
    inside tactic blocks---those must be in the tactic.interactive
    namespace (this is not quite necessary for very simple tactics, but
    weird things will happen in general when ignoring this rule).

  3. PatrickMassot commented on Apr 11, 2019

    @PatrickMassot
    Member

    I really don't understand what is confusing in this sentence. Do you have something clearer than "must be in the tactic.interactive namespace? I was really surprised by #902.

  4. holtzermann17 commented on Apr 11, 2019

    @holtzermann17
    Author

    The facts in the sentence are reasonably clear. The grammar is wild. Here's an attempt that breaks it down into smaller bite-sized pieces.

    Such functions are either called by other tactics, or called interactively by users inside tactic blocks. Tactics that are called non-interactively typically live in the tactic namespace. Tactics that are called interactively must be in the tactic.interactive namespace. (In fact, this is not quite necessary for very simple tactics, but weird things will happen in general when ignoring this rule.)

    I'd be curious to know more about the edge cases described in the parenthetical comment but perhaps that's a discussion for Zulip.

  5. PatrickMassot commented on Apr 11, 2019

    @PatrickMassot
    Member

    I'm not surprised my sentences are too long, this comes from the French language. Don't hesitate to PR this proposal, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions