lib/hqmf-parser/converter/pass1/precondition_converter.rb in hqmf-parser-1.0.6 vs lib/hqmf-parser/converter/pass1/precondition_converter.rb in hqmf-parser-1.1.0
- old
+ new
@@ -132,16 +132,25 @@
negated_conditions.concat precondition.preconditions if precondition.preconditions
end
end
if (!sub_conditions.empty?)
- # if we have negated conditions, add them to a new precondition of the same conjunction that is negated
+ # if we have negated conditions, add them to a new precondition with an inverted conjunction on a negated precondition
+ # the reason we invert the conjunction is because we are turning
+ # AND: NOT X
+ # AND: NOT Y
+ # into
+ # NOT: X OR Y
+ # (i.e, demorgan's law)
if (!negated_conditions.empty?)
- sub_conditions << HQMF::Converter::SimplePrecondition.new(nil,negated_conditions,nil,conjunction_code, true)
+ inverted_conjunction_code = HQMF::Precondition::INVERSIONS[conjunction_code]
+ sub_conditions << HQMF::Converter::SimplePrecondition.new(nil,negated_conditions,nil,inverted_conjunction_code, true)
end
joined << HQMF::Converter::SimplePrecondition.new(nil,sub_conditions,nil,conjunction_code, false)
elsif (!negated_conditions.empty?)
- joined << HQMF::Converter::SimplePrecondition.new(nil,negated_conditions,nil,conjunction_code, true)
+ # invert conjunction based on demorgan's law
+ inverted_conjunction_code = HQMF::Precondition::INVERSIONS[conjunction_code]
+ joined << HQMF::Converter::SimplePrecondition.new(nil,negated_conditions,nil,inverted_conjunction_code, true)
end
end
joined
end