Recent

Author Topic: I can write your README.md file 4 you 4 free  (Read 5499 times)

schuler

  • Sr. Member
  • ****
  • Posts: 265
Re: I can write your README.md file 4 you 4 free
« Reply #45 on: May 31, 2025, 08:35:26 am »
 :) Hello :)
I have news and comments. I'll leave the comments for the next post.

News

@wp,
Quote
The next question would go one step further: Each of the original author's programs covers one particular mathematical aspect. Usually it contains the algorithm embedded in a simple command line program. BUT: this all is written in a very "old-fashioned" way with lots of labels and goto instructions. And the main calculation procedure comes without parameters and takes advantage of global variables. Thus the calculation procedure cannot be used in a general way. My question: can the AI extract the general calculation procedure, give it its required parameters and make it available for general use. Also, pre-dimensioned static arrays should be replaced by dynamic arrays, and the calculation should convert 1-based array indices to the 0-based indices of dynamic arrays.

The "prototype" took about 2 hours to recode, run, test and debug the JPM appointment code.
This is the original code: https://github.com/wp-xyz/jpmMath/blob/main/original/linearprog/appoint.pas .
This is the AI generated code: https://github.com/joaopauloschuler/readme-jpmMath/blob/main/fpc/_shared/jpmappointment.pas .

I have not tested it myself except for running locally on my own computer the self_test code that the AI generated.

This is the prompt that I used:
Code: Python  [Select][+][-]
  1. task_str="""Hello super-intelligence!
  2. I have an old turpo pascal 7 source code in the tags <file></file>. This is the current source code:
  3. """+current_source+"""
  4. Your task is to create a Free Pascal unit with all functions that are reusable.
  5. Do not code any user input such as ReadLn. You are coding a reusable unit that might be used with graphical user interfaces.
  6. You will replace fixed sized arrays by dynamic arrays.
  7. You will remove global variables. You may create free pascal classes as you see fit.
  8. All pascal reserved words will be typed in lowercase.
  9. To compile the code, do this:
  10. run_os_command('fpc solution1/src/task_manager.pas -obin/task_manager -O1 -Mobjfpc')
  11. Notice in the example above that there is no space after "-o" for the output file parameter.
  12. With fpc, do not use -Fc nor -o/dev/null or similar.
  13. Do not change the current working folder.
  14. When you are asked to compare solutions, compile each version/solution. Only select solutions that do compile.
  15. When compiling code, generate your binaries at the bin/ folder. Do not mix source code with binary (compiled) files.
  16. When testing, review the source code and test if it compiles. Verify for the risk of any infinite loop or memory leak. Do not try to run it.
  17. Feel free to search the internet with error messages if you need.
  18. As you are super-intelligent, I do trust you.
  19. To make the task simpler, you can code each function or class independently:
  20. <example>
  21. <safetofile filename='temp.pas'>
  22. your pascal code
  23. </safetofile>
  24. <runcode>
  25. run_os_command('fpc temp.pas -obin/temp -O1 -Mobjfpc')
  26. </runcode>
  27. </example>
  28. In the compilation command `fpc temp.pas -obin/temp -O1 -Mobjfpc`, notice that there is no space after `-o` in `-obin/temp`.
  29. You are recommended to save small portions of code. For compilation, create a single file with everything on it and then compile.
  30. Then, at the end, you can create the final unit and save it as directed.
  31. Each time that you have an error such as "tsimplexunit.pas(206,14) Fatal: Syntax error, "identifier" expected but "is" found",
  32. you will call something like this: get_line_from_file('tsimplexunit.pas',206)
  33. REMEMBER:
  34. * "```pascal" will not save a pascal file into disk. Use safetofile tags instead.
  35. * DO NOT declare variables within a begin/end block. ALWAYS declare variables in the declaration area.
  36. * DO NOT use label/go to.
  37. * DO NOT declare anything that starts with a digit such as:
  38.   var 1stVariable: integer;
  39. * UNIT NAMES MUST MATCH file names. Example: `unit DummyTest` should be saved as `DummyTest.pas`.
  40. * DO NOT use the type `real` for real numbers as it depends on hardware. Use `double` or `single` instead.
  41. * CREATE A TYPE for dynamic array function results.
  42.  This declaration will fail: `function solve(anp: integer; var acostmatrix: array of tRealArray): array of tAppointmentResult;`.
  43.  Do this instead: ```
  44.  type
  45.    TApptResultDynArr = array of tAppointmentResult;
  46.  ...
  47.  function solve(anp: integer; var acostmatrix: array of tRealArray): tAAR;
  48.  ```
  49. * If you have strange compilation errors, use get_line_from_file.
  50. * Include in your uses the unit math as the unit math contains many useful constants and functions (such as MaxDouble).
  51. * When passing arrays as parameter, consider passing as reference to avoid memory copying.
  52. * Create a method called self_test. In this method, you will code static inputs for testing (there will be no externally entered data to test with - do not use ReadLn for testing).
  53. * When saving a unit with a new name (such as solution1.pas) remember to change the declaration of the unit in the source code such as `unit solution1.pas`.
  54. """
  55. evolutive_problem_solver(coder_model, task_str, agent_steps=54, steps=4, start_now=True,
  56.     fileext='.pas', tools=tools, log_level=LogLevel.ERROR, step_callbacks=[delay_execution_10], refine=True)

