Zulip Chat Archive

Stream: new members

Topic: Inline subsitution


Marcus Rossel (Jun 02 2021 at 16:42):

I often find myself in proofs doing something like:

  example {n m o : } : (n < m)  (m = o)  (n < o) :=
  begin
    intros h_lt h_eq,
    rw h_eq at h_lt, -- focus point 1
    exact h_lt       -- focus point 2
  end

Is there a way to perform the substitution inline in some way? So that I can write something like:

...
    intros h_lt h_eq,
    exact (h_lt <~ h_eq)
  end

Kevin Buzzard (Jun 02 2021 at 18:24):

exact h_eq ▸ h_lt,

Kevin Buzzard (Jun 02 2021 at 18:25):

The triangle is just notation for eq.subst and after a while you learn that the rw tactic is _far_ more sophisticated, however it will work if the stars are aligned.

Damiano Testa (Jun 02 2021 at 18:46):

While not shorter, calc produces very readable code:

λ hlt heq, calc n < m : hlt
   ... = o : heq

(I'm not at a computer: the code above is untested.)

Alistair Tucker (Jun 02 2021 at 19:03):

A third option: rwa h_eq at hlt

Marcus Rossel (Jun 03 2021 at 06:26):

Kevin Buzzard said:

The triangle is just notation for eq.subst and after a while you learn that the rw tactic is _far_ more sophisticated, however it will work if the stars are aligned.

Ok yeah, the stars being aligned was my problem :D
I tried this syntax but there were metavariables messing it up.


Last updated: Dec 20 2023 at 11:08 UTC