1 / 34

FLUX

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.

urbano
Download Presentation

FLUX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FLUX

  2. 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

  3. 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

  4. 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

  5. CHR Operational Semantics in FLUX

  6. Agent View • World Model • Execution State • Program Rules • Actions • Transitions • Execution • While a final state has not been reached • Apply transitions non-deterministically

  7. 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).

  8. Helper Predicates isBIC(true). isBIC(false). isBIC(_ == _). isUDC(X) :- notisBIC(X).

  9. 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)

  10. Helper Predicates • generateMatchingEquations(Constraints, Matching, Equations) • generateMatchingEquations([c(X),d(Y)], [c(1), d(2)], W = [X == 1, Y == 2].

  11. Helper Predicates • entails(Z, V, C, Z1) • Z = <G,U,B> • Z1 = <G,U,B’> • Z Z1

  12. 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).

  13. 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).

  14. state_update(Z1, introduce, Z2, []) :- (knows_val([X], goal(X), Z1), isUDC(X), update(Z1, [udstore(X)], [goal(X)], Z2)) ; Z1 = Z2.

  15. state_update(Z1, solve, Z2, []) :- (knows_val([X], goal(X), Z1), isBIC(X), getVars([X], LV), entails(Z1, LV, X, Z2)) ; Z1 = Z2.

  16. state_update(Z1, simplify, Zf, []) :- (knows_val([HeadRemove0, Guard0, Body0],rule(HeadRemove0 <==> Guard0 : Body0), Z1), renameVars([], HeadRemove0, Guard0, Body0, _, HeadRemove, Guard, Body), ...

  17. ... 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), ...

  18. ... ((knows(bicstore(false), Z3), fail) ; (not knows(bicstore(false), Z3), removeMatching(Z3, Matching, Z4), addBody(Z4, Body, Z5), addEquations(Z5, Equations, Zf) ) ) ) ; Z1 = Zf.

  19. CHOR Semantics in FLUX

  20. 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

  21. Helper Predicates isFAtom(isa(_,_)). isFAtom(sub(_,_)). isFAtom(fd(_,_,_)).

  22. Taxonomy Completion Taxonomy Validation Feature Inheritance Inherit propagateSub/2 propagateIsa/2 validadeCycles/2 computeInheritedFeatures/2 cancelOverridenByCS/3 computeOverriding/3

  23. 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).

  24. 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).

  25. Examples

  26. Clyde rule1 @@ main <==> clyde:royalElephant, royalElephant::elephant, elephant[color->gray], royalElephant[color->white) ].

  27. Clyde (Results) clyde[color->white] clyde:elephant royalElephant[color->white] elephant[color->gray] royalElephant::elephant clyde:royalElephant

  28. Nixon diamond rule1 @@ main<==> quaker[policy->pacifist], republican[policy->hawk], nixon:quaker, nixon:republican.

  29. Nixon Diamond (Results)Source Based Multiple Inheritance nixon : republican nixon : quaker republican[policy -> hawk] quaker[policy -> pacifist]

  30. 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

  31. Example 2.5.1 (Adapt.) rule1 @@ main <==> c1::c2, c2[m->a]. rule2 @@ c1[m->a] \ c2[m->a] <==> c2[m->b].

  32. Example 2.5.1 (Adapt.)(Results) c1[m->a] c2[m->b] c1::c2

  33. Example 2.5.3 rule1 @@ main <==> c1:c2, c3::c2, c2[m->a], c3[m->b]. rule2 @@ c1[m->a] ===> c1:c3.

  34. Example 2.5.3 (Results) c1 : c3 c1[m-> a] c3[m->b] c2[m->a] c3 :: c2 c1 : c2

More Related