TransWikia.com

Equational Reasoning for Functional Programming

TeX - LaTeX Asked by thoughtpolice on July 20, 2021

How can I create equational reasoning proof like the ones in CS literatures:

  A + (B + C)
=   { Associativity }
  (A + B) + C
=   { Commutativity }
  (B + A) + C

I can’t seem to find the right package except maybe with lhs2tex. Thanks!

2 Answers

A possible solution, using an align* environment.

enter image description here

documentclass{article}
usepackage{amsmath} % for 'align*' env.
begin{document}

begin{align*}
 &quad A + ( B + C ) 
=&qquad text{{ Associativity }} 
 &quad (A + B) + C 
=&qquad text{{ Commutativity }} 
 &quad (B+A)+C 
end{align*}

end{document}

Correct answer by Mico on July 20, 2021

This is almost identical to the first example of the witharrows package documentation. There are many ways to customize things, but it does seem to match the requirements.

documentclass{article}
usepackage{witharrows}
begin{document}
$begin{WithArrows}
F&=A + (B + C) Arrow{Associativity}
&=  (A + B) + CArrow{Commutativity}
&=  (B + A) + C%<-------don't put  here 
end{WithArrows}$
end{document}

enter image description here

Answered by user238301 on July 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP