Numpy Implementation#

NumpyPosition#

class theodias.NumpyPosition#

Bases: Position

Implements Position on the basis of Numpy arrays.

Methods

as_bitarray()

Position as BitarrayPosition.

as_list()

Position as integer list.

as_np_array(position)

Position as numpy array.

as_set()

Position as integer set.

as_ternary()

Position as ternary.

difference(other)

The set theoretic difference of two positions.

direct_subpositions()

Iterate over subpositions that have exactly one element less than the position itself.

domain()

Determines the domain of the position.

from_set(position, n)

Instanciating a Position from a set.

intersection(*positions)

The set theoretic intersection of positions.

is_accepting(sentence)

Checks whether sentence is in the position.

is_in_domain(sentence)

Checks whether sentence is in the domain of the position.

is_minimally_compatible(position)

Checks for minimal compatibility with position.

is_minimally_consistent()

Checks for minimal consistency.

is_subposition(pos2)

Checks for set-theoretic inclusion.

neighbours(depth)

Iterate over the neighbours of the position.

sentence_pool()

Returns the sentences (without negations) of a position's sentence pool.

size()

size of the position

subpositions([n, only_consistent_subpositions])

Iterator over subsets of size n.

to_numpy_position(position)

Convert an implemented instance of Position to an instance of NumpyPosition.

union(*positions)

The set theoretic union of positions.

__init__(pos)#

Instantiates a NumpyPosition from a numpy array.

A sentence \(s_{i}\) of a position \(\mathcal{A}\) (over a sentence pool with \(n\) unnegated sentences) corresponds to an entry at index \(i-1\) in a numpy array of length \(n\). 1 represents acceptance (\(s_{i}\in\mathcal{A}\)), 2 stands for rejection (\(\neg s_{i}\in\mathcal{A}\)), and 3 denotes acceptance and rejection (flat contradiction). Absent sentences correspond to 0. For example, for a sentence pool of 7 unnegated sentences, \(\mathcal{A} = \lbrace s_{1}, \neg s_{2}, s_{6} \rbrace\) correponds to numpy.array([1, 2, 0, 0, 0, 1, 0]), which can be handed over to NumpyPosition.

Note

It is more comfortable to instantiate NumpyPosition with NumpyPosition.from_set

Parameters:

pos (ndarray) –

as_bitarray()#

Position as BitarrayPosition.

A pair of bits represents a sentence: The first bit represents acceptance and the second bit rejection. Suspension of a sentence corresponds to both bits being False/0 and (minimal or flat) contradiction is present if both bits are True/1. For instance, the position \(\{ s_1, s_3, \neg s_4 \}\) is represented by 10001001.

Return type:

bitarray

Returns:

a bitarray representation of the position if possible, otherwise should return None

as_list()#

Position as integer list.

The position \(\mathcal{A}\) represented by a python list of integer values. \(s_i \in \mathcal{A}\) is represented by \(i\) and \(\neg s_i \in \mathcal{A}\) by \(-i\). For instance, the position \(\{ s_1, s_3, \neg s_4 \}\) is represented by [1, 3, -4].

Note

The returned order of the values is not specified.

Return type:

List[int]

Returns:

a representation of the position as a list of integer values

static as_np_array(position)#

Position as numpy array.

Parameters:

position (Position) – An instance of Position

Return type:

ndarray

Returns:

A numpy array of length \(n\) (size of the sentence pool associated with the position). An entry at index \(i\) corresponds to the standing of \(s_{i+1}\) according to the following conventions: 1: acceptance, 2: rejection, 3: acceptance and rejection, 0: abstention

as_set()#

Position as integer set.

The position \(\mathcal{A}\) represented by a python set of integer values. \(s_i \in \mathcal{A}\) is represented by \(i\) and \(\neg s_i \in \mathcal{A}\) by \(-i\). For instance, the position \(\{ s_1, s_3, \neg s_4 \}\) is represented by {1, 3, -4}.

Return type:

Set[int]

Returns:

a representation of the position as a set of integer values

as_ternary()#

Position as ternary.

