Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(rs): fully by-hand expression simplification #273

Merged
merged 33 commits into from
Sep 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f90f512
testing: filter out nAn-looking things in proptests
Jul 25, 2023
1fa8b22
fix: some more rules, big test commented out
Jul 26, 2023
3aae513
fix: use velcro, simplify and add some rules
Jul 27, 2023
72a2990
Merge branch 'main' into big-eggspression
Jul 27, 2023
ea6c596
fix: rename some rules
Jul 27, 2023
13bd8a9
fix: remove pathological test case; simplify ruleset
Jul 27, 2023
787c29b
Merge branch 'main' into big-eggspression
Aug 1, 2023
ec64583
fix: typo
Aug 3, 2023
cb76257
new(rs): combine by hand & egg to simplify expressions
Aug 4, 2023
1288663
feat: remove egg, rely solely on by_hand
Aug 31, 2023
645f7b4
fix: unused dep
Aug 31, 2023
890f591
Merge branch 'main' into combo-simplifier
Aug 31, 2023
994063a
fix: debug
Aug 31, 2023
513f361
fix: clippy
Aug 31, 2023
924c060
fix: un-remove hash utility
Aug 31, 2023
10e53dd
wip: still getting syntax errors on the affine case
Aug 31, 2023
956e1cf
fix: fewer references and clones
Aug 31, 2023
d666ae8
fix: get affine working
Aug 31, 2023
4d945cd
fix: π => 3.1415926535897932384626…
Sep 1, 2023
c311ecc
fix: various tidyings and comments
Sep 1, 2023
be60ad1
doc: justify LIMIT = 1
Sep 1, 2023
c2b60de
fix: respond to PR review comments
Sep 5, 2023
a6ae87b
fix: some other opportunities for simplification
Sep 7, 2023
3b1957f
fix: responding to PR review comments
Sep 7, 2023
60ffad9
fix: test coverage
Sep 7, 2023
72ea53b
fix: make private something that no longer needs pub(crate)
Sep 7, 2023
5ba3c3d
Merge branch 'main' into combo-simplifier
Sep 7, 2023
ab09e46
fix: responding to PR comments
Sep 9, 2023
44ba8ff
Merge branch 'main' into combo-simplifier
Sep 9, 2023
b3d735d
fix: Commentary tweaks per review comments
Sep 11, 2023
65ac565
fix: simplify exponentiations of numbers or π
Sep 11, 2023
3068fe4
fix: remove erroneous subtraction rule
Sep 11, 2023
100345a
fix: add simple double subtraction test to protect against previous b…
Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: test coverage
  • Loading branch information
Graham Enos committed Sep 7, 2023
commit 60ffad9888793196438445d942118c3faeba68b1
186 changes: 186 additions & 0 deletions quil-rs/src/expression/simplification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,192 @@ mod tests {
};
}

genos marked this conversation as resolved.
Show resolved Hide resolved
test_simplify! {
function_cis,
"cis(0)",
"1"
}

test_simplify! {
function_cos,
"cis(0)",
"1"
}

test_simplify! {
function_exp,
"exp(1)",
"2.718281828459045"
}

test_simplify! {
function_sin,
"sin(0)",
"0"
}

test_simplify! {
function_sqrt,
"sqrt(9)",
"3"
}

test_simplify! {
infix_add_0_r,
"x + 0",
"x"
}

test_simplify! {
infix_add_0_l,
"0 + x",
"x"
}

test_simplify! {
infix_add,
"1 + 2",
"3"
}

test_simplify! {
infix_sub_0_r,
"x - 0",
"x"
}

test_simplify! {
infix_sub_self,
"x - x",
"0"
}

test_simplify! {
infix_mul_0_r,
"x * 0",
"0"
}

test_simplify! {
infix_mul_0_l,
"0 * x",
"0"
}

test_simplify! {
infix_mul_1_r,
"x * 1",
"x"
}

test_simplify! {
infix_mul_1_l,
"1 * x",
"x"
}

test_simplify! {
infix_div_0_l,
"0 / x",
"0"
}

test_simplify! {
infix_div_1_r,
"x / 1",
"x"
}

test_simplify! {
infix_div_self,
"x / x",
"1"
}

test_simplify! {
infix_exp_0_r,
"0^x",
"0"
}

test_simplify! {
infix_exp_0_l,
"x^0",
"1"
}

test_simplify! {
infix_sub_neg,
"x - (-y)",
"x + y"
}

test_simplify! {
infix_mul_double_neg,
"(-x) * (-y)",
"x * y"
}

test_simplify! {
infix_div_double_neg,
"(-x) / (-y)",
"x / y"
}

test_simplify! {
infix_affine_full,
"(a1 * x + b1) + (a2 * x + b2)",
"(a1 + a2) * x + (b1 + b2)"
}

test_simplify! {
infix_affine_coeffs,
"(a1 * x) + (a2 * x)",
"(a1 + a2) * x"
}

test_simplify! {
infix_affine_constants,
"(x + b1) + (x + b2)",
"(2 * x) + (b1 + b2)"
}

test_simplify! {
infix_mul_div_ll,
"(y * x) / x",
"y"
}

test_simplify! {
infix_mul_div_lr,
"(x * y) / x",
"y"
}

test_simplify! {
infix_mul_div_rl,
"x / (y * x)",
"1 / y"
}

test_simplify! {
infix_mul_div_rr,
"x / (x * y)",
"1 / y"
}

test_simplify! {
infix_div_mul_l,
"(x / y) * y",
"x"
}

test_simplify! {
infix_div_mul_r,
"y * (x / y)",
"x"
}

test_simplify! {
docstring_example,
"cos(2 * pi) + 2",
Expand Down