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

Support printing rules in LaTeX #474

Merged
merged 9 commits into from
Sep 4, 2024
Merged

Support printing rules in LaTeX #474

merged 9 commits into from
Sep 4, 2024

Conversation

eyihluyc
Copy link
Member

@eyihluyc eyihluyc commented Aug 16, 2024

Issue: #471

This PR adds printing rules in LaTeX format.

Usage:

normalizer print-rules --tex -r filename
  • --tex flag is optional,
  • if path to rules is not specified, yegor.yaml is used.

PR-Codex overview

This PR introduces a new feature to print rules in LaTeX format, enhances command line options, updates documentation, and adds new imports.

Detailed summary

  • Added the ability to print rules in LaTeX format
  • Updated command line options for printing rules
  • Modified documentation files
  • Added new imports for rule processing

The following files were skipped due to too many changes: eo-phi-normalizer/src/Language/EO/Phi/ToLaTeX.hs, eo-phi-normalizer/test/eo/phi/rules/yegor.yaml, site/docs/src/normalizer/print-rules.md

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@eyihluyc eyihluyc requested review from fizruk and deemp August 16, 2024 07:42
@eyihluyc
Copy link
Member Author

There are two versions now:

  1. When conditions are listed on new lines
image
\begin{figure*}
\begin{tabular}{rl}
  \rrule{Phi}: & $ Q $ \(\trans\) $ b $ \\\text {if }& $ Q -> b $ \\&not in subformations\\\\
  \rrule{xi}: & $ \xi $ \(\trans\) $ b $ \\\text {if }& $ b $  is the scope of the redex\\&not in subformations\\\\
  \rrule{DOT}: & $ [[ \tau -> b, B ]].\tau $ \(\trans\) $ \mathbb{S}(b, [[ \tau -> b, B ]]) $ \\\text {if }&not in subformations,\\& $ b $  is nf inside formation,\\& $ [[ B ]]\in\mathcal{N} $ ,\\& $ \tau \neq ^ $ \\\\
  \rrule{DOTrho}: & $ [[ ^ -> b, B ]].^ $ \(\trans\) $ b $ \\\text {if }& $ [[ B ]]\in\mathcal{N} $ \\\\
  \rrule{phi}: & $ [[ B ]].\tau $ \(\trans\) $ [[ B ]].@.\tau $ \\\text {if }& $ @ \in B $ ,\\& $ \tau \notin B $ \\\\
  \rrule{COPY}: & $ [[ \tau -> ?, B1 ]]( \tau -> b1, B2 ) $ \(\trans\) $ [[ \tau -> \mathbb{S}(b1, b2), B1 ]]( B2 ) $ \\\text {if }& $ b2 $  is the scope of the redex\\&not in subformations,\\& $ b1\in\mathcal{N} $ \\\\
  \rrule{COPY1}: & $ [[ \tau -> ?, B ]]( 0-> b1 ) $ \(\trans\) $ [[ \tau -> \mathbb{S}(b1, b2), B ]] $ \\\text {if }& $ b2 $  is the scope of the redex\\&not in subformations,\\& $ b1\in\mathcal{N} $ \\\\
  \rrule{COPY2}: & $ [[ \tau1 -> ?, \tau2 -> ?, B ]]( 0-> b1, 1-> b2 ) $ \(\trans\) $ [[ \tau1 -> \mathbb{S}(b1, b3), \tau2 -> \mathbb{S}(b2, b3), B ]] $ \\\text {if }& $ b3 $  is the scope of the redex\\&not in subformations,\\& $ b1\in\mathcal{N} $ ,\\& $ b2\in\mathcal{N} $ \\\\
  \rrule{COPYdelta}: & $ [[ D> ?, B ]]( D> y ) $ \(\trans\) $ [[ D> y, B ]] $ \\\text {if }&not in subformations\\\\
  \rrule{EMPTY}: & $ [[ B1 ]](  ) $ \(\trans\) $ [[ B1 ]] $ \\\\
  \rrule{OVER}: & $ [[ \tau -> b1, B1 ]]( \tau -> b2, B2 ) $ \(\trans\) $ \dead $ \\\\
  \rrule{STOP}: & $ [[ B ]].\tau $ \(\trans\) $ \dead $ \\\text {if }& $ \tau, @, \lambda \notin B $ ,\\& $ [[ B ]]\in\mathcal{N} $ \\\\
  \rrule{MISS}: & $ [[ B1 ]]( \tau -> b, B2 ) $ \(\trans\) $ \dead $ \\\text {if }& $ \tau, @, \lambda \notin B1 $ \\\\
  \rrule{DD}: & $ \dead.\tau $ \(\trans\) $ \dead $ \\\\
  \rrule{DC}: & $ \dead( B ) $ \(\trans\) $ \dead $ \\\\
\end{tabular}
\end{figure*}
  1. When the whole rule is one line (but this one is commented out)
