2

I need to simplify a set of solutions of a system, say for example:

A := (a[1] == 3 && a[2] <= 1 && b[1] <= 5) || (a[1] == 3 && a[2] == 1 && b[1] == -7)

I care only about a[1] and a[2] but I can not use Eliminate since I have inequalities. So one solution is:

Simplify[Reduce[Exists[{b[1]}, A]]]

a[1] == 3 && a[2] <= 1

It works! But since I have a large system (many b's) I need to automate this. Since:

Array[b, 1]

{b[1]}

I tried:

Simplify[Reduce[Exists[Array[b,1],A]]]

a[1] == 3 && a[2] <= 1 && b[1] <= 5

The second method yields the wrong outcome! What am I doing wrong here?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Sergio Parreiras
  • 409
  • 2
  • 11
  • I just noticed you deleted your other question... did you get an answer? I was midway through writing one... – rm -rf Mar 28 '13 at 23:59
  • sorry for wasting your time! after digging more I found this http://mathematica.stackexchange.com/questions/3070/from-a-list-to-a-list-of-rules which solves my other problem. thanks. – Sergio Parreiras Mar 29 '13 at 01:24
  • Ok, no problem. In any case, what you had was mostly fine; you just needed to use HoldPattern. For example, HoldPattern[a@# == _] -> True & /@ Range@5 will generate replacement rules for a[1] through a[5] – rm -rf Mar 29 '13 at 01:38

2 Answers2

4

Exists has attribute HoldAll:

Attributes[Exists]
(* {HoldAll, Protected, ReadProtected} *)

You need to do

Simplify@Reduce@Exists[Evaluate@Array[b, 1], A]
(* a[1] == 3 && a[2] <= 1 *)
Federico
  • 2,553
  • 16
  • 16
3

Exists has the attribute HoldAll:

Attributes[Exists]
(* {HoldAll, Protected, ReadProtected} *)

As such, specifying Exists[Array[b, 1], A] in your argument for Reduce is the same thing as telling that there is exists a value for the symbol of the form Array[b,1], verbatim, which makes A true.

Using Evaluate to make sure that Array is expanded into its appropriate set of values, you can achieve the desired result:

Simplify[Reduce[Exists[Evaluate[Array[b, 1]], A]]]
(* a[1] == 3 && a[2] <= 1 *)
VF1
  • 4,702
  • 23
  • 31
  • LOL! Our answers are identical! :D – Federico Mar 27 '13 at 00:43
  • We also adopted the same style for posting code: code followed by (* return value *). You just wrote a little more explanation. I'm tired instead, 2AM here... Good night! – Federico Mar 27 '13 at 00:47