Cross Reference: proof_attempt.rb
xref
: /
ontohub
/
app
/
models
/
proof_attempt.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
proof_attempt.rb revision 80d7c205926c3c8b9869082cc4eb0760e54e0aee
2
ronwalf
class
ProofAttempt
<
ActiveRecord
::
Base
2
ronwalf
include
Numbering
2
ronwalf
include
StateUpdater
2
ronwalf
2
ronwalf
numbering_parent_column
'sentence_id'
2
ronwalf
2
ronwalf
belongs_to
:
theorem
,
foreign_key
:
'sentence_id'
2
ronwalf
belongs_to
:
proof_status
2
ronwalf
belongs_to
:
prover
2
ronwalf
belongs_to
:
proof_attempt_configuration
2
ronwalf
has_one
:
prover_output
2
ronwalf
has_one
:
tactic_script
2
ronwalf
has_many
:
generated_axioms
,
dependent
: :
destroy
2
ronwalf
has_and_belongs_to_many
:
used_axioms
,
2
ronwalf
class_name
:
'Axiom'
,
2
ronwalf
association_foreign_key
:
'sentence_id'
,
2
ronwalf
join_table
:
'used_axioms_proof_attempts'
2
ronwalf
has_and_belongs_to_many
:
used_theorems
,
2
ronwalf
class_name
:
'Theorem'
,
2
ronwalf
association_foreign_key
:
'sentence_id'
,
2
ronwalf
join_table
:
'used_axioms_proof_attempts'
2
ronwalf
2
ronwalf
attr_accessible
:
locid
2
ronwalf
attr_accessible
:
time_taken
,
2
ronwalf
:
number
,
2
ronwalf
:
state
,
2
ronwalf
:
state_updated_at
,
2
ronwalf
:
last_error
2
ronwalf
2
ronwalf
validates
:
state
,
inclusion
: {
in
:
State
::
STATES
}
2
ronwalf
validates
:
theorem
,
presence
:
true
2
ronwalf
2
ronwalf
before_create
:
generate_locid
2
ronwalf
before_save
:
set_default_proof_status
2
ronwalf
after_save
:
update_theorem_status
2
ronwalf
2
ronwalf
scope
:
latest
,
order
(
'number DESC'
)
2
ronwalf
2
ronwalf
delegate
:
ontology
,
to
: :
theorem
2
ronwalf
2
ronwalf
def
self.find
_with_locid
(
locid
,
_iri
=
nil
)
2
ronwalf
where
(
locid
:
locid
)
.
first
2
ronwalf
end
2
ronwalf
2
ronwalf
def
used_sentences
2
ronwalf
@
used_sentences
||=
used_axioms
+
used_theorems
2
ronwalf
end
2
ronwalf
2
ronwalf
def
set_default_proof_status
2
ronwalf
self.proof
_status
||=
ProofStatus.find
(
ProofStatus
::
DEFAULT_OPEN_STATUS
)
2
ronwalf
end
2
ronwalf
2
ronwalf
def
generate_locid
2
ronwalf
self.locid
=
2
ronwalf
"#{
theorem.locid
}//#{
self.class.to_s.underscore.dasherize
}-#{number}"
2
ronwalf
end
2
ronwalf
2
ronwalf
def
update_theorem_status
2
ronwalf
theorem.update
_proof_status
(
proof_status
)
2
ronwalf
end
2
ronwalf
2
ronwalf
def
associate_prover_with_ontology_version
ontology_version
=
theorem.ontology.current
_version
unless
ontology_version.provers.include
?
(
prover
)
ontology_version.provers
<< prover
ontology_version.save!
end
end
def retry_failed
options_to_attempts = CollectiveProofAttemptWorker.
normalize_for_async_call({prove_options_from_configuration => [self]})
CollectiveProofAttemptWorker.
perform_async(Theorem.to_s, theorem.id, options_to_attempts)
end
protected
def prove_options_from_configuration
pac = proof_attempt_configuration
Hets::ProveOptions.new({prover: pac.prover,
timeout: pac.timeout})
end
end