git @ Cat's Eye Technologies Eqthy / 99973a1
Show step number in some error messages. Chris Pressey 2 years ago
3 changed file(s) with 7 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
8989 ----
9090
9191 * Handle "on LHS", "on RHS" in hints.
92 * Show the step number or line number in the error message when
93 there is a derivation error.
9492 * Allow rules to be instantiated with variable names other than the
9593 ones that are specified in the rule.
9694 * Allow context accumulated when verifying one document to be
204204 mul(A, e) = A
205205 mul(A, e) = mul(foo, mul(e, A))
206206 qed
207 ???> DerivationError: Could not derive mul(A, e) = mul(foo, mul(e, A)) from mul(A, e) = A
207 ???> Could not derive mul(A, e) = mul(foo, mul(e, A)) from mul(A, e) = A
208208
209209 This theorem does not prove what it says it proves.
210210
217217 A = A
218218 mul(A, e) = A
219219 qed
220 ???> DerivationError: No step in proof showed mul(A, e) = mul(A, A)
220 ???> No step in proof of unnamed_theorem_1 showed mul(A, e) = mul(A, A)
221221
222222 Typically, all theorems that are given in the document are checked,
223223 and are checked in sequence, and checking stops at the first failure.
246246 A = mul(A, e)
247247 mul(e, A) = mul(e, A)
248248 qed
249 ???> DerivationError: Could not derive mul(e, A) = mul(A, A) from A = mul(A, e)
249 ???> Could not derive mul(e, A) = mul(A, A) from A = mul(A, e)
250250
251251 This proof requires rewrites on the right-hand side of the equation.
252252
3636 prev = None
3737 rewritten_eqn = None
3838 eqn_shown = False
39 for step in theorem.steps:
39 for step_num, step in enumerate(theorem.steps):
4040 if prev is None:
4141 self.log("Verifying that {} follows from established rules", render(step.eqn))
4242 if step.eqn.lhs == step.eqn.rhs:
4343 rewritten_eqn = step.eqn
4444 self.log("Confirmed that {} follows from Reflexivity", render(step.eqn))
4545 else:
46 raise DerivationError("Could not derive {} from established rules".format(render(step.eqn)))
46 raise DerivationError("In step {} of {}: Could not derive {} from established rules".format(step_num + 1, theorem.name, render(step.eqn)))
4747 else:
4848 self.log("Verifying that {} follows from {}", render(step.eqn), render(prev.eqn))
4949 rewritten_eqn = self.obtain_rewritten_step(step, prev)
5050 if not rewritten_eqn:
51 raise DerivationError("Could not derive {} from {}".format(render(step.eqn), render(prev.eqn)))
51 raise DerivationError("In step {} of {}: Could not derive {} from {}".format(step_num + 1, theorem.name, render(step.eqn), render(prev.eqn)))
5252
5353 if rewritten_eqn == theorem.eqn:
5454 self.log("With {} we have now shown the theorem {}".format(render(rewritten_eqn), render(theorem.eqn)))
5656 prev = step
5757
5858 if not eqn_shown:
59 raise DerivationError("No step in proof showed {}".format(render(theorem.eqn)))
59 raise DerivationError("No step in proof of {} showed {}".format(theorem.name, render(theorem.eqn)))
6060
6161 def obtain_rewritten_step(self, step, prev):
6262 rules_to_try = self.rules