I am new to Mathematica, and would like some help in the following operation. I have a truth table stored in a text file. I want to read this in Mathematica, and find its Boolean Rule. Suppose I have two Boolean variables. I am reading the text file in Mathematica like this:
arr=Import["bool.txt","Table"]
Suppose this array is arr=
0 0 0
0 1 1
1 0 1
1 1 1
The third column represents the output, and the first two columns are the states of the inputs. For finding the Boolean rule, I need to convert this array as an association of
table={{0,0}->0,{0,1}->1,{1,0}->1,{1,1}->1}
So that I can infer the Boolean rule using the following function:
BooleanFunction[table,{x,y}]
My problem is, I don't know how to create the variable table
, from the array arr
. I looked up a bit and think the Association
function would be used, but not sure how. I need to do it for multiple text files, and am looking to develop a short program for this functionality. Any help would be appreciated.