I slightly learn Prolog for the design of ATS3.
My opinion is following:

## Variable is useful

```
$ cat family.pl
father(naoyuki, hyogo).
father(saburo, naoyuki).
father(saburo, shinji).
father(yoshihisa, hisako).
mother(hisako, hyogo).
mother(yoko, naoyuki).
mother(yoko, shinji).
mother(nobuko, hisako).
$ swipl
?- [family].
true.

?- father(F, hyogo), father(G, F).
F = naoyuki,
G = saburo.
```

Does ATS2 have such variable to prove something already?

## `spy` is useful

```
$ cat fact.pl
fact(0, 1).
fact(N, F) :-
    N > 0,
    N1 is N-1,
    fact(N1, F1),
    F is N*F1.
$ swipl
?- [fact].
true.

?- spy(fact).
% Spy point on fact/2
true.

[debug]  ?- fact(10,F).
 * Call: (8) fact(10, _828) ? creep
   Call: (9) 10>0 ? creep
   Exit: (9) 10>0 ? creep
   Call: (9) _1052 is 10+ -1 ? creep
   Exit: (9) 9 is 10+ -1 ? creep
 * Call: (9) fact(9, _1054) ? creep
   Call: (10) 9>0 ? creep
   Exit: (10) 9>0 ? creep
   Call: (10) _1058 is 9+ -1 ? creep
   Exit: (10) 8 is 9+ -1 ? creep
 * Call: (10) fact(8, _1060) ? creep
   Call: (11) 8>0 ? creep
   Exit: (11) 8>0 ? creep
   Call: (11) _1064 is 8+ -1 ? creep
   Exit: (11) 7 is 8+ -1 ? EOF: exit
```

There will be some debugger for proof things of ATS3?
Or symbolic execution such like https://github.com/verifast/verifast
is also useful.

## Compressed description of specification

```
$ cat nat.pl
nat(0).
nat(s(X)) :- nat(X).

plus(0, Y, Y).
plus(s(X), Y, s(Z)) :- plus(X, Y, Z).

le(X, Y) :- plus(X, _, Y).

lt(X, Y) :- le(s(X), Y).

quot(X, Y, 0, X) :- lt(X, Y).
quot(X, Y, s(Q), R) :- plus(Y, X1, X), quot(X1, Y, Q, R).

dnd(M, N) :- quot(N, M, _, s(_)).

df(s(0), _).
df(s(s(M)), N) :- dnd(s(s(M)), N), df(s(M), N).

prime(s(X)) :- df(X, s(X)).
$ swipl
?- [nat].
true.

?- nat(N), prime(N).
N = s(s(0))
```

`nat(N), prime(N).` is very smart description of specification.

Regards,

-- 
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-users+unsubscr...@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/CAEvX6d%3DaVgLUShkPKeZM0BffJr_VnafA6PMHwtXd8vnKHL1sbg%40mail.gmail.com.

Reply via email to