The position \(\mathcal{A}\) represented by an integer of base 4. \(s_i \in \mathcal{A}\) is represented by \(1*10^{i-1}\), \(\neg s_i \in \mathcal{A}\) by \(2*10^{i-1}\), \(s_i, \neg s_i \notin \mathcal{A}\) by zero and \(s_i, \neg s_i \notin \mathcal{A}\) by 3. For instance, the position \(\{ s_1, s_3, \neg s_4 \}\) is represented by the integer 2101.

Return type:

int

Returns:

a ternary representation of the position if possible, otherwise should return None

difference(other)#

The set theoretic difference of two positions.

Return type:

Position

Returns:

The set-theoretic difference of the two positions (sentences that are in the position but not in the other position).

Raises:

a ValueError if the sentence pools do not match.

Parameters:

other (Position) –

direct_subpositions()#

Iterate over subpositions that have exactly one element less than the position itself.

Return type:

Iterator[Position]

domain()#

Determines the domain of the position.

The domain of a position \(\mathcal{A}\) is the closure of \(\mathcal{A}\) under negation.

Return type:

Position

Returns:

the domain of the position

static from_set(position, n)#

Instanciating a Position from a set.

Returns:

Position

Parameters:

position (Set[int]) –

intersection(*positions)#

The set theoretic intersection of positions.

Return type:

Position

Returns:

The set-theoretic intersection of the position with the given positions. If no argument is provided, the empty position is returned.

Raises:

a ValueError if the sentence pools do not match.

Parameters:

positions (Position) –

is_accepting(sentence)#

Checks whether sentence is in the position.

Parameters:

sentence (int) – A sentence \(s_i\) represented by i.

Return type:

bool

Returns:

True iff sentence is in the position.

is_in_domain(sentence)#

Checks whether sentence is in the domain of the position.

Parameters:

sentence (int) – A sentence \(s_i\) represented by i.

Return type:

bool

Returns:

True iff sentence is in the domain of the position.

is_minimally_compatible(position)#

Checks for minimal compatibility with position.

Two positions \(\mathcal{A}\) and \(\mathcal{A}'\) are minimally compatible iff \(\mathcal{A} \cup \mathcal{A}'\) is minimally consistent.

Return type:

bool

Returns:

True iff the position-instance is compatible with position

Parameters:

position (Position) –

is_minimally_consistent()#

Checks for minimal consistency.

A position \(\mathcal{A}\) is minimally consistent iff \(\forall s \in S: s\in \mathcal{A} \rightarrow \neg s \notin \mathcal{A}\)

Return type:

bool

Returns:

True iff the position is minimally consistent

is_subposition(pos2)#

Checks for set-theoretic inclusion.

The position \(\mathcal{A}\) is a subposition of \(\mathcal{A}'\) iff \(\mathcal{A} \subseteq \mathcal{A}'\).

Return type:

bool

Returns:

True iff the position-instance is a subposition of position

Parameters:
neighbours(depth)#

Iterate over the neighbours of the position.

Parameters:

depth (int) – Depth of the neighbourhood, i.e. positions that can be reached by at most depth many adjustments of individual sentences. The number of neighbours is \(\sum_{k=0}^{d} {n \choose k} \cdot 2^k\), where \(n\) is the number of unnegated sentences in the sentence pool, and \(d\) is the depth of the neighbourhood, including the position itself.

Return type:

Iterator[Position]

Returns:

An iterator over positions in the neighbourhood of the position, including the position itself.

sentence_pool()#

Returns the sentences (without negations) of a position’s sentence pool.

Returns from \(S = \{ s_1, s_2, \dots, s_N, \neg s_1, \neg s_2, \dots, \neg s_N \}\) only \(\{ s_1, s_2, \dots, s_N\}\)

Return type:

Position

Returns:

“Half” of the full sentence pool \(S\) as Position (sentences without their negation).

size()#

size of the position

Return type:

int

Returns:

The amount of sentences in that position (\(|S|\)).

subpositions(n=-1, only_consistent_subpositions=True)#

Iterator over subsets of size n.

Parameters:
  • n (int) – The size of the returned positions. If n is \(-1\), the method returns all subpositions including the empty position and itself.

  • only_consistent_subpositions (bool) – If True only consistent subpositions will be returned.

Return type:

Iterator[Position]

Returns:

A python iterator over subpositions of size n.

static to_numpy_position(position)#

Convert an implemented instance of Position to an instance of NumpyPosition.

Return type:

NumpyPosition

Parameters:

position (Position) –

union(*positions)#

The set theoretic union of positions.

Return type:

Position

Returns:

The set-theoretic union of the position with the given positions. If no argument is provided, the positions is returned.

Raises:

a ValueError if the sentence pools do not match.

Parameters:

positions (Position) –

DAGNumpyDialecticalStructure#

class theodias.DAGNumpyDialecticalStructure#

Bases: DialecticalStructure

Implementing DialecticalStructure on the basis of NumpyPosition and directed acyclic graphs (DAG).

Note

This class calculates and stores information about all positions in a dialectical structure. The number of positions grows exponentially in the number of sentences in the sentence pool (\(3^{n}\)). Consequently, it is not suitable for larger sentence pool sizes, for which BDDNumpyDialecticalStructure is recommended.

Methods

add_argument(argument)

Adds an argument to the dialectical structure.

add_arguments(arguments)

Adds arguments to the dialectical structure.

are_compatible(position1, position2)

Checks for dialectical compatibility of two positions.

axioms(position[, source])

Iterator over all axiomatic bases from source.

closed_positions()

Iterator over all dialectically consistent and closed positions.

closure(position)

Dialectical closure.

consistent_complete_positions([position])

Iterator over all dialectically consistent and complete positions that extend position.

consistent_positions([position])

Iterator over all dialectically consistent positions that extend position.

degree_of_justification(position1, position2)

Conditional degree of justification.

entails(position1, position2)

Dialectical entailment.

from_arguments(arguments, ...[, name])

Instanciating a DialecticalStructure from a list of int lists.

get_arguments()

The arguments as a list.

get_name()

Get the name of the dialectical structure.

is_closed(position)

Checks whether a position is dialectically closed.

is_complete(position)

Checks whether position is complete.

is_consistent(position)

Checks for dialectical consistency.

is_minimal(position)

Checks dialectical minimality.

minimal_positions()

Iterator over all dialectically minimal positions.

minimally_consistent_positions()

Iterator over all minimally consistent positions.

n_complete_extensions([position])

Number of complete and consistent extension.

sentence_pool()

Returns the sentences (without negations) of a dialetical structure's sentence pool.

set_name(name)

Set the name of the dialectical structure.

complete_minimally_consistent_positions

__init__(n, initial_arguments=None, name=None)#
Parameters:
  • n (int) –

  • initial_arguments (List[List[int]] | None) –

  • name (str | None) –

add_argument(argument)#

Adds an argument to the dialectical structure.

Parameters:

argument (List[int]) – An argument as an integer list. The last element represents the conclusion the others the premises.

Return type:

DialecticalStructure

Returns:

The dialectical structure for convenience.

add_arguments(arguments)#

Adds arguments to the dialectical structure.

Parameters:

arguments (List[List[int]]) – A list of arguments as a list of integer lists.

Return type:

DialecticalStructure

Returns:

The dialectical structure for convenience.

are_compatible(position1, position2)#

Checks for dialectical compatibility of two positions.

Two positions are dialectically compatible iff there is a complete and consistent positition that extends both.

Return type:

bool

Returns:

True iff position1 it dialectically compatible to position2.

Parameters:
axioms(position, source=None)#

Iterator over all axiomatic bases from source. The source defaults to all consistent positions if it is not provided.

A position \(\mathcal{B}\) (\(\in\) source) is an axiomatic basis of another position \(\mathcal{A}\) iff \(\mathcal{A}\) is dialectically entailed by \(\mathcal{B}\) and there is no proper subset \(\mathcal{C}\) of \(\mathcal{B}\) such that \(\mathcal{A}\) is entailed by \(\mathcal{C}\).

Return type:

Iterator[Position]

Returns:

A (possibly empty) python-iterator over all axiomatic bases of position from source. The iterator will be empty ([]) if there is no axiomatic basis in the source.

Raises:

A ValueError if the given position is inconsistent.

Parameters:
closed_positions()#

Iterator over all dialectically consistent and closed positions.

This iterator will include the empty position if it is closed.

Return type:

Iterator[Position]

Returns:

A python-iterator over all dialectically consistent and closed positions.

closure(position)#

Dialectical closure.

The dialectical closure of a position \(\mathcal{A}\) is the intersection of all consistent and complete positions that extend \(\mathcal{A}\). Note that in consequence, the empty position can have a non-empty closure.

Return type:

Position

Returns:

The dialectical closure of position.

Parameters:

position (Position) –

complete_minimally_consistent_positions()#
Return type:

Iterator[Position]

consistent_complete_positions(position=None)#

Iterator over all dialectically consistent and complete positions that extend position.

Return type:

Iterator[Position]

Returns:

An iterator over all dialectically consistent and complete positions that extend position. If no position is given, the function returns an iterator over all dialectically consistent and complete positions.

Parameters:

position (Position | None) –

consistent_positions(position=None)#

Iterator over all dialectically consistent positions that extend position.

This iterator will include the empty position.

Return type:

Iterator[Position]

Returns:

A python iterator over all dialectically consistent positions that extend position. If no position is given, the function returns an iterator over all dialectically consistent positions.

Parameters:

position (Position | None) –

degree_of_justification(position1, position2)#

Conditional degree of justification.

The conditional degree of justification \(DOJ\) of two positions \(\mathcal{A}\) and \(\mathcal{B}\) is defined by \(DOJ(\mathcal{A}| \mathcal{B}):=\frac{\sigma_{\mathcal{AB}}}{\sigma_{\mathcal{B}}}\) with \(\sigma_{\mathcal{AB}}\) the set of all consistent and complete positions that extend both \(\mathcal{A}\) and \(\mathcal{B}\) and \(\sigma_{\mathcal{B}}\) the set of all consistent and complete positions that extend \(\mathcal{B}\).

Return type:

float

Returns:

The conditional degree of justification of position1 with respect to position2.

Parameters:
entails(position1, position2)#

Dialectical entailment.

A position \(\mathcal{A}\) dialectically entails another position \(\mathcal{B}\) iff every consistent and complete position that extends \(\mathcal{A}\) also extends \(\mathcal{B}\).

Return type:

bool

Returns:

True iff position2 is dialectically entailed by position1.

Parameters:
static from_arguments(arguments, n_unnegated_sentence_pool, name=None)#

Instanciating a DialecticalStructure from a list of int lists.

Return type:

DialecticalStructure

Returns:

DialecticalStructure

Parameters:
  • arguments (List[List[int]]) –

  • n_unnegated_sentence_pool (int) –

  • name (str | None) –

get_arguments()#

The arguments as a list.

Return type:

List[List[int]]

Returns:

The arguments as a list of integer lists. The last element of each inner list represents the conclusion, the others the premises.

get_name()#

Get the name of the dialectical structure.

Return type:

str

Returns:

The name of the dialectical structure as a string (default: None)

is_closed(position)#

Checks whether a position is dialectically closed.

Return type:

bool

Returns:

True iff position is dialectically closed.

Parameters:

position (Position) –

is_complete(position)#

Checks whether position is complete.

A position \(\mathcal{A}\) is complete iff the domain of \(\mathcal{A}\) is identical with the sentence pool \(S\).

Return type:

bool

Returns:

True iff the Position is complete.

Parameters:

position (Position) –

is_consistent(position)#

Checks for dialectical consistency.

A complete position \(\mathcal{A}\) is dialectically consistent iff it is a minimally consistent and for all arguments \(a=(P_a, c_a) \in A\) holds: If \((\forall p \in P_a:p \in \mathcal{A})\) then \(c_a \in \mathcal{A}\)

A partial position \(\mathcal{A}\) is dialectically consistent iff there is a complete and consistent position that extends \(\mathcal{A}\).

Return type:

bool

Returns:

True iff position it dialectically consistent.

Parameters:

position (Position) –

is_minimal(position)#

Checks dialectical minimality.

A position \(\mathcal{A}\) is dialectically minimal if every subposition \(\mathcal{B}\subseteq\mathcal{A}\) that entails \(\mathcal{A}\) is identical with \(\mathcal{A}\).

Return type:

bool

Returns:

True iff position is dialectically minimal.

Parameters:

position (Position) –

minimal_positions()#

Iterator over all dialectically minimal positions.

Return type:

Iterator[Position]

Returns:

A python iterator over all dialectically minimal positions.

minimally_consistent_positions()#

Iterator over all minimally consistent positions.

A position \(\mathcal{A}\) is minimally consistent iff \(\forall s \in S: s\in \mathcal{A} \rightarrow \neg s \notin \mathcal{A}\)

This iterator will include the empty position.

Return type:

Iterator[Position]

Returns:

An iterator over all minimally consistent positions.

n_complete_extensions(position=None)#

Number of complete and consistent extension.

Return type:

int

Returns:

The number of complete and consistent positions that extend position. If none is given, the function returns the number of all complete consistent extensions. If the given position is dialectically inconsistent, there are no consistent extensions.

Parameters:

position (Position | None) –

sentence_pool()#

Returns the sentences (without negations) of a dialetical structure’s sentence pool.

Returns from \(S = \{ s_1, s_2, \dots, s_N, \neg s_1, \neg s_2, \dots, \neg s_N \}\) only \(\{ s_1, s_2, \dots, s_N\}\)

Return type:

Position

Returns:

“Half” of the full sentence pool \(S\) as Position (sentences without their negation).

set_name(name)#

Set the name of the dialectical structure.

Parameters:

name (str) –

BDDNumpyDialecticalStructure#

class theodias.BDDNumpyDialecticalStructure#

Bases: DAGNumpyDialecticalStructure

Implementing DialecticalStructure on the basis of NumpyPosition and binary decision diagrams (BDD).

Methods

add_argument(argument)

Adds an argument to the dialectical structure.

add_arguments(arguments)

Adds arguments to the dialectical structure.

are_compatible(position1, position2)

Checks for dialectical compatibility of two positions.

axioms(position[, source])

Iterator over all axiomatic bases from source.

closed_positions()

Iterator over all dialectically consistent and closed positions.

closure(position)

Dialectical closure.

consistent_complete_positions([position])

Iterator over all dialectically consistent and complete positions that extend position.

consistent_positions([position])

Iterator over all dialectically consistent positions that extend position.

degree_of_justification(position1, position2)

Conditional degree of justification.

entails(position1, position2)

Dialectical entailment.

from_arguments(arguments, ...[, name])

Instanciating a DialecticalStructure from a list of int lists.

get_arguments()

The arguments as a list.

get_name()

Get the name of the dialectical structure.

is_closed(position)

Checks whether a position is dialectically closed.

is_complete(position)

Checks whether position is complete.

is_consistent(position)

Checks for dialectical consistency.

is_minimal(position)

Checks dialectical minimality.

minimal_positions()

Iterator over all dialectically minimal positions.

minimally_consistent_positions()

Iterator over all minimally consistent positions.

n_complete_extensions([position])

Number of complete and consistent extension.

sentence_pool()

Returns the sentences (without negations) of a dialetical structure's sentence pool.

set_name(name)

Set the name of the dialectical structure.

complete_minimally_consistent_positions

__init__(n, initial_arguments=None, name=None)#

Initialize an instance of BDDNumpyDialecticalStructure.

Parameters:
  • n (int) –

  • initial_arguments (List[List[int]] | None) –

  • name (str | None) –

are_compatible(position1, position2)#

Checks for dialectical compatibility of two positions.

Two positions are dialectically compatible iff there is a complete and consistent positition that extends both.

Return type:

bool

Returns:

True iff position1 it dialectically compatible to position2.

Parameters:
axioms(position, source=None)#

Iterator over all axiomatic bases from source.

The source defaults to all consistent positions if it is not provided.

A position \(\mathcal{B}\) (\(\in\) source) is an axiomatic basis of another position \(\mathcal{A}\) iff \(\mathcal{A}\) is dialectically entailed by \(\mathcal{B}\) and there is no proper subset \(\mathcal{C}\) of \(\mathcal{B}\) such that \(\mathcal{A}\) is entailed by \(\mathcal{C}\).

Note

This function will become computationally costly if the source is not given (in this case the function has to go through all dialectically consistent positions).

Return type:

Iterator[Position]

Returns:

