Recursively try to match the remaining points given current mapping.
(
clause_enum: list[tuple[pr.Clause, list[tuple[gm.Point, ...]]]],
mapping: dict[str, gm.Point],
)
| 825 | |
| 826 | |
| 827 | def try_to_map( |
| 828 | clause_enum: list[tuple[pr.Clause, list[tuple[gm.Point, ...]]]], |
| 829 | mapping: dict[str, gm.Point], |
| 830 | ) -> Generator[dict[str, gm.Point], None, None]: |
| 831 | """Recursively try to match the remaining points given current mapping.""" |
| 832 | if not clause_enum: |
| 833 | yield mapping |
| 834 | return |
| 835 | |
| 836 | clause, enum = clause_enum[0] |
| 837 | for points in enum: |
| 838 | mpcpy = dict(mapping) |
| 839 | |
| 840 | fail = False |
| 841 | for p, a in zip(points, clause.args): |
| 842 | if a in mpcpy and mpcpy[a] != p or p in mpcpy and mpcpy[p] != a: |
| 843 | fail = True |
| 844 | break |
| 845 | mpcpy[a] = p |
| 846 | mpcpy[p] = a |
| 847 | |
| 848 | if fail: |
| 849 | continue |
| 850 | |
| 851 | for m in try_to_map(clause_enum[1:], mpcpy): |
| 852 | yield m |
| 853 | |
| 854 | |
| 855 | def match_generic( |