diff --git a/lab4/chainageAvantAvecFiltrage.py b/lab4/chainageAvantAvecFiltrage.py index 9e7e020..22b1d18 100755 --- a/lab4/chainageAvantAvecFiltrage.py +++ b/lab4/chainageAvantAvecFiltrage.py @@ -1,4 +1,5 @@ import match +import copy ##La variable globale utilsee pour signifier un ECHEC echec='ECHEC' @@ -132,21 +133,21 @@ ## @param faits_initiaux les faits initiaux ## @ret la liste des faits deduits def chainageAvantAvecFiltrage(regles, faits_initiaux): - Q = faits[:] + Q = copy.deepcopy(faits) while Q: - q = Q[0] - Q = Q[1:] + q = Q.pop(0) if q not in faits: ajouteFait(q) - afficheFait(q) + print q + for r in regles: c = conditionsRegle(r) - es = match.filtrage(q, c) - if es != echec: - for e in es: - e2 = satisfaitConditions(c, e) - n = instantieVariables(consequenceRegle(r), e2) + res = faitSatisfaitUneCondition(q, c) + for env, cond in zip(res[0], res[1]): + e2 = satisfaitConditions(cond, env) + ns = instantieVariables(consequenceRegle(r), e2) + for n in ns: if n not in faits: Q.append(n) @@ -157,10 +158,3 @@ #execfile("testInstantieVariables.py") execfile("impots2.py") chainageAvantAvecFiltrage(regles,faits) - -diff = faits[:] -for item in diff: - if item in result: - diff.remove(item) - -print diff diff --git a/lab4/unificateur.py b/lab4/unificateur.py index 1b93e6a..612ccc1 100755 --- a/lab4/unificateur.py +++ b/lab4/unificateur.py @@ -157,7 +157,7 @@ return {} else: if testeVariable(pat1): - if variableDansSubstitutions(pat1, pat2): + if :: return echec else: return {pat1: pat2}