-
Notifications
You must be signed in to change notification settings - Fork 2
/
ficha8_BB.pl
69 lines (53 loc) · 1.58 KB
/
ficha8_BB.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%--------------------------------- - - - - - - - - - - - - - - -
% ITELIG�NCIA ARTIFICIAL - MiEI/LEI/3
%--------------------------------- - - - - - - - - - - - - - - -
% Invariants
%--------------------------------- - - - - - - - - - - - - - - -
% PROLOG: initial definition
:- op(900,xfy,'::').
:- dynamic son/2.
:- dynamic father/2.
%--------------------------------- - - - - - - - - - - - - - - -
% Extension son:Son,Father -> {V,F,D}
son(joao,jose).
son(jose,manuel).
son(carlos,jose).
% Structural Invariant: doesn't allow duplicate knowlege addiction
+son(F,P) :: (
findall((F,P),
(son(F,P)),S),
comp(S,N),
N==1
).
% Invariante Referencial: doesn's allow more than 2 x for the same y (father/son)
+son(F,P) :: (
findall((F,P),(son(F,P),S)),
comp(S,N),
N==1
).
+son(F,_) :: (
findall(Ps,(son(F,Ps),S)),
comp(S,N),
N=<2
).
-son(F,P) :: (
findall(F,(age(F,I)),S),
comp(S,N),
N == 0
).
%--------------------------------- - - - - - - - - - - - - - - -
% Extensao do predicado que permite a evolucao do conhecimento
evolucao(Term) :-
findall(Invariant,+Term::Invariant,List),
insercao(Term),
test(List).
%--------------------------------- - - - - - - - - - - - - - - -
% Auxiliar
evolucao(Termo) :-
findall(Invariante,+Termo::Invariante,Lista),
insercao(Termo),
teste(Lista).
insercao(Termo) :-
assert(Termo).
insercao(Termo) :-
retract(Termo),!,fail.