xpile 0.1.1

Polyglot transpile workbench (Python/C/C++/Rust/Ruchy/Lean ↔ Rust/Ruchy/PTX/WGSL/SPIR-V) with provable contracts at every layer.
1
2
3
4
5
6
7
8
9
10
11
12
# Bitwise binops fixture (PMAT-003).
#
# Exercises &, |, ^, <<, >> in one function so the runtime-verified
# round-trip pins the semantics of every Layer-1 `C-PY-INT-ARITH`
# bitwise op in a single shot.
#
# Python:  ((a & b) | (a ^ b)) is `a | b`, but routing through both
#          gives us a useful product. Then `<<` and `>>` apply
#          arithmetic shifts to the result. We pick small literals to
#          keep i64 well inside range.
def bits(a: int, b: int) -> int:
    return ((a & b) | (a ^ b)) << 2 >> 1