A (possibly empty) python-iterator over all axiomatic bases of position from source. The iterator will be empty ([]) if there is no axiomatic basis in the source.

Raises:

A ValueError if the given position is inconsistent.

Parameters:
closure(position)#

Dialectical closure.

The dialectical closure of a position \(\mathcal{A}\) is the intersection of all consistent and complete positions that extend \(\mathcal{A}\). Note that in consequence, the empty position can have a non-empty closure.

Return type:

Position

Returns:

The dialectical closure of position.

Parameters:

position (Position) –

complete_minimally_consistent_positions()#
Return type:

Iterator[Position]

consistent_complete_positions(position=None)#

Iterator over all dialectically consistent and complete positions that extend position.

Return type:

Iterator[Position]

Returns:

An iterator over all dialectically consistent and complete positions that extend position. If no position is given, the function returns an iterator over all dialectically consistent and complete positions.

Parameters:

position (Position | None) –

consistent_positions(position=None)#

Iterator over all dialectically consistent positions that extend position.

This iterator will include the empty position.

Note

This function will be computationally costly for large sentence pools.

Return type:

Iterator[Position]

Returns:

A python iterator over all dialectically consistent positions that extend position. If no position is given, the function returns an iterator over all dialectically consistent positions.

Parameters:

position (Position | None) –

degree_of_justification(position1, position2)#

Conditional degree of justification.

The conditional degree of justification \(DOJ\) of two positions \(\mathcal{A}\) and \(\mathcal{B}\) is defined by \(DOJ(\mathcal{A}| \mathcal{B}):=\frac{\sigma_{\mathcal{AB}}}{\sigma_{\mathcal{B}}}\) with \(\sigma_{\mathcal{AB}}\) the set of all consistent and complete positions that extend both \(\mathcal{A}\) and \(\mathcal{B}\) and \(\sigma_{\mathcal{B}}\) the set of all consistent and complete positions that extend \(\mathcal{B}\).

Return type:

float

Returns:

The conditional degree of justification of position1 with respect to position2.

Parameters:
entails(position1, position2)#

Dialectical entailment.

A position \(\mathcal{A}\) dialectically entails another position \(\mathcal{B}\) iff every consistent and complete position that extends \(\mathcal{A}\) also extends \(\mathcal{B}\).

Return type:

bool

Returns:

True iff position2 is dialectically entailed by position1.

Parameters:
static from_arguments(arguments, n_unnegated_sentence_pool, name=None)#

Instanciating a DialecticalStructure from a list of int lists.

Return type:

DialecticalStructure

Returns:

DialecticalStructure

Parameters:
  • arguments (List[List[int]]) –

  • n_unnegated_sentence_pool (int) –

  • name (str | None) –

get_name()#

Get the name of the dialectical structure.

Return type:

str

Returns:

The name of the dialectical structure as a string (default: None)

is_consistent(position)#

Checks for dialectical consistency.

A complete position \(\mathcal{A}\) is dialectically consistent iff it is a minimally consistent and for all arguments \(a=(P_a, c_a) \in A\) holds: If \((\forall p \in P_a:p \in \mathcal{A})\) then \(c_a \in \mathcal{A}\)

A partial position \(\mathcal{A}\) is dialectically consistent iff there is a complete and consistent position that extends \(\mathcal{A}\).

Return type:

bool

Returns:

True iff position it dialectically consistent.

Parameters:

position (NumpyPosition) –

minimally_consistent_positions()#

Iterator over all minimally consistent positions.

A position \(\mathcal{A}\) is minimally consistent iff \(\forall s \in S: s\in \mathcal{A} \rightarrow \neg s \notin \mathcal{A}\)

This iterator will include the empty position.

Return type:

Iterator[Position]

Returns:

An iterator over all minimally consistent positions.

n_complete_extensions(position=None)#

Number of complete and consistent extension.

Return type:

int

Returns:

The number of complete and consistent positions that extend position. If none is given, the function returns the number of all complete consistent extensions. If the given position is dialectically inconsistent, there are no consistent extensions.

Parameters:

position (Position | None) –

name: Optional[str]#
set_name(name)#

Set the name of the dialectical structure.

Parameters:

name (str) –