Skip to content

satore: fix crash rendering a bare Var in literal->tptp-string - #740

Open
PratikDhanave wants to merge 1 commit into
google-deepmind:masterfrom
PratikDhanaveFork:fix/satore-tptp-var-rendering
Open

satore: fix crash rendering a bare Var in literal->tptp-string#740
PratikDhanave wants to merge 1 commit into
google-deepmind:masterfrom
PratikDhanaveFork:fix/satore-tptp-var-rendering

Conversation

@PratikDhanave

Copy link
Copy Markdown

Summary

The Var? branch of literal->tptp-string (satore/tptp.rkt) crashes when handed a bare variable.

[(Var? lit) (symbol->string (Var-name->symbol lit))]   ; passes the whole struct

Var-name->symbol (unification.rkt) is documented as exact-nonnegative-integer? -> symbol? and its else clause errors on anything that is not a number or symbol-variable. The Var? guard has already established lit is a Var struct, so its name must be extracted first.

Concrete failure:

(literal->tptp-string (Var 5))
; expected: "F"   (name 5 -> A,B,C,D,E,F)
; actual:   error  "Var-name->symbol: Don't know what to do with #s(Var 5)"

Fix — extract the name, matching every other caller (Vars->symbols, the tests):

[(Var? lit) (symbol->string (Var-name->symbol (Var-name lit)))]

The bug is latent in normal use because clause->tptp-string runs its input through Vars->symbols first (which turns every Var into a symbol), so the Var? branch is only reached on a direct call.

Testing

Verified by static tracing of Var-name->symbol and the Var struct accessor. Reviewers can validate via raco test satore/tests/.

The `Var?` branch of `literal->tptp-string` passed the whole `Var` struct to
`Var-name->symbol`, but that function expects a Var *name* (a number, per its
`exact-nonnegative-integer? -> symbol?` contract) and its `else` clause errors
on anything else. So `(literal->tptp-string (Var 5))` raised
"Var-name->symbol: Don't know what to do with #s(Var 5)" instead of returning
"F".

Extract the name first with `(Var-name lit)`, matching every other caller
(`Vars->symbols`, the tests). The bug was latent because `clause->tptp-string`
pre-converts Vars to symbols via `Vars->symbols`, so this branch is only
reachable on a direct call.
@polarbe

polarbe commented Jul 25, 2026 via email

Copy link
Copy Markdown

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.

2 participants