how to evaluate/simplify a term contain if-then-else's?
Subject: how to evaluate/simplify a term contain if-then-else's?
From: Oliver Kullmann
Date: Tue, 13 Apr 2010 15:55:28 +0100
Hello,
I have the following function
exactf_tau_arithprog(k,n) :=
if n < k then 0
elseif k=1 then n
elseif k=2 then n-1
elseif n <= 2*k-1 and evenp(k) then
if n = 2*k-1 then 2 else 1
elseif n <= 2*k and oddp(k) then
if n = 2*k then 2 else 1
else unknown$
which yields
exactf_tau_arithprog(1,n);
if n < 1 then 0 elseif 1 = 1 then n elseif 1 = 2 then n-1 elseif n <= 1 and evenp(1)
then (if n = 1 then 2 else 1) elseif n <= 2 and oddp(1) then (if n = 2 then 2 else 1)
else unknown
however this should yield "if n < 1 then 0 else n" --- how to achieve this?
I've tried ev in variations, and simp, but no results.
Thanks for your help.
Oliver