Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rolando Grave De Peralta Gonzalez
semantique_2019
Commits
2f82bfd1
Commit
2f82bfd1
authored
Apr 16, 2019
by
Didier.Buchs
Browse files
Upload New File
parent
970100f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
InterpretProlog/resolution.pl
0 → 100644
View file @
2f82bfd1
%------------------------------------------------------------------------
% SolveSLD: implementation of Prolog Strategy in Prolog !!!!
%------------------------------------------------------------------------
solveSLD
([]).
solveSLD
([
H
|
T
]):-
axiom
(
H
,
RESTE
),
solveSLD
(
RESTE
),
solveSLD
(
T
).
%------------------------------------------------------------------------
% SolveRes: implementation of Logic Programming without Strategy in Prolog !!!!
%------------------------------------------------------------------------
solveRes
([]).
solveRes
(
L
):-
elem_liste_random
(
L
,
H
,
R
),
bagof
(
axiom
(
H
,
T
),
H
^
axiom
(
H
,
T
),
LAXIOMS
),
chooseaxiom
(
LAXIOMS
,
H
,
R
).
chooseaxiom
([
HL
|
L
],
H
,
R
):-
elem_liste_random
([
HL
|
L
],
axiom
(
HH
,
RESTE
),
OTHERS
),
(
append
(
R
,
RESTE
,
RR
),
H
=
HH
,
solveRes
(
RR
);
(
OTHERS
=
[
_
|
_
],
chooseaxiom
(
OTHERS
,
H
,
R
))).
% choisi aleatoirement un element dans une liste
% elem_liste_random(liste, element choisi, liste privee de l'element choisi)
:-
mode
(
elem_liste_random
(
+,-,-
)).
elem_liste_random
([
E
|
L
],
F
,
NL
)
:-
length
([
E
|
L
],
Length
),
Lengthi
is
Length
+
1
,
random
(
1
,
Lengthi
,
Ranki
),(
Lengthi
=
Ranki
,
Rank
=
Length
,!;
Rank
=
Ranki
),
% Hack pour random fragile
neme_elem
(
Rank
,
[
E
|
L
],
F
,
NL
).
% retourne le neme element d'une liste
:-
mode
(
neme_elem
(
++,+,-,-
)).
neme_elem
(
1
,
[
E
|
L
],
E
,
L
)
:-
!.
neme_elem
(
N
,
[
E
|
L
],
F
,
[
E
|
NL
])
:-
M
is
N
-
1
,
neme_elem
(
M
,
L
,
F
,
NL
).
axiom
(
a
(
X
,
Y
),[
b
(
X
),
c
(
Y
)]).
axiom
(
b
(
1
),[]).
axiom
(
b
(
2
),[]).
axiom
(
c
(
3
),[]).
axiom
(
c
(
4
),[]).
% paths in a binary tree
axiom
(
path
(
leaf
),[]).
axiom
(
path
(
l
(
P
)),[
path
(
P
)]).
axiom
(
path
(
r
(
P
)),[
path
(
P
)]).
axiom
(
length
(
leaf
,
0
),[]).
axiom
(
length
(
l
(
P
),
s
(
R
)),[
length
(
P
,
R
)]).
axiom
(
length
(
r
(
P
),
s
(
R
)),[
length
(
P
,
R
)]).
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment