0
$\begingroup$

As asked in this question, I strongly prefer to use "mathematical" typography in Mathematica over text-based ("computer science") typography. Nevertheless, it sometimes fails for no reason I can discern.

Here's a text-based proof from formal logic:

basicAxioms = {ForAll[{a, b}, And[a, b] == And[b, a]],
   ForAll[{a, b}, Or[a, b] == Or[b, a]]};

mybasicProof = FindEquationalProof[And[a, b] == And[b, a], basicAxioms]

which yields a perfectly normal proof, as can be seen by

mybasicProof["ProofGraph"]

But the (apparently) equivalent set of axioms and proof, expressed in mathematical typography, fails:

basicAxioms2 = {
   \!\(
\*SubscriptBox[\(\[ForAll]\), \(\({a, b}\)\(\ \)\)]a\) \[And] 
    b == b \[And] a,
   \!\(
\*SubscriptBox[\(\[ForAll]\), \(\({a, b}\)\(\ \)\)]a\) \[Or] 
    b == b \[Or] a};

 FindEquationalProof[a \[And] b == b \[And] a, basicAxioms2]

How can I express the axioms and proof using mathematical typography, and not ForAll[], And[], Or[], and such text-based entry?

$\endgroup$
3
  • 1
    $\begingroup$ It's a precedence issue. Equal has higher precedence than And, so a \[And] b == c is parsed as And[a, b==c] and not Equal[And[a, b], c]. $\endgroup$
    – Carl Woll
    Commented Mar 9, 2023 at 4:41
  • $\begingroup$ Up to the documentation, "Therefore, while StandardForm is an input format and an output format, TraditionalForm is primarily intended as an output format". I think no chance. $\endgroup$
    – user64494
    Commented Mar 9, 2023 at 5:09
  • $\begingroup$ I'd like to add that mybasicProof["ProofNotebook"] does not work the job. $\endgroup$
    – user64494
    Commented Mar 9, 2023 at 5:20

1 Answer 1

1
$\begingroup$

As mentioned by @CarlWoll in the comments, it comes down to the precedence of operators.

Precedence[And]
(* 215 *)

Precedence[Equal]
(* 290 *)

a ∧ b == b ∧ a // Trace
(* {a && b == b && a, {b == b, True}, a && a} *)

Working upon @CarlWoll's answer, you can define some other infix equal-like operator, define it as Equal, and give it a very low precedence (like the one of Equivalent) to achieve the desired parsing.

CurrentValue[EvaluationNotebook[], {InputAliases, "eq"}] = 
  TemplateBox[{}, "Equal", DisplayFunction -> (" ⪮ " &), 
   InterpretationFunction :> (Sequence["~", "Equal", "~"] &), 
   SyntaxForm -> "⧦"];

eq

However, the precedence of ForAll is $240$, even higher than that of And. So you will still need some brackets.

Solution 1

Obviously, the simplest solution is to just properly parenthesize the whole expression in the first place.

Solution 2

$\endgroup$
4
  • $\begingroup$ Unfortunately, I see && and == in ProofObject. What does "ProofNotebook" produce? Can you present the end of your code as a code instead of a picture? $\endgroup$
    – user64494
    Commented Mar 9, 2023 at 13:50
  • $\begingroup$ @user64494, I don't really understand where the problem is. My output is the same as the one the OP wants. $\endgroup$
    – Domen
    Commented Mar 9, 2023 at 13:55
  • $\begingroup$ I have doubts whether your words do correspond to reality in view of a&&b==b&&a in ProofObject. Hope I am clear. $\endgroup$
    – user64494
    Commented Mar 9, 2023 at 17:06
  • $\begingroup$ @user64494, sorry, I have read read your comment several times, but I do not understand your point :-/ $\endgroup$
    – Domen
    Commented Mar 9, 2023 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.