Rules

Inheritance diagram of authorityspoke.rules.Rule
class authorityspoke.rules.Rule(procedure=Procedure(outputs=(), inputs=(), despite=()), enactments=(), enactments_despite=(), mandatory=False, universal=False, generic=False, name=None, outputs=(), inputs=(), despite=())

A statement of a legal doctrine about a Procedure for litigation.

May decide some aspect of current litigation, and also potentially may be cided and reused by future courts. When Rules appear as judicial holdings they are often hypothetical and don’t necessarily imply that the court accepts the Fact assertions or other Factors that make up the inputs or outputs of the Procedure mentioned in the Rule.

Parameters
  • procedure (Procedure) – a Procedure containing the inputs, and despite Factors and resulting outputs when this rule is triggered.

  • enactments (Iterable[Enactment]) – the Enactments cited as authority for invoking the procedure.

  • enactments_despite (Iterable[Enactment]) – the Enactments specifically cited as failing to preclude application of the procedure.

  • mandatory (bool) – whether the procedure is mandatory for the court to apply whenever the Rule is properly invoked. False means that the procedure is “discretionary”.

  • universal (bool) – True if the procedure is applicable whenever its inputs are present. False means that the procedure is applicable in “some” situation where the inputs are present.

  • generic (bool) – whether the Rule is being mentioned in a generic context. e.g., if the Rule is being mentioned in an Argument object merely as an example of the kind of Rule that might be mentioned in such an Argument.

  • name (Optional[str]) – an identifier used to retrieve this Rule when needed for the composition of another Factor object.

__add__(other)

Create new Rule if self can satisfy the inputs of other.

If both self and other have False for universal, then returns None. Otherwise:

If the union of the inputs and outputs of self would trigger other, then return a new version of self with the output Factors of other as well as the outputs of self.

The new universal and mandatory values are the lesser of the old values for each.

Don’t test whether self could be triggered by the outputs of other. Let user do other + self for that.

Parameters

other – another Rule to try to add to self

Return type

Optional[Rule]

Returns

a combined Rule that extends the procedural move made in self, if possible. Otherwise None.

get_contrapositives()

Make contrapositive forms of this Rule.

Used when converting from JSON input containing the entry "exclusive": True, which means the specified inputs` are the only way to reach the specified output. When that happens, it can be inferred that in the absence of any of the inputs, the output must also be absent. (Multiple outputs are not allowed when the exclusive flag is True.) So, this generator will yield one new Rule for each input.

Return type

Iterator[Rule]

Returns

iterator yielding Rules.

property context_factors

Call Procedure’s context_factors() method.

Return type

Tuple

Returns

context_factors from self’s Procedure

property generic_factors

Get Factors that can be replaced without changing selfs meaning.

Return type

List[Optional[Factor]]

Returns

generic Factors from self’s Procedure

add_enactment(incoming, role='enactments')

Make new version of self with an Enactment added.

Parameters
  • incoming (Enactment) – the new Enactment to be added to enactments or enactments_despite

  • role (str) – specifies whether the new Enactment should be added to enactments or enactments_despite

Return type

Rule

Returns

a new version of self with the specified change

add_factor(incoming, role='inputs')

Make new version of self with an added input, output, 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

Rule

Returns

a new version of self with the specified change

contradicts(other, context=None)

Test if self contradicts other.

Return type

bool

Returns

whether self contradicts other, if each is posited by a Holding with rule_valid` and decided

explain_contradiction(other, context=None)

Find context matches that would result in a contradiction with other.

Return type

Iterator[ContextRegister]

needs_subset_of_enactments(other)

Test whether self’s Enactment support is a subset of other’s.

A Rule makes a more powerful statement if it relies on fewer Enactments (or applies despite more Enactments).

So this method must return True for self to imply other.

Return type

bool

explain_implication(other, context=None)

Generate ContextRegisters that cause self to imply other.

If self is absent, then generate a ContextRegister from other’s point of view and then swap the keys and values.

Return type

Iterator[ContextRegister]

implies(other, context=None)

Test if self implies other if posited in valid and decided Holdings.

If self relies for support on some Enactment text that other doesn’t, then self doesn’t imply other.

Also, if other specifies that it applies notwithstanding some Enactment not mentioned by self, then self doesn’t imply other.

This will be called as part of the Holding.__ge__() implication function.

Return type

bool

Returns

whether self implies other, assuming that both are Rule/s, and rule_valid and decided are True for both of them.

__ge__(other)

Call implies() as an alias.

Return type

bool

Returns

bool indicating whether self implies other

__len__()

Count generic Factors needed as context for this Rule.

Returns

the number of generic Factors needed for self’s Procedure.

has_all_same_enactments(other)

Test if self has Enactments with same meanings as other’s.

Parameters

other (Rule) – another Rule to compare to self.

Return type

bool

Returns

whether the means() test passes for all Enactments

explain_same_meaning(other, context=None)

Find context matches that would result in self and other meaning the same.

Return type

Iterator[ContextRegister]

means(other, context=None)

Test whether other has the same meaning as self.

Return type

bool

Returns

whether other is a Rule with the same meaning as self.

__or__(other)

Create new Rule showing combined effect of all inputs of self and other.

This operation is destructive in the sense that the new Rule may not contain all the information that was available in self and other.

This seems to work differently when one Rule implies the other. That could mean there is a union to return even when both Rules are SOME rules. Or it could mean an ALL rule should be returned even though implied is SOME, because implied contributes no information that wasn’t already in greater.

Parameters

other (Rule) – a Rule to be combined with self.

Return type

Optional[Rule]

Returns

a Rule indicating the combined effect of the input and despite Factors of self and other

own_attributes()

Return attributes of self that aren’t inherited from another class.

Used for getting parameters to pass to __init__() when generating a new object.

Return type

Dict[str, Any]

__str__()

Return str(self).