sine_axiom_selection.rb revision 01f82915d3add64f685ccd7d9386a424e54a3587
a857fb61f1cc77a81d18adee6a95ae04c27a5ffbTimo Sirainen attr_accessible :commonness_threshold, :depth_limit, :tolerance
53d794b1cb99c0cc437ec9449d19abf504058390Timo Sirainen validates_numericality_of :commonness_threshold,
1904e2fc786dbc037039d284b371730777277fc5Aki Tuomi # Special case: The depth limit of -1 is considered to be infinite.
53d794b1cb99c0cc437ec9449d19abf504058390Timo Sirainen validates_numericality_of :tolerance, greater_than_or_equal_to: 1
53d794b1cb99c0cc437ec9449d19abf504058390Timo Sirainen delegate :lock_key, :mark_as_finished!, to: :axiom_selection
35283613d4c04ce18836e9fc431582c87b3710a0Timo Sirainen @goal ||= proof_attempt_configurations.first.proof_attempt.theorem
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen ontology.symbols.each { |symbol| calculate_commonness(symbol) }
a07b1d77c546256eebda95b7c403e92e1bbcbe94Timo Sirainen axiom_selection_id: axiom_selection.id).first_or_initialize
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen ontology.all_axioms.joins(:symbols).where(:'symbols.id' => symbol.id).count
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen def calculate_symbol_axiom_trigger(symbol, axiom)
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen axiom_selection_id: axiom_selection.id).first_or_initialize
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen ssat.tolerance = needed_tolerance(symbol, axiom)
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen lcs_commonness = commonness_of_least_common_symbol(axiom)
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen sym_commonness = symbol.sine_symbol_commonness.commonness
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen axiom.symbols.includes(:sine_symbol_commonness).
a3fe8c0c54d87822f4b4f8f0d10caac611861b2bTimo Sirainen order('sine_symbol_commonnesses.commonness ASC').first
94d0d29f23083c4e79a3fc6b76e9ed761b0e3511Timo Sirainen least_common_symbol(axiom).sine_symbol_commonness.commonness
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen def select_new_axioms(sentence, current_depth)
eb627e89fba85791ec894e57f96752b1bd64d001Timo Sirainen new_axioms = select_axioms_by_sentence(sentence) - @selected_axioms
eb627e89fba85791ec894e57f96752b1bd64d001Timo Sirainen new_axioms.each { |axiom| select_new_axioms(axiom, current_depth + 1) }
eb627e89fba85791ec894e57f96752b1bd64d001Timo Sirainen sentence.symbols.map { |symbol| triggered_axioms(symbol) }.flatten
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen Axiom.unscoped.joins(:sine_symbol_axiom_triggers).
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen where('sine_symbol_axiom_triggers.symbol_id = ?', symbol.id).
cd2ed64888b42b481cde6bb9548c8520516fa3e9Timo Sirainen where('sine_symbol_axiom_triggers.tolerance <= ?', tolerance)