Mapped Many-Valued Semantics

Module by Joaquin S. Toranzo Calderon

Mapped Many-Valued Semantics

class logics.classes.propositional.semantics.mapped_logic.MappedManyValuedSemantics(language, truth_values, mapping_constraints, truth_function_dict, sentential_constant_values_dict, use_molecular_valuation_fast_version=False, name='MappedManyValuedSemantics object')

Class for many-valued semantics, with a consequence relation constrained by a set of allowed combinations of mappings for premises and conclusions. It extends the class MixedManyValuedSemantics.

Parameters:
  • language (language: logics.classes.propositional.Language or logics.classes.propositional.InfiniteLanguage) – Instance of Language or InfiniteLanguage.

  • truth_values (list) – A list of the truth values (which may be int, str, etc.).

  • mapping_constraints (MappingMatrix) – A boolean matrix representing the allowed combinations of mappings for premises (rows) and mapping for conclusions (columns). Rows and columns are ordered, such that the initial rows and columns are linked to subsets of truth_values with lesser values than the final rows and columns. The order between rows or columns linked to equinumerous subsets respects the order of the elements of the subsets. A permitted mapping is represented with a one and a prohibited mapping with a zero.

  • truth_function_dict (dict) – Dict containing the logical constants (str) as keys, and n-dimensional lists as values (for constants of arity n). Will also accept any indexable (things with a __getitem__ method, e.g. numpy arrays) and any n-ary callable.

  • sentential_constant_values_dict (dict) – Dict containing the sentential constants (str) as keys, and their truth values (members of truth_values) as values.

  • use_molecular_valuation_fast_version (bool) – Implements a faster version of the molecular valuation function (e.g. if asked for a disjunction will return ‘1’ with one true disjunct, without evaluating the other). In counterpart, it is less general, since it assumes the Kleene truth matrices. Defaults to False.

  • name (str) – Name of the system (only for prettier printing to the console).

Notes

As in MixedManyValuedSemantics, the order of truth_values is the order in which the rows and columns will be read in the truth functions. For defining mapping_constraints, you must also use a set of truth values: It must be the same set.

Raises:

ValueError – If some logical constant of the language does not receive a truth function (or receives something that is neither a callable nor an indexible), or some sentential constant does not receive a truth value (or gets a truth value not present in truth_values).

Examples

>>> from logics.instances.propositional.languages import classical_infinite_language_with_sent_constants     ...     as classical_language
>>> from logics.instances.propositional.mapped_logic_semantics import     ...     two_valued_truth_preservation_from_all_premises_to_some_conclusions, classical_truth_functions,     ...     classical_sentential_constants_values
>>> two_valued_truth_preservation_from_all_premises_to_some_conclusions_logic = MappedManyValuedSemantics(
...     language=classical_language,
...     truth_values=['1', '0'],
...     mapping_constraints=two_valued_truth_preservation_from_all_premises_to_some_conclusions,
...     truth_function_dict=classical_truth_functions,
...     sentential_constant_values_dict=classical_sentential_constants_values,
...     use_molecular_valuation_fast_version=True,
...     name='CL_2V_all_some')
>>> from logics.instances.propositional.mapped_logic_semantics import     ...     three_valued_truth_values, three_valued_truth_functions, three_valued_sentential_constants_values,     ...     three_valued_strict_tolerant_from_all_premises_to_some_conclusions
>>> three_valued_strict_tolerant_from_all_premises_to_some_conclusions_logic = MappedManyValuedSemantics(
...     language=classical_language,
...     truth_values=three_valued_truth_values,
...     mapping_constraints=three_valued_strict_tolerant_from_all_premises_to_some_conclusions,
...     truth_function_dict=three_valued_truth_functions,
...     sentential_constant_values_dict=three_valued_sentential_constants_values,
...     use_molecular_valuation_fast_version=True,
...     name='ST_all_some')
mapped_standard_to_formulae(formulae, atomic_valuation_dict=None, coordinate=False)

Gets, for a given a valuation, the subset of truth_values mapped to the set of formulae.

When coordinate is True, gets the index of mappings linked to the mapped subset.

Examples

>>> from logics.classes.propositional.formula import Formula
>>> from logics.instances.propositional.mapped_logic_semantics import         ...    three_valued_strict_tolerant_from_all_premises_to_some_conclusions_logic as ST
>>> ST.mapped_standard_to_formulae([Formula(['p']), Formula(['q'])],
...                                  {'p': '0', 'q':'0'})
['0']
>>> ST.mapped_standard_to_formulae([Formula(['p']), Formula(['q'])],
...                                  {'p': '0', 'q':'1'})
['1', '0']
>>> ST.mapped_standard_to_formulae([Formula(['p']), Formula(['q'])],
...                                  {'p': '1', 'q':'0'})
['1', '0']
>>> print(ST.mappings)
[[], ['1'], ['i'], ['0'], ['1', 'i'], ['1', '0'], ['i', '0'], ['1', 'i', '0']]
>>> ST.mapped_standard_to_formulae([Formula(['p']), Formula(['q'])],
...                                  {'p': '0', 'q':'0'}, coordinate=True)
3
mapped_standard_to_inferences(inference, atomic_valuation_dict=None, coordinate=False)

