Forward deduce one breadth-first level.
(
g: gh.Graph,
theorems: list[pr.Theorem],
level: int,
controller: pr.Problem,
verbose: bool = False,
nm_check: bool = False,
timeout: int = 600,
)
| 1006 | |
| 1007 | |
| 1008 | def bfs_one_level( |
| 1009 | g: gh.Graph, |
| 1010 | theorems: list[pr.Theorem], |
| 1011 | level: int, |
| 1012 | controller: pr.Problem, |
| 1013 | verbose: bool = False, |
| 1014 | nm_check: bool = False, |
| 1015 | timeout: int = 600, |
| 1016 | ) -> tuple[ |
| 1017 | list[pr.Dependency], |
| 1018 | dict[str, list[tuple[gm.Point, ...]]], |
| 1019 | dict[str, list[tuple[gm.Point, ...]]], |
| 1020 | int, |
| 1021 | ]: |
| 1022 | """Forward deduce one breadth-first level.""" |
| 1023 | |
| 1024 | # Step 1: match all theorems: |
| 1025 | theorem2mappings = match_all_theorems(g, theorems, controller.goal) |
| 1026 | |
| 1027 | # Step 2: traceback for each deduce: |
| 1028 | theorem2deps = {} |
| 1029 | t0 = time.time() |
| 1030 | for theorem, mappings in theorem2mappings.items(): |
| 1031 | if time.time() - t0 > timeout: |
| 1032 | break |
| 1033 | mp_deps = [] |
| 1034 | for mp in mappings: |
| 1035 | deps = EmptyDependency(level=level, rule_name=theorem.rule_name) |
| 1036 | fail = False # finding why deps might fail. |
| 1037 | |
| 1038 | for p in theorem.premise: |
| 1039 | p_args = [mp[a] for a in p.args] |
| 1040 | # Trivial deps. |
| 1041 | if p.name == 'cong': |
| 1042 | a, b, c, d = p_args |
| 1043 | if {a, b} == {c, d}: |
| 1044 | continue |
| 1045 | if p.name == 'para': |
| 1046 | a, b, c, d = p_args |
| 1047 | if {a, b} == {c, d}: |
| 1048 | continue |
| 1049 | |
| 1050 | if theorem.name in [ |
| 1051 | 'cong_cong_eqangle6_ncoll_contri*', |
| 1052 | 'eqratio6_eqangle6_ncoll_simtri*', |
| 1053 | ]: |
| 1054 | if p.name in ['eqangle', 'eqangle6']: # SAS or RAR |
| 1055 | b, a, b, c, y, x, y, z = ( # pylint: disable=redeclared-assigned-name,unused-variable |
| 1056 | p_args |
| 1057 | ) |
| 1058 | if not nm.same_clock(a.num, b.num, c.num, x.num, y.num, z.num): |
| 1059 | p_args = b, a, b, c, y, z, y, x |
| 1060 | |
| 1061 | dep = Dependency(p.name, p_args, rule_name='', level=level) |
| 1062 | try: |
| 1063 | dep = dep.why_me_or_cache(g, level) |
| 1064 | except: # pylint: disable=bare-except |
| 1065 | fail = True |
nothing calls this directly
no test coverage detected