parse_expr parses Python syntax. global_dict only tells it how to
handle names that are undefined, but a->b isn't valid Python syntax.
So the only way to do this would be to create a transformer function
that parses -> from the tokens and reorganizes it into an Implies
call.
This actually probably won't be that hard, because -> is already a
token recognized by the Python tokenizer (RARROW). Take a look at the
existing transformers in sympy/parsing/sympy_parser.py to see how they
work. I also recommend a site that I made for documentation on Python
tokenize in general
https://www.asmeurer.com/brown-water-python/index.html.
Aaron Meurer
On Fri, Jun 18, 2021 at 4:07 AM Paul Royik <
distan...@gmail.com> wrote:
>
> I want to parse logic implication `p->q`. What should I add to global_dict, so that parse_expr parsed it?
>
> I know, that SymPy doesn't have and Implication class. I will create it by myself, but `global_dict = {'->': Implication}` doesn't work.
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sympy+un...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/81e866b5-d1c7-4c1a-b762-1ecfc3cd22f0n%40googlegroups.com.