pyk.kcfg.kcfg module¶
- final class Abstract(cterm: 'CTerm')[source]¶
Bases:
KCFGExtendResult
- final class Branch(constraints: 'Iterable[KInner]', *, heuristic: 'bool' = False)[source]¶
Bases:
KCFGExtendResult
- heuristic: bool¶
- class KCFG(cfg_dir: Path | None = None, optimize_memory: bool = True)[source]¶
Bases:
Container
[Union
[KCFG.Node
,KCFG.Successor
]]- final class Cover(source: 'KCFG.Node', target: 'KCFG.Node', csubst: 'CSubst')[source]¶
Bases:
EdgeLike
- static from_dict(dct: dict[str, Any], nodes: Mapping[int, KCFG.Node]) KCFG.Cover [source]¶
- final class Edge(source: 'KCFG.Node', target: 'KCFG.Node', depth: 'int', rules: 'tuple[str, ...]')[source]¶
Bases:
EdgeLike
- depth: int¶
- rules: tuple[str, ...]¶
- final class NDBranch(source: 'KCFG.Node', _targets: 'Iterable[KCFG.Node]', rules: 'tuple[str, ...]')[source]¶
Bases:
MultiEdge
- static from_dict(dct: dict[str, Any], nodes: Mapping[int, KCFG.Node]) KCFG.NDBranch [source]¶
- rules: tuple[str, ...]¶
- final class Node(id: 'int', cterm: 'CTerm', attrs: 'Iterable[NodeAttr]' = ())[source]¶
Bases:
object
- property free_vars: frozenset[str]¶
- id: int¶
- let(cterm: CTerm | None = None, attrs: Iterable[KCFGNodeAttr] | None = None) KCFG.Node [source]¶
- final class Split(source: 'KCFG.Node', _targets: 'Iterable[tuple[KCFG.Node, CSubst]]')[source]¶
Bases:
MultiEdge
- static from_dict(dct: dict[str, Any], nodes: Mapping[int, KCFG.Node]) KCFG.Split [source]¶
- class Successor[source]¶
Bases:
ABC
- abstract static from_dict(dct: dict[str, Any], nodes: Mapping[int, KCFG.Node]) KCFG.Successor [source]¶
- property source_vars: frozenset[str]¶
- property target_ids: list[int]¶
- property target_vars: frozenset[str]¶
- covers(*, source_id: NodeIdLike | None = None, target_id: NodeIdLike | None = None) list[Cover] [source]¶
- create_cover(source_id: NodeIdLike, target_id: NodeIdLike, csubst: CSubst | None = None) Cover [source]¶
- create_edge(source_id: NodeIdLike, target_id: NodeIdLike, depth: int, rules: Iterable[str] = ()) Edge [source]¶
- create_ndbranch(source_id: NodeIdLike, ndbranches: Iterable[NodeIdLike], rules: Iterable[str] = ()) KCFG.NDBranch [source]¶
- create_split(source_id: NodeIdLike, splits: Iterable[tuple[NodeIdLike, CSubst]]) KCFG.Split [source]¶
- edge_likes(*, source_id: NodeIdLike | None = None, target_id: NodeIdLike | None = None) list[EdgeLike] [source]¶
- edges(*, source_id: NodeIdLike | None = None, target_id: NodeIdLike | None = None) list[Edge] [source]¶
- extend(extend_result: KCFGExtendResult, node: KCFG.Node, logs: dict[int, tuple[LogEntry, ...]]) None [source]¶
- static from_claim(defn: KDefinition, claim: KClaim, cfg_dir: Path | None = None, optimize_memory: bool = True) tuple[KCFG, NodeIdLike, NodeIdLike] [source]¶
- let_node(node_id: NodeIdLike, cterm: CTerm | None = None, attrs: Iterable[KCFGNodeAttr] | None = None) None [source]¶
- lift_edge(b_id: int | str) None [source]¶
Lift an edge up another edge directly preceding it.
- Input:
b_id: the identifier of the central node B of a sequence of edges A –> B –> C.
Effect: A –M steps–> B –N steps–> C becomes A –(M + N) steps–> C. Node B is removed.
Output: None
Raises: An AssertionError if the edges in question are not in place.
- lift_edges() bool [source]¶
Perform all possible edge lifts across the KCFG.
Given the KCFG design, it is not possible for one edge lift to either disallow another or allow another that was not previously possible. Therefore, this function is guaranteed to lift all possible edges without having to loop.
Input: None
Effect: The KCFG is transformed to an equivalent in which no further edge lifts are possible.
- Output:
bool: An indicator of whether or not at least one edge lift was performed.
- lift_split_edge(b_id: int | str) None [source]¶
Lift a split up an edge directly preceding it.
- Input:
b_id: the identifier of the central node B of the structure A –> B –> [C_1, …, C_N].
- Effect:
A –M steps–> B –[cond_1, …, cond_N]–> [C_1, …, C_N] becomes A –[cond_1, …, cond_N]–> [A #And cond_1 –M steps–> C_1, …, A #And cond_N –M steps–> C_N]. Node B is removed.
Output: None
- Raises:
AssertionError, if the structure in question is not in place.
AssertionError, if any of the cond_i contain variables not present in A.
- lift_split_split(b_id: int | str) None [source]¶
Lift a split up a split directly preceding it, joining them into a single split.
- Input:
b_id: the identifier of the node B of the structure A –[…, cond_B, …]–> […, B, …] with B –[cond_1, …, cond_N]–> [C_1, …, C_N]
- Effect:
A –[…, cond_B, …]–> […, B, …] with B –[cond_1, …, cond_N]–> [C_1, …, C_N] becomes A –[…, cond_B #And cond_1, …, cond_B #And cond_N, …]–> […, C_1, …, C_N, …]. Node B is removed.
Output: None
- Raises:
AssertionError, if the structure in question is not in place.
- lift_splits() bool [source]¶
Perform all possible split liftings.
Input: None
Effect: The KCFG is transformed to an equivalent in which no further split lifts are possible.
- Output:
bool: An indicator of whether or not at least one split lift was performed.
- minimize() None [source]¶
Minimize KCFG by repeatedly performing the lifting transformations.
The loop is designed so that each transformation is performed once in each iteration.
Input: None
Effect: The KCFG is transformed to an equivalent in which no further lifting transformations are possible.
Output: None
- ndbranches(*, source_id: int | str | None = None, target_id: int | str | None = None) list[NDBranch] [source]¶
- static path_length(_path: Iterable[KCFG.Successor]) int [source]¶
- shortest_path_between(source_node_id: NodeIdLike, target_node_id: NodeIdLike) tuple[Successor, ...] | None [source]¶
- splits(*, source_id: NodeIdLike | None = None, target_id: NodeIdLike | None = None) list[Split] [source]¶
- to_module(module_name: str | None = None, imports: Iterable[KImport] = (), priority: int = 20, att: KAtt = KAtt(atts=FrozenDict({}))) KFlatModule [source]¶
- class KCFGNodeAttr(value: str)[source]¶
Bases:
NodeAttr
- STUCK = NodeAttr(value='stuck')¶
- VACUOUS = NodeAttr(value='vacuous')¶
- class KCFGStore(store_path: Path)[source]¶
Bases:
object
- property kcfg_json_path: Path¶
- property kcfg_node_dir: Path¶
- store_path: Path¶
- final class NDBranch(cterms: 'Iterable[CTerm]', logs: 'Iterable[LogEntry,]', rule_labels: 'Iterable[str]')[source]¶
Bases:
KCFGExtendResult
- rule_labels: tuple[str, ...]¶
- final class Step(cterm: 'CTerm', depth: 'int', logs: 'tuple[LogEntry, ...]', rule_labels: 'list[str]', cut: 'bool' = False)[source]¶
Bases:
KCFGExtendResult
- cut: bool = False¶
- depth: int¶
- rule_labels: list[str]¶
- final class Stuck[source]¶
Bases:
KCFGExtendResult
- final class Vacuous[source]¶
Bases:
KCFGExtendResult