pytableaux.proof
Classes
- class Branch(parent=None, /)[source]
A tableau branch.
- Parameters:
parent (Branch | None) --
- any(mappings, /)[source]
Check a list of property mappings against the
has
method.- Parameters:
mappings (
Iterable[Mapping]
) -- An iterable of property mappings.- Returns:
True when the first match is found, else False.
- Return type:
- all(mappings, /)[source]
Check a list of property mappings against the
has
method.- Parameters:
mappings (
Iterable[Mapping]
) -- An iterable of property mappings.- Returns:
False when the first non-match is found, else True.
- Return type:
- search(mapping, /)[source]
Search the nodes on the branch that match the given properties, up to the limit, if given.
- append(node, /)[source]
Append a node.
- Parameters:
node (
Mapping
) -- Node object or mapping.- Returns:
self
- Return type:
- Raises:
DuplicateValueError -- if the node is already on the branch.
- extend(nodes, /)[source]
Add multiple nodes.
- Parameters:
nodes (
Iterable
) -- An iterable of node objects/mappings.- Returns:
self
- Return type:
- Raises:
DuplicateValueError -- if a node is already on the branch.
- close()[source]
Close the branch. Adds a flag node and emits the AFTER_BRANCH_CLOSE event.
- Returns:
self.
- Return type:
- is_ticked(node, /)[source]
Whether the node is ticked relative to the branch.
- Returns
bool: Whether the node is ticked.
- new_constant()[source]
Return a new constant that does not appear on the branch.
- Returns:
The new constant.
- Return type:
- class Node(mapping=mappingproxy({}), /)[source]
A tableau node.
- class Rule(tableau, /, **opts)[source]
Base class for a Tableau rule.
- Parameters:
tableau (Tableau) --
- Helpers: Mapping[type[Rule.Helper], Any] = mappingproxy({})
Helper classes mapped to their settings.
- timer_names: Sequence[str] = qsetf({'search', 'apply'})
StopWatch names to create in
timers
mapping.
- state: Rule.State
The state bit flag.
- opts: Mapping
The options.
- helpers: TypeInstMap[Rule.Helper]
Helper instances mapped by class.
- class Tableau(logic=None, argument=None, **opts)[source]
A tableau proof.
- argument
The argument of the tableau.
When setting this value, if the tableau has a logic set, and the auto_build_trunk option is true (default), then the trunk is automatically built.
- logic
The logic of the tableau.
When setting this value, if the tableau has an argument set, and the auto_build_trunk option is true (default), then the trunk is automatically built.
- finished
Whether the tableau is finished. A tableau is finished iff any of the following conditions apply:
The tableau is completed.
The max_steps option is met or exceeded.
The build_timeout option is exceeded.
The
finish
method is manually invoked.
- valid
Whether the tableau's argument is valid (proved). A tableau with an argument is valid iff it is
completed
and it has no open branches. If the tableau is not completed, or it has no argument, the value will be None.
- invalid
Whether the tableau's argument is invalid (disproved). A tableau with an argument is invalid iff it is
completed
and it has at least one open branch. If the tableau is not completed, or it has no argument, the value will be None.
- completed
Whether the tableau is completed. A tableau is completed iff all rules that can be applied have been applied.
- premature
Whether the tableau is finished prematurely. A tableau is premature iff it is finished but not completed.
- id
The unique object ID of the tableau.
- history: Sequence[Tableau.StepEntry]
The history of rule applications.
- tree: Tableau.Tree
A tree structure of the tableau. This is generated after the tableau is finished. If the build_timeout was exceeded, the tree is not built.
- step()[source]
Find, execute, and return the next rule application. If no rule can be applied, the
finish()
method is called, andNone
is returned. If the tableau is already finished then this is a no-op and``None`` is returned.- Returns (Tableau.StepEntry):
The history entry, or
None
.
- Return type:
StepEntry | None
- stepiter()[source]
Returns an iterator that calls
step()
untilNone
is returned.- Return type:
Iterator[StepEntry]
- finish()[source]
Mark the tableau as finished, and perform post-build tasks, including populating the
tree
,stats
, andmodels
properties.When using the
build()
orstep()
methods, there is never a need to call this method, since it is handled internally. However, this method is safe to call multiple times. If the tableau is already finished, it will be a no-op.- Returns:
self
- Return type:
- build_trunk()[source]
Build the trunk of the tableau. Delegates to the
build_trunk()
method ofSystem
. This is called automatically when the tableau has non-emptyargument
andlogic
properties and the auto_build_trunk option is True (default).- Raises:
errors.IllegalStateError -- if the trunk is already built, the tableau is already started, there is no argument, or no logic.
- Return type:
- class System[source]
Tableaux system base class.
- abstract classmethod build_trunk(b, arg, /)[source]
Build the trunk for an argument on the tableau.
- Parameters:
b (
Branch
) -- The branch to construct.arg (
Argument
) -- The argument.
- Return type:
None
- classmethod branching_complexity(node, rules, /)[source]
Compute how many new branches would be added if a rule were to be applied to the node.
- class Tableau.Tree[source]
Recursive tree structure representation of a tableau.
- balanced_line_width: float = 0.0
0.5x the width of the first child structure, plus 0.5x the width of the last child structure (if distinct from the first), plus the sum of the widths of the other (distinct) children.
- class RulesRoot(tableau, /)[source]
Grouped and named collection of rules for a tableau.
- Parameters:
tableau (Tableau) --
- groups: RuleGroups
The rule groups sequence view.
- get(ref, default=<object object>, /)
Get rule instance by name or type.
- Parameters:
- Returns:
The rule instance, or
default
if it is specified and the rule was not found.- Raises:
- Return type:
_RT
- names()
Return all the rule names.
- class RuleGroups(root, /)[source]
- Parameters:
root (RulesRoot) --
- create(name=None)[source]
Create and return a new emtpy rule group.
- Parameters:
name (str | None) --
- append(classes, /, name=<object object>)[source]
Create a new group with the given rules. Raise IllegalStateError if locked.
- clear()[source]
Clear the groups. Raise IllegalStateError if locked.
- Parameters:
self (RulesRoot) --
- class RuleGroup(name, root, /)[source]
A rule group of a Tableau's
rules
.This class supports the full
Sequence
standard interface for iterating, subscripting, and slicing.The
append
,extend
, andclear
methods provide mutability until the instance is locked. An input value is a subclass ofRule
, which is instantiated for the tableau before it is added to the sequence.Rule instances are indexed, and can be retrieved by its class or name using the
get
method.- append(rulecls, /)[source]
Instantiate and append a rule class.
- Parameters:
- Raises:
ValueError -- If there is a duplicate name.
errors.IllegalStateError -- If locked.
- extend(classes, /)[source]
Append multiple rules.
- Parameters:
classes (Iterable[type[Rule]]) -- An iterable of
Rule
classes.- Raises:
ValueError -- If there is a duplicate name.
errors.IllegalStateError -- If locked.
- clear()[source]
Clear the rule group.
- Raises:
errors.IllegalStateError -- If locked.
- Parameters:
self (RulesRoot) --