feat: Sibling coupling information
This commit is contained in:
parent
da6f8f9b5b
commit
3f77bc453f
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Data structuers for expressions and goals
|
Data structuers for expressions and goals
|
||||||
"""
|
"""
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass, field
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
Expr = str
|
Expr = str
|
||||||
|
@ -35,6 +35,7 @@ class Variable:
|
||||||
class Goal:
|
class Goal:
|
||||||
variables: list[Variable]
|
variables: list[Variable]
|
||||||
target: Expr
|
target: Expr
|
||||||
|
sibling_dep: list[int] = field(default_factory=lambda: [])
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
is_conversion: bool = False
|
is_conversion: bool = False
|
||||||
|
|
||||||
|
@ -43,12 +44,16 @@ class Goal:
|
||||||
return Goal(variables=[], target=target)
|
return Goal(variables=[], target=target)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(payload: dict):
|
def parse(payload: dict, sibling_map: dict[str, int]):
|
||||||
name = payload.get("userName")
|
name = payload.get("userName")
|
||||||
variables = [Variable.parse(v) for v in payload["vars"]]
|
variables = [Variable.parse(v) for v in payload["vars"]]
|
||||||
target = parse_expr(payload["target"])
|
target = parse_expr(payload["target"])
|
||||||
is_conversion = payload["isConversion"]
|
is_conversion = payload["isConversion"]
|
||||||
return Goal(variables, target, name, is_conversion)
|
|
||||||
|
dependents = payload["target"]["dependentMVars"]
|
||||||
|
sibling_dep = [sibling_map[d] for d in dependents if d in sibling_map]
|
||||||
|
|
||||||
|
return Goal(variables, target, sibling_dep, name, is_conversion)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
front = "|" if self.is_conversion else "⊢"
|
front = "|" if self.is_conversion else "⊢"
|
||||||
|
@ -75,7 +80,8 @@ class GoalState:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(payload: dict, _sentinel: list[int]):
|
def parse(payload: dict, _sentinel: list[int]):
|
||||||
state_id = payload["nextStateId"]
|
state_id = payload["nextStateId"]
|
||||||
goals = [Goal.parse(g) for g in payload["goals"]]
|
goal_names = { g["name"]: i for i,g in enumerate(payload["goals"]) }
|
||||||
|
goals = [Goal.parse(g, goal_names) for g in payload["goals"]]
|
||||||
return GoalState(state_id, goals, _sentinel)
|
return GoalState(state_id, goals, _sentinel)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -60,6 +60,8 @@ class Server:
|
||||||
)
|
)
|
||||||
self.proc.setecho(False)
|
self.proc.setecho(False)
|
||||||
|
|
||||||
|
self.run('options.set', {'printDependentMVars': True})
|
||||||
|
|
||||||
def run(self, cmd, payload):
|
def run(self, cmd, payload):
|
||||||
"""
|
"""
|
||||||
Runs a raw JSON command. Preferably use one of the commands below.
|
Runs a raw JSON command. Preferably use one of the commands below.
|
||||||
|
|
Loading…
Reference in New Issue