Commit e6553e0d by Hemery Mathieu

### Add is_null/1 to arithmetic_rules and use it to improve strictness test

parent e21a7757
 ... ... @@ -6,7 +6,8 @@ additive_normal_form/2, always_negative/1, always_positive/1, normalize_number/2 normalize_number/2, is_null/1 ]). % Insert here for separate compilation and linting ... ... @@ -767,3 +768,23 @@ normalize_number(N, Norm) :- ; Norm = N ). %! is_null(+Expr) % % Check if an expression is uniformly null is_null(Expr) :- once(is_null_sr(Expr)). is_null_sr(0). is_null_sr(0.0). is_null_sr(A*B) :- is_null_sr(A); is_null_sr(B). is_null_sr(A/_B) :- is_null_sr(A). is_null_sr(A+B) :- is_null_sr(A), is_null_sr(B). is_null_sr(A-B) :- is_null_sr(A), is_null_sr(B). is_null_sr(_A^(-_N)) :- !, false. is_null_sr(A^_N) :- is_null_sr(A).
 ... ... @@ -5,4 +5,8 @@ test('distribute', [true(Out == a * a + a * b + c)]) :- distribute(a * (a + b) + c, Out). test('is_null', []) :- is_null(a*0*1/2), \+(is_null(a*b/0)). :- end_tests(arithmetic_rules).
 ... ... @@ -695,13 +695,6 @@ binomial_bounded_search(First_Var, Varlist, Currentlist, Sumlist, PODE, Bound, R % clean_writing(1*input, input). % clean_writing(input^2*0, 0). is_null(Zero) :- catch( Zero =:= 0, error(_A,_B), fail ). is_one(One) :- catch( One =:= 1, ... ...
 ... ... @@ -1324,7 +1324,7 @@ test_wf_inhibitor(Molecule, Expression) :- test_strictness(Molecule, Expression) :- substitute([Molecule], [0], Expression, Output), ( simplify(Output+0, 0) is_null(Output) ; format("Due to: ~w while checking ~w;~n", [Expression, Molecule]), fail ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!