Algorithmadvanced
Regression in the situation calculus
Also called Reiter's regression operator.
Rewrites a query about the situation after a sequence of actions into an equivalent query about the initial situation, using successor state axioms.
- Time
- O(2^k (q + n m)) entail_brute_forceO(n p + n^2 m) executable_expectedO(n q + n^2 m) regress_expected
- Space
- O(q + n m) regressed_formula
- Where
- k = the number of fluents; m = the largest total size of the successor state formulas of one action; n = the number of actions in the sequence; p = the number of nodes of the largest precondition; q = the number of nodes of the query
- Model
- Word RAM
- Properties
- deterministicexactnot needs complete initial database
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Raymond Reiter, 1991
Regression is Reiter's method for the projection problem of the situation calculus: to decide whether a formula holds in the situation , it replaces each fluent by the right side of its successor state axiom, one action at a time from the last to the first, until the formula speaks only about . Then a theorem prover checks the result against the initial database alone, with no axioms about actions or situations. Goal regression does the same for a set of STRIPS facts and one action; this page treats arbitrary formulas and whole action sequences, and gives the regression theorem that makes the method complete. The code on this page handles a ground, finite, propositional fragment with no sensing actions, while the regression theorem of Pirri and Reiter (1999) is first order.
In plain words
You know some things about the world now, and you plan to do a list of actions. You want to know whether some fact will be true at the end. One way is to run the actions forward in your head from every world you think possible. Regression goes the other way. Take the question about the end and ask: what must be true one step before, so that the last action makes the fact true? Each action has a rule that says exactly when it makes a fact true and when it leaves it alone, so that question has an exact answer. Repeat this for each action, back to the start. Now the question is about the present only, and you can check it against what you know now. The rules are used, but never the full history of possible worlds.
The problem
A basic action theory (Reiter 2001, Section 4.4) is : the foundational axioms for situations, one successor state axiom for each fluent,
one precondition axiom for each action function , unique names axioms for actions, and the initial database , a set of first-order sentences about only. A formula is regressable when every situation term in it has the form , every atom has an action term of the form , and it does not quantify over situations, compare situations with or equate two situations.
- Projection. Given and a regressable sentence , decide .
- Executability. Given ground actions , decide whether .
The regression operator is defined on regressable formulas by: if mentions no situation term other than ; ; after a renaming of the bound variables of ; and commutes with , and . Each rewrite of a fluent removes one from its situation term, so the recursion stops.
Regression theorem (Pirri and Reiter 1999; Reiter 2001, Section 4.5). If is regressable, then is a formula about only, and
The foundational axioms, the successor state axioms and the precondition axioms are used up by the rewriting; the final test is an ordinary first-order entailment.
The fragment of the code. Fluents are ground atoms with no object arguments, the actions are a finite set of ground names, and no action senses. A state is then a truth assignment to the fluents. For each action and fluent the successor state axiom is , where are propositional formulas over the fluents, and is its right side. The unique names axioms are built into the action names, and is a set of propositional formulas, which may leave fluents unknown.
The algorithm
Formulas are nodes of a hash-consed DAG: MAKE returns the existing node for a formula that is already built, and folds the constants true and false.
REGRESS(φ, [a_1, ..., a_n]) ▷ φ is about do([a_1, ..., a_n], S0)- 1
for i ← n down to 1 do - 2
M ← an empty memo table - 3
φ ← STEP(φ, a_i, M) ▷ now φ is about do([a_1, ..., a_{i-1}], S0) - 4
return φ ▷ a formula about S0 STEP(u, a, M) ▷ the formula u with each fluent F replaced by Φ_{F,a}- 5
if u is in M then return M[u] - 6
if u is true or false then r ← u - 7
else if u is a fluent F then r ← Φ_{F,a} - 8
else if u = ¬v then r ← MAKE(¬, STEP(v, a, M)) - 9
else u = v ∘ w with ∘ in {∧, ∨}: r ← MAKE(∘, STEP(v, a, M), STEP(w, a, M)) - 10
M[u] ← r; return r EXECUTABLE-FORMULA([a_1, ..., a_n])- 11
χ ← true - 12
for i ← n down to 1 do - 13
χ ← MAKE(∧, Π_{a_i}, STEP(χ, a_i, an empty memo table)) - 14
return χ PROJECT(D, φ, [a_1, ..., a_n])- 15
return ENTAILS(D_S0, REGRESS(φ, [a_1, ..., a_n]))
ENTAILS decides . The code tries all states; a real system gives to a SAT solver after the Tseitin transformation of the DAG. Line L13 keeps the invariant that , after the step for , is about and says that can run in order from there. So one backward pass regresses every precondition through all the actions before it.
Example
Take the Yale shooting domain with the fluents and . The action has and ; has no effects; has and . Both and are always possible. The right sides of the successor state axioms are:
| action | ||
|---|---|---|
Regress through :
| step | action | after line L3 |
|---|---|---|
| start | ||
| , which MAKE folds to |
The result is , so every initial database entails that the victim is dead after the sequence. EXECUTABLE-FORMULA gives after and , and after . With the sequence is not known to be executable, since the state with true is a model, and with it is. The query after regresses to : the first database does not entail it and the second does.
Sharing matters. Let one action set to , with and , so that . Regressing through copies of gives a formula whose tree has nodes for (9, 25, 57, ..., 2041 for ), because occurs twice in . The DAG has nodes (7, 11, 15, ..., 35).
Correctness
The proofs are in the correctness proof. For a state and an action , let be the state with for each fluent ; this is what the successor state axioms force.
- One step. For every formula and state , . The proof is an induction on ; the case of a fluent is the successor state axiom, and the memo table only returns values that were computed by the same rule.
- Whole sequence. By induction on , if and only if holds in the state reached from by .
- Projection. In the fragment, a model of is fixed by its initial state, which is any model of , since the successor state axioms determine every later state. So if and only if , which is the regression theorem for this fragment.
- Executability. By induction from down to 1, after line L13 holds at if and only if are possible in order from .
Proof: Regression in the ground propositional situation calculus is sound and complete for projection and executabilityfull
We use the pseudocode of the page, lines L1 to L15, and the fragment of the page: ground fluents, a finite set of ground actions, no sensing. A state is a map from the fluents to , extended to formulas in the usual way; we write when is true in . For an action , is the right side of the successor state axiom of , and is the state with if and only if . For a sequence, and .
Semantics of the fragment. A model of the theory assigns a state to every situation. The successor state axioms say that the state of is , so by induction on the length of the action list the state of is , where is the state of . The only other axioms on states are those of , so the possible values of are exactly the models of , and each of them extends to a model of the whole theory by this rule. is true if and only if is true in the state of .
Lemma 0 (MAKE). MAKE, MAKE and MAKE return a node that is true in each state exactly when , or is.
Proof. MAKE either returns a stored node built from the same operator and the same children, or applies one of the identities , , , , and their duals for , each of which holds in every state.
Lemma 1 (one step). Fix an action and a memo table such that every entry satisfies: for every state , . Then STEP returns a node with the same property, and every entry it adds to has it.
Proof. By induction on the number of nodes below . If is in (line L5), the claim is the assumption on . If is a constant (line L6), and a constant has the same value in every state. If is a fluent (line L7), , and if and only if , by the definition of succ. If (line L8), the call on returns with by the induction hypothesis, since has fewer nodes below it than ; by Lemma 0, . The case (line L9) is the same with two calls; the call on may use entries that the call on added, and these have the property by the induction hypothesis. Line L10 adds the entry , which has the property by the case analysis.
Lemma 2 (REGRESS). For every formula , every action list and every state ,
Proof. Let and let be the value of after the loop body for (lines L2 and L3). We show by induction on that for every state , . For the list is empty and both sides are . For the step from to , line L2 makes an empty table, which satisfies the assumption of Lemma 1 for . By Lemma 1, , and by the induction hypothesis applied to the state this holds if and only if , which is . For this is the claim.
Theorem 1 (projection). PROJECT returns true if and only if holds in in every model of the theory.
Proof. By the semantics of the fragment, holds in in every model if and only if for every model of . By Lemma 2 this holds if and only if every model of satisfies REGRESS, that is, if and only if entails it, which is what line L15 tests.
Theorem 2 (executability). EXECUTABLE-FORMULA returns a formula such that, for every state , if and only if for each from 1 to , . So if and only if the sequence is executable in every model.
Proof. Let and let be the value after line L13 for . We show by induction on : for every state , if and only if for each with . For there is no such and . For the step, , so by Lemmas 0 and 1, if and only if and . By the induction hypothesis at the state , the second part says that for each with , and the first part is the case . For this is the claim. The second sentence follows from the semantics of and of , as in Theorem 1.
Termination and size. The loop of line L1 runs times. Each call of STEP on a node not in adds that node to before it returns, and it calls STEP only on the children of the node, so each node of the current DAG is expanded at most once per step. The nodes that step creates are the nodes of the formulas (these exist before the step) and at most one node from line L8 or L9 for each node of . So , and by induction .
Complexity
- Size. Line L7 adds the nodes of and lines L8 and L9 add at most one node for each node of . So the DAG after the step for has at most nodes, and the result has at most nodes. The tree form has no such bound, as the example shows.
- Time. Step visits each node of the current DAG once, with one expected hash lookup per node, so the total is expected. EXECUTABLE-FORMULA has the same bound with replaced by the size of the largest precondition, because grows by at most one precondition and one round of formulas per step.
- Entailment. In the fragment, projection with an arbitrary propositional is coNP-complete. It is in coNP because the regressed DAG has polynomial size, and a model of that falsifies it is a short certificate. It is coNP-hard already for , where it is propositional entailment. If fixes every fluent, ENTAILS is one evaluation and projection takes polynomial time. In the first-order case regression still terminates, but the final test is first-order entailment, which is undecidable in general.
Properties
- Exact. The answer is the same as the answer from the whole theory, not an approximation.
- Works with incomplete knowledge. may leave fluents open; the answer is "entailed" only when every possible initial state gives the same answer.
- Query-driven. Only the fluents that the query reaches are rewritten. Regression never builds a state.
- Leaves the database unchanged. Many queries over different histories use the same .
Variants and improvements
- Composition forward. In the propositional fragment, compute for each fluent a formula about that gives after : and . Then . With sharing this takes expected time, at the cost of computing all fluents, also those that the query does not need.
- Progression (Lin and Reiter 1997). Update to a database about the current situation, and answer later queries against it. Lin and Reiter show that the progressed database is not always first-order definable, and they give classes where it is.
- Knowledge and sensing. With a knowledge fluent and sensing actions, regression extends to formulas about what the agent knows (Reiter 2001, Section 11.6).
- Goal regression for STRIPS. When each and is or and the query is a conjunction of fluents, is the set formula of goal regression, and regressing through a plan is backward state-space search read as logic. The weakest precondition of an assignment is the same substitution idea for programs.
When to use it
Use regression for a few queries about hypothetical action sequences over an initial database that changes rarely, for example in an interpreter that must check that each step of a candidate plan is possible. Use progression when an agent acts for a long time and asks many questions about the current state: the regressed formulas then grow with the length of the history, while a progressed database does not.
Pitfalls
- Projection is not executability. A query can hold after a sequence in every model even when the sequence cannot run. In the example, after is entailed by , but the sequence is not known to be executable there. Check separately, or conjoin it to the query.
- Exponential growth without sharing. A successor state formula that mentions a fluent twice doubles the tree at each step, as in the example. Keep the formula as a DAG and pass it to the prover in a form that keeps the sharing.
- Non-regressable queries. "The light is on in every situation reachable from " quantifies over situations, and is not defined on it. Such properties need induction on situations, which provides but regression does not use.
- Variable capture and unique names. In the first-order case, rename the bound variables of before the substitution. A formula such as inside simplifies to for only with the unique names axioms, so leaving out of the final test gives wrong answers.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/situation-calculus-regression/. The authors are listed in prov/A4NKPR.jsonl.
"""Regression for a ground, finite, propositional fragment of the situation calculus.
This module is not the first-order regression operator of Reiter. It covers
the case where every fluent is a ground atom with no situation-independent
arguments, there are finitely many ground actions, and no action senses
anything. In that case a situation is a truth assignment to the fluents,
and the successor state axiom of a fluent F for an action a reads
F(do(a, s)) <-> gamma_plus(s) or (F(s) and not gamma_minus(s)),
where gamma_plus and gamma_minus are formulas over the fluents at s. The
precondition axiom of a is Poss(a, s) <-> pi_a(s). The general regression
theorem (Pirri and Reiter, JACM 46(3), 1999) is first order and needs the
foundational axioms and unique names axioms for actions; none of that
appears here.
Formulas are nodes of a hash-consed DAG (class Formulas). Node ids are
integers and equal formulas built twice get the same id, so a regression
step that replaces each fluent by its successor state formula shares every
common subformula. The size of the regressed DAG grows by at most the size
of the successor state formulas at each step.
"""
from __future__ import annotations
import itertools
FALSE, TRUE = 0, 1
class Formulas:
"""A hash-consed DAG of propositional formulas over named fluents."""
def __init__(self) -> None:
self.nodes: list[tuple] = [("const", False), ("const", True)]
self.unique: dict[tuple, int] = {}
def _make(self, key: tuple) -> int:
u = self.unique.get(key)
if u is None:
u = len(self.nodes)
self.nodes.append(key)
self.unique[key] = u
return u
def fluent(self, name: str) -> int:
return self._make(("fluent", name))
def neg(self, a: int) -> int:
if a in (FALSE, TRUE):
return TRUE - a
key = self.nodes[a]
if key[0] == "not":
return key[1]
return self._make(("not", a))
def conj(self, a: int, b: int) -> int:
if a == FALSE or b == FALSE:
return FALSE
if a == TRUE:
return b
if b == TRUE or a == b:
return a
return self._make(("and", min(a, b), max(a, b)))
def disj(self, a: int, b: int) -> int:
if a == TRUE or b == TRUE:
return TRUE
if a == FALSE:
return b
if b == FALSE or a == b:
return a
return self._make(("or", min(a, b), max(a, b)))
def evaluate(self, root: int, state: dict[str, bool]) -> bool:
memo: dict[int, bool] = {}
def ev(u: int) -> bool:
if u in memo:
return memo[u]
key = self.nodes[u]
if key[0] == "const":
r = key[1]
elif key[0] == "fluent":
r = state[key[1]]
elif key[0] == "not":
r = not ev(key[1])
elif key[0] == "and":
r = ev(key[1]) and ev(key[2])
else:
r = ev(key[1]) or ev(key[2])
memo[u] = r
return r
return ev(root)
def dag_size(self, root: int) -> int:
"""The number of distinct nodes below the root."""
seen = set()
stack = [root]
while stack:
u = stack.pop()
if u in seen:
continue
seen.add(u)
key = self.nodes[u]
if key[0] in ("not", "and", "or"):
stack.extend(key[1:])
return len(seen)
def tree_size(self, root: int) -> int:
"""The number of nodes of the formula written out as a tree, with no sharing."""
memo: dict[int, int] = {}
def ts(u: int) -> int:
if u in memo:
return memo[u]
key = self.nodes[u]
r = 1 + sum(ts(c) for c in key[1:]) if key[0] in ("not", "and", "or") else 1
memo[u] = r
return r
return ts(root)
def show(self, root: int) -> str:
key = self.nodes[root]
if key[0] == "const":
return "true" if key[1] else "false"
if key[0] == "fluent":
return key[1]
if key[0] == "not":
return "not " + self.show(key[1])
return "(" + self.show(key[1]) + " " + key[0] + " " + self.show(key[2]) + ")"
class Action:
"""A ground action: a precondition and, per fluent, the formulas gamma_plus and gamma_minus."""
def __init__(self, name: str, poss: int, plus: dict[str, int], minus: dict[str, int]) -> None:
self.name = name
self.poss = poss
self.plus = plus
self.minus = minus
class BasicActionTheory:
"""Fluents, actions with successor state axioms, and an initial database D_S0.
D_S0 is a list of formulas over the fluents. It may leave some fluents
unknown, so the initial situation can have many models.
"""
def __init__(self, f: Formulas, fluents: list[str], actions: dict[str, Action], initial: list[int]) -> None:
self.f = f
self.fluents = fluents
self.actions = actions
self.initial = initial
# Phi[a][F] is the right side of the successor state axiom of F for a.
self.phi: dict[str, dict[str, int]] = {}
for a in actions.values():
row = {}
for name in fluents:
gp = a.plus.get(name, FALSE)
gm = a.minus.get(name, FALSE)
row[name] = f.disj(gp, f.conj(f.fluent(name), f.neg(gm)))
self.phi[a.name] = row
# ------------------------------------------------------------ regression
def regress_step(self, phi: int, action: str) -> int:
"""R_a(phi): replace each fluent F of phi by Phi_{F,a}; the result is about the earlier situation."""
f = self.f
row = self.phi[action]
memo: dict[int, int] = {} # @line L2
def r(u: int) -> int:
if u in memo: # @line L5
return memo[u]
key = f.nodes[u]
if key[0] == "const": # @line L6
out = u
elif key[0] == "fluent": # @line L7
out = row[key[1]]
elif key[0] == "not": # @line L8
out = f.neg(r(key[1]))
else: # @line L9
make = f.conj if key[0] == "and" else f.disj
out = make(r(key[1]), r(key[2]))
memo[u] = out # @line L10
return out
return r(phi)
def regress(self, phi: int, actions: list[str]) -> int:
"""R[phi(do([a1, ..., an], S0))]: a formula about S0 with the same truth value."""
for a in reversed(actions): # @line L1
phi = self.regress_step(phi, a) # @line L3
return phi # @line L4
def executable_formula(self, actions: list[str]) -> int:
"""The regression of: each a_i is possible in the situation reached by a_1 to a_{i-1}.
One backward pass: chi_n = true and chi_{i-1} = pi_{a_i} and R_{a_i}(chi_i), so chi_0
is the conjunction of each precondition regressed through the actions before it.
"""
f = self.f
chi = TRUE # @line L11
for a in reversed(actions): # @line L12
chi = f.conj(self.actions[a].poss, self.regress_step(chi, a)) # @line L13
return chi # @line L14
def entails_initially(self, phi: int) -> bool:
"""Does D_S0 entail phi? Brute force over the assignments to the fluents."""
for state in self.initial_models():
if not self.f.evaluate(phi, state):
return False
return True
def initial_models(self):
for bits in itertools.product([False, True], repeat=len(self.fluents)):
state = dict(zip(self.fluents, bits))
if all(self.f.evaluate(g, state) for g in self.initial):
yield state
def project_by_regression(self, phi: int, actions: list[str]) -> bool:
"""Is phi true in do(actions, S0) in every model of the theory?"""
return self.entails_initially(self.regress(phi, actions)) # @line L15
def executable_by_regression(self, actions: list[str]) -> bool:
return self.entails_initially(self.executable_formula(actions))
# ------------------------------------------------- progression (reference)
def step(self, state: dict[str, bool], action: str) -> dict[str, bool]:
"""The successor state, by evaluating each successor state axiom at the current state."""
row = self.phi[action]
return {name: self.f.evaluate(row[name], state) for name in self.fluents}
def project_by_simulation(self, phi: int, actions: list[str]) -> bool:
for state in self.initial_models():
for a in actions:
state = self.step(state, a)
if not self.f.evaluate(phi, state):
return False
return True
def executable_by_simulation(self, actions: list[str]) -> bool:
for state in self.initial_models():
for a in actions:
if not self.f.evaluate(self.actions[a].poss, state):
return False
state = self.step(state, a)
return True
def yale_shooting(initial_alive_only: bool = True) -> tuple[BasicActionTheory, Formulas]:
"""The Yale shooting domain: fluents loaded and alive; actions load, wait and shoot."""
f = Formulas()
loaded, alive = f.fluent("loaded"), f.fluent("alive")
actions = {
"load": Action("load", f.neg(loaded), {"loaded": TRUE}, {}),
"wait": Action("wait", TRUE, {}, {}),
"shoot": Action("shoot", TRUE, {}, {"alive": loaded, "loaded": TRUE}),
}
initial = [alive] if initial_alive_only else [alive, f.neg(loaded)]
return BasicActionTheory(f, ["loaded", "alive"], actions, initial), f
test_situation_calculus_regression.py 130 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/situation-calculus-regression/. The authors are listed in prov/A4NKPR.jsonl.
"""Regression against progression by simulation, on random ground domains."""
import itertools
import random
from situation_calculus_regression import (
FALSE,
TRUE,
Action,
BasicActionTheory,
Formulas,
yale_shooting,
)
def random_formula(f: Formulas, rng: random.Random, fluents, depth: int) -> int:
if depth == 0 or rng.random() < 0.3:
r = rng.random()
if r < 0.08:
return TRUE
if r < 0.16:
return FALSE
return f.fluent(rng.choice(fluents))
op = rng.choice(["not", "and", "or"])
if op == "not":
return f.neg(random_formula(f, rng, fluents, depth - 1))
a = random_formula(f, rng, fluents, depth - 1)
b = random_formula(f, rng, fluents, depth - 1)
return f.conj(a, b) if op == "and" else f.disj(a, b)
def random_theory(rng: random.Random) -> BasicActionTheory:
f = Formulas()
k = rng.randint(1, 6)
fluents = ["F%d" % i for i in range(k)]
actions = {}
for j in range(rng.randint(1, 4)):
name = "a%d" % j
poss = TRUE if rng.random() < 0.5 else random_formula(f, rng, fluents, 2)
plus, minus = {}, {}
for fl in fluents:
if rng.random() < 0.5:
plus[fl] = random_formula(f, rng, fluents, 2)
if rng.random() < 0.5:
minus[fl] = random_formula(f, rng, fluents, 2)
actions[name] = Action(name, poss, plus, minus)
initial = [random_formula(f, rng, fluents, 2) for _ in range(rng.randint(0, 3))]
return BasicActionTheory(f, fluents, actions, initial)
def all_states(fluents):
for bits in itertools.product([False, True], repeat=len(fluents)):
yield dict(zip(fluents, bits))
def test_regression_agrees_with_progression_on_every_state():
"""For every initial state s, R[phi] holds at s iff phi holds after simulating the actions from s."""
rng = random.Random(1)
for _ in range(300):
bat = random_theory(rng)
names = sorted(bat.actions)
seq = [rng.choice(names) for _ in range(rng.randint(0, 8))]
phi = random_formula(bat.f, rng, bat.fluents, 3)
reg = bat.regress(phi, seq)
for s in all_states(bat.fluents):
t = dict(s)
for a in seq:
t = bat.step(t, a)
assert bat.f.evaluate(reg, s) == bat.f.evaluate(phi, t)
def test_projection_and_executability_match_simulation():
rng = random.Random(2)
for _ in range(400):
bat = random_theory(rng)
names = sorted(bat.actions)
seq = [rng.choice(names) for _ in range(rng.randint(0, 8))]
phi = random_formula(bat.f, rng, bat.fluents, 3)
assert bat.project_by_regression(phi, seq) == bat.project_by_simulation(phi, seq)
assert bat.executable_by_regression(seq) == bat.executable_by_simulation(seq)
def test_regressed_dag_grows_linearly():
"""dag_size(R[phi]) <= dag_size(phi) + sum over the steps of the sizes of the successor state formulas."""
rng = random.Random(3)
for _ in range(100):
bat = random_theory(rng)
names = sorted(bat.actions)
seq = [rng.choice(names) for _ in range(rng.randint(0, 12))]
phi = random_formula(bat.f, rng, bat.fluents, 3)
bound = bat.f.dag_size(phi)
for a in seq:
bound += sum(bat.f.dag_size(bat.phi[a][fl]) for fl in bat.fluents)
assert bat.f.dag_size(bat.regress(phi, seq)) <= bound
def test_tree_blows_up_but_dag_does_not():
"""An action that sets p to (p iff q) doubles the tree at each step, while the DAG grows by a constant."""
f = Formulas()
p, q = f.fluent("p"), f.fluent("q")
same = f.disj(f.conj(p, q), f.conj(f.neg(p), f.neg(q)))
# p(do(a, s)) <-> gamma_plus or (p and not gamma_minus), with gamma_plus = not p and not q, gamma_minus = not q.
act = Action("a", TRUE, {"p": f.conj(f.neg(p), f.neg(q))}, {"p": f.neg(q)})
bat = BasicActionTheory(f, ["p", "q"], {"a": act}, [])
for s in all_states(["p", "q"]):
assert bat.step(s, "a")["p"] == f.evaluate(same, s)
trees, dags = [], []
for n in range(1, 9):
r = bat.regress(p, ["a"] * n)
trees.append(f.tree_size(r))
dags.append(f.dag_size(r))
assert all(trees[i + 1] > 2 * trees[i] for i in range(len(trees) - 1))
assert all(dags[i + 1] - dags[i] <= f.dag_size(bat.phi["a"]["p"]) for i in range(len(dags) - 1))
def test_yale_shooting():
bat, f = yale_shooting(initial_alive_only=True)
alive, loaded = f.fluent("alive"), f.fluent("loaded")
assert bat.regress(f.neg(alive), ["load", "wait", "shoot"]) == TRUE
assert bat.regress(alive, ["wait", "shoot"]) == f.conj(alive, f.neg(loaded))
assert not bat.project_by_regression(alive, ["wait", "shoot"])
assert bat.executable_formula(["load", "wait", "shoot"]) == f.neg(loaded)
assert not bat.executable_by_regression(["load", "wait", "shoot"])
bat2, f2 = yale_shooting(initial_alive_only=False)
assert bat2.project_by_regression(f2.fluent("alive"), ["wait", "shoot"])
assert bat2.project_by_regression(f2.neg(f2.fluent("alive")), ["load", "wait", "shoot"])
assert bat2.executable_by_regression(["load", "wait", "shoot"])
assert not bat2.executable_by_regression(["load", "load"])
History
Reiter (1991) gave successor state axioms, built from effect axioms and the causal completeness assumption, and proved that goal regression with them is complete. Pirri and Reiter (1999) gave the metatheory of basic action theories, including the regression theorem and the result that such a theory is satisfiable if and only if its initial database together with the unique names axioms is satisfiable. Lin and Reiter (1997) studied progression as the alternative. Reiter (2001) collected the theory, an implementation in Prolog and the extension to knowledge.
References
- Raymond Reiter, Knowledge in Action, Logical Foundations for Specifying and Implementing Dynamical Systems, MIT Press, 2001, Chapter 4, Section 4.4 (basic action theories), Section 4.5 (regression, the regression operator and the regression theorem), Section 4.6 (using regression for executability and projection); Section 11.6 (regression with knowledge-producing actions)
- Fiora Pirri and Raymond Reiter, Some contributions to the metatheory of the situation calculus, Journal of the ACM 46(3), 1999, pages 325 to 361 (basic action theories, relative satisfiability, regressable formulas and the soundness and completeness of regression)
- Raymond Reiter, The frame problem in the situation calculus: A simple solution (sometimes) and a completeness result for goal regression, in V. Lifschitz (editor), Artificial Intelligence and Mathematical Theory of Computation, Academic Press, 1991, pages 359 to 380 (successor state axioms and the completeness of goal regression)
- Fangzhen Lin and Raymond Reiter, How to progress a database, Artificial Intelligence 92(1-2), 1997, pages 131 to 167 (progression as the alternative to regression, and the result that progression is not always first-order definable; general locator)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag A4NKPR Edit this page History Report an error Markdown