22

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

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453

1 Answers1

11

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.

Matt W-D
  • 306
  • 3
  • 7
  • 1
    Matt, welcome to the site, and thanks a lot for your very interesting answer! – Dr. belisarius Jul 27 '12 at 04:40
  • 1
    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. – Dr. belisarius Jul 27 '12 at 04:45
  • BTW ... What version of Mathematica are you using? – Dr. belisarius Jul 27 '12 at 05:04
  • 1
    @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) – rm -rf Jul 27 '12 at 05:11
  • @belisarius: Okay, I'll make sure to follow the convention in the future. I'm using Mathematica 8.0 – Matt W-D Jul 27 '12 at 13:34
  • @R.M - Thanks. @ in Mathematica are right-associative, which is a little different than in combinatory logic and lambda calculus (where function application is left associative). So I fixed that... – Matt W-D Jul 27 '12 at 13:44
  • Matt, is that what you intended? This gives s[k][k][x], whereas using composition gives s[k[k[x]]] and they're both different. I thought the latter was closer to your latex expression (yes, the associativity had to be fixed), but I could be wrong, because this is not my field – rm -rf Jul 27 '12 at 13:58
  • 1
    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". – Matt W-D Jul 27 '12 at 17:50
  • Thanks for the clarification and the reference, Matt :) – rm -rf Jul 27 '12 at 18:27