Macaulay2 / Macaulay2/M2

Wishlist: Make Expressions work with inequalities

Open
#1,754 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Core
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

> > I see no reason to introduce scads of new functions, such as `assertEqual`, when you can write something like `assert (hold 4 == 5)` or `assert (hold 4 > 5)`.
>
> The latter doesn't work:
>
> ```m2
> i6 : hold 4 > 5
> stdio:6:8:(3): error: no method for binary operator ? applied to objects:
> -- 4 (of class Holder)
> -- ? 5 (of class ZZ)
> ```
>

Right, we'd have to make it work. Actually, we'd have to install method lookup in the d directory first, because the code for `x>y` always just runs `x?y` to see what the answer is. If we did that, then this would work:
```m2
Thing > Expression := Expression > Thing := (x,y) -> BinaryOperation {symbol >, x, y}
```

> How does `hold` know where the expression stops?

In `hold x == y`, we're comparing `hold x` to `y`. But there is a method for doing that:
```m2

i5 : code lookup (symbol ==, Expression, Thing)

o5 = ../../../../../../Macaulay2/m2/expressions.m2:490:45-490:64: --source code:
installMethod(op,Expression,Thing,(x,y) -> g(x,expression y));
| symbol class value location of symbol
| ------ ----- ----- ------------------
| f : FunctionClosure -- ... ../../../../../../Macaulay2/m2/expressions.m2:485:5-485:6
| g : FunctionClosure -- ... ../../../../../../Macaulay2/m2/expressions.m2:489:5-489:6
| op : Keyword -- == ../../../../../../Macaulay2/m2/expressions.m2:484:33-484:35
```

_Originally posted by @DanGrayson in https://github.com/Macaulay2/M2/issues/1738#issuecomment-751016854_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the expression handling in expressions.m2 and the method lookup in the d directory mentioned in the issue. Trace how held expressions handle ==, then determine what is needed for inequalities such as >; done means the shown held inequality produces the intended expression and method lookup works.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.