Skip to content

Conversation

@loader3229
Copy link
Contributor

No description provided.

@loader3229 loader3229 requested a review from ckrause as a code owner October 14, 2025 19:11
Copy link
Contributor

@ckrause ckrause left a comment

Choose a reason for hiding this comment

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

Please check comments

if (expr.name == "bitxor") {
if (expr.children.size() != 2) return false;
Expression f(Expression::Type::FUNCTION, "Int.xor", {expr.children[0], expr.children[1]});
expr = f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just set expr.name=...


std::string LeanFormula::printEvalCode(int64_t offset, int64_t numTerms) const {
std::stringstream out;
out << "import Mathlib.Data.Int.Bitwise" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Install it in the GH workflow

A008531: def a (n : Int) : Int := (Bool.toInt (n==0))+n*(5*n^2+5)
A021019: def a (n : Int) : Int := 6*(min n 1)
A060576: def a (n : Int) : Int := Bool.toInt (n != 1)
A092242: def a (n : Int) : Int := 2*(Int.xor (3*n-3) 1)+3
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add more examples?

@loader3229
Copy link
Contributor Author

You can use Copilot to fix GH workflow issue
I will find more examples

@ckrause ckrause requested a review from Copilot October 14, 2025 19:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the bitwise XOR operation in the LEAN formula conversion system. The purpose is to enable LODA to generate LEAN code that includes XOR operations when converting mathematical expressions to LEAN syntax.

  • Adds handling for "bitxor" expressions in the LEAN converter to output "Int.xor"
  • Includes necessary import statement for bitwise operations in LEAN
  • Adds test case for sequence A092242 which uses XOR operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/form/lean.cpp Implements bitxor to Int.xor conversion and adds required import
tests/formula/lean.txt Adds test case for A092242 sequence using XOR operation

Comment on lines 35 to 40
if (expr.name == "bitxor") {
if (expr.children.size() != 2) return false;
Expression f(Expression::Type::FUNCTION, "Int.xor", {expr.children[0], expr.children[1]});
expr = f;
break;
}
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

[nitpick] The bitxor handling code duplicates the pattern used for min/max operations. Consider extracting the common binary function conversion logic to reduce code duplication.

Copilot uses AI. Check for mistakes.
@loader3229
Copy link
Contributor Author

Replaced by #522

@loader3229 loader3229 closed this Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants