Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attribute function applied to a constant in the head of a state constraint #27

Open
zhangyuanlin opened this issue Sep 3, 2018 · 2 comments

Comments

@zhangyuanlin
Copy link

We have the following pieces of a program

            elevations :: things
              attributes
                top: points
              ... 
          box :  elevations
             ... 
          connected : points * points -> booleans
             ... 
	  -connected(top(box),P) if
		loc_in(box) != P, instance(P,floor_points).

The state constraint above is translated into

-connected(elevations_top(box), P, TS) :- loc_in(box, LO, TS), #floor_points(P), LO!=P, 
          instance(P, floor_points).

causing an exception

Exception in thread "main" java.lang.RuntimeException: SPARC  V2.54
: argument number 1 of predicate connected/3, "elevations_top(box)", 
at line 595 [above], column 1 violates definition of sort "#points"

So, CALM has some mistake in this translation?

Full program is basicMotion_yn.tp:

system description monkeyBanana
	theory basic_motion
      module moving
        sort declarations
            points, things :: universe
            agents :: things

            carriables :: things

            elevations :: things
              attributes
                top: points

            move :: actions
                attributes
                    actor : agents
                    origin : points
                    dest : points

            climb :: move
              attributes
                elevation : elevations

        function declarations
            statics
                basic
                    symmetric_connectivity : booleans
                    transitive_connectivity : booleans
            fluents
                basic
                    % connnected(P1, P2) - true if P1 and P2 are connected
                    connected : points * points -> booleans
                    % loca_in(T) - the point where thing T is at
                    total loc_in : things -> points
        axioms
            dynamic causal laws
                % move action causes its actor to be at its destination
                occurs(X) causes loc_in(A) = D if
                    instance(X, move),
                    actor(X) = A,
                    dest(X) = D.
            state constraints
                % top(E) is the destination of climbing an elevation E
                dest(A) = C if elevation(A) = E, C = top(E).

                connected(X, X).
                connected(X, Y) if connected(Y, X),symmetric_connectivity.
                -connected(X, Y) if -connected(Y, X),symmetric_connectivity.
                connected(X, Z) if
                    connected(X, Y),connected(Y, Z),transitive_connectivity.
                % NEW bug?
                
            executability conditions
                % move is not possible if its actor is not at its origin.
                % NEW - what if the origin of actor unknown?
                impossible occurs(X) if
                    instance(X, move),actor(X) = A,loc_in(A) != origin(X).
                    % instance(X, move), loc_in(actor(X)) != origin(X).

                % move is not possible if its actor is at its dest.
                impossible occurs(X) if
                    instance(X, move),actor(X) = A,loc_in(A) = dest(X).
                    % instance(X, move), loc_in(actor(X)) = dest(X).

                % move is not possible if the location of its actor is not
                % connected to its dest.
                impossible occurs(X) if
                    instance(X, move),
                    actor(X) = A,
                    loc_in(A) = O,
                    dest(X) = D,
                    -connected(O, D).
					
	module main depends on moving
		sort declarations
			floor_points, ceiling_points, movable_points :: points
		constant declarations
			monkey : agents
			box :  elevations
            %  top = top(box)
            % top(elevations): movable_points
			box, banana : carriables
		function declarations
			statics
				basic
					% under(P, T) - point P is under thing T
					under : floor_points * things -> booleans
			axioms
				function definitions
                    % monkey can reach the banana if it is on top of the box
                    % which under the banana
					%?? can_reach(monkey, banana) if
                    %    loc_in(box) = P, under(P,banana),loc_in(monkey) = top(box).
				state constraints
                        % top(E) is the destination of climbing an elevation E
                        % NEW ??
                        %dest(A) = C if instance(A, climb), elevation(A) = E, C = top(E).
						% The location of the box is connected to the top of the box
						connected(T,P) if
							loc_in(box) = P, T= top(box), instance(P, floor_points).
						% top of box is not connected to
						% any points other than the box's location.
						-connected(top(box),P) if
							loc_in(box) != P, instance(P,floor_points).
						% any two points on floor are connected
						connected(P1,P2) if
							instance(P1,floor_points), instance(P2, floor_points).
						% any ceiling point is not connected to any other point
						-connected(P1, P2) if
							instance(P1, ceiling_points),
							instance(P2,points), P1 != P2.
				executability conditions

	structure monkey_and_banana
	instances
        under_banana, initial_monkey, initial_box in floor_points
        initial_banana in ceiling_points
        box in elevations
            % top = top(box)
            % top = t(box)

        t(X) in movable_points where instance(X, elevations)

        move(P) in move where instance(P, points)
            actor = monkey
            dest = P

        climb(box) in climb
            actor = monkey
            elevation = box
            dest = t(box)

	value of statics
		under(under_banana, banana).
		symmetric_connectivity.
		-transitive_connectivity.

temporal projection
max steps 7
history

    observed(loc_in(box), initial_box, 0).
    observed(loc_in(monkey), initial_monkey, 0).
    happened(move(initial_box), 0).
    %happened(grasp(box), 1).
    %happened(carry(box, under_banana), 2).
    %happened(release(box), 3).
    %happened(climb(box), 4).
    %happened(grasp(banana), 5).
@Topology
Copy link
Owner

Topology commented Sep 9, 2018

Just want to make sure that we are seeing the same issue. The issue here is not that top(box) is interpreted as an attribute function. That is correct, it is an attribute function. The issue here is that the attribute function was not normalized out of the head of the state constraint during translation. The translation should be:

-connected(E, P, TS) :- loc_in(box, LO, TS), #floor_points(P), LO!=P, 
      instance(P, floor_points), E = elevations_top(box).

This is the problem I'm seeing and this is what I can fix without further clarification.

@zhangyuanlin
Copy link
Author

You are right. In the distributable version, I used an workaround to achieve the normalization at ALM level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants