14934Re: Boolean algebra solver?

Expand Messages
• Jun 3, 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Justin asked me for a real life example of how this technique
can be used to find factors, so at the risk of boring everyone
else, I thought I'd post it here on the forum. Here is a sample
Maple code snippet ('#' begins a comment) that illustrates the
problem:

n:= [0,0,1,1,1,1]: # factor binary 001111 = decimal 15 = 3*5

c1:=a1*b1:
c2:=(a2+a1*b1+b2)*c1+1+(a2*a1*b1+1)*(a2*b2+1)*(a1*b1*b2+1):
c3:=(a2+a1*b1+b2)*c1*(1+(a2*a1*b1+1)*(a2*b2+1)*(a1*b1*b2+1)):
c4:=1+(a2*b1*a1*b2+1)*(a2*b1*c2+1)*(a1*b2*c2+1):
c5:=1+(a2*b2*c3+1)*(a2*b2*c4+1)*(c3*c4+1):

eqn := {a1+b1 = 1,
a2+a1*b1+b2+c1 = 1,
a2*b1+a1*b2+c2 = 1,
a2*b2+c3+c4 = 0,
c5 = 0};

solve(eqn,{a1,a2,b1,b2}); # <= Maple can't solve this

# But the solution is:

a2:=0: a1:=1: # a0:=1, so that a= "011" binary = 3 decimal
b2:=1: b1:=0: # a0:=1, so that b= "101" binary = 5 decimal

# Where a=3 and b=5 are the factors of 15.

Ron Dotson
6/03/2004

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>

iQA/AwUBQL97thpqFjUCnHWBEQIOeQCgpMXLFGkaEsNQ/nshYRRMxNVi3+8An3RQ
20UaohAI3jTT0B9S1XCz0Fj2
=Zgga
-----END PGP SIGNATURE-----
• Show all 13 messages in this topic