Skip to content

Commit

Permalink
Check free variables in initial and goal state in Wise
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Apr 24, 2024
1 parent d644be5 commit 5f0ce7d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extensions/Wise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def apply(operators, methods, predicates, state, tasks, goal_pos, goal_not, debu
# Initial state
state.reject! {|pre,k|
if predicates.include?(pre)
# Free variable
raise 'Initial state contains free variable' if k.flatten(1).any? {|t| t.start_with?('?')}
# Duplicates
puts "Initial state contains duplicate predicates (#{pre} ...): removed" if k.uniq! and debug
# Arity check
Expand Down Expand Up @@ -99,6 +101,7 @@ def apply(operators, methods, predicates, state, tasks, goal_pos, goal_not, debu
tasks.unshift(ordered)
end
# Goal
raise 'Goal contains free variable' if (goal_pos + goal_not).flatten(1).any? {|t| t.start_with?('?')}
puts "Goal contains duplicate positive condition: removed" if goal_pos.uniq! and debug
puts "Goal contains duplicate negative condition: removed" if goal_not.uniq! and debug
(goal_pos & goal_not).each {|pre| raise "Goal contains contradiction (#{pre.join(' ')}) and (not (#{pre.join(' ')}))"}
Expand Down

0 comments on commit 5f0ce7d

Please sign in to comment.