image
\begin{figure*}
  \rrule{Phi}:  $ Q $ \(\trans\) $ b $ \quad\text {if } $ Q -> b $ , not in subformations\\\vspace*{0.5em}
  \rrule{xi}:  $ \xi $ \(\trans\) $ b $ \quad\text {if } $ b $  is the scope of the redex, not in subformations\\\vspace*{0.5em}
  \rrule{DOT}:  $ [[ \tau -> b, B ]].\tau $ \(\trans\) $ \mathbb{S}(b, [[ \tau -> b, B ]]) $ \quad\text {if }not in subformations,  $ b $  is nf inside formation,  $ [[ B ]]\in\mathcal{N} $ ,  $ \tau \neq ^ $ \\\vspace*{0.5em}
  \rrule{DOTrho}:  $ [[ ^ -> b, B ]].^ $ \(\trans\) $ b $ \quad\text {if } $ [[ B ]]\in\mathcal{N} $ \\\vspace*{0.5em}
  \rrule{phi}:  $ [[ B ]].\tau $ \(\trans\) $ [[ B ]].@.\tau $ \quad\text {if } $ @ \in B $ ,  $ \tau \notin B $ \\\vspace*{0.5em}
  \rrule{COPY}:  $ [[ \tau -> ?, B1 ]]( \tau -> b1, B2 ) $ \(\trans\) $ [[ \tau -> \mathbb{S}(b1, b2), B1 ]]( B2 ) $ \quad\text {if } $ b2 $  is the scope of the redex, not in subformations,  $ b1\in\mathcal{N} $ \\\vspace*{0.5em}
  \rrule{COPY1}:  $ [[ \tau -> ?, B ]]( 0-> b1 ) $ \(\trans\) $ [[ \tau -> \mathbb{S}(b1, b2), B ]] $ \quad\text {if } $ b2 $  is the scope of the redex, not in subformations,  $ b1\in\mathcal{N} $ \\\vspace*{0.5em}
  \rrule{COPY2}:  $ [[ \tau1 -> ?, \tau2 -> ?, B ]]( 0-> b1, 1-> b2 ) $ \(\trans\) $ [[ \tau1 -> \mathbb{S}(b1, b3), \tau2 -> \mathbb{S}(b2, b3), B ]] $ \quad\text {if } $ b3 $  is the scope of the redex, not in subformations,  $ b1\in\mathcal{N} $ ,  $ b2\in\mathcal{N} $ \\\vspace*{0.5em}
  \rrule{COPYdelta}:  $ [[ D> ?, B ]]( D> y ) $ \(\trans\) $ [[ D> y, B ]] $ \quad\text {if }not in subformations\\\vspace*{0.5em}
  \rrule{EMPTY}:  $ [[ B1 ]](  ) $ \(\trans\) $ [[ B1 ]] $ \\\vspace*{0.5em}
  \rrule{OVER}:  $ [[ \tau -> b1, B1 ]]( \tau -> b2, B2 ) $ \(\trans\) $ \dead $ \\\vspace*{0.5em}
  \rrule{STOP}:  $ [[ B ]].\tau $ \(\trans\) $ \dead $ \quad\text {if } $ \tau, @, \lambda \notin B $ ,  $ [[ B ]]\in\mathcal{N} $ \\\vspace*{0.5em}
  \rrule{MISS}:  $ [[ B1 ]]( \tau -> b, B2 ) $ \(\trans\) $ \dead $ \quad\text {if } $ \tau, @, \lambda \notin B1 $ \\\vspace*{0.5em}
  \rrule{DD}:  $ \dead.\tau $ \(\trans\) $ \dead $ \\\vspace*{0.5em}
  \rrule{DC}:  $ \dead( B ) $ \(\trans\) $ \dead $ \\\vspace*{0.5em}
\end{figure*}

@deemp
Copy link
Member

deemp commented Aug 16, 2024

@yegor256, which version(s) should normalizer support?

@yegor256
Copy link
Member

@deemp the second one, please

@deemp
Copy link
Member

deemp commented Aug 17, 2024

@yegor256, I believe normalizer may support both versions since both versions are implemented.

I suggest to introduce the compact (short version is c) flag that will determine the version.

  • normalizer print-rules --tex -r filename prints the first version.
  • normalizer print-rules --tex --compact -r filename prints the second version.

@eyihluyc, @yegor256, WDYT?

@yegor256
Copy link
Member

@deemp sounds good to me

@fizruk
Copy link
Collaborator

fizruk commented Aug 23, 2024

@eyihluyc can you please look into the failing tests?

@deemp
Copy link
Member

deemp commented Aug 23, 2024

@eyihluyc, please document this new command and its options in a new site file.

  1. Create site/docs/src/normalizer/print-rules.md.
  2. Update the ToC in normalizer/site/docs/src/SUMMARY.md
  3. Write in print-rules.md about the command and its options.
  4. Demonstrate the output of the command with different options. The output will be generated by mdsh in CI if you insert blocks like this.
```$ as latex
normalizer print-rules --tex -r filename
```


The compact version prints rules listing all conditions on a single line:

```console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use $ as tex instead of console to make mdsh generate output for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так? a74fb3e


### Default version

```console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deemp
Copy link
Member

deemp commented Aug 29, 2024

@eyihluyc, if you use nix, insert here a line for normalizer/print-rules.md. Next, run nix run .#update-markdown. This command will run mdsh on the print-rules.md file, generate scripts/update-markdown.sh and update other Markdown files.

Otherwise, insert a line for normalizer/print-rules.md both here and here, so that the script update-markdown.sh is in sync with the flake script update-markdown. Then, run scripts/update-markdown.sh.

@deemp deemp merged commit 9a640e9 into master Sep 4, 2024
@0crat
Copy link

0crat commented Sep 4, 2024

@fizruk Great job on the review! 🎉 You've earned an impressive +11 points: +4 base points and +7 for reviewing 716 hits-of-code. Your dedication is paying off, as your balance now stands at +29. Keep up the excellent work!

@0crat
Copy link

0crat commented Sep 4, 2024

@eyihluyc Thank you for your contribution! We appreciate your effort, but there are a few points to consider. Your submission of 495 hits-of-code exceeds our 200 limit, resulting in an 8-point deduction. However, you've earned 4 base points for your contribution. Your final score for this submission is -4 points. Remember to keep your contributions concise and focused. Your updated running balance is -10. We look forward to your future contributions!

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.

5 participants