[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: List of possible algebraic transformations
> Juergen Zimmermann
>
> Here the list:
> - integer types
>
> a + 0 = a
> 0 + a = a
> a - 0 = a
> 0 - a = a
I think this should be 0 - a = -a
>
> --a = a
> - real types
>
> a + 0.0 = a
> 0.0 + a = a
> a - 0.0 = a
> 0.0 - a = a
Same problem, should be 0.0 - a = -a
> --a = a
>
> a * 1.0 = a
> 1.0 * a = a
> a * (-1.0) = -a
> (-1.0) * a = -a
>
> a * 0.0 = 0
> 0.0 * a = 0
>
> a / 1.0 = a
> a / (-1.0) = -a
Would a / 1 = a where a is a REAL? ie., are expression type conversions
part of the optimizations?
> - boolean types
>
> a & a = a
> a OR a = a
You could add:
a & ~a = ~a & a = FALSE
a OR ~a = ~a OR a = TRUE
> ~~a = a
>
> a & TRUE = a
> TRUE & a = a
> FALSE & a = FALSE
>
> a OR FALSE = a
> FALSE OR a = a
> TRUE OR a = TRUE
I assume you would also support the equivalent reductions
for when a is replaced by ~a? i.e., ~a & TRUE = ~a, etc.
> - set types
>
> a - a = {}
> a + a = a
> a * a = a
> a / a = {}
>
> a - {} = a
> a + {} = a
> a * {} = a
Should be: a * {} = {}
> a / {} = ?
I believe: a / {} = a
> {} - a = ?
Should be: {} - a = {}
> {} + a = a
> {} * a = {}
> {} / a = ?
Should be: {} / a = a
You may wish to add the following:
Let F = ~{}
F + a = a + F = F
F - a = ~a
a - F = {}
F * a = a * F = a
F / a = a / F = ~a
As well, consider the replacement of a with ~a.
>
> -string types
>
> str = "" -> str[0] = 0X
> str # "" -> str[0] # 0X
> str >= "" -> TRUE
> str < "" -> FALSE
> "" <= str -> TRUE
> "" > str -> FALSE
>
> str ( < | > | # ) str -> FALSE
> str ( <= | >= | = ) str -> TRUE
Michael G.