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

Alectryon displays local definitions (with set, pose) as declarations #94

Open
Casteran opened this issue Nov 20, 2023 · 3 comments
Open

Comments

@Casteran
Copy link
Collaborator

Casteran commented Nov 20, 2023

In the following proof, alectryon AlectryonIssue.v --backend latex builds a document where the variable z is presented as a simple declaration z: nat and not z := Nat.max x y : nat, which makes the displayed sub-goals apparently unsolvable.

Require Import Arith Lia.

(* begin snippet LProof *)
 Lemma L: forall x y, exists z:nat, x <= z /\ y <= z.
 Proof.  
  intros x y; pose (z := Nat.max x y). 
  exists z. 
  split; lia.
 Qed.  
(* end snippet LProof *)

Indeed, the displayed sub-goal

x, y: nat    z:nat
---------------
x <= z /\ y <= z

is unsolvable, but if the definition z := max x y: nat were displayed, the generated doc would be OK.

I noticed this issue only in Latex output mode. My alectryon version is Alectryon v1.5.0-dev

Note: this issue occurs also in the CI of hydra-battles on the top of page 227 of the doc (file https://github.com/coq-community/hydra-battles/blob/master/theories/ordinals/MoreAck/AckNotPR.v ).

@Casteran
Copy link
Collaborator Author

Casteran commented Nov 22, 2023

Looks to be an issue specific to Latex output generation.
The html file generated by the same snippet is OK w.r.t. the display of local definitions x:= A: t, whilst they appear as x: tin the pdf document.

I didn't test the other output formats.

@Casteran
Copy link
Collaborator Author

Casteran commented Jan 4, 2024

Cc: @cpitclaudel

Here is a simpler example:

(* begin snippet LProof *)
 Lemma L: exists z: bool, negb z = true.
 Proof.  
  pose (z := false). 
  exists z. 
  (* error in latex output : *)
  reflexivity.
 Qed.  
(* end snippet LProof *)

On the html output, the goal just before reflexivity is correctly displayed.
On the latex/pdf output, this goal is printed as:

z: bool
===========
negb z = true

Which is clearly unsolvable.

@Casteran
Copy link
Collaborator Author

Casteran commented Jan 5, 2024

This issue seems to be solved if one replaces in latex.py the method gen_hyp
with

 def gen_hyp(self, hyp):
        names = self.gen_names(hyp.names)
        hbody = [self.gen_code(hyp.body)] if hyp.body else []
        with macros.hyp(args=[names], optargs=hbody, verbatim=True):
           self.gen_code(hyp.type)
           if hyp.body != None:
               self.gen_txt(r":= ")
               self.gen_code(hyp.body)
           self.gen_txt(r" ")
           self.gen_mrefs(hyp)

This change has been tested successfully on the hydra-battles book.
Could someone have a look and improve the python code ?
Being a Python beginner, I didn't dare to open a PR with poor style.

Nevertheless, it would be fine to fix this issue before the next release.

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

No branches or pull requests

1 participant