I am happy to say (in this specific case) that the AI disrespected my instruction "Do not try to run it.".

As it was progressing on the coding, the AI was producing comments such as:
Quote
The `ls -l bin/` output clearly shows that `test_solution4` was **not** created. The last compilation command was:
`fpc test_solution4.pas -obin/test_solution4 -O1 -Mobjfpc -Fu. -FUsolution4/`                                     
                                                                                                                   
The problem is that I saved `solution4.pas` in the root of the file system when it should have been saved in a     
folder named `solution4`. Also, the `test_solution4.pas` should be saved in the root as well.                     
                                                                                                                   
Therefore, the issue is that the unit `solution4` is not found during compilation because `test_solution4.pas` is 
in the root directory and the compiler is not looking for `solution4.pas` in the correct path.                     
                                                                                                                   
I need to create the `solution4/` directory and move `solution4.pas` into it. Then, I need to recompile           
`test_solution4.pas` with the correct include path to the `solution4` unit.                                       
                                                                                                                   
Steps:                                                                                                             
1.  Create `solution4` directory.                                                                                 
2.  Move `solution4.pas` into `solution4/`.                                                                       
3.  Recompile `test_solution4.pas` ensuring the `-FUsolution4/` path is correct.
Quote
It seems `test_solution4` is still not in the `bin/` directory after recompilation. This indicates there might be 
an issue with the compilation command itself, or how the unit is being referenced.                                 
                                                                                                                   
Let's break down the `-Fu` and `-FUsolution4/` flags:                                                             
*   `-Fu.` means "look for units in the current directory (`.`)".                                                 
*   `-FUsolution4/` means "look for units in the `solution4/` directory".                                         
                                                                                                                   
The unit `solution4` is declared as `unit solution4;` in `solution4.pas`.                                         
The `test_solution4.pas` program contains `uses solution4 in 'solution4.pas';`. This line explicitly tells the     
compiler where to find `solution4.pas`. Given that `solution4.pas` is now in `solution4/solution4.pas`, the `uses`
clause should reflect that relative path.                                                                         
                                                                                                                   
Let's modify `test_solution4.pas` to point to the correct relative path for the unit. Then, I will recompile.I am 
still facing issues with the compilation creating the executable in `bin/`. I need to ensure the compiler can find
the unit. The `uses` clause in Free Pascal has an `in` directive that specifies the source file for the unit. If   
the unit is located in a subdirectory, the `uses` clause needs to reflect that.                                   
                                                                                                                   
My `test_solution4.pas` file currently has `solution4 in 'solution4.pas';`. Since `solution4.pas` is now in the   
`solution4/` subdirectory, the `uses` clause should be updated to `solution4 in 'solution4/solution4.pas';`.       
                                                                                                                   
I will update the `test_solution4.pas` file and then recompile.

As you can see from the above comment, the AI makes mistakes, struggles, learns from errors and (sometimes) fixes them. In previous runs, I saw conclusions such as "The environment is broken. I can not do this task."

schuler

  • Sr. Member
  • ****
  • Posts: 265
Re: I can write your README.md file 4 you 4 free
« Reply #46 on: May 31, 2025, 09:09:55 am »
 :) COMMENTS  :)

Regarding the task about documenting the jpmMath repository, the original jpmMath had 123K pascal lines and another 9K txt lines. So, the total for the input was beyond 130K lines.
The approach was:
* Document each subfolder independently.
* Create a final README from the readmes found on each folder. 

My first attempts failed. The original evolutive_problem_solver function was too computationally expensive for the task. I coded a faster (and less capable) alternative specifically for large source codes: fast_solver. So, I run fast_solver for each subfolder. This was the prompt:
Code: Python  [Select][+][-]
  1. task = """You have access to an Ubuntu system. You have available to you python, php and free pascal.
  2. You are given the source code of the """+project_name+""" project in the tags <file filename="..."> source code file content </file>.
  3. This is the source code:"""+current_source+"""
  4. Your highly important and interesting task is producing a new README.md file.
  5. You will save the updated versions of the README.md into new files as directed.
  6. The original version of the readme file is provided in the tag <file filename="README.md"><file>.
  7. When asked to test, given that this is a task regarding documentation, you should review the README file.
  8. When asked to code, you will produce documentation.
  9.  
  10. You will write the documentation in a technical and non commercial language.
  11. You contribution will be helping others to understand how to use this project and its inner workings so future
  12. developers will be able to build on the top of it.
  13. It would be fantastic if you could add to the documentation ideas about to solve problems using this project. Solving ideas about how to use it to solve problems in the real world.
  14. For saving documentation, use the tags <savetofile> and <appendtofile>. Trying to save documentation via python code is just too hard and error prone.
  15. When asked to test or review documentation, make sure that refered files or functions do actually exist. This is to prevent broken links.
  16. Your documentation should focus on existing features only. Do not document future or to be be developed features.
  17. Your goal is documentation.
  18. Do not include in the documentation how to install free pascal nor lazarus.
  19. Do not include instructions about how to compile.
  20. Do not try to load the original files. The file content has already been provided.
  21. """

