//
extern
praxi
fib_bas0(): [fib(0)==0] unit_p
extern
praxi
fib_bas1(): [fib(1)==1] unit_p
extern
praxi
fib_ind2{n:int | n >= 2}(): [fib(n)==fib(n-1)+fib(n-2)] unit_p
//
(* ****** ****** *)
fun
fib
{n:nat} .<>.
(
n: int(n)
) : int(fib(n)) = let
//
val () = $solver_assert(fib_bas0)
val () = $solver_assert(fib_bas1)
val () = $solver_assert(fib_ind2)
//
fun
loop
{i:nat|i <= n} .<n-i>.
(
ni: int(n-i)
, f0: int(fib(i)), f1: int(fib(i+1))
) : int(fib(n)) = (
//
if
ni >= 2
then (
loop{i+1}(ni-1, f1, f0+f1)
) (* end of [then] *)
else (
if ni >= 1 then f1 else f0
) (* end of [else] *)
//
) (* end of [loop] *)
//
in
loop{0}(n, 0, 1)
end // end of [fib]
(* ****** ****** *)
prval () = fib_ind2{i+2}()
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/d982f806-709f-430b-aa88-9db5938af633%40googlegroups.com.
It is about the potential. Quantifier-free constraints and quantified constraints
are totally different beasts in terms of constraint-solving.
The built-in constraint-solver of ATS cannot handle constraints introduced via $solver_assert.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAORbNRr9oS%2BkpXcVpWhHLrpFTDso_vPc-Thi-snq-m8A6%3Dkctw%40mail.gmail.com.
I agree that's cause for celebration; even if it is only one line removed (actually I noticed another prval line is dropped too, if trivial), I feel more than half the battle with ATS for me, now, is recognizing when a constraint issue arises because the solver cannot solve the constraint because either 1) it is not possible in the solver or 2) it is not possible mathematically. The former could be thought of as a "soft programmer error" and the latter is a "hard programmer error", or traditional error in programming logic. So anything that reduces the occurrence of 1) is nice.
I agree that's cause for celebration; even if it is only one line removed (actually I noticed another prval line is dropped too, if trivial), I feel more than half the battle with ATS for me, now, is recognizing when a constraint issue arises because the solver cannot solve the constraint because either 1) it is not possible in the solver or 2) it is not possible mathematically. The former could be thought of as a "soft programmer error" and the latter is a "hard programmer error", or traditional error in programming logic. So anything that reduces the occurrence of 1) is nice.Does $solver_assert work with the original ATS constraint solver as well?
There are several issues. What happens if the solver assert returns "unknown"?
It would seem sane to (a) issue a warning and (b) assume the assertion
is correct anyhow.