-
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
79d3bcf
commit 29b1563
Showing
6 changed files
with
101 additions
and
31 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
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,26 @@ | ||
import kdrag.smt as smt | ||
import kdrag as kd | ||
|
||
|
||
def induct(DT: smt.DatatypeSortRef) -> kd.Proof: | ||
"""Build a basic induction principle for an algebraic datatype""" | ||
P = smt.FreshConst(smt.ArraySort(DT, smt.BoolSort()), prefix="P") | ||
hyps = [] | ||
for i in range(DT.num_constructors()): | ||
constructor = DT.constructor(i) | ||
args = [ | ||
smt.FreshConst(constructor.domain(j), prefix="a") | ||
for j in range(constructor.arity()) | ||
] | ||
acc = P[constructor(*args)] | ||
for arg in args: | ||
if arg.sort() == DT: | ||
acc = kd.QForAll([arg], P[arg], acc) | ||
else: | ||
acc = kd.QForAll([arg], acc) | ||
hyps.append(acc) | ||
x = smt.FreshConst(DT, prefix="x") | ||
conc = kd.QForAll([x], P[x]) | ||
return kd.axiom( | ||
smt.ForAll([P], smt.Implies(smt.And(hyps), conc)), by="induction_axiom" | ||
) |
File renamed without changes.
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