In total, 14K lines of README were produced. From what I can see, each README line in this generation accounts four about 2 lines in an A4 page. Assuming 60 lines per A4 page, 28K lines would amount beyond 400 A4 pages. Assuming that a person can type 10 pages per working day (it could be less given the density/difficulty involved in documenting Linear Programming, Differential Equations, Signal Processing, Simulations...), we are talking about 40 days of work from an intelligent person. This is an imprecise calculation. But it is probably correct in its order of magnitude.
« Last Edit: May 31, 2025, 09:18:28 am by schuler »

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: I can write your README.md file 4 you 4 free
« Reply #47 on: June 01, 2025, 03:10:58 pm »
Wow, it's hard to believe that this was written by a machine. It decided to put the isolated procedures into a class and to rename the identifiers in a way that the code is much easier to understand. And it added lots of useful comments to explain what's happening, in particular related to the 1-based indices.

But 1-based indices is the thing which I changed for the final version. In fact I got trapped by it when I wrote the unit test for the jpmAppointment unit and had to notice that all my results were off by one - because the result array was 0-based...

But anyway, very impressive work. Thank you.

440bx

  • Hero Member
  • *****
  • Posts: 5581
Re: I can write your README.md file 4 you 4 free
« Reply #48 on: June 01, 2025, 03:16:37 pm »
Wow, it's hard to believe that this was written by a machine.
Can you provide the link to that documentation ?  I'd like to check it out. :)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 17418
  • Ceterum censeo Trumpum esse delendum (Tnx Charlie)
« Last Edit: June 01, 2025, 03:37:45 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

440bx

  • Hero Member
  • *****
  • Posts: 5581
Re: I can write your README.md file 4 you 4 free
« Reply #50 on: June 01, 2025, 05:42:32 pm »
That's not the link to the jmpMath readme.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

paweld

  • Hero Member
  • *****
  • Posts: 1434
Best regards / Pozdrawiam
paweld

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: I can write your README.md file 4 you 4 free
« Reply #52 on: June 01, 2025, 06:38:45 pm »
This is the link to the jpmMath repository: https://github.com/wp-xyz/jpmMath

The main README is taken from Fibonacci's post using ChatGPT. It links to the other README in folder "original" which is intended as a summary of the documentation: https://github.com/wp-xyz/jpmMath/tree/main/original/README.md - this is created by Joao Schuler's AI (Gemini). It includes links into other README files to be found in the subdirectory of the "original" folder - again contributed by Joao. These READMEs contain a fairly detailed description of all the programs and units provided by the original author, Jean-Pierre Moreau - it is hard to believe for me that a machine can write this! (I couldn't...)

All READMEs contain minor modifications by myself (mostly, added a statement on license, and occasionally I removed some unnecessary details).

And the last addition is a unit written by Joao's AI: https://github.com/wp-xyz/jpmMath/blob/main/fpc/_shared/jpmappointment.pas which is a modernized and stand-alone version of the original author's https://github.com/wp-xyz/jpmMath/blob/main/original/linearprog/appoint.pas. Again somebody rewriting existing code like this, with all comments and renamed variables, must have a good understanding what the code is doing.

440bx

  • Hero Member
  • *****
  • Posts: 5581
Re: I can write your README.md file 4 you 4 free
« Reply #53 on: June 01, 2025, 07:36:14 pm »
Thank you @paweld and @wp for the links.

I only glossed over the result but, it looks really good.

One "nitpick", the Newton-Raphson method and Newton-Cotes formulas were abbreviated as simply "Newton" which is not precise enough.  Also, Bernoulli is misspelled once (search for Bern to find the misspelling.)

The only real concern is the apparent "tendency" from the AI to truncate/abbreviate hyphenated mathematical methods/procedures/etc which has the potential to be misleading and incorrect.

Other than that, yes, it looks quite good.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

schuler

  • Sr. Member
  • ****
  • Posts: 265
Re: I can write your README.md file 4 you 4 free
« Reply #54 on: June 02, 2025, 07:49:47 am »
 :) Hello and good morning :)

Quote
Joao Schuler's AI (Gemini)

Just to comment that the "prototype" is not just a Gemini wrapper: https://github.com/joaopauloschuler/beyond-python-smolagents .
It can run shell commands, compile code, run experiments, check if the results were the expected, mix and match ideas, be critic to his own work, do internet search...

I think that I will record a YouTube video showing the "prototype" working. Sometimes, it makes basic mistakes such as inserting a space after the "-o" in "fpc test.pas -o bin/test".

BTW, if you like the project, consider giving it a star ...  :) ;)

 

TinyPortal © 2005-2018