-
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.
refactored cond, recrusive well formed in record, Lemma forward tactic
- Loading branch information
1 parent
4829e90
commit 3a4bf86
Showing
6 changed files
with
139 additions
and
45 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
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 |
---|---|---|
@@ -1,9 +1,34 @@ | ||
import knuckledragger as kd | ||
import knuckledragger.theories.Real as R | ||
|
||
norm2 = kd.notation.SortDispatch(name="norm2") | ||
dot = kd.notation.SortDispatch(name="dot") | ||
|
||
Vec2 = kd.Record("Vec2", ("x", kd.R), ("y", kd.R)) | ||
u, v = kd.smt.Consts("u v", Vec2) | ||
kd.notation.add.define([u, v], Vec2(u.x + v.x, u.y + v.y)) | ||
kd.notation.sub.define([u, v], Vec2(u.x - v.x, u.y - v.y)) | ||
|
||
norm2 = kd.define("norm2", [u], u.x * u.x + u.y * u.y) | ||
Vec2.vzero = Vec2(0, 0) | ||
Vec2.dot = dot.define([u, v], u.x * v.x + u.y * v.y) | ||
Vec2.norm2 = norm2.define([u], dot(u, u)) | ||
|
||
|
||
Vec2.norm_pos = kd.lemma( | ||
kd.smt.ForAll([u], norm2(u) >= 0), by=[Vec2.norm2.defn, Vec2.dot.defn] | ||
) | ||
Vec2.norm_zero = kd.lemma( | ||
kd.smt.ForAll([u], (norm2(u) == 0) == (u == Vec2.vzero)), | ||
by=[Vec2.norm2.defn, Vec2.dot.defn], | ||
) | ||
|
||
dist = kd.define("dist", [u, v], R.sqrt(norm2(u - v))) | ||
|
||
# Vec2.triangle = norm2(u - v) <= norm2(u) + norm2(v) | ||
|
||
Vec3 = kd.Record("Vec3", ("x", kd.R), ("y", kd.R), ("z", kd.R)) | ||
u, v = kd.smt.Consts("u v", Vec3) | ||
kd.notation.add.define([u, v], Vec3(u.x + v.x, u.y + v.y, u.z + v.z)) | ||
kd.notation.sub.define([u, v], Vec3(u.x - v.x, u.y - v.y, u.z - v.z)) | ||
|
||
norm2.define([u], u.x * u.x + u.y * u.y + u.z * u.z) |
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,2 @@ | ||
import knuckledragger as kd | ||
import knuckledragger.smt as smt |
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