diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df12e92..5c5b836 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,12 +36,42 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 + # -o python_type_annotations needs the option declared in etc/options, which Isabelle + # only reads for a registered component; the Python session must be built after this, + # or it is compiled without the option and -o has no effect + - name: register component + run: /home/isabelle/Isabelle/bin/isabelle components -u "$PWD" + - name: extract Python code run: /home/isabelle/Isabelle/bin/isabelle build -v -d . -e Python_Examples - name: Run diff test suite run: uv run pytest test/diff/run_test.py + - name: extract Python code with type annotations + run: | + /home/isabelle/Isabelle/bin/isabelle build -v -d . -c -o python_type_annotations -e Python_Examples + grep -q "from __future__ import annotations" examples/python_out/Python_Examples.Example/code/Example.py + + - name: Run diff test suite on annotated code + run: uv run pytest test/diff/run_test.py + + - name: type-check generated code + # each example has its own copy of the library modules, so check them one by one + run: | + status=0 + for d in examples/python_out/*/code; do uv run mypy "$d" || status=1; done + exit $status + + - name: type-check generated code with ty + # ty finds the casts that are there for mypy redundant + run: | + status=0 + for d in examples/python_out/*/code; do + uv run ty check --python-version 3.12 --no-progress --ignore redundant-cast --extra-search-path "$d" "$d" || status=1 + done + exit $status + oracle: runs-on: ubuntu-latest container: @@ -73,6 +103,12 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v6 + # -o python_type_annotations needs the option declared in etc/options, which Isabelle + # only reads for a registered component; the Python session must be built after this, + # or it is compiled without the option and -o has no effect + - name: register component + run: /home/isabelle/Isabelle/bin/isabelle components -u "$PWD" + - name: extract Python code run: ISABELLE_PYTHON=1 /home/isabelle/Isabelle/bin/isabelle build -v -d . -e Python_Test_Slow @@ -80,4 +116,24 @@ jobs: run: | uv run python -m py_compile test/slow/generated_basic/*.py uv run python -m py_compile test/slow/generated_full/*.py + + - name: import check generated code + run: uv run pytest test/slow/run_test.py --tb=line + + - name: extract Python code with type annotations + run: | + /home/isabelle/Isabelle/bin/isabelle build -v -d . -c -o python_type_annotations -e Python_Test_Slow + grep -q "from __future__ import annotations" test/slow/generated_full/Nat.py + + - name: type-check generated code + run: | + uv run mypy test/slow/generated_basic + uv run mypy test/slow/generated_full + + - name: type-check generated code with ty + # ty finds the casts that are there for mypy redundant + run: | + for d in test/slow/generated_basic test/slow/generated_full; do + uv run ty check --python-version 3.12 --no-progress --ignore redundant-cast --extra-search-path "$d" "$d" + done diff --git a/.gitignore b/.gitignore index 3166f8e..3f6dd1f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ python_out/ generated_basic/ generated_full/ __pycache__/ +.mypy_cache/ # Editor backups *.thy~ diff --git a/Makefile b/Makefile index 2142e5a..0f75156 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ ISABELLE = isabelle PYTEST = uv run pytest PYTHON = uv run python3 +# ty finds the casts that are there for mypy redundant +TY = uv run ty check --python-version 3.12 --no-progress --ignore redundant-cast default: build @@ -10,6 +12,7 @@ build-test-slow: test-slow: build-test-slow $(PYTHON) -m py_compile test/slow/generated_basic/*.py $(PYTHON) -m py_compile test/slow/generated_full/*.py + $(PYTEST) test/slow/run_test.py build-test-quick: $(ISABELLE) build -d . -e Python_Test_Quick @@ -17,8 +20,9 @@ build-test-quick: test-quick: $(PYTEST) test/quick/run_test.py +# -c: a changed python_type_annotations does not rebuild the session by itself build-examples: - $(ISABELLE) build -d . -e Python_Examples + $(ISABELLE) build -d . -c -e Python_Examples test-diff: build-examples $(PYTEST) test/diff/run_test.py @@ -29,9 +33,26 @@ build-test-oracle: test-oracle: build-test-oracle $(PYTEST) test/oracle/run_test.py +typecheck-diff: + $(ISABELLE) build -d . -c -o python_type_annotations -e Python_Examples + $(PYTEST) test/diff/run_test.py + status=0; for d in examples/python_out/*/code; do uv run mypy $$d || status=1; done; exit $$status + status=0; for d in examples/python_out/*/code; do $(TY) --extra-search-path $$d $$d || status=1; done; exit $$status + +typecheck-slow: + $(ISABELLE) build -d . -c -o python_type_annotations -e Python_Test_Slow + uv run mypy test/slow/generated_basic + uv run mypy test/slow/generated_full + $(TY) --extra-search-path test/slow/generated_basic test/slow/generated_basic + $(TY) --extra-search-path test/slow/generated_full test/slow/generated_full + reseed: build-examples $(PYTHON) test/diff/reseed_goldens.py +reseed-annotated: + $(ISABELLE) build -d . -c -o python_type_annotations -e Python_Examples + $(PYTHON) test/diff/reseed_goldens.py + reserved-words: $(PYTHON) etc/update_reserved_words.py @@ -42,7 +63,7 @@ test: test-quick build: $(ISABELLE) build -d . -e Python -.PHONY: default build-test-slow test-slow build-test-quick test-quick build-examples test-diff reseed test-all test build-test-oracle test-oracle build reserved-words +.PHONY: default build-test-slow test-slow build-test-quick test-quick build-examples test-diff typecheck-diff typecheck-slow reseed reseed-annotated test-all test build-test-oracle test-oracle build reserved-words diff --git a/Python_IArray.thy b/Python_IArray.thy index 328896a..07a6e2d 100644 --- a/Python_IArray.thy +++ b/Python_IArray.thy @@ -13,7 +13,7 @@ text \ \ code_printing - type_constructor iarray \ (Python) "_ tuple" + type_constructor iarray \ (Python) "tuple[_, ...]" | constant IArray \ (Python) "tuple'(_')" | constant IArray.list_of \ (Python) "list'(_')" | constant IArray.sub \ (Python) "_[_]" @@ -24,7 +24,9 @@ code_printing | constant IArray.exists \ (Python) "any'(map'(_, _')')" text \@{const IArray.sub'} and @{const IArray.tabulate} take a pair; a literal pair is - printed directly, any other pair expression is unpacked into a lambda.\ + printed directly, any other pair expression is passed to a lambda that takes it apart + by indexing (\(lambda p: p[0][p[1]])(t)\), so that it is evaluated once. Unpacking + it with \*\ instead would lose the types of its components for a type checker.\ setup \ let @@ -34,16 +36,16 @@ setup \ `$ a `$ b) = SOME (a, b) | dest_pair _ = NONE; - fun paired name params body = fn print_term => fn vars => fn t => + fun paired body = fn print_term => fn vars => fn t => case dest_pair t of SOME (a, b) => body (print_term vars BR a) (print_term vars NOBR b) - | NONE => Pretty.block [Pretty.str ("(lambda " ^ params ^ ": "), - body (Pretty.str (fst name)) (Pretty.str (snd name)), - Pretty.str ")(*", print_term vars NOBR t, Pretty.str ")"]; + | NONE => Pretty.block [Pretty.str "(lambda p: ", + body (Pretty.str "p[0]") (Pretty.str "p[1]"), + Pretty.str ")(", print_term vars NOBR t, Pretty.str ")"]; - val sub' = paired ("a", "i") "a, i" (fn a => fn i => + val sub' = paired (fn a => fn i => Pretty.block [a, Pretty.str "[", i, Pretty.str "]"]); - val tabulate = paired ("n", "f") "n, f" (fn n => fn f => + val tabulate = paired (fn n => fn f => Pretty.block [Pretty.str "tuple(map(", f, Pretty.str ", range(", n, Pretty.str ")))"]); fun set target (c, pr) = diff --git a/Python_Setup.thy b/Python_Setup.thy index a0cd816..f3e6bf1 100644 --- a/Python_Setup.thy +++ b/Python_Setup.thy @@ -148,7 +148,7 @@ setup \ (* Lists *) code_printing - type_constructor List.list \ (Python) "_ list" + type_constructor List.list \ (Python) "list[_]" | constant List.list.Nil \ (Python) "[]" code_printing @@ -192,7 +192,7 @@ setup \ Code_Python.enable_native_encoding "list" \ (* Pairs *) code_printing - type_constructor Product_Type.prod \ (Python) "(_ * _)" + type_constructor Product_Type.prod \ (Python) "tuple[_, _]" | constant Product_Type.Pair \ (Python) "(_, _)" | constant fst \ (Python) "_[0]" | constant snd \ (Python) "_[1]" diff --git a/README.md b/README.md index ca80246..fbc00c2 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,36 @@ per line in `etc/python_reserved_words`: the keywords, soft keywords and builtins of the Python version in `.python-version`. Lines starting with `#` are comments. `Python.thy` reserves every name in the file, together with the names that the prelude of each generated module binds (`dataclass`, `Any`, -`Callable`, `functools`, `_abort`, `_unimplemented`; `prelude_names` in +`Callable`, `Never`, `cast`, `functools`, `_abort`, `_cached`, `_unimplemented`; +`prelude_names` in `code_python.ML`). +### Values and modules + +A value is printed as a cached function without arguments, and its uses call +it, so it is evaluated once, when it is first used: + +```python +@functools.cache +def num_of_nat(): + return (Fun.comp(Arith.num_of_integer, lambda a: a)) +``` + +Code that uses the generated modules therefore calls a value too +(`Example_nat.nat_sum()`). An alias of a function (`f_int = f`), or a value +whose type is a function of two or more arguments, is printed as an ordinary +function instead. + +Importing a module thus evaluates nothing, which matters for two reasons. Each +theory becomes a Python module (unless `code_identifier` or the `module_name` of +`export_code` says otherwise), and code equations may use constants of later +theories, e.g. `Num.num_of_nat` is implemented by `Code_Numeral.num_of_integer`. +So the modules can import each other: in the HOL library, about 50 modules form +one import cycle. Python allows this as long as no module reads an attribute of +a module that is still being imported, which evaluating a value could do. And a +value that calls a constant without code (`_abort`) raises when it is used, +rather than when its module is imported. + A definition, class or datatype with a reserved name gets a trailing underscore (`tuple` becomes `tuple_`), and a variable gets a fresh variant (`len` becomes `lena`). @@ -96,6 +123,156 @@ one) is left recursive: Python closures capture variables, not values, so a closure created in one iteration would see the next iteration's rebinding. `examples/Example_tail_calls.thy` shows both outputs side by side. +### Type annotations + +The option `python_type_annotations` (off by default) is the start of type +annotations in the generated code, in the PEP 695 syntax of Python 3.12. It is +work in progress: it covers datatypes, functions, values and type classes, but +not yet local definitions such as hoisted lambdas. Each constructor becomes a generic dataclass with typed +fields, over the type parameters these fields use, and the datatype becomes the +union of its constructors: + +```python +@dataclass(frozen=True) +class None_: + pass +@dataclass(frozen=True) +class Some[A]: + a: A +type option[A] = None_ | Some[A] +``` + +A function gets annotated parameters and a return type, and declares the type +variables of its type as PEP 695 type parameters. Since function values are +applied one argument at a time, a function-typed parameter or return value has +a curried type: + +```python +def px[A](x0: point_ext[A]) -> int: ... +def apply_twice(f: Callable[[int], int], x: int) -> int: ... +@_cached +def empty_list[A]() -> list[A]: ... +``` + +A value is cached with `_cached`, which the prelude defines on top of +`functools.cache`: `functools.cache` would hide the type parameters of +`empty_list` from a type checker. + +A type class becomes a generic dataclass over its type variable. Methods are +called with all their arguments at once, so their fields have uncurried types. +An instance returns the class at its type, and a function with a sort +constraint takes a dictionary of that class (a tuple of dictionaries, for a +sort with several classes): + +```python +@dataclass(frozen=True) +class ord_[A]: + less_eq: Callable[[A, A], bool] + less: Callable[[A, A], bool] + +def ord_list[A](a_dict: ord_[A]) -> ord_[list[A]]: ... +def announce[A](a_dict: describable[A], x: A) -> str: ... +``` + +A type that has no Python name is annotated as `Any`: a type without a +printing whose datatype has no constructors (for example one with an abstract +representation) is not part of the generated code. + +Some printing differs from the output without the option, so that a type +checker accepts the code. A `match` keeps its final `case _:` arm that raises an +error, unless its last pattern is a variable or a wildcard: a type checker +cannot tell that the other patterns are exhaustive, and would otherwise report +a missing return. + +Set the option like `python_tail_calls`: + +```bash +isabelle build -o python_type_annotations -d . -e Python_Examples +``` + +Changing the option does not rebuild an up-to-date session, so add `-c` to +rebuild the session when switching it on or off. `-o` only works when the +directory is registered as an Isabelle component (`isabelle components -u .`) +before the `Python` session is built, since Isabelle reads `etc/options` only +for a component. `make typecheck-diff` builds +the examples with the option, compares them with their golden files (see the +`diff` suite below) and runs mypy and ty over them, one example directory at a time +(each has its own copy of the library modules). + +A function without code, which always aborts, returns `Never`. A lambda becomes +a local function with annotated parameters, and so does a partial application: + +```python +@_cached +def add_one() -> Callable[[int], int]: + def lam(a: int) -> int: + return (add2(1, a)) + return (lam) +``` + +A variable that the branches of an `if` or the arms of a `match` assign is +declared with its type first, and the subject of a `match` is annotated too; +otherwise a type checker would take the constructor of the first assignment +(`Inl`) for the type of the variable, and reject the others: + +```python +x: Sum_Type.sum_[Nat.nat, Nat.nat] +if (Int.less_eq_int(Int.zero_int_(), i)): + x = (Sum_Type.Inl(Int.nat(i))) +else: + x = (Sum_Type.Inr(...)) +``` + +These local definitions, and the hoisted lambdas, get names that differ within +a definition, since mypy rejects one name declared at different types, even in +different arms of a `match`. + +Mypy infers the parameter types of a lambda passed to a generic function by +checking its body again for each candidate, so nested lambdas take exponential +time: the generators of `Quickcheck_Random` took it hours to check. + +A type checker infers a type parameter of a generic function from a +constructor argument as the constructor's class: in `fold(f, xs, Nil())`, mypy +takes `Nil` for `B` rather than `list_[A]`, which then does not fit `f`; and from +a generic value such as `top_set()` it infers `set_[Never]`. Such an argument for +a parameter declared with a bare type variable is therefore cast to the type at +the call: + +```python +return (fold(lam, xs, cast(list_[A], Nil()))) +``` + +A constructor printed as a Python literal, such as a list with `Python_Setup`, +is cast for any parameter whose declared type has a type variable, since +Python's lists are invariant: `[Leaf()]` is a `list[Leaf]`, not a +`list[tree[int]]` (`examples/Example_annotation_edges.thy`). + +No cast is printed where a type checker infers the type exactly anyway: for a +variable or a call, a literal such as `(x, y)`, `[x, *xs]`, `True` or `2`, or +the only constructor of a datatype. `mypy --strict` then finds one redundant +cast in the slow suite. + +Likewise, a superclass instance whose type parameter no dictionary argument +determines (`def inf_fun[A, B](b_dict) -> inf[Callable[[A], B]]`) is cast to its +type in the instance that uses it. A generic function passed as an argument +(`Fun.comp(f, List.rev)`) becomes a local function at its instantiated type, +as a partial application does, since mypy cannot always infer the type +parameters of one generic function passed to another. And a `case` on `unit` +with one arm (`case trace s of () => t`) evaluates its subject as a statement, +since mypy rejects binding the result of a function that returns `None`. + +Mypy accepts the code generated for the slow suite (`generated_basic` and +`generated_full`) and checks each in about a second; `make typecheck-slow` +builds it with the option and runs mypy and ty, as CI does. + +[ty](https://github.com/astral-sh/ty) accepts the same code; it is pinned to +the version tested, as it is still in beta. It infers a literal such as `[]` +from the type it is expected to have, so it finds the casts that mypy needs +redundant, and runs with `--ignore redundant-cast`. Pyright also accepts the +examples, but takes too long on the slow suite: it is exponential in the depth +of nested calls of generic constructors, which the Quickcheck generators and +`term_of` functions are full of. + ## Running the tests This repository comes with three test suites: @@ -123,14 +300,21 @@ with `Python.Python_Setup`. Unfortunately, we can currently not use Isabelle's isabelle build -d . -e Python_Test_Slow uv run python -m py_compile test/slow/generated_basic/*.py uv run python -m py_compile test/slow/generated_full/*.py +uv run pytest test/slow/run_test.py ``` +`run_test.py` imports every generated module in a fresh interpreter; the +modules that are known not to import are listed in `KNOWN_FAILURES` there. + - **diff** During the development of this code generator, different Isabelle features were tested in isolation in different example theories under `examples/`. To see if changes to the backend result in changes to the extracted code, the `diff` test -suite holds golden reference files under `test/diff/golden/`. +suite holds golden reference files under `test/diff/golden/`, and those of the +output with type annotations under `test/diff/golden_annotated/`. The test and +`reseed_goldens.py` tell the two apart by the `from __future__ import +annotations` that starts every annotated module. ```bash isabelle build -d . -e Python_Examples @@ -145,6 +329,10 @@ isabelle build -d . -e Python_Examples uv run python test/diff/reseed_goldens.py ``` +and those of the annotated output by the same commands with `-c -o +python_type_annotations` added to the build (`make reseed-annotated`). A change +to the backend usually changes both sets. + ## Known limitations - No support yet for `real`, `rat`, or other numeric types beyond @@ -155,6 +343,7 @@ circumvent this, such a symbol must be declared with `Code_Python.add_transparent_wrapper_sym`. For an example, look at `examples/Example_transparent_wrapper.thy`. + ## License BSD diff --git a/ROOT b/ROOT index 963b860..7f5b80a 100644 --- a/ROOT +++ b/ROOT @@ -41,6 +41,7 @@ session Python_Examples in "examples" = Python + Example_iarray Example_tail_calls Example_short_circuit + Example_annotation_edges export_files (in "python_out") "*:**" session Python_Test_Quick in "test/quick" = Python + diff --git a/code_python.ML b/code_python.ML index 7730612..c379661 100644 --- a/code_python.ML +++ b/code_python.ML @@ -6,6 +6,7 @@ sig val enable_native_encoding: string -> theory -> theory val print_python_string: string -> string val tail_calls: bool Config.T + val type_annotations: bool Config.T end; structure Code_Python : CODE_PYTHON = @@ -27,6 +28,13 @@ val tail_calls = then Attrib.setup_option_bool ("python_tail_calls", \<^here>) else Attrib.setup_config_bool \<^binding>\python_tail_calls\ (K false); +(* Print type annotations (PEP 484, with the PEP 695 generics of Python 3.12). Off by default, + set up like python_tail_calls *) +val type_annotations = + if can Options.default_typ "python_type_annotations" + then Attrib.setup_option_bool ("python_type_annotations", \<^here>) + else Attrib.setup_config_bool \<^binding>\python_type_annotations\ (K false); + structure Transparent_Wrapper_Data = Theory_Data ( type T = unit Symtab.table @@ -70,7 +78,8 @@ fun use_native_encoding thy name = Symtab.defined (Native_Encoding_Data.get thy) (* Names bound by the prelude of every generated module; the keywords and builtins of Python are reserved by Python.thy, from etc/python_reserved_words *) -val prelude_names = ["dataclass", "Any", "Callable", "_unimplemented", "_abort", "functools"]; +val prelude_names = ["dataclass", "Any", "Callable", "Never", "cast", "_unimplemented", "_abort", + "_cached", "functools"]; type eqtn = { patterns: iterm list, (* left hand side pattern list *) @@ -108,6 +117,7 @@ datatype python_stmt = (* A typeclass definition (turns into a `@dataclass with one Callable field per method, and one field per direct superclass) *) | Class of { + var: vname, (* the type variable of the class *) super: (class * class) list, (* super classes *) methods: (string * itype) list (* class methods *) } @@ -163,20 +173,58 @@ fun invent_names vars prefix n = * arguments: * undefineds: intentionally unimplemented symbols, turn into `_abort(...)` * const_syntax: custom registered code_printing declarations for constants + * tyco_syntax: custom registered code_printing declarations for type constructors + * tyvar_ctxt: names a type variable must not take (everything the module binds) * reserved: context of names that are not useable as new names * args_num: how many arguments needed by the current stmt for saturation * is_class_param: true if the current symbol is a type-class method + * is_value: true for a value definition (a nullary constant without dictionaries) + * is_cached_value: true for a value, which is printed as a cached function without + * arguments (see serialize_python) * is_constr: true for a datatype constructor without a printing + * generic_dom: the parameter types of a function as it is declared, before its type + * variables are instantiated (empty for other symbols) * ctxt: thoery context (neede to look up record field names) * deresolve: module relative naming resolver + * lam_tyvars: the type variables that the annotations of hoisted lambdas (see anf_term) + * may name, those of the generic function they are in; NONE outside of one, where they + * print as Any *) -fun print_python_stmt undefineds const_syntax reserved args_num - is_class_param is_value is_constr ctxt deresolve = +fun print_python_stmt undefineds const_syntax tyco_syntax tyvar_ctxt reserved args_num + is_class_param is_value is_cached_value is_constr generic_dom ctxt deresolve lam_tyvars = let fun deresolve_const name = deresolve (Constant name); + (* names of the local definitions of this statement so far, see invent_local *) + val local_names = Unsynchronized.ref ([] : string list); fun deresolve_class name = deresolve (Type_Class name); fun deresolve_inst name = deresolve (Class_Instance name); + (* Python names of type variables: capitalised ('a -> A), and distinct from every + name the module binds, as a PEP 695 type parameter shadows them in the body + of the function or class that declares it *) + fun intro_tyvars vs = + let + val capitalize = implode o nth_map 0 Symbol.to_ascii_upper o Symbol.explode + val (names, ctxt') = fold_map (Name.variant o capitalize) vs tyvar_ctxt + in (fold2 (curry Symtab.update) vs names Symtab.empty, ctxt') end; + + (* A function value is applied one argument at a time, so its type is curried: + a => b => c is Callable[[a], Callable[[b], c]]. A type without a Python name + has a syntax that prints Any (typ_syntax in serialize_python). *) + fun print_typ tyvars (ITyVar v) = Pretty.str (lookup_var tyvars v) + | print_typ tyvars ("fun" `%% [ty1, ty2]) = + Pretty.block [Pretty.str "Callable[[", print_typ tyvars ty1, Pretty.str "], ", + print_typ tyvars ty2, Pretty.str "]"] + | print_typ tyvars (tyco `%% tys) = + (case tyco_syntax tyco of + SOME (_, print) => print (K (print_typ tyvars)) NOBR tys + | NONE => + (case try deresolve (Type_Constructor tyco) of + SOME name => print_typ_app (Pretty.str name) (map (print_typ tyvars) tys) + | NONE => Pretty.str "Any")) + and print_typ_app head [] = head + | print_typ_app head ps = Pretty.block [head, Pretty.enum "," "[" "]" ps]; + (* Attribute name of a class dataclass field (method or superclass). Declaration, construction and projection must all use this, as deresolve may rename (`equal` -> `equala`) or module-qualify. *) @@ -188,6 +236,11 @@ fun print_python_stmt undefineds const_syntax reserved args_num (* extract the theory from the context *) val thy = Proof_Context.theory_of ctxt + + val annotate = Config.get ctxt type_annotations + (* With type annotations, functools.cache would hide the type parameters of a function + from a type checker; _cached, defined in the prelude, is typed as the identity *) + val cache_decorator = Pretty.str (if annotate then "@_cached" else "@functools.cache"); (* Python introduced structural pattern matching in version 3.10. * We can therefore use things like capture patterns, wildcards, and @@ -322,7 +375,19 @@ fun print_python_stmt undefineds const_syntax reserved args_num else is_sole_constr sym andalso forall exhaustive args | NONE => false) - fun is_trivial_pattern _ t = exhaustive t + (* Whether a match needs no `case _` arm after a last arm with the patterns ts. Python + needs none after an exhaustive arm. A type checker however only sees that an arm is + exhaustive if it knows the type of the subject, which it does not for an unannotated + lambda, and otherwise infers that the function may fall off the match and return + None. With type annotations, only an arm that matches anything ends the match: a + capture or a wildcard, after which Python forbids further arms. *) + fun ends_match vars ts = + if annotate + then (case pattern_of_iterms vars ts of + ([PCapture _], [], _, _) => true + | ([PWild], [], _, _) => true + | _ => false) + else forall exhaustive ts fun print_python_pattern (PCapture v) = Pretty.str v | print_python_pattern PWild = Pretty.str "_" @@ -337,6 +402,40 @@ fun print_python_stmt undefineds const_syntax reserved args_num | print_python_pattern (PList (ps, SOME rest)) = Pretty.enum "," "[" "]" (map print_python_pattern ps @ [Pretty.str ("*" ^ rest)]); + (* The annotation of a local definition: the type variables are those of the generic + function it is in (lam_tyvars), and Any outside of one *) + val local_tyvars = case lam_tyvars of + SOME vs => intro_tyvars vs + | NONE => (Symtab.empty, tyvar_ctxt) + fun print_local_typ ty = case lam_tyvars of + SOME _ => print_typ local_tyvars ty + | NONE => + let + fun add_tyvars (ITyVar v) = insert (op =) v + | add_tyvars (_ `%% tys) = fold add_tyvars tys + in print_typ (fold (fn v => Symtab.update (v, "Any")) (add_tyvars ty []) + Symtab.empty, tyvar_ctxt) ty end + + (* The type of a term, where a constant or a lambda determines it: a case has the + result type of its case combinator *) + fun type_of_term (ICase { primitive, ... }) = type_of_term primitive + | type_of_term ((_, ty) `|=> (_, rty)) = SOME ([ty] `--> rty) + | type_of_term t = (case Code_Thingol.unfold_const_app t of + SOME ({ dom, range, ... }, ts) => + if length ts <= length dom then SOME (drop (length ts) dom `--> range) else NONE + | NONE => NONE) + + (* A fresh name for a local definition. Mypy rejects definitions of one name at + different types, even in different arms of a match, so with type annotations the + names of local definitions differ within a statement. *) + fun invent_local vars prefix = + if annotate + then + let val (name, vars') = invent_name (fst vars, fold Name.declare (! local_names) (snd vars)) + prefix + in (local_names := name :: ! local_names; (name, vars')) end + else invent_name vars prefix + fun print_guard _ _ [] = NONE | print_guard some_thm vars guards = guards @@ -375,32 +474,87 @@ fun print_python_stmt undefineds const_syntax reserved args_num | _ => NONE) | _ => NONE - and anf_term vars (t as IConst _) = ([], vars, t) + (* With type annotations, a partial application that would be printed as a lambda + (see print_app_expr) is eta-expanded before hoisting, so that it becomes an + annotated def as well *) + and eta_expansion t = + if not annotate then NONE + else case Code_Thingol.unfold_const_app t of + SOME (app as ({ sym = sym as Constant name, dictss, typargs, ... }, ts)) => + if member (op =) undefineds name then NONE + else + let + val arity = case const_syntax name of + SOME (_, Plain_printer _) => NONE + | SOME (wanted, _) => SOME wanted + | NONE => + (* a unary function is printed by name, unless it is generic: a type + checker cannot always infer the type arguments of a generic function + passed to another generic one *) + let val l = args_num sym + in + if null ts andalso forall null dictss andalso l = 1 andalso null typargs + then NONE else SOME l + end + in case arity of + SOME l => if length ts < l + then SOME (Code_Thingol.saturated_application l app) else NONE + | NONE => NONE + end + | _ => NONE + + and anf_term vars (t as IConst _) = + (case eta_expansion t of + SOME t' => anf_term vars t' + | NONE => ([], vars, t)) | anf_term vars (t as IVar _) = ([], vars, t) | anf_term vars (t as t1 `$ t2) = (case short_circuit t of SOME (cond, t_branch, e_branch) => let val (bc, vars1, cond') = anf_term vars cond; - val (x, vars2) = invent_name vars1 "x"; + val (x, vars2) = invent_local vars1 "x"; in (bc @ [PIf (x, cond', t_branch, e_branch)], vars2, IVar (SOME x)) end | NONE => - let - val (b1, vars1, t1') = anf_term vars t1; - val (b2, vars2, t2') = anf_term vars1 t2; - in (b1 @ b2, vars2, t1' `$ t2') end) + (case (eta_expansion t, Code_Thingol.unfold_const_app t) of + (SOME t', _) => anf_term vars t' + | (NONE, SOME (const, ts)) => + (* the arguments of a constant; its partial applications that make + up the head are not terms of their own *) + let + val (bs, vars', ts') = fold (fn t => fn (bs, vs, ts') => + let val (b, vs', t') = anf_term vs t + in (bs @ b, vs', ts' @ [t']) end) + ts ([], vars, []) + in (bs, vars', IConst const `$$ ts') end + | (NONE, NONE) => + let + val (b1, vars1, t1') = anf_term vars t1; + val (b2, vars2, t2') = anf_term vars1 t2; + in (b1 @ b2, vars2, t1' `$ t2') end)) + (* With type annotations, every lambda becomes a def, whose annotations spare a + type checker inferring the types of its parameters. Mypy infers those of a + lambda passed to a generic function by checking it once per candidate type, so + nested ones take exponential time: the generators of Quickcheck_Random take + hours to check. *) | anf_term vars (t as (_, _) `|=> (_, _)) = - if is_stmt_free t + if is_stmt_free t andalso not annotate then ([], vars, t) else let - fun strip_lambdas vs ((param, _) `|=> (body, _)) = + fun strip_lambdas vs ((param, ty) `|=> (body, body_ty)) = let val vs' = intro_vars (map_filter I [param]) vs - val (ps, vs'', body') = strip_lambdas vs' body - in (param :: ps, vs'', body') end - | strip_lambdas vs body = ([], vs, body) - val (params, vars1, body) = strip_lambdas vars t + val (ps, vs'', body', range_ty) = strip_lambdas vs' body + in ((param, ty) :: ps, vs'', body', + case range_ty of NONE => SOME body_ty | some => some) end + | strip_lambdas vs body = ([], vs, body, NONE) + val (typed_params, vars1, body, range_ty) = strip_lambdas vars t + val params = map fst typed_params + (* the annotations of the def taking the i-th parameter *) + fun def_typs i = + let val (_, rest) = chop i (map snd typed_params) + in (print_local_typ (hd rest), print_local_typ (tl rest `--> the range_ty)) end val (param_prettys, vars2) = fold_map (fn NONE => (fn vs => let val (n, vs') = invent_name vs "unused" in (Pretty.str n, vs') end) @@ -408,35 +562,42 @@ fun print_python_stmt undefineds const_syntax reserved args_num params vars1 (* Function values are applied one argument at a time (f(x)(y)), so a multi-parameter lambda becomes nested one-parameter defs. *) - fun def_head vs fname param = - Pretty.block [Pretty.str "def ", Pretty.str (lookup_var vs fname), + fun def_head vs fname param i = + if annotate + then + let val (param_typ, ret_typ) = def_typs i + in Pretty.block [Pretty.str "def ", Pretty.str (lookup_var vs fname), + Pretty.str "(", param, Pretty.str ": ", param_typ, Pretty.str ") -> ", + ret_typ, Pretty.str ":"] + end + else Pretty.block [Pretty.str "def ", Pretty.str (lookup_var vs fname), Pretty.str "(", param, Pretty.str "):"] - fun curried_defs vs [param] = + fun curried_defs vs i [param] = let - val (fname, vs') = invent_name vs "lam" + val (fname, vs') = invent_local vs "lam" val body_pretty = print_tail_expr NONE (fn vars' => fn t' => Pretty.block [Pretty.str "return (", print_python_expr const_syntax NONE vars' NOBR t', Pretty.str ")"]) vs' body - in (Pretty.chunks [def_head vs' fname param, indent_block 4 body_pretty], + in (Pretty.chunks [def_head vs' fname param i, indent_block 4 body_pretty], fname, vs') end - | curried_defs vs (param :: params') = + | curried_defs vs i (param :: params') = let - val (fname, vs1) = invent_name vs "lam" - val (inner, inner_name, vs2) = curried_defs vs1 params' + val (fname, vs1) = invent_local vs "lam" + val (inner, inner_name, vs2) = curried_defs vs1 (i + 1) params' val inner_block = Pretty.chunks [inner, Pretty.str ("return " ^ lookup_var vs2 inner_name)] - in (Pretty.chunks [def_head vs2 fname param, indent_block 4 inner_block], + in (Pretty.chunks [def_head vs2 fname param i, indent_block 4 inner_block], fname, vs2) end - | curried_defs _ [] = error "internal error: hoisted lambda without parameters" - val (def_stmt, fname, vars3) = curried_defs vars2 param_prettys + | curried_defs _ _ [] = error "internal error: hoisted lambda without parameters" + val (def_stmt, fname, vars3) = curried_defs vars2 0 param_prettys (* the lambda's parameters are local to the def: keep the outer bindings (only adding the def's name), but keep all names reserved so later fresh names cannot clash *) val vars4 = (Symtab.update (fname, lookup_var vars3 fname) (fst vars), snd vars3) in ([PRaw def_stmt], vars4, IVar (SOME fname)) end | anf_term vars (t as ICase _) = - let val (x, vars') = invent_name vars "x" + let val (x, vars') = invent_local vars "x" in ([PBind (x, t)], vars', IVar (SOME x)) end and print_if_then_else some_thm finish vars target t_branch e_branch = @@ -464,10 +625,26 @@ fun print_python_stmt undefineds const_syntax reserved args_num end | get_if_then_else _ = NONE - and print_tail_expr some_thm finish vars (ICase { term = target, clauses, ... }) = + (* With type annotations, a case on unit with one arm (`case trace s of () => t`) + evaluates its subject as a statement and continues with the arm: unit is None, + and a type checker rejects binding the result of a function that returns None *) + and print_tail_expr some_thm finish vars + (ICase { term = target, typ = "Product_Type.unit" `%% [], clauses = [(pat, t)], ... }) = + if annotate andalso (case pat of + IVar NONE => true + | IConst { sym = Constant "Product_Type.Unity", ... } => true + | _ => false) + then + let val (bindings, vars', target') = anf_term vars target + in Pretty.chunks (map (print_preamble some_thm vars') bindings @ + [print_python_expr const_syntax some_thm vars' NOBR target', + print_tail_expr some_thm finish vars' t]) + end + else print_case_block some_thm finish vars target ("Product_Type.unit" `%% []) [(pat, t)] + | print_tail_expr some_thm finish vars (ICase { term = target, typ, clauses, ... }) = (case get_if_then_else clauses of SOME (t_branch, e_branch) => print_if_then_else some_thm finish vars target t_branch e_branch - | NONE => print_case_block some_thm finish vars target clauses) + | NONE => print_case_block some_thm finish vars target typ clauses) | print_tail_expr some_thm finish vars t = let val (bindings, vars', t') = anf_term vars t in Pretty.chunks (map (print_preamble some_thm vars') bindings @ [finish vars' t']) end @@ -478,7 +655,15 @@ fun print_python_stmt undefineds const_syntax reserved args_num print_python_expr const_syntax some_thm vars' NOBR t', Pretty.str ")"]) vars t - and print_preamble some_thm vars (PBind (name, t)) = print_binding some_thm vars (name, t) + (* With type annotations, the variable that the arms of a case assign is declared + first, or a type checker would take the type of the first assignment (one + constructor) for all of them *) + and print_preamble some_thm vars (PBind (name, t)) = + (case (annotate, type_of_term t) of + (true, SOME ty) => Pretty.chunks + [Pretty.block [Pretty.str name, Pretty.str ": ", print_local_typ ty], + print_binding some_thm vars (name, t)] + | _ => print_binding some_thm vars (name, t)) | print_preamble _ _ (PRaw p) = p | print_preamble some_thm vars (PIf (name, cond, t_branch, e_branch)) = let @@ -494,11 +679,14 @@ fun print_python_stmt undefineds const_syntax reserved args_num indent_block 4 (branch e_branch)] end - and print_case_block some_thm finish vars target clauses = + and print_case_block some_thm finish vars target typ clauses = let val (target_bindings, vars1, target') = anf_term vars target; - val (tvar, vars0) = invent_name vars1 "target" - val assign = Pretty.block [Pretty.str tvar, Pretty.str " = (", + val (tvar, vars0) = invent_local vars1 "target" + val tvar_decl = if annotate + then Pretty.block [Pretty.str tvar, Pretty.str ": ", print_local_typ typ] + else Pretty.str tvar + val assign = Pretty.block [tvar_decl, Pretty.str " = (", print_python_expr const_syntax some_thm vars1 NOBR target', Pretty.str ")"]; val match_head = Pretty.block [Pretty.str "match ", Pretty.str tvar, Pretty.str ":"]; fun one_arm (pattern, term) = @@ -510,7 +698,7 @@ fun print_python_stmt undefineds const_syntax reserved args_num pattern is exhaustive on its own *) val last_clause_pattern = case rev clauses of (p, _) :: _ => SOME p | [] => NONE val already_exhaustive = case last_clause_pattern of - SOME p => is_trivial_pattern vars0 p + SOME p => ends_match vars0 [p] | NONE => false val arms = map one_arm clauses @ (if already_exhaustive then [] else [fallthrough_arm]) in @@ -529,8 +717,14 @@ fun print_python_stmt undefineds const_syntax reserved args_num SOME app => print_app const_syntax some_thm vars fxy app (* If not, then this might be a lambda application or similar *) | NONE => - applify "(" ")" (print_python_expr const_syntax some_thm vars NOBR) fxy - (print_python_expr const_syntax some_thm vars BR t1) [t2]) + let + (* an applied lambda needs brackets, or it would apply its body: + `lambda x: t(u)` instead of `(lambda x: t)(u)` *) + val head = case t1 of + _ `|=> _ => Pretty.enclose "(" ")" + [print_python_expr const_syntax some_thm vars NOBR t1] + | _ => print_python_expr const_syntax some_thm vars BR t1 + in applify "(" ")" (print_python_expr const_syntax some_thm vars NOBR) fxy head [t2] end) | IVar (SOME v) => Pretty.str (lookup_var vars v) | IVar NONE => error "can't return a variable with no name" | (params, _) `|=> (t', _) => @@ -571,14 +765,65 @@ fun print_python_stmt undefineds const_syntax reserved args_num and print_dicts some_thm vars = tuplify (print_dict some_thm vars) - and print_app_expr const_syntax some_thm vars (app as ({ sym, dictss, ...}, ts)) = + and print_app_expr const_syntax some_thm vars (app as ({ sym, dictss, dom, ...}, ts)) = let val l = args_num sym + (* With type annotations, a constructor argument for a parameter whose declared type + is a type variable is cast to the instantiated type: a type checker would take the + constructor's own class for the type variable (`fold(f, xs, Nil())` makes B Nil + rather than list_[A]), which then does not fit the other arguments. So is a + generic value (`fold(f, xs, top_set())`), whose type parameters it would take + for Never. A constructor printed as a Python literal is cast for any parameter + whose declared type has a type variable: Python's lists are invariant, so + `first_or([Leaf()], f, t)` does not fit a list[tree[int]] either. *) + val declared_dom = if annotate then generic_dom sym else [] + fun is_constr_app t = case Code_Thingol.unfold_const_app t of + SOME ({ sym = sym' as Constant c, typargs, ... }, _) => + is_some (Code.get_type_of_constr_or_abstr thy c) + orelse (is_cached_value sym' andalso not (null typargs)) + | _ => false + fun is_literal_constr_app t = case Code_Thingol.unfold_const_app t of + SOME ({ sym = Constant c, ... }, _) => + is_some (Code.get_type_of_constr_or_abstr thy c) andalso is_some (const_syntax c) + | _ => false + fun has_tyvar (ITyVar _) = true + | has_tyvar (_ `%% tys) = exists has_tyvar tys + (* An argument for which a type checker infers exactly its type needs no cast. A + variable, a call or a hoisted lambda has its declared type. So has a constructor + application if its class is the type (a constructor printed as a Python literal, + or the only one of its datatype), and its arguments determine the type variables + of its result: (x, y), [x, *xs], True or None, but not [] or Nil(). And any term + of a Python type without parameters is exact, such as the numeral 2 :: int. *) + fun determined c = + let val (dom_tys, range_ty) = strip_type (Sign.the_const_type thy c) + in subset (op =) (Term.add_tvarsT range_ty [], fold Term.add_tvarsT dom_tys []) end + fun is_python_scalar (tyco `%% []) = is_some (tyco_syntax tyco) + | is_python_scalar _ = false + fun is_exact t = + (case type_of_term t of SOME ty => is_python_scalar ty | NONE => false) orelse + (case Code_Thingol.unfold_const_app t of + SOME ({ sym = sym' as Constant c, typargs, ... }, ts) => + if is_some (Code.get_type_of_constr_or_abstr thy c) + then (is_some (const_syntax c) orelse is_sole_constr sym') + andalso determined c andalso forall is_exact ts + else not (is_cached_value sym' andalso not (null typargs)) + andalso (null typargs orelse forall is_exact ts) + | _ => true) + fun needs_cast declared t = not (is_exact t) andalso (case declared of + ITyVar _ => is_constr_app t + | _ => has_tyvar declared andalso is_literal_constr_app t) + fun print_arg i t = + if i < length declared_dom andalso i < length dom + andalso needs_cast (nth declared_dom i) t + then Pretty.block [Pretty.str "cast(", print_local_typ (nth dom i), Pretty.str ", ", + print_python_expr const_syntax some_thm vars NOBR t, Pretty.str ")"] + else print_python_expr const_syntax some_thm vars BR t + (* a value is referenced by calling its cached function *) + val name_pretty = Pretty.str (deresolve sym ^ (if is_cached_value sym then "()" else "")) fun call_with head_pretty extra_dicts = let val (immediate, curried) = chop l ts - val immediate_pretty = - map (print_python_expr const_syntax some_thm vars BR) immediate + val immediate_pretty = map_index (uncurry print_arg) immediate val curried_pretty = map (fn t => Pretty.enclose "(" ")" [print_python_expr const_syntax some_thm vars NOBR t]) curried @@ -591,7 +836,7 @@ fun print_python_stmt undefineds const_syntax reserved args_num one argument. A constant of higher arity is eta-expanded, since the corresponding Python function is uncurried but function values are applied one argument at a time. *) if null ts andalso forall null dictss andalso l = 1 - then [(Pretty.str o deresolve) sym] + then [name_pretty] else [print_python_expr const_syntax some_thm vars BR (Code_Thingol.saturated_application l app)] else if is_class_param sym andalso not (null dictss) @@ -603,14 +848,14 @@ fun print_python_stmt undefineds const_syntax reserved args_num Pretty.str (attr_name sym)] in call_with head_pretty extra_dict_pretty end else if is_value sym andalso forall null dictss andalso null ts - then [(Pretty.str o deresolve) sym] + then [name_pretty] else let (* constructors take no dictionaries (as in SML), even when the type has sort constraints, e.g. the abstype morphism vec_lambda of ('a, 'b::finite) vec *) val dict_pretty = if is_constr sym then [] else map_filter (print_dicts some_thm vars BR) dictss - in call_with ((Pretty.str o deresolve) sym) dict_pretty end + in call_with name_pretty dict_pretty end end and print_app const_syntax some_thm vars fxy (const as { sym, ... }, ts) = @@ -641,9 +886,21 @@ fun print_python_stmt undefineds const_syntax reserved args_num | _ => stock fxy ts end - fun print_python_typedef tyco { cnstrs, ... } = + (* With type annotations, a constructor is a generic dataclass over the type + parameters its fields use, and the datatype is the union of its constructors: + class Some[A]: a: A + type option[A] = None_ | Some[A] + A constructor without a parameter its datatype has (None_) then fits every + instance of the datatype (option[int]) *) + fun print_python_typedef tyco { typarams, cnstrs } = let - val field_names = + val tyvars = intro_tyvars typarams + fun add_tyvars (ITyVar v) = insert (op =) v + | add_tyvars (_ `%% tys) = fold add_tyvars tys + fun used_typarams arg_tys = filter (member (op =) (fold add_tyvars arg_tys [])) typarams + fun print_generic name vs = + print_typ_app (Pretty.str name) (map (Pretty.str o lookup_var tyvars) vs) + val field_names = case Record.get_info thy (Long_Name.qualifier tyco) of SOME { fields, ... } => SOME (map (Long_Name.base_name o fst) fields) | NONE => NONE @@ -664,32 +921,70 @@ fun print_python_stmt undefineds const_syntax reserved args_num | n => "more" :: List.tabulate (n - 1, fn i => "more" ^ string_of_int (i + 2))) else map fst named_fields | NONE => map fst named_fields - val fields = labels - |> map (fn fname => Pretty.str (python_safe_ident fname ^ ": Any")) + val fields = labels ~~ arg_tys + |> map (fn (fname, ty) => Pretty.block [Pretty.str (python_safe_ident fname ^ ": "), + if annotate then print_typ tyvars ty else Pretty.str "Any"]) + val class_head = if annotate + then print_generic (deresolve_const name) (used_typarams arg_tys) + else Pretty.str (deresolve_const name) in Pretty.chunks [Pretty.str "@dataclass(frozen=True)", - Pretty.block [Pretty.str "class ", Pretty.str (deresolve_const name), Pretty.str ":"], + Pretty.block [Pretty.str "class ", class_head, Pretty.str ":"], indent_block 4 (if null fields then Pretty.str "pass" else Pretty.chunks fields)] end - in Pretty.chunks (map print_constructor cnstrs) end; + val alias = Pretty.block [Pretty.str "type ", + print_generic (deresolve (Type_Constructor tyco)) typarams, Pretty.str " = ", + Pretty.block (separate (Pretty.str " | ") (map (fn { name, arg_tys, ... } => + print_generic (deresolve_const name) (used_typarams arg_tys)) cnstrs))] + in Pretty.chunks (map print_constructor cnstrs @ (if annotate then [alias] else [])) end; + + (* The type of a dictionary of class for the type variable v: cls[V] *) + fun print_dict_typ tyvars class v = + print_typ_app (Pretty.str (deresolve_class class)) [Pretty.str (lookup_var tyvars v)] + + (* A method is called with all its arguments at once (see print_app_expr), so its + field has an uncurried type: a => a => bool is Callable[[A, A], bool] *) + fun print_method_typ tyvars ty = + let val (tys, ran) = Code_Thingol.unfold_fun ty + in Pretty.block [Pretty.str "Callable[", Pretty.enum "," "[" "]" (map (print_typ tyvars) tys), + Pretty.str ", ", print_typ tyvars ran, Pretty.str "]"] + end - fun print_python_class sym { super, methods } = + (* With type annotations, a class is a generic dataclass over its type variable, + with a field of type super[A] per direct superclass *) + fun print_python_class sym { var, super, methods } = let + val tyvars = intro_tyvars [var] val fields = methods - |> map (fn (name, _) => Pretty.str (attr_name (Constant name) ^ ": Callable")) + |> map (fn (name, ty) => Pretty.block [Pretty.str (attr_name (Constant name) ^ ": "), + if annotate then print_method_typ tyvars ty else Pretty.str "Callable"]) val super_fields = super - |> map (fn (self, super) => Pretty.str - (attr_name (Class_Relation (self, super)) ^ ": Any")) + |> map (fn (self, super) => Pretty.block + [Pretty.str (attr_name (Class_Relation (self, super)) ^ ": "), + if annotate then print_dict_typ tyvars super var else Pretty.str "Any"]) val all_fields = super_fields @ fields + val class_head = if annotate + then print_typ_app (Pretty.str (deresolve_class sym)) [Pretty.str (lookup_var tyvars var)] + else Pretty.str (deresolve_class sym) in Pretty.chunks [Pretty.str "@dataclass(frozen=True)", - Pretty.block [Pretty.str "class ", Pretty.str (deresolve_class sym), Pretty.str ":"], + Pretty.block [Pretty.str "class ", class_head, Pretty.str ":"], indent_block 4 (if null all_fields then Pretty.str "pass" else Pretty.chunks all_fields)] end; fun print_dict_args vs = map_filter (fn (v, sort) => if null sort then NONE else SOME (Pretty.str (v ^ "_dict"))) vs + (* The types of the dictionary arguments: cls[V], or a tuple of them if the sort of + V has several classes (indexed as v_dict[i], see print_plain_dict) *) + fun print_dict_arg_typs tyvars vs = map_filter (fn (_, []) => NONE + | (v, [class]) => SOME (print_dict_typ tyvars class v) + | (v, sort) => SOME (print_typ_app (Pretty.str "tuple") + (map (fn class => print_dict_typ tyvars class v) sort))) vs + + fun annotate_args names typs = + map2 (fn p => fn ty => Pretty.block [p, Pretty.str ": ", ty]) names typs + fun print_python_instance (target', class) { vs, tyco, inst_params, superinsts, ... } = let val tyvars = intro_vars (map fst vs) reserved @@ -707,35 +1002,78 @@ fun print_python_stmt undefineds const_syntax reserved args_num Pretty.block [Pretty.str "lambda ", params, Pretty.str ": ", call]] end + (* With type annotations, a superclass instance with a type parameter that no + dictionary argument determines (inf_fun[A, B](b_dict) -> inf[Callable[[A], B]]) + is cast to its type here, which a type checker cannot infer from the call *) fun print_superinst_field (super_class, dictss) = let val field_name = attr_name (Class_Relation (class, super_class)) - val value = print_plain_dict NONE tyvars + val dict = print_plain_dict NONE tyvars (Dict_Const ((tyco, super_class), dictss)) + val value = if annotate andalso exists (null o snd) dictss + then + let val typ_vars = intro_tyvars (map fst vs) + in Pretty.block [Pretty.str "cast(", + print_typ_app (Pretty.str (deresolve_class super_class)) + [print_typ typ_vars (tyco `%% map (ITyVar o fst) vs)], + Pretty.str ", ", dict, Pretty.str ")"] + end + else dict in concat [Pretty.str field_name, Pretty.str "=", value] end val fields = map print_superinst_field superinsts @ map print_classparam_field inst_params val body = Pretty.block [Pretty.str "return ", class_pretty, Pretty.enum "," "(" ")" fields] val dict_args = print_dict_args vs - val head = Pretty.block [Pretty.str "def ", Pretty.str instance_name, - Pretty.enum "," "(" ")" dict_args, Pretty.str ":"] + (* annotated: def ord_list[A](a_dict: ord[A]) -> ord[list_[A]] *) + val head = if annotate + then + let val typ_vars = intro_tyvars (map fst vs) + in Pretty.block [Pretty.str "def ", + print_typ_app (Pretty.str instance_name) (map (Pretty.str o lookup_var typ_vars o fst) vs), + Pretty.enum "," "(" ")" (annotate_args dict_args (print_dict_arg_typs typ_vars vs)), + Pretty.str " -> ", + print_typ_app class_pretty [print_typ typ_vars (tyco `%% map (ITyVar o fst) vs)], + Pretty.str ":"] + end + else Pretty.block [Pretty.str "def ", Pretty.str instance_name, + Pretty.enum "," "(" ")" dict_args, Pretty.str ":"] (* an instance without dictionary arguments always builds the same (frozen) dictionary, so build it once *) - val decorator = if null dict_args then [Pretty.str "@functools.cache"] else [] + val decorator = if null dict_args then [cache_decorator] else [] in Pretty.chunks (decorator @ [head, indent_block 4 body]) end; - fun print_func_head const vctxt dicts params = - Pretty.block [ - Pretty.str "def ", - Pretty.str (deresolve_const const), - Pretty.enum "," "(" ")" ( - dicts @ - map_index (fn (_, SOME v) => Pretty.str (lookup_var vctxt v) - | (i, NONE) => Pretty.str ("unused" ^ string_of_int i)) - params - ), - Pretty.str ":" - ] + (* Annotations of a function of type ty that takes n parameters: its PEP 695 type + parameters, the types of its dictionary arguments and parameters, and the rest of the + type as the return type (a function that returns a function value returns it curried, + see print_typ) *) + fun func_signature vs ty n = + if not annotate then NONE + else + let + val tyvars = intro_tyvars (map fst vs) + val (tys, ran) = Code_Thingol.unfold_fun ty + val (param_tys, rest) = chop n tys + in + if length param_tys <> n then NONE + else SOME (map (Pretty.str o lookup_var tyvars o fst) vs, print_dict_arg_typs tyvars vs, + map (print_typ tyvars) param_tys, print_typ tyvars (rest `--> ran)) + end + + fun print_func_head const vctxt dicts params func_sig = + let + val param_prettys = map_index (fn (_, SOME v) => Pretty.str (lookup_var vctxt v) + | (i, NONE) => Pretty.str ("unused" ^ string_of_int i)) + params + val (name, typed_args, ret) = case func_sig of + NONE => (Pretty.str (deresolve_const const), dicts @ param_prettys, []) + | SOME (typarams, dict_tys, tys, ran) => + (print_typ_app (Pretty.str (deresolve_const const)) typarams, + annotate_args dicts dict_tys @ annotate_args param_prettys tys, + [Pretty.str " -> ", ran]) + in + Pretty.block ([Pretty.str "def ", name, + Pretty.enum "," "(" ")" typed_args] @ ret @ [Pretty.str ":"]) + end fun print_undefined_func_stub const { vs, ty, ... } = let @@ -743,9 +1081,14 @@ fun print_python_stmt undefineds const_syntax reserved args_num val vctxt = intro_vars (map fst vs) reserved val (params, vctxt) = invent_names vctxt "a" arity val dict_params = print_dict_args vs + (* it never returns: a type variable that only occurs in the return type would + be rejected by mypy (`def undefined[A]() -> A`) *) val head = print_func_head const vctxt dict_params (map SOME params) + (Option.map (fn (typarams, dict_tys, tys, _) => (typarams, dict_tys, tys, Pretty.str "Never")) + (func_signature vs ty arity)) in Pretty.chunks [head, - indent_block 4 (Pretty.block [Pretty.str "return ", print_abort const])] + indent_block 4 (Pretty.block ((if annotate then [] else [Pretty.str "return "]) @ + [print_abort const]))] end (* A pattern-less equation whose rhs is a constant (`f_int = f`) can't be an @@ -763,9 +1106,12 @@ fun print_python_stmt undefineds const_syntax reserved args_num in { patterns = map (IVar o fst) vs_tys, rhs = body, thm = thm } end (* The same holds for any pattern-less equation of a function that takes dictionaries itself, e.g. `to_nat = nat o Rep` in a class context: it is - printed as `def to_nat(a_dict)`, but callers pass the arguments too. *) + printed as `def to_nat(a_dict)`, but callers pass the arguments too; and + for one of arity 2 or more, e.g. `empty = (%_ _. None)`: as a value it would + be a curried lambda, but callers pass all arguments at once. At arity 1 both + agree, so such an equation stays a value. *) | eta_expand_alias takes_dicts n (eq as { patterns = [], rhs, thm }) = - if n = 0 orelse not takes_dicts then eq + if n = 0 orelse (not takes_dicts andalso n < 2) then eq else let val names = Name.invent @@ -812,10 +1158,8 @@ fun print_python_stmt undefineds const_syntax reserved args_num else map SOME (aux_params vars1 (map #patterns eqs)) val vars2 = intro_vars (map_filter I params) vars1 val dict_params = print_dict_args vs - (* a simple function without parameters and dictionary arguments can - be printed as a plain value (i.e., an assignment x = ...) *) - val prints_as_value = simple andalso null params andalso null dict_params - val head = print_func_head const vars2 dict_params params + val func_sig = func_signature vs ty (length params) + val head = print_func_head const vars2 dict_params params func_sig fun print_return some_thm vars' t' = Pretty.block [Pretty.str "return (", print_python_expr const_syntax some_thm vars' NOBR t', Pretty.str ")"] @@ -875,16 +1219,15 @@ fun print_python_stmt undefineds const_syntax reserved args_num then Pretty.chunks [Pretty.str "while True:", indent_block 4 body] else body in - if prints_as_value - then - (* value definition: `const = (expr)` *) - let val { rhs = t, thm = some_thm, ... } = hd eqs - in print_binding some_thm vars2 (deresolve_const const, t) end - else if simple + if simple then - (* simple function, plain variable args *) - let val { rhs = t, thm = some_thm, ... } = hd eqs - in Pretty.chunks [head, indent_block 4 (loop_body (print_rhs some_thm vars2 t))] end + (* simple function, plain variable args; a value is a function without + arguments that is evaluated once, when it is first used *) + let + val { rhs = t, thm = some_thm, ... } = hd eqs + val decorator = if is_cached_value (Constant const) then [cache_decorator] else [] + in Pretty.chunks (decorator @ + [head, indent_block 4 (loop_body (print_rhs some_thm vars2 t))]) end else (* multiple equations and/or patterns in arguments, this compiles to a match/case over the arguments *) @@ -907,7 +1250,7 @@ fun print_python_stmt undefineds const_syntax reserved args_num own patterns are already all bare variables, that arm is unconditionally exhaustive on its own *) val last_is_exhaustive = case rev eqs of - { patterns, ... } :: _ => forall (is_trivial_pattern vars2) patterns + { patterns, ... } :: _ => ends_match vars2 patterns | [] => false val arms = map print_one_equation eqs @ (if last_is_exhaustive then [] else [fallthrough_arm]) @@ -933,15 +1276,18 @@ fun print_python_stmt undefineds const_syntax reserved args_num fun python_program_of_program ctxt module_name reserved identifiers exports program = let - (* Add trailing underscores to a name until it is unused and not a module name, following PEP 8 *) - fun namify_common module_names base ((nsp_class, nsp_object), nsp_common) = + (* Add trailing underscores to a name until it is not reserved, unused and not a module name, + following PEP 8. The names in use are kept apart from the Name.context of reserved names: + Name.declare drops a trailing underscore, so after declaring `set_` the name `set_` would + still count as free, and a datatype and its constructor could both become `set_`. *) + fun namify_common module_names base (reserved, used) = let fun fresh x = - if Name.is_declared nsp_common x orelse member (op =) module_names x then fresh (x ^ "_") else x; + if Name.is_declared reserved x orelse Symtab.defined used x + orelse member (op =) module_names x + then fresh (x ^ "_") else x; val base' = fresh base; - in - (base', ((Name.declare base' nsp_class, Name.declare base' nsp_object), Name.declare base' nsp_common)) - end; + in (base', (reserved, Symtab.insert_set base' used)) end; (* Python doesn't really have any naming restrictions relating to upper/lowercase etc. *) fun namify_stmt _ (Code_Thingol.NoStmt) = raise Fail "should not be reached" @@ -961,7 +1307,7 @@ fun python_program_of_program ctxt module_name reserved identifiers exports prog fun flat_program module_names = Code_Namespace.flat_program ctxt { module_prefix = "", module_name = module_name, reserved = reserved, - identifiers = identifiers, empty_nsp = ((reserved, reserved), reserved), + identifiers = identifiers, empty_nsp = (reserved, Symtab.empty), namify_stmt = namify_stmt module_names, modify_stmt = modify_stmt } exports program; @@ -970,7 +1316,7 @@ fun python_program_of_program ctxt module_name reserved identifiers exports prog in flat_program module_names end; fun serialize_python undefineds _ ctxt { module_name, reserved_syms, - identifiers, includes, const_syntax, ... } program exports = + identifiers, includes, const_syntax, tyco_syntax, ... } program exports = let val program = Code_Symbol.Graph.restrict @@ -1005,13 +1351,23 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, of Code_Thingol.Datatype (_, constrs) => AList.lookup (op = o apsnd fst) constrs constr | _ => NONE; + (* A type constructor without a printing has a Python name only if its datatype has + constructors: one without (e.g. a type with an abstract representation) is dropped + from the program, though it still has a name, so it is printed as Any *) + fun typ_syntax tyco = case tyco_syntax tyco of + SOME syn => SOME syn + | NONE => (case try (Code_Symbol.Graph.get_node program) (Type_Constructor tyco) of + SOME (Code_Thingol.Datatype (_, _ :: _)) => NONE + | _ => SOME (0, fn _ => fn _ => fn _ => Pretty.str "Any")); + fun is_class_param (sym as Constant _) = ( case Code_Symbol.Graph.get_node program sym of Code_Thingol.Classparam _ => true | _ => false) | is_class_param _ = raise Fail "should never be reached"; - fun is_value sym = + fun is_value sym = + Code_Symbol.Graph.defined program sym andalso case sym of Constant _ => ( case Code_Symbol.Graph.get_node program sym of @@ -1019,7 +1375,34 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, forall (null o snd) vs andalso null ts | _ => false) | _ => false; + + (* A value that print_python_func prints as an assignment `v = ...`, and that is + therefore evaluated when its module is imported: eta_expand_alias turns an alias of + a function (`f_int = f`) and a value of arity 2 or more into a function *) + fun is_assigned_value (sym as Constant name) = is_value sym andalso + not (member (op =) undefineds name) andalso + (case Code_Symbol.Graph.get_node program sym of + Code_Thingol.Fun (((_, ty), [((_, rhs), _)]), _) => + (case length (fst (Code_Thingol.unfold_fun ty)) of + 0 => true + | 1 => (case rhs of IConst _ => false | _ => true) + | _ => false) + | _ => false) + | is_assigned_value _ = false; + (* Every value is printed as a cached function without arguments, which is called + where it is used, so importing a module evaluates nothing. Modules follow theories, + and code equations may use constants of later theories (e.g. Num.num_of_nat is + implemented by Code_Numeral.num_of_integer), so modules can import each other, and + reading an attribute of a module that is still being imported would fail. And a value + that calls a constant without code only raises when it is used. *) + val is_cached_value = is_assigned_value; + + fun generic_dom (sym as Constant _) = (case Code_Symbol.Graph.get_node program sym of + Code_Thingol.Fun (((_, ty), _), _) => fst (Code_Thingol.unfold_fun ty) + | _ => []) + | generic_dom _ = []; + fun classparams_of_class class = case Code_Symbol.Graph.get_node program (Type_Class class) of Code_Thingol.Class (_, (_, classparams)) => classparams @@ -1058,8 +1441,8 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, ) cnstrs in Datatype { typarams = typarams, cnstrs = constrs' } end | python_stmt_of_thingol (Code_Thingol.Class x) = - let val (_, (super, methods)) = x - in Class { super = super, methods = methods } end + let val (var, (super, methods)) = x + in Class { var = var, super = super, methods = methods } end | python_stmt_of_thingol (Code_Thingol.Classinst inst) = let val { vs, tyco, inst_params, superinsts, ... } = inst in Instance { vs = vs, tyco = tyco, inst_params = inst_params, superinsts = superinsts } @@ -1068,6 +1451,16 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, val module_names = Graph.keys python_program; + (* Names a type variable of a module must avoid: the reserved names, the imported + modules, and every statement of the module *) + fun tyvar_ctxt mod_name = + let val (stmt_gr, _) = Graph.get_node python_program mod_name + in Name.make_context reserved_syms + |> fold Name.declare module_names + |> fold Name.declare + (map_filter (try (deresolver mod_name)) (Code_Symbol.Graph.keys stmt_gr)) + end; + (* `program` (and therefore python_program) has already been pruned down to exactly the live statements above, so this is just: print every surviving statement, drop empty modules. *) @@ -1075,26 +1468,29 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, |> map (fn mod_name => let val (stmt_gr, imports) = Graph.get_node python_program mod_name; + fun lam_tyvars (Code_Thingol.Fun (((vs, _), _), _)) = SOME (map fst vs) + | lam_tyvars _ = NONE; val stmt_ps = (Code_Symbol.Graph.strong_conn stmt_gr |> flat) |> rev |> map_filter (fn sym => case Code_Symbol.Graph.get_node stmt_gr sym of (_, NONE) => NONE | (_, SOME (export, stmt)) => - SOME (print_python_stmt undefineds const_syntax - (make_vars reserved_syms) args_num is_class_param is_value - is_constr ctxt (deresolver mod_name) + SOME (print_python_stmt undefineds const_syntax typ_syntax + (tyvar_ctxt mod_name) (make_vars reserved_syms) args_num is_class_param is_value + is_cached_value is_constr generic_dom ctxt (deresolver mod_name) (lam_tyvars stmt) (sym, (export, python_stmt_of_thingol stmt)))); in (mod_name, imports, stmt_ps) end) |> filter (fn (_, _, stmt_ps) => not (null stmt_ps)); val nonempty_names = map #1 module_stmts; - (* modules that print a cached (dictionary-free) instance need functools *) + (* modules that print a cached (dictionary-free) instance or a lazy value need functools *) fun needs_functools mod_name = let val (stmt_gr, _) = Graph.get_node python_program mod_name - in Code_Symbol.Graph.fold (fn (_, ((_, stmt), _)) => fn b => b orelse + in Code_Symbol.Graph.fold (fn (sym, ((_, stmt), _)) => fn b => b orelse (case stmt of SOME (_, Code_Thingol.Classinst { vs, ... }) => forall (null o snd) vs + | SOME _ => is_cached_value sym | _ => false)) stmt_gr false end; @@ -1122,15 +1518,28 @@ fun serialize_python undefineds _ ctxt { module_name, reserved_syms, val import_ps = imports |> filter (fn (imported_name, _) => member (op =) nonempty_names imported_name) |> map (fn (imported_name, _) => concat [Pretty.str "import", Pretty.str imported_name]); - val imports_block = Pretty.chunks (Pretty.str "from dataclasses import dataclass" - :: Pretty.str "from typing import Any, Callable" + (* annotations are not evaluated (PEP 563), so they may refer to classes and + type aliases defined further down, e.g. in recursive datatypes *) + val annotate = Config.get ctxt type_annotations + val imports_block = Pretty.chunks + ((if annotate then [Pretty.str "from __future__ import annotations"] else []) + @ Pretty.str "from dataclasses import dataclass" + :: Pretty.str ("from typing import Any, Callable" ^ + (if annotate then ", Never, cast" else "")) :: (if needs_functools mod_name then [Pretty.str "import functools"] else []) @ import_ps) val abort_def = Pretty.chunks - [Pretty.str "def _abort(msg, thunk):", + [Pretty.str (if annotate then "def _abort(msg: str, thunk: object) -> Never:" + else "def _abort(msg, thunk):"), indent_block 4 (Pretty.str "raise RuntimeError(msg)")] + (* the cache decorator with type annotations, see print_python_stmt *) + val cached_def = if annotate andalso needs_functools mod_name + then [Pretty.chunks + [Pretty.str "def _cached[F: Callable[[], Any]](f: F) -> F:", + indent_block 4 (Pretty.str "return cast(F, functools.cache(f))")]] + else [] in ([mod_name ^ ".py"], - Pretty.chunks2 (print_header mod_name :: imports_block :: abort_def :: stmt_ps)) + Pretty.chunks2 (print_header mod_name :: imports_block :: abort_def :: cached_def @ stmt_ps)) end; val p = map print_one_module module_stmts diff --git a/etc/options b/etc/options index b9895b2..9fb67c5 100644 --- a/etc/options +++ b/etc/options @@ -4,3 +4,6 @@ section "Python Code Generation" option python_tail_calls : bool = false for content -- "print self tail calls of generated Python functions as loops (see code_python.ML)" + +option python_type_annotations : bool = false for content + -- "print type annotations in generated Python code (see code_python.ML)" diff --git a/examples/Example_annotation_edges.thy b/examples/Example_annotation_edges.thy new file mode 100644 index 0000000..a70aa8b --- /dev/null +++ b/examples/Example_annotation_edges.thy @@ -0,0 +1,46 @@ +theory Example_annotation_edges + imports Main "Python.Python_Setup" +begin + +text \Cases a type checker can get wrong in the code generated with type annotations.\ + +text \A constructor at a nested position of a generic parameter: from the argument + \[Leaf]\ of \first_or\, a type checker may take \Leaf\ rather than \nat tree\ + for \'b\, which does not fit the function argument.\ + +datatype 'a tree = Leaf | Node "'a tree" 'a "'a tree" + +definition first_or :: "'b list \ ('b \ 'b) \ 'b \ 'b" where + "first_or xs f d = (case xs of [] \ d | x # _ \ f x)" + +definition grow :: "nat tree \ nat tree" where + "grow t = first_or [Leaf] (\l. Node l 0 t) t" + +text \An instance dictionary passed to an ordinary function, where the instance has a + type parameter that no dictionary argument determines: the instance for functions + only constrains their result type.\ + +class pointed = + fixes point :: 'a + +instantiation nat :: pointed +begin +definition point_nat :: nat where "point_nat = 0" +instance .. +end + +instantiation "fun" :: (type, pointed) pointed +begin +definition point_fun :: "'a \ 'b" where "point_fun = (\_. point)" +instance .. +end + +definition with_point :: "'a::pointed \ 'a \ 'a" where + "with_point x = (point, x)" + +definition fun_with_point :: "(nat \ nat) \ (nat \ nat)" where + "fun_with_point = with_point (\n. n + 1)" + +export_code grow fun_with_point in Python file_prefix "." + +end diff --git a/pyproject.toml b/pyproject.toml index c4818bc..d3e28df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,5 +5,7 @@ description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ + "mypy>=2.4.1", "pytest>=9.1.1", + "ty==0.0.96", ] diff --git a/test/diff/golden/Python_Examples.Example_annotation_edges/Example_annotation_edges.py b/test/diff/golden/Python_Examples.Example_annotation_edges/Example_annotation_edges.py new file mode 100644 index 0000000..41cbf6b --- /dev/null +++ b/test/diff/golden/Python_Examples.Example_annotation_edges/Example_annotation_edges.py @@ -0,0 +1,55 @@ +# Generated by Isabelle from theory Python_Examples.Example_annotation_edges; do not edit + +from dataclasses import dataclass +from typing import Any, Callable +import functools + +def _abort(msg, thunk): + raise RuntimeError(msg) + +@dataclass(frozen=True) +class pointed: + point: Callable + +def point_fun(b_dict, x): + return ((lambda _: b_dict.point())(x)) + +def pointed_fun(b_dict): + return pointed(point = lambda : lambda a: point_fun(b_dict, a)) + +@functools.cache +def point_nat(): + return (0) + +@functools.cache +def pointed_nat(): + return pointed(point = lambda : point_nat()) + +@dataclass(frozen=True) +class Leaf: + pass +@dataclass(frozen=True) +class Node: + a: Any + b: Any + c: Any + +def first_or(xs, f, d): + target = (xs) + match target: + case []: + return (d) + case [x, *_]: + return (f(x)) + case _: + raise RuntimeError("match failed") + +def grow(t): + return (first_or([Leaf()], lambda l: Node(l, 0, t), t)) + +def with_point(a_dict, x): + return ((a_dict.point(), x)) + +@functools.cache +def fun_with_point(): + return (with_point(pointed_fun(pointed_nat()), lambda n: (n + 1))) diff --git a/test/diff/golden/Python_Examples.Example_classrel/Example_classrel.py b/test/diff/golden/Python_Examples.Example_classrel/Example_classrel.py index 65054ca..6e77aa4 100644 --- a/test/diff/golden/Python_Examples.Example_classrel/Example_classrel.py +++ b/test/diff/golden/Python_Examples.Example_classrel/Example_classrel.py @@ -19,6 +19,10 @@ def super_op_bool(): def sub_op_bool(): return Example_classrel_base.sub_op(super_op_sub_op = super_op_bool()) -test_sub = (Example_classrel_base.sub_apply(sub_op_bool(), True)) +@functools.cache +def test_sub(): + return (Example_classrel_base.sub_apply(sub_op_bool(), True)) -test_super = (sup_apply_bool(True)) +@functools.cache +def test_super(): + return (sup_apply_bool(True)) diff --git a/test/diff/golden/Python_Examples.Example_code_numerals/Example_code_numerals.py b/test/diff/golden/Python_Examples.Example_code_numerals/Example_code_numerals.py index 92f6f83..128afb3 100644 --- a/test/diff/golden/Python_Examples.Example_code_numerals/Example_code_numerals.py +++ b/test/diff/golden/Python_Examples.Example_code_numerals/Example_code_numerals.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -10,15 +11,25 @@ def _abort(msg, thunk): def cn_add(x, y): return ((x + y)) -cn_neg = (-5) +@functools.cache +def cn_neg(): + return (-5) -cn_int_lit = (42) +@functools.cache +def cn_int_lit(): + return (42) -cn_sum = (cn_add(cn_int_lit, 8)) +@functools.cache +def cn_sum(): + return (cn_add(cn_int_lit(), 8)) def cn_nat_add(x, y): return ((x + y)) -cn_nat_lit = (max(0, 7)) +@functools.cache +def cn_nat_lit(): + return (max(0, 7)) -cn_nat_sum = (cn_nat_add(cn_nat_lit, (max(0, 3)))) +@functools.cache +def cn_nat_sum(): + return (cn_nat_add(cn_nat_lit(), (max(0, 3)))) diff --git a/test/diff/golden/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py b/test/diff/golden/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py index 35eaab6..ec02e31 100644 --- a/test/diff/golden/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py +++ b/test/diff/golden/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import List import Product_Type @@ -22,9 +23,13 @@ def any_true(x0): case _: raise RuntimeError("match failed") -test_swap = (swap(Product_Type.Pair(True, False))) +@functools.cache +def test_swap(): + return (swap(Product_Type.Pair(True, False))) -test_any_true = (any_true(List.Cons(False, List.Cons(False, List.Cons(True, List.Nil()))))) +@functools.cache +def test_any_true(): + return (any_true(List.Cons(False, List.Cons(False, List.Cons(True, List.Nil()))))) def first_two_agree(x0): match x0: @@ -37,4 +42,6 @@ def first_two_agree(x0): case _: raise RuntimeError("match failed") -test_first_two = (Product_Type.Pair(first_two_agree(List.Cons(True, List.Cons(True, List.Cons(False, List.Nil())))), first_two_agree(List.Cons(True, List.Nil())))) +@functools.cache +def test_first_two(): + return (Product_Type.Pair(first_two_agree(List.Cons(True, List.Cons(True, List.Cons(False, List.Nil())))), first_two_agree(List.Cons(True, List.Nil())))) diff --git a/test/diff/golden/Python_Examples.Example_iarray/Example_iarray.py b/test/diff/golden/Python_Examples.Example_iarray/Example_iarray.py index f74a5bb..3808007 100644 --- a/test/diff/golden/Python_Examples.Example_iarray/Example_iarray.py +++ b/test/diff/golden/Python_Examples.Example_iarray/Example_iarray.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import IArray import Num import Nat @@ -12,14 +13,20 @@ def _abort(msg, thunk): def sum_ends(a): return (((a[0]) + (a[(max(0, (len(a)) - 1))]))) -squares = (tuple(map(lambda i: (i * i), range((max(0, 4)))))) +@functools.cache +def squares(): + return (tuple(map(lambda i: (i * i), range((max(0, 4)))))) -example = (((list(squares)), ((sum_ends(squares), (((all(map(lambda x: (x < (max(0, 10))), squares))), IArray.equal_iarray(Nat.equal_nat(), (tuple((list(map(lambda a: (a + 1), [1, max(0, 2)]))))), (tuple([max(0, 2), max(0, 3)]))))))))) +@functools.cache +def example(): + return (((list(squares())), ((sum_ends(squares()), (((all(map(lambda x: (x < (max(0, 10))), squares()))), IArray.equal_iarray(Nat.equal_nat(), (tuple((list(map(lambda a: (a + 1), [1, max(0, 2)]))))), (tuple([max(0, 2), max(0, 3)]))))))))) def sub_pair(p): - return ((lambda a, i: a[i])(*p)) + return ((lambda p: p[0][p[1]])(p)) -example_nth = ([10, 20, 30][1]) +@functools.cache +def example_nth(): + return ([10, 20, 30][1]) def first_or_zero(x0): match x0: diff --git a/test/diff/golden/Python_Examples.Example_int_arith/Example_int_arith.py b/test/diff/golden/Python_Examples.Example_int_arith/Example_int_arith.py index 9352d20..a1a8cb8 100644 --- a/test/diff/golden/Python_Examples.Example_int_arith/Example_int_arith.py +++ b/test/diff/golden/Python_Examples.Example_int_arith/Example_int_arith.py @@ -2,28 +2,47 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): raise RuntimeError(msg) -product = ((6 * 7)) +@functools.cache +def product(): + return ((6 * 7)) def checksum(x, y): return ((((lambda a, b: a % b if b else a)(((x * y)), ((y - x)))) + ((lambda a, b: a // b if b else 0)(x, 2)))) -zero_test = (0) +@functools.cache +def zero_test(): + return (0) -neg_product = ((((- 3)) * 4)) +@functools.cache +def neg_product(): + return ((((- 3)) * 4)) -quotient_neg = ((lambda a, b: a // b if b else 0)(((- 7)), 2)) +@functools.cache +def quotient_neg(): + return ((lambda a, b: a // b if b else 0)(((- 7)), 2)) -quotient_pos = ((lambda a, b: a // b if b else 0)(7, 2)) +@functools.cache +def quotient_pos(): + return ((lambda a, b: a // b if b else 0)(7, 2)) -remainder_neg = ((lambda a, b: a % b if b else a)(((- 7)), 2)) +@functools.cache +def remainder_neg(): + return ((lambda a, b: a % b if b else a)(((- 7)), 2)) -remainder_pos = ((lambda a, b: a % b if b else a)(7, 2)) +@functools.cache +def remainder_pos(): + return ((lambda a, b: a % b if b else a)(7, 2)) -quotient_neg_divisor = ((lambda a, b: a // b if b else 0)(7, ((- 2)))) +@functools.cache +def quotient_neg_divisor(): + return ((lambda a, b: a // b if b else 0)(7, ((- 2)))) -remainder_neg_divisor = ((lambda a, b: a % b if b else a)(7, ((- 2)))) +@functools.cache +def remainder_neg_divisor(): + return ((lambda a, b: a % b if b else a)(7, ((- 2)))) diff --git a/test/diff/golden/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py b/test/diff/golden/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py index dcbc1b5..d9dbe22 100644 --- a/test/diff/golden/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py +++ b/test/diff/golden/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py @@ -2,26 +2,45 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Arith import Num def _abort(msg, thunk): raise RuntimeError(msg) -test_bit = (Arith.bit_integer(10, 1)) +@functools.cache +def test_bit(): + return (Arith.bit_integer(10, 1)) -test_sgn = (Arith.sgn_integer(-42)) +@functools.cache +def test_sgn(): + return (Arith.sgn_integer(-42)) -test_mask = (Arith.mask_integer((max(0, 5)))) +@functools.cache +def test_mask(): + return (Arith.mask_integer((max(0, 5)))) -test_set_bit = (Arith.set_bit_integer((max(0, 2)), 0)) +@functools.cache +def test_set_bit(): + return (Arith.set_bit_integer((max(0, 2)), 0)) -test_drop_bit = (Arith.drop_bit_integer((max(0, 2)), 20)) +@functools.cache +def test_drop_bit(): + return (Arith.drop_bit_integer((max(0, 2)), 20)) -test_flip_bit = (Arith.flip_bit_integer(1, 5)) +@functools.cache +def test_flip_bit(): + return (Arith.flip_bit_integer(1, 5)) -test_push_bit = (Arith.push_bit_integer((max(0, 3)), 5)) +@functools.cache +def test_push_bit(): + return (Arith.push_bit_integer((max(0, 3)), 5)) -test_take_bit = (Arith.take_bit_integer((max(0, 4)), 255)) +@functools.cache +def test_take_bit(): + return (Arith.take_bit_integer((max(0, 4)), 255)) -test_unset_bit = (Arith.unset_bit_integer(0, 7)) +@functools.cache +def test_unset_bit(): + return (Arith.unset_bit_integer(0, 7)) diff --git a/test/diff/golden/Python_Examples.Example_lists/Example_lists.py b/test/diff/golden/Python_Examples.Example_lists/Example_lists.py index 8baf75f..90c903a 100644 --- a/test/diff/golden/Python_Examples.Example_lists/Example_lists.py +++ b/test/diff/golden/Python_Examples.Example_lists/Example_lists.py @@ -2,14 +2,19 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): raise RuntimeError(msg) -example = ([1, 2, 3]) +@functools.cache +def example(): + return ([1, 2, 3]) def prepend(x, xs): return ([x] + xs) -example2 = (prepend(5, example)) +@functools.cache +def example2(): + return (prepend(5, example())) diff --git a/test/diff/golden/Python_Examples.Example_nat/Example_nat.py b/test/diff/golden/Python_Examples.Example_nat/Example_nat.py index e124381..c032b0e 100644 --- a/test/diff/golden/Python_Examples.Example_nat/Example_nat.py +++ b/test/diff/golden/Python_Examples.Example_nat/Example_nat.py @@ -2,32 +2,55 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): raise RuntimeError(msg) -nat_sum = (((max(0, 6)) + (max(0, 7)))) +@functools.cache +def nat_sum(): + return (((max(0, 6)) + (max(0, 7)))) -nat_eq_test = (((max(0, 4)) == (max(0, 4)))) +@functools.cache +def nat_eq_test(): + return (((max(0, 4)) == (max(0, 4)))) -nat_le_test = (((max(0, 3)) <= (max(0, 5)))) +@functools.cache +def nat_le_test(): + return (((max(0, 3)) <= (max(0, 5)))) -nat_literal = (max(0, 42)) +@functools.cache +def nat_literal(): + return (max(0, 42)) -nat_lt_test = (((max(0, 5)) < (max(0, 3)))) +@functools.cache +def nat_lt_test(): + return (((max(0, 5)) < (max(0, 3)))) -nat_product = (((max(0, 6)) * (max(0, 7)))) +@functools.cache +def nat_product(): + return (((max(0, 6)) * (max(0, 7)))) -nat_sub_pos = (max(0, (max(0, 10)) - (max(0, 3)))) +@functools.cache +def nat_sub_pos(): + return (max(0, (max(0, 10)) - (max(0, 3)))) def nat_checksum(x, y): return ((((lambda a, b: a % b if b else a)(((x * y)), ((y + 1)))) + (max(0, x - y)))) -nat_quotient = ((lambda a, b: a // b if b else 0)((max(0, 7)), (max(0, 2)))) +@functools.cache +def nat_quotient(): + return ((lambda a, b: a // b if b else 0)((max(0, 7)), (max(0, 2)))) -nat_remainder = ((lambda a, b: a % b if b else a)((max(0, 7)), (max(0, 2)))) +@functools.cache +def nat_remainder(): + return ((lambda a, b: a % b if b else a)((max(0, 7)), (max(0, 2)))) -nat_sub_trunc = (max(0, (max(0, 3)) - (max(0, 10)))) +@functools.cache +def nat_sub_trunc(): + return (max(0, (max(0, 3)) - (max(0, 10)))) -nat_zero_test = (0) +@functools.cache +def nat_zero_test(): + return (0) diff --git a/test/diff/golden/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py b/test/diff/golden/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py index 2084b17..b00a07e 100644 --- a/test/diff/golden/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py +++ b/test/diff/golden/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -19,7 +20,9 @@ def peel_positive_head(x0): case _: raise RuntimeError("match failed") -peel_test = (peel_positive_head([max(0, 3), max(0, 4), max(0, 5)])) +@functools.cache +def peel_test(): + return (peel_positive_head([max(0, 3), max(0, 4), max(0, 5)])) def nat_minus2(v, n): if ((v == 0)): @@ -39,6 +42,10 @@ def classify_small(uu): else: return (max(0, 2)) -classify_test = ((classify_small(0), ((classify_small(1), classify_small((max(0, 7))))))) +@functools.cache +def classify_test(): + return ((classify_small(0), ((classify_small(1), classify_small((max(0, 7))))))) -nat_minus2_test = (nat_minus2((max(0, 5)), (max(0, 3)))) +@functools.cache +def nat_minus2_test(): + return (nat_minus2((max(0, 5)), (max(0, 3)))) diff --git a/test/diff/golden/Python_Examples.Example_nat_pattern/Example_nat_pattern.py b/test/diff/golden/Python_Examples.Example_nat_pattern/Example_nat_pattern.py index cf7f52b..8a0efe8 100644 --- a/test/diff/golden/Python_Examples.Example_nat_pattern/Example_nat_pattern.py +++ b/test/diff/golden/Python_Examples.Example_nat_pattern/Example_nat_pattern.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -13,7 +14,9 @@ def fact(n): else: return (((((max(0, n - 1)) + 1)) * fact((max(0, n - 1))))) -fact_5 = (fact((max(0, 5)))) +@functools.cache +def fact_5(): + return (fact((max(0, 5)))) def countdown(n): if ((n == 0)): @@ -27,6 +30,10 @@ def nat_is_even(n): else: return (not nat_is_even((max(0, n - 1)))) -is_even_7 = (nat_is_even((max(0, 7)))) +@functools.cache +def is_even_7(): + return (nat_is_even((max(0, 7)))) -countdown_4 = (countdown((max(0, 4)))) +@functools.cache +def countdown_4(): + return (countdown((max(0, 4)))) diff --git a/test/diff/golden/Python_Examples.Example_nested_case/Example_nested_case.py b/test/diff/golden/Python_Examples.Example_nested_case/Example_nested_case.py index a0e9035..1e8c075 100644 --- a/test/diff/golden/Python_Examples.Example_nested_case/Example_nested_case.py +++ b/test/diff/golden/Python_Examples.Example_nested_case/Example_nested_case.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -37,13 +38,21 @@ def abs_manual(x): else: return (x) -label_five = (nat_label((max(0, 5)))) +@functools.cache +def label_five(): + return (nat_label((max(0, 5)))) -label_zero = (nat_label(0)) +@functools.cache +def label_zero(): + return (nat_label(0)) -weird_five = (weird((max(0, 5)))) +@functools.cache +def weird_five(): + return (weird((max(0, 5)))) -weird_zero = (weird(0)) +@functools.cache +def weird_zero(): + return (weird(0)) def describe_len(xs): target = (xs) @@ -56,12 +65,22 @@ def describe_len(xs): raise RuntimeError("match failed") return ((x + 1)) -classify_zero = (classify(0)) +@functools.cache +def classify_zero(): + return (classify(0)) -abs_manual_neg = (abs_manual(((- 7)))) +@functools.cache +def abs_manual_neg(): + return (abs_manual(((- 7)))) -abs_manual_pos = (abs_manual(7)) +@functools.cache +def abs_manual_pos(): + return (abs_manual(7)) -classify_other = (classify((max(0, 5)))) +@functools.cache +def classify_other(): + return (classify((max(0, 5)))) -describe_len_123 = (describe_len([1, max(0, 2), max(0, 3)])) +@functools.cache +def describe_len_123(): + return (describe_len([1, max(0, 2), max(0, 3)])) diff --git a/test/diff/golden/Python_Examples.Example_nested_if/Example_nested_if.py b/test/diff/golden/Python_Examples.Example_nested_if/Example_nested_if.py index 9e11078..8e0b16d 100644 --- a/test/diff/golden/Python_Examples.Example_nested_if/Example_nested_if.py +++ b/test/diff/golden/Python_Examples.Example_nested_if/Example_nested_if.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -22,15 +23,25 @@ def grade_code(score): else: return (max(0, 4)) -grade_a = (grade_code((max(0, 95)))) +@functools.cache +def grade_a(): + return (grade_code((max(0, 95)))) -grade_b = (grade_code((max(0, 85)))) +@functools.cache +def grade_b(): + return (grade_code((max(0, 85)))) -grade_c = (grade_code((max(0, 75)))) +@functools.cache +def grade_c(): + return (grade_code((max(0, 75)))) -grade_d = (grade_code((max(0, 65)))) +@functools.cache +def grade_d(): + return (grade_code((max(0, 65)))) -grade_f = (grade_code((max(0, 40)))) +@functools.cache +def grade_f(): + return (grade_code((max(0, 40)))) def nested_then(x, y): if ((0 < x)): @@ -41,8 +52,14 @@ def nested_then(x, y): else: return (3) -nested_then_f = (nested_then(((- 1)), 1)) +@functools.cache +def nested_then_f(): + return (nested_then(((- 1)), 1)) -nested_then_tf = (nested_then(1, ((- 1)))) +@functools.cache +def nested_then_tf(): + return (nested_then(1, ((- 1)))) -nested_then_tt = (nested_then(1, 1)) +@functools.cache +def nested_then_tt(): + return (nested_then(1, 1)) diff --git a/test/diff/golden/Python_Examples.Example_no_eqs/Example_no_eqs.py b/test/diff/golden/Python_Examples.Example_no_eqs/Example_no_eqs.py index c30f789..ebaeeaa 100644 --- a/test/diff/golden/Python_Examples.Example_no_eqs/Example_no_eqs.py +++ b/test/diff/golden/Python_Examples.Example_no_eqs/Example_no_eqs.py @@ -2,9 +2,12 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import HOL def _abort(msg, thunk): raise RuntimeError(msg) -uses_undefined = (HOL.undefined()) +@functools.cache +def uses_undefined(): + return (HOL.undefined()) diff --git a/test/diff/golden/Python_Examples.Example_options/Example_options.py b/test/diff/golden/Python_Examples.Example_options/Example_options.py index d6031c7..68fa650 100644 --- a/test/diff/golden/Python_Examples.Example_options/Example_options.py +++ b/test/diff/golden/Python_Examples.Example_options/Example_options.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num import Option @@ -17,13 +18,21 @@ def describe_opt(x0): case _: raise RuntimeError("match failed") -o_some = (Option.Some(5)) +@functools.cache +def o_some(): + return (Option.Some(5)) -d1 = (describe_opt(o_some)) +@functools.cache +def d1(): + return (describe_opt(o_some())) -o_none = (Option.None_()) +@functools.cache +def o_none(): + return (Option.None_()) -d2 = (describe_opt(o_none)) +@functools.cache +def d2(): + return (describe_opt(o_none())) def describe_opt2(x0): match x0: @@ -34,6 +43,10 @@ def describe_opt2(x0): case _: raise RuntimeError("match failed") -d3 = (describe_opt2(o_some)) +@functools.cache +def d3(): + return (describe_opt2(o_some())) -d4 = (describe_opt2(o_none)) +@functools.cache +def d4(): + return (describe_opt2(o_none())) diff --git a/test/diff/golden/Python_Examples.Example_partial/Example_partial.py b/test/diff/golden/Python_Examples.Example_partial/Example_partial.py index a1d7803..b2519df 100644 --- a/test/diff/golden/Python_Examples.Example_partial/Example_partial.py +++ b/test/diff/golden/Python_Examples.Example_partial/Example_partial.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -10,16 +11,24 @@ def _abort(msg, thunk): def add2(x, y): return ((x + y)) -add_one = (lambda a: add2(1, a)) +@functools.cache +def add_one(): + return (lambda a: add2(1, a)) def add2_ref(a, b): return (add2(a, b)) -p_mapped = (list(map(add_one, [1, 2, 3]))) +@functools.cache +def p_mapped(): + return (list(map(add_one(), [1, 2, 3]))) def apply_twice(f, x): return (f(f(x))) -p_result = (apply_twice(add_one, 5)) +@functools.cache +def p_result(): + return (apply_twice(add_one(), 5)) -p_ref_result = (add2_ref(3, 4)) +@functools.cache +def p_ref_result(): + return (add2_ref(3, 4)) diff --git a/test/diff/golden/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py b/test/diff/golden/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py index 9afa91e..28d8b37 100644 --- a/test/diff/golden/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py +++ b/test/diff/golden/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py @@ -2,15 +2,24 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): raise RuntimeError(msg) -empty_list = ([]) +@functools.cache +def empty_list(): + return ([]) -magic_number = (max(0, 42)) +@functools.cache +def magic_number(): + return (max(0, 42)) -uses_empty_list = (empty_list) +@functools.cache +def uses_empty_list(): + return (empty_list()) -uses_magic_number = ((magic_number + 1)) +@functools.cache +def uses_magic_number(): + return ((magic_number() + 1)) diff --git a/test/diff/golden/Python_Examples.Example_record_ext/Example_record_ext.py b/test/diff/golden/Python_Examples.Example_record_ext/Example_record_ext.py index 798abf9..4b071a5 100644 --- a/test/diff/golden/Python_Examples.Example_record_ext/Example_record_ext.py +++ b/test/diff/golden/Python_Examples.Example_record_ext/Example_record_ext.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -44,8 +45,14 @@ def px(x0): def point3d_sum(p): return ((((px(p) + py(p))) + pz(p))) -origin3d = (point_ext_(0, 0, point3d_ext_(0, None))) +@functools.cache +def origin3d(): + return (point_ext_(0, 0, point3d_ext_(0, None))) -shifted3d = (move_z(origin3d, 7)) +@functools.cache +def shifted3d(): + return (move_z(origin3d(), 7)) -total3d = (point3d_sum(shifted3d)) +@functools.cache +def total3d(): + return (point3d_sum(shifted3d())) diff --git a/test/diff/golden/Python_Examples.Example_records/Example_records.py b/test/diff/golden/Python_Examples.Example_records/Example_records.py index db04f04..bb7d1ad 100644 --- a/test/diff/golden/Python_Examples.Example_records/Example_records.py +++ b/test/diff/golden/Python_Examples.Example_records/Example_records.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): @@ -26,7 +27,9 @@ def px(x0): def point_sum(p, q): return ((((((px(p) + py(p))) + px(q))) + py(q))) -origin = (point_ext_(0, 0, None)) +@functools.cache +def origin(): + return (point_ext_(0, 0, None)) def px_update(pxa, x1): match (pxa, x1): @@ -36,6 +39,10 @@ def px_update(pxa, x1): def move_x(p, dx): return (px_update(lambda _: (px(p) + dx), p)) -shifted = (move_x(origin, 5)) +@functools.cache +def shifted(): + return (move_x(origin(), 5)) -total = (point_sum(origin, shifted)) +@functools.cache +def total(): + return (point_sum(origin(), shifted())) diff --git a/test/diff/golden/Python_Examples.Example_short_circuit/Example_short_circuit.py b/test/diff/golden/Python_Examples.Example_short_circuit/Example_short_circuit.py index fd513e1..8ef9ce8 100644 --- a/test/diff/golden/Python_Examples.Example_short_circuit/Example_short_circuit.py +++ b/test/diff/golden/Python_Examples.Example_short_circuit/Example_short_circuit.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num import List @@ -47,7 +48,9 @@ def impl_case(xs): x = (True) return (x) -if_case_empty = (if_case([])) +@functools.cache +def if_case_empty(): + return (if_case([])) def conj_case_list(xss): if (not List.null(xss)): @@ -63,14 +66,26 @@ def conj_case_list(xss): x = (False) return (x) -conj_case_zero = (conj_case([0])) +@functools.cache +def conj_case_zero(): + return (conj_case([0])) -conj_case_empty = (conj_case([])) +@functools.cache +def conj_case_empty(): + return (conj_case([])) -disj_case_empty = (disj_case([])) +@functools.cache +def disj_case_empty(): + return (disj_case([])) -disj_case_three = (disj_case([max(0, 3)])) +@functools.cache +def disj_case_three(): + return (disj_case([max(0, 3)])) -impl_case_empty = (impl_case([])) +@functools.cache +def impl_case_empty(): + return (impl_case([])) -conj_case_list_empty = (conj_case_list([])) +@functools.cache +def conj_case_list_empty(): + return (conj_case_list([])) diff --git a/test/diff/golden/Python_Examples.Example_super/Example_super.py b/test/diff/golden/Python_Examples.Example_super/Example_super.py index 905f21d..e07b36e 100644 --- a/test/diff/golden/Python_Examples.Example_super/Example_super.py +++ b/test/diff/golden/Python_Examples.Example_super/Example_super.py @@ -59,4 +59,6 @@ def describable_verbose_color(): def announce_verbose(a_dict, x): return (a_dict.describable_describable_verbose.describe(x) + " -- " + a_dict.describe_verbose(x)) -announce_verbose_red = (announce_verbose(describable_verbose_color(), Red())) +@functools.cache +def announce_verbose_red(): + return (announce_verbose(describable_verbose_color(), Red())) diff --git a/test/diff/golden/Python_Examples.Example_super_chain/Example_super_chain.py b/test/diff/golden/Python_Examples.Example_super_chain/Example_super_chain.py index c1df7d7..e716dbd 100644 --- a/test/diff/golden/Python_Examples.Example_super_chain/Example_super_chain.py +++ b/test/diff/golden/Python_Examples.Example_super_chain/Example_super_chain.py @@ -133,6 +133,10 @@ def announce_chain(a_dict, x): def announce_multi(a_dict, x): return (a_dict.labeled_labeled_measured.label_of(x) + " (" + a_dict.measured_labeled_measured.size_label(x) + ") -- " + a_dict.full_description(x)) -announce_chain_cat = (announce_chain(tagged_extra_animal(), Cat())) +@functools.cache +def announce_chain_cat(): + return (announce_chain(tagged_extra_animal(), Cat())) -announce_multi_box = (announce_multi(labeled_measured_item(), Box())) +@functools.cache +def announce_multi_box(): + return (announce_multi(labeled_measured_item(), Box())) diff --git a/test/diff/golden/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py b/test/diff/golden/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py index f59286b..aa1bdfd 100644 --- a/test/diff/golden/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py +++ b/test/diff/golden/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from typing import Any, Callable +import functools def _abort(msg, thunk): raise RuntimeError(msg) @@ -9,7 +10,9 @@ def _abort(msg, thunk): def unbox(n): return (n) -unbox_test = (unbox(True)) +@functools.cache +def unbox_test(): + return (unbox(True)) def box_is_true(x0): match x0: @@ -20,4 +23,6 @@ def box_is_true(x0): case _: raise RuntimeError("match failed") -box_is_true_test = ((box_is_true(True), box_is_true(False))) +@functools.cache +def box_is_true_test(): + return ((box_is_true(True), box_is_true(False))) diff --git a/test/diff/golden/Python_Examples.Example_tuples/Example_tuples.py b/test/diff/golden/Python_Examples.Example_tuples/Example_tuples.py index 4323f44..978b957 100644 --- a/test/diff/golden/Python_Examples.Example_tuples/Example_tuples.py +++ b/test/diff/golden/Python_Examples.Example_tuples/Example_tuples.py @@ -2,14 +2,19 @@ from dataclasses import dataclass from typing import Any, Callable +import functools import Num def _abort(msg, thunk): raise RuntimeError(msg) -point = ((3, 4)) +@functools.cache +def point(): + return ((3, 4)) -triple = ((1, ((2, 3)))) +@functools.cache +def triple(): + return ((1, ((2, 3)))) def swap_pair(p): return (((p[1]), (p[0]))) @@ -19,8 +24,14 @@ def add_points(x0, x1): case ((x1a, y1), (x2, y2)): return ((((x1a + x2)), ((y1 + y2)))) -point_swapped = (swap_pair(point)) +@functools.cache +def point_swapped(): + return (swap_pair(point())) -points_sum = (add_points(point, point_swapped)) +@functools.cache +def points_sum(): + return (add_points(point(), point_swapped())) -points_list = ([point, point_swapped]) +@functools.cache +def points_list(): + return ([point(), point_swapped()]) diff --git a/test/diff/golden/Python_Examples.Example_tyclass/Example_tyclass.py b/test/diff/golden/Python_Examples.Example_tyclass/Example_tyclass.py index 4d4fd8f..f659028 100644 --- a/test/diff/golden/Python_Examples.Example_tyclass/Example_tyclass.py +++ b/test/diff/golden/Python_Examples.Example_tyclass/Example_tyclass.py @@ -59,6 +59,10 @@ def describable_shape(): def announce(a_dict, x): return (a_dict.describe(x) + a_dict.describe(x)) -announce_red = (announce(describable_color(), Red())) +@functools.cache +def announce_red(): + return (announce(describable_color(), Red())) -announce_circle = (announce(describable_shape(), Circle())) +@functools.cache +def announce_circle(): + return (announce(describable_shape(), Circle())) diff --git a/test/diff/golden_annotated/Python_Examples.Example/Example.py b/test/diff/golden_annotated/Python_Examples.Example/Example.py new file mode 100644 index 0000000..ddfd1ff --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example/Example.py @@ -0,0 +1,30 @@ +# Generated by Isabelle from theory Python_Examples.Example; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class Red: + pass +@dataclass(frozen=True) +class Green: + pass +@dataclass(frozen=True) +class Blue: + pass +type color = Red | Green | Blue + +def is_red(x0: color) -> bool: + match x0: + case Red(): + return (True) + case Green(): + return (False) + case Blue(): + return (False) + case _: + raise RuntimeError("match failed") diff --git a/test/diff/golden_annotated/Python_Examples.Example_annotation_edges/Example_annotation_edges.py b/test/diff/golden_annotated/Python_Examples.Example_annotation_edges/Example_annotation_edges.py new file mode 100644 index 0000000..cfd6279 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_annotation_edges/Example_annotation_edges.py @@ -0,0 +1,66 @@ +# Generated by Isabelle from theory Python_Examples.Example_annotation_edges; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class pointed[A]: + point: Callable[[], A] + +def point_fun[A, B](b_dict: pointed[B], x: A) -> B: + def lam(unused: A) -> B: + return (b_dict.point()) + return (lam(x)) + +def pointed_fun[A, B](b_dict: pointed[B]) -> pointed[Callable[[A], B]]: + return pointed(point = lambda : lambda a: point_fun(b_dict, a)) + +@_cached +def point_nat() -> int: + return (0) + +@_cached +def pointed_nat() -> pointed[int]: + return pointed(point = lambda : point_nat()) + +@dataclass(frozen=True) +class Leaf: + pass +@dataclass(frozen=True) +class Node[A]: + a: tree[A] + b: A + c: tree[A] +type tree[A] = Leaf | Node[A] + +def first_or[A](xs: list[A], f: Callable[[A], A], d: A) -> A: + target: list[A] = (xs) + match target: + case []: + return (d) + case [x, *_]: + return (f(x)) + case _: + raise RuntimeError("match failed") + +def grow(t: tree[int]) -> tree[int]: + def lam(l: tree[int]) -> tree[int]: + return (Node(l, 0, t)) + return (first_or(cast(list[tree[int]], [Leaf()]), lam, t)) + +def with_point[A](a_dict: pointed[A], x: A) -> tuple[A, A]: + return ((a_dict.point(), x)) + +@_cached +def fun_with_point() -> tuple[Callable[[int], int], Callable[[int], int]]: + def lam(n: int) -> int: + return ((n + 1)) + return (with_point(pointed_fun(pointed_nat()), lam)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Example_class_dicts.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Example_class_dicts.py new file mode 100644 index 0000000..03eca1f --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Example_class_dicts.py @@ -0,0 +1,56 @@ +# Generated by Isabelle from theory Python_Examples.Example_class_dicts; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import Product_Type +import Int +import Num +import HOL +import Orderings + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def weight[A](a_dict: tuple[HOL.equal[A], Orderings.linorder[A]], x: A, xa1: list[A]) -> int: + match (x, xa1): + case (xa, []): + return (0) + case (xa, [y, *ys]): + z: int + if (a_dict[1].order_linorder.preorder_order.ord_preorder.less(y, xa)): + z = (max(0, 2)) + else: + if (HOL.eq(a_dict[0], y, xa)): + z = (1) + else: + z = (0) + return ((z + weight((a_dict[0], a_dict[1]), xa, ys))) + case _: + raise RuntimeError("match failed") + +def weight_int(a: int, b: list[int]) -> int: + return (weight((Int.equal_int(), Int.linorder_int()), a, b)) + +def occurrences[A](a_dict: HOL.equal[A], x: A, xa1: list[A]) -> int: + match (x, xa1): + case (xa, []): + return (0) + case (xa, [y, *ys]): + z: int + if (HOL.eq(a_dict, xa, y)): + z = (1) + else: + z = (0) + return ((z + occurrences(a_dict, xa, ys))) + case _: + raise RuntimeError("match failed") + +def occurrences_int(a: int, b: list[int]) -> int: + return (occurrences(Int.equal_int(), a, b)) + +def occurrences_pair(a: tuple[int, int], b: list[tuple[int, int]]) -> int: + return (occurrences(Product_Type.equal_prod(Int.equal_int(), Int.equal_int()), a, b)) + +def occurrences_int_eta(x: int, ys: list[int]) -> int: + return (occurrences(Int.equal_int(), x, ys)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/HOL.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/HOL.py new file mode 100644 index 0000000..624eda7 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/HOL.py @@ -0,0 +1,15 @@ +# Generated by Isabelle from theory HOL.HOL; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class equal[A]: + equal_: Callable[[A, A], bool] + +def eq[A](a_dict: equal[A], aa: A, b: A) -> bool: + return (a_dict.equal_(aa, b)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Int.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Int.py new file mode 100644 index 0000000..8049434 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Int.py @@ -0,0 +1,34 @@ +# Generated by Isabelle from theory HOL.Int; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Orderings +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def equal_int() -> HOL.equal[int]: + return HOL.equal(equal_ = lambda a, b: (a == b)) + +@_cached +def ord_int() -> Orderings.ord_[int]: + return Orderings.ord_(less_eq = lambda a, b: (a <= b ), less = lambda a, b: (a < b)) + +@_cached +def preorder_int() -> Orderings.preorder[int]: + return Orderings.preorder(ord_preorder = ord_int()) + +@_cached +def order_int() -> Orderings.order[int]: + return Orderings.order(preorder_order = preorder_int()) + +@_cached +def linorder_int() -> Orderings.linorder[int]: + return Orderings.linorder(order_linorder = order_int()) diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Num.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Orderings.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Orderings.py new file mode 100644 index 0000000..281ce2e --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Orderings.py @@ -0,0 +1,25 @@ +# Generated by Isabelle from theory HOL.Orderings; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class ord_[A]: + less_eq: Callable[[A, A], bool] + less: Callable[[A, A], bool] + +@dataclass(frozen=True) +class preorder[A]: + ord_preorder: ord_[A] + +@dataclass(frozen=True) +class order[A]: + preorder_order: preorder[A] + +@dataclass(frozen=True) +class linorder[A]: + order_linorder: order[A] diff --git a/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Product_Type.py b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Product_Type.py new file mode 100644 index 0000000..4df048d --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_class_dicts/Product_Type.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Product_Type; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def equal_prod_[A, B](a_dict: HOL.equal[A], b_dict: HOL.equal[B], x0: tuple[A, B], x1: tuple[A, B]) -> bool: + match (x0, x1): + case ((x1a, x2), (y1, y2)): + return (HOL.eq(a_dict, x1a, y1) and HOL.eq(b_dict, x2, y2)) + case _: + raise RuntimeError("match failed") + +def equal_prod[A, B](a_dict: HOL.equal[A], b_dict: HOL.equal[B]) -> HOL.equal[tuple[A, B]]: + return HOL.equal(equal_ = lambda a, b: equal_prod_(a_dict, b_dict, a, b)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel.py b/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel.py new file mode 100644 index 0000000..fb947fe --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel.py @@ -0,0 +1,32 @@ +# Generated by Isabelle from theory Python_Examples.Example_classrel; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Example_classrel_base + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def sup_apply_bool(b: bool) -> bool: + return (b) + +@_cached +def super_op_bool() -> Example_classrel_base.super_op[bool]: + return Example_classrel_base.super_op(sup_apply = lambda a: sup_apply_bool(a)) + +@_cached +def sub_op_bool() -> Example_classrel_base.sub_op[bool]: + return Example_classrel_base.sub_op(super_op_sub_op = super_op_bool()) + +@_cached +def test_sub() -> bool: + return (Example_classrel_base.sub_apply(sub_op_bool(), True)) + +@_cached +def test_super() -> bool: + return (sup_apply_bool(True)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel_base.py b/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel_base.py new file mode 100644 index 0000000..bfc354e --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_classrel/Example_classrel_base.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory Python_Examples.Example_classrel_base; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class super_op[A]: + sup_apply: Callable[[A], A] + +@dataclass(frozen=True) +class sub_op[A]: + super_op_sub_op: super_op[A] + +def sub_apply[A](a_dict: sub_op[A], x: A) -> A: + return (a_dict.super_op_sub_op.sup_apply(a_dict.super_op_sub_op.sup_apply(x))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Example_code_numerals.py b/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Example_code_numerals.py new file mode 100644 index 0000000..0fce225 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Example_code_numerals.py @@ -0,0 +1,39 @@ +# Generated by Isabelle from theory Python_Examples.Example_code_numerals; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def cn_add(x: int, y: int) -> int: + return ((x + y)) + +@_cached +def cn_neg() -> int: + return (-5) + +@_cached +def cn_int_lit() -> int: + return (42) + +@_cached +def cn_sum() -> int: + return (cn_add(cn_int_lit(), 8)) + +def cn_nat_add(x: int, y: int) -> int: + return ((x + y)) + +@_cached +def cn_nat_lit() -> int: + return (max(0, 7)) + +@_cached +def cn_nat_sum() -> int: + return (cn_nat_add(cn_nat_lit(), (max(0, 3)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Num.py b/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_code_numerals/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py new file mode 100644 index 0000000..c295aa1 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Example_generic_list_pair.py @@ -0,0 +1,53 @@ +# Generated by Isabelle from theory Python_Examples.Example_generic_list_pair; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import List +import Product_Type + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def swap(x0: Product_Type.prod[bool, bool]) -> Product_Type.prod[bool, bool]: + match x0: + case Product_Type.Pair(x, y): + return (Product_Type.Pair(y, x)) + case _: + raise RuntimeError("match failed") + +def any_true(x0: List.list_[bool]) -> bool: + match x0: + case List.Nil(): + return (False) + case List.Cons(x, xs): + return (x or any_true(xs)) + case _: + raise RuntimeError("match failed") + +@_cached +def test_swap() -> Product_Type.prod[bool, bool]: + return (swap(Product_Type.Pair(True, False))) + +@_cached +def test_any_true() -> bool: + return (any_true(List.Cons(False, List.Cons(False, List.Cons(True, List.Nil()))))) + +def first_two_agree(x0: List.list_[bool]) -> bool: + match x0: + case List.Cons(x, List.Cons(y, uu)): + return (x == y) + case List.Nil(): + return (False) + case List.Cons(v, List.Nil()): + return (False) + case _: + raise RuntimeError("match failed") + +@_cached +def test_first_two() -> Product_Type.prod[bool, bool]: + return (Product_Type.Pair(first_two_agree(List.Cons(True, List.Cons(True, List.Cons(False, List.Nil())))), first_two_agree(List.Cons(True, List.Nil())))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/List.py b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/List.py new file mode 100644 index 0000000..e35c1f9 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/List.py @@ -0,0 +1,17 @@ +# Generated by Isabelle from theory HOL.List; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class Nil: + pass +@dataclass(frozen=True) +class Cons[A]: + a: A + b: list_[A] +type list_[A] = Nil | Cons[A] diff --git a/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Product_Type.py b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Product_Type.py new file mode 100644 index 0000000..7cb38b3 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_generic_list_pair/Product_Type.py @@ -0,0 +1,14 @@ +# Generated by Isabelle from theory HOL.Product_Type; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class Pair[A, B]: + a: A + b: B +type prod[A, B] = Pair[A, B] diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/Example_iarray.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/Example_iarray.py new file mode 100644 index 0000000..6f793b3 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/Example_iarray.py @@ -0,0 +1,48 @@ +# Generated by Isabelle from theory Python_Examples.Example_iarray; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import IArray +import Num +import Nat + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def sum_ends(a: tuple[int, ...]) -> int: + return (((a[0]) + (a[(max(0, (len(a)) - 1))]))) + +@_cached +def squares() -> tuple[int, ...]: + def lam(i: int) -> int: + return ((i * i)) + return (tuple(map(lam, range((max(0, 4)))))) + +@_cached +def example() -> tuple[list[int], tuple[int, tuple[bool, bool]]]: + def lam(x: int) -> bool: + return ((x < (max(0, 10)))) + def lan(a: int) -> int: + return ((a + 1)) + return (((list(squares())), ((sum_ends(squares()), (((all(map(lam, squares()))), IArray.equal_iarray(Nat.equal_nat(), cast(tuple[int, ...], tuple((list(map(lan, [1, max(0, 2)]))))), cast(tuple[int, ...], tuple([max(0, 2), max(0, 3)]))))))))) + +def sub_pair(p: tuple[tuple[int, ...], int]) -> int: + return ((lambda p: p[0][p[1]])(p)) + +@_cached +def example_nth() -> int: + return ([10, 20, 30][1]) + +def first_or_zero(x0: tuple[int, ...]) -> int: + match x0: + case []: + return (0) + case [x, *uu]: + return (x) + case _: + raise RuntimeError("match failed") diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/HOL.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/HOL.py new file mode 100644 index 0000000..624eda7 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/HOL.py @@ -0,0 +1,15 @@ +# Generated by Isabelle from theory HOL.HOL; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class equal[A]: + equal_: Callable[[A, A], bool] + +def eq[A](a_dict: equal[A], aa: A, b: A) -> bool: + return (a_dict.equal_(aa, b)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/IArray.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/IArray.py new file mode 100644 index 0000000..d36cb0b --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/IArray.py @@ -0,0 +1,13 @@ +# Generated by Isabelle from theory HOL-Library.IArray; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import List +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def equal_iarray[A](a_dict: HOL.equal[A], asa: tuple[A, ...], bs: tuple[A, ...]) -> bool: + return (List.equal_list(a_dict, (list(asa)), (list(bs)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/List.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/List.py new file mode 100644 index 0000000..e3ea4fe --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/List.py @@ -0,0 +1,22 @@ +# Generated by Isabelle from theory HOL.List; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def equal_list[A](a_dict: HOL.equal[A], x0: list[A], x1: list[A]) -> bool: + match (x0, x1): + case ([], [x21, *x22]): + return (False) + case ([x21, *x22], []): + return (False) + case ([x21, *x22], [y21, *y22]): + return (HOL.eq(a_dict, x21, y21) and equal_list(a_dict, x22, y22)) + case ([], []): + return (True) + case _: + raise RuntimeError("match failed") diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/Nat.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/Nat.py new file mode 100644 index 0000000..4c201fa --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/Nat.py @@ -0,0 +1,17 @@ +# Generated by Isabelle from theory HOL.Nat; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def equal_nat() -> HOL.equal[int]: + return HOL.equal(equal_ = lambda a, b: (a == b)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_iarray/Num.py b/test/diff/golden_annotated/Python_Examples.Example_iarray/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_iarray/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_int_arith/Example_int_arith.py b/test/diff/golden_annotated/Python_Examples.Example_int_arith/Example_int_arith.py new file mode 100644 index 0000000..6f41913 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_int_arith/Example_int_arith.py @@ -0,0 +1,52 @@ +# Generated by Isabelle from theory Python_Examples.Example_int_arith; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def product() -> int: + return ((6 * 7)) + +def checksum(x: int, y: int) -> int: + return ((((lambda a, b: a % b if b else a)(((x * y)), ((y - x)))) + ((lambda a, b: a // b if b else 0)(x, 2)))) + +@_cached +def zero_test() -> int: + return (0) + +@_cached +def neg_product() -> int: + return ((((- 3)) * 4)) + +@_cached +def quotient_neg() -> int: + return ((lambda a, b: a // b if b else 0)(((- 7)), 2)) + +@_cached +def quotient_pos() -> int: + return ((lambda a, b: a // b if b else 0)(7, 2)) + +@_cached +def remainder_neg() -> int: + return ((lambda a, b: a % b if b else a)(((- 7)), 2)) + +@_cached +def remainder_pos() -> int: + return ((lambda a, b: a % b if b else a)(7, 2)) + +@_cached +def quotient_neg_divisor() -> int: + return ((lambda a, b: a // b if b else 0)(7, ((- 2)))) + +@_cached +def remainder_neg_divisor() -> int: + return ((lambda a, b: a % b if b else a)(7, ((- 2)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_int_arith/Num.py b/test/diff/golden_annotated/Python_Examples.Example_int_arith/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_int_arith/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Arith.py b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Arith.py new file mode 100644 index 0000000..8b6f2b4 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Arith.py @@ -0,0 +1,66 @@ +# Generated by Isabelle from theory HOL.Code_Numeral; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num +import Power +import Groups + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def one_integer() -> Groups.one[int]: + return Groups.one(one_ = lambda : 1) + +@_cached +def times_integer() -> Groups.times[int]: + return Groups.times(times_ = lambda a, b: (a * b)) + +@_cached +def power_integer() -> Power.power[int]: + return Power.power(one_power = one_integer(), times_power = times_integer()) + +def drop_bit(i: int, k: int) -> int: + return ((lambda a, b: a // b if b else 0)(k, Power.power_(power_integer(), 2, (max(0, (abs(i))))))) + +def push_bit(i: int, k: int) -> int: + return ((k * Power.power_(power_integer(), 2, (max(0, (abs(i))))))) + +def sgn_integer(k: int) -> int: + if ((k == 0)): + return (0) + else: + if ((k < 0)): + return (-1) + else: + return (1) + +def push_bit_integer(n: int, k: int) -> int: + return (push_bit(n, k)) + +def bit_integer(k: int, n: int) -> bool: + return (not ((((k & push_bit_integer(n, 1))) == 0))) + +def mask_integer(n: int) -> int: + return ((push_bit_integer(n, 1) - 1)) + +def set_bit_integer(n: int, k: int) -> int: + return ((k | push_bit_integer(n, 1))) + +def drop_bit_integer(n: int, k: int) -> int: + return (drop_bit(n, k)) + +def flip_bit_integer(n: int, k: int) -> int: + return ((k ^ push_bit_integer(n, 1))) + +def take_bit_integer(n: int, k: int) -> int: + return ((k & mask_integer(n))) + +def unset_bit_integer(n: int, k: int) -> int: + return ((k & ((~ push_bit_integer(n, 1))))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py new file mode 100644 index 0000000..6d7b2d0 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Example_integer_bit_ops.py @@ -0,0 +1,50 @@ +# Generated by Isabelle from theory Python_Examples.Example_integer_bit_ops; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Arith +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def test_bit() -> bool: + return (Arith.bit_integer(10, 1)) + +@_cached +def test_sgn() -> int: + return (Arith.sgn_integer(-42)) + +@_cached +def test_mask() -> int: + return (Arith.mask_integer((max(0, 5)))) + +@_cached +def test_set_bit() -> int: + return (Arith.set_bit_integer((max(0, 2)), 0)) + +@_cached +def test_drop_bit() -> int: + return (Arith.drop_bit_integer((max(0, 2)), 20)) + +@_cached +def test_flip_bit() -> int: + return (Arith.flip_bit_integer(1, 5)) + +@_cached +def test_push_bit() -> int: + return (Arith.push_bit_integer((max(0, 3)), 5)) + +@_cached +def test_take_bit() -> int: + return (Arith.take_bit_integer((max(0, 4)), 255)) + +@_cached +def test_unset_bit() -> int: + return (Arith.unset_bit_integer(0, 7)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Groups.py b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Groups.py new file mode 100644 index 0000000..096585d --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Groups.py @@ -0,0 +1,16 @@ +# Generated by Isabelle from theory HOL.Groups; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class one[A]: + one_: Callable[[], A] + +@dataclass(frozen=True) +class times[A]: + times_: Callable[[A, A], A] diff --git a/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Num.py b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Power.py b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Power.py new file mode 100644 index 0000000..c2af789 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_integer_bit_ops/Power.py @@ -0,0 +1,20 @@ +# Generated by Isabelle from theory HOL.Power; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import Groups + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class power[A]: + one_power: Groups.one[A] + times_power: Groups.times[A] + +def power_[A](a_dict: power[A], aa: A, n: int) -> A: + if ((n == 0)): + return (a_dict.one_power.one_()) + else: + return (a_dict.times_power.times_(aa, power_(a_dict, aa, (max(0, n - 1))))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Example_lambda_case.py b/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Example_lambda_case.py new file mode 100644 index 0000000..2fa829f --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Example_lambda_case.py @@ -0,0 +1,38 @@ +# Generated by Isabelle from theory Python_Examples.Example_lambda_case; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import Option + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def doubled(xs: list[int]) -> list[int]: + def lam(n: int) -> int: + return ((n + n)) + return (list(map(lam, xs))) + +def sum_or_zero(x0: Option.option[int]) -> int: + match x0: + case Option.None_(): + return (0) + case Option.Some(n): + return (n) + case _: + raise RuntimeError("match failed") + +def sum_options_named(xs: list[Option.option[int]]) -> list[int]: + return (list(map(sum_or_zero, xs))) + +def sum_options_inline(xs: list[Option.option[int]]) -> list[int]: + def lam(a: Option.option[int]) -> int: + target: Option.option[int] = (a) + match target: + case Option.None_(): + return (0) + case Option.Some(n): + return (n) + case _: + raise RuntimeError("match failed") + return (list(map(lam, xs))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Option.py b/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Option.py new file mode 100644 index 0000000..60eb7e0 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_lambda_case/Option.py @@ -0,0 +1,16 @@ +# Generated by Isabelle from theory HOL.Option; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class None_: + pass +@dataclass(frozen=True) +class Some[A]: + a: A +type option[A] = None_ | Some[A] diff --git a/test/diff/golden_annotated/Python_Examples.Example_lists/Example_lists.py b/test/diff/golden_annotated/Python_Examples.Example_lists/Example_lists.py new file mode 100644 index 0000000..5fde9bc --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_lists/Example_lists.py @@ -0,0 +1,24 @@ +# Generated by Isabelle from theory Python_Examples.Example_lists; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def example() -> list[int]: + return ([1, 2, 3]) + +def prepend[A](x: A, xs: list[A]) -> list[A]: + return ([x] + xs) + +@_cached +def example2() -> list[int]: + return (prepend(5, example())) diff --git a/test/diff/golden_annotated/Python_Examples.Example_lists/Num.py b/test/diff/golden_annotated/Python_Examples.Example_lists/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_lists/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat/Example_nat.py b/test/diff/golden_annotated/Python_Examples.Example_nat/Example_nat.py new file mode 100644 index 0000000..10ca330 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat/Example_nat.py @@ -0,0 +1,60 @@ +# Generated by Isabelle from theory Python_Examples.Example_nat; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def nat_sum() -> int: + return (((max(0, 6)) + (max(0, 7)))) + +@_cached +def nat_eq_test() -> bool: + return (((max(0, 4)) == (max(0, 4)))) + +@_cached +def nat_le_test() -> bool: + return (((max(0, 3)) <= (max(0, 5)))) + +@_cached +def nat_literal() -> int: + return (max(0, 42)) + +@_cached +def nat_lt_test() -> bool: + return (((max(0, 5)) < (max(0, 3)))) + +@_cached +def nat_product() -> int: + return (((max(0, 6)) * (max(0, 7)))) + +@_cached +def nat_sub_pos() -> int: + return (max(0, (max(0, 10)) - (max(0, 3)))) + +def nat_checksum(x: int, y: int) -> int: + return ((((lambda a, b: a % b if b else a)(((x * y)), ((y + 1)))) + (max(0, x - y)))) + +@_cached +def nat_quotient() -> int: + return ((lambda a, b: a // b if b else 0)((max(0, 7)), (max(0, 2)))) + +@_cached +def nat_remainder() -> int: + return ((lambda a, b: a % b if b else a)((max(0, 7)), (max(0, 2)))) + +@_cached +def nat_sub_trunc() -> int: + return (max(0, (max(0, 3)) - (max(0, 10)))) + +@_cached +def nat_zero_test() -> int: + return (0) diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat/Num.py b/test/diff/golden_annotated/Python_Examples.Example_nat/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py b/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py new file mode 100644 index 0000000..19600a8 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Example_nat_edge_cases.py @@ -0,0 +1,55 @@ +# Generated by Isabelle from theory Python_Examples.Example_nat_edge_cases; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def peel_positive_head(x0: list[int]) -> int: + match x0: + case []: + return (0) + case [n, *va]: + if ((n == 0)): + return (0) + else: + return (max(0, n - 1)) + case _: + raise RuntimeError("match failed") + +@_cached +def peel_test() -> int: + return (peel_positive_head([max(0, 3), max(0, 4), max(0, 5)])) + +def nat_minus2(v: int, n: int) -> int: + if ((v == 0)): + return (0) + else: + if ((n == 0)): + return (((max(0, v - 1)) + 1)) + else: + return (nat_minus2((max(0, v - 1)), (max(0, n - 1)))) + +def classify_small(uu: int) -> int: + if ((uu == 0)): + return (0) + else: + if (((max(0, uu - 1)) == 0)): + return (1) + else: + return (max(0, 2)) + +@_cached +def classify_test() -> tuple[int, tuple[int, int]]: + return ((classify_small(0), ((classify_small(1), classify_small((max(0, 7))))))) + +@_cached +def nat_minus2_test() -> int: + return (nat_minus2((max(0, 5)), (max(0, 3)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Num.py b/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat_edge_cases/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Example_nat_pattern.py b/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Example_nat_pattern.py new file mode 100644 index 0000000..0439f8b --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Example_nat_pattern.py @@ -0,0 +1,43 @@ +# Generated by Isabelle from theory Python_Examples.Example_nat_pattern; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def fact(n: int) -> int: + if ((n == 0)): + return (1) + else: + return (((((max(0, n - 1)) + 1)) * fact((max(0, n - 1))))) + +@_cached +def fact_5() -> int: + return (fact((max(0, 5)))) + +def countdown(n: int) -> list[int]: + if ((n == 0)): + return ([0]) + else: + return ([((max(0, n - 1)) + 1)] + countdown((max(0, n - 1)))) + +def nat_is_even(n: int) -> bool: + if ((n == 0)): + return (True) + else: + return (not nat_is_even((max(0, n - 1)))) + +@_cached +def is_even_7() -> bool: + return (nat_is_even((max(0, 7)))) + +@_cached +def countdown_4() -> list[int]: + return (countdown((max(0, 4)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Num.py b/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nat_pattern/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_nested_case/Example_nested_case.py b/test/diff/golden_annotated/Python_Examples.Example_nested_case/Example_nested_case.py new file mode 100644 index 0000000..4d1a2ab --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nested_case/Example_nested_case.py @@ -0,0 +1,94 @@ +# Generated by Isabelle from theory Python_Examples.Example_nested_case; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def weird(n: int) -> int: + if ((n == 0)): + return (1) + else: + x: int + if ((n == 0)): + x = (max(0, 10)) + else: + x = (((max(0, 20)) + (max(0, n - 1)))) + return ((1 + x)) + +def classify(n: int) -> int: + x: int + if ((n == 0)): + x = (max(0, 100)) + else: + x = (max(0, 200)) + return ((1 + x)) + +def nat_label(n: int) -> int: + x: int + if ((n == 0)): + x = (max(0, 10)) + else: + x = (((max(0, 20)) + (max(0, n - 1)))) + return ((1 + x)) + +def abs_manual(x: int) -> int: + if ((x < 0)): + return ((- x)) + else: + return (x) + +@_cached +def label_five() -> int: + return (nat_label((max(0, 5)))) + +@_cached +def label_zero() -> int: + return (nat_label(0)) + +@_cached +def weird_five() -> int: + return (weird((max(0, 5)))) + +@_cached +def weird_zero() -> int: + return (weird(0)) + +def describe_len(xs: list[int]) -> int: + x: int + target: list[int] = (xs) + match target: + case []: + x = (0) + case [_, *a]: + x = (len(a)) + case _: + raise RuntimeError("match failed") + return ((x + 1)) + +@_cached +def classify_zero() -> int: + return (classify(0)) + +@_cached +def abs_manual_neg() -> int: + return (abs_manual(((- 7)))) + +@_cached +def abs_manual_pos() -> int: + return (abs_manual(7)) + +@_cached +def classify_other() -> int: + return (classify((max(0, 5)))) + +@_cached +def describe_len_123() -> int: + return (describe_len([1, max(0, 2), max(0, 3)])) diff --git a/test/diff/golden_annotated/Python_Examples.Example_nested_case/Num.py b/test/diff/golden_annotated/Python_Examples.Example_nested_case/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nested_case/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_nested_if/Example_nested_if.py b/test/diff/golden_annotated/Python_Examples.Example_nested_if/Example_nested_if.py new file mode 100644 index 0000000..a704284 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nested_if/Example_nested_if.py @@ -0,0 +1,69 @@ +# Generated by Isabelle from theory Python_Examples.Example_nested_if; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def grade_code(score: int) -> int: + if ((score < (max(0, 60)))): + return (0) + else: + if ((score < (max(0, 70)))): + return (1) + else: + if ((score < (max(0, 80)))): + return (max(0, 2)) + else: + if ((score < (max(0, 90)))): + return (max(0, 3)) + else: + return (max(0, 4)) + +@_cached +def grade_a() -> int: + return (grade_code((max(0, 95)))) + +@_cached +def grade_b() -> int: + return (grade_code((max(0, 85)))) + +@_cached +def grade_c() -> int: + return (grade_code((max(0, 75)))) + +@_cached +def grade_d() -> int: + return (grade_code((max(0, 65)))) + +@_cached +def grade_f() -> int: + return (grade_code((max(0, 40)))) + +def nested_then(x: int, y: int) -> int: + if ((0 < x)): + if ((0 < y)): + return (1) + else: + return (2) + else: + return (3) + +@_cached +def nested_then_f() -> int: + return (nested_then(((- 1)), 1)) + +@_cached +def nested_then_tf() -> int: + return (nested_then(1, ((- 1)))) + +@_cached +def nested_then_tt() -> int: + return (nested_then(1, 1)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_nested_if/Num.py b/test/diff/golden_annotated/Python_Examples.Example_nested_if/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_nested_if/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_no_eqs/Example_no_eqs.py b/test/diff/golden_annotated/Python_Examples.Example_no_eqs/Example_no_eqs.py new file mode 100644 index 0000000..1c8d0a7 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_no_eqs/Example_no_eqs.py @@ -0,0 +1,17 @@ +# Generated by Isabelle from theory Python_Examples.Example_no_eqs; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import HOL + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def uses_undefined() -> int: + return (HOL.undefined()) diff --git a/test/diff/golden_annotated/Python_Examples.Example_no_eqs/HOL.py b/test/diff/golden_annotated/Python_Examples.Example_no_eqs/HOL.py new file mode 100644 index 0000000..a05277d --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_no_eqs/HOL.py @@ -0,0 +1,11 @@ +# Generated by Isabelle from theory HOL.HOL; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def undefined[A]() -> Never: + _abort("HOL.undefined", None) diff --git a/test/diff/golden_annotated/Python_Examples.Example_options/Example_options.py b/test/diff/golden_annotated/Python_Examples.Example_options/Example_options.py new file mode 100644 index 0000000..e4abfdd --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_options/Example_options.py @@ -0,0 +1,56 @@ +# Generated by Isabelle from theory Python_Examples.Example_options; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num +import Option + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def describe_opt(x0: Option.option[int]) -> int: + match x0: + case Option.None_(): + return (0) + case Option.Some(x): + return ((x + 1)) + case _: + raise RuntimeError("match failed") + +@_cached +def o_some() -> Option.option[int]: + return (Option.Some(5)) + +@_cached +def d1() -> int: + return (describe_opt(o_some())) + +@_cached +def o_none() -> Option.option[int]: + return (Option.None_()) + +@_cached +def d2() -> int: + return (describe_opt(o_none())) + +def describe_opt2(x0: Option.option[int]) -> int: + match x0: + case Option.Some(x): + return ((x + 100)) + case Option.None_(): + return ((- 1)) + case _: + raise RuntimeError("match failed") + +@_cached +def d3() -> int: + return (describe_opt2(o_some())) + +@_cached +def d4() -> int: + return (describe_opt2(o_none())) diff --git a/test/diff/golden_annotated/Python_Examples.Example_options/Num.py b/test/diff/golden_annotated/Python_Examples.Example_options/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_options/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_options/Option.py b/test/diff/golden_annotated/Python_Examples.Example_options/Option.py new file mode 100644 index 0000000..60eb7e0 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_options/Option.py @@ -0,0 +1,16 @@ +# Generated by Isabelle from theory HOL.Option; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class None_: + pass +@dataclass(frozen=True) +class Some[A]: + a: A +type option[A] = None_ | Some[A] diff --git a/test/diff/golden_annotated/Python_Examples.Example_partial/Example_partial.py b/test/diff/golden_annotated/Python_Examples.Example_partial/Example_partial.py new file mode 100644 index 0000000..8a3d716 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_partial/Example_partial.py @@ -0,0 +1,40 @@ +# Generated by Isabelle from theory Python_Examples.Example_partial; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def add2(x: int, y: int) -> int: + return ((x + y)) + +@_cached +def add_one() -> Callable[[int], int]: + def lam(a: int) -> int: + return (add2(1, a)) + return (lam) + +def add2_ref(a: int, b: int) -> int: + return (add2(a, b)) + +@_cached +def p_mapped() -> list[int]: + return (list(map(add_one(), [1, 2, 3]))) + +def apply_twice(f: Callable[[int], int], x: int) -> int: + return (f(f(x))) + +@_cached +def p_result() -> int: + return (apply_twice(add_one(), 5)) + +@_cached +def p_ref_result() -> int: + return (add2_ref(3, 4)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_partial/Num.py b/test/diff/golden_annotated/Python_Examples.Example_partial/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_partial/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py b/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py new file mode 100644 index 0000000..ade4502 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Example_polymorphic_const.py @@ -0,0 +1,29 @@ +# Generated by Isabelle from theory Python_Examples.Example_polymorphic_const; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def empty_list[A]() -> list[A]: + return ([]) + +@_cached +def magic_number() -> int: + return (max(0, 42)) + +@_cached +def uses_empty_list() -> list[int]: + return (empty_list()) + +@_cached +def uses_magic_number() -> int: + return ((magic_number() + 1)) diff --git a/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Num.py b/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_polymorphic_const/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_record_ext/Example_record_ext.py b/test/diff/golden_annotated/Python_Examples.Example_record_ext/Example_record_ext.py new file mode 100644 index 0000000..2314b17 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_record_ext/Example_record_ext.py @@ -0,0 +1,74 @@ +# Generated by Isabelle from theory Python_Examples.Example_record_ext; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class point_ext_[A]: + px: int + py: int + more: A +type point_ext[A] = point_ext_[A] + +@dataclass(frozen=True) +class point3d_ext_[A]: + pz: int + more: A +type point3d_ext[A] = point3d_ext_[A] + +def pz_update[A](pza: Callable[[int], int], x1: point_ext[point3d_ext[A]]) -> point_ext[point3d_ext[A]]: + match (pza, x1): + case (pzaa, point_ext_(px, py, point3d_ext_(pz, more))): + return (point_ext_(px, py, point3d_ext_((pzaa(pz)), more))) + case _: + raise RuntimeError("match failed") + +def pz[A](x0: point_ext[point3d_ext[A]]) -> int: + match x0: + case point_ext_(px, py, point3d_ext_(pz, more)): + return (pz) + case _: + raise RuntimeError("match failed") + +def move_z(p: point_ext[point3d_ext[None]], dz: int) -> point_ext[point3d_ext[None]]: + def lam(unused: int) -> int: + return ((pz(p) + dz)) + return (pz_update(lam, p)) + +def py[A](x0: point_ext[A]) -> int: + match x0: + case point_ext_(px, py, more): + return (py) + case _: + raise RuntimeError("match failed") + +def px[A](x0: point_ext[A]) -> int: + match x0: + case point_ext_(px, py, more): + return (px) + case _: + raise RuntimeError("match failed") + +def point3d_sum(p: point_ext[point3d_ext[None]]) -> int: + return ((((px(p) + py(p))) + pz(p))) + +@_cached +def origin3d() -> point_ext[point3d_ext[None]]: + return (point_ext_(0, 0, point3d_ext_(0, None))) + +@_cached +def shifted3d() -> point_ext[point3d_ext[None]]: + return (move_z(origin3d(), 7)) + +@_cached +def total3d() -> int: + return (point3d_sum(shifted3d())) diff --git a/test/diff/golden_annotated/Python_Examples.Example_record_ext/Num.py b/test/diff/golden_annotated/Python_Examples.Example_record_ext/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_record_ext/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_records/Example_records.py b/test/diff/golden_annotated/Python_Examples.Example_records/Example_records.py new file mode 100644 index 0000000..90fb93f --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_records/Example_records.py @@ -0,0 +1,61 @@ +# Generated by Isabelle from theory Python_Examples.Example_records; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class point_ext_[A]: + px: int + py: int + more: A +type point_ext[A] = point_ext_[A] + +def py[A](x0: point_ext[A]) -> int: + match x0: + case point_ext_(px, py, more): + return (py) + case _: + raise RuntimeError("match failed") + +def px[A](x0: point_ext[A]) -> int: + match x0: + case point_ext_(px, py, more): + return (px) + case _: + raise RuntimeError("match failed") + +def point_sum(p: point_ext[None], q: point_ext[None]) -> int: + return ((((((px(p) + py(p))) + px(q))) + py(q))) + +@_cached +def origin() -> point_ext[None]: + return (point_ext_(0, 0, None)) + +def px_update[A](pxa: Callable[[int], int], x1: point_ext[A]) -> point_ext[A]: + match (pxa, x1): + case (pxaa, point_ext_(px, py, more)): + return (point_ext_((pxaa(px)), py, more)) + case _: + raise RuntimeError("match failed") + +def move_x(p: point_ext[None], dx: int) -> point_ext[None]: + def lam(unused: int) -> int: + return ((px(p) + dx)) + return (px_update(lam, p)) + +@_cached +def shifted() -> point_ext[None]: + return (move_x(origin(), 5)) + +@_cached +def total() -> int: + return (point_sum(origin(), shifted())) diff --git a/test/diff/golden_annotated/Python_Examples.Example_records/Num.py b/test/diff/golden_annotated/Python_Examples.Example_records/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_records/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Example_short_circuit.py b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Example_short_circuit.py new file mode 100644 index 0000000..d191fe1 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Example_short_circuit.py @@ -0,0 +1,95 @@ +# Generated by Isabelle from theory Python_Examples.Example_short_circuit; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num +import List + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def if_case(xs: list[int]) -> bool: + if (List.null(xs)): + return (False) + else: + if ((List.hd(xs) == 0)): + return (True) + else: + return (False) + +def conj_case(xs: list[int]) -> bool: + if (not List.null(xs)): + if ((List.hd(xs) == 0)): + x = (True) + else: + x = (False) + else: + x = (False) + return (x) + +def disj_case(xs: list[int]) -> bool: + if (List.null(xs)): + x = (True) + else: + if ((List.hd(xs) == 0)): + x = (True) + else: + x = (False) + return (x) + +def impl_case(xs: list[int]) -> bool: + if (not List.null(xs)): + if ((List.hd(xs) == 0)): + x = (True) + else: + x = (False) + else: + x = (True) + return (x) + +@_cached +def if_case_empty() -> bool: + return (if_case([])) + +def conj_case_list(xss: list[list[int]]) -> bool: + if (not List.null(xss)): + target: list[int] = (List.hd(xss)) + match target: + case []: + x = (True) + case [_, *_]: + x = (False) + case _: + raise RuntimeError("match failed") + else: + x = (False) + return (x) + +@_cached +def conj_case_zero() -> bool: + return (conj_case([0])) + +@_cached +def conj_case_empty() -> bool: + return (conj_case([])) + +@_cached +def disj_case_empty() -> bool: + return (disj_case([])) + +@_cached +def disj_case_three() -> bool: + return (disj_case([max(0, 3)])) + +@_cached +def impl_case_empty() -> bool: + return (impl_case([])) + +@_cached +def conj_case_list_empty() -> bool: + return (conj_case_list([])) diff --git a/test/diff/golden_annotated/Python_Examples.Example_short_circuit/List.py b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/List.py new file mode 100644 index 0000000..e9dab7a --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/List.py @@ -0,0 +1,24 @@ +# Generated by Isabelle from theory HOL.List; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def null[A](x0: list[A]) -> bool: + match x0: + case []: + return (True) + case [x, *xs]: + return (False) + case _: + raise RuntimeError("match failed") + +def hd[A](x0: list[A]) -> A: + match x0: + case [x21, *x22]: + return (x21) + case _: + raise RuntimeError("match failed") diff --git a/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Num.py b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_short_circuit/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_super/Example_super.py b/test/diff/golden_annotated/Python_Examples.Example_super/Example_super.py new file mode 100644 index 0000000..2504091 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_super/Example_super.py @@ -0,0 +1,69 @@ +# Generated by Isabelle from theory Python_Examples.Example_super; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class Red: + pass +@dataclass(frozen=True) +class Green: + pass +@dataclass(frozen=True) +class Blue: + pass +type color = Red | Green | Blue + +def describe_color(x0: color) -> str: + match x0: + case Red(): + return ("red") + case Green(): + return ("green") + case Blue(): + return ("blue") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class describable[A]: + describe: Callable[[A], str] + +@_cached +def describable_color() -> describable[color]: + return describable(describe = lambda a: describe_color(a)) + +def describe_verbose_color(x0: color) -> str: + match x0: + case Red(): + return ("the color red") + case Green(): + return ("the color green") + case Blue(): + return ("the color blue") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class describable_verbose[A]: + describable_describable_verbose: describable[A] + describe_verbose: Callable[[A], str] + +@_cached +def describable_verbose_color() -> describable_verbose[color]: + return describable_verbose(describable_describable_verbose = describable_color(), describe_verbose = lambda a: describe_verbose_color(a)) + +def announce_verbose[A](a_dict: describable_verbose[A], x: A) -> str: + return (a_dict.describable_describable_verbose.describe(x) + " -- " + a_dict.describe_verbose(x)) + +@_cached +def announce_verbose_red() -> str: + return (announce_verbose(describable_verbose_color(), cast(color, Red()))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_super_chain/Example_super_chain.py b/test/diff/golden_annotated/Python_Examples.Example_super_chain/Example_super_chain.py new file mode 100644 index 0000000..5b6d4e8 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_super_chain/Example_super_chain.py @@ -0,0 +1,148 @@ +# Generated by Isabelle from theory Python_Examples.Example_super_chain; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class Box: + pass +@dataclass(frozen=True) +class Crate: + pass +type item = Box | Crate + +def label_of_item(x0: item) -> str: + match x0: + case Box(): + return ("box") + case Crate(): + return ("crate") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class labeled[A]: + label_of: Callable[[A], str] + +@_cached +def labeled_item() -> labeled[item]: + return labeled(label_of = lambda a: label_of_item(a)) + +def size_label_item(x0: item) -> str: + match x0: + case Box(): + return ("small") + case Crate(): + return ("large") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class measured[A]: + size_label: Callable[[A], str] + +@_cached +def measured_item() -> measured[item]: + return measured(size_label = lambda a: size_label_item(a)) + +def full_description_item(x0: item) -> str: + match x0: + case Box(): + return ("a plain cardboard box") + case Crate(): + return ("a sturdy wooden crate") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class labeled_measured[A]: + labeled_labeled_measured: labeled[A] + measured_labeled_measured: measured[A] + full_description: Callable[[A], str] + +@_cached +def labeled_measured_item() -> labeled_measured[item]: + return labeled_measured(labeled_labeled_measured = labeled_item(), measured_labeled_measured = measured_item(), full_description = lambda a: full_description_item(a)) + +@dataclass(frozen=True) +class Cat: + pass +@dataclass(frozen=True) +class Dog: + pass +type animal = Cat | Dog + +def tag_animal(x0: animal) -> str: + match x0: + case Cat(): + return ("cat") + case Dog(): + return ("dog") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class tagged[A]: + tag: Callable[[A], str] + +@_cached +def tagged_animal() -> tagged[animal]: + return tagged(tag = lambda a: tag_animal(a)) + +def tag_verbose_animal(x0: animal) -> str: + match x0: + case Cat(): + return ("the animal cat") + case Dog(): + return ("the animal dog") + case _: + raise RuntimeError("match failed") + +def tag_extra_animal(x0: animal) -> str: + match x0: + case Cat(): + return ("a small domesticated cat") + case Dog(): + return ("a loyal domesticated dog") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class tagged_verbose[A]: + tagged_tagged_verbose: tagged[A] + tag_verbose: Callable[[A], str] + +@dataclass(frozen=True) +class tagged_extra[A]: + tagged_verbose_tagged_extra: tagged_verbose[A] + tag_extra: Callable[[A], str] + +@_cached +def tagged_verbose_animal() -> tagged_verbose[animal]: + return tagged_verbose(tagged_tagged_verbose = tagged_animal(), tag_verbose = lambda a: tag_verbose_animal(a)) + +@_cached +def tagged_extra_animal() -> tagged_extra[animal]: + return tagged_extra(tagged_verbose_tagged_extra = tagged_verbose_animal(), tag_extra = lambda a: tag_extra_animal(a)) + +def announce_chain[A](a_dict: tagged_extra[A], x: A) -> str: + return (a_dict.tagged_verbose_tagged_extra.tagged_tagged_verbose.tag(x) + " | " + a_dict.tagged_verbose_tagged_extra.tag_verbose(x) + " | " + a_dict.tag_extra(x)) + +def announce_multi[A](a_dict: labeled_measured[A], x: A) -> str: + return (a_dict.labeled_labeled_measured.label_of(x) + " (" + a_dict.measured_labeled_measured.size_label(x) + ") -- " + a_dict.full_description(x)) + +@_cached +def announce_chain_cat() -> str: + return (announce_chain(tagged_extra_animal(), cast(animal, Cat()))) + +@_cached +def announce_multi_box() -> str: + return (announce_multi(labeled_measured_item(), cast(item, Box()))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_tail_calls/Example_tail_calls.py b/test/diff/golden_annotated/Python_Examples.Example_tail_calls/Example_tail_calls.py new file mode 100644 index 0000000..a117e40 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_tail_calls/Example_tail_calls.py @@ -0,0 +1,68 @@ +# Generated by Isabelle from theories HOL.HOL, HOL.Orderings, Pure, Python_Examples.Example_tail_calls; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class ord_[A]: + less_eq: Callable[[A, A], bool] + less: Callable[[A, A], bool] + +@dataclass(frozen=True) +class preorder[A]: + ord_preorder: ord_[A] + +@dataclass(frozen=True) +class order[A]: + preorder_order: preorder[A] + +@dataclass(frozen=True) +class linorder[A]: + order_linorder: order[A] + +def len_rec[A](x0: list[A]) -> int: + match x0: + case []: + return (0) + case [uu, *xs]: + return ((len_rec(xs) + 1)) + case _: + raise RuntimeError("match failed") + +def shift_n(n: int, f: Callable[[int], int]) -> Callable[[int], int]: + if ((n == 0)): + return (f) + else: + def lam(x: int) -> int: + return (f((x + 1))) + return (shift_n((max(0, n - 1)), lam)) + +def sum_acc(n: int, acc: int) -> int: + if ((n == 0)): + return (acc) + else: + return (sum_acc((max(0, n - 1)), ((acc + (((max(0, n - 1)) + 1)))))) + +def count_le[A](a_dict: linorder[A], x: A, xa1: list[A], n: int) -> int: + match (x, xa1, n): + case (xa, [], na): + return (na) + case (xa, [y, *ys], na): + z: int + if (a_dict.order_linorder.preorder_order.ord_preorder.less_eq(y, xa)): + z = ((na + 1)) + else: + z = (na) + return (count_le(a_dict, xa, ys, z)) + case _: + raise RuntimeError("match failed") + +def gcd_loop(a: int, b: int) -> int: + if ((b == 0)): + return (a) + else: + return (gcd_loop(b, ((lambda a, b: a % b if b else a)(a, b)))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_tail_calls/loops/Example_tail_calls_loops.py b/test/diff/golden_annotated/Python_Examples.Example_tail_calls/loops/Example_tail_calls_loops.py new file mode 100644 index 0000000..9741bc4 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_tail_calls/loops/Example_tail_calls_loops.py @@ -0,0 +1,74 @@ +# Generated by Isabelle from theories HOL.HOL, HOL.Orderings, Pure, Python_Examples.Example_tail_calls; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class ord_[A]: + less_eq: Callable[[A, A], bool] + less: Callable[[A, A], bool] + +@dataclass(frozen=True) +class preorder[A]: + ord_preorder: ord_[A] + +@dataclass(frozen=True) +class order[A]: + preorder_order: preorder[A] + +@dataclass(frozen=True) +class linorder[A]: + order_linorder: order[A] + +def len_rec[A](x0: list[A]) -> int: + match x0: + case []: + return (0) + case [uu, *xs]: + return ((len_rec(xs) + 1)) + case _: + raise RuntimeError("match failed") + +def shift_n(n: int, f: Callable[[int], int]) -> Callable[[int], int]: + if ((n == 0)): + return (f) + else: + def lam(x: int) -> int: + return (f((x + 1))) + return (shift_n((max(0, n - 1)), lam)) + +def sum_acc(n: int, acc: int) -> int: + while True: + if ((n == 0)): + return (acc) + else: + n, acc = (max(0, n - 1)), ((acc + (((max(0, n - 1)) + 1)))) + continue + +def count_le[A](a_dict: linorder[A], x: A, xa1: list[A], n: int) -> int: + while True: + match (x, xa1, n): + case (xa, [], na): + return (na) + case (xa, [y, *ys], na): + z: int + if (a_dict.order_linorder.preorder_order.ord_preorder.less_eq(y, xa)): + z = ((na + 1)) + else: + z = (na) + x, xa1, n = (xa), (ys), (z) + continue + case _: + raise RuntimeError("match failed") + +def gcd_loop(a: int, b: int) -> int: + while True: + if ((b == 0)): + return (a) + else: + a, b = (b), ((lambda a, b: a % b if b else a)(a, b)) + continue diff --git a/test/diff/golden_annotated/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py b/test/diff/golden_annotated/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py new file mode 100644 index 0000000..fc19081 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_transparent_wrapper/Example_transparent_wrapper.py @@ -0,0 +1,32 @@ +# Generated by Isabelle from theory Python_Examples.Example_transparent_wrapper; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +def unbox(n: bool) -> bool: + return (n) + +@_cached +def unbox_test() -> bool: + return (unbox(True)) + +def box_is_true(x0: bool) -> bool: + match x0: + case c if (c == True): + return (True) + case c if (c == False): + return (False) + case _: + raise RuntimeError("match failed") + +@_cached +def box_is_true_test() -> tuple[bool, bool]: + return ((box_is_true(True), box_is_true(False))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_tuples/Example_tuples.py b/test/diff/golden_annotated/Python_Examples.Example_tuples/Example_tuples.py new file mode 100644 index 0000000..d44d006 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_tuples/Example_tuples.py @@ -0,0 +1,43 @@ +# Generated by Isabelle from theory Python_Examples.Example_tuples; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools +import Num + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@_cached +def point() -> tuple[int, int]: + return ((3, 4)) + +@_cached +def triple() -> tuple[int, tuple[int, int]]: + return ((1, ((2, 3)))) + +def swap_pair[A, B](p: tuple[A, B]) -> tuple[B, A]: + return (((p[1]), (p[0]))) + +def add_points(x0: tuple[int, int], x1: tuple[int, int]) -> tuple[int, int]: + match (x0, x1): + case ((x1a, y1), (x2, y2)): + return ((((x1a + x2)), ((y1 + y2)))) + case _: + raise RuntimeError("match failed") + +@_cached +def point_swapped() -> tuple[int, int]: + return (swap_pair(point())) + +@_cached +def points_sum() -> tuple[int, int]: + return (add_points(point(), point_swapped())) + +@_cached +def points_list() -> list[tuple[int, int]]: + return ([point(), point_swapped()]) diff --git a/test/diff/golden_annotated/Python_Examples.Example_tuples/Num.py b/test/diff/golden_annotated/Python_Examples.Example_tuples/Num.py new file mode 100644 index 0000000..6660948 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_tuples/Num.py @@ -0,0 +1,19 @@ +# Generated by Isabelle from theory HOL.Num; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +@dataclass(frozen=True) +class One: + pass +@dataclass(frozen=True) +class Bit0: + a: num +@dataclass(frozen=True) +class Bit1: + a: num +type num = One | Bit0 | Bit1 diff --git a/test/diff/golden_annotated/Python_Examples.Example_tyclass/Example_tyclass.py b/test/diff/golden_annotated/Python_Examples.Example_tyclass/Example_tyclass.py new file mode 100644 index 0000000..293f0b4 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_tyclass/Example_tyclass.py @@ -0,0 +1,74 @@ +# Generated by Isabelle from theory Python_Examples.Example_tyclass; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast +import functools + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def _cached[F: Callable[[], Any]](f: F) -> F: + return cast(F, functools.cache(f)) + +@dataclass(frozen=True) +class Red: + pass +@dataclass(frozen=True) +class Green: + pass +@dataclass(frozen=True) +class Blue: + pass +type color = Red | Green | Blue + +def describe_color(x0: color) -> str: + match x0: + case Red(): + return ("red") + case Green(): + return ("green") + case Blue(): + return ("blue") + case _: + raise RuntimeError("match failed") + +@dataclass(frozen=True) +class describable[A]: + describe: Callable[[A], str] + +@_cached +def describable_color() -> describable[color]: + return describable(describe = lambda a: describe_color(a)) + +@dataclass(frozen=True) +class Circle: + pass +@dataclass(frozen=True) +class Square: + pass +type shape = Circle | Square + +def describe_shape(x0: shape) -> str: + match x0: + case Circle(): + return ("circle") + case Square(): + return ("square") + case _: + raise RuntimeError("match failed") + +@_cached +def describable_shape() -> describable[shape]: + return describable(describe = lambda a: describe_shape(a)) + +def announce[A](a_dict: describable[A], x: A) -> str: + return (a_dict.describe(x) + a_dict.describe(x)) + +@_cached +def announce_red() -> str: + return (announce(describable_color(), cast(color, Red()))) + +@_cached +def announce_circle() -> str: + return (announce(describable_shape(), cast(shape, Circle()))) diff --git a/test/diff/golden_annotated/Python_Examples.Example_unused_arg/Example_unused_arg.py b/test/diff/golden_annotated/Python_Examples.Example_unused_arg/Example_unused_arg.py new file mode 100644 index 0000000..b8172f2 --- /dev/null +++ b/test/diff/golden_annotated/Python_Examples.Example_unused_arg/Example_unused_arg.py @@ -0,0 +1,11 @@ +# Generated by Isabelle from theory Python_Examples.Example_unused_arg; do not edit + +from __future__ import annotations +from dataclasses import dataclass +from typing import Any, Callable, Never, cast + +def _abort(msg: str, thunk: object) -> Never: + raise RuntimeError(msg) + +def const_fn(x: int, uu: int, uv: int) -> int: + return ((x + 1)) diff --git a/test/diff/reseed_goldens.py b/test/diff/reseed_goldens.py index 53e5bcf..2d466c6 100644 --- a/test/diff/reseed_goldens.py +++ b/test/diff/reseed_goldens.py @@ -15,6 +15,9 @@ .../Example_a/code/Num.py and .../Example_b/code/Num.py) get their own distinct golden copies rather than colliding on a bare filename. +Output built with type annotations goes to test/diff/golden_annotated/ instead +(see run_test.py). + Usage (from test/diff/, after `isabelle build -d . -e Python_Examples` run from the project root): @@ -27,7 +30,22 @@ THIS_DIR = Path(__file__).resolve().parent PROJECT_ROOT = THIS_DIR.parent.parent PYTHON_OUT_ROOT = PROJECT_ROOT / "examples" / "python_out" -GOLDEN_ROOT = THIS_DIR / "golden" + + +# Output built with the python_type_annotations option has its own golden files. +# Annotated modules start with this import (see print_one_module in code_python.ML). +ANNOTATED_MARKER = "from __future__ import annotations" + + +def _golden_root(generated_paths): + """test/diff/golden_annotated/ for annotated output, test/diff/golden/ otherwise.""" + annotated = {ANNOTATED_MARKER in p.read_text().splitlines()[:5] for p in generated_paths} + if annotated == {True, False}: + raise SystemExit( + f"{PYTHON_OUT_ROOT} mixes annotated and unannotated modules -- rebuild " + "Python_Examples with -c, with or without -o python_type_annotations." + ) + return THIS_DIR / ("golden_annotated" if annotated == {True} else "golden") def _canonical_key(rel_parts): """Drop the `code/` export-category segment -- see module docstring.""" @@ -42,19 +60,21 @@ def main(): "Python_Examples` first." ) - GOLDEN_ROOT.mkdir(exist_ok=True) + generated_paths = sorted(PYTHON_OUT_ROOT.rglob("*.py")) + golden_root = _golden_root(generated_paths) + golden_root.mkdir(exist_ok=True) updated = [] - for generated in sorted(PYTHON_OUT_ROOT.rglob("*.py")): + for generated in generated_paths: rel_path = Path(*_canonical_key(generated.relative_to(PYTHON_OUT_ROOT).parts)) - dest = GOLDEN_ROOT / rel_path + dest = golden_root / rel_path if not dest.exists() or dest.read_text() != generated.read_text(): dest.parent.mkdir(parents=True, exist_ok=True) shutil.copy2(generated, dest) updated.append(rel_path.as_posix()) if updated: - print(f"Updated {len(updated)} golden file(s):") + print(f"Updated {len(updated)} file(s) in {golden_root.name}/:") for name in updated: print(f" {name}") else: diff --git a/test/diff/run_test.py b/test/diff/run_test.py index 9ae7460..9cbb4b5 100644 --- a/test/diff/run_test.py +++ b/test/diff/run_test.py @@ -16,6 +16,14 @@ pytest test/diff/run_test.py -v +Output built with type annotations, + + isabelle build -d . -c -o python_type_annotations -e Python_Examples + +is compared against test/diff/golden_annotated/ instead of test/diff/golden/: +the test tells the two apart by the `from __future__ import annotations` +that starts every annotated module. + Accepting a new baseline after a change to a *.thy file: 1. Build normally (isabelle build -d . -e Python_Examples). 2. Run this test. Every failure names the exact `cp` command to accept @@ -41,7 +49,22 @@ # levels up, as a sibling of test/, not under test/diff/ itself. PROJECT_ROOT = THIS_DIR.parent.parent PYTHON_OUT_ROOT = PROJECT_ROOT / "examples" / "python_out" -GOLDEN_ROOT = THIS_DIR / "golden" + + +# Output built with the python_type_annotations option has its own golden files. +# Annotated modules start with this import (see print_one_module in code_python.ML). +ANNOTATED_MARKER = "from __future__ import annotations" + + +def _golden_root(generated_paths): + """test/diff/golden_annotated/ for annotated output, test/diff/golden/ otherwise.""" + annotated = {ANNOTATED_MARKER in p.read_text().splitlines()[:5] for p in generated_paths} + if annotated == {True, False}: + raise SystemExit( + f"{PYTHON_OUT_ROOT} mixes annotated and unannotated modules -- rebuild " + "Python_Examples with -c, with or without -o python_type_annotations." + ) + return THIS_DIR / ("golden_annotated" if annotated == {True} else "golden") def _canonical_key(rel_parts): @@ -74,6 +97,8 @@ def _discover_golden(root): "`isabelle build -d . -e Python_Examples` first.", allow_module_level=True, ) + +GOLDEN_ROOT = _golden_root(_generated.values()) def _all_relative_paths(): @@ -92,7 +117,7 @@ def test_example_matches_golden(rel_path): if generated_path is None: pytest.fail( - f"golden/{rel_path} exists but nothing at that path was " + f"{GOLDEN_ROOT.name}/{rel_path} exists but nothing at that path was " f"generated under {PYTHON_OUT_ROOT} this build -- the theory " "was renamed/removed, or this was an auxiliary module (like " "HOL.py) that a different example no longer pulls in. Delete " @@ -111,7 +136,7 @@ def test_example_matches_golden(rel_path): if current != golden: diff = "\n".join(difflib.unified_diff( golden.splitlines(), current.splitlines(), - fromfile=f"golden/{rel_path} (expected)", + fromfile=f"{GOLDEN_ROOT.name}/{rel_path} (expected)", tofile=f"generated {rel_path} (actual)", lineterm="", )) diff --git a/test/oracle/Oracle_Import_Cycle.thy b/test/oracle/Oracle_Import_Cycle.thy index 3a34f7c..7b74ff6 100644 --- a/test/oracle/Oracle_Import_Cycle.thy +++ b/test/oracle/Oracle_Import_Cycle.thy @@ -3,9 +3,9 @@ theory Oracle_Import_Cycle begin text \Sorting string literals makes this module import \String\ before \Arith\. - The generated \Arith\ and \String\ import each other, and \Arith\ uses - \String.char_of_integer\ at import time. Kept apart because the failure is at - import, so it fails every check in its module.\ + The generated \Arith\ and \String\ import each other, and a value of + \Arith\ uses \String.char_of_integer\, which fails if it is evaluated at import + time. Kept apart because such a failure is at import, so it fails every check in its module.\ python_check sort_str: "sort [STR ''b'', STR ''a'', STR ''c'']" diff --git a/test/oracle/run_test.py b/test/oracle/run_test.py index 0dac17b..cc28d2d 100644 --- a/test/oracle/run_test.py +++ b/test/oracle/run_test.py @@ -16,7 +16,8 @@ the generated modules under test/oracle/python_out/./. Each check `c` in the manifest names the module that defines `c_ok` (the generated `t = r`, where r is Isabelle's value of t) and `c_actual` (the -generated t, for failure messages), both functions of a unit argument. +generated t, for failure messages), both values of a unit function type: cached +functions without arguments that return a function of a unit argument. """ import importlib @@ -82,16 +83,17 @@ def test_agrees_with_isabelle(code_dir, module, check): pytest.fail(f"{term}: module {module} does not import: {_describe(e)}", pytrace=False) name = check["name"] - actual_fn = getattr(m, f"{name}_actual") + actual_def = getattr(m, f"{name}_actual") try: - ok = getattr(m, f"{name}_ok")(None) + actual_fn = actual_def() + ok = getattr(m, f"{name}_ok")()(None) except Exception as e: pytest.fail(f"{term}: Isabelle gives {check['expected']}, " - f"Python raises {_describe(e)}\n {_source(actual_fn)}", + f"Python raises {_describe(e)}\n {_source(actual_def)}", pytrace=False) if ok is not True: pytest.fail(f"{term}: Isabelle gives {check['expected']}, " - f"Python gives {actual_fn(None)!r}\n {_source(actual_fn)}", + f"Python gives {actual_fn(None)!r}\n {_source(actual_def)}", pytrace=False) @@ -101,6 +103,7 @@ def _describe(e): def _source(fn): + fn = inspect.unwrap(fn) code = fn.__code__ try: source = inspect.getsource(fn).strip() diff --git a/test/quick/Quick_Test_Tail_Calls.thy b/test/quick/Quick_Test_Tail_Calls.thy index b045b57..8d429ec 100644 --- a/test/quick/Quick_Test_Tail_Calls.thy +++ b/test/quick/Quick_Test_Tail_Calls.thy @@ -2,8 +2,8 @@ theory Quick_Test_Tail_Calls imports Main "Python.Python_Setup" begin -text \Runtime checks for python_tail_calls: the values below are computed at import time and - recurse far deeper than Python's default limit of 1000 frames, unless printed as loops.\ +text \Runtime checks for python_tail_calls: the values below are computed when the tests use them + and recurse far deeper than Python's default limit of 1000 frames, unless printed as loops.\ declare [[python_tail_calls]] diff --git a/test/quick/run_test.py b/test/quick/run_test.py index 8cddd9b..346ebad 100644 --- a/test/quick/run_test.py +++ b/test/quick/run_test.py @@ -55,11 +55,11 @@ def test_abort_in_expression(): # ---- tuples ---- def test_tuple_values(): - assert m.t_point == (3, 4) + assert m.t_point() == (3, 4) def test_tuple_swap(): - assert m.t_swap(m.t_point) == (4, 3) + assert m.t_swap(m.t_point()) == (4, 3) def test_tuple_add(): @@ -69,15 +69,15 @@ def test_tuple_add(): def test_tuple_points_sum(): # t_points_sum = t_add_points t_point (t_swap t_point) # = (3,4) + (4,3) = (7,7) - assert m.t_points_sum == (7, 7) + assert m.t_points_sum() == (7, 7) # ---- int arithmetic ---- def test_int_floor_division(): # HOL's int div/mod use flooring semantics, matching Python's // and % - assert m.i_quotient_neg == -4 # (-7) div 2 - assert m.i_remainder_neg == 1 # (-7) mod 2 + assert m.i_quotient_neg() == -4 # (-7) div 2 + assert m.i_remainder_neg() == 1 # (-7) mod 2 def test_int_checksum(): @@ -88,54 +88,54 @@ def test_int_checksum(): # ---- nat arithmetic (monus, literals) ---- def test_nat_monus_truncates_at_zero(): - assert m.n_sub_trunc == 0 # 3 - 10, nat subtraction truncates at 0 + assert m.n_sub_trunc() == 0 # 3 - 10, nat subtraction truncates at 0 def test_nat_monus_normal_case(): - assert m.n_sub_pos == 7 # 10 - 3 + assert m.n_sub_pos() == 7 # 10 - 3 def test_nat_literal(): - assert m.n_literal == 42 + assert m.n_literal() == 42 # ---- nat structural pattern matching (0 / Suc) ---- def test_nat_factorial(): assert m.n_fact(0) == 1 - assert m.n_fact_5 == 120 + assert m.n_fact_5() == 120 assert m.n_fact(6) == 720 def test_nat_countdown(): assert m.n_countdown(0) == [0] - assert m.n_countdown_4 == [4, 3, 2, 1, 0] + assert m.n_countdown_4() == [4, 3, 2, 1, 0] # ---- int/nat remaining operators ---- def test_int_abs(): - assert m.i_abs_neg == 7 + assert m.i_abs_neg() == 7 def test_int_sgn(): - assert m.i_sgn_neg == -1 - assert m.i_sgn_zero == 0 - assert m.i_sgn_pos == 1 + assert m.i_sgn_neg() == -1 + assert m.i_sgn_zero() == 0 + assert m.i_sgn_pos() == 1 def test_int_min_max(): - assert m.i_min_ab == 3 - assert m.i_max_ab == 9 + assert m.i_min_ab() == 3 + assert m.i_max_ab() == 9 def test_nat_min_max(): - assert m.n_min_ab == 3 - assert m.n_max_ab == 9 + assert m.n_min_ab() == 3 + assert m.n_max_ab() == 9 # ---- nested case expressions ---- def test_nested_case_expression(): # nat_label n = 1 + (case n of 0 => 10 | Suc m => 20 + m) - assert m.label_zero == 11 # 1 + 10 - assert m.label_five == 25 # 1 + (20 + 4), since 5 = Suc^5(0), m = 4 + assert m.label_zero() == 11 # 1 + 10 + assert m.label_five() == 25 # 1 + (20 + 4), since 5 = Suc^5(0), m = 4 assert m.nat_label(0) == 11 assert m.nat_label(5) == 25 @@ -144,22 +144,22 @@ def test_nested_case_expression(): def test_if_then_else_whole_body(): # abs_manual x = if x < 0 then -x else x - assert m.abs_manual_neg == 7 - assert m.abs_manual_pos == 7 + assert m.abs_manual_neg() == 7 + assert m.abs_manual_pos() == 7 assert m.abs_manual(-7) == 7 assert m.abs_manual(7) == 7 def test_if_then_else_nested_in_expression(): # classify n = 1 + (if n = 0 then 100 else 200) - assert m.classify_zero == 101 - assert m.classify_other == 201 + assert m.classify_zero() == 101 + assert m.classify_other() == 201 def test_if_then_else_branch_with_nested_case(): # weird n = if n = 0 then 1 else 1 + (case n of 0 => 10 | Suc m => 20 + m) - assert m.weird_zero == 1 - assert m.weird_five == 25 + assert m.weird_zero() == 1 + assert m.weird_five() == 25 # ---- list pattern matching ---- @@ -168,7 +168,7 @@ def test_list_pattern_matching(): # describe_len xs = Suc (case xs of [] => 0 | (_ # ys) => length ys) assert m.describe_len([]) == 1 assert m.describe_len([1, 2, 3]) == 3 - assert m.describe_len_123 == 3 + assert m.describe_len_123() == 3 # ---- partial application ---- @@ -176,55 +176,55 @@ def test_list_pattern_matching(): def test_partial_application(): # add_one = add2 1 -- genuine partial application, eta-expanded via # Code_Thingol.saturated_application into a Python lambda - assert m.add_one(5) == 6 - assert m.p_add_one_5 == 6 + assert m.add_one()(5) == 6 + assert m.p_add_one_5() == 6 def test_bare_reference_and_point_free_alias(): # add2_ref = add2 -- point-free alias; args_num falls back to the # declared type's arity since the alias's own equation has no # explicit parameters of its own - assert m.p_ref_result == 7 + assert m.p_ref_result() == 7 def test_map_native_list(): # map add_one [1, 2, 3] -- requires the native code_printing # registration for List.map (Python_Setup.thy); without it this # silently fails to compile map's definition at all - assert m.p_mapped == [2, 3, 4] + assert m.p_mapped() == [2, 3, 4] def test_bare_binary_constant_as_function_value(): # foldr add2 [1, 2, 3] 0 -- add2 passed bare must be curried, since foldr # applies it one argument at a time - assert m.p_folded == 6 + assert m.p_folded() == 6 # ---- code numerals ---- def test_code_numeral_integer(): - assert m.cn_int_lit == 42 - assert m.cn_neg == -5 - assert m.cn_sum == 50 + assert m.cn_int_lit() == 42 + assert m.cn_neg() == -5 + assert m.cn_sum() == 50 def test_code_numeral_natural(): - assert m.cn_nat_lit == 7 - assert m.cn_nat_sum == 10 + assert m.cn_nat_lit() == 7 + assert m.cn_nat_sum() == 10 # ---- records, including extension ---- def test_record_extension_roundtrip(): # r_shifted3d = r_move_z r_origin3d 7, only pz changes - assert m.r_total3d == 7 + assert m.r_total3d() == 7 # ---- typeclasses / superclasses ---- def test_typeclass_dispatch(): - assert m.cls_default_b == 2 # default_val TagB - assert m.cls_double_a == 2 # double_val TagA = 2 * default_val TagA (=1) + assert m.cls_default_b() == 2 # default_val TagB + assert m.cls_double_a() == 2 # double_val TagA = 2 * default_val TagA (=1) # ---- dictionary-parameterized instance ---- @@ -232,22 +232,22 @@ def test_typeclass_dispatch(): def test_dict_parameterized_instance(): # has_default 'a list requires 'a's own has_default dictionary -- # exercises print_dict_args for Class_Instance printing. - assert m.cls_list_default == 2 # default_val TagB (first elem of [TagB, TagA]) - assert m.cls_list_default_empty == 0 + assert m.cls_list_default() == 2 # default_val TagB (first elem of [TagB, TagA]) + assert m.cls_list_default_empty() == 0 # ---- options ---- def test_option_values(): - assert m.o_describe_some == 6 - assert m.o_describe_none == 0 + assert m.o_describe_some() == 6 + assert m.o_describe_none() == 0 # ---- hoisted multi-argument lambdas ---- def test_hoisted_lambda_is_curried(): # apply2 calls its function argument as f(a)(b); the hoisted def must accept that. - assert m.l_curried_none == 3 - assert m.l_curried_some == 7 + assert m.l_curried_none() == 3 + assert m.l_curried_some() == 7 # ---- native List.nth and IArray ---- @@ -258,9 +258,9 @@ def test_list_nth_is_native_indexing(): def test_iarray_is_tuple(): - assert m.ia_grid == ((0, 1, 2), (10, 11, 12)) + assert m.ia_grid() == ((0, 1, 2), (10, 11, 12)) assert m.ia_get(1, 2) == 12 - assert m.ia_rows == [[0, 1, 2], [10, 11, 12]] + assert m.ia_rows() == [[0, 1, 2], [10, 11, 12]] def test_iarray_pattern_and_exists(): @@ -281,26 +281,26 @@ def test_dict_free_instance_is_built_once(): # ---- division by zero (Isabelle semantics) ---- def test_div_mod_by_zero(): - assert m.z_int_div == 0 - assert m.z_int_mod == -7 - assert m.z_nat_div == 0 - assert m.z_nat_mod == 7 - assert m.z_int_floor == (-4, 1) # floor division, as in Python + assert m.z_int_div() == 0 + assert m.z_int_mod() == -7 + assert m.z_nat_div() == 0 + assert m.z_nat_mod() == 7 + assert m.z_int_floor() == (-4, 1) # floor division, as in Python # ---- hoisting, constructors and dictionary-taking definitions ---- def test_hoisted_lambda_does_not_shadow_outer_vars(): - assert m.l_shadow_none == 104 # (1 + 3) + 100 - assert m.l_shadow_some == 14 # (1 + 3) + 10 + assert m.l_shadow_none() == 104 # (1 + 3) + 100 + assert m.l_shadow_some() == 14 # (1 + 3) + 10 def test_constructor_of_sorted_datatype(): - assert m.c_boxed == 5 + assert m.c_boxed() == 5 def test_pattern_less_dict_function(): - assert m.e_twice_twice == 12 + assert m.e_twice_twice() == 12 # ---- python_tail_calls (Quick_Test_Tail_Calls.thy, exported with the option on) ---- @@ -316,8 +316,8 @@ def _load_tail_calls(): def test_tail_calls_run_as_loops(): tc = _load_tail_calls() - # computed at import, 100000 calls deep without the loop - assert tc.tc_sum_big == 100000 * 100001 // 2 + # 100000 calls deep without the loop + assert tc.tc_sum_big() == 100000 * 100001 // 2 # the list is built in Python: upt itself is not tail recursive. Kept at 20000, as each # [y, *ys] match copies the tail (quadratic), but still far deeper than 1000 frames. assert tc.tc_count_le_int(10000, list(range(20000)), 0) == 10001 @@ -325,5 +325,5 @@ def test_tail_calls_run_as_loops(): def test_tail_calls_with_closures_stay_recursive(): tc = _load_tail_calls() - assert tc.tc_shift_small == 13 + assert tc.tc_shift_small() == 13 assert tc.tc_shift(3, lambda x: x)(0) == 3 diff --git a/test/slow/run_test.py b/test/slow/run_test.py new file mode 100644 index 0000000..eca085e --- /dev/null +++ b/test/slow/run_test.py @@ -0,0 +1,71 @@ +""" +Import check for the Python generated from all code equations of the +slow test suite: every generated module must import, which py_compile +alone does not check (e.g. circular imports between the modules fail +only at import time). + +Prerequisite (run this first, from the project root): + + isabelle build -d . -e Python_Test_Slow + +Then: + + uv run pytest test/slow/run_test.py -q --tb=line + +Each module is imported in a fresh interpreter, since importing a module +also runs (and may break) the modules it imports. +""" + +import re +import subprocess +import sys +from pathlib import Path + +import pytest + +THIS_DIR = Path(__file__).resolve().parent +GENERATED_DIRS = [THIS_DIR / "generated_basic", THIS_DIR / "generated_full"] + +# Modules that are known not to import +KNOWN_FAILURES = {} + + +def _cases(): + for gen_dir in GENERATED_DIRS: + for path in sorted(gen_dir.glob("*.py")): + marks = [] + if path.stem in KNOWN_FAILURES: + marks.append(pytest.mark.xfail(reason=KNOWN_FAILURES[path.stem], strict=True)) + yield pytest.param(gen_dir, path.stem, id=f"{gen_dir.name}:{path.stem}", marks=marks) + + +_CASES = list(_cases()) +if not _CASES: + pytest.skip( + "no generated modules under test/slow -- run " + "`isabelle build -d . -e Python_Test_Slow` first.", + allow_module_level=True, + ) + + +_CACHED_DEF = re.compile(r"^@functools\.cache\ndef (\w+)(?:\[[^\]]*\])?\((.*?)\)", re.M) + + +@pytest.mark.parametrize("gen_dir,module", _CASES) +def test_cached_functions_take_no_arguments(gen_dir, module): + # Only lazy values and instances without dictionaries are cached, and their + # uses call them without arguments + source = (gen_dir / f"{module}.py").read_text() + with_args = [name for name, params in _CACHED_DEF.findall(source) if params.strip()] + assert not with_args, f"cached functions with parameters: {', '.join(with_args)}" + + +@pytest.mark.parametrize("gen_dir,module", _CASES) +def test_imports(gen_dir, module): + result = subprocess.run( + [sys.executable, "-c", f"import {module}"], + cwd=gen_dir, capture_output=True, text=True, + ) + if result.returncode != 0: + last_line = (result.stderr.strip().splitlines() or ["(no output)"])[-1] + pytest.fail(f"import {module} failed: {last_line}", pytrace=False) diff --git a/uv.lock b/uv.lock index d543f47..6acfc0e 100644 --- a/uv.lock +++ b/uv.lock @@ -1,6 +1,74 @@ version = 1 revision = 3 requires-python = ">=3.12" +resolution-markers = [ + "python_full_version >= '3.15'", + "python_full_version < '3.15'", +] + +[[package]] +name = "ast-serialize" +version = "0.13.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/d5/5dc1ee8a80c3b20a0b63c61b43ba6bc53517faecd1def47bcd752d22268e/ast_serialize-0.13.1.tar.gz", hash = "sha256:401cc84e8888d4d76f2c8d296fa006ed1a5ff993b6aff90dd777c03973efd025", size = 955137, upload-time = "2026-10-17T00:04:17.183Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f3/a8/fbd136b9f70c59e75f59a8e974c84102976f1201828b4f886480ba956936/ast_serialize-0.13.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:3e129d44b0cffbea24a7f40117ce49e30993c3d119e584d4817ebd6f87246456", size = 897306, upload-time = "2026-10-17T00:02:52.479Z" }, + { url = "https://files.pythonhosted.org/packages/50/3f/2ad51e9823a790e7a70fd781e9595ab3abeace27f3aefcaa1939457efd72/ast_serialize-0.13.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:523d45bab16ddaf1399c04c4fe81bbf180f81e33c2f7bcbe76be56b0f7311ab4", size = 1236082, upload-time = "2026-10-17T00:02:54.82Z" }, + { url = "https://files.pythonhosted.org/packages/c0/5c/8e959db5cc2237f9d4c560a8e2253c98f9746883fb4774651e4cda458901/ast_serialize-0.13.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:638333fb8ae72c62753f9e794fda20290883ddc65b0d85e26e08f8bb227567ad", size = 1221242, upload-time = "2026-10-17T00:02:56.395Z" }, + { url = "https://files.pythonhosted.org/packages/d6/05/ab1c56c3b7adcac88764bba609502d6b4989e449b2dd60eb478e1d20e369/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc34c670747d85d4232834665e247009413eaebe47c69eaf60a5c439aaecaed9", size = 1282105, upload-time = "2026-10-17T00:02:58.275Z" }, + { url = "https://files.pythonhosted.org/packages/0d/f4/41981fcd2ddffe0760e5326be9dcbd2eda9478a8430a637e5123bd8fcb26/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8c8ebd419811c435812d242fb2a173e57dfede198c9ac9a0a584666ebc9b9331", size = 1287905, upload-time = "2026-10-17T00:03:00.068Z" }, + { url = "https://files.pythonhosted.org/packages/6a/43/b783addc5681153707121991b7b47892f7e9c8ba58a0d03b71a3b023ba47/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8899c038b1c15ae8b98e379057fb3ef398ceb0b21d1737a8156dd5a0923b7e51", size = 1541806, upload-time = "2026-10-17T00:03:01.503Z" }, + { url = "https://files.pythonhosted.org/packages/47/10/969db095038ee15270f65ad20d1129c5e4da605bf7e93b70ae640f1c8a9f/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e14c4de98f965647a74e6eaf37e20207124e45451ccd36e84a6f6ebab45e0372", size = 1309946, upload-time = "2026-10-17T00:03:02.971Z" }, + { url = "https://files.pythonhosted.org/packages/06/dd/7c623d2fb0b868948952d1787e629a43b866f7d4caefd5445e20aefacec4/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f3e8a3eff69af640db985360fef35073fb46956dfc3e5c614cf00920d2746dd", size = 1302773, upload-time = "2026-10-17T00:03:04.378Z" }, + { url = "https://files.pythonhosted.org/packages/d4/c2/4d49469110a19a44fc6269f4fd59679bcf84df068f185f89b73bee4da19b/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:75d7750fe98f6f35a96c43aba8d98a2e623e22c778a0c17ab9ede92eb10f5d82", size = 1299579, upload-time = "2026-10-17T00:03:05.88Z" }, + { url = "https://files.pythonhosted.org/packages/9d/9a/2d381f1f262dda15affc8ad643fba1619eb07e7d9f8bd904deffef183006/ast_serialize-0.13.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e8ddd63e80fc280c2f790157386f27f9b9f6ccb9c4f8e803b863cbfb085769", size = 1355969, upload-time = "2026-10-17T00:03:07.321Z" }, + { url = "https://files.pythonhosted.org/packages/9d/9c/2266794e6c25fa9ce51ce04a9bf4b7e330e3ac9351ba3fa14e487678acdb/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:9221e09496fb942901993c1812ee87950cc0ecbb514c7c0f1f5fa6d78f701ed8", size = 1460227, upload-time = "2026-10-17T00:03:08.733Z" }, + { url = "https://files.pythonhosted.org/packages/2b/d6/14deb28e5d8f328f626a0778ea2cf98fe908f2bbcccd804cb6f449ee1782/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:7a5c38bdb93669c596f94fb7204dd6ebe4fadb19058ac9a2faf2948c2a175f96", size = 1562691, upload-time = "2026-10-17T00:03:10.25Z" }, + { url = "https://files.pythonhosted.org/packages/f5/19/7a28c0e5ba54f0d3e054f847a2a549b748cb179ab433321a8dc1b39e398d/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:acf4e9f055d75058ab01536da330648746f2f82b7697a85230547f2d5ebe895c", size = 1558669, upload-time = "2026-10-17T00:03:11.799Z" }, + { url = "https://files.pythonhosted.org/packages/18/9a/f9e2690eab58217f1d395a964a78efa7eaf813a1e38be8dfd9a8d45d0840/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:87427913c325adc811e81e7c9a757b061f47ef1e29114ac479aa0953a2687a98", size = 1665071, upload-time = "2026-10-17T00:03:13.284Z" }, + { url = "https://files.pythonhosted.org/packages/8e/f3/ef5b159a0d7161b404f05e7ec21cf7735ee7edc10c000cd2cbbc7bb6b69a/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:ad88921f95b92bc144d9ad059a0e16f8c1ae69f5239f2d3c6536fd2774f73dfe", size = 1473364, upload-time = "2026-10-17T00:03:14.563Z" }, + { url = "https://files.pythonhosted.org/packages/1d/87/6e8ac4a865124a12cc4f915bf1bcfac3bba426cd5f58d3712a873ee61012/ast_serialize-0.13.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f8b17e2921e56621bcb46792bd3e0b82ca3b85de78d5936e7b8174ba1758b0aa", size = 1500566, upload-time = "2026-10-17T00:03:15.917Z" }, + { url = "https://files.pythonhosted.org/packages/f5/1e/29155f1621433008013ad5c940a03d41a676be0680c41527040472d37583/ast_serialize-0.13.1-cp314-cp314t-win32.whl", hash = "sha256:2f9a9ce8b0994f757b941f7f7fe384a6666b4162b941ebc5c248081baea18e47", size = 1128674, upload-time = "2026-10-17T00:03:17.481Z" }, + { url = "https://files.pythonhosted.org/packages/bb/64/2506da65143ea138de5822e9173e0b72320a2f70e23bd723f044033175f1/ast_serialize-0.13.1-cp314-cp314t-win_amd64.whl", hash = "sha256:5d99910e6b9a9b9360bcca2ae99aee36cc912ce058df2a57d1c33099b6cb2593", size = 1163306, upload-time = "2026-10-17T00:03:19.046Z" }, + { url = "https://files.pythonhosted.org/packages/6d/8f/c7cb22638899b0cf15908809c270560e46395e65604bc59e4b623ab9f405/ast_serialize-0.13.1-cp314-cp314t-win_arm64.whl", hash = "sha256:a789cbe14d0a0e9ec9b32a456e5abc81ad8799479c3cfd88a29e3442262aebe6", size = 1133775, upload-time = "2026-10-17T00:03:20.377Z" }, + { url = "https://files.pythonhosted.org/packages/2b/e2/b0c140fe50fa39dd249e382f7733af6f816c90021fe7959a0b026f86237f/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_10_12_x86_64.whl", hash = "sha256:23d768369b89d551077dc173da6892fad00443338417523b6732f4e8ba4a7ed5", size = 1236160, upload-time = "2026-10-17T00:03:21.945Z" }, + { url = "https://files.pythonhosted.org/packages/23/c4/a8a2ca21e3943555b48221f8fba546877a7ad39efaf6505506524967d7c4/ast_serialize-0.13.1-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:68f8829d114dab6c9db4a8bbb8d0e342958faee1b5e15a29022678df639960f8", size = 1222214, upload-time = "2026-10-17T00:03:23.462Z" }, + { url = "https://files.pythonhosted.org/packages/15/19/2f58f2ba64e4799b39de85c140aef09a03aa6ea53be75dd292a9d9b9d8ae/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e385b17d5bde892a6184003a9aff3518387908b73f8f5ea539313c07c8c0ede", size = 1282979, upload-time = "2026-10-17T00:03:24.695Z" }, + { url = "https://files.pythonhosted.org/packages/b1/af/ca6087fe84210c1ccd43e3182917bb70649fa1e69745a90c1d59ba08fea8/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:02686b281ec9b8e9614f6f0db27e12e4cac515f336c5d05b678bc9eb73ff2af5", size = 1288596, upload-time = "2026-10-17T00:03:26.04Z" }, + { url = "https://files.pythonhosted.org/packages/b0/2c/4ef964c763329a0347125e745ec0451ba4fbaceec9efe2ac729b7cd55f17/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a8ab2c2585b2e22e48cd4aff2136fce4eab4ced569b85f150ef9a5a5d6f34d49", size = 1545540, upload-time = "2026-10-17T00:03:27.52Z" }, + { url = "https://files.pythonhosted.org/packages/bb/85/aa961dbb75813cfa94de0ce9a16a9510c226b95f604c405421e727f44bb0/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c652d9f5d52d8b81eff3ff2c95c9dd0f281de45f6ad5d3fa95527550c396454a", size = 1309374, upload-time = "2026-10-17T00:03:29.091Z" }, + { url = "https://files.pythonhosted.org/packages/b4/e6/f2b67c327d9f9533e41791804403ccc2dc457821195a2e51f0b587a90b90/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:121e1d08d58b75c15491cc3003609cbad71ac2b0016043c36d30a6b2032b6605", size = 1303466, upload-time = "2026-10-17T00:03:30.451Z" }, + { url = "https://files.pythonhosted.org/packages/73/1d/33f18b81d1bb1f5d682943ea92fda8130a6593627f12f6201668d40824fd/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_31_riscv64.whl", hash = "sha256:30cf89b6a6844542d116c758725d13de5b97b9410a51ee577715f761270d0c1c", size = 1300576, upload-time = "2026-10-17T00:03:32.102Z" }, + { url = "https://files.pythonhosted.org/packages/25/cb/64914144925f1a4abdd9217e717b122255c38fc5ebe4342f92052f3bacbc/ast_serialize-0.13.1-cp315-abi3.abi3t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:732aaae9e498c973fc63fd7f308009b57c4afa6ff59d0b674d894e57d0bca01a", size = 1355960, upload-time = "2026-10-17T00:03:33.676Z" }, + { url = "https://files.pythonhosted.org/packages/ee/80/bd29379fab2bce19adc0bf9177002b11b23dfe8d8fecf409998b458b4624/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:d9c1a920b2aa0c1e016bed7721689717034ca0dba64ac3a3ff243b003d4e8dd8", size = 1459779, upload-time = "2026-10-17T00:03:35.09Z" }, + { url = "https://files.pythonhosted.org/packages/83/89/012dbe733de05ffdf8e40ca0f9fa5d417cb16ec93a74463c57c001914198/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_armv7l.whl", hash = "sha256:847cad4c22953823f5e76d0b126c6f9da670cfa45b1df41b9324e22189d77611", size = 1563399, upload-time = "2026-10-17T00:03:37.285Z" }, + { url = "https://files.pythonhosted.org/packages/69/37/ee4bcb0358bee38744eb0f18560446572d095fe3bf6b63d6f739d08a839c/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_i686.whl", hash = "sha256:aca07de3ca8e3d9f2b716c3c31f4f384fe4bd2d03e09912417cff7a3e08036f7", size = 1558808, upload-time = "2026-10-17T00:03:38.711Z" }, + { url = "https://files.pythonhosted.org/packages/54/1c/ff44c5355251d61ef22934c4430bb31a61de4781d25a992154aac9b8c82a/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_ppc64le.whl", hash = "sha256:5db12d843d931b9d1f1519ce66b9cbfe72d8563b75c1204d255322254d1964dd", size = 1666324, upload-time = "2026-10-17T00:03:40.376Z" }, + { url = "https://files.pythonhosted.org/packages/c8/bb/6da4bfc8aa3403e6447607131bf3463acaf954d990c6c8b6787c1902ddfe/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_riscv64.whl", hash = "sha256:fb8021f4dc3296de18737e3b8b34994411da725374d74a0b9eb32a738f2a23d0", size = 1474089, upload-time = "2026-10-17T00:03:41.715Z" }, + { url = "https://files.pythonhosted.org/packages/21/97/897e33bef2eefd880e6350e375cc66bc5bcd00a139be480fd655f5b3f095/ast_serialize-0.13.1-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:0d764913374ba21df8cd618045b371ed104ce55c6276de7c59e554a4f5ba26fd", size = 1501542, upload-time = "2026-10-17T00:03:43.08Z" }, + { url = "https://files.pythonhosted.org/packages/8d/4c/821211ac83870c27e4412381b7c7838336456b40575bf840e4680b2018d9/ast_serialize-0.13.1-cp315-abi3.abi3t-win32.whl", hash = "sha256:2bad302ae2427454ef9dab71bd5c3ad67188860c39d36daee38f72031edb39c4", size = 1126118, upload-time = "2026-10-17T00:03:44.616Z" }, + { url = "https://files.pythonhosted.org/packages/1f/86/2b2d5e6c4fa352874a80618e742ffd32d249dee6c119f4233b51afc6b8f4/ast_serialize-0.13.1-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:032b09d86c785c3984e975378b7861f2a68ac44e22ba7b07b93a536b2524eeb8", size = 1163766, upload-time = "2026-10-17T00:03:45.986Z" }, + { url = "https://files.pythonhosted.org/packages/77/a3/d610cfcdabaa44fd62a54ca1fc57a7dba120643798b089a14914973562de/ast_serialize-0.13.1-cp315-abi3.abi3t-win_arm64.whl", hash = "sha256:929eda0c419e622ab49df3a4c45f81c57dcc10874bbad55d0470a4a03324dac3", size = 1134043, upload-time = "2026-10-17T00:03:48.453Z" }, + { url = "https://files.pythonhosted.org/packages/f0/89/0e30f9eddf7d44ccf9d25979030754fd0457af61fa4279acb8c293a04f97/ast_serialize-0.13.1-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:bf53a3ba1cbe45399fc1e4ccd684b8f2a11cca450f89706b79122f478534c6f5", size = 897546, upload-time = "2026-10-17T00:03:50.093Z" }, + { url = "https://files.pythonhosted.org/packages/81/92/d705be88ff452b9ba0088b554a0cbd308fd01879da092b33fd2ad7d1aa60/ast_serialize-0.13.1-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:4bcf1d5f4eefecaa325a34ecf079b2741189e7d0821523f92cb343a389a67489", size = 1242416, upload-time = "2026-10-17T00:03:51.521Z" }, + { url = "https://files.pythonhosted.org/packages/60/c2/98370845a7f35cb8a25782e78284b48e01bf3128339881d48d613f304f8f/ast_serialize-0.13.1-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:1b158f1c9e3a0d386913924c57995d6df78224868a4d0f215bdd41587c97b34a", size = 1229729, upload-time = "2026-10-17T00:03:52.825Z" }, + { url = "https://files.pythonhosted.org/packages/d8/8b/2d7ffed76addd9d3fcf37fb171400942735c8912264c763561a85407f6a8/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77a6201b69ce42e919f2fd9a559138d5410b5d8afff7c3a6b1f500b0481ff7d8", size = 1292255, upload-time = "2026-10-17T00:03:54.148Z" }, + { url = "https://files.pythonhosted.org/packages/6b/2a/bb9e0e719d89cc950fadfcfcc9cb4bc7640419c4228c852f031ab8abf440/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6eb0be64c9b8f1ed26637eef345abe75ea90351c92c85a8aec7838b3af971011", size = 1298501, upload-time = "2026-10-17T00:03:55.559Z" }, + { url = "https://files.pythonhosted.org/packages/7a/32/13ce07dce48226f5bd9cfd8f708ec101a8be05aa430cda4918ce31ce8c82/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7f2427bddfca208e84de700044fadf9aef2769a70bae740a1bdabb89ee9e1117", size = 1553758, upload-time = "2026-10-17T00:03:56.952Z" }, + { url = "https://files.pythonhosted.org/packages/e2/fb/9b51d186db0c20ca28cbaaefd50f03b573c89327b9a2627820cbce22196b/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88df960e67184a71874e5b2ee014f87d1254a0dbc1f903c7bd7b1ab7733ecaef", size = 1318258, upload-time = "2026-10-17T00:03:58.418Z" }, + { url = "https://files.pythonhosted.org/packages/c5/fa/da311559dd3dae9af5825cf21660775a929b970f72e3786af3f2cd667944/ast_serialize-0.13.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f99786e0d62082a5b121b3437f3167562133711df22128de1e9886f57f0b226", size = 1313260, upload-time = "2026-10-17T00:04:00.194Z" }, + { url = "https://files.pythonhosted.org/packages/2b/11/97a4b9e5b4776d72f47fcd9a09a497bbf68ec8c1ae074307a2c51e410d85/ast_serialize-0.13.1-cp39-abi3-manylinux_2_31_riscv64.whl", hash = "sha256:a01b515b25a03184eff4acef25b981ae007916379682e908fc8785b342a0bf3e", size = 1309992, upload-time = "2026-10-17T00:04:01.575Z" }, + { url = "https://files.pythonhosted.org/packages/2e/c4/62f85121a80cd451ef04f550cf0f7ea0ad9ff46cc4e9a5b9ae439b6527b1/ast_serialize-0.13.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:29422d7bcd9e7f39411571c36cec45ce8a7a9b3ad4b2e7aa64497c15a9e397f6", size = 1362715, upload-time = "2026-10-17T00:04:02.881Z" }, + { url = "https://files.pythonhosted.org/packages/c1/fa/c5f4a545f72a7681e3295bab6e3600ee0862ec4391bed961fe9f735b67e0/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:6ffb0f548a7dc126067fdfb7b2325ab5dfcdeecc29faf5e0f0461c96d6ebfa3d", size = 1469931, upload-time = "2026-10-17T00:04:04.181Z" }, + { url = "https://files.pythonhosted.org/packages/38/a9/65aed4f8fa7a001a7cfdc03e68e844517ab041ba6fb614b7d78a1d6ac056/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:2876444a5f87a7c76f371af3c07c2fda563a08bc8af52568df812e8aba4bf568", size = 1570945, upload-time = "2026-10-17T00:04:05.778Z" }, + { url = "https://files.pythonhosted.org/packages/fb/8c/44b2da991cede79bfbf52089f33a5f0168945466b3d9cd38b5dcf08e7130/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_i686.whl", hash = "sha256:885a62ec6481ce58ab24c6357360d7a82023b62dd7e5e7ceccf59e9662a3272b", size = 1569978, upload-time = "2026-10-17T00:04:07.347Z" }, + { url = "https://files.pythonhosted.org/packages/46/e4/109b2a5beca700237767d5add920c2f8e1ba9bd5799b0faf143d0e9cf4ef/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:2015fd0165e463aac3b1aadc6a1fa1e5820c14ca950821f4fe02f8a3f6a388d6", size = 1676082, upload-time = "2026-10-17T00:04:08.7Z" }, + { url = "https://files.pythonhosted.org/packages/73/e0/7df70f6dbb11b5762da5416318f08316a1c51348e0d69ec79ca5f98f836a/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:eb41e1906502ac80d24ff343f45008552a3f5b5158607959fe6a07dbfc6eb037", size = 1483207, upload-time = "2026-10-17T00:04:10.162Z" }, + { url = "https://files.pythonhosted.org/packages/1f/bc/523aa1c08bd69b5654621beb3dc1a9035715a4a63762fb8d219d6fb3eb81/ast_serialize-0.13.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ca9acc67f796aa2554fa3037dccc022a4b08b38b2ad153edfac9c9bb7cb1f3c6", size = 1512140, upload-time = "2026-10-17T00:04:11.589Z" }, + { url = "https://files.pythonhosted.org/packages/66/83/6607060659998f00afdea0d8375c1e6e2b7d515ab905090d9a5a02f48851/ast_serialize-0.13.1-cp39-abi3-win32.whl", hash = "sha256:4f98da562e5901d69c7dd30885594c5438f859edf354e9ac7517d188fb026c3a", size = 1131889, upload-time = "2026-10-17T00:04:12.953Z" }, + { url = "https://files.pythonhosted.org/packages/9f/6f/bafd6490fe7b355627fabe95f4417e3d02da93102c8552550eb9a0774e1e/ast_serialize-0.13.1-cp39-abi3-win_amd64.whl", hash = "sha256:ddf7cbc9c8abf70102c4a088efe154bb86bfb825b0a10e556d2b15972cf99bd7", size = 1171153, upload-time = "2026-10-17T00:04:14.362Z" }, + { url = "https://files.pythonhosted.org/packages/11/25/4235f4b375a67a37ac595bf478a5407a744eaf7b64113c1c3a5432b8d954/ast_serialize-0.13.1-cp39-abi3-win_arm64.whl", hash = "sha256:48f11d96c9ec71119612f8e79a8c55c12f2b136716d68347433c561d27a25f43", size = 1139035, upload-time = "2026-10-17T00:04:15.767Z" }, +] [[package]] name = "colorama" @@ -25,11 +93,181 @@ name = "isabelle-python-codegen" version = "0.1.0" source = { virtual = "." } dependencies = [ + { name = "mypy" }, { name = "pytest" }, + { name = "ty" }, ] [package.metadata] -requires-dist = [{ name = "pytest", specifier = ">=9.1.1" }] +requires-dist = [ + { name = "mypy", specifier = ">=2.4.1" }, + { name = "pytest", specifier = ">=9.1.1" }, + { name = "ty", specifier = "==0.0.96" }, +] + +[[package]] +name = "librt" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/04/f5/9dc696772d241814bacac7880bac32f2930b5a6ebc1f85317b83161a011c/librt-0.16.0.tar.gz", hash = "sha256:ac38d6d8d66bf3d744148dbbc0b8e193e195a51e364ed55e224631f5721891fc", size = 219839, upload-time = "2026-09-29T00:55:32.891Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ad/76/bbdaeb87b7c47b5c7343e90222b9bfa4e4a8a83f647e02933ad0129225b1/librt-0.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:fe52bf4641069e7978a14253b036cb9002def1926317e710f2e249f8a8c47742", size = 151028, upload-time = "2026-09-29T00:52:41.508Z" }, + { url = "https://files.pythonhosted.org/packages/fd/0c/ab8ed3dab0085931aec4a792c7eaac8dc6c5ff4691fda3a5360d9d8a9cd2/librt-0.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5bcc2c4726ced915b00de0c9856a4eeabfb3fddb93e10e0b8f735b7709358b6d", size = 155283, upload-time = "2026-09-29T00:52:42.873Z" }, + { url = "https://files.pythonhosted.org/packages/eb/36/494e79d460c80c1f030661e8287c9eca5e1ad652dc2b2180b6cd42abce0a/librt-0.16.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ff7baa55f8e7c69851419e50a666015d02a74198716fd45c0125a2112e0a389f", size = 503185, upload-time = "2026-09-29T00:52:44.638Z" }, + { url = "https://files.pythonhosted.org/packages/9b/34/a8464038dd9db6e4381fa2b6eb73dc9a50888d77102c4c139304ac35cddc/librt-0.16.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:b95d5d92ab83d39e760a52091bb1baba664f3a2351e39b1e16801e5747c2f0e9", size = 496738, upload-time = "2026-09-29T00:52:46.441Z" }, + { url = "https://files.pythonhosted.org/packages/6a/53/e0e5e334ef0c6ed27039d323819368b9ef6712be87d55ee2bf9799398afd/librt-0.16.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b6d085d70bce51d43c5c7c36d63490770180d8779e71c49305c87b4213918de7", size = 513818, upload-time = "2026-09-29T00:52:48.068Z" }, + { url = "https://files.pythonhosted.org/packages/ad/f7/7ce72cbf19d0addd05090b339152fd0548a02562c2866a603e6e3b3da2df/librt-0.16.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:36e53948e99bbe3ffea257124cfcae1cfb01831555c9a9c903c9f9a72db7fd07", size = 531952, upload-time = "2026-09-29T00:52:49.816Z" }, + { url = "https://files.pythonhosted.org/packages/83/22/0b1bcb6a8e723c8b4fd60dfc8ae8ec6461c54073fbc8685efeb8d900d407/librt-0.16.0-cp312-cp312-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:54d11f726aae9df5a6ffbbf0a03a52449bbac84a53ef03669cb41cdfd4ae41bf", size = 524465, upload-time = "2026-09-29T00:52:51.354Z" }, + { url = "https://files.pythonhosted.org/packages/64/2e/e9c23b8b9df1813da1be205deca9606beb7ddd033972246cd426d05374a0/librt-0.16.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4323193ac0cd025f85af531df8ba91bf24d1973b401697347a6282e8fd3fcf5e", size = 543191, upload-time = "2026-09-29T00:52:53.284Z" }, + { url = "https://files.pythonhosted.org/packages/bc/e5/6a8b21b342c03ed7e230fa3afbfd2edc58e6e87ef1f0d11fa2b9a748c252/librt-0.16.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e42f8e098b9c5396fefa05fb1cc7e33b0e08fc51da106b5de4a45fd22aac6743", size = 546979, upload-time = "2026-09-29T00:52:54.932Z" }, + { url = "https://files.pythonhosted.org/packages/84/9e/b5129023eced1be01e01c22757f53be551d463b1bb7264f787927404c1d6/librt-0.16.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:39ec1d5a14e37baf1450a6cabf03fe552340808bf1ad9d71824ab90117716459", size = 555317, upload-time = "2026-09-29T00:52:56.869Z" }, + { url = "https://files.pythonhosted.org/packages/71/89/28bba5938c725fe91f06bf93f7fa6c6b150229df53a87b454b0d5c2a796e/librt-0.16.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d1aabe3925cbb4a08d15b7b20ba4011b53019da0c4173a25155139b7b1baed65", size = 535846, upload-time = "2026-09-29T00:52:58.475Z" }, + { url = "https://files.pythonhosted.org/packages/22/92/63773026614f888c5d4e370e395ce42ca604b89f70b3acdfedbf94851b80/librt-0.16.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:300c3ffdc459f4a779a8411ecb188e3ac0b1ff3a3a7b099642555dedae06c69b", size = 573700, upload-time = "2026-09-29T00:53:00.127Z" }, + { url = "https://files.pythonhosted.org/packages/66/8f/347d4677eefb57cd9f8e01d95a1dcee9a91b4e44e664173c32ff6f3752e5/librt-0.16.0-cp312-cp312-win32.whl", hash = "sha256:c17194318e4c0c0348b36f36c2ec7534436fe0a4c15582403162a4f08c80797a", size = 106158, upload-time = "2026-09-29T00:53:02.031Z" }, + { url = "https://files.pythonhosted.org/packages/f0/2c/5193dc81127cd5ddfad031391b046bf32dda219b38463ab872407ca30646/librt-0.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:25a58a19ea8d83b68209f04912df765e9260635ef77646542ed4b4abe6bc7940", size = 126176, upload-time = "2026-09-29T00:53:03.445Z" }, + { url = "https://files.pythonhosted.org/packages/ff/3d/9668a400c8dd81d162eba38b33fa49fa6205f1a64493570a13fbb815c3ee/librt-0.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:f7be7cf555bc30ec12622e9447299cc4a9b8ff307548b634794353db0c2065dc", size = 116572, upload-time = "2026-09-29T00:53:04.815Z" }, + { url = "https://files.pythonhosted.org/packages/46/cd/ae5e0e9dba45d1399aa04a5395bcc0bead40d9fa06dc903634a7b4d7473d/librt-0.16.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:c5e6144e68b577f157519f2ba88ca20e3ed61c29b00e5cdfa76cd2d45acf059a", size = 151036, upload-time = "2026-09-29T00:53:06.284Z" }, + { url = "https://files.pythonhosted.org/packages/41/5a/48a16e323c5f9447a94cce7b59babf60fa04e62c3365ecf060c77ed8b320/librt-0.16.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:33f41443a1f4e1f099331b3d8120e409fbff84b9760bc1cc9ea496f37ddaa5cc", size = 155211, upload-time = "2026-09-29T00:53:07.72Z" }, + { url = "https://files.pythonhosted.org/packages/3f/29/0f59299eb4251a409b2e690ad4b7d9f8a676db829d7817ec961f32b44f7e/librt-0.16.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7e510b7770bee609617a3374a96548eb114cae048023e3f049ee449e7ff2db32", size = 502587, upload-time = "2026-09-29T00:53:09.191Z" }, + { url = "https://files.pythonhosted.org/packages/de/ba/d6fb4ef8d1537c396079d72289f16be7cd35a366e5065c51253fea2760b6/librt-0.16.0-cp313-cp313-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:efc49c462d4516b8a58b00b490078fa64689fd1fe66970cc190131d7afb8027e", size = 496146, upload-time = "2026-09-29T00:53:11.016Z" }, + { url = "https://files.pythonhosted.org/packages/52/fc/8c50dd4d7cc97c0ee8f252c8a3104980f234391cf1519b554e8b9de08b60/librt-0.16.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:92caf82ebef5e12d21c72242b70d1e92536f1711cf2a727a4c276de4b4469087", size = 513336, upload-time = "2026-09-29T00:53:12.655Z" }, + { url = "https://files.pythonhosted.org/packages/a9/59/16c409c56f708eda2db9a0553662845d45e3871c77d70a240dae3f3bdc56/librt-0.16.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:17bac7f7a16b328fff77e440287693eb017abde913595b5827ebccbc21ecd8a6", size = 531689, upload-time = "2026-09-29T00:53:14.39Z" }, + { url = "https://files.pythonhosted.org/packages/88/82/d34772a6c29d1446dcca6e64d74062efd508523ab351aa16625a4689d5cc/librt-0.16.0-cp313-cp313-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5b976054553670829985ed767feb78fb6bcede0175327c4844dd5c281c1be659", size = 524537, upload-time = "2026-09-29T00:53:16.064Z" }, + { url = "https://files.pythonhosted.org/packages/77/8f/24c5631313746131ccee53bc91fdc8374f9cf25e0082a1fee9c93bb98acc/librt-0.16.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0058f9d68721094105917254c72ac0569117bb7b13b9769cf45d26d89f9d21cd", size = 543231, upload-time = "2026-09-29T00:53:17.939Z" }, + { url = "https://files.pythonhosted.org/packages/f2/cb/5f8e0d41dbd8b499c2265e939c31acc9ba59845565bf99539ad1c06aebcf/librt-0.16.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:30b7beaf3f4487b7d8adef1f158b49067cb4d5a19fa7a3bf31a4e7a820e435c5", size = 546499, upload-time = "2026-09-29T00:53:19.666Z" }, + { url = "https://files.pythonhosted.org/packages/be/61/063052de441d1385f59cea4223f184bf9e5d125de1ae3239b490aa1e486e/librt-0.16.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:468df902df016a06eb0e40b0747dc8d14e47d7a38b18b63b1fb167d85cb94d63", size = 555261, upload-time = "2026-09-29T00:53:21.292Z" }, + { url = "https://files.pythonhosted.org/packages/14/11/a2ada0529372268d6401afa9d457a095b68cd7753532b6f7f33049a19b43/librt-0.16.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:aea7b1f2b125dad5de85f049136651bff256c883c65e6b9209b2da0a1ac3cdef", size = 536029, upload-time = "2026-09-29T00:53:23.07Z" }, + { url = "https://files.pythonhosted.org/packages/23/9d/5bb6d38853382986dca702fc7e06c8256d30f5fa0676d882773b744610dc/librt-0.16.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a8afb6557920860b7a3a596eb804cf37e09e7cf8a803db2478c202acc72d8c2e", size = 573748, upload-time = "2026-09-29T00:53:24.696Z" }, + { url = "https://files.pythonhosted.org/packages/99/f6/0025cde35ff7f607684dc775a2b2d732cce2561cec050a6ee1fb2e1fc6fe/librt-0.16.0-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:77c7a2b4fe2c1369e0d5aa1cade26740a7b14be32fbc9a5535d617d20065c39d", size = 79861, upload-time = "2026-09-29T00:53:26.089Z" }, + { url = "https://files.pythonhosted.org/packages/93/93/303b8592909bd583f83f02818ffbea3f7647ca1e22b1cd5465d04b8145fe/librt-0.16.0-cp313-cp313-win32.whl", hash = "sha256:02d89c813d5ff74b17df72d3a34819d132cd168e56b81bf755b809bd9e46b8c4", size = 106236, upload-time = "2026-09-29T00:53:27.43Z" }, + { url = "https://files.pythonhosted.org/packages/cf/24/80bbb463c60ed18e29cb26aba386ddb76609580e4e7160710e550587018c/librt-0.16.0-cp313-cp313-win_amd64.whl", hash = "sha256:14ed6ebe3e4f85f326d7920011ad30ff49ed9334e62cf88caef9ba973d9e3a92", size = 126180, upload-time = "2026-09-29T00:53:28.7Z" }, + { url = "https://files.pythonhosted.org/packages/43/80/b1a6fbdd7da825cdd55c71aa81eb6cfa82c513c360774152eacb50b4a771/librt-0.16.0-cp313-cp313-win_arm64.whl", hash = "sha256:83d4041a3d9b2fd053a8a4e1f22878b3e5833e2712956382d5c048d791454e91", size = 116557, upload-time = "2026-09-29T00:53:30.012Z" }, + { url = "https://files.pythonhosted.org/packages/1e/93/9e0cf7da129a93c3dc7f45bc3cd4a660f2aaa995aa8a6f95c2583ef41239/librt-0.16.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:931a0bb0fcac88f263e269e46eb30ba8e21402cd3c62ca40cb97034c0693fab1", size = 149844, upload-time = "2026-09-29T00:53:31.391Z" }, + { url = "https://files.pythonhosted.org/packages/8f/26/8a90d2a8f2b2e471bb486b7aec117b8ae622715ed6c39853aec48ea20073/librt-0.16.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1bc17e54e5305f8d40b7ca203671ff5a9e59c1d0f8ea0f625dcca53a3984de11", size = 154111, upload-time = "2026-09-29T00:53:32.718Z" }, + { url = "https://files.pythonhosted.org/packages/35/ce/67abb46258da4d3e42ff5b141db6f38c59357bef84c7979f183b22f924f1/librt-0.16.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:877698bf6bca5721d8be345f2fe09778e40ecadea8b58c73075f2b1a53666bf2", size = 494234, upload-time = "2026-09-29T00:53:34.466Z" }, + { url = "https://files.pythonhosted.org/packages/12/f9/ea7162414a16f8f1bbd3b493ad6d22b926c5471916e078350bdbca8c4e5f/librt-0.16.0-cp314-cp314-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:5981c011b306781ce561e18e14230a14524a3d8109b97553666c942c18f31a96", size = 491173, upload-time = "2026-09-29T00:53:36.124Z" }, + { url = "https://files.pythonhosted.org/packages/b1/09/9b3e869060dd33f9989b80ba4fea306f6db8cecefcdfe6d7346ef0603f65/librt-0.16.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:afced3dfc17cd805ecf7a3d77996a71cf5f2c75aa66eb0c21a9930f4fc992f86", size = 505547, upload-time = "2026-09-29T00:53:37.686Z" }, + { url = "https://files.pythonhosted.org/packages/50/07/79007d2165f649ea93e08c0962d1d62c70af9cde77965255095bf9d96f9a/librt-0.16.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ca8052401c55d7511dda6760719fda7618067e83535d7d0010096d216c34b667", size = 523057, upload-time = "2026-09-29T00:53:39.301Z" }, + { url = "https://files.pythonhosted.org/packages/61/0c/8fbaff66d0ba376d8864653f5acce1569bae27e89648671f26f7eca67ab8/librt-0.16.0-cp314-cp314-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1e511762a074005bb0aa569166779834e75e438370226930d0ce1866d4b6a33b", size = 515158, upload-time = "2026-09-29T00:53:41.012Z" }, + { url = "https://files.pythonhosted.org/packages/df/2e/23ff0dece76f07a4124413a57682efa0bbeb5765ac0122bc0955513f82ca/librt-0.16.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f1e8591bd8a5a628cd7f07954c6a1592359a878bf032957a8e9057a41d644311", size = 534183, upload-time = "2026-09-29T00:53:42.451Z" }, + { url = "https://files.pythonhosted.org/packages/26/c4/e11dea21d9a29486eba78887380374189d472734fa32cc50cb37ca44d3d0/librt-0.16.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4aaefb4ba6c07e1aeebb2795c8958148f1d6f9af3b555b53d23d766edb6d67a", size = 540663, upload-time = "2026-09-29T00:53:44.272Z" }, + { url = "https://files.pythonhosted.org/packages/44/75/e873ae158a8b7f5359be33e7fd6c1fbe02d9a78a3e89a77de6b0e837f476/librt-0.16.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:d92db7a0f6aee44f1baee94750457e8d2d1c6ccea41842de6268d34e8dc7eddd", size = 545908, upload-time = "2026-09-29T00:53:45.812Z" }, + { url = "https://files.pythonhosted.org/packages/ba/36/8939d3f6a93e11bd9592e6fe28d2b44f1c2dc4bed6e22e72359a91e18ffb/librt-0.16.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:378dfaffb38e59c24a87cde5713cd865d51ff7383fa12947f3907f306ea1ca55", size = 523302, upload-time = "2026-09-29T00:53:47.596Z" }, + { url = "https://files.pythonhosted.org/packages/71/14/35309f44a077f0f42ade0e2e7cd88c0cea760c661af205c01ea90d3c0e1f/librt-0.16.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:3e0c39bdc85370422e8b637be76eb1fd07d30967551b03e62267dd156f553152", size = 565911, upload-time = "2026-09-29T00:53:49.278Z" }, + { url = "https://files.pythonhosted.org/packages/78/0c/df6255b94967f3159ebc46f08d8e783c12da6ee269ddb74b2efed63c640c/librt-0.16.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:1b384b90ab79a7bc30b566895809a636e0666f21f3cf12b54823d025b7e83839", size = 79119, upload-time = "2026-09-29T00:53:50.938Z" }, + { url = "https://files.pythonhosted.org/packages/6b/44/d30d5a5461378c9d33f36736c6791c3b4c4ba4b1ffe0da7350aedcb2c9a0/librt-0.16.0-cp314-cp314-win32.whl", hash = "sha256:52327da75a94012e7f932f913d20d3876bed3c102be00e6c3e8600ff7bdd58a7", size = 100140, upload-time = "2026-09-29T00:53:52.205Z" }, + { url = "https://files.pythonhosted.org/packages/c2/98/769712f356a1e897df3581bb0c3100375d054a000de26099360ea65b5111/librt-0.16.0-cp314-cp314-win_amd64.whl", hash = "sha256:3f0b8114c44b2ac06ff5dacd08e07e8e807ff4f46083f2a1602685122559be41", size = 120464, upload-time = "2026-09-29T00:53:53.495Z" }, + { url = "https://files.pythonhosted.org/packages/bf/d3/ae2abccc8bdc8b063c1613a77686e17b74e9d3d60cfe6f12c63fa2821b9f/librt-0.16.0-cp314-cp314-win_arm64.whl", hash = "sha256:8caf96a4ef8fb27d0ac0d1ad8337d26a240acd4a02fe4345d0a8f264753e8f99", size = 110889, upload-time = "2026-09-29T00:53:54.817Z" }, + { url = "https://files.pythonhosted.org/packages/e4/26/0737d4be058dd6376eade7dd8b380d4b869b6394cee929393a5a431c45bb/librt-0.16.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:953107e2f68d0f3512c48f898b0dbf0ce5cc52bba0f318d847c985dc555ee4cc", size = 159838, upload-time = "2026-09-29T00:53:56.22Z" }, + { url = "https://files.pythonhosted.org/packages/01/96/9bc96531d7c620e9949af904470f02e3fa8f35129ab8e8f281c51eaa3788/librt-0.16.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ad37d5b9abd49c9a655dcda7ea52a8a752884062ef1ee71ae17c2f2a0f81fe6a", size = 162018, upload-time = "2026-09-29T00:53:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/0e/fa/b0289dcb186eb3f97221ba00da5f4bd3ba7fa5e99752d48aa8d336615334/librt-0.16.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2c4aa329c17bd1aaea4f6e89335d8ccd494b3a5830b6654462273e50e11023f0", size = 703983, upload-time = "2026-09-29T00:53:59.024Z" }, + { url = "https://files.pythonhosted.org/packages/d9/ab/05ebbbde7530fc5eeb58fbd1581522a9f64f132fa703c4c595eed6e14760/librt-0.16.0-cp314-cp314t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:0ead24d2562a49473dddd9efef8581f020007eb0054389c3ee3ffad38b1ca4c9", size = 683847, upload-time = "2026-09-29T00:54:00.671Z" }, + { url = "https://files.pythonhosted.org/packages/a3/75/f52aeecd4dbadbddf80725ba7de126d8bd5d0eb66247eae17a81ed90dd4d/librt-0.16.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:02118f56a9c36ddd07dfd9b919d9ecc117ba20a90987d56aa4c429fa34509188", size = 698045, upload-time = "2026-09-29T00:54:02.247Z" }, + { url = "https://files.pythonhosted.org/packages/e6/55/fa277a835cd6eb42380591ceb85f48c5b4d2b2d7e2cb9869e1e17d24d237/librt-0.16.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4e29522c62e28595ff7e324c6834ade51127707f0e255b18d1c1cf03d39c1048", size = 724640, upload-time = "2026-09-29T00:54:04.078Z" }, + { url = "https://files.pythonhosted.org/packages/25/e4/2cf64354f3fde8ebd591b3b48f96510bee24ac5f7d1e567adbbe210abdbd/librt-0.16.0-cp314-cp314t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:3ff4b2367926b69c6215635902cccb04048e73094e9862900d27cb2c6bbff143", size = 731748, upload-time = "2026-09-29T00:54:05.741Z" }, + { url = "https://files.pythonhosted.org/packages/f8/c9/c180af3e94e01aa529fa93d7733fec2abc47f222345400cf21d5481d5f8a/librt-0.16.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c6f1b27bf1632a7e016af9f145f82be95e1edd7721a646505c21059257cb5a04", size = 754960, upload-time = "2026-09-29T00:54:07.38Z" }, + { url = "https://files.pythonhosted.org/packages/95/d6/01073aa78c58f356b10d9c57b3fe9abb143df338142bcd316df417b89db0/librt-0.16.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:5696d7f52e7b37217cb3a8f92c744fe835942602fdd4c1a8bc4741d3bfdce15e", size = 747000, upload-time = "2026-09-29T00:54:09.06Z" }, + { url = "https://files.pythonhosted.org/packages/f7/d8/1de3783908658d697a8cfc00582f61299ffba7796d7260c112e4700b1109/librt-0.16.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:6072e92dd876ff6ceeb6cf371e35e51f479349837391341f479b08df4564242b", size = 749569, upload-time = "2026-09-29T00:54:10.702Z" }, + { url = "https://files.pythonhosted.org/packages/b7/32/e817f66c96d6caa8bb8435ff93c4c220624d59efc506be59ab98fcd01d0c/librt-0.16.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:39ca4f2f2fe05de8e63493da592d84311adabe5bef52b193851981da9816b302", size = 729483, upload-time = "2026-09-29T00:54:12.25Z" }, + { url = "https://files.pythonhosted.org/packages/7c/c9/23992ccd2b9d22798fdd0f61353183a47414e651da782ad83eb680f50833/librt-0.16.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f9807485a908f00355820f18e91e045ffdcdc5adb68aaec40a1e2b88c5f7bba1", size = 776584, upload-time = "2026-09-29T00:54:13.837Z" }, + { url = "https://files.pythonhosted.org/packages/67/3b/e8af957f08e6e2e8e566b099e43d2748418aa565df6ee1d9d3331209fdfe/librt-0.16.0-cp314-cp314t-win32.whl", hash = "sha256:94be5cb7bca4df6201f4183e9e4fa2086c655283d20b38cd84500a69057575a7", size = 104402, upload-time = "2026-09-29T00:54:15.568Z" }, + { url = "https://files.pythonhosted.org/packages/ca/1c/946e6443d7cd32347a086043395e421e52fd603c9163d2ec970ceab8eed6/librt-0.16.0-cp314-cp314t-win_amd64.whl", hash = "sha256:d46ca272b251d033dd4527b0dec5f261a28a52bd5fa0f99c117b0a1f8588cc2d", size = 126227, upload-time = "2026-09-29T00:54:17.165Z" }, + { url = "https://files.pythonhosted.org/packages/c2/a3/bc4f9959d3c62bcbf9e5fd3470a8bbd8bf33224ed4c25d7fba173201b8ac/librt-0.16.0-cp314-cp314t-win_arm64.whl", hash = "sha256:b9d6d4b14e92d876f8026b54c20c445f36425214c1081dc76f74e40db386b82b", size = 116493, upload-time = "2026-09-29T00:54:18.567Z" }, + { url = "https://files.pythonhosted.org/packages/b6/4b/10fdb42dfab4c1533e1570e686b18e86ff4328b406361b39fb3016667638/librt-0.16.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:6fe436af2eaf630474f491af5d032cbe45f93fcff5c3b9fe4ab194a7255b20ff", size = 149829, upload-time = "2026-09-29T00:54:19.933Z" }, + { url = "https://files.pythonhosted.org/packages/8e/30/a90ca13f1d3d91af1680000a4038536907018fbd51764767287a05d28b8b/librt-0.16.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:8ff5d26c529336be9bd7ae04483235d77778ee7d6444a95353102b542601ce81", size = 154522, upload-time = "2026-09-29T00:54:21.306Z" }, + { url = "https://files.pythonhosted.org/packages/5c/dd/bcf364eacfa070bb1fc88d503111ae7177914197ba1fa717c748926e7930/librt-0.16.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:909d8e3c1faee44cb762b1c519ff8613dcc5ceae5c99987a00917b5a31fd1d6a", size = 497593, upload-time = "2026-09-29T00:54:22.798Z" }, + { url = "https://files.pythonhosted.org/packages/18/c1/2c4e81e347bdabfe8346bfc6dc37ae5e154d61c88e30848ec0606025a5e0/librt-0.16.0-cp315-cp315-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:6d4a64283ee61824b5790de882bc68e2d9d7a5143537cb7a966f7354f71646d4", size = 480459, upload-time = "2026-09-29T00:54:24.364Z" }, + { url = "https://files.pythonhosted.org/packages/ab/d7/fef2a3cb8400701be496f6e459876f650b3451f407e30cb243de571ae615/librt-0.16.0-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5810ba811297fdf37a1531a57667cb8ace0842013ca8606bf9eb7c24cf4be154", size = 507814, upload-time = "2026-09-29T00:54:25.997Z" }, + { url = "https://files.pythonhosted.org/packages/e1/6f/53762927a32e9dc9eb1d1c1f3528da281290c86d96929a8af652f671266e/librt-0.16.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e56aaf8c167548dc8e5d6f3bd0f48dcdd299a23c73be3f744aab79d99e9c7f5d", size = 525114, upload-time = "2026-09-29T00:54:27.747Z" }, + { url = "https://files.pythonhosted.org/packages/6c/67/0b9d031f303c4e8c691a9a8ef9d272f13b530c11cc563b819df621b6a348/librt-0.16.0-cp315-cp315-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8f36c58e33b304b525c6c9c5076399c6ebf1109e17b9051a05a407b091b9215b", size = 520465, upload-time = "2026-09-29T00:54:29.331Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d5/2056a3a85864e882eb17a203a10ddb26fa748bc9718ec67e79059ab46cae/librt-0.16.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:242e00b3d4fa37c3d3c1ca5f5c9adb7d909ddb1eac9c41f2787320d00caa0af2", size = 537257, upload-time = "2026-09-29T00:54:30.915Z" }, + { url = "https://files.pythonhosted.org/packages/54/57/e0d79790c163cbc0909e209a6f62e30bb713b647f905a176cdc64848fd4d/librt-0.16.0-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:0253721561787b8df8443eb347b7a6461015354e5bdd37ee38a41fef220d2bb0", size = 527442, upload-time = "2026-09-29T00:54:32.478Z" }, + { url = "https://files.pythonhosted.org/packages/aa/50/1c0c95aba7af51f4752ea34fbf2eb79b36e7cae3a72536248e8c735de735/librt-0.16.0-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:3e483a8d69ede8067db70c0e83007423b6925de6fd53afed01d66160f2e9398c", size = 548139, upload-time = "2026-09-29T00:54:34.183Z" }, + { url = "https://files.pythonhosted.org/packages/98/91/a8a43dd5138d4f55f88846b8f0c85454a4fad69952cebfcff9948f831290/librt-0.16.0-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:69ba927445cfaaffb4081003ef5224c55a5c2ab67ef956f416ef744916e44121", size = 529708, upload-time = "2026-09-29T00:54:35.761Z" }, + { url = "https://files.pythonhosted.org/packages/2d/41/d5226881ab2b7c20d9d587b37bdd4a0ec8775a96d00ca87ac9f385587db4/librt-0.16.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:d6a365f2ab45a984d0e00eee0dd17f599ceab8cadab6ea07b6111c8132fc0e42", size = 567781, upload-time = "2026-09-29T00:54:37.409Z" }, + { url = "https://files.pythonhosted.org/packages/bb/bf/2345ba57a626e8c78c4ddcc724636a8df5a593fe46c1ee76bbf477e32b0d/librt-0.16.0-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:f01f3805f2dae4781c0c34b440e31740d082950bdaf89a6f601ad589a28af57a", size = 79177, upload-time = "2026-09-29T00:54:38.792Z" }, + { url = "https://files.pythonhosted.org/packages/1e/40/99e77936cc9207f629b077bf7cbc5e2f0827cddd7c29792f04ef881bd2c3/librt-0.16.0-cp315-cp315-win32.whl", hash = "sha256:b0e3e721c75d2e79a76d4422c79d7ba705fe1bbafec907037fe7a657a480a0e3", size = 100127, upload-time = "2026-09-29T00:54:40.251Z" }, + { url = "https://files.pythonhosted.org/packages/56/1e/801fe26bc622061b9dfd010e166d94142cb774b733217e6d98d1c0cf2638/librt-0.16.0-cp315-cp315-win_amd64.whl", hash = "sha256:bc02954b1295de798bbdb0b4e2d8a28c2117de8b5c73dcbeb27dc32572dfb971", size = 120480, upload-time = "2026-09-29T00:54:41.722Z" }, + { url = "https://files.pythonhosted.org/packages/bb/a9/d533983055bd36e112627384c2c038845d1df882540b8bcefb566475640b/librt-0.16.0-cp315-cp315-win_arm64.whl", hash = "sha256:c5db585d43449a5f54303d4b2774e45e1babd975cfe1630a3d708c0b80c3e560", size = 110915, upload-time = "2026-09-29T00:54:43.052Z" }, + { url = "https://files.pythonhosted.org/packages/55/fe/d62238fa9c653b0e0613290349467cb65711b5800e8e474f45e942a0ad95/librt-0.16.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:f06c689cb14afd9b612727553a5ec5a40febf113ca41c4413a2b0b334285884b", size = 159714, upload-time = "2026-09-29T00:54:44.497Z" }, + { url = "https://files.pythonhosted.org/packages/f3/ac/f31efe7818700be72ba4f9af8a80fa67c39808c8d26dacc55dc1f6f35172/librt-0.16.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:13b4e8aba90b0b1c82474e9844aa9ffe7ad3faa484350e1da64cb8188d903134", size = 162086, upload-time = "2026-09-29T00:54:45.968Z" }, + { url = "https://files.pythonhosted.org/packages/d9/16/4d7487bf86a9d7e8e18f37ba5538789233ea693637379b75701bd35ec9de/librt-0.16.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5a269c46ae327d8e6f8c1f85f7516cb52c0fa48127565a1105a4f4a05ff2a0b4", size = 712727, upload-time = "2026-09-29T00:54:47.486Z" }, + { url = "https://files.pythonhosted.org/packages/77/74/50cd550ccc1a517b9ed62347625c01ddf8c4afad66490312677c011458f6/librt-0.16.0-cp315-cp315t-manylinux2014_i686.manylinux_2_17_i686.manylinux_2_28_i686.whl", hash = "sha256:a33e0dae1f8592146a4764d54ce842b278732d21a84e17c3bbe6b1bc158a2248", size = 681106, upload-time = "2026-09-29T00:54:49.126Z" }, + { url = "https://files.pythonhosted.org/packages/df/5d/7293f712975ee6fdd2251411fd9ef1c62bc99c7b83ecbe62dbc999b1fab7/librt-0.16.0-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:47ada6ea32636492c61aa8ad27ae3b9404bfe7a97e3ba946d1984236cc741da0", size = 705921, upload-time = "2026-09-29T00:54:50.905Z" }, + { url = "https://files.pythonhosted.org/packages/67/f7/8aab946f11d59d1bece9ffc65d994b200c789a8ca5a95c17e17e609f912a/librt-0.16.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c43bd6e642d8a248c114327f98dd25ac5a7cb5aa168ef02f0559b91874df16b8", size = 731786, upload-time = "2026-09-29T00:54:52.584Z" }, + { url = "https://files.pythonhosted.org/packages/43/76/1c42ab31e7cb8384ebf6d3af607213c495222474f4940443ae7639ab7685/librt-0.16.0-cp315-cp315t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c3d1bb7841a816ace6449bb26d3f9560dbfa20e71c568d23f0f62bf1e68f50b1", size = 744964, upload-time = "2026-09-29T00:54:54.217Z" }, + { url = "https://files.pythonhosted.org/packages/6f/2e/4b19982d933d2dfced671e840b219e4c1cd3f507df6e6dabb51bbd4e3850/librt-0.16.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:3931f7a3db322e7f44e02a280e3949326ce9579ad388ee8d691dc7c76da9fb70", size = 765305, upload-time = "2026-09-29T00:54:55.815Z" }, + { url = "https://files.pythonhosted.org/packages/b8/1b/e872583de2dcb3ac7746e7a2321aeeb168274f3952a87dc66e05ddb29faf/librt-0.16.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:f4462528b6000afe8f16907b5c7c2553abf1df005ba5140e6eb394541c3624c3", size = 744959, upload-time = "2026-09-29T00:54:57.532Z" }, + { url = "https://files.pythonhosted.org/packages/10/de/a18c6bcfb297af2674233e90b3c3661c3a0af0f1434a0c966d2ef708a835/librt-0.16.0-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:80039ba9b6a7d5f1a0175a4cca6bbefead87bd854c80abad1cb30afe47a830db", size = 758138, upload-time = "2026-09-29T00:54:59.484Z" }, + { url = "https://files.pythonhosted.org/packages/22/1c/0df1d732539c297bb1a093e1fe3204d2faf76a9022cf4e1d1c2fce059790/librt-0.16.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:7a1d272724b581bb6bc769dfdafed6da2ecc9886ba2450311de55a4ac2e1e9cd", size = 744268, upload-time = "2026-09-29T00:55:01.179Z" }, + { url = "https://files.pythonhosted.org/packages/a2/f7/ccaf31331f20c91a5bd9bd48ffc3f743f9c81bb5720cc7b2a720ca204f0a/librt-0.16.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:fbe4fb8c5445f7496d7f7f6bb0807875d09d47e6771ffa175fb2df2895fb86ba", size = 785783, upload-time = "2026-09-29T00:55:02.938Z" }, + { url = "https://files.pythonhosted.org/packages/c1/ea/7421d9e6db894cd6cd788b604b3394a163ded6b942052b6f96c23ccf08e1/librt-0.16.0-cp315-cp315t-win32.whl", hash = "sha256:375bfe6b572a8f6cfc398709356046173bf27e64c4c5edaf5f7062f051fb4bf9", size = 104355, upload-time = "2026-09-29T00:55:04.533Z" }, + { url = "https://files.pythonhosted.org/packages/85/6d/7c31a506eb847bc58aeb2402d58e17605e821f68ab5df5e66fe274a6df41/librt-0.16.0-cp315-cp315t-win_amd64.whl", hash = "sha256:bd3150023d3dc2bc70f3784e59ffa1140d56ddba3d8125b3d6f9f85221279bfc", size = 126134, upload-time = "2026-09-29T00:55:06.017Z" }, + { url = "https://files.pythonhosted.org/packages/36/69/7a5d10ac409c4da0355e054a14371871da9b5557fcc42772cd00181c6cce/librt-0.16.0-cp315-cp315t-win_arm64.whl", hash = "sha256:8ceafb70f2a4f0826f11031942e59c0728fd98da112dc346d4352bde1e486866", size = 116391, upload-time = "2026-09-29T00:55:07.484Z" }, +] + +[[package]] +name = "mypy" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ast-serialize" }, + { name = "librt", marker = "platform_python_implementation != 'PyPy'" }, + { name = "mypy-extensions" }, + { name = "pathspec" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4a/3c/78ecece71ee4b5445389a4ccd11627cfb9c69e4de554d11060171f376305/mypy-2.4.1.tar.gz", hash = "sha256:63b590965691e540a335fa74dadf31a7069142f6b72e234689bbd244edf55623", size = 4066728, upload-time = "2026-10-28T19:23:13.286Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c0/1a/0be9dc6af5e0e04128f18a5e36b4ca44bfb0085857d37aa6a7de1ac2b0cb/mypy-2.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d63737426a048a27705a4eedb828669f4bc0873612a1b46b0b9fe892b2ebaaaf", size = 14381321, upload-time = "2026-10-28T19:21:54.223Z" }, + { url = "https://files.pythonhosted.org/packages/0d/a6/7907e36711a8a8c703f961f076fab61793383694140bd1fd87589f3f68d4/mypy-2.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7344869cad05f073b8cae2826774fa0161e3eb2f5c685b76813574008d77d750", size = 14466373, upload-time = "2026-10-28T19:22:25.211Z" }, + { url = "https://files.pythonhosted.org/packages/5d/b8/7313212b29de570c25c9859d7c8e4ef2251a6d34338a1e20031d94297721/mypy-2.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a20ff6cd2af7a670c64f089bfa5fbcebe8ff3bf896c5e6ac7c9862c7960e4494", size = 15553666, upload-time = "2026-10-28T19:22:36.511Z" }, + { url = "https://files.pythonhosted.org/packages/23/8f/92966b6082ff49da9142e1e527eb9af4359a9a61632a1cfc313da96b37fe/mypy-2.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:9ed1195502cca32be5ef756b1693477f4991db2f2e34eaa90cc4ad6bea4f9531", size = 15802641, upload-time = "2026-10-28T19:21:13.421Z" }, + { url = "https://files.pythonhosted.org/packages/b6/b4/874f6fd54b005020ad63e2cf7a59b178d16a771d478849b29b842cb0cf14/mypy-2.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:4c194c5d878130fca1ae662dfb1feb6274afbab0b40032c80147377e0ea803d5", size = 11383067, upload-time = "2026-10-28T19:22:03.516Z" }, + { url = "https://files.pythonhosted.org/packages/b0/41/5ae8e6528c2faa96e4a921a999d2c7ac7c565bee184b4282bf62ffa76b5d/mypy-2.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:71eda06e5bae51976ce869fda429159c9cec678bd02f25bb197f0265c8f991be", size = 10946882, upload-time = "2026-10-28T19:21:39.51Z" }, + { url = "https://files.pythonhosted.org/packages/6a/65/cd19bc06b67d2df4828220245fd98569ba40fac00c60ba48bef1817d8ac3/mypy-2.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3f1613bfe6726169a5680ec3dad5fe1f6d96285c12aded51ad432eadedd39d45", size = 14214179, upload-time = "2026-10-28T19:22:27.49Z" }, + { url = "https://files.pythonhosted.org/packages/c9/db/4d54ca4f49a0113d0c956980272aefdc6eec5458f7a72b350785b9ef2249/mypy-2.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:680ba5d9f0e3fe0c746b3d14df15f2a718e4bc308a1145616a1ea691ce7c354b", size = 14376217, upload-time = "2026-10-28T19:21:08.019Z" }, + { url = "https://files.pythonhosted.org/packages/a2/45/089b4724b85f0f408941be5298f817ee89181c1ce031a73d60ebb150c2c7/mypy-2.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb70621535c22fd4b1a0450d37ed1d6c5eb39656a1cebfb189084c12de54ba7", size = 15467623, upload-time = "2026-10-28T19:21:21.555Z" }, + { url = "https://files.pythonhosted.org/packages/27/4c/15edbc64b0b1412bfe94c74192b3b56554ab642b85a31bb06cef6313101f/mypy-2.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4af5ad558033bf71a44a1be149ed61633522824f84c1b6bc2445d3fe2d2a5296", size = 15729867, upload-time = "2026-10-28T19:21:37.557Z" }, + { url = "https://files.pythonhosted.org/packages/76/5b/7d160fb685994b65b0ca86d352f3afb5424f96a9e6914719f7b861fb6701/mypy-2.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:acdd82cb3a2eb10720e87706a128d75785d005a8c47e36a4973221524f41fc56", size = 11390802, upload-time = "2026-10-28T19:22:18.081Z" }, + { url = "https://files.pythonhosted.org/packages/9a/ea/453d27f8d531f57c5f14aa73094eaa48e3fb77f680bdede2045cb64fa58b/mypy-2.4.1-cp313-cp313-win_arm64.whl", hash = "sha256:133886ef1a7a8cf673df55d865e41580c6c46aa9b8e31e1325dfe315c038f745", size = 10950427, upload-time = "2026-10-28T19:22:59.003Z" }, + { url = "https://files.pythonhosted.org/packages/7d/75/282d43d6fea7be984ac63e75ffd8eee146ba2f3b077bb1ca5bf3f973e0c4/mypy-2.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c45485061ba08f700acc12cfc8b177e6997e6bc353605babfc0abb081e079456", size = 14233251, upload-time = "2026-10-28T19:22:44.977Z" }, + { url = "https://files.pythonhosted.org/packages/ac/a8/9021263cc7e761451c7d8131bdfab3c0a5c2d67aa2d694670019e1ab86a7/mypy-2.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:727890a32f1858c09549eb55a8b234fe990d460450b28f03e8213ef925f1247c", size = 14394953, upload-time = "2026-10-28T19:21:29.492Z" }, + { url = "https://files.pythonhosted.org/packages/16/10/4192a5cea09ebbc41c534f57bd0d8f0fb42a8e810632cda6e37f072c59fd/mypy-2.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:beb254fec368c4e7f7f82a5f310c6470b893ec88a90b66426da971c6826b0453", size = 15442824, upload-time = "2026-10-28T19:22:42.068Z" }, + { url = "https://files.pythonhosted.org/packages/99/e6/d3b0a7474aa4f696594a47a218b6796d9c4346fc81ed288904278cddd9bd/mypy-2.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ec416d5d2ae689e681f5727e328723f18d8b5dc8c903a146b7851dc5727aad8a", size = 15717227, upload-time = "2026-10-28T19:22:54.026Z" }, + { url = "https://files.pythonhosted.org/packages/48/6a/2ec530dacd4f77ca50d0fa05b854098f2d75e5d18c587d2612b44f10d68c/mypy-2.4.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:0e95ad0bec03ced9a73b42514208abd24c789e67f0e1eba476e276dd7a2dea3a", size = 7898637, upload-time = "2026-10-28T19:21:41.709Z" }, + { url = "https://files.pythonhosted.org/packages/cc/56/de9d7bad12e3868d5f1f4279aed20b1b568b2c5e166f2d3a05b211dca0b1/mypy-2.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:51f742d4154824837ca6e92aa81f00eec222700a3c337bd258e5562a3880d75a", size = 11576656, upload-time = "2026-10-28T19:22:13.232Z" }, + { url = "https://files.pythonhosted.org/packages/b8/12/4fa9883b9b59e5c96ff62845ad019dc47786031c45d67eaccf452cffffd8/mypy-2.4.1-cp314-cp314-win_arm64.whl", hash = "sha256:f44dd4c5ab22df21206dd926c98381ebdbf5bfd696df37dd38ded2d23143fcb6", size = 11174403, upload-time = "2026-10-28T19:23:01.346Z" }, + { url = "https://files.pythonhosted.org/packages/3f/f2/827e356fc4f74c60b8da42663336e035b49d948a3c11224b0fc7543086b1/mypy-2.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2875280687e64740e6ddcef43bd4c5852ad45ff34549740f6aea3f0373870b93", size = 15713427, upload-time = "2026-10-28T19:21:26.757Z" }, + { url = "https://files.pythonhosted.org/packages/a2/fa/e58a4fcae1d238189eac758036c0921992a86e3e6209190efd96d61fc5d4/mypy-2.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ea0714d2bccaf6d010c970e1d3ba2c9c2add79d2030aad2ef03167d788948276", size = 15938481, upload-time = "2026-10-28T19:22:34.371Z" }, + { url = "https://files.pythonhosted.org/packages/a1/54/a20f881801b88900923f2be1541a4b438ad0f0883e03836641fdc3d7adf4/mypy-2.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63c6ff0e7ea546943001a91639c9f0c64b60d239268fa5d29e4a6c87f82c2373", size = 17243006, upload-time = "2026-10-28T19:22:39.425Z" }, + { url = "https://files.pythonhosted.org/packages/de/1c/ff84a6133a6e89c390bff6b25d9bad6598e7891b205f4b30b496906d636d/mypy-2.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:a5b5da107dc2c93fb0a22f7a45dbaea5dc131afc7056b5468d78e819f9a138e6", size = 17557728, upload-time = "2026-10-28T19:21:43.607Z" }, + { url = "https://files.pythonhosted.org/packages/15/4a/effa47d39b8fadf679c08e7c78559e523f9769a42a75662d2d15b2b9cdd6/mypy-2.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:c3a4d0c47053cc90035dd3a2c321112b593ad42935d0cbfd747288e1564fa8ca", size = 12370826, upload-time = "2026-10-28T19:22:29.779Z" }, + { url = "https://files.pythonhosted.org/packages/46/9f/b214ececb1a97fbb61ab3dfd48ae3cffd92ae2c148af4c9dc94c6c56772b/mypy-2.4.1-cp314-cp314t-win_arm64.whl", hash = "sha256:0c5bf267645351887b72903fd2f5fbddcf85234e0e6c4ad94e2fcfb4f0c3f971", size = 11851083, upload-time = "2026-10-28T19:23:11.288Z" }, + { url = "https://files.pythonhosted.org/packages/57/5b/e44a2edb0b25a9f1429de770e1d0238af23302671dd40c77ac5efeb0c559/mypy-2.4.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:db599d03e7d60d15f2e0a11665c18bc52a88699fcab990fdf8cecd5be8ac801c", size = 14243144, upload-time = "2026-10-28T19:21:10.975Z" }, + { url = "https://files.pythonhosted.org/packages/59/d4/5c99dc3a28e11d2f0fcbb02df63d2d3e574dedc0f9f69d50901df305a7a6/mypy-2.4.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c6c7210e40dd423af7d65cbe428b5906d11dc60659337bdae4e5fdf02ce32ed7", size = 14409316, upload-time = "2026-10-28T19:22:15.515Z" }, + { url = "https://files.pythonhosted.org/packages/c3/c9/3108b38f4c30eabd80194f5d9771a87e27196c5e0ddb5bf4b99c6ed1e97e/mypy-2.4.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a2d4a51db92059eecc2c33b2a5194b28585ebfd917292c015fe87a77dbff6cd2", size = 15445573, upload-time = "2026-10-28T19:22:05.635Z" }, + { url = "https://files.pythonhosted.org/packages/dd/12/84a53eceaf11c46dfd7931fb6b8902d01fb33787d3a991e81c461458150b/mypy-2.4.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:01b7718552d017f88d1151f3cc9d6556d778a90bd58060a2c3d87d070f9099fb", size = 15732989, upload-time = "2026-10-28T19:23:06.512Z" }, + { url = "https://files.pythonhosted.org/packages/65/ba/bf017dc2abdf83b2f74e29c43834b7af67dc1f1b20202f02dae60b4781a0/mypy-2.4.1-cp315-cp315-pyemscripten_2026_5_wasm32.whl", hash = "sha256:3467b1d13000812ab85dc2a3834b9379ec77798ca1bcabe434e23fb21fead692", size = 7898932, upload-time = "2026-10-28T19:21:59.366Z" }, + { url = "https://files.pythonhosted.org/packages/76/05/0c22b1f0390120a8592d31209cb6b9f932b6a0b426fe643e550de15139e3/mypy-2.4.1-cp315-cp315-win_amd64.whl", hash = "sha256:080cf64a60b90a73435542feecf4171904cc5710658165b40c6869115d4aa100", size = 11577577, upload-time = "2026-10-28T19:22:01.302Z" }, + { url = "https://files.pythonhosted.org/packages/73/fb/ac01e173629697ddac2f11e51efd10347d673f9a7311b03f4aba710ebccd/mypy-2.4.1-cp315-cp315-win_arm64.whl", hash = "sha256:f9118a3f50de264b614861bb11814833a742138ac3c8e2e49a860b6977fb2704", size = 11173540, upload-time = "2026-10-28T19:21:46.444Z" }, + { url = "https://files.pythonhosted.org/packages/5b/e4/b9b9c8eb09e70927ee65b1456cfed35710b6e4ff0b07f364ceaf2202307c/mypy-2.4.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:9d7dafd56179d296651df9e1844b91c9517c379398f017a2a435d077a28943c1", size = 15706623, upload-time = "2026-10-28T19:22:20.528Z" }, + { url = "https://files.pythonhosted.org/packages/26/74/1ceb1ca884add0565e618d013dd24333039100dc0fcc42661561f2e1cae5/mypy-2.4.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d923cec43316f0e6736b8298fd00abeaaf348a091c20e7296b3aebceecb63eca", size = 15944095, upload-time = "2026-10-28T19:21:04.779Z" }, + { url = "https://files.pythonhosted.org/packages/2b/68/27bcf9b4efa22733b6050485ae37845b94c9b8851abe4fc60632d905c32d/mypy-2.4.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6e081b466e88d4343adffe11aff0f02df34b5b9070b4b700053a0b7294c0be1", size = 17223065, upload-time = "2026-10-28T19:23:03.724Z" }, + { url = "https://files.pythonhosted.org/packages/1a/a3/ed5724b317bf585c29f3c8be2792e97d45925d65a9c8af40ceeb267072e6/mypy-2.4.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:70196470ac300f444a302a738541101893c2c57804078b33690286a7899149e9", size = 17560589, upload-time = "2026-10-28T19:21:34.539Z" }, + { url = "https://files.pythonhosted.org/packages/42/2f/005185e6ab4752fd6cc2d1a6d1421fe21979770afe2490c00c555f34a913/mypy-2.4.1-cp315-cp315t-win_amd64.whl", hash = "sha256:de95648e0a6d46fa9929b956ed2c87c5dc9933d4d59945e6390e9d753c74e7c1", size = 12353324, upload-time = "2026-10-28T19:22:51.481Z" }, + { url = "https://files.pythonhosted.org/packages/a1/d6/20420cc9c780087139662534d128c2f3274361f8bb7e9cf0d5495a846ed5/mypy-2.4.1-cp315-cp315t-win_arm64.whl", hash = "sha256:ef8d5be90032261197ac388d945d8ff4f476c95880798a1911760af64ddfe71f", size = 11845599, upload-time = "2026-10-28T19:22:23.136Z" }, + { url = "https://files.pythonhosted.org/packages/21/5c/6e8010f8f2c4ad817364592d4b3883633417269b913fc9d5174fdeb7e565/mypy-2.4.1-py3-none-any.whl", hash = "sha256:1784648d6ec8c2b5465e3f26241b845a0b3cb4e56c993c64abe16989e7698999", size = 2801286, upload-time = "2026-10-28T19:21:19.516Z" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, +] [[package]] name = "packaging" @@ -40,6 +278,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, ] +[[package]] +name = "pathspec" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/82/42f767fc1c1143d6fd36efb827202a2d997a375e160a71eb2888a925aac1/pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a", size = 135180, upload-time = "2026-04-27T01:46:08.907Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" }, +] + [[package]] name = "pluggy" version = "1.6.0" @@ -73,3 +320,37 @@ sdist = { url = "https://files.pythonhosted.org/packages/e4/47/b9efed96c114afcfa wheels = [ { url = "https://files.pythonhosted.org/packages/24/25/1de2678b631f5a49215c6c96fff41ba892b0a34df68d6d80292b1b48aa7f/pytest-9.1.1-py3-none-any.whl", hash = "sha256:37a86b45efb9a47a61a36449063e8e18d0cab3161329fc099eb21783169c4f0c", size = 386536, upload-time = "2026-06-19T10:58:31.347Z" }, ] + +[[package]] +name = "ty" +version = "0.0.96" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d0/95/25b7533185c74ba38d859e3477e74cd98546f59a4ae5cd3962d11c3c6bdb/ty-0.0.96.tar.gz", hash = "sha256:f3026ef87a5ee1bd0687100c775af75a53289afe8e35b6e85bc3d1ce7d2f98cb", size = 8140460, upload-time = "2026-11-03T02:24:42.38Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/87/d0/4987625df7c37b6e945d8c2ed7fe320afc7af5967d7f1573f4a9011f9e13/ty-0.0.96-py3-none-linux_armv6l.whl", hash = "sha256:e306f33aeb58292b1164139101f22ee04d3db91fb5979ac87cbf379050fe11b8", size = 14566969, upload-time = "2026-11-03T02:23:45.474Z" }, + { url = "https://files.pythonhosted.org/packages/13/2a/aaf97d030999e31a5f27d4a017de151cc708e13b4e80f328f1f51c623a12/ty-0.0.96-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:0e1f272b15bf4329157d31a33481d59dd3ffab68070b98630e8ce627047f630d", size = 14169477, upload-time = "2026-11-03T02:23:49.263Z" }, + { url = "https://files.pythonhosted.org/packages/83/41/21373c2051ff5240eb312ef9523ce40d1f50e35eb951a72bb0fe04a4e57c/ty-0.0.96-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d8ed64f17ea16d3b6fd884398dae2d24b7982f6563219b5b30a3e25bec1ab364", size = 13250878, upload-time = "2026-11-03T02:23:52.604Z" }, + { url = "https://files.pythonhosted.org/packages/78/b4/c20ccce8281c790365052175fb059307f8ffac545ed14cfd49e0bf26b439/ty-0.0.96-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b4fe546b53c7156ab86cb28d07740bf239a8762885cc332c60f84b2cfdd5301", size = 14036428, upload-time = "2026-11-03T02:23:55.722Z" }, + { url = "https://files.pythonhosted.org/packages/fb/d6/2402cce8eb82948ac750ac302ecfdc112baa2f3e32a687d79cf567afab2c/ty-0.0.96-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:48c364d56a44b151fb70e626c000e968b4061b3df7de761f7dbbd356cb2ebf08", size = 14300301, upload-time = "2026-11-03T02:23:58.893Z" }, + { url = "https://files.pythonhosted.org/packages/85/12/34bd4a98fd6e328546cef2c6fd813cf1ef34ea737326580cd0d015d3e8c7/ty-0.0.96-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ef8ff21f39cb46395b1ae4b7fbb02b31481876afdb18c2a2df90f6745646ce1f", size = 15277037, upload-time = "2026-11-03T02:24:02.409Z" }, + { url = "https://files.pythonhosted.org/packages/79/d9/5b97d5cc1b39331cef2e69e11123a675dbeb68cc871d64dd039014c1a52e/ty-0.0.96-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5343ec6c3d70bcb3ec7b5ebf1cb885db02520d46fb6856acdaee7e3adf2d2a38", size = 15736036, upload-time = "2026-11-03T02:24:05.413Z" }, + { url = "https://files.pythonhosted.org/packages/3c/3b/d54892fbd35070acd9ec42a61414bd078c938195d2a85f8c49dd8c40e046/ty-0.0.96-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ad1658abe08ba90828fc86990e33559be641d4c275a661f0b98395368399a1f", size = 15660841, upload-time = "2026-11-03T02:24:09.079Z" }, + { url = "https://files.pythonhosted.org/packages/a6/67/a85ae9a7def66d0f0811e4b70a6373654fdd46f50b48c3fe22405e366f3a/ty-0.0.96-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f30919b298967c02e0fef4971d38df2cecc828a1b0db28af06e9504b7906c57", size = 16315589, upload-time = "2026-11-03T02:24:12.102Z" }, + { url = "https://files.pythonhosted.org/packages/a7/ce/522c9338a4a1f05ec94107951769a424e4fde2629253295d3f3b281d802d/ty-0.0.96-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:896a63e35f50f912c53d6fac82f0882b012967ead9a9548eb8f420b748e2de96", size = 15198643, upload-time = "2026-11-03T02:24:15.287Z" }, + { url = "https://files.pythonhosted.org/packages/5c/dd/e3ab40f645c45b8db9e25cabd338613fe935d4b65407776bc984d188180e/ty-0.0.96-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b6ffa368cc7aa220aa82431af13a5b3b4b96ca1b7db85af74fcb5e2722e703b2", size = 14038680, upload-time = "2026-11-03T02:24:18.239Z" }, + { url = "https://files.pythonhosted.org/packages/1e/a7/a3f84298dedb45b44b9083305ded6f7af0b84850677ebaa0c3254802a1b1/ty-0.0.96-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:cb39bc334dd1b882a273e0e79b5cc725191cda352ebd72498f078b9355647d58", size = 14307028, upload-time = "2026-11-03T02:24:21.307Z" }, + { url = "https://files.pythonhosted.org/packages/f9/2d/6143f17a2cf2508031a719c2af7bc69d5a05c7609f5fee7bcfce481cc8bf/ty-0.0.96-py3-none-musllinux_1_2_i686.whl", hash = "sha256:dbb581fb2440e369fbed7a3f02b822c040f13f13de77e99e194227b4a5e7fc4c", size = 14691384, upload-time = "2026-11-03T02:24:24.614Z" }, + { url = "https://files.pythonhosted.org/packages/b9/89/379c1bc9a0136b39e9a2fc251a2269bf8fdf51d652e64948131612919ee6/ty-0.0.96-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:83a60cc4129e27c1baca4da393a5d8e60ed0900dee2d7467475cd482e7b468d6", size = 15050137, upload-time = "2026-11-03T02:24:28.094Z" }, + { url = "https://files.pythonhosted.org/packages/b3/a3/c0259c3ef7ee010ef30ebd326bc6870c253b759852fd54d35ffa2fe6c218/ty-0.0.96-py3-none-win32.whl", hash = "sha256:0c52f28fd8baf646d8a1afed19ac9b905f5e0e488a86c7751f51bdc3bc42fecb", size = 13525177, upload-time = "2026-11-03T02:24:33.978Z" }, + { url = "https://files.pythonhosted.org/packages/a1/02/f02fd80e8a16f963492f851b5bc133bd4b815345b16765a8fa52769aea58/ty-0.0.96-py3-none-win_amd64.whl", hash = "sha256:aad1015dfafbc1ce1825977ea269dd0303de65369241d72f633632eba783c1bf", size = 14114949, upload-time = "2026-11-03T02:24:37.13Z" }, + { url = "https://files.pythonhosted.org/packages/d8/c7/03e8aa44da396aef5ae1bef1100b82e30bcebd46d0e1b850a6bf8d459ad1/ty-0.0.96-py3-none-win_arm64.whl", hash = "sha256:2d8ed65359556fb8974e265b747ad7dff81db14f2ac116072e53e6baa1639094", size = 13628038, upload-time = "2026-11-03T02:24:39.917Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +]