/// <summary> /// Handles an inferred theorem by communicating it with the normalization helper and scheduler, and also handling proof /// construction is the proof data is provided. /// </summary> /// <param name="theorem">The theorem to be handled.</param> /// <param name="helper">The normalization helper that verifies and normalizes the theorem.</param> /// <param name="scheduler">The scheduler of inference rules used for the theorem if it is correct.</param> /// <param name="proofData">Either the data needed to mark the theorem's inference in case it's correct; or null, if we are not constructing proofs.</param> /// <param name="isValid">Indicates whether the theorem has been found geometrically valid.</param> private void HandleNonequality(Theorem theorem, NormalizationHelper helper, Scheduler scheduler, ProofData proofData, out bool isValid) { // Mark the theorem to the helper helper.MarkProvedNonequality(theorem, out var isNew, out isValid, out var normalizedTheorem, out var equalities); // If it turns out not new or valid, we're done if (!isNew || !isValid) { return; } #region Handle proof construction // Mark the original theorem proofData?.ProofBuilder.AddImplication(proofData.InferenceData, theorem, proofData.Assumptions); // If any normalization happened if (equalities.Any()) { // Mark the normalized theorem too proofData?.ProofBuilder.AddImplication(ReformulatedTheorem, normalizedTheorem, assumptions: equalities.Concat(theorem).ToArray()); } #endregion // Let the scheduler know scheduler.ScheduleAfterProving(normalizedTheorem); #region Inference from symmetry // If the theorem use an object that is not part of the original configuration, // then we will not do any symmetry inference. If it could prove a new theorem, // then this new theorem would be inferable conventionally if (!normalizedTheorem.GetInnerConfigurationObjects().All(helper.Configuration.AllObjects.Contains)) { return; } // Otherwise try to infer new theorems using this one foreach (var inferredTheorem in normalizedTheorem.InferTheoremsFromSymmetry(helper.Configuration)) { // If it can be done, make sure the proof builder knows it proofData?.ProofBuilder.AddImplication(InferableFromSymmetry, inferredTheorem, assumptions: new[] { normalizedTheorem }); // Call this method to handle this new inferred theorem, without caring if it is valid (it should be logically) HandleNonequality(inferredTheorem, helper, scheduler, proofData, isValid: out var _); } #endregion }