git @ Cat's Eye Technologies Eqthy / 7b01f7b
Raise error if naming theorem or axiom with already existing name. Chris Pressey 3 months ago
5 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
88
99 0.5
1010 ---
11
12 Language:
13
14 * It is not valid to name a theorem or an axiom with the
15 same name as an existing theorem or axiom.
1116
1217 Implementation:
1318
116116
117117 * Allow the first line of a proof to be an axiom.
118118 * Arity checking in parser would prevent some silly errors in axioms.
119 * Prevent naming a theorem or axiom with a name already in context.
119 * Improve unnamed theorem and axiom support (unique names across files.)
120120
121121 ### Desired Examples
122122
103103 A = or(A, and(A, B))
104104 qed
105105
106 theorem (#or-absorp)
106 theorem (#and-absorp)
107107 A = and(A, or(A, B))
108108 proof
109109 A = A
190190 not(0) = 1
191191 qed
192192
193 theorem
193 theorem (#comp-involutive)
194194 not(not(A)) = A
195195 proof
196196 and(or(not(not(A)), A), 1) = and(or(not(not(A)), A), 1)
1111 Term, Eqn, RewriteRule,
1212 all_rewrites, render, replace, apply_substs_to_rule
1313 )
14
15
16 class NamingError(Exception):
17 pass
1418
1519
1620 class DerivationError(Exception):
2832
2933 def register(self, name: str, lhs: Term, rhs: Term) -> None:
3034 self.log("Registering rule [{}]: {} = {}", render(name), render(lhs), render(rhs))
35 if (name + '_1') in self.rules:
36 raise NamingError("The name '{}' has already been defined".format(name))
3137 self.rules[name + '_1'] = RewriteRule(pattern=lhs, substitution=rhs)
3238 self.rules[name + '_2'] = RewriteRule(pattern=rhs, substitution=lhs)
3339