Skip to content
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

Add nicer names in derive.param2 #761

Merged
merged 1 commit into from
Jan 30, 2025
Merged

Conversation

proux01
Copy link
Contributor

@proux01 proux01 commented Jan 29, 2025

n1, n2 and n_R are more readable than H, H0 and H1

@proux01 proux01 force-pushed the param2-nicer-names branch from e14e504 to 50249eb Compare January 29, 2025 07:48
@proux01
Copy link
Contributor Author

proux01 commented Jan 29, 2025

From elpi.apps Require Import derive.std.

Elpi derive.param2 list.
Print list_R. (*                                                                                                                                                                          
* before                                                                                                                                                                                  
Inductive list_R (A A0 : Type) (A1 : A -> A0 -> Type) : list A -> list A0 -> Type :=                                                                                                      
  | nil_R : list_R A A0 A1 nil nil                                                                                                                                                        
  | cons_R : forall (H : A) (H0 : A0), A1 H H0 ->                                                                                                                                         
             forall (H1 : list A) (H2 : list A0), list_R A A0 A1 H1 H2 ->                                                                                                                 
             list_R A A0 A1 (H :: H1) (H0 :: H2).                                                                                                                                         
Arguments list_R (A A)%type_scope A%function_scope (s1 s2)%list_scope                                                                                                                     
Arguments nil_R (A A)%type_scope A%function_scope                                                                                                                                         
Arguments cons_R (A A)%type_scope A%function_scope _ _ _ (_ _)%list_scope _                                                                                                               
                                                                                                                                                                                          
* after                                                                                                                                                                                   
Inductive list_R (A1 A2 : Type) (A_R : A1 -> A2 -> Type) : list A1 -> list A2 -> Type :=                                                                                                  
  | nil_R : list_R A1 A2 A_R nil nil                                                                                                                                                      
  | cons_R : forall (a1 : A1) (a2 : A2), A_R a1 a2 ->                                                                                                                                     
             forall (l1 : list A1) (l2 : list A2), list_R A1 A2 A_R l1 l2 ->                                                                                                              
             list_R A1 A2 A_R (a1 :: l1) (a2 :: l2).                                                                                                                                      
Arguments list_R (A1 A2)%type_scope A_R%function_scope (s1 s2)%list_scope                                                                                                                 
Arguments nil_R (A1 A2)%type_scope A_R%function_scope                                                                                                                                     
Arguments cons_R (A1 A2)%type_scope A_R%function_scope a1 a2 a_R (l1 l2)%list_scope l_R                                                                                                   
*)

Definition fa (n : nat) (b : bool) := 0.

Elpi derive.param2 fa.
Print fa_R. (*                                                                                                                                                                            
* before                                                                                                                                                                                  
fa_R = fun (n n0 : nat) (_ : nat_R n n0) (b b0 : bool) (_ : bool_R b b0) => O_R                                                                                                           
Arguments fa_R (n n)%nat_scope n (b b)%bool_scope b                                                                                                                                       
                                                                                                                                                                                          
* after                                                                                                                                                                                   
fa_R = fun (n1 n2 : nat) (_ : nat_R n1 n2) (b1 b2 : bool) (_ : bool_R b1 b2) => O_R                                                                                                       
Arguments fa_R (n1 n2)%nat_scope n_R (b1 b2)%bool_scope b_R                                                                                                                               
*)

apps/derive/elpi/param2.elpi Outdated Show resolved Hide resolved
@proux01 proux01 force-pushed the param2-nicer-names branch from 50249eb to 31b79cc Compare January 29, 2025 16:16
n1, n2 and n_R are more readable than n, n0 and n1

```Coq
From elpi.apps Require Import derive.std.

Elpi derive.param2 list.
Print list_R. (*
* before
Inductive list_R (A A0 : Type) (A1 : A -> A0 -> Type) : list A -> list A0 -> Type :=
  | nil_R : list_R A A0 A1 nil nil
  | cons_R : forall (H : A) (H0 : A0), A1 H H0 ->
             forall (H1 : list A) (H2 : list A0), list_R A A0 A1 H1 H2 ->
             list_R A A0 A1 (H :: H1) (H0 :: H2).
Arguments list_R (A A)%type_scope A%function_scope (s1 s2)%list_scope
Arguments nil_R (A A)%type_scope A%function_scope
Arguments cons_R (A A)%type_scope A%function_scope _ _ _ (_ _)%list_scope _

* after
Inductive list_R (A1 A2 : Type) (A_R : A1 -> A2 -> Type) : list A1 -> list A2 -> Type :=
  | nil_R : list_R A1 A2 A_R nil nil
  | cons_R : forall (a1 : A1) (a2 : A2), A_R a1 a2 ->
             forall (l1 : list A1) (l2 : list A2), list_R A1 A2 A_R l1 l2 ->
             list_R A1 A2 A_R (a1 :: l1) (a2 :: l2).
Arguments list_R (A1 A2)%type_scope A_R%function_scope (s1 s2)%list_scope
Arguments nil_R (A1 A2)%type_scope A_R%function_scope
Arguments cons_R (A1 A2)%type_scope A_R%function_scope a1 a2 a_R (l1 l2)%list_scope l_R
*)

Definition fa (n : nat) (b : bool) := 0.

Elpi derive.param2 fa.
Print fa_R. (*
* before
fa_R = fun (n n0 : nat) (_ : nat_R n n0) (b b0 : bool) (_ : bool_R b b0) => O_R
Arguments fa_R (n n)%nat_scope n (b b)%bool_scope b

* after
fa_R = fun (n1 n2 : nat) (_ : nat_R n1 n2) (b1 b2 : bool) (_ : bool_R b1 b2) => O_R
Arguments fa_R (n1 n2)%nat_scope n_R (b1 b2)%bool_scope b_R
*)
```
@proux01 proux01 force-pushed the param2-nicer-names branch from 31b79cc to 2495e53 Compare January 30, 2025 09:06
@gares gares merged commit 8335cf9 into LPCIC:master Jan 30, 2025
74 checks passed
@proux01
Copy link
Contributor Author

proux01 commented Jan 31, 2025

Thanks

@proux01 proux01 deleted the param2-nicer-names branch January 31, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants