A matrix generation apparatus comprising: a tree structure generation part adapted to receive as input a logical formula and generate tree structure data expressing the logical formula; a root processing part adapted to determine a type of an element expressed by a root of the tree structure data generated by the tree structure generation part, among elements of the logical formula, and generate a matrix corresponding to the determined type, the determined type being one of a logical sum operator or a logical product operator; and a node processing part adapted to store in a memory the matrix generated by the root processing part, the node processing part adapted to sequentially select nodes, other than the root, of the tree structure data generated by the tree structure generation part, if having selected a node having a child node, then perform an operation corresponding to a type of an element expressed by the selected node, among the elements of the logical formula, on the matrix stored in the memory, if having selected a node not having a child node, then associate a variable being the element expressed by the selected node, among the elements of the logical formula, with one row of the matrix stored in the memory, and after having selected the nodes of the tree structure data, output the matrix stored in the memory and information indicating variables associated with respective rows of the matrix, characterized in that the root processing part is adapted to, if the determined type is a logical sum operator, generate a 2-row, 1-column matrix in which every component is 1, as a matrix corresponding to the logical sum operator, or, if the determined type is a logical product operator, generate a 2-row, 2-column matrix in which a 1 st-row, 1 st-column component and a 2nd-row, 2nd-column component are each 1 or each 0, and a 1 st-row, 2nd-column component and a 2nd-row, 1st-column component are each 0 or each1, respectively, as a matrix corresponding to the logical product operator. a tree structure generation part adapted to receive as input a logical formula and generate tree structure data expressing the logical formula; a root processing part adapted to determine a type of an element expressed by a root of the tree structure data generated by the tree structure generation part, among elements of the logical formula, and generate a matrix corresponding to the determined type, the determined type being one of a logical sum operator or a logical product operator; and a node processing part adapted to store in a memory the matrix generated by the root processing part, the node processing part adapted to sequentially select nodes, other than the root, of the tree structure data generated by the tree structure generation part, if having selected a node having a child node, then perform an operation corresponding to a type of an element expressed by the selected node, among the elements of the logical formula, on the matrix stored in the memory, if having selected a node not having a child node, then associate a variable being the element expressed by the selected node, among the elements of the logical formula, with one row of the matrix stored in the memory, and after having selected the nodes of the tree structure data, output the matrix stored in the memory and information indicating variables associated with respective rows of the matrix,