ccobra.syllogistic

Syllogistic submodule.

Functions

ccobra.syllogistic.decode_response(enc_response, task)[source]

Decodes an encoded syllogistic response by transforming it to the corresponding tuple representation and inserting the appropriate terms.

Parameters
  • enc_response (str) – Encoded syllogistic response (e.g., ‘Aac’).

  • task (list(str)) – Syllogistic task in the tuple list representation (e.g., [[‘Some’, ‘models’, ‘managers’], [‘All’, ‘models’, ‘clerks’]]).

Returns

List representation of the response to decode.

Return type

list

ccobra.syllogistic.encode_response(response, task)[source]

Encodes a response to its syllogistic encoding.

Parameters
  • response (list(str)) – Syllogistc response in list representation (e.g., [‘All’, ‘A’, ‘C’])

  • task (list(list(str))) – Syllogistic task in list representation (e.g., [[‘All’, ‘A’, ‘B’], [‘Some’, ‘B’, ‘C’]]).

Returns

Syllogistic response encoding (e.g., ‘Aac’).

Return type

str

ccobra.syllogistic.encode_task(task)[source]

Encodes a syllogistic task.

Parameters

task (list(list(str))) – List representation of the syllogism (e.g., [[‘All’, ‘A’, ‘B’], [‘Some’, ‘B’, ‘C’]]).

Returns

Syllogistic task encoding (e.g., ‘AI1’).

Return type

str

Classes

class ccobra.syllogistic.Syllogism(item)[source]

Syllogistic helper class. Facilitates the extraction of premise information as well as encoding and decoding of responses.

Constructs the Syllogism based on a given task item.

Parameters

item (ccobra.Item) – CCOBRA task item container to base this Syllogism helper on.

decode_response(encoded_response)[source]

Decodes a syllogistic response in string representation based on the information stored in the syllogism’s premises.

Parameters

encoded_response (str) – Encoded syllogistic response (e.g., ‘Aac’).

Returns

List representation of the encoded response (e.g., [‘All’, ‘clerks’, ‘managers’]).

Return type

list(str)

encode_response(response)[source]

Encodes a given syllogistic response based on the information contained in the premises.

Parameters

response (list(str)) – Syllogistic response in list representation (e.g., [‘All’, ‘clerks’, ‘managers’]).

Returns

String encoding of the response (e.g., ‘Aac’).

Return type

str

encoded_task

String representation of the task

figure

Figure of the syllogism

is_valid_syllogism()[source]

Returns true if syllogism is valid, i.e., has a logically valid conclusion.

Returns

True, if syllogism is valid, i.e., has a logically valid conclusion. False otherwise.

Return type

bool

item

Instance of the item the Syllogism is constructed on. The instance is copied in order to prevent reference mismatches from happening.

logically_valid_conclusions()[source]

Returns the list of logically valid (according to first-order logics) conclusions for the syllogism.

Returns

List of logically valid conclusions.

Return type

list(str)

p1

List representation of the first premise

p2

List representation of the second premise

quantifier_p1

Quantifier of the first premise

quantifier_p2

Quantifier of the second premise

task

Reference to the task the Syllogism is constructed on.

class ccobra.syllogistic.SyllogisticTaskEncoder[source]

Syllogistic encoder. Provides functions for abbreviating syllogistic tasks.

static encode_response(response, task)[source]

Encodes a response to its syllogistic encoding.

Parameters
  • response (list(str)) – Syllogistc response in list representation (e.g., [‘All’, ‘A’, ‘C’])

  • task (list(list(str))) – Syllogistic task in list representation (e.g., [[‘All’, ‘A’, ‘B’], [‘Some’, ‘B’, ‘C’]]).

Returns

Syllogistic response encoding (e.g., ‘Aac’).

Return type

str

static encode_task(task)[source]

Encodes a task to its syllogistic encoding.

Parameters

task (list(list(str))) – List representation of the syllogism (e.g., [[‘All’, ‘A’, ‘B’], [‘Some’, ‘B’, ‘C’]]).

Returns

Syllogistic task encoding (e.g., ‘AI1’).

Return type

str

Raises

ValueError – If figure of syllogism cannot be determined.

class ccobra.syllogistic.SyllogisticResponseEncoder[source]

Syllogistic encoder. Provides functions for abbreviating syllogistic responses.

static encode_response(response, task)[source]

Encodes a response to its syllogistic encoding.

Parameters
  • response (list(str)) – Syllogistc response in list representation (e.g., [‘All’, ‘A’, ‘C’])

  • task (list(list(str))) – Syllogistic task in list representation (e.g., [[‘All’, ‘A’, ‘B’], [‘Some’, ‘B’, ‘C’]]).

Returns

Syllogistic response encoding (e.g., ‘Aac’).

Return type

str