Wednesday, 26 April 2023

Why is Mace4 valuation not working in my Python program?

Here is a very simple example of the use of Mace4, taken directly from the NLTK Web site:

from nltk.sem import Expression
from nltk.inference import MaceCommand

read_expr = Expression.fromstring
a = read_expr('(see(mary,john) & -(mary = john))')
mb = MaceCommand(assumptions=[a])
mb.build_model()
print(mb.valuation)

When instead of mb.valuation I print the return value of mb.build_model() I get True so the model is correctly built. But when I ask print(mb.valuation)I get

Traceback (most recent call last):
  File "test2.py", line 8, in <module>
    print(mb.valuation)
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/mace.py", line 51, in valuation
    return mbc.model("valuation")
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/api.py", line 355, in model
    return self._decorate_model(self._model, format)
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/mace.py", line 185, in _decorate_model
    return self._convert2val(valuation_str)
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/mace.py", line 60, in _convert2val
    valuation_standard_format = self._transform_output(valuation_str, "standard")
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/mace.py", line 206, in _transform_output
    return self._call_interpformat(valuation_str, [format])[0]
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/mace.py", line 220, in _call_interpformat
    self._interpformat_bin = self._modelbuilder._find_binary(
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/inference/prover9.py", line 177, in _find_binary
    return nltk.internals.find_binary(
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/internals.py", line 675, in find_binary
    return next(
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/internals.py", line 661, in find_binary_iter
    yield from find_file_iter(
  File "/Users/yannis/miniconda3/lib/python3.8/site-packages/nltk/internals.py", line 620, in find_file_iter
    raise LookupError(f"\n\n{div}\n{msg}\n{div}")
LookupError: 

===========================================================================
NLTK was unable to find the interpformat file!
Use software specific configuration parameters or set the PROVER9 environment variable.

  Searched in:
    - /usr/local/bin/prover9
    - /usr/local/bin/prover9/bin
    - /usr/local/bin
    - /usr/bin
    - /usr/local/prover9
    - /usr/local/share/prover9

  For more information on interpformat, see:
    <https://www.cs.unm.edu/~mccune/prover9/>
===========================================================================

I installed Prover9 through brew install and everything went fine. Am I doing something wrong?



from Why is Mace4 valuation not working in my Python program?

No comments:

Post a Comment