Version
8.8.0
Operating system
Linux
Description of the problem
Defining mutually recursive fixpoints as instances of definitional/singleton type classes is a little awkward right now. The following is an example that illustrates the problem.
Inductive bexp : Set :=
| b_true : bexp
| b_false : bexp
| b_eq : aexp -> aexp -> bexp
with aexp : Set :=
| a_of_bool : bexp -> aexp.
Class ContainsFalse (A : Set) :=
contains_false : A -> bool.
Fixpoint bexp_ContainsFalse (b : bexp) :=
match b with
| b_true => false
| b_false => true
| b_eq a1 a2 => orb
(@contains_false aexp aexp_ContainsFalse a1)
(@contains_false aexp aexp_ContainsFalse a2)
end with
aexp_ContainsFalse (a : aexp) :=
match a with
| a_of_bool b => (@contains_false bexp bexp_ContainsFalse b)
end.
Instance BexpContainsFalse : ContainsFalse bexp := bexp_ContainsFalse.
Instance AexpContainsFalse : ContainsFalse aexp := aexp_ContainsFalse.
In the above code there are two awkward patterns. Firstly, I had to manually pass implicit parameters to contains_false, since I couldn't declare the instances a priori. Secondly, I had to rebind bexp_ContainsFalse and aexp_ContainsFalse to BexpContainsFalse and AexpContainsFalse so that I could declare them as instances.
Ideally I should be able to define instances with something like the following:
Fixpoint BexpContainsFalse (b : bexp) :=
match b with
| b_true => false
| b_false => true
| b_eq a1 a2 => orb (contains_false a1) (contains_false a2)
end with
AexpContainsFalse (a : aexp) :=
match a with
| a_of_bool b => (contains_false b)
end
with Instance BexpContainsFalse : ContainsFalse bexp
with Instance AexpContainsFalse : ContainsFalse aexp.
Could we extend coq's syntax for Fixpoint or Instance to support recursive singleton instances?
Version
8.8.0
Operating system
Linux
Description of the problem
Defining mutually recursive fixpoints as instances of definitional/singleton type classes is a little awkward right now. The following is an example that illustrates the problem.
In the above code there are two awkward patterns. Firstly, I had to manually pass implicit parameters to
contains_false, since I couldn't declare the instances a priori. Secondly, I had to rebindbexp_ContainsFalseandaexp_ContainsFalsetoBexpContainsFalseandAexpContainsFalseso that I could declare them as instances.Ideally I should be able to define instances with something like the following:
Could we extend coq's syntax for
FixpointorInstanceto support recursive singleton instances?