coment on compare deux characteres ? [prolog] - Divers - Programmation
Marsh Posté le 19-12-2002 à 20:46:45
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PROJET'02 : TRANSFORMATIONS EQUIVALENTES %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% DEFINITIONS DES CONNECTEURS %%%%%%%%%
:-op(600,fy,'~'. % la negation
:-op(670,yfx,&). % la conjonction
:-op(675,yfx,'V'. % la disjonction
:-op(680,yfx, '->'. % l'implication
:-op(700,yfx,'<->'. % l'equivalence
%%%%%%%%%%%%%%%%%%%%%%%% TRANSFORMATIONS %%%%%%%%%%%%%%%%%%%%%%%%
%% Equivalence :
%%%%%%%%%%%%%%%%%
teq(Form1 '<->' Form2, Memb1 & Memb2) :-
!,
teq(Form1 '->' Form2, Memb1),
teq(Form2 '->' Form1, Memb2).
teq(Form1 & Form2, Memb1 & Memb2) :-
!,
teq(Form1, Memb1),
teq(Form2, Memb2).
teq(Form1 'V' Form2, Memb1 'V' Memb2) :-
!,
teq(Form1, Memb1),
teq(Form2, Memb2).
teq(Form1 '->' Form2, Memb1 '->' Memb2) :-
!,
teq(Form1, Memb1),
teq(Form2, Memb2).
teq('~' Form, '~' Memb) :-
!,
teq(Form, Memb).
teq(P,P).
%%%%%%%%%%%%%%%%%%%%%%
%% Implication :
%%%%%%%%%%%%%%%%%%%%%%
tim(Form1 '->' Form2, '~' Memb1 'V' Memb2) :-
!,
tim(Form1, Memb1),
tim(Form2, Memb2).
tim(Form1 & Form2, Memb1 & Memb2) :-
!,
tim(Form1, Memb1),
tim(Form2, Memb2).
tim(Form1 'V' Form2, Memb1 'V' Memb2) :-
!,
tim(Form1, Memb1),
tim(Form2, Memb2).
tim('~' Form, '~' Memb) :-
!,
tim(Form, Memb).
tim(P,P) :-
atom(P).
%%%%%%%%%%%%%%%%%%%%%%
%% Negation :
%%%%%%%%%%%%%%%%%%%%%%
tng('~' '~' Form, Res) :-
!,
tng(Form,Res).
tng('~' (Form1 & Form2), (Res1 'V' Res2)) :-
!,
tng('~' Form1, Res1),
tng('~' Form2, Res2).
tng('~' (Form1 'V' Form2), (Res1 & Res2)) :-
!,
tng('~' Form1, Res1),
tng('~' Form2, Res2).
tng('~' P, '~' P) :-
!,
atom(P).
tng(Form1 & Form2, Memb1 & Memb2) :-
!,
tng(Form1, Memb1),
tng(Form2, Memb2).
tng(Form1 'V' Form2, Memb1 'V' Memb2) :-
!,
tng(Form1, Memb1),
tng(Form2, Memb2).
tng(P, P) :-
atom(P).
%%%%%%%%%%%%%%%%%%%%%%
%% Distributions :
%%%%%%%%%%%%%%%%%%%%%%
%% & --> 'V'
dstrc((G1 'V' G2) & D, R1 'V' R2) :-
!,
dstrc(G1 & D,R1),
dstrc(G2 & D,R2).
dstrc(G & (D1 'V' D2), R1 'V' R2) :-
!,
dstrc(G & D1,R1),
dstrc(G & D2,R2).
dstrc((F1 & F2) & F3, F) :-
!,
dstrc(F2 & F3, R1),
dstrc(F1 & R1, F).
dstrc(F1 'V' F2, R1 'V' R2) :-
!,
dstrc(F1, R1),
dstrc(F2, R2).
dstrc(F, F).
%%%%%%%%%%%%%%%%%%%%%%
%% Distributions :
%%%%%%%%%%%%%%%%%%%%%%
%% 'V' --> &
dstrd((G1 & G2) 'V' D, R1 & R2) :-
!,
dstrd(G1 'V' D,R1),
dstrd(G2 'V' D,R2).
dstrd(G 'V' (D1 & D2), R1 & R2) :-
!,
dstrd(G 'V' D1,R1),
dstrd(G 'V' D2,R2).
dstrd((F1 'V' F2) 'V' F3, F) :-
!,
dstrd(F2 'V' F3, R1),
dstrd(F1 'V' R1, F).
dstrd(F1 & F2, R1 & R2) :-
!,
dstrd(F1, R1),
dstrd(F2, R2).
dstrd(F, F).
%%%%%%%%%%%%%%%%%%
%% Associativites :
%%%%%%%%%%%%%%%%%%%
assg(F1 'V' (F2 'V' F3),R1a 'V' F3a) :-
!,
assg(F1 'V' F2,R1a),
assg(F3, F3a).
assg((F1 'V' F2) 'V' F3,R1a 'V' F3a) :-
!,
assg(F1 'V' F2,R1a),
assg(F3, F3a).
assg(F,F).
assd((F1 'V' F2) 'V' F3, F1a 'V' (F2a 'V' F3a)) :-
!,
assd(F1, F1a),
assd(F2, F2a),
assd(F3, F3a).
assd(F1 'V' (F2 'V' F3), F1a 'V' (F2a 'V' F3a)) :-
!,
assd(F1, F1a),
assd(F2, F2a),
assd(F3, F3a).
assd(F,F).
eassg(F1 & (F2 & F3),(F1a & F2a) & F3a) :-
!,
eassg(F1, F1a),
eassg(F2, F2a),
eassg(F3, F3a).
eassg((F1 & F2) & F3,(F1a & F2a) & F3a) :-
!,
eassg(F1, F1a),
eassg(F2, F2a),
eassg(F3, F3a).
eassg(F,F).
eassd((F1 & F2) & F3, F1a & (F2a & F3a)) :-
!,
eassd(F1, F1a),
eassd(F2, F2a),
eassd(F3, F3a).
eassd(F1 & (F2 & F3), F1a & (F2a & F3a)) :-
!,
eassd(F1, F1a),
eassd(F2, F2a),
eassd(F3, F3a).
eassd(F,F).
Marsh Posté le 19-12-2002 à 23:46:27
En fait si j'ai mis ça c'est pour un pote de fac.
Evolution buggait et je pouvais pas lui envoyer le fichier alors j'ai fait copier collé
sinon j'ai resolu mon probleme et ça marche.
Marsh Posté le 19-12-2002 à 19:37:49
je voudrais trier des listes avec des characeteres dedans.