Print valid arithmetic expressions
Jelly, ... 33 bytes

⁾()j
p`j”+Ç$€;;”-;ÇƊ€;®‘©¤Ṅ€
WÇ1¿


Try it online!

Wow, writing a correct submission is hard.



Python pseudocode equivalent:

import itertools

# Jelly: ⁾()j
def wrap_in_parentheses(x):
 return str(x).join(['(',')'])
 # or equivalently, `return '('+str(x)+')'

# Jelly: p`j”+Ç$€;;”-;ÇƊ€;®‘©¤Ṅ€
register = 0
def expand_and_print(expressions):
 # Jelly: p`
 result = list(itertools.product(expressions, repeat=2))

 # Jelly: j”+Ç$€
 result = [wrap_in_parentheses('+'.join(expr)) for expr in result]

 # Jelly: ;
 result.extend(expressions)

 # Jelly: ;”-;ÇƊ€
 result.extend([wrap_in_parentheses('-'+expr) for expr in expression])

 # Jelly: ;®‘©¤
 global register
 register += 1
 result.append(register)

 # Jelly: Ṅ€
 for expr in result:
  print(expr)

 return result

# Jelly: WÇ1¿
expressions = ['0']
while 1:
 expressions = expand_and_print(expressions)