Zulip Chat Archive

Stream: new members

Topic: chaining together heterogeneous equalities


Patrick Nicodemus (Nov 10 2025 at 16:26):

How do you chain together heterogeneous equalities?

example het_eq (A B C D  :Type u) (a : A) (b : B) (c :C) (d :D)
  (p : a  b)(q : b  c) (r : c  d) : a  d := by
  calc
  a  b := p
  _  c := q -- invalid 'calc' step, left-hand side is C : Type u but previous right-hand side is  b : B
  _  d := r

Aaron Liu (Nov 10 2025 at 16:29):

oh heq doesn't work with calc because of how the arguments are ordered

Aaron Liu (Nov 10 2025 at 16:30):

probably best to use docs#HEq.trans manually or automation would take care of this too

Eric Wieser (Nov 10 2025 at 16:32):

Should the argument order be changed so that this works?

Aaron Liu (Nov 10 2025 at 16:35):

it looks like it would give you one parameter and three indices instead of what we have now which is two parameters and two indices

Patrick Nicodemus (Nov 10 2025 at 16:37):

Okay. I used HEqtrans manually and that was fine.

Kenny Lau (Nov 10 2025 at 18:09):

@Patrick Nicodemus you can also use the trans tactic:

import Batteries.Tactic.Trans

universe u

example (A B C D : Type u) (a : A) (b : B) (c : C) (d : D)
    (p : a  b) (q : b  c) (r : c  d) : a  d := by
  trans b
  · exact p
  trans c
  · exact q
  · exact r

Last updated: Dec 20 2025 at 21:32 UTC