Esempio n. 1
0
def test_b_tautology(string_b, output_file):
    '''Extracts all the lisp-readable expressions passed as arguments in
string_b then either prints it to the console, or writes it to the file
object called output_file if it is not None.

    Keyword Arguments:
    string_b -- The lisp-readable string with the expressions to be tested
based on whether or not they are tautologies.
    output_file -- The file object to write the results of the test to.
If no file was specified, this value is simply None.

    Returns:
    Nothing'''
    #Get the expressions and values, then get the individual expressions to be evaluated by parsing the result of the first call to get_exps once more.
    exps_and_vals = prog3.get_exps(prog3.remove_outer_parenthesis(string_b))
    test_exps = exps_and_vals[0]
    expressions_b = prog3.get_exps(prog3.remove_outer_parenthesis(test_exps))
    if output_file is None:
        print('\n')
    else:
        output_file.write('\n')
    for prop in expressions_b:
        if output_file is None:
            is_tautology = prog3.IsTautology(prop)
            print('(part_b_tautology {} {})'.format(prop,is_tautology))
        else:
            is_tautology = prog3.IsTautology(prop)
            output_file.write('(part_b_tautology {} {})\n'.format(prop,is_tautology))
Esempio n. 2
0
def test_b_tautology(string_b, output_file):
    '''Extracts all the lisp-readable expressions passed as arguments in
string_b then either prints it to the console, or writes it to the file
object called output_file if it is not None.

    Keyword Arguments:
    string_b -- The lisp-readable string with the expressions to be tested
based on whether or not they are tautologies.
    output_file -- The file object to write the results of the test to.
If no file was specified, this value is simply None.

    Returns:
    Nothing'''
    #Get the expressions and values, then get the individual expressions to be evaluated by parsing the result of the first call to get_exps once more.
    exps_and_vals = prog3.get_exps(prog3.remove_outer_parenthesis(string_b))
    test_exps = exps_and_vals[0]
    expressions_b = prog3.get_exps(prog3.remove_outer_parenthesis(test_exps))
    if output_file is None:
        print('\n')
    else:
        output_file.write('\n')
    for prop in expressions_b:
        if output_file is None:
            is_tautology = prog3.IsTautology(prop)
            print('(part_b_tautology {} {})'.format(prop, is_tautology))
        else:
            is_tautology = prog3.IsTautology(prop)
            output_file.write('(part_b_tautology {} {})\n'.format(
                prop, is_tautology))
Esempio n. 3
0
def test_c(string_c, output_file):
    '''Extracts all the lisp-readable expressions passed as arguments in
string_c then either prints it to the console, or writes it to the file
object called output_file if it is not None.

    Keyword Arguments:
    string_c -- The lisp-readable string with the expressions to be tested
for well-formedness in the context of FOL
    output_file -- The file object to write the results of the test to.
If no file was specified, this value is simply None.

    Returns:
    Nothing'''

    expressions_c = prog3.get_exps(prog3.remove_outer_parenthesis(string_c))
    if output_file is None:
        print('\n')
    else:
        output_file.write('\n')
    for prop in expressions_c:
        is_wf = prog3.wfp_checkerFOL(prop)
        if output_file is None:
            print('(part_c {} {})'.format(prop, is_wf))
        else:
            output_file.write('(part_c {} {})\n'.format(prop, is_wf))
Esempio n. 4
0
def test_c(string_c, output_file):
    '''Extracts all the lisp-readable expressions passed as arguments in
string_c then either prints it to the console, or writes it to the file
object called output_file if it is not None.

    Keyword Arguments:
    string_c -- The lisp-readable string with the expressions to be tested
for well-formedness in the context of FOL
    output_file -- The file object to write the results of the test to.
If no file was specified, this value is simply None.

    Returns:
    Nothing'''

    expressions_c = prog3.get_exps(prog3.remove_outer_parenthesis(string_c))
    if output_file is None:
        print('\n')
    else:
        output_file.write('\n')
    for prop in expressions_c:
        is_wf = prog3.wfp_checkerFOL(prop)
        if output_file is None:
            print('(part_c {} {})'.format(prop, is_wf))
        else:
            output_file.write('(part_c {} {})\n'.format(prop, is_wf))
Esempio n. 5
0
def test_a(string_a, output_file):
    '''Performs the tests for part a based on the Lisp-readable input given for part a. Determines whether the given propositions are well-formed and prints out the answer.

    Keyword Arguments:
    string_a -- The string starting with '(part_a' that contains the propositions to be tested for well-formedness.
    output_file -- The file object to output results to. If this is None then
output is printed to the console

    Returns:
    Nothing.'''
    expressions_a = prog3.get_exps(prog3.remove_outer_parenthesis(string_a))
    for prop in expressions_a:
        is_wf = prog3.wfp_checker(prop)
        if output_file is None:
            print('(part_a {} {})'.format(prop, is_wf))
        else:
            output_file.write('(part_a {} {})\n'.format(prop, is_wf))
Esempio n. 6
0
def test_a(string_a, output_file):
    '''Performs the tests for part a based on the Lisp-readable input given for part a. Determines whether the given propositions are well-formed and prints out the answer.

    Keyword Arguments:
    string_a -- The string starting with '(part_a' that contains the propositions to be tested for well-formedness.
    output_file -- The file object to output results to. If this is None then
output is printed to the console

    Returns:
    Nothing.'''
    expressions_a = prog3.get_exps(prog3.remove_outer_parenthesis(string_a))
    for prop in expressions_a:
        is_wf = prog3.wfp_checker(prop)
        if output_file is None:
            print('(part_a {} {})'.format(prop, is_wf))
        else:
            output_file.write('(part_a {} {})\n'.format(prop, is_wf))