Zulip Chat Archive

Stream: new members

Topic: dunfold for abbreviated notations?


Chris M (Jul 26 2020 at 04:19):

Consider the following code:

import tactic

variables {a b c : }
example (divab : a  b) (divac : a  c) : a  (b + c) :=
begin
   dunfold | at divab,
end

The dunfold doesn't work, probably because | is an abbreviation. Is there a way to make this work? (hopefully without actually manually stating the definition of a | b)

Jalex Stark (Jul 26 2020 at 04:21):

you probably want cases divab

Jalex Stark (Jul 26 2020 at 04:23):

I think \mid is an abbreviation for has_dvd.dvd, so it may be easier to rw or unfold with that

Chris M (Jul 26 2020 at 04:23):

Yeah I do, but I also want to know how to see the definition of a | b within the tactic.

Kevin Buzzard (Jul 26 2020 at 08:27):

The easiest way (in VS Code): hover over the \| symbol in the statement of your example, to discover that it is has_dvd.dvd. Other ways: #print notation \| just above or below your example, or set_option pp.notation false above your example, so you can see what Lean actually sees after the notation has been unravelled. dunfold takes a function, not notation. Finally, once you've figured out how to proceed after the unfolding:

import tactic

variables {a b c : }
example (divab : a  b) (divac : a  c) : a  (b + c) :=
begin
  dunfold has_dvd.dvd at divab,
  -- divab: ∃ (c : ℕ), b = a * c
  cases divab with m hm,
  -- ...
  sorry
end

don't forget to delete the dunfold, because your code probably compiles without it.


Last updated: Dec 20 2023 at 11:08 UTC