22
$\begingroup$

I found the undocumented EquationalLogic`FindCounterexample[] by browsing the lists of available symbols, but I have no clue about its purpose.

The name is intriguing!

So far I found the following:

  • Accepts 2 or 3 arguments
  • Returns an Integer (1, 10, 15, 31, 100 ...)
  • For the first two arguments it seems to need equalities and boolean expressions (I didn't try quantifiers yet). Like in

    EquationalLogic`FindCounterexample[r == r + 1  && r == 2, b == 1]
    
  • For the third argument, almost anything is allowed
  • The numeric result seems to be connected to some feature of the equation system, but not sure to which one.

For example:

EquationalLogic`FindCounterexample[r == a + 1  , a == 1]
(*
-> 31
*)

EquationalLogic`FindCounterexample[r == a + 1  , r == a]
(*
-> 100
*)

Any suggestions or ideas about how to use this?

Edit

Some additional info, mostly provided by @Rojo:

Names["EquationalLogic`*"] // Column
(*
 "EquationalLogic`FindCounterexample"
 "EquationalLogic`FindProof"
 "EquationalLogic`Prove"
 "EquationalLogic`$MaxCounterexampleSearchSize"
     "EquationalLogic`$ProverOptions"
*)

All interesting names!

Now, look at this:

EquationalLogic`FindProof[y == x, y == 2 && x == 2]
(*
{ProofObject[
  InitialLemma[1, 2 == x],
  InitialLemma[2, 2 == y],
  InitialHypothesis[3, y == x],
  OrientRule[4, 2 -> x, Reason[1, Identity, 1]],
  ApplyLemma[5, 2 -> x, 2 == y, 0, 1, DeducedLemma[5, x == y, SupportingReason[2, x, x, 4, 0]]],
  OrientRule[6, x -> y, Reason[5, Identity, 2]],
  ApplyLemma[8, y -> x, y == x, 0, 1, SufficesToShow[8, True, SupportingReason[3, x, x, 6, 1]]],
  FinalGoal[9, True, EndReason[8]]
  ], True}

However, hold your expectations:

EquationalLogic`FindProof[2 y == 2 x, y == 2 && x == 2]
(*
{ProofObject[], False}
*)

If you run

Trace[EquationalLogic`FindProof[x == 0, x == 0], TraceInternal -> True]

among a lot of non human gibberish, you will find a lot of references to

EquationalLogicDump`skolem____$

And just for your reference, there is the Skolem normal form

$\endgroup$
4
  • $\begingroup$ infosuite.duke4.net/e1l5sm2.png $\endgroup$
    – Mr.Wizard
    Commented Jul 23, 2012 at 0:06
  • $\begingroup$ @Mr.Wizard Don't try to scare me off with that. Everybody is telling me the same since kindergarten. $\endgroup$ Commented Jul 23, 2012 at 4:14
  • $\begingroup$ Scare you off? Not at all! The screen shot is an "Easter egg" from a game: a reward of sorts for exploring beyond the intended limits. $\endgroup$
    – Mr.Wizard
    Commented Jul 23, 2012 at 4:28
  • $\begingroup$ @Mr.Wizard Ohhh sorry .. I believed you were looking for a job at the Thought Police $\endgroup$ Commented Jul 23, 2012 at 4:36

1 Answer 1

11
$\begingroup$

Pretty cool; EquationalLogic`FindCounterexample is still mysterious (at least to me), but I managed to get it to do something more interesting than spit back numbers.

EquationalLogic`FindCounterexample[f[a, i] == a, f[a, a] == a]
(* {{f -> ({{1, 2}, {1, 1}}[[##1]] &), a -> 1}, {i -> 2}} *)

It appears the the first clause satisfies the logical constraints from the second argument (i.e., the assumptions) and the second clause makes the first clause false.

This is speculation, but perhaps EquationalLogic`FindCounterexample returns a number when it has some kind of error.


EquationalLogic`FindProof and EquationalLogic`Prove appears to be implementing a term-rewriting based proof system (like Equational Logic from Mathworld). This reminds me of SIMP_TAC from the computer proof assistant HOL Light.

A key difference is that the logic of this prover does not follow the following rules from equational logic: $$\frac{a=b}{f(a)=f(b)}$$ $$\frac{a=b}{a(x)=b(x)}$$

Seems to work fine as a term-rewriting prover despite lacking those rules. Here's a little proof in combinatory logic using the EquationalLogic prover:

EquationalLogic`Prove[ForAll[x, ((s@k)@k)@x == x], 
                        ForAll[{x, y}, (k@x)@y == x] && 
                        ForAll[{f, g, x}, ((s@f)@g)@x == (f@x)@(g@x)]]
(* True *)

You can do a lot of this stuff with Prover9, if you want a point of comparison.

As a final note, since it is apparently possible to express combinatory logic in this system, it is possible to ask the EquationalLogic prover to prove an undecidable proposition. From my own experiments, it will eat up all of your memory if you ask it to prove something it can't.

$\endgroup$
9
  • 1
    $\begingroup$ Matt, welcome to the site, and thanks a lot for your very interesting answer! $\endgroup$ Commented Jul 27, 2012 at 4:40
  • 1
    $\begingroup$ Note: we prefer to post here executable code, and if it helps also the corresponding TEX expressions. You may want to edit your answer and add the Mathematica code for your last expression. $\endgroup$ Commented Jul 27, 2012 at 4:45
  • $\begingroup$ BTW ... What version of Mathematica are you using? $\endgroup$ Commented Jul 27, 2012 at 5:04
  • 1
    $\begingroup$ @Matt This is a very nice answer. I've edited your post to include copyable code, staying true to your latex equivalent, so that others can easily copy-paste and test it for themselves. Feel free to add a math equivalent in latex if it helps. There is generally no need to pretty print mathematica expressions (and usually InputForm is used here) $\endgroup$
    – rm -rf
    Commented Jul 27, 2012 at 5:11
  • 1
    $\begingroup$ This is what I intended. s[k][k] is the identity function in combinatory logic. Back in the 20s when this stuff was being invented, Schoenfinkle and Church treated function application as left associative. I agree that right associativity makes more sense for Mathematica. If you would like a reference, see Schoenfinkle's Building Blocks of Logic (1924), $\S3$. Note that Schoenfinkle wrote "C" instead of "K". $\endgroup$
    – Matt W-D
    Commented Jul 27, 2012 at 17:50

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.