-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a17444
commit 547dccd
Showing
6 changed files
with
158 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
from . import kernel | ||
from . import notation | ||
from . import tactics | ||
|
||
lemma = kernel.lemma | ||
axiom = kernel.axiom | ||
define = kernel.define | ||
|
||
QForAll = notation.QForAll | ||
QExists = notation.QExists | ||
|
||
Calc = tactics.Calc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import knuckledragger as kd | ||
import z3 | ||
|
||
|
||
class Calc: | ||
""" | ||
calc is for equational reasoning. | ||
One can write a sequence of formulas interspersed with useful lemmas. | ||
""" | ||
|
||
def __init__(self, vars, lhs): | ||
# TODO: hyps=None for conditional rewriting. assumpt, assume=[] | ||
self.vars = vars | ||
self.terms = [lhs] | ||
self.lemmas = [] | ||
|
||
def ForAll(self, body): | ||
if len(self.vars) == 0: | ||
return body | ||
else: | ||
return z3.ForAll(self.vars, body) | ||
|
||
def eq(self, rhs, by=[]): | ||
self.lemmas.append(kd.lemma(self.ForAll(self.terms[-1] == rhs), by=by)) | ||
self.terms.append(rhs) | ||
return self | ||
|
||
# TODO: lt, le, gt, ge chaining. Or custom op. | ||
|
||
def __repr__(self): | ||
return "... = " + repr(self.terms[-1]) | ||
|
||
def qed(self): | ||
return kd.lemma(self.ForAll(self.terms[0] == self.terms[-1]), by=self.lemmas) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters