prove_evaluator.rb revision 274388c57b757bc0c9298b84ec0f078ac1caf173
register :tactic_script_extra_options, :end,
if ontology.name == hash[:ontology_name]
proof_attempt.prover = hash[:used_prover]
end
end
end
case hash[:result]
when 'Proved'
when 'Disproved'
else
end
end
{
time_limit: hash[:tactic_script_time_limit],
extra_options: hash[:tactic_script_extra_options],
}.to_json
end
if hash[:used_axioms] && proof_attempt.theorem
process_used_axioms(hash, proof_attempt)
else
[[], []]
end
end
used_sentences = []
generated_axioms = []
used_sentences << axiom if axiom.is_a?(Sentence)
generated_axioms << axiom if axiom.is_a?(GeneratedAxiom)
end
[used_sentences, generated_axioms]
end
# Logic translations applied before proving can introduce new axioms that
# are not stored as sentences in our database. They need to be
# distinguished from sentences.
def find_sentence_or_generate_axiom(axiom_name, proof_attempt)
# We need the `unscoped` call to include theorems.
sentence = Sentence.unscoped.
where(ontology_id: proof_attempt.theorem.ontology.id,
name: axiom_name).first
sentence || generate_axiom(axiom_name, proof_attempt)
end
def generate_axiom(axiom_name, proof_attempt)
generated_axiom = GeneratedAxiom.new
generated_axiom.name = axiom_name
generated_axiom.proof_attempt = proof_attempt
generated_axiom.save
generated_axiom
end
def all_start
self.hierarchy = []
end
def all_end
end
def set_object_value(value, key)
info = proof_attempt_info(key, value)
object_hash[info.keys.first] = info.values.first if info
end
def add_array_value(value)
info = proof_attempt_info
object_hash[info.keys.first] ||= []
object_hash[info.keys.first] << value
end
def node_start
hierarchy << :node
self.object_hash = {}
end
def node_end
hierarchy.pop
end
def goal_start
hierarchy << :goal
ontology_name = object_hash[:ontology_name]
self.object_hash = {ontology_name: ontology_name}
end
def goal_end
hierarchy.pop
create_proof_attempt_from_hash(object_hash)
end
%i(tactic_script
tactic_script_extra_options
used_time
used_time_components
used_axioms).each do |hook|
define_method("#{hook}_start") do
hierarchy << hook
end
define_method("#{hook}_end") do
hierarchy.pop
end
end
def proof_attempt_info(key = nil, value = nil)
case hierarchy.last
when :node
{ontology_name: value} if key == 'node'
when :goal
goal_info(key, value)
when :tactic_script
{:"tactic_script_#{key.underscore}" => value}
when :tactic_script_extra_options
{:tactic_script_extra_options => nil}
when :used_time
{:time_taken => value} if key == 'seconds'
when :used_time_components
# don't use them
when :used_axioms
{:used_axioms => nil}
else
{key.underscore.to_sym => value}
end
end
def goal_info(key, value)
if key == 'name'
{:theorem_name => value}
else
{key.underscore.to_sym => value}
end
end
def initiate_concurrency_handling
# overwrite this method - concurrency is not an issue here
end
def finish_concurrency_handling
# overwrite this method - concurrency is not an issue here
end
def cancel_concurrency_handling_on_error
# overwrite this method - concurrency is not an issue here
end
end
end
end