First, let’s create some propositions using the PropLiteral constructor. All propositions are atomic, that is, either positive or negative literals.
>>> kill = PropLiteral('kill')
>>> kill.polarity
True
>>> intent = PropLiteral('intent')
>>> murder = PropLiteral('murder')
>>> witness1 = PropLiteral('witness1')
>>> unreliable1 = PropLiteral('unreliable1')
>>> witness2 = PropLiteral('witness2')
>>> unreliable2 = PropLiteral('unreliable2')
The negate() method allows us to introduce negated propositions.
>>> neg_intent = intent.negate()
>>> print(neg_intent)
-intent
>>> neg_intent.polarity
False
>>> neg_intent == intent
False
>>> neg_intent.negate() == intent
True
Arguments are built with the Argument constructor. They are required to have a conclusion, and may also have premises and exceptions.
>>> arg1 = Argument(murder, premises={kill, intent})
>>> arg2 = Argument(intent, premises={witness1}, exceptions={unreliable1})
>>> arg3 = Argument(neg_intent, premises={witness2}, exceptions={unreliable2})
>>> print(arg1)
[intent, kill], ~[] => murder
In order to organise the dependencies between the conclusion of an argument and its premises and exceptions, we model them using a directed graph called an ArgumentSet. Notice that the premise of one argument (e.g., the intent premise of arg1) can be the conclusion of another argument (i.e., arg2)).
>>> argset = ArgumentSet()
>>> argset.add_argument(arg1, arg_id='arg1')
>>> argset.add_argument(arg2, arg_id='arg2')
>>> argset.add_argument(arg3, arg_id='arg3')
There is a draw() method which allows us to view the resulting graph.
>>> argset.draw()
In evaluating the relative value of arguments for a particular conclusion p, we need to determine what standard of proof is required to establish p. The notion of proof used here is not formal proof in a logical system. Instead, it tries to capture how substantial the arguments are in favour of, or against, a particular conclusion.
The ProofStandard constructor is initialised with a list of (proposition, name-of-proof-standard) pairs. The default proof standard, viz., 'scintilla', is the weakest level. Different propositions can be assigned different proof standards that they need to attain.
>>> ps = ProofStandard([(intent, "beyond_reasonable_doubt")],
... default='scintilla')
The core of the argumentation model is a data structure plus set of rules for evaluating arguments; this is called a Carneades Argument Evaluation Structure (CAES). A CAES consists of a set of arguments, an audience (or jury), and a method for determining whether propositions satisfy the relevant proof standards.
The role of the audience is modeled as an Audience, consisting of a set of assumed propositions, and an assignment of weights to arguments.
>>> assumptions = {kill, witness1, witness2, unreliable2}
>>> weights = {'arg1': 0.8, 'arg2': 0.3, 'arg3': 0.8}
>>> audience = Audience(assumptions, weights)
Once an audience has been defined, we can use it to initialise a CAES, together with instances of ArgumentSet and ProofStandard:
>>> caes = CAES(argset, audience, ps)
>>> caes.get_all_arguments()
[intent, kill], ~[] => murder
[witness1], ~[unreliable1] => intent
[witness2], ~[unreliable2] => -intent
The get_arguments() method returns the list of arguments in an ArgumentSet which support a given proposition.
A proposition is said to be acceptable in a CAES if it meets its required proof standard. The process of checking whether a proposition meets its proof standard requires another notion: namely, whether the arguments that support it are applicable. An argument arg is applicable if and only if all its premises either belong to the audience’s assumptions or are acceptable; moreover, the exceptions of arg must not belong to the assumptions or be acceptable. For example, arg2, which supports the conclusion intent, is acceptable since witness1 is an assumption, while the exception unreliable1 is neither an assumption nor acceptable.
>>> arg_for_intent = argset.get_arguments(intent)[0]
>>> print(arg_for_intent)
[witness1], ~[unreliable1] => intent
>>> caes.applicable(arg_for_intent)
True
>>> caes.acceptable(intent)
False
Although there is an argument (arg3) for -intent, it is not applicable, since the exception unreliable2 does belong to the audience’s assumptions.
>>> any(caes.applicable(arg) for arg in argset.get_arguments(neg_intent))
False
This in turn has the consequence that -intent is not acceptable.
>>> caes.acceptable(neg_intent)
False
Despite the fact that the argument arg2 for murder is applicable, the conclusion murder is not acceptable, since
>>> caes.acceptable(murder)
False
>>> caes.acceptable(murder.negate())
False
An argument consists of a conclusion, a set of premises and a set of exceptions (both of which can be empty).
Although arguments should have identifiers (arg_id), it is preferable to specify these when calling the add_argument() method of ArgumentSet.
Parameters: |
|
---|
An ArgumentSet is modeled as a dependency graph where vertices represent the components of an argument. A vertex corresponding to the conclusion of an argument A will depend on the premises and exceptions in A.
The graph is built using the igraph library. This allows attributes to be associated with both vertices and edges. Attributes are represented as Python dictionaries where the key (which must be a string) is the name of the attribute and the value is the attribute itself. For more details, see the igraph tutorial.
Add an argument to the graph.
Parameters: |
|
---|
Add a proposition to a graph if it is not already present as a vertex.
Parameters: | proposition (PropLiteral) – The proposition to be added to the graph. |
---|---|
Returns: | The graph vertex corresponding to the proposition. |
Return type: | Graph.Vertex |
Raises TypeError: | |
if the input is not a PropLiteral. |
Visualise an ArgumentSet as a labeled graph.
Parameters: | debug – If True, add the vertex index to the label. |
---|
Find the arguments for a proposition in an ArgumentSet.
Parameters: | proposition (PropLiteral) – The proposition to be checked. |
---|---|
Returns: | A list of the arguments pro the proposition |
Return type: | list(Argument) |
Raises ValueError: | |
if the input PropLiteral isn’t present in the graph. |
The set of PropLiterals represented by the vertices in the graph.
Retrieving this set relies on the fact that add_proposition() sets a value for the prop attribute in vertices created when a new proposition is added to the graph.
Write the graph to a file using the Graphviz dot language.
A dot file can be converted to multiple output formats, including png and pdf. For example, dot -Tpng graph.dot > graph.png will produce an output file graph.png.
Parameters: | fname – Name of file to write the results to. If no filename is supplied, the results will be written to graph.dot. |
---|
An audience has assumptions about which premises hold and also assigns weights to arguments.
Parameters: |
|
---|
Alias for field number 0
Alias for field number 1
A class that represents a Carneades Argument Evaluation Structure (CAES).
Parameters: |
|
---|
A conclusion is acceptable in a CAES if it can be arrived at under the relevant proof standards, given the beliefs of the audience.
Parameters: | proposition (PropLiteral) – The conclusion whose acceptability is to be determined. |
---|---|
Return type: | bool |
An argument is applicable in a CAES if it needs to be taken into account when evaluating the CAES.
Parameters: | argument (Argument) – The argument whose applicablility is being determined. |
---|---|
Return type: | bool |
Retrieve the weight of the strongest applicable argument in a list of arguments.
Parameters: | arguments (list(Argument)) – The arguments whose weight is being compared. |
---|---|
Returns: | The maximum of the weights of the arguments. |
Return type: | float in interval [0, 1] |
The maximum of the weights con the proposition.
Parameters: | proposition (PropLiteral) – The conclusion whose acceptability is to be determined. |
---|---|
Return type: | float in interval [0, 1] |
The maximum of the weights pro the proposition.
Parameters: | proposition (PropLiteral) – The conclusion whose acceptability is to be determined. |
---|---|
Return type: | float in interval [0, 1] |
Determine whether a proposition meets a given proof standard.
Parameters: |
|
---|---|
Return type: | bool |
Each proposition in a CAES is associated with a proof standard.
A proof standard is initialised by supplying a (possibly empty) list of pairs, each consisting of a proposition and the name of a proof standard.
>>> intent = PropLiteral('intent')
>>> ps = ProofStandard([(intent, "beyond_reasonable_doubt")])
Possible values for proof standards: "scintilla", "preponderance", "clear_and_convincing", "beyond_reasonable_doubt", and "dialectical_validity".
Parameters: | propstandards (list(tuple(PropLiteral, str))) – the proof standard associated with each proposition under consideration. |
---|
Determine the proof standard associated with a proposition.
Parameters: | proposition (PropLiteral) – The proposition to be checked. |
---|
Module to see what calls actually occurred during execution, their arguments and return values, when executing algorithms with complex function call sequences, and especially ones that require recursion.
The class TraceCalls is called as a decorator @TraceCalls().
Use as a decorator on functions that should be traced. Several functions can be decorated; they will all be indented according to their call depth.
Parameters: |
|
---|