Procedures

Inheritance diagram of authorityspoke.procedures.Procedure
class authorityspoke.procedures.Procedure(outputs=(), inputs=(), despite=(), name=None, absent=False, generic=False)

A (potential) rule for courts to use in resolving litigation.

Described in terms of inputs and outputs, and also potentially “despite” Factors, which occur when a Rule could be said to apply “even if” some “despite” factor is true.

Users generally should not need to interact with this class directly, under the current design. Instead, they should interact with the class Rule.

Parameters
  • outputs (Tuple[Factor, ..]) – an outcome that a court may accept based on the presence of the inputs

  • inputs (Tuple[Factor, ..]) – supporting Factors in favor of the output. The input Factors are not treated as potential undercutters.

  • despite (Tuple[Factor, ..]) – Factors that do not prevent the court from imposing the output. These could be considered “failed undercutters” in defeasible logic. If a Factor is relevant both as support for the output and as a potential undercutter, include it in both inputs and despite.

  • name (Optional[str]) – An identifier that can be used to reference and incorporate an existing procedure in a new Factor, instead of constructing a new copy of the Procedure.

  • absent (bool) – Whether the absence, rather than presence, of this Procedure is being referenced. The usefulness of this is unclear, but I’m not prepared to eliminate it before the Argument class has been implemented and tested.

  • generic (bool) – Whether the this Procedure is being referenced as a generic example, which could be replaced by any other Procedure.

union(other, context=None)

Combine two Procedures into one.

The new Procedure will have all of the inputs, outputs, and despite Factors of both self and other.

All of the context Factors of self will remain the same.

Return type

Optional[Procedure]

__len__()

Get number of generic Factors specified for self.

Returns

the number of generic Factors that need to be specified for this Procedure.

__repr__()

Return repr(self).

__str__()

Return str(self).

property factors_all

Get Factors in inputs, outputs, and despite.

Return type

List[Factor]

Returns

a list of all Factors.

property generic_factors

Factors that can be replaced without changing selfs meaning.

If self.generic is True then the only generic Factor is self. This could happen if the Procedure was mentioned generically in an Argument about preserving objections for appeal, for instance.

Return type

Tuple[Factor, …]

Returns

self’s generic Factors, which must be matched to other generic Factors to perform equality or implication tests between Factors with Factor.means() or Factor.__ge__().

add_factor(incoming, role='inputs')

Add an output, input, or despite Factor.

Parameters
  • incoming (Factor) – the new Factor to be added to input, output, or despite

  • role (str) – specifies whether the new Factor should be added to input, output, or despite

Return type

Procedure

Returns

a new version of self with the specified change

contradicts(other)

Find if self applying in some cases implies other cannot apply in some.

Raises an error because, by analogy with Procedure.implies(), users might expect this method to return True only when Rule with universal=False and Procedure self would contradict another Rule with universal=False and Procedure other. But that would never happen.

Return type

bool

contradicts_some_to_all(other, context=None)

Find if self applying in some cases implies other cannot apply in all.

Return type

bool

Returns

whether the assertion that self applies in some cases contradicts that other applies in all cases, where at least one of the Rules is mandatory.

explain_contradiction_some_to_all(other, context=None)

Explain why other can’t apply in all cases if self applies in some.

Return type

Iterator[ContextRegister]

implies_all_to_all(other, context=None)

Find if self applying in all cases implies other applies in all.

self does not imply other if any output of other is not equal to or implied by some output of self.

For self to imply other, every input of self must be implied by some input of other.

self does not imply other if any despite of other contradicts() an input of self.

Return type

bool

Returns

whether the assertion that self applies in all cases implies that other applies in all cases.

implies_all_to_some(other, context=None)

Find if self applying in all cases implies other applies in some.

For self to imply other, every output of other must be equal to or implied by some output of self.

For self to imply other, every input of self must not be contradicted by any input or despite of other.

self does not imply other if any “despite” Factors of other are not implied by inputs of self.

Return type

bool

Returns

whether the assertion that self applies in all cases implies that other applies in some cases (that is, if the list of self’s inputs is not considered an exhaustive list of the circumstances needed to invoke the procedure).

_implies_if_present(other, context=None)

Find if self would imply other if they aren’t absent.

When self and other are included in Rules that both apply in some cases:

self does not imply other if any input of other is not equal to or implied by some input of self.

self does not imply other if any output of other is not equal to or implied by some output of self.

self does not imply other if any despite of other is not equal to or implied by some despite or input of self.

Return type

Iterator[ContextRegister]

Returns

whether the assertion that self applies in some cases implies that the Procedure other applies in some cases.

explain_same_meaning(other, context=None)

Generate ways to match contexts of self and other so they mean the same.

Return type

Iterator[ContextRegister]

means(other, context=None)

Determine whether other has the same meaning as self.

Return type

bool

Returns

whether the two Procedures have all the same Factors with the same context factors in the same roles.

new_context(changes)

Create new Procedure, replacing keys of changes with values.

Parameters

changes (ContextRegister) – a dict of Factors to replace matched to the Factors that should replace them

Return type

Procedure

Returns

new Procedure object, replacing keys of changes with their values.

triggers_next_procedure(other)

Test if Factors from firing self would trigger other.

Note

To be confident that self actually can trigger other, we would have to assume that other has universal: True since otherwise we don’t know exactly what is required to trigger other.

Parameters

other (Procedure) – another Procedure to test to see whether it can be triggered by triggering self

Return type

List[ContextRegister]

Returns

whether the set of Factors that exist after self is fired could trigger other

authorityspoke.procedures.consistent_factor_groups(self_factors, other_factors, matches=None)

Find whether two sets of Factors can be consistent.

Works by first determining whether one Factor potentially contradicts() another, and then determining whether it’s possible to make context assignments match between the contradictory Factors.

Note

Does Factor: None in matches always mean that the Factor can avoid being matched in a contradictory way?

Returns

whether unassigned context factors can be assigned in such a way that there’s no contradiction between any factor in self_factors and other_factors, given that some Factors have already been assigned as described by matches.

authorityspoke.procedures.contradictory_factor_groups(self_factors, other_factors, context=None)

Find whether two sets of Factors can be contradictory.

Parameters
  • self_factors (Tuple[Factor, …]) – one set of Factors with consistent context factors. Normally collected from the outputs attribute of a Procedure.

  • other_factors (Tuple[Factor, …]) – a second set of Factors with context factors that are internally consistent, but may not be consistent with self_factors.

  • matches – keys representing context Factors in self_factors and values representing Factors in other_factors. The keys and values have been found in corresponding positions in self and other.

Return type

Iterator[ContextRegister]

Returns

whether any Factor assignment can be found that makes a Factor in the output of other contradict a Factor in the output of self.