module documentation
This module provides data structures for representing first-order models.
Class |
|
A dictionary which represents an assignment of values to variables. |
Class |
|
A first order model is a domain D of discourse and a valuation V. |
Class |
|
A dictionary which represents a model-theoretic Valuation of non-logical constants. Keys are strings representing the constants to be interpreted, and values correspond to individuals (represented as strings) and n-ary relations (represented as sets of tuples of strings). |
Exception |
|
Undocumented |
Exception |
|
Undocumented |
Function | arity |
Check the arity of a relation. :type rel: set of tuples :rtype: int of tuple of str |
Function | demo |
Run exists demos. |
Function | foldemo |
Interpretation of closed expressions in a first-order model. |
Function | folmodel |
Example of a first-order model. |
Function | is |
Check whether a set represents a relation (of any arity). |
Function | propdemo |
Example of a propositional model. |
Function | read |
Convert a valuation string into a valuation. |
Function | satdemo |
Satisfiers of an open formula in a first order model. |
Function | set2rel |
Convert a set containing individuals (strings or numbers) into a set of unary tuples. Any tuples of strings already in the set are passed through unchanged. |
Function | trace |
Undocumented |
Variable | mult |
Undocumented |
Function | _read |
Read a line in a valuation file. |
Constant | _ELEMENT |
Undocumented |
Constant | _TUPLES |
Undocumented |
Constant | _VAL |
Undocumented |
Run exists demos.
- num = 1: propositional logic demo
- num = 2: first order model demo (only if trace is set)
- num = 3: first order sentences demo
- num = 4: satisfaction of open formulas demo
- any other value: run all the demos
Parameters | |
num | Undocumented |
trace | trace = 1, or trace = 2 for more verbose tracing |
Check whether a set represents a relation (of any arity).
Parameters | |
s:set | a set containing tuples of str elements |
Returns | |
bool | Undocumented |
Convert a valuation string into a valuation.
Parameters | |
s:str | a valuation string |
encoding:str | the encoding of the input string, if it is binary |
Returns | |
Valuation | a nltk.sem valuation |
Convert a set containing individuals (strings or numbers) into a set of unary tuples. Any tuples of strings already in the set are passed through unchanged.
- For example:
- set(['a', 'b']) => set([('a',), ('b',)])
- set([3, 27]) => set([('3',), ('27',)])
Parameters | |
s:set | Undocumented |
Returns | |
set of tuple of str | Undocumented |
Read a line in a valuation file.
Lines are expected to be of the form:
noosa => n girl => {g1, g2} chase => {(b1, g1), (b2, g1), (g1, d1), (g2, d2)}
Parameters | |
s:str | input line |
Returns | |
tuple | a pair (symbol, value) |