Gets, for a given a valuation, the subset of truth_values mapped to a pair of sets of formulae, one for premises and one for conclusions.

When coordinate is True, gets the index of mappings linked to the premises and the index linked to the conclusions.

Examples

>>> from logics.classes.propositional.formula import Formula
>>> from logics.classes.propositional.inference import Inference
>>> from logics.instances.propositional.mapped_logic_semantics import         ...    three_valued_strict_tolerant_from_all_premises_to_some_conclusions_logic as ST
>>> ST.mapped_standard_to_inferences(Inference([Formula(['p']), Formula(['q'])], [Formula(['p'])]),
...                                  {'p': '1', 'q': '0'})
[['1', '0'], ['1']]
>>> print(ST.mappings)
[[], ['1'], ['i'], ['0'], ['1', 'i'], ['1', '0'], ['i', '0'], ['1', 'i', '0']]
>>> ST.mapped_standard_to_inferences(Inference([Formula(['p']), Formula(['q'])], [Formula(['p'])]),
...                                  {'p': '1', 'q': '0'},
...                                  coordinate=True)
[5, 1]
valuation_matrix(inference)

Gets a valuation matrix (MappingMatrix) for a given inference.

Parameters:

inference (logics.classes.propositional.Inference) – The inference needed for constructing the matrix.

Returns:

It represents (with a one) for each possible valuation v, what combination of mappings gets linked to v. For every other combinations, it represents they are not linked to the inference with zeros.

Return type:

MappingMatrix

Examples

>>> from logics.classes.propositional.inference import Inference
>>> from logics.instances.propositional.mapped_logic_semantics import         ... two_valued_truth_preservation_from_all_premises_to_some_conclusions_logic as TrueTrue_AllSome
>>> TrueTrue_AllSome.valuation_matrix(Inference([Formula(['p']), Formula(['q'])], [Formula(['p'])]))
[
  [0, 0, 0, 0]
  [0, 1, 0, 0]
  [0, 0, 1, 0]
  [0, 1, 1, 0]
]
>>> from logics.instances.propositional.mapped_logic_semantics import         ...    three_valued_strict_tolerant_from_all_premises_to_some_conclusions_logic as ST
>>> ST.valuation_matrix(Inference([Formula(['p']), Formula(['q'])], [Formula(['p'])]))
[
  [0, 0, 0, 0, 0, 0, 0, 0]
  [0, 1, 0, 0, 0, 0, 0, 0]
  [0, 0, 1, 0, 0, 0, 0, 0]
  [0, 0, 0, 1, 0, 0, 0, 0]
  [0, 1, 1, 0, 0, 0, 0, 0]
  [0, 1, 0, 1, 0, 0, 0, 0]
  [0, 0, 1, 1, 0, 0, 0, 0]
  [0, 0, 0, 0, 0, 0, 0, 0]
]
satisfies(formula_or_inference, atomic_valuation_dict=None)

Returns True if the valuation satisfies the inference; False otherwise.

For a single formula, it assumes it is the single conclusion of an empty-premises inference.

Parameters:
Returns:

True if the valuation satisfies the inference; False otherwise.

Return type:

bool

Examples

>>> from logics.classes.propositional.inference import Inference
>>> from logics.instances.propositional.mapped_logic_semantics import         ... two_valued_truth_preservation_from_all_premises_to_some_conclusions_logic as TrueTrue_AllSome
>>> TrueTrue_AllSome.satisfies(Inference([Formula(['p']), Formula(['→', ['p'], ['q']])], [Formula(['q'])]),
...                            {'p': '1', 'q': '0'})
True
>>> TrueTrue_AllSome.satisfies(Inference([Formula(['q']), Formula(['→', ['p'], ['q']])], [Formula(['p'])]),
...                            {'p': '0', 'q': '1'})
False

Notes

There is no implementation for metainferences, yet.

Instances

The following are two-valued predefined instances of MappedManyValuedSemantics.

logics.instances.propositional.mapped_logic_semantics.two_valued_truth_preservation_from_all_premises_to_some_conclusions_logic

Classical logic semantics (truth values are ['1', '0'], premises receives a universal interpretation, and conclusions receives an existential interpretation): Truth preservation in a bivalent frame.

logics.instances.propositional.mapped_logic_semantics.two_valued_falsity_preservation_from_all_premises_to_some_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.two_valued_truth_preservation_from_all_premises_to_all_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.two_valued_falsity_preservation_from_all_premises_to_all_conclusions_logic

The following are three-valued predefined instances of MappedManyValuedSemantics.

logics.instances.propositional.mapped_logic_semantics.three_valued_tolerant_strict_from_all_premises_to_some_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.three_valued_tolerant_tolerant_from_all_premises_to_some_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.three_valued_strict_tolerant_from_all_premises_to_some_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.three_valued_strict_strict_from_all_premises_to_some_conclusions_logic
logics.instances.propositional.mapped_logic_semantics.intersective_mixed_logic_between_ss_and_tt_relations_all_some_logic

The above five systems share the truth values [‘1’, ‘i’, ‘0’]. The first four systems are the mixed systems TS, TT, ST and SS, in that order. The last one is the intersection between SS and TT. They all receive a universal interpretation for premises and an existential interpretation for conclusions.