This is the first in series of several Python scripts which I will post over the next couple of days as we add license which completely solves original problem. The code is written by my student Stephen Pardue. The first one is the final wrapper bftruthtable.py (boolean functions truth table). However, I have to post couple objects on which wrapper depends before you can use it.
#!/usr/local/bin/python
# Copyright (c) 2011, Stephen Pardue <spardue@aug.edu>
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
import argparse
from asciitruthtable import ascii_tables
from latextruthtable import latex_tables
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="generates truth tables for boolean functions",
epilog="By Stephen Pardue. Fear the pandas")
parser.add_argument(
"function", metavar="fn", type=str, nargs="+",
help="boolean function(s) to generate the table(s) for")
parser.add_argument(
"--ascii", dest="ascii", action="store_const",
const=True,
help="output the table(s) to stdout in ascii format"
)
parser.add_argument(
"--latex", dest="latex", action="store_const",
const=True,
help="output the table(s) to stdout in LaTex format")
args = parser.parse_args()
if args.ascii:
ascii_tables(args.function)
if args.latex:
latex_tables(args)