• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Apr 18th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. domains
2.
3. faculty_name, second_name, name, subject = symbol
4. spec_code, group_number, mark, military_department = real
5. group=group(faculty_name, spec_code, group_number, list_composition)
6. list_composition=composition*
7. composition=composition(second_name, name, military_department, list_vedomost)
8. list_vedomost=vedomost*
9. vedomost=vedomost(subject, mark)
10.
11. facts
12. average_mark(real,real)
13. min_students(group_number, real)
14. dq3(group_number,subject)
15. dq4(group_number, spec_code)
16. dq5(faculty_name, group_number)
17.
18. predicates
19. nondeterm groups(group)
20. q1(group_number)
21. q11(real, list_composition, real, real, real)
22. q12(real,list_vedomost,real,real,real)
23. q2
24. q21(list_composition, real)
25. nondeterm q3(real)
26. nondeterm q31(real,list_composition)
27. nondeterm q32(real,list_vedomost)
28. q4(group_number)
29. q5(faculty_name)
30.
31.
32.
33. clauses
34. groups(group("faculty name1",6,6102,[composition("Mike","Gordon",1, [vedomost("Phys", 5), vedomost("Math", 3), vedomost("Lang", 4)]),
35. composition("Sam", "Jackson", 0, [vedomost("SII", 3), vedomost("Religion", 2)])])).
36. groups(group("faculty name1",2,6208,[composition("Sally","Smith",0, [vedomost("Eloctronic", 4), vedomost("Mech", 5)]),
37. composition("Jack", "Lowson", 0, [vedomost("Program", 2), vedomost("Math", 3), vedomost("Eng", 5)])])).
38. groups(group("faculty name2",4,6311,[composition("Andy","White",1, [vedomost("History", 5)])])).
39.
40. average_mark(0,0).
41. q1(N):-
42. groups(group(_,_,N,L)),
43. q11(N,L,0,C,0),
44. average_mark(E,R),
45. C>R,
46. retract(average_mark(E,R)),
47. assert(average_mark(N,C)),fail.
48.
49. q11(_,[],Z1,Z,G):-Z=Z1/G.
50. q11(A1,[H|T],Y,W,Q):-H=composition(_,_,_,U),q12(A1,U,0,V,0),Y1=Y+V, Q1=Q+1, q11(A1,T,Y1,W,Q1).
51. q12(_,[],D1,D,P):-D=D1/P.
52. q12(F,[H1|T1],D1,D2,P1):-H1= vedomost(_,Z), D3=D1+Z, P3=P1+1,
53. q12(F,T1,D3,D2,P3).
54.
55. min_students(6102,23321456).
56. q2:-
57. groups(group(_,_,GN,L)),
58. min_students(Q,M),
59. q21(L,N),
60. N<M,
61. retract(min_students(Q,M)),
62. assert(min_students(GN,N)), fail.
63. q21([_|T],N):-q21(T,N1),N=N1+1.
64. q21([],0).
65.
66.
67. %q3(K):-groups(group(_,_,K,L)), q31(L).
68. %q31([]).
69. %q31([H|T]):-H=composition(_,_,_,V),q32(V),q31(T).
70. %q32([]).
71. %q32([H1|T1]):-H1=vedomost(S,_), write(S),nl, q32(T1).
72.
73. q3(GN):- dq3(GN,S),write('#',S), nl,fail.
74. q3(GN):- not(dq3(GN,_)),groups(group(_,_,GN,L)), q31(GN,L), fail.
75. q31(GN,[H|T]):-H=composition(_,_,_,L1), q32(GN,L1), q31(GN,T).
76. q31(_,[]).
77. q32(GN,[H1|T1]):-H1=vedomost(S,_), assert(dq3(GN,S)), write(S), nl,q32(GN,T1).
78. q32(_,[]).
79.
80. q4(G):-groups(group(_,C,G,_)), write(C), nl, fail.%ñòàòè÷åñêèé
81.
82. q4(G):-dq4(G,A), write(G," ",A), nl, fail.%äèíàìè÷åñêèé
83. q4(G):- not(dq4(G,_)), groups(group(_,C,G,_)), write(C), nl, assert(dq4(G,C)), fail.
84.
85.
86. q5(K):-groups(group(K,_,A,_)), write(A), nl, fail.%ñòàòè÷åñêèé
87.
88. q5(K):-dq5(K,N), write(K," ",N), nl, fail.%äèíàìè÷åñêèé
89. q5(K):-not(dq5(K,_)), groups(group(K,_,N,_)), write(N), nl, assert(dq5(K,N)), fail.
90.
91.
92.
93. goal
94. %q1(6311); average_mark(N,C).
95. %q2; min_students(A,B).
96. %q3(6208).
97. q3(6208);q3(6208).
98. %q4(6311); q4(6311).
99. %write("Code:"), nl,q4(6311).
100. %write("Groups:"),nl,q5("faculty name1").
101. %q5("faculty name1");q5("faculty name1").
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?