-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move arithmetic operations to complex expressions in ANF (#31)
- Loading branch information
1 parent
03a8ee4
commit 549238e
Showing
18 changed files
with
344 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
let g'1 a'2 b'3 = | ||
if ((a'2 = 0) || (b'3 = 1)) | ||
then true | ||
else | ||
let anf'18 = (g'1 (a'2 - 1)) | ||
in (anf'18 (b'3 + 5));; | ||
let anf'20 = | ||
let anf'18 = (a'2 = 0) | ||
in | ||
let anf'19 = (b'3 = 1) | ||
in (anf'18 || anf'19) | ||
in | ||
if anf'20 | ||
then true | ||
else | ||
let anf'22 = | ||
let anf'21 = (a'2 - 1) | ||
in (g'1 anf'21) | ||
in | ||
let anf'23 = (b'3 + 5) | ||
in (anf'22 anf'23);; | ||
let h'4 m'5 p'6 z'7 = | ||
let m'8 = (p'6 + z'7) | ||
in | ||
if (m'8 = 1) | ||
then | ||
let anf'20 = | ||
let anf'19 = (h'4 0) | ||
in (anf'19 0) | ||
in (anf'20 z'7) | ||
else | ||
let anf'21 = (g'1 m'8) | ||
in (anf'21 p'6);; | ||
let anf'24 = (m'8 = 1) | ||
in | ||
if anf'24 | ||
then | ||
let anf'26 = | ||
let anf'25 = (h'4 0) | ||
in (anf'25 0) | ||
in (anf'26 z'7) | ||
else | ||
let anf'27 = (g'1 m'8) | ||
in (anf'27 p'6);; | ||
let g'9 = | ||
let anf'23 = | ||
let anf'22 = (g'1 0) | ||
in (anf'22 2) | ||
let anf'29 = | ||
let anf'28 = (g'1 0) | ||
in (anf'28 2) | ||
in | ||
let anf'26 = | ||
let anf'25 = | ||
let anf'24 = (h'4 2) | ||
in (anf'24 2) | ||
in (anf'25 2) | ||
in (anf'23 + anf'26);; | ||
let anf'32 = | ||
let anf'31 = | ||
let anf'30 = (h'4 2) | ||
in (anf'30 2) | ||
in (anf'31 2) | ||
in (anf'29 + anf'32);; | ||
let g'11 a'10 = (a'10 + 1);; | ||
let g'13 b'12 = | ||
let anf'27 = (g'11 b'12) | ||
in (anf'27 + 2);; | ||
let anf'33 = (g'11 b'12) | ||
in (anf'33 + 2);; | ||
let simp'14 = (g'13 5);; | ||
let k'17 x'15 x'16 = x'16;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
let g'1 x'2 = | ||
if (x'2 < 0) | ||
then 0 | ||
else (g'1 (x'2 + 1));; | ||
let anf'6 = (x'2 < 0) | ||
in | ||
if anf'6 | ||
then 0 | ||
else | ||
let anf'7 = (x'2 + 1) | ||
in (g'1 anf'7);; | ||
let g'4 x'3 = | ||
let anf'6 = (g'1 (-5)) | ||
in (anf'6 + x'3);; | ||
let anf'9 = | ||
let anf'8 = (-5) | ||
in (g'1 anf'8) | ||
in (anf'9 + x'3);; | ||
let simp'5 = (g'4 3);; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
let factorial'1 n'2 = | ||
if (n'2 <= 0) | ||
then 1 | ||
else | ||
let anf'4 = (factorial'1 (n'2 - 1)) | ||
in (n'2 * anf'4);; | ||
let anf'4 = (n'2 <= 0) | ||
in | ||
if anf'4 | ||
then 1 | ||
else | ||
let anf'6 = | ||
let anf'5 = (n'2 - 1) | ||
in (factorial'1 anf'5) | ||
in (n'2 * anf'6);; | ||
let simp'3 = | ||
let anf'5 = (factorial'1 5) | ||
in (print_int anf'5);; | ||
let anf'7 = (factorial'1 5) | ||
in (print_int anf'7);; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
let id'2 x'1 = x'1;; | ||
let ll'10 n'4 k'5 result'6 = (k'5 (n'4 * result'6));; | ||
let ll'10 n'4 k'5 result'6 = | ||
let anf'11 = (n'4 * result'6) | ||
in (k'5 anf'11);; | ||
let cps_factorial'3 n'4 k'5 = | ||
if (n'4 = 0) | ||
then (k'5 1) | ||
else | ||
let anf'11 = (cps_factorial'3 (n'4 - 1)) | ||
in | ||
let anf'13 = | ||
let anf'12 = (ll'10 n'4) | ||
in (anf'12 k'5) | ||
in (anf'11 anf'13);; | ||
let anf'12 = (n'4 = 0) | ||
in | ||
if anf'12 | ||
then (k'5 1) | ||
else | ||
let anf'14 = | ||
let anf'13 = (n'4 - 1) | ||
in (cps_factorial'3 anf'13) | ||
in | ||
let anf'16 = | ||
let anf'15 = (ll'10 n'4) | ||
in (anf'15 k'5) | ||
in (anf'14 anf'16);; | ||
let factorial'8 n'7 = | ||
let anf'14 = (cps_factorial'3 n'7) | ||
in (anf'14 id'2);; | ||
let anf'17 = (cps_factorial'3 n'7) | ||
in (anf'17 id'2);; | ||
let simp'9 = | ||
let anf'15 = (factorial'8 5) | ||
in (print_int anf'15);; | ||
let anf'18 = (factorial'8 5) | ||
in (print_int anf'18);; |
Oops, something went wrong.