Skip to content

Native characters, reserved builtins and undefined as stub - #9

Merged
rolyp-claude-bot merged 31 commits into
mainfrom
3-names-and-characters
Oct 24, 2026
Merged

rolyp-claude-bot merged 31 commits into
mainfrom
3-names-and-characters

Conversation

@rolyp-claude-bot

@rolyp-claude-bot rolyp-claude-bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

Python_Setup imports Code_Abstract_Char and prints char as a one-character
string, with chr and ord for the abstract constructor and projection, each
character constant as a string literal, and explode and implode as list and
join. Python's builtins are reserved in the generator, so a generated name
no longer shadows int, str, ord or filter in its module; the per-theory
code_reserved lines go. HOL.undefined is an intentionally unimplemented
symbol, printed as a stub without the warning for a function without code
equations.
Following PEP 8, rather than Isabelle's appended letter, so the primitive
type constructors print as int_ and str_ and the option constructor as None_.
.python-version is 3.12, as in pure-py-spec. The generator reads its reserved
builtins from that Python through uv, and pyproject.toml, the README and CI
use the same version.
The reserved keywords come from Python's keyword module, in the same call as
the builtins, leaving out the wildcard _. The names bound by the header of a
generated module are defined once, for both the header printer and the
reserved names.
# Conflicts:
#	code_python.ML
#	test/diff/golden/Python_Examples.Example_no_eqs/Example_no_eqs.py
#	test/quick/Quick_Test.thy
The header function for constants without code equations goes; their uses
and stub functions call the abort helper instead, with the full name of the
constant as message.
Isabelle leaves a constant without code equations only when it is declared
to abort, so every such constant is meant to have no code. The declaration
that exempted undefined from the warning goes with it.
An imported module and a definition share the namespace of a module, so a
definition named after a module of the program is renamed, as for reserved
names, in place of the error. A first pass finds the module names, which
don't depend on the names of definitions.
A constructor replaced by a printing is absent from the program, which the
constructor test now checks, and the arity of a constant with a printing is
the number of arguments the printing requires.
@rolyp-claude-bot
rolyp-claude-bot merged commit c79803f into main Oct 24, 2026
3 checks passed
@rolyp
rolyp deleted the 3-names-and-characters branch October 24, 2026 17:57
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