planning-structs 0.1.0__py3-none-any.whl
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.
- planning_structs/__init__.py +18 -0
- planning_structs/action_model.py +66 -0
- planning_structs/domain.py +184 -0
- planning_structs/instance.py +129 -0
- planning_structs/trace.py +39 -0
- planning_structs-0.1.0.dist-info/METADATA +85 -0
- planning_structs-0.1.0.dist-info/RECORD +9 -0
- planning_structs-0.1.0.dist-info/WHEEL +4 -0
- planning_structs-0.1.0.dist-info/licenses/LICENSE +395 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Typed STRIPS planning structures: domains, their groundings on object sets, symbolic action models
|
|
3
|
+
and traces. No dependencies.
|
|
4
|
+
"""
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
|
|
7
|
+
from planning_structs.action_model import ActionModel, Literal
|
|
8
|
+
from planning_structs.domain import ActionSchema, Domain, Predicate, Type
|
|
9
|
+
from planning_structs.instance import Action, Instance, Object, Proposition
|
|
10
|
+
from planning_structs.trace import Trace
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
__version__ = version("planning-structs")
|
|
14
|
+
except PackageNotFoundError: # running from a source checkout without installation
|
|
15
|
+
__version__ = "0.0.0+unknown"
|
|
16
|
+
|
|
17
|
+
__all__ = ["Type", "Predicate", "ActionSchema", "Domain", "Object", "Proposition", "Action", "Instance",
|
|
18
|
+
"ActionModel", "Literal", "Trace", "__version__"]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A symbolic (discrete) lifted STRIPS action model over a Domain.
|
|
3
|
+
|
|
4
|
+
Each literal of an action schema is a (predicate, binding) pair, where the binding lists, for each
|
|
5
|
+
predicate position, the 1-based position of the action parameter it refers to. For example, in
|
|
6
|
+
`turn-on(?s, ?r)` the literal `(in ?s ?r)` is (in, (1, 2)).
|
|
7
|
+
|
|
8
|
+
Action model learners (e.g. ROSAME) can return their result as an ActionModel, which can then be
|
|
9
|
+
inspected, compared with a reference (`==`, `diff`) or written out.
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from typing import Dict, List, Tuple
|
|
15
|
+
|
|
16
|
+
from planning_structs.domain import Domain, Predicate
|
|
17
|
+
|
|
18
|
+
Literal = Tuple[Predicate, Tuple[int, ...]]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(eq=False)
|
|
22
|
+
class ActionModel:
|
|
23
|
+
domain: Domain
|
|
24
|
+
preconditions: Dict[str, List[Literal]] = field(default_factory=dict)
|
|
25
|
+
add_effects: Dict[str, List[Literal]] = field(default_factory=dict)
|
|
26
|
+
del_effects: Dict[str, List[Literal]] = field(default_factory=dict)
|
|
27
|
+
|
|
28
|
+
def schema(self, name: str) -> Tuple[List[Literal], List[Literal], List[Literal]]:
|
|
29
|
+
"""(preconditions, add effects, delete effects) of one action schema."""
|
|
30
|
+
return (self.preconditions.get(name, []), self.add_effects.get(name, []), self.del_effects.get(name, []))
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def literal_str(lit: Literal, parameter_names=None) -> str:
|
|
34
|
+
p, x = lit
|
|
35
|
+
names = parameter_names or [f"?x{i}" for i in range(1, max(x, default=0) + 1)]
|
|
36
|
+
return f"({p.name}{''.join(' ' + names[i - 1] for i in x)})"
|
|
37
|
+
|
|
38
|
+
def _key(self):
|
|
39
|
+
schemas = {a.name for a in self.domain.action_schemas}
|
|
40
|
+
return {n: tuple(frozenset((p.name, x) for p, x in lits) for lits in self.schema(n)) for n in schemas}
|
|
41
|
+
|
|
42
|
+
def __eq__(self, other) -> bool:
|
|
43
|
+
"""Same literals per action schema (by name), regardless of order."""
|
|
44
|
+
return isinstance(other, ActionModel) and self._key() == other._key()
|
|
45
|
+
|
|
46
|
+
def diff(self, other: "ActionModel") -> List[str]:
|
|
47
|
+
"""Readable differences from another model, e.g. a reference: one line per literal that is
|
|
48
|
+
in only one of the two (empty if they are equal)."""
|
|
49
|
+
mine, theirs, out = self._key(), other._key(), []
|
|
50
|
+
for name in sorted(set(mine) | set(theirs)):
|
|
51
|
+
for part, a, b in zip(("precondition", "add effect", "delete effect"),
|
|
52
|
+
mine.get(name, (frozenset(),) * 3), theirs.get(name, (frozenset(),) * 3)):
|
|
53
|
+
for p, x in sorted(a - b):
|
|
54
|
+
out.append(f"{name}: {part} ({p}{''.join(f' ?x{i}' for i in x)}) only in this model")
|
|
55
|
+
for p, x in sorted(b - a):
|
|
56
|
+
out.append(f"{name}: {part} ({p}{''.join(f' ?x{i}' for i in x)}) only in the other model")
|
|
57
|
+
return out
|
|
58
|
+
|
|
59
|
+
def __str__(self) -> str:
|
|
60
|
+
lines = []
|
|
61
|
+
for a in self.domain.action_schemas:
|
|
62
|
+
names = [f"?x{i}" for i in range(1, a.arity + 1)]
|
|
63
|
+
pre, add, dele = self.schema(a.name)
|
|
64
|
+
fmt = lambda lits: " ".join(self.literal_str(l, names) for l in lits) or "-"
|
|
65
|
+
lines.append(f"{a.name}({', '.join(names)})\n pre: {fmt(pre)}\n add: {fmt(add)}\n del: {fmt(dele)}")
|
|
66
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Typed STRIPS domains: types (single inheritance), predicates and action schemas.
|
|
3
|
+
|
|
4
|
+
A Domain also enumerates, for every (action schema, predicate) pair, the bindings x that map each
|
|
5
|
+
predicate position to a distinct, type-compatible action parameter position (1-based). Every
|
|
6
|
+
(schema, predicate, binding) triple is one slot of the lifted action model that ROSAME learns.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from itertools import permutations
|
|
11
|
+
from typing import Dict, List, Optional, Set, Tuple
|
|
12
|
+
|
|
13
|
+
@dataclass(eq=True, frozen=True)
|
|
14
|
+
class Type:
|
|
15
|
+
name: str
|
|
16
|
+
parent: Optional["Type"] = field(default=None, compare=False)
|
|
17
|
+
|
|
18
|
+
def is_child_of(self, ancestor: "Type") -> bool:
|
|
19
|
+
"""Returns True iff self is the same as ancestor or a descendant."""
|
|
20
|
+
t = self
|
|
21
|
+
while t is not None:
|
|
22
|
+
if t.name == ancestor.name:
|
|
23
|
+
return True
|
|
24
|
+
t = object.__getattribute__(t, "parent") # avoid dataclass frozen recursion
|
|
25
|
+
return False
|
|
26
|
+
|
|
27
|
+
def __str__(self):
|
|
28
|
+
return self.name
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(eq=True, frozen=True)
|
|
32
|
+
class Predicate:
|
|
33
|
+
name: str
|
|
34
|
+
arity: int
|
|
35
|
+
types: Tuple[Type, ...] # length = arity (unpadded)
|
|
36
|
+
|
|
37
|
+
def __str__(self):
|
|
38
|
+
return f"{self.name}([{', '.join([t.name for t in self.types])}])"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(eq=True, frozen=True)
|
|
42
|
+
class ActionSchema:
|
|
43
|
+
name: str
|
|
44
|
+
arity: int
|
|
45
|
+
types: Tuple[Type, ...] # length = arity (unpadded)
|
|
46
|
+
|
|
47
|
+
def __str__(self):
|
|
48
|
+
return f"{self.name}([{', '.join([t.name for t in self.types])}])"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class Domain:
|
|
52
|
+
"""
|
|
53
|
+
Domain(types, predicates, action_schemas)
|
|
54
|
+
- types: List[Tuple[name, parent_name_or_None]]
|
|
55
|
+
- predicates: List[Tuple[name, List[type_names]]]
|
|
56
|
+
- action_schemas: List[Tuple[name, List[type_names]]]
|
|
57
|
+
"""
|
|
58
|
+
def __init__(self, types, predicates, action_schemas, name: str | None = None):
|
|
59
|
+
# store name if provided
|
|
60
|
+
self.name = name
|
|
61
|
+
|
|
62
|
+
self.types_set, self._types_dict, self._edges = self.build_types(types)
|
|
63
|
+
self.predicates: List[Predicate] = self.build_predicates(predicates)
|
|
64
|
+
self.action_schemas: List[ActionSchema] = self.build_action_schemas(action_schemas)
|
|
65
|
+
|
|
66
|
+
# arity stats (for padding)
|
|
67
|
+
self.max_pred_arity = max((p.arity for p in self.predicates), default=0)
|
|
68
|
+
self.max_action_arity = max((a.arity for a in self.action_schemas), default=0)
|
|
69
|
+
|
|
70
|
+
# all valid bindings (padded to max_pred_arity with 0s)
|
|
71
|
+
self.predicate_arguments: Dict[Tuple[ActionSchema, Predicate], List[Tuple[int, ...]]] = \
|
|
72
|
+
self.build_predicate_arguments()
|
|
73
|
+
|
|
74
|
+
# --------- building blocks ---------
|
|
75
|
+
|
|
76
|
+
def build_types(self, types_spec):
|
|
77
|
+
"""
|
|
78
|
+
types_spec: List[Tuple[name, parent_name_or_None]]
|
|
79
|
+
Returns: (types_set, name->Type dict, edges[parent, child] sorted)
|
|
80
|
+
Behavior:
|
|
81
|
+
- Ensures a base 'object' type exists.
|
|
82
|
+
- Any type declared as a root (parent=None) and not named 'object'
|
|
83
|
+
is silently attached under 'object'.
|
|
84
|
+
- Any parent name that appears but isn't declared is created as a root,
|
|
85
|
+
then also attached under 'object'.
|
|
86
|
+
"""
|
|
87
|
+
# 1) Collect declared relations
|
|
88
|
+
name_to_parent = {n: p for n, p in types_spec}
|
|
89
|
+
|
|
90
|
+
# 2) Ensure 'object' exists as explicit root
|
|
91
|
+
if "object" not in name_to_parent:
|
|
92
|
+
name_to_parent["object"] = None
|
|
93
|
+
|
|
94
|
+
# 3) If a parent name appears that isn't declared, create it (root for now)
|
|
95
|
+
for _, p in types_spec:
|
|
96
|
+
if p is not None and p not in name_to_parent:
|
|
97
|
+
name_to_parent[p] = None # implicit node
|
|
98
|
+
|
|
99
|
+
# 4) Attach all roots (except 'object') under 'object'
|
|
100
|
+
# This handles the "loosely declared several roots" case.
|
|
101
|
+
for n, p in list(name_to_parent.items()):
|
|
102
|
+
if p is None and n != "object":
|
|
103
|
+
name_to_parent[n] = "object"
|
|
104
|
+
|
|
105
|
+
# --- Build Type objects with cycle detection ---
|
|
106
|
+
cache = {} # name -> Type
|
|
107
|
+
visiting = set()
|
|
108
|
+
|
|
109
|
+
def build(n: str):
|
|
110
|
+
if n in cache:
|
|
111
|
+
return cache[n]
|
|
112
|
+
if n in visiting:
|
|
113
|
+
raise ValueError(f"Cycle detected in type hierarchy at '{n}'")
|
|
114
|
+
visiting.add(n)
|
|
115
|
+
parent_name = name_to_parent.get(n, None)
|
|
116
|
+
parent_obj = build(parent_name) if parent_name is not None else None
|
|
117
|
+
t = Type(name=n, parent=parent_obj)
|
|
118
|
+
cache[n] = t
|
|
119
|
+
visiting.remove(n)
|
|
120
|
+
return t
|
|
121
|
+
|
|
122
|
+
# Build all nodes (declared + implicit)
|
|
123
|
+
for n in list(name_to_parent.keys()):
|
|
124
|
+
build(n)
|
|
125
|
+
|
|
126
|
+
# Deterministic edges: (parent, child) excluding roots
|
|
127
|
+
edges = sorted((p, c) for c, p in name_to_parent.items() if p is not None)
|
|
128
|
+
|
|
129
|
+
types_set = set(cache.values())
|
|
130
|
+
return types_set, cache, edges
|
|
131
|
+
|
|
132
|
+
def build_predicates(self, predicates_spec) -> list[Predicate]:
|
|
133
|
+
preds = []
|
|
134
|
+
for (name, params) in predicates_spec:
|
|
135
|
+
types = tuple(self._types_dict[tn] for tn in params)
|
|
136
|
+
preds.append(Predicate(name=name, arity=len(types), types=types))
|
|
137
|
+
self._pred_map = {p.name: p for p in preds}
|
|
138
|
+
return preds
|
|
139
|
+
|
|
140
|
+
def build_action_schemas(self, schemas_spec) -> list[ActionSchema]:
|
|
141
|
+
acts = []
|
|
142
|
+
for (name, params) in schemas_spec:
|
|
143
|
+
types = tuple(self._types_dict[tn] for tn in params)
|
|
144
|
+
acts.append(ActionSchema(name=name, arity=len(types), types=types))
|
|
145
|
+
self._act_map = {a.name: a for a in acts}
|
|
146
|
+
return acts
|
|
147
|
+
|
|
148
|
+
def _type_match(self, x_tuple: Tuple[int, ...], a: ActionSchema, p: Predicate) -> bool:
|
|
149
|
+
"""
|
|
150
|
+
x_tuple is a length p.arity tuple of integers in 1..a.arity (positions),
|
|
151
|
+
mapping predicate positions -> action positions.
|
|
152
|
+
Zeros are for padded predicate positions and are handled elsewhere; here we only check 1..p.arity.
|
|
153
|
+
"""
|
|
154
|
+
for i in range(p.arity):
|
|
155
|
+
ai = x_tuple[i]
|
|
156
|
+
# ai is in 1..a.arity
|
|
157
|
+
if not a.types[ai - 1].is_child_of(p.types[i]):
|
|
158
|
+
return False
|
|
159
|
+
return True
|
|
160
|
+
|
|
161
|
+
def build_predicate_arguments(self):
|
|
162
|
+
"""
|
|
163
|
+
For each (a, p), enumerate all valid bindings of length == p.arity
|
|
164
|
+
mapping predicate positions -> distinct action positions.
|
|
165
|
+
"""
|
|
166
|
+
res = {}
|
|
167
|
+
for a in self.action_schemas:
|
|
168
|
+
for p in self.predicates:
|
|
169
|
+
valid = []
|
|
170
|
+
if a.arity >= p.arity:
|
|
171
|
+
for x in permutations(range(1, a.arity + 1), p.arity):
|
|
172
|
+
if self._type_match(x, a, p):
|
|
173
|
+
valid.append(x)
|
|
174
|
+
res[(a, p)] = valid
|
|
175
|
+
return res
|
|
176
|
+
|
|
177
|
+
def get_type(self, type_name: str) -> Optional[Type]:
|
|
178
|
+
return self._types_dict.get(type_name)
|
|
179
|
+
|
|
180
|
+
def get_action_schema(self, act_name: str) -> Optional[ActionSchema]:
|
|
181
|
+
return self._act_map.get(act_name)
|
|
182
|
+
|
|
183
|
+
def get_predicate(self, pred_name: str) -> Optional[Predicate]:
|
|
184
|
+
return self._pred_map.get(pred_name)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Grounding of a Domain on a set of objects: objects, propositions and grounded actions.
|
|
3
|
+
|
|
4
|
+
Order conventions (relied on throughout the package):
|
|
5
|
+
- propositions: for each predicate in domain order, every tuple of *distinct*, type-compatible
|
|
6
|
+
objects in lexicographic order of their positions in the object list;
|
|
7
|
+
- actions: the same, for each action schema in domain order.
|
|
8
|
+
Object names never affect these orders, only the sequence of object types does.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from itertools import product
|
|
14
|
+
from typing import Dict, List, Optional, Sequence, Tuple
|
|
15
|
+
|
|
16
|
+
from planning_structs.domain import ActionSchema, Domain, Predicate, Type
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def objs2str(args: Tuple["Object", ...]) -> str:
|
|
20
|
+
return "_".join(o.name for o in args) if args else ""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass(eq=True, frozen=True)
|
|
24
|
+
class Object:
|
|
25
|
+
name: str
|
|
26
|
+
type: Type
|
|
27
|
+
|
|
28
|
+
def __str__(self) -> str:
|
|
29
|
+
return f"{self.name}: {self.type.name}"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(eq=True, frozen=True)
|
|
33
|
+
class Proposition:
|
|
34
|
+
"""Grounded predicate application with Object arguments."""
|
|
35
|
+
predicate: Predicate
|
|
36
|
+
args: Tuple[Object, ...]
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def arity(self) -> int:
|
|
40
|
+
return len(self.args)
|
|
41
|
+
|
|
42
|
+
def __str__(self) -> str:
|
|
43
|
+
return self.predicate.name if not self.args else f"{self.predicate.name}_{objs2str(self.args)}"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass(eq=True, frozen=True)
|
|
47
|
+
class Action:
|
|
48
|
+
"""Grounded action with Object arguments."""
|
|
49
|
+
action_schema: ActionSchema
|
|
50
|
+
args: Tuple[Object, ...]
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def arity(self) -> int:
|
|
54
|
+
return len(self.args)
|
|
55
|
+
|
|
56
|
+
def __str__(self) -> str:
|
|
57
|
+
return self.action_schema.name if not self.args else f"{self.action_schema.name}_{objs2str(self.args)}"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _groundings(objects: Sequence[Object], types: Sequence[Type]):
|
|
61
|
+
"""Tuples of distinct objects whose types match `types`, in lexicographic position order
|
|
62
|
+
(identical to filtering itertools.permutations(objects, len(types)) by type, but only visits
|
|
63
|
+
type-compatible candidates)."""
|
|
64
|
+
cands = [[i for i, o in enumerate(objects) if o.type.is_child_of(t)] for t in types]
|
|
65
|
+
for idx in product(*cands):
|
|
66
|
+
if len(set(idx)) == len(idx):
|
|
67
|
+
yield tuple(objects[i] for i in idx)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Instance:
|
|
71
|
+
"""
|
|
72
|
+
Objects, propositions and grounded actions of a Domain for one object set.
|
|
73
|
+
|
|
74
|
+
Groundings use distinct objects for distinct parameters (injective bindings), matching the
|
|
75
|
+
bindings enumerated by Domain. Propositions are built on construction; grounded actions are
|
|
76
|
+
built on first access to `actions`, since their number grows with the action arity and can be
|
|
77
|
+
very large (code that only grounds observed actions never needs them).
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
def __init__(self, domain: Domain, objects: Sequence[Tuple[str, str]]):
|
|
81
|
+
self.domain = domain
|
|
82
|
+
self.objects: List[Object] = self._build_objects(objects)
|
|
83
|
+
self.propositions: List[Proposition] = [Proposition(p, args) for p in domain.predicates
|
|
84
|
+
for args in _groundings(self.objects, p.types)]
|
|
85
|
+
self.prop_index: Dict[Tuple[Predicate, Tuple[Object, ...]], int] = {
|
|
86
|
+
(p.predicate, p.args): i for i, p in enumerate(self.propositions)}
|
|
87
|
+
self._objects_dict: Dict[str, Object] = {o.name: o for o in self.objects}
|
|
88
|
+
self._actions: Optional[List[Action]] = None
|
|
89
|
+
self._actions_dict: Optional[Dict[Tuple[ActionSchema, Tuple[Object, ...]], Action]] = None
|
|
90
|
+
|
|
91
|
+
def _build_objects(self, objects: Sequence[Tuple[str, str]]) -> List[Object]:
|
|
92
|
+
objs: List[Object] = []
|
|
93
|
+
for name, type_name in objects:
|
|
94
|
+
t = self.domain.get_type(type_name)
|
|
95
|
+
if t is None:
|
|
96
|
+
raise ValueError(f"Unknown type '{type_name}' for object '{name}'.")
|
|
97
|
+
objs.append(Object(name=name, type=t))
|
|
98
|
+
return objs
|
|
99
|
+
|
|
100
|
+
# ---------- grounded actions (lazy) ----------
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def actions(self) -> List[Action]:
|
|
104
|
+
if self._actions is None:
|
|
105
|
+
self._actions = [Action(a, args) for a in self.domain.action_schemas
|
|
106
|
+
for args in _groundings(self.objects, a.types)]
|
|
107
|
+
self._actions_dict = {(a.action_schema, a.args): a for a in self._actions}
|
|
108
|
+
return self._actions
|
|
109
|
+
|
|
110
|
+
# ---------- lookups ----------
|
|
111
|
+
|
|
112
|
+
def get_object(self, name: str) -> Optional[Object]:
|
|
113
|
+
return self._objects_dict.get(name)
|
|
114
|
+
|
|
115
|
+
def get_action(self, action_schema: ActionSchema, args: Sequence[Object]) -> Optional[Action]:
|
|
116
|
+
self.actions
|
|
117
|
+
return self._actions_dict.get((action_schema, tuple(args)))
|
|
118
|
+
|
|
119
|
+
def get_proposition(self, predicate: Predicate, args: Sequence[Object]) -> Optional[Proposition]:
|
|
120
|
+
i = self.prop_index.get((predicate, tuple(args)))
|
|
121
|
+
return None if i is None else self.propositions[i]
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def num_actions(self) -> int:
|
|
125
|
+
return len(self.actions)
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def num_propositions(self) -> int:
|
|
129
|
+
return len(self.propositions)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Traces: sequences of states and actions over one object set.
|
|
3
|
+
|
|
4
|
+
Trace(objects=[("r1", "room"), ("r2", "room"), ("s1", "switch")],
|
|
5
|
+
states=[["(robot-at r1)", "(off s1)"], ["(robot-at r2)", "(off s1)"]],
|
|
6
|
+
actions=["(move r1 r2)"])
|
|
7
|
+
|
|
8
|
+
Atoms and actions may be written "(in s1 r2)", "in s1 r2", ("in", "s1", "r2") or ("in", ("s1", "r2")).
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, Sequence, Tuple
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class Trace:
|
|
18
|
+
"""One trace of T transitions.
|
|
19
|
+
|
|
20
|
+
objects [(name, type), ...]: every object the states and actions mention, including domain
|
|
21
|
+
constants.
|
|
22
|
+
states T + 1 states. Each state is an iterable of true atoms, a dict {atom: probability} (atoms
|
|
23
|
+
not listed have probability 0), or a vector of probabilities over the propositions of
|
|
24
|
+
Instance(domain, objects), in their order; a whole [T + 1, P] array is also accepted.
|
|
25
|
+
actions T actions; None marks an unknown action.
|
|
26
|
+
"""
|
|
27
|
+
objects: Sequence[Tuple[str, str]]
|
|
28
|
+
states: Any
|
|
29
|
+
actions: Sequence[Any]
|
|
30
|
+
|
|
31
|
+
def __post_init__(self) -> None:
|
|
32
|
+
if hasattr(self.states, "__len__") and len(self.states) != len(self.actions) + 1:
|
|
33
|
+
raise ValueError(f"a trace with {len(self.actions)} actions needs {len(self.actions) + 1} states, "
|
|
34
|
+
f"got {len(self.states)}")
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def length(self) -> int:
|
|
38
|
+
"""Number of transitions."""
|
|
39
|
+
return len(self.actions)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: planning-structs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed STRIPS planning structures: domains, groundings, symbolic action models and traces
|
|
5
|
+
Project-URL: Homepage, https://github.com/xikaioliver/planning-structs
|
|
6
|
+
Project-URL: Issues, https://github.com/xikaioliver/planning-structs/issues
|
|
7
|
+
Author: Kai Xi, Stephen Gould, Sylvie Thiébaux
|
|
8
|
+
License-Expression: CC-BY-4.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: PDDL,STRIPS,action models,planning
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest>=7; extra == 'test'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# planning-structs
|
|
24
|
+
|
|
25
|
+
Typed STRIPS planning structures in plain Python, with no dependencies: domains, their groundings on
|
|
26
|
+
object sets, symbolic action models and traces. It is the structure layer of
|
|
27
|
+
[ROSAME](https://github.com/xikaioliver/ROSAME) and of other projects on learning planning models.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install planning-structs
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Overview
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from planning_structs import Domain, Instance, ActionModel, Trace
|
|
37
|
+
|
|
38
|
+
# A domain: types (single inheritance), predicates and action schemas with typed parameters.
|
|
39
|
+
domain = Domain(types=[("room", None), ("device", None), ("switch", "device")],
|
|
40
|
+
predicates=[("robot-at", ["room"]), ("in", ["device", "room"]), ("on", ["switch"])],
|
|
41
|
+
action_schemas=[("move", ["room", "room"]), ("turn-on", ["switch", "room"])],
|
|
42
|
+
name="switches")
|
|
43
|
+
|
|
44
|
+
# Its grounding on an object set: propositions (built at once) and actions (built on first use).
|
|
45
|
+
instance = Instance(domain, [("r1", "room"), ("r2", "room"), ("s1", "switch")])
|
|
46
|
+
print([str(p) for p in instance.propositions]) # robot-at_r1, robot-at_r2, in_s1_r1, ...
|
|
47
|
+
print(instance.num_actions)
|
|
48
|
+
|
|
49
|
+
# The lifted literals ("bindings") an action schema can have over each predicate:
|
|
50
|
+
move, robot_at = domain.get_action_schema("move"), domain.get_predicate("robot-at")
|
|
51
|
+
print(domain.predicate_arguments[(move, robot_at)]) # [(1,), (2,)]: robot-at(?x1), robot-at(?x2)
|
|
52
|
+
|
|
53
|
+
# A symbolic action model: per action schema, preconditions, add and delete effects.
|
|
54
|
+
model = ActionModel(domain)
|
|
55
|
+
model.preconditions["move"] = [(robot_at, (1,))]
|
|
56
|
+
model.add_effects["move"] = [(robot_at, (2,))]
|
|
57
|
+
model.del_effects["move"] = [(robot_at, (1,))]
|
|
58
|
+
print(model)
|
|
59
|
+
|
|
60
|
+
# A trace: objects, T + 1 states (true atoms, {atom: probability}, or vectors) and T actions.
|
|
61
|
+
trace = Trace(objects=[("r1", "room"), ("r2", "room")],
|
|
62
|
+
states=[["(robot-at r1)"], ["(robot-at r2)"]],
|
|
63
|
+
actions=["(move r1 r2)"])
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Conventions
|
|
67
|
+
|
|
68
|
+
- **Types** form a tree under `object`; `t.is_child_of(u)` is true when `t` is `u` or a descendant.
|
|
69
|
+
- **Bindings.** `domain.predicate_arguments[(schema, predicate)]` lists every way to fill the
|
|
70
|
+
predicate's positions with distinct, type-compatible parameters of the schema, as tuples of 1-based
|
|
71
|
+
parameter positions. In `move(?from, ?to)`, `(connected ?to ?from)` is the binding `(2, 1)`.
|
|
72
|
+
- **Grounding order.** Propositions: predicates in domain order, then tuples of *distinct*,
|
|
73
|
+
type-compatible objects in lexicographic order of their positions in the object list. Actions: the
|
|
74
|
+
same for action schemas. Only the sequence of object types matters, not the names.
|
|
75
|
+
- **Action models** compare with `==` regardless of literal order; `a.diff(b)` lists the literals
|
|
76
|
+
present in only one of them.
|
|
77
|
+
|
|
78
|
+
## Versions
|
|
79
|
+
|
|
80
|
+
Semantic versioning; see [CHANGELOG.md](CHANGELOG.md). Additions arrive in minor releases and stay
|
|
81
|
+
compatible with code written for earlier ones.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
planning_structs/__init__.py,sha256=HjCgBAOV1JY5ZEvW9IFWqIaVntlsS_s0bfUl496ou84,797
|
|
2
|
+
planning_structs/action_model.py,sha256=bEFv82P-Vflq4M3bzxZN5QU8a0nLiA5fIU_jz5x-CR4,3200
|
|
3
|
+
planning_structs/domain.py,sha256=4qJmVFU3LDZK9k8MaRlYce6p2sZyxjYVC4_wYln7oCs,7041
|
|
4
|
+
planning_structs/instance.py,sha256=ber6yXHN3TVIjVQpCctRe4NpjX7jRRSUNlXN7OzKiI8,4974
|
|
5
|
+
planning_structs/trace.py,sha256=Nz0mfbM-7YrXNhSxgOSiimL2_kI3Ky8ezOL5N1VJPrU,1507
|
|
6
|
+
planning_structs-0.1.0.dist-info/METADATA,sha256=mN-HcDrdRsQg0y9ANePJUmHv2IZCY_MF8XLD9OvCc3g,3876
|
|
7
|
+
planning_structs-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
planning_structs-0.1.0.dist-info/licenses/LICENSE,sha256=nl8bPGELnC2lwxO_gdV3p9Gs7Ghr2wOE7e-m3w-QzZQ,18656
|
|
9
|
+
planning_structs-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
Attribution 4.0 International
|
|
2
|
+
|
|
3
|
+
=======================================================================
|
|
4
|
+
|
|
5
|
+
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
6
|
+
does not provide legal services or legal advice. Distribution of
|
|
7
|
+
Creative Commons public licenses does not create a lawyer-client or
|
|
8
|
+
other relationship. Creative Commons makes its licenses and related
|
|
9
|
+
information available on an "as-is" basis. Creative Commons gives no
|
|
10
|
+
warranties regarding its licenses, any material licensed under their
|
|
11
|
+
terms and conditions, or any related information. Creative Commons
|
|
12
|
+
disclaims all liability for damages resulting from their use to the
|
|
13
|
+
fullest extent possible.
|
|
14
|
+
|
|
15
|
+
Using Creative Commons Public Licenses
|
|
16
|
+
|
|
17
|
+
Creative Commons public licenses provide a standard set of terms and
|
|
18
|
+
conditions that creators and other rights holders may use to share
|
|
19
|
+
original works of authorship and other material subject to copyright
|
|
20
|
+
and certain other rights specified in the public license below. The
|
|
21
|
+
following considerations are for informational purposes only, are not
|
|
22
|
+
exhaustive, and do not form part of our licenses.
|
|
23
|
+
|
|
24
|
+
Considerations for licensors: Our public licenses are
|
|
25
|
+
intended for use by those authorized to give the public
|
|
26
|
+
permission to use material in ways otherwise restricted by
|
|
27
|
+
copyright and certain other rights. Our licenses are
|
|
28
|
+
irrevocable. Licensors should read and understand the terms
|
|
29
|
+
and conditions of the license they choose before applying it.
|
|
30
|
+
Licensors should also secure all rights necessary before
|
|
31
|
+
applying our licenses so that the public can reuse the
|
|
32
|
+
material as expected. Licensors should clearly mark any
|
|
33
|
+
material not subject to the license. This includes other CC-
|
|
34
|
+
licensed material, or material used under an exception or
|
|
35
|
+
limitation to copyright. More considerations for licensors:
|
|
36
|
+
wiki.creativecommons.org/Considerations_for_licensors
|
|
37
|
+
|
|
38
|
+
Considerations for the public: By using one of our public
|
|
39
|
+
licenses, a licensor grants the public permission to use the
|
|
40
|
+
licensed material under specified terms and conditions. If
|
|
41
|
+
the licensor's permission is not necessary for any reason--for
|
|
42
|
+
example, because of any applicable exception or limitation to
|
|
43
|
+
copyright--then that use is not regulated by the license. Our
|
|
44
|
+
licenses grant only permissions under copyright and certain
|
|
45
|
+
other rights that a licensor has authority to grant. Use of
|
|
46
|
+
the licensed material may still be restricted for other
|
|
47
|
+
reasons, including because others have copyright or other
|
|
48
|
+
rights in the material. A licensor may make special requests,
|
|
49
|
+
such as asking that all changes be marked or described.
|
|
50
|
+
Although not required by our licenses, you are encouraged to
|
|
51
|
+
respect those requests where reasonable. More considerations
|
|
52
|
+
for the public:
|
|
53
|
+
wiki.creativecommons.org/Considerations_for_licensees
|
|
54
|
+
|
|
55
|
+
=======================================================================
|
|
56
|
+
|
|
57
|
+
Creative Commons Attribution 4.0 International Public License
|
|
58
|
+
|
|
59
|
+
By exercising the Licensed Rights (defined below), You accept and agree
|
|
60
|
+
to be bound by the terms and conditions of this Creative Commons
|
|
61
|
+
Attribution 4.0 International Public License ("Public License"). To the
|
|
62
|
+
extent this Public License may be interpreted as a contract, You are
|
|
63
|
+
granted the Licensed Rights in consideration of Your acceptance of
|
|
64
|
+
these terms and conditions, and the Licensor grants You such rights in
|
|
65
|
+
consideration of benefits the Licensor receives from making the
|
|
66
|
+
Licensed Material available under these terms and conditions.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Section 1 -- Definitions.
|
|
70
|
+
|
|
71
|
+
a. Adapted Material means material subject to Copyright and Similar
|
|
72
|
+
Rights that is derived from or based upon the Licensed Material
|
|
73
|
+
and in which the Licensed Material is translated, altered,
|
|
74
|
+
arranged, transformed, or otherwise modified in a manner requiring
|
|
75
|
+
permission under the Copyright and Similar Rights held by the
|
|
76
|
+
Licensor. For purposes of this Public License, where the Licensed
|
|
77
|
+
Material is a musical work, performance, or sound recording,
|
|
78
|
+
Adapted Material is always produced where the Licensed Material is
|
|
79
|
+
synched in timed relation with a moving image.
|
|
80
|
+
|
|
81
|
+
b. Adapter's License means the license You apply to Your Copyright
|
|
82
|
+
and Similar Rights in Your contributions to Adapted Material in
|
|
83
|
+
accordance with the terms and conditions of this Public License.
|
|
84
|
+
|
|
85
|
+
c. Copyright and Similar Rights means copyright and/or similar rights
|
|
86
|
+
closely related to copyright including, without limitation,
|
|
87
|
+
performance, broadcast, sound recording, and Sui Generis Database
|
|
88
|
+
Rights, without regard to how the rights are labeled or
|
|
89
|
+
categorized. For purposes of this Public License, the rights
|
|
90
|
+
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
91
|
+
Rights.
|
|
92
|
+
|
|
93
|
+
d. Effective Technological Measures means those measures that, in the
|
|
94
|
+
absence of proper authority, may not be circumvented under laws
|
|
95
|
+
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
96
|
+
Treaty adopted on December 20, 1996, and/or similar international
|
|
97
|
+
agreements.
|
|
98
|
+
|
|
99
|
+
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
100
|
+
any other exception or limitation to Copyright and Similar Rights
|
|
101
|
+
that applies to Your use of the Licensed Material.
|
|
102
|
+
|
|
103
|
+
f. Licensed Material means the artistic or literary work, database,
|
|
104
|
+
or other material to which the Licensor applied this Public
|
|
105
|
+
License.
|
|
106
|
+
|
|
107
|
+
g. Licensed Rights means the rights granted to You subject to the
|
|
108
|
+
terms and conditions of this Public License, which are limited to
|
|
109
|
+
all Copyright and Similar Rights that apply to Your use of the
|
|
110
|
+
Licensed Material and that the Licensor has authority to license.
|
|
111
|
+
|
|
112
|
+
h. Licensor means the individual(s) or entity(ies) granting rights
|
|
113
|
+
under this Public License.
|
|
114
|
+
|
|
115
|
+
i. Share means to provide material to the public by any means or
|
|
116
|
+
process that requires permission under the Licensed Rights, such
|
|
117
|
+
as reproduction, public display, public performance, distribution,
|
|
118
|
+
dissemination, communication, or importation, and to make material
|
|
119
|
+
available to the public including in ways that members of the
|
|
120
|
+
public may access the material from a place and at a time
|
|
121
|
+
individually chosen by them.
|
|
122
|
+
|
|
123
|
+
j. Sui Generis Database Rights means rights other than copyright
|
|
124
|
+
resulting from Directive 96/9/EC of the European Parliament and of
|
|
125
|
+
the Council of 11 March 1996 on the legal protection of databases,
|
|
126
|
+
as amended and/or succeeded, as well as other essentially
|
|
127
|
+
equivalent rights anywhere in the world.
|
|
128
|
+
|
|
129
|
+
k. You means the individual or entity exercising the Licensed Rights
|
|
130
|
+
under this Public License. Your has a corresponding meaning.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Section 2 -- Scope.
|
|
134
|
+
|
|
135
|
+
a. License grant.
|
|
136
|
+
|
|
137
|
+
1. Subject to the terms and conditions of this Public License,
|
|
138
|
+
the Licensor hereby grants You a worldwide, royalty-free,
|
|
139
|
+
non-sublicensable, non-exclusive, irrevocable license to
|
|
140
|
+
exercise the Licensed Rights in the Licensed Material to:
|
|
141
|
+
|
|
142
|
+
a. reproduce and Share the Licensed Material, in whole or
|
|
143
|
+
in part; and
|
|
144
|
+
|
|
145
|
+
b. produce, reproduce, and Share Adapted Material.
|
|
146
|
+
|
|
147
|
+
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
148
|
+
Exceptions and Limitations apply to Your use, this Public
|
|
149
|
+
License does not apply, and You do not need to comply with
|
|
150
|
+
its terms and conditions.
|
|
151
|
+
|
|
152
|
+
3. Term. The term of this Public License is specified in Section
|
|
153
|
+
6(a).
|
|
154
|
+
|
|
155
|
+
4. Media and formats; technical modifications allowed. The
|
|
156
|
+
Licensor authorizes You to exercise the Licensed Rights in
|
|
157
|
+
all media and formats whether now known or hereafter created,
|
|
158
|
+
and to make technical modifications necessary to do so. The
|
|
159
|
+
Licensor waives and/or agrees not to assert any right or
|
|
160
|
+
authority to forbid You from making technical modifications
|
|
161
|
+
necessary to exercise the Licensed Rights, including
|
|
162
|
+
technical modifications necessary to circumvent Effective
|
|
163
|
+
Technological Measures. For purposes of this Public License,
|
|
164
|
+
simply making modifications authorized by this Section 2(a)
|
|
165
|
+
(4) never produces Adapted Material.
|
|
166
|
+
|
|
167
|
+
5. Downstream recipients.
|
|
168
|
+
|
|
169
|
+
a. Offer from the Licensor -- Licensed Material. Every
|
|
170
|
+
recipient of the Licensed Material automatically
|
|
171
|
+
receives an offer from the Licensor to exercise the
|
|
172
|
+
Licensed Rights under the terms and conditions of this
|
|
173
|
+
Public License.
|
|
174
|
+
|
|
175
|
+
b. No downstream restrictions. You may not offer or impose
|
|
176
|
+
any additional or different terms or conditions on, or
|
|
177
|
+
apply any Effective Technological Measures to, the
|
|
178
|
+
Licensed Material if doing so restricts exercise of the
|
|
179
|
+
Licensed Rights by any recipient of the Licensed
|
|
180
|
+
Material.
|
|
181
|
+
|
|
182
|
+
6. No endorsement. Nothing in this Public License constitutes or
|
|
183
|
+
may be construed as permission to assert or imply that You
|
|
184
|
+
are, or that Your use of the Licensed Material is, connected
|
|
185
|
+
with, or sponsored, endorsed, or granted official status by,
|
|
186
|
+
the Licensor or others designated to receive attribution as
|
|
187
|
+
provided in Section 3(a)(1)(A)(i).
|
|
188
|
+
|
|
189
|
+
b. Other rights.
|
|
190
|
+
|
|
191
|
+
1. Moral rights, such as the right of integrity, are not
|
|
192
|
+
licensed under this Public License, nor are publicity,
|
|
193
|
+
privacy, and/or other similar personality rights; however, to
|
|
194
|
+
the extent possible, the Licensor waives and/or agrees not to
|
|
195
|
+
assert any such rights held by the Licensor to the limited
|
|
196
|
+
extent necessary to allow You to exercise the Licensed
|
|
197
|
+
Rights, but not otherwise.
|
|
198
|
+
|
|
199
|
+
2. Patent and trademark rights are not licensed under this
|
|
200
|
+
Public License.
|
|
201
|
+
|
|
202
|
+
3. To the extent possible, the Licensor waives any right to
|
|
203
|
+
collect royalties from You for the exercise of the Licensed
|
|
204
|
+
Rights, whether directly or through a collecting society
|
|
205
|
+
under any voluntary or waivable statutory or compulsory
|
|
206
|
+
licensing scheme. In all other cases the Licensor expressly
|
|
207
|
+
reserves any right to collect such royalties.
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
Section 3 -- License Conditions.
|
|
211
|
+
|
|
212
|
+
Your exercise of the Licensed Rights is expressly made subject to the
|
|
213
|
+
following conditions.
|
|
214
|
+
|
|
215
|
+
a. Attribution.
|
|
216
|
+
|
|
217
|
+
1. If You Share the Licensed Material (including in modified
|
|
218
|
+
form), You must:
|
|
219
|
+
|
|
220
|
+
a. retain the following if it is supplied by the Licensor
|
|
221
|
+
with the Licensed Material:
|
|
222
|
+
|
|
223
|
+
i. identification of the creator(s) of the Licensed
|
|
224
|
+
Material and any others designated to receive
|
|
225
|
+
attribution, in any reasonable manner requested by
|
|
226
|
+
the Licensor (including by pseudonym if
|
|
227
|
+
designated);
|
|
228
|
+
|
|
229
|
+
ii. a copyright notice;
|
|
230
|
+
|
|
231
|
+
iii. a notice that refers to this Public License;
|
|
232
|
+
|
|
233
|
+
iv. a notice that refers to the disclaimer of
|
|
234
|
+
warranties;
|
|
235
|
+
|
|
236
|
+
v. a URI or hyperlink to the Licensed Material to the
|
|
237
|
+
extent reasonably practicable;
|
|
238
|
+
|
|
239
|
+
b. indicate if You modified the Licensed Material and
|
|
240
|
+
retain an indication of any previous modifications; and
|
|
241
|
+
|
|
242
|
+
c. indicate the Licensed Material is licensed under this
|
|
243
|
+
Public License, and include the text of, or the URI or
|
|
244
|
+
hyperlink to, this Public License.
|
|
245
|
+
|
|
246
|
+
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
247
|
+
reasonable manner based on the medium, means, and context in
|
|
248
|
+
which You Share the Licensed Material. For example, it may be
|
|
249
|
+
reasonable to satisfy the conditions by providing a URI or
|
|
250
|
+
hyperlink to a resource that includes the required
|
|
251
|
+
information.
|
|
252
|
+
|
|
253
|
+
3. If requested by the Licensor, You must remove any of the
|
|
254
|
+
information required by Section 3(a)(1)(A) to the extent
|
|
255
|
+
reasonably practicable.
|
|
256
|
+
|
|
257
|
+
4. If You Share Adapted Material You produce, the Adapter's
|
|
258
|
+
License You apply must not prevent recipients of the Adapted
|
|
259
|
+
Material from complying with this Public License.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
Section 4 -- Sui Generis Database Rights.
|
|
263
|
+
|
|
264
|
+
Where the Licensed Rights include Sui Generis Database Rights that
|
|
265
|
+
apply to Your use of the Licensed Material:
|
|
266
|
+
|
|
267
|
+
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
268
|
+
to extract, reuse, reproduce, and Share all or a substantial
|
|
269
|
+
portion of the contents of the database;
|
|
270
|
+
|
|
271
|
+
b. if You include all or a substantial portion of the database
|
|
272
|
+
contents in a database in which You have Sui Generis Database
|
|
273
|
+
Rights, then the database in which You have Sui Generis Database
|
|
274
|
+
Rights (but not its individual contents) is Adapted Material; and
|
|
275
|
+
|
|
276
|
+
c. You must comply with the conditions in Section 3(a) if You Share
|
|
277
|
+
all or a substantial portion of the contents of the database.
|
|
278
|
+
|
|
279
|
+
For the avoidance of doubt, this Section 4 supplements and does not
|
|
280
|
+
replace Your obligations under this Public License where the Licensed
|
|
281
|
+
Rights include other Copyright and Similar Rights.
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
285
|
+
|
|
286
|
+
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
287
|
+
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
288
|
+
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
289
|
+
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
290
|
+
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
291
|
+
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
292
|
+
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
293
|
+
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
294
|
+
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
295
|
+
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
296
|
+
|
|
297
|
+
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
298
|
+
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
299
|
+
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
300
|
+
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
301
|
+
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
302
|
+
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
303
|
+
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
304
|
+
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
305
|
+
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
306
|
+
|
|
307
|
+
c. The disclaimer of warranties and limitation of liability provided
|
|
308
|
+
above shall be interpreted in a manner that, to the extent
|
|
309
|
+
possible, most closely approximates an absolute disclaimer and
|
|
310
|
+
waiver of all liability.
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
Section 6 -- Term and Termination.
|
|
314
|
+
|
|
315
|
+
a. This Public License applies for the term of the Copyright and
|
|
316
|
+
Similar Rights licensed here. However, if You fail to comply with
|
|
317
|
+
this Public License, then Your rights under this Public License
|
|
318
|
+
terminate automatically.
|
|
319
|
+
|
|
320
|
+
b. Where Your right to use the Licensed Material has terminated under
|
|
321
|
+
Section 6(a), it reinstates:
|
|
322
|
+
|
|
323
|
+
1. automatically as of the date the violation is cured, provided
|
|
324
|
+
it is cured within 30 days of Your discovery of the
|
|
325
|
+
violation; or
|
|
326
|
+
|
|
327
|
+
2. upon express reinstatement by the Licensor.
|
|
328
|
+
|
|
329
|
+
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
330
|
+
right the Licensor may have to seek remedies for Your violations
|
|
331
|
+
of this Public License.
|
|
332
|
+
|
|
333
|
+
c. For the avoidance of doubt, the Licensor may also offer the
|
|
334
|
+
Licensed Material under separate terms or conditions or stop
|
|
335
|
+
distributing the Licensed Material at any time; however, doing so
|
|
336
|
+
will not terminate this Public License.
|
|
337
|
+
|
|
338
|
+
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
339
|
+
License.
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
Section 7 -- Other Terms and Conditions.
|
|
343
|
+
|
|
344
|
+
a. The Licensor shall not be bound by any additional or different
|
|
345
|
+
terms or conditions communicated by You unless expressly agreed.
|
|
346
|
+
|
|
347
|
+
b. Any arrangements, understandings, or agreements regarding the
|
|
348
|
+
Licensed Material not stated herein are separate from and
|
|
349
|
+
independent of the terms and conditions of this Public License.
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
Section 8 -- Interpretation.
|
|
353
|
+
|
|
354
|
+
a. For the avoidance of doubt, this Public License does not, and
|
|
355
|
+
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
356
|
+
conditions on any use of the Licensed Material that could lawfully
|
|
357
|
+
be made without permission under this Public License.
|
|
358
|
+
|
|
359
|
+
b. To the extent possible, if any provision of this Public License is
|
|
360
|
+
deemed unenforceable, it shall be automatically reformed to the
|
|
361
|
+
minimum extent necessary to make it enforceable. If the provision
|
|
362
|
+
cannot be reformed, it shall be severed from this Public License
|
|
363
|
+
without affecting the enforceability of the remaining terms and
|
|
364
|
+
conditions.
|
|
365
|
+
|
|
366
|
+
c. No term or condition of this Public License will be waived and no
|
|
367
|
+
failure to comply consented to unless expressly agreed to by the
|
|
368
|
+
Licensor.
|
|
369
|
+
|
|
370
|
+
d. Nothing in this Public License constitutes or may be interpreted
|
|
371
|
+
as a limitation upon, or waiver of, any privileges and immunities
|
|
372
|
+
that apply to the Licensor or You, including from the legal
|
|
373
|
+
processes of any jurisdiction or authority.
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
=======================================================================
|
|
377
|
+
|
|
378
|
+
Creative Commons is not a party to its public
|
|
379
|
+
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
380
|
+
its public licenses to material it publishes and in those instances
|
|
381
|
+
will be considered the “Licensor.” The text of the Creative Commons
|
|
382
|
+
public licenses is dedicated to the public domain under the CC0 Public
|
|
383
|
+
Domain Dedication. Except for the limited purpose of indicating that
|
|
384
|
+
material is shared under a Creative Commons public license or as
|
|
385
|
+
otherwise permitted by the Creative Commons policies published at
|
|
386
|
+
creativecommons.org/policies, Creative Commons does not authorize the
|
|
387
|
+
use of the trademark "Creative Commons" or any other trademark or logo
|
|
388
|
+
of Creative Commons without its prior written consent including,
|
|
389
|
+
without limitation, in connection with any unauthorized modifications
|
|
390
|
+
to any of its public licenses or any other arrangements,
|
|
391
|
+
understandings, or agreements concerning use of licensed material. For
|
|
392
|
+
the avoidance of doubt, this paragraph does not form part of the
|
|
393
|
+
public licenses.
|
|
394
|
+
|
|
395
|
+
Creative Commons may be contacted at creativecommons.org.
|