Skip to content

Comments

cryptol-saw-core: Basic FLiteral support#3046

Open
RyanGlScott wants to merge 1 commit intomasterfrom
T3045-basic-FLiteral-support
Open

cryptol-saw-core: Basic FLiteral support#3046
RyanGlScott wants to merge 1 commit intomasterfrom
T3045-basic-FLiteral-support

Conversation

@RyanGlScott
Copy link
Contributor

@RyanGlScott RyanGlScott commented Feb 16, 2026

Fixes #3045.

@RyanGlScott RyanGlScott self-assigned this Feb 16, 2026
@RyanGlScott RyanGlScott added the subsystem: cryptol-saw-core Issues related to Cryptol -> saw-core translation with cryptol-saw-core label Feb 16, 2026
@RyanGlScott
Copy link
Contributor Author

Oops, I forgot to add an implementation of PFLiteral for TCFloat (mirroring PLiteralFloat). I'll do that shortly.

@RyanGlScott RyanGlScott force-pushed the T3045-basic-FLiteral-support branch from 6544981 to 6a136fd Compare February 16, 2026 19:44
Comment on lines 1243 to 1244
PFLiteral : (a : sort 0) -> sort 0;
PFLiteral _ = #();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to put all four arguments in? Unless it comes unstuck that seems preferable when someone goes to actually implement it...

Copy link
Contributor

Choose a reason for hiding this comment

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

(also, what do the arguments mean? the only documentation I can find is GaloisInc/cryptol#1654, which isn't very explicit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally punted on making PFLiteral actually use the arguments, since other parts of SAW will choke on Rational/Float values anyway. But fair enough, I might as well fill this part in while I'm in the neighborhood. I've pushed a new version of the PR which does this.

(also, what do the arguments mean? the only documentation I can find is GaloisInc/cryptol#1654, which isn't very explicit)

These are explained in the docstring for the FLiteral class (here).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@RyanGlScott RyanGlScott force-pushed the T3045-basic-FLiteral-support branch 2 times, most recently from 54f250a to f3a5c67 Compare February 20, 2026 14:40
Comment on lines +340 to +342
C.PFLiteral -> -- we omit the first three arguments to class FLiteral
do a <- go (tyargs !! 3)
scGlobalApply sc "Cryptol.PFLiteral" [a]
Copy link
Contributor

Choose a reason for hiding this comment

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

also I don't think this is right any more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is correct. The type of PFLiteral is still sort 0 -> sort 0, so we only need to supply it with a single argument. The remaining three arguments (m, n, and r) are only used when actually invoking a PFLiteral dictionary to construct a fractional value, as seen in the implementations of things like PFLiteralRational.

@RyanGlScott RyanGlScott force-pushed the T3045-basic-FLiteral-support branch from f3a5c67 to 00ac6f5 Compare February 21, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

subsystem: cryptol-saw-core Issues related to Cryptol -> saw-core translation with cryptol-saw-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cryptol-saw-core: Fractional literals are given incorrect SAWCore types

2 participants