implica 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of implica might be problematic. Click here for more details.
- {implica-0.3.2 → implica-0.3.3}/PKG-INFO +1 -1
- {implica-0.3.2 → implica-0.3.3}/pyproject.toml +1 -1
- {implica-0.3.2 → implica-0.3.3}/src/implica/__init__.py +1 -1
- {implica-0.3.2 → implica-0.3.3}/src/implica/core/types.py +40 -0
- {implica-0.3.2 → implica-0.3.3}/LICENSE +0 -0
- {implica-0.3.2 → implica-0.3.3}/README.md +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/core/__init__.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/core/combinator.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/graph/__init__.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/graph/connection.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/graph/elements.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/graph/graph.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/__init__.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/add_edge.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/add_many_edges.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/add_many_nodes.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/add_node.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/base.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/remove_edge.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/remove_many_edges.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/remove_many_nodes.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/remove_node.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_add_edge.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_add_many_edges.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_add_many_nodes.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_add_node.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_remove_edge.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_remove_many_edges.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_remove_many_nodes.py +0 -0
- {implica-0.3.2 → implica-0.3.3}/src/implica/mutations/try_remove_node.py +0 -0
|
@@ -10,6 +10,7 @@ This module defines the type hierarchy for the implicational logic graph:
|
|
|
10
10
|
import hashlib
|
|
11
11
|
from abc import ABC, abstractmethod
|
|
12
12
|
from functools import cached_property
|
|
13
|
+
from typing import List
|
|
13
14
|
|
|
14
15
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
15
16
|
|
|
@@ -33,6 +34,20 @@ class BaseType(BaseModel, ABC):
|
|
|
33
34
|
"""
|
|
34
35
|
pass
|
|
35
36
|
|
|
37
|
+
@property
|
|
38
|
+
@abstractmethod
|
|
39
|
+
def variables(self) -> List["Variable"]:
|
|
40
|
+
"""
|
|
41
|
+
Return the list of all variables in this type.
|
|
42
|
+
|
|
43
|
+
This property is computed recursively on each access.
|
|
44
|
+
The list may contain duplicate variables if they appear multiple times.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
List[Variable]: A list of all Variable instances in this type
|
|
48
|
+
"""
|
|
49
|
+
pass
|
|
50
|
+
|
|
36
51
|
@abstractmethod
|
|
37
52
|
def __str__(self) -> str:
|
|
38
53
|
"""String representation of the type."""
|
|
@@ -62,6 +77,18 @@ class Variable(BaseType):
|
|
|
62
77
|
content = f"Var({self.name})"
|
|
63
78
|
return hashlib.sha256(content.encode("utf-8")).hexdigest()
|
|
64
79
|
|
|
80
|
+
@property
|
|
81
|
+
def variables(self) -> List["Variable"]:
|
|
82
|
+
"""
|
|
83
|
+
Return the list of variables in this type.
|
|
84
|
+
|
|
85
|
+
For a Variable, this returns a list containing only itself.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
List[Variable]: A list containing only this variable
|
|
89
|
+
"""
|
|
90
|
+
return [self]
|
|
91
|
+
|
|
65
92
|
def __str__(self) -> str:
|
|
66
93
|
"""Return the variable name."""
|
|
67
94
|
return self.name
|
|
@@ -93,6 +120,19 @@ class Application(BaseType):
|
|
|
93
120
|
content = f"App({self.input_type.uid},{self.output_type.uid})"
|
|
94
121
|
return hashlib.sha256(content.encode("utf-8")).hexdigest()
|
|
95
122
|
|
|
123
|
+
@property
|
|
124
|
+
def variables(self) -> List[Variable]:
|
|
125
|
+
"""
|
|
126
|
+
Return the list of variables in this type.
|
|
127
|
+
|
|
128
|
+
For an Application, this recursively collects all variables from
|
|
129
|
+
both the input_type and output_type.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
List[Variable]: A list of all variables in this application type
|
|
133
|
+
"""
|
|
134
|
+
return self.input_type.variables + self.output_type.variables
|
|
135
|
+
|
|
96
136
|
def __str__(self) -> str:
|
|
97
137
|
"""
|
|
98
138
|
Return a human-readable string representation.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|