MCPcopy Index your code
hub / github.com/google-deepmind/alphageometry / Dependency

Class Dependency

problem.py:676–1056  ·  view source on GitHub ↗

Dependency is a predicate that other predicates depend on.

Source from the content-addressed store, hash-verified

674
675
676class Dependency(Construction):
677 """Dependency is a predicate that other predicates depend on."""
678
679 def __init__(
680 self, name: str, args: list[gm.Point], rule_name: str, level: int
681 ):
682 super().__init__(name, args)
683 self.rule_name = rule_name or ''
684 self.level = level
685 self.why = []
686
687 self._stat = None
688 self.trace = None
689
690 def _find(self, dep_hashed: tuple[str, ...]) -> Dependency:
691 for w in self.why:
692 f = w._find(dep_hashed)
693 if f:
694 return f
695 if w.hashed() == dep_hashed:
696 return w
697
698 def remove_loop(self) -> Dependency:
699 f = self._find(self.hashed())
700 if f:
701 return f
702 return self
703
704 def copy(self) -> Dependency:
705 dep = Dependency(self.name, self.args, self.rule_name, self.level)
706 dep.trace = self.trace
707 dep.why = list(self.why)
708 return dep
709
710 def why_me_or_cache(self, g: Any, level: int) -> Dependency:
711 if self.hashed() in g.cache:
712 return g.cache[self.hashed()]
713 self.why_me(g, level)
714 return self
715
716 def populate(self, name: str, args: list[gm.Point]) -> Dependency:
717 assert self.rule_name == CONSTRUCTION_RULE, self.rule_name
718 dep = Dependency(self.name, self.args, self.rule_name, self.level)
719 dep.why = list(self.why)
720 return dep
721
722 def why_me(self, g: Any, level: int) -> None:
723 """Figure out the dependencies predicates of self."""
724 name, args = self.name, self.args
725
726 hashed_me = hashed(name, args)
727 if hashed_me in g.cache:
728 dep = g.cache[hashed_me]
729 self.why = dep.why
730 self.rule_name = dep.rule_name
731 return
732
733 if self.name == 'para':

Callers 15

coll_depMethod · 0.90
cyclic_depMethod · 0.90
make_equal_pairsMethod · 0.90
add_s_angleMethod · 0.90
add_clauseMethod · 0.90
get_proof_stepsFunction · 0.90
bfs_one_levelFunction · 0.90
why_eqratioFunction · 0.85
why_eqangleFunction · 0.85
populateMethod · 0.85
extendMethod · 0.85
extend_manyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected