340 likes | 546 Views
FLUX. FLUX Predicates. holds(X, Z) Asserts X in Z knows(X, Z) X is known to be true in Z knows_val(X, V, Z) update(Z1, FAdd, FRemove, Z2) Z2 = Z1 + FAdd – FRemove execute(A, Z1, Z2) Z2 is the state after executing A in Z1. FLUX as a Modeling Language.
E N D
FLUX Predicates • holds(X, Z) • Asserts X in Z • knows(X, Z) • X is known to be true in Z • knows_val(X, V, Z) • update(Z1, FAdd, FRemove, Z2) • Z2 = Z1 + FAdd – FRemove • execute(A, Z1, Z2) • Z2 is the state after executing A in Z1
FLUX as a Modeling Language • perform(+Action, -Perceptions). • Executes the action on the environment simulator • Returns the perception list • state_update(Z1, Action, Z2, Perceptions) • Updates agent’s internal world model from Z1 to Z2, provided Action has been executed and Perceptions have been detected
Non FLUX modeling • Action preconditions (the poss/2 or 3 predicate) • Some examples do not include it • The underlying code does not uses it • Each example models it in a different way... • poss(Action, State) • poss(Action, Perceptions, State) • Model initialization • Planing • Environment simulator
Agent View • World Model • Execution State • Program Rules • Actions • Transitions • Execution • While a final state has not been reached • Apply transitions non-deterministically
World Model rule0 @ a, b \ c, d <=> g0 | b0. rule1 @ x, y ==> g1 | b1. init(Z) :- holds(goal(g0), Z), ..., holds(goal(gn), Z), holds(udstore(u0), Z), ..., holds(udstore(un), Z), holds(bicstore(b0), Z), ..., holds(bicstore(bn), Z), holds(rule(a, b \ c, d <=> g0 | b0), Z), holds(rule(x, y ==> g1 | b1), Z).
Helper Predicates isBIC(true). isBIC(false). isBIC(_ == _). isUDC(X) :- notisBIC(X).
Helper Predicates • getVars(Constraints, Variables) • getVars([p(X), q(Y,X)], W), W = [X,Y]. • renameVars(HeadKeep0, HeadRemove0, Guard0, Body0, HeadKeep, HeadRemove, Guard, Body) • findMatchingConstraints(Z, Constraints, Matching)
Helper Predicates • generateMatchingEquations(Constraints, Matching, Equations) • generateMatchingEquations([c(X),d(Y)], [c(1), d(2)], W = [X == 1, Y == 2].
Helper Predicates • entails(Z, V, C, Z1) • Z = <G,U,B> • Z1 = <G,U,B’> • Z Z1
Helper Predicates processBics(Z, _, [], Z). processBics(Z, LV, [B|R], Zf) :- entails(Z,LV,B, Z1), update(Z1,[bicstore(B)], [], Z2),processBics(Z2, LV, R,Zf).
Helper Predicates removeMatching(Z1, [], Z1). removeMatching(Z1, [C|R], Z2) :- removeMatching(Z1, R, Z12), update(Z12, [], [udstore(C)], Z2). addBody(Z1, [], Z1). addBody(Z1, [C|R], Z2) :- addBody(Z1, R, Z12), update(Z12, [goal(C)], [], Z2). addEquations(Z1, [], Z1). addEquations(Z1, [C|R], Z2) :- addEquations(Z1, R, Z12), update(Z12, [bicstore(C)], [], Z2).
state_update(Z1, introduce, Z2, []) :- (knows_val([X], goal(X), Z1), isUDC(X), update(Z1, [udstore(X)], [goal(X)], Z2)) ; Z1 = Z2.
state_update(Z1, solve, Z2, []) :- (knows_val([X], goal(X), Z1), isBIC(X), getVars([X], LV), entails(Z1, LV, X, Z2)) ; Z1 = Z2.
state_update(Z1, simplify, Zf, []) :- (knows_val([HeadRemove0, Guard0, Body0],rule(HeadRemove0 <==> Guard0 : Body0), Z1), renameVars([], HeadRemove0, Guard0, Body0, _, HeadRemove, Guard, Body), ...
... findMatchingConstraints(Z1, HeadRemove,Matching), generateMatchingEquations(HeadRemove, Matching, Equations), getVars(HeadRemove, HeadVars), getVars(Guard, GuardVars), subtract(GuardVars, HeadVars, GuardLocalVars), processBics(Z1, HeadVars, Equations, Z2), processBics(Z2, GuardLocalVars, Guard, Z3), ...
... ((knows(bicstore(false), Z3), fail) ; (not knows(bicstore(false), Z3), removeMatching(Z3, Matching, Z4), addBody(Z4, Body, Z5), addEquations(Z5, Equations, Zf) ) ) ) ; Z1 = Zf.
CHR + O • F-Atoms are syntax sugar for special UD constraints using Kifer’s codification • O:C isa(O,C) • C::S sub(C,S) • X[F->V] fd(X,F,V) • A new transition was added. It completes the current UD-store with information inherited by the means of inheritance • Syntatic constraints: • O:C and C::S cannot appear on HeadRemove
Helper Predicates isFAtom(isa(_,_)). isFAtom(sub(_,_)). isFAtom(fd(_,_,_)).
Taxonomy Completion Taxonomy Validation Feature Inheritance Inherit propagateSub/2 propagateIsa/2 validadeCycles/2 computeInheritedFeatures/2 cancelOverridenByCS/3 computeOverriding/3
state_update(Z1, inherit, Zf, []) :- (not (knows_val([X], goal(X), Z1), isFAtom(X)), handleTypeInheritance(Z1, Z2), handleFeatureInheritance(Z2,Zf)) ; Z1 = Zf. handleTypeInheritance(Z1, Zf) :- propagateSub(Z1,Z2), propagateIsa(Z2,Z3), validateCycles(Z3,Zf).
handleFeatureInheritance(Z,Zf) :- computeInheritedFeatures(Z,Candidates), computeOverriding(Z,Candidates, CandidatesWithOutOverriden), cancelOverridenByCS(Z, CandidatesWithOutOverriden, CandidatesWithOutOverridenExt), computeSourceValue(Z,CandidatesWithOutOverridenExt, CandidatesFinal, Conflicts), transformCandidates(CandidatesFinal, NewFeatures), update(Z, NewFeatures, [], Z1), getVars(Conflicts, VarC), processBics(Z1, VarC, Conflicts, Zf).
Clyde rule1 @@ main <==> clyde:royalElephant, royalElephant::elephant, elephant[color->gray], royalElephant[color->white) ].
Clyde (Results) clyde[color->white] clyde:elephant royalElephant[color->white] elephant[color->gray] royalElephant::elephant clyde:royalElephant
Nixon diamond rule1 @@ main<==> quaker[policy->pacifist], republican[policy->hawk], nixon:quaker, nixon:republican.
Nixon Diamond (Results)Source Based Multiple Inheritance nixon : republican nixon : quaker republican[policy -> hawk] quaker[policy -> pacifist]
Nixon Diamond (Results)Value Based Multiple Inheritance nixon[policy->pacifist] nixon[policy->hawk] nixon:republican nixon:quaker Republican[policy->hawk] quaker[policy->pacifist] hawk==pacifist pacifist==hawk false
Example 2.5.1 (Adapt.) rule1 @@ main <==> c1::c2, c2[m->a]. rule2 @@ c1[m->a] \ c2[m->a] <==> c2[m->b].
Example 2.5.1 (Adapt.)(Results) c1[m->a] c2[m->b] c1::c2
Example 2.5.3 rule1 @@ main <==> c1:c2, c3::c2, c2[m->a], c3[m->b]. rule2 @@ c1[m->a] ===> c1:c3.
Example 2.5.3 (Results) c1 : c3 c1[m-> a] c3[m->b] c2[m->a] c3 :: c2 c1 : c2