-
Notifications
You must be signed in to change notification settings - Fork 62
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
Get Coq extraction working with the latest Coq version #1601
Comments
What version of Coq are you having problems with? It works for me with Coq 8.13.2. |
Yeah, actually, it seems to be working for me with Coq 8.13.1 now too. I think maybe the problem was originally that the coq-bits library didn't yet support Coq versions past 8.12, but they put out a new version that supports through 8.14. So... maybe we should close this? |
I finally had a chance to try building
|
They must have changed something about how typeclass resolution is performed. It seems like that beta-redex in the argument to |
I now have a slightly better understanding on what is happening here. Here is a minimized example: Definition F : bool -> Type -> Type :=
fun b x =>
if b then x else x.
Class Inhabited (a:Type) := MkInhabited { inhabitant : a }.
Global Hint Extern 5 (Inhabited ?A) =>
(apply (@MkInhabited A); intuition (eauto with typeclass_instances inh)) : typeclass_instances.
Instance Inhabited_unit : Inhabited unit :=
MkInhabited unit tt.
Instance Inhabited_F (b : bool) (a : Type) (Ha : Inhabited a) : Inhabited (F b a) :=
MkInhabited
(F b a)
(match b with
| true => inhabitant
| false => inhabitant
end).
Definition hm : forall (p : bool -> Type), forall {Inh_p : forall (_1 : bool), Inhabited (p _1)}, p true :=
fun _ _ => inhabitant.
Definition onlyWorksOnOldCoq : unit :=
hm (fun b : bool => F b unit).
The nuclear option would be to give up on Coq 8.14 entirely. A slightly less extreme idea would be to tweak the way Instead of relying on a Ltac inhabit :=
apply @MkInhabited; intuition (eauto with typeclass_instances inh). For most definitions, the Inductive Simple (b : bool) := MkSimple : Simple b.
Instance Inhabited_Simple (b : bool) : Inhabited (Simple b).
Proof. inhabit. Qed.
Definition test_Inhabited_Simple : Simple true :=
hm (fun b : bool => Simple b). Since much of |
Well, yuck. It does seem kind of ridiculous to autogenerate instances just to support a single version of Coq, especially because there have been two major versions of Coq put out since then. It seems like we would do much better to put effort into supporting those newer versions of Coq, which we will want to do anyway at some point. On that note, I tried to contact Anton Trunov, the maintainer of the coq-bits package, to ask if he plans to upgrade it to more recent versions of Coq, but I couldn't quite track down his contact info, though maybe I was too dumb to figure it out and someone else could give it a try? Otherwise, we could consider upgrading it ourselves, or maybe even writing our own version, since we have very specific needs and a strong dependency on it. |
I'm inclined to agree. I very briefly tried out my
I think this is his contact info: https://github.com/coq-community/bits/blob/734d8622b546fe4e99d47729d35cf82b591ef47e/coq-bits.opam#L5 |
Awesome, I knew you would be better at finding that contact info. I just sent Anton a note to ask about his intent with the Coq bits library. |
I heard back from Anton Trunov, and he updated coq-bits to work with 8.15 and 8.16: Maybe we could see if the Coq extraction overall works with 8.15 now? |
Thanks, @eddywestbrook!
diff --git a/saw-core-coq/coq/handwritten/CryptolToCoq/SAWCoreVectorsAsCoqVectors.v b/saw-core-coq/coq/handwritten/CryptolToCoq/SAWCoreVectorsAsCoqVectors.v
index a32846b4c..9b610324f 100644
--- a/saw-core-coq/coq/handwritten/CryptolToCoq/SAWCoreVectorsAsCoqVectors.v
+++ b/saw-core-coq/coq/handwritten/CryptolToCoq/SAWCoreVectorsAsCoqVectors.v
@@ -230,7 +230,7 @@ Definition sbvToInt (n : Nat) (b : bitvector n) : Z
(* Useful notation for bools *)
Definition boolToInt (b : bool) : Z := if b then 1%Z else 0%Z.
-Numeral Notation bool Z.odd boolToInt : bool_scope.
+Number Notation bool Z.odd boolToInt : bool_scope.
Close Scope bool_scope. (* no, don't interpret all numbers as booleans... *)
(* This is annoying to implement, so using BITS conversion *) If I'm reading the 8.15 changelog correctly, |
This requires a small change from `Numeral Notation` notation to `Number Notation`, the former of which was removed in Coq 8.15. The latter is only supported in Coq 8.13 or later, so I have documented this in the `saw-core-coq` `README`. Fixes #1601.
This requires a small change from `Numeral Notation` notation to `Number Notation`, the former of which was removed in Coq 8.15. The latter is only supported in Coq 8.13 or later, so I have documented this in the `saw-core-coq` `README`. Fixes #1601. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Right now, the
saw-core-coq
Coq extraction does not work with the latest version of Coq. Instead, the README in that directory suggests using Coq version 8.12. I don't remember exactly whether the issue is that generated Coq files do not work with the newer version of Coq or that the existing handwritten Coq library files do not work, but either way this should be fixed.The text was updated successfully, but these errors were encountered: