Zulip Chat Archive

Stream: new members

Topic: generated names


Callan McGill (Jan 19 2022 at 04:16):

I am going through kevin buzzard's very pleasant current undergraduate course and there is a proof of the form:

example : ((P  Q)  R)  (P  (Q  R)) :=
begin
  sorry
end

I know a bit about coq style proofs and so I wanted to do this using semicolons as something like:

example : ((P  Q)  R)  (P  (Q  R)) :=
begin
  split; intros, cases 1, cases 1; try cases 1; cases 2; split; try assumption; split; try assumption
end

or something like that, but I don't know what names lean is guaranteed to generate so I wanted to know what is the proper way to refer to such names in a robust way?

Kevin Buzzard (Jan 19 2022 at 04:22):

This works:

import tactic

variables (P Q R : Prop)

example : ((P  Q)  R)  (P  (Q  R)) :=
begin
  split;
  { intro h,
    cases h with h1 h2,
    try {cases h1},
    try {cases h2},
    split;
    try {assumption},
    split;
    assumption,
  },
end

I don't know how to run cases on a term whose name I don't know.

Kyle Miller (Jan 19 2022 at 04:38):

tactic#destruct seems useful here

example {P Q R : Prop} : ((P  Q)  R)  (P  (Q  R)) :=
begin
  split;
  repeat { intro h, try { destruct h }, };
  repeat { split };
  assumption,
end

Kyle Miller (Jan 19 2022 at 04:39):

It seems to be like cases, but it does tactic#revert to all the new hypotheses


Last updated: Dec 20 2023 at 11:08 UTC