-
Notifications
You must be signed in to change notification settings - Fork 8
Add env var to disable typing of formulas during entailment checking #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eb79d56
create dynamic typing module
danbaterisna e8c8567
fail non-term substs when given a non-var
danbaterisna 0f39bb5
add dynamic typing switch in frontend
danbaterisna 289e1e8
instantiate all Any types before SMT check
danbaterisna d2a1e63
suppress Infer_types.Unification_failure during entailment
danbaterisna 117ffb7
add docs
danbaterisna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 +1,8 @@ | ||
| (library | ||
| (name hipcore_typed) | ||
| (public_name heifer.hipcore_typed) | ||
| (modules subst typedhip pretty untypehip retypehip patterns syntax patterns globals rewrite_context variables typed_core_ast) | ||
| (modules subst typedhip pretty untypehip retypehip patterns syntax patterns globals rewrite_context variables typed_core_ast | ||
| dynamic_typing) | ||
| (libraries debug unionFind str utils hipcore) | ||
| (inline_tests) | ||
| (preprocess (pps ppx_expect ppx_deriving.std visitors.ppx))) |
This file contains hidden or 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 @@ | ||
| open Typedhip | ||
|
|
||
| let status = ref false | ||
|
|
||
| let set_dynamic_typing () = status := true | ||
|
|
||
| let dynamic_typing_enabled () = !status | ||
|
|
||
| let spec_visitor f = object | ||
| inherit [_] map_spec | ||
|
|
||
| method! visit_typ _ t = f t | ||
| end | ||
|
|
||
| let type_with_any_spec s = (spec_visitor (fun _ -> Any))#visit_staged_spec () s | ||
|
|
||
| let instantiate_any_types_pi p = (spec_visitor (fun _ -> TVar (Variables.fresh_variable ())))#visit_pi () p | ||
|
|
||
| let check_for_untyped_visitor = object | ||
| inherit [_] reduce_spec | ||
|
|
||
| method zero = false | ||
| method plus = (||) | ||
|
|
||
| method! visit_CShift _ _ _ _ = true | ||
| method! visit_CReset _ _ = true | ||
|
|
||
| method! visit_Shift _ _ _ _ _ _ = true | ||
| method! visit_Reset _ _ = true | ||
| end | ||
|
|
||
| let uses_untyped_extensions_spec s = check_for_untyped_visitor#visit_staged_spec () s | ||
|
|
||
| let uses_untyped_extensions_core c = check_for_untyped_visitor#visit_core_lang () c |
This file contains hidden or 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,24 @@ | ||
| open Typedhip | ||
|
|
||
| (** Enable dynamic typing. This disables all type checks before translation to SMT. | ||
| This does not do anything by itself; relevant areas of the library whose | ||
| behaviors differ between untyped and typed mode must check this flag | ||
| using [dynamic_typing_enabled]. | ||
|
|
||
| For a declaration to be processed in untyped mode, this must be called before | ||
| the declaration is processed. *) | ||
| val set_dynamic_typing : unit -> unit | ||
|
|
||
| val dynamic_typing_enabled : unit -> bool | ||
|
|
||
| (** Replace all types in this specification with [Any]. *) | ||
| val type_with_any_spec : staged_spec -> staged_spec | ||
|
|
||
| (** Replace all [Any] types in this pure formula with fresh type variables. | ||
| Inferring these types can be done using one of the [Infer_types] endpoints. *) | ||
| val instantiate_any_types_pi : pi -> pi | ||
|
|
||
| (* Currently, the only untyped extensions are shift/reset. *) | ||
|
|
||
| val uses_untyped_extensions_spec : staged_spec -> bool | ||
| val uses_untyped_extensions_core : core_lang -> bool |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused about the intended use of this, i.e. how this eases development. Is it to disable the type checking in case there are bugs in it?
If so, why is that related to shift/reset - my understanding is that without NOTYPES, shift/reset will be typed with Anys and will still work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at least according to my interpretation. Even if shift/reset are typed with Anys, there may still be bugs inside the type checker when dealing with those Anys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add to this, there are cases where these Anys prevent the type checker from seeing that two types are equal. Since Any does not propagate, depending on how types are handled later on, it can be a nuisance to have to worry about types when implementing similar future extensions which do not have a simple-to-implement type system (since otherwise, rewriting rules do not match due to type mismatches, etc.)