Repository navigation
refactor(FOL): derive Repr and add ToString for the syntax types - #40
Merged
Merged
Conversation
Variable, Term and Formula now derive Repr, so #eval shows the constructor tree, and their notation moves from a hand-written Repr over Std.Format to ToString instances, so toString shows the formula. This is the pattern InfEngine and ModelChecking already follow, and it lets a chapter show both views of the same formula. ToString, its behaviour under #eval and s! strings are presented at their first use, with Variable, and the ledger moves them from InfEngine to Logic/FOL. This change was prepared with the assistance of Claude Code (Anthropic); all edits were reviewed by the author.
`$` appears nowhere else in the book; `<|` is the idiomatic Lean form and IntroL already uses it. Record `<|` in the ledger under IntroL. This change was prepared with the assistance of Claude Code (Anthropic); all edits were reviewed by the author.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Only a minor presentation-before-use convention issue remains; no blocking defects were identified.
1 open issue
What changed in this PR
Separates FOL syntax-tree output from readable logical notation, supporting the planned ModelChecking examples.
Changes:
- Derives
Reprand addsToStringprinters for FOL syntax types. - Explains both display modes and updates the feature ledger.
- Adjusts ModelChecking prose and removes a redundant signature display.
| File | Description |
|---|---|
| STYLE-CODE.md | Updates first-use entries for printing features. |
| CSwL/ModelChecking.lean | Updates the display example and removes the signature display. |
| CSwL/Logic/FOL.lean | Separates structural and notation printing, with explanatory examples. |
Review effort: Balanced
|
|
||
| ```lean | ||
| #eval Variable.mk "x" [1] | ||
| #eval toString $ Variable.mk "x" [1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Logic/FOLwas the one chapter whose syntax types printed through a hand-writtenReproverStd.Format, so#evalof a formula showed its notation and there was no way to see its structure.InfEngineandModelCheckingalready follow the other pattern:deriving Reprfor the constructor tree, plus aToStringinstance for the notation.This moves
Variable,TermandFormulato that pattern:deriving Repron the three types;#eval fshows the tree.Variable.format,Term.formatandFormula.formatbecometoTextfunctions toString, withToStringinstances;toString fgives the same notation as before (∀x R[x, x]).ToString, how#evalchooses betweenReprandToString, ands!strings are presented at their first use, withVariable; theFormulaparagraph becomes a short reminder.STYLE-CODE.mdmovesToStringands!strings fromInfEnginetoLogic/FOLand dropsStd.Format.InfEngineusedToStringwithout presenting it, so this also closes that gap.ModelChecking:#eval toString (lfSent tr1)in the prose, and thelfDETsignature display is dropped.Needed by the step-by-step example from syntax tree to formula that is being added to
ModelChecking(#15), which shows both views of the same formula.Verified locally:
make allbuilds the four variants (thesolutionsproject compiles standalone).This change was prepared with the assistance of Claude Code (Anthropic); all edits were reviewed by the author.