-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
4 changed files
with
61 additions
and
48 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,28 +1,28 @@ | ||
;; Loop Invariant | ||
|
||
;; bool: whether the term in the Expr is an invariant. | ||
(function is-inv-Expr (Expr Expr) bool :unextractable :merge (or old new)) | ||
(function is-inv-ListExpr (Expr ListExpr) bool :unextractable :merge (or old new)) | ||
(function is-inv-Expr (IdSort Expr) bool :unextractable :merge (or old new)) | ||
(function is-inv-ListExpr (IdSort ListExpr) bool :unextractable :merge (or old new)) | ||
|
||
(relation arg-inv (Expr i64)) | ||
(relation arg-inv (IdSort i64)) | ||
|
||
;; in default, when there is a find, set is-inv to false | ||
(rule ((BodyContainsExpr loop term) (= loop (Loop id in pred_out))) ((set (is-inv-Expr loop term) false)) :ruleset always-run) | ||
(rule ((BodyContainsListExpr loop term) (= loop (Loop id in pred_out))) ((set (is-inv-ListExpr loop term) false)) :ruleset always-run) | ||
(rule ((BodyContainsExpr loop_id term) (Loop loop_id in pred_out)) ((set (is-inv-Expr loop_id term) false)) :ruleset always-run) | ||
(rule ((BodyContainsListExpr loop_id term) (Loop loop_id in pred_out)) ((set (is-inv-ListExpr loop_id term) false)) :ruleset always-run) | ||
|
||
;; I assume input is tuple here | ||
(rule ((= loop (Loop id inputs outputs)) | ||
(= (Get (Arg id) i) (get-loop-outputs-ith loop i))) | ||
((arg-inv loop i)) :ruleset always-run) | ||
(= (Get (Arg id) i) (get-loop-outputs-ith id i))) | ||
((arg-inv id i)) :ruleset always-run) | ||
|
||
(relation is-inv-ListExpr-helper (Expr ListExpr i64)) | ||
(rule ((BodyContainsListExpr loop list)) ((is-inv-ListExpr-helper loop list 0)) :ruleset always-run) | ||
(relation is-inv-ListExpr-helper (IdSort ListExpr i64)) | ||
(rule ((BodyContainsListExpr loop_id list) (Loop loop_id in out)) ((is-inv-ListExpr-helper loop_id list 0)) :ruleset always-run) | ||
|
||
(rule ((is-inv-ListExpr-helper loop list i) | ||
(= true (is-inv-Expr loop expr)) | ||
(rule ((is-inv-ListExpr-helper loop_id list i) | ||
(= true (is-inv-Expr loop_id expr)) | ||
(= expr (ListExpr-ith list i))) | ||
((is-inv-ListExpr-helper loop list (+ i 1))) :ruleset always-run) | ||
((is-inv-ListExpr-helper loop_id list (+ i 1))) :ruleset always-run) | ||
|
||
(rule ((is-inv-ListExpr-helper loop list i) | ||
(rule ((is-inv-ListExpr-helper loop_id list i) | ||
(= i (ListExpr-length list))) | ||
((set (is-inv-ListExpr loop list) true)) :ruleset always-run) | ||
((set (is-inv-ListExpr loop_id list) true)) :ruleset always-run) |
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