-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
eo::dt_constructors
and eo::dt_selectors
to inspe…
…ct datatypes and datatype constructors (#87) This adds a way `eo::dt_constructors` to extract the definition of datatypes (their corresponding list of constructors) and `eo::dt_selectors` to extract the definition of datatype constructors (their corresponding list of selectors). It adds an ordinary type `eo::List` that is part of the assumed background signature for this purpose. Also fixes the parser for `declare-datatype` (the singular form of datatypes, which had not been tested).
- Loading branch information
Showing
11 changed files
with
238 additions
and
22 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
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
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,47 @@ | ||
; (declare-type eo::List ()) | ||
; (declare-const eo::List::nil eo::List) | ||
; (declare-const eo::List::cons (-> (! Type :var T :implicit) T eo::List eo::List)) | ||
|
||
(declare-type Int ()) | ||
(declare-datatypes ((Lst 0)) (((cons (head Int) (tail Lst)) (nil)))) | ||
|
||
|
||
|
||
|
||
(declare-const is (-> (! Type :var C :implicit) (! Type :var D :implicit) C D Bool)) | ||
(declare-const or (-> Bool Bool Bool) :right-assoc-nil false) | ||
(declare-const = (-> (! Type :var T :implicit) T T Bool)) | ||
|
||
(program $mk_dt_split ((D Type) (x D) (T Type) (c T) (xs eo::List :list)) | ||
(eo::List D) Bool | ||
( | ||
(($mk_dt_split eo::List::nil x) false) | ||
(($mk_dt_split (eo::List::cons c xs) x) (eo::cons or (is c x) ($mk_dt_split xs x))) | ||
) | ||
) | ||
|
||
(declare-rule dt-split ((D Type) (x D)) | ||
:args (x) | ||
:conclusion ($mk_dt_split (eo::dt_constructors (eo::typeof x)) x) | ||
) | ||
|
||
(declare-const x Lst) | ||
|
||
(step @p0 (or (is cons x) (is nil x)) :rule dt-split :args (x)) | ||
|
||
|
||
(program $mk_dt_inst ((D Type) (x D) (T Type) (t T) (S Type) (s S) (xs eo::List :list)) | ||
(eo::List D T) Bool | ||
( | ||
(($mk_dt_inst eo::List::nil x t) t) | ||
(($mk_dt_inst (eo::List::cons s xs) x t) ($mk_dt_inst xs x (t (s x)))) | ||
) | ||
) | ||
|
||
(declare-rule dt-inst ((D Type) (T Type) (c T) (x D)) | ||
:args (c x) | ||
:conclusion (= (is c x) (= x ($mk_dt_inst (eo::dt_selectors c) x c))) | ||
) | ||
|
||
(step @p1 (= (is cons x) (= x (cons (head x) (tail x)))) :rule dt-inst :args (cons x)) | ||
(step @p1 (= (is nil x) (= x nil)) :rule dt-inst :args (nil x)) |
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 @@ | ||
(declare-datatype a ((b))) |
Oops, something went wrong.