Skip to content

Commit 6a48311

Browse files
committed
Small fixes
1 parent cc7ea58 commit 6a48311

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

tests/scryer/cli/issues/incorrect_arithmetics.in/hoist-expr.pl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
:- use_module(library(format)).
44
:- use_module(library(reif)).
55

6+
tt :-
7+
tt(Clause),
8+
nl, portray_clause(Clause), nl.
9+
tt((f(V is Expr) :- Sequence)) :-
10+
sample("ttttffft", _ is Expr),
11+
once(phrase(ae(Expr,Repl), Removed)),
12+
append(Removed, [V is Repl], X),
13+
list_sequence(X, Sequence).
14+
15+
16+
sample(Template, R) :-
17+
setof(E, phrase(arith_relation(E), Template), Es),
18+
length(Es, L),
19+
repeat,
20+
random_integer(0, L, I),
21+
format("~n% Info: Selected ~dth out of ~d found aritmetic relations that satisfy ~s template:~n\t", [I,L,Template]),
22+
nth0(I, Es, R).
23+
624
%% Proof-of-concept arithmetic expression expander
725
%
826
% TODO: Don't use DCG's, because they aren't available in loader.pl
@@ -14,14 +32,13 @@
1432
append(Removed, [V is Repl], X),
1533
list_sequence(X, Sequence).
1634

17-
ae(A, R) --> ex(A, R).
18-
ae(F, FR) --> ey(F, A, R, FR), ae(A, R).
1935
ae(F, FR) --> ez(F, A, B, AR, BR, FR), ae(A, AR), ae(B, BR).
36+
ae(F, FR) --> ey(F, A, R, FR), ae(A, R).
37+
ae(A, R) --> ex(A, R).
2038

21-
ex([] , R ) --> [R = []].
22-
ex([H|T] , R ) --> [R = [H|T]].
23-
ex(zeta(A) , R ) --> [R = zeta(A)].
39+
ex(A , R ) --> [R = A], { nonvar(A), \+number(A), A \= e, A \= pi}.
2440
ex(A , A ) --> t, { var(A) }.
41+
ex(A , A ) --> t, { number(A) }.
2542
ex(e , e ) --> t.
2643
ex(pi , pi ) --> t.
2744

@@ -35,7 +52,7 @@
3552
ez(A/B,A,B, AR,BR,AR/BR) --> t.
3653
ez(A^B,A,B, AR,BR,AR^BR) --> t.
3754

38-
t --> [true].
55+
t --> [].
3956

4057
%% list_sequence(List, Sequence).
4158
%

0 commit comments

Comments
 (0)