FORM-bench / benchmarks /v3c /test_open_v2_docs.jsonl
rakab's picture
Upload benchmarks/v3c/test_open_v2_docs.jsonl with huggingface_hub
8a1c25e verified
Raw History Blame Contribute Delete
220 kB
{"instruction": "Write a FORM program that defines a polynomial in three variables x, y, z with at least four terms and integer coefficients of your choice. Then, in a single statement, compute the expression E = P^2 - 2*P + 1, where P is your polynomial. Finally, print only the terms of E that are of degree 3 in the variables (i.e., total degree 3, such as x^3, x*y*z, etc.), using Bracket to organize the output by these terms. The program must end with Print; and .end.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Off Statistics;\nSymbols x,y,z;\nLocal P = x + y^2 + z^2 + 1;\nLocal E = P^2 - 2*P + 1;\nif ( count(x,1,y,1,z,1) != 3 );\n discard;\nendif;\nBracket x,y,z;\nPrint E;\n.end", "category": "open_codegen", "task_id": "790c25011c", "form_stdout": "\n E =\n + x*z^2 * ( 2 )\n\n + x*y^2 * ( 2 );\n\n", "changelog": "REF_BUG: original P made E=(P-1)^2 contain no degree-3 terms, and the reference printed all of E. Changed P to x+y^2+z^2+1 (still 4 terms, integer coefficients) so E has degree-3 terms; added FORM's if/count/discard degree-3 filter; Print E only."}
{"instruction": "Write a FORM program that defines a polynomial in two commuting symbols x and y with at least four terms, where at least two terms contain both x and y (with positive powers). Then compute the expression squared (i.e., multiply it by itself) and expand the result. Finally, collect terms with respect to x (i.e., use bracket x) and print the output. Make sure the final output shows the coefficients of each power of x as polynomials in y.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x,y;\nLocal F = x^2*y + 3*x*y^2 + 2*x + 5*y;\nLocal G = F^2;\nB x;\nPrint;\n.end", "category": "open_codegen", "task_id": "ee92f516b5", "form_stdout": "\nTime = 0.00 sec Generated terms = 4\n F Terms in output = 4\n Bytes used = 180\n\nTime = 0.00 sec Generated terms = 10\n G Terms in output = 9\n Bytes used = 356\n\n F =\n + x * ( 2 + 3*y^2 )\n\n + x^2 * ( y )\n\n + 5*y;\n\n G =\n + x * ( 20*y + 30*y^3 )\n\n + x^2 * ( 4 + 22*y^2 + 9*y^4 )\n\n + x^3 * ( 4*y + 6*y^3 )\n\n + x^4 * ( y^2 )\n\n + 25*y^2;\n\n"}
{"instruction": "Write a FORM program that defines a tensor expression involving a generic rank-2 tensor T (declared as a tensor with two indices) contracted with two vectors p and q. Specifically, define the expression as T(m1,m2)*p(m1)*q(m2) (with implicit summation over repeated indices). Then symmetrize the tensor T in its two indices (i.e., replace T(m1,m2) with (T(m1,m2)+T(m2,m1))/2) and simplify the resulting expression. Finally, print the result, which should be a scalar expression in terms of T, p, and q.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Tensors T;\nVectors p,q;\nIndices m1,m2;\nLocal F = T(m1,m2)*p(m1)*q(m2);\nid T(m1?,m2?) = (T(m1,m2) + T(m2,m1))/2;\nPrint;\n.end", "category": "open_codegen", "task_id": "ba8bb7281f", "form_stdout": "\nTime = 0.00 sec Generated terms = 2\n F Terms in output = 2\n Bytes used = 68\n\n F =\n 1/2*T(p,q) + 1/2*T(q,p);\n\n"}
{"instruction": "Create a FORM program that defines a polynomial in two variables, x and y, with at least five terms (including both positive and negative coefficients). Then perform the following operations in order:\n1. Substitute y with y + 1.\n2. Expand the result.\n3. Collect terms with respect to y (so that the output is grouped as coefficients times powers of y).\n4. Print the final result, showing the polynomial grouped by powers of y with x-dependent coefficients.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x, y;\nLocal F = 3*x^2*y^3 - 2*x*y^2 + 5*x^3*y - 7*x^2 + 4*y - 6*x + 1;\nid y = y + 1;\nBracket y;\nPrint;\n.end", "category": "open_codegen", "task_id": "8c7f9da4f7", "form_stdout": "\nTime = 0.00 sec Generated terms = 14\n F Terms in output = 11\n Bytes used = 372\n\n F =\n + y * ( 4 - 4*x + 9*x^2 + 5*x^3 )\n\n + y^2 * ( - 2*x + 9*x^2 )\n\n + y^3 * ( 3*x^2 )\n\n + 5 - 8*x - 4*x^2 + 5*x^3;\n\n"}
{"instruction": "Write a FORM program that defines the polynomial N = a^2 + 2*a*b - 3*b^2 in two symbols a and b, and verifies that N factors as (a - b)*(a + 3*b). Define an expression F = N - (a - b)*(a + 3*b), print it, and confirm the printed result is 0. (FORM does not perform rational-function cancellation, so verify the factorization symbolically.)", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a, b;\nLocal F = (a^2 + 2*a*b - 3*b^2) - (a - b)*(a + 3*b);\nPrint;\n.end", "category": "open_codegen", "task_id": "5de9f11884", "form_stdout": "\nTime = 0.00 sec Generated terms = 7\n F Terms in output = 0\n Bytes used = 4\n\n F = 0;\n\n", "changelog": "SPEC_BUG: 'multiply by the denominator to get the numerator' is unimplementable \u2014 FORM 5.0 does not cancel (a-b)*(a-b)^-1 (verified: Multiply (a-b) leaves the inverse factor). Rewrote as factorization verification N - (a-b)(a+3b) = 0."}
{"instruction": "Write a FORM program that defines three symbols a, b, c and a vector p. Create an expression with at least five terms of your choice, where each term is a product of powers of a, b, c and at least one factor of p.p (using the dot product). Then apply the substitution a = b + c and evaluate the result. Finally, collect the terms in powers of b and print the result.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,c;\nVectors p;\nLocal F = a^2*p.p + a*b*p.p + b^2*c*p.p + a*c^2*p.p + c^3*p.p;\nid a = b + c;\nBracket b;\nPrint;\n.end", "category": "open_codegen", "task_id": "e28d19aebd", "form_stdout": "\nTime = 0.00 sec Generated terms = 9\n F Terms in output = 6\n Bytes used = 288\n\n F =\n + b * ( 3*p.p*c + p.p*c^2 )\n\n + b^2 * ( 2*p.p + p.p*c )\n\n + p.p*c^2 + 2*p.p*c^3;\n\n"}
{"instruction": "Create a polynomial in two variables, say u and v, where the polynomial has at least 6 terms with varying degrees (including cross terms like u^2*v). Then substitute u = y+1 and v = y-1 into the polynomial, expand the result, and express it as a polynomial in y. Finally, print the result in a bracket form grouped by powers of y.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols u,v,y,a,b,c,d,e,f;\nLocal P = a*u^3 + b*u^2*v + c*u*v^2 + d*v^3 + e*u + f*v;\nid u = y+1;\nid v = y-1;\nBracket y;\nPrint;\n.end", "category": "open_codegen", "task_id": "3d59dd8aca", "form_stdout": "\nTime = 0.00 sec Generated terms = 24\n P Terms in output = 20\n Bytes used = 660\n\n P =\n + y * ( f + e + 3*d - c - b + 3*a )\n\n + y^2 * ( - 3*d - c + b + 3*a )\n\n + y^3 * ( d + c + b + a )\n\n - f + e - d + c - b + a;\n\n"}
{"instruction": "Write a FORM program that defines a polynomial in three symbols a, b, and c with at least four terms, each term having a distinct power of c (ranging from c^0 to c^3 or higher). Then apply the differentiation operator with respect to c to the polynomial and print the result. The polynomial should be of your choosing, but it must contain terms where the coefficient of each power of c is a nonzero combination of a and b (e.g., 3*a*b*c^2 is acceptable).", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,c,n;\nLocal F = a^2*b + 2*a*b^2*c + 3*a*b*c^2 + 4*b*c^3;\nid c^n? = n*c^(n-1);\nPrint;\n.end", "category": "open_codegen", "task_id": "97dd0bcafa", "form_stdout": "\nTime = 0.00 sec Generated terms = 3\n F Terms in output = 3\n Bytes used = 132\n\n F =\n 12*b*c^2 + 6*a*b*c + 2*a*b^2;\n\n"}
{"instruction": "Create a FORM program that takes the product of two sums: (x + y + z)^2 and (x - y + z)^2, where x, y, and z are symbols. Expand the product fully, then collect terms with the same total power of x (i.e., group by x-power), and print the result in a bracket format where each bracket header is the power of x (e.g., x^4, x^3, etc.). Use the Bracket statement to achieve this grouping.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x,y,z;\nLocal F = (x+y+z)^2 * (x-y+z)^2;\nBracket x;\nPrint;\n.end", "category": "open_codegen", "task_id": "82ee79fa42", "form_stdout": "\nTime = 0.00 sec Generated terms = 36\n F Terms in output = 9\n Bytes used = 388\n\n F =\n + x * ( 4*z^3 - 4*y^2*z )\n\n + x^2 * ( 6*z^2 - 2*y^2 )\n\n + x^3 * ( 4*z )\n\n + x^4 * ( 1 )\n\n + z^4 - 2*y^2*z^2 + y^4;\n\n"}
{"instruction": "Write a FORM program that defines a polynomial in two symbols x and y with at least five terms of your choosing. Then compute its square (i.e., multiply the polynomial by itself) and print the result. Ensure the program uses the standard FORM declarations and ends with a Print statement followed by .end.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x,y;\nLocal F = x^4 + 3*x^3*y - 2*x^2*y^2 + 5*x*y^3 + y^4;\nLocal G = F^2;\nPrint G;\n.end", "category": "open_codegen", "task_id": "25c5dcbdf2", "form_stdout": "\nTime = 0.00 sec Generated terms = 5\n F Terms in output = 5\n Bytes used = 172\n\nTime = 0.00 sec Generated terms = 15\n G Terms in output = 9\n Bytes used = 300\n\n G =\n y^8 + 10*x*y^7 + 21*x^2*y^6 - 14*x^3*y^5 + 36*x^4*y^4 - 2*x^5*y^3 + 5*\n x^6*y^2 + 6*x^7*y + x^8;\n\n"}
{"instruction": "Write a FORM program that defines two vectors of length 3 using index notation with symbols p and q (e.g., p(i) and q(i)). Compute the dot product p\u00b7q and then square that dot product. Print the final expression, which should be a scalar. Use the standard FORM index declarations and ensure the output is fully contracted.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Vector p,q;\nIndex i;\nLocal F = p(i)*q(i);\nLocal G = F^2;\nPrint G;\n.end", "category": "open_codegen", "task_id": "7cd06b4f83", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n F Terms in output = 1\n Bytes used = 40\n\nTime = 0.00 sec Generated terms = 1\n G Terms in output = 1\n Bytes used = 40\n\n G =\n p.q^2;\n\n"}
{"instruction": "Write a FORM program that defines a polynomial in two variables, x and y, with at least four terms and rational coefficients of your choice. Then compute the expression (poly)^2 - (poly) and print the result, collecting terms in powers of x.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x,y;\nLocal F = 3/2*x^2*y - 7/4*x*y^2 + 5/6*x - 2/3*y + 1;\nLocal G = F^2 - F;\nBracket x;\nPrint;\n.end", "category": "open_codegen", "task_id": "42ffbf1afe", "form_stdout": "\nTime = 0.00 sec Generated terms = 5\n F Terms in output = 5\n Bytes used = 200\n\nTime = 0.00 sec Generated terms = 20\n G Terms in output = 13\n Bytes used = 448\n\n F =\n + x * ( 5/6 - 7/4*y^2 )\n\n + x^2 * ( 3/2*y )\n\n + 1 - 2/3*y;\n\n G =\n + x * ( 5/6 - 10/9*y - 7/4*y^2 + 7/3*y^3 )\n\n + x^2 * ( 25/36 + 3/2*y - 59/12*y^2 + 49/16*y^4 )\n\n + x^3 * ( 5/2*y - 21/4*y^3 )\n\n + x^4 * ( 9/4*y^2 )\n\n - 2/3*y + 4/9*y^2;\n\n"}
{"instruction": "Write a FORM program that defines three vectors a, b, c in 4-dimensional space and a rank-2 tensor T whose components you choose explicitly as sums of products of vector components (via an id rule, e.g. id T(mu?,nu?) = a(mu)*b(nu) + b(mu)*c(nu)). Then: (1) compute the double contraction Expr = T(mu,nu)*a(mu)*b(nu); (2) compute the difference Diff = T(mu,nu)*a(mu)*b(nu) - T(mu,nu)*b(mu)*a(nu), which measures the asymmetry of the contraction under exchange of a and b; (3) print both Expr and Diff, fully contracted.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Dimension 4;\nVectors a,b,c;\nIndices mu,nu;\nCTensor T;\nLocal Expr = T(mu,nu) * a(mu) * b(nu);\nLocal Diff = T(mu,nu) * a(mu) * b(nu) - T(mu,nu) * b(mu) * a(nu);\nid T(mu?,nu?) = a(mu)*b(nu) + b(mu)*c(nu);\nPrint Expr, Diff;\n.end", "category": "open_codegen", "task_id": "d022a70ac3", "form_stdout": "\nTime = 0.00 sec Generated terms = 2\n Expr Terms in output = 2\n Bytes used = 92\n\nTime = 0.00 sec Generated terms = 4\n Diff Terms in output = 4\n Bytes used = 176\n\n Expr =\n a.a*b.b + a.b*b.c;\n\n Diff =\n a.a*b.b + a.b*b.c - a.b^2 - a.c*b.b;\n\n", "changelog": "SPEC_BUG: 'verify the contraction is symmetric' is false for a general T; instruction now asks for explicit components + the asymmetry difference. Reference restructured (compute Diff before substituting T, since id consumes T)."}
{"instruction": "Write a FORM program that computes the sum of all products of pairs of distinct elements from the set {a, b, c, d}, where each product is written with its two factors in alphabetical order. Use a nested #do loop to generate the products, and collect them into a single expression. Then, multiply the entire sum by the variable x and print the result. The output should contain all six pairwise products, each multiplied by x.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,c,d,x,dummy;\nLocal F = dummy;\n#do i = 1, 4\n #do j = 1, 4\n #if ( `i' < `j' )\n #if ( `i' == 1 ) && ( `j' == 2 )\n id dummy = dummy + a*b;\n #endif\n #if ( `i' == 1 ) && ( `j' == 3 )\n id dummy = dummy + a*c;\n #endif\n #if ( `i' == 1 ) && ( `j' == 4 )\n id dummy = dummy + a*d;\n #endif\n #if ( `i' == 2 ) && ( `j' == 3 )\n id dummy = dummy + b*c;\n #endif\n #if ( `i' == 2 ) && ( `j' == 4 )\n id dummy = dummy + b*d;\n #endif\n #if ( `i' == 3 ) && ( `j' == 4 )\n id dummy = dummy + c*d;\n #endif\n #endif\n #enddo\n#enddo\nid dummy = 0;\n.sort\nLocal G = x * F;\nPrint G;\n.end", "category": "tutorial", "task_id": "79102df246", "form_stdout": "\nTime = 0.00 sec Generated terms = 6\n F Terms in output = 6\n Bytes used = 200\n\nTime = 0.00 sec Generated terms = 6\n F Terms in output = 6\n Bytes used = 200\n\nTime = 0.00 sec Generated terms = 6\n G Terms in output = 6\n Bytes used = 248\n\n G =\n c*d*x + b*d*x + b*c*x + a*d*x + a*c*x + a*b*x;\n\n", "changelog": "REF_BUG: FORM #if compares literal strings unless loop vars are backtick-quoted (`i' < `j'), and 'Local F = F + ...' redefines instead of accumulating. Fixed: backtick-quoted conditions + dummy-symbol accumulation idiom (id dummy = dummy + term) + .sort before defining G."}
{"instruction": "Write a FORM program that takes the expression E = 3*a^2*b + 5*a*b^2 + 7*a^2*c + 2*b*c^2 and prints it twice: first grouped by powers of a (Bracket a; Print; .sort), then grouped by powers of b (Bracket b; Print). The two printed forms show the expression factored with respect to a and then with respect to b.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,c;\nLocal E = 3*a^2*b + 5*a*b^2 + 7*a^2*c + 2*b*c^2;\nBracket a;\nPrint;\n.sort\nBracket b;\nPrint;\n.end", "category": "tutorial", "task_id": "4ce3b917af", "form_stdout": "\nTime = 0.00 sec Generated terms = 4\n E Terms in output = 4\n Bytes used = 196\n\n E =\n + a * ( 5*b^2 )\n\n + a^2 * ( 7*c + 3*b )\n\n + 2*b*c^2;\n\n\nTime = 0.00 sec Generated terms = 4\n E Terms in output = 4\n Bytes used = 196\n\n E =\n + b * ( 2*c^2 + 3*a^2 )\n\n + b^2 * ( 5*a )\n\n + 7*a^2*c;\n\n", "changelog": "SPEC_BUG: 'factors out the common factor a*b from the first two terms' misdescribes what Bracket does. Restated as bracket-by-a-then-b, which is what the reference implements."}
{"instruction": "Write a FORM program that uses the Bracket statement to group terms in the expression F = a*x^2 + b*x + c + d*x^2 + e*x + f by powers of x. First declare the symbols, define the expression, then use the Bracket statement to factor out powers of x. Print the bracketed result so that terms with the same power of x are grouped together.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "S x, a, b, c, d, e, f;\nL F = a*x^2 + b*x + c + d*x^2 + e*x + f;\nB x;\nPrint F;\n.end", "category": "tutorial", "task_id": "add3764317", "form_stdout": "\nTime = 0.00 sec Generated terms = 6\n F Terms in output = 6\n Bytes used = 244\n\n F =\n + x * ( e + b )\n\n + x^2 * ( d + a )\n\n + f + c;\n\n"}
{"instruction": "Write a FORM program that applies the transformation f(t) = t^2 + 1 four times starting from the symbol x. Build the iterate with a #do loop over i = 1..4: each iteration applies id x = x^2 + 1 followed by .sort. Print the final polynomial in x. The constant term of the final polynomial is 26 (the 4th iterate of f applied to 1); the full polynomial is x^16 + 8*x^14 + 32*x^12 + 80*x^10 + 138*x^8 + 168*x^6 + 144*x^4 + 80*x^2 + 26.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbol x;\nLocal expr = x;\n#do i = 1, 4\n id x = x^2 + 1;\n .sort\n#enddo\nPrint;\n.end", "category": "tutorial", "task_id": "ec69aa1cd0", "form_stdout": "\nTime = 0.00 sec Generated terms = 2\n expr Terms in output = 2\n Bytes used = 52\n\nTime = 0.00 sec Generated terms = 4\n expr Terms in output = 3\n Bytes used = 76\n\nTime = 0.00 sec Generated terms = 9\n expr Terms in output = 5\n Bytes used = 124\n\nTime = 0.00 sec Generated terms = 25\n expr Terms in output = 9\n Bytes used = 220\n\nTime = 0.00 sec Generated terms = 9\n expr Terms in output = 9\n Bytes used = 220\n\n expr =\n 26 + 80*x^2 + 144*x^4 + 168*x^6 + 138*x^8 + 80*x^10 + 32*x^12 + 8*x^14\n + x^16;\n\n", "changelog": "SPEC_BUG: expected result '26' mismatched the reference (which iterates the symbol x, printing a polynomial whose constant term is 26). Restated instruction to match: polynomial iterate, constant term 26."}
{"instruction": "Write a FORM program that defines a polynomial P(x) = (x+1)^4, expands it, and then uses the Bracket command to group terms by their power of x. The program should print the result with terms grouped by powers, showing coefficients for each power from x^0 through x^4. Use the proper FORM syntax for bracketing and printing.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x;\nLocal P = (x+1)^4;\nBracket x;\nPrint;\n.end", "category": "tutorial", "task_id": "b59cdace13", "form_stdout": "\nTime = 0.00 sec Generated terms = 5\n P Terms in output = 5\n Bytes used = 184\n\n P =\n + x * ( 4 )\n\n + x^2 * ( 6 )\n\n + x^3 * ( 4 )\n\n + x^4 * ( 1 )\n\n + 1;\n\n"}
{"instruction": "Write a FORM program to compute the contraction of the Levi-Civita tensor with itself in 4-dimensional spacetime: \u03b5^{\u03bc\u03bd\u03c1\u03c3} \u03b5_{\u03bc\u03bd\u03c1\u03c3}. Use the convention that \u03b5^{0123} = +1 and \u03b5_{0123} = -1 (i.e., \u03b5^{\u03bc\u03bd\u03c1\u03c3} \u03b5_{\u03bc\u03bd\u03c1\u03c3} = -24). The program should use the built-in epsilon tensor e_ with four indices, contract all indices using the metric, and output the numerical result. Declare four Lorentz indices and use the standard FORM epsilon tensor notation. The final answer should be a simple integer. Ensure the sign convention is correct by checking that the result is -24, not +24.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Indices mu, nu, rho, sigma;\nLocal C = - e_(mu, nu, rho, sigma) * e_(mu, nu, rho, sigma);\nContract;\nPrint;\n.end", "category": "physics", "task_id": "f94c8e17d4", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n C Terms in output = 1\n Bytes used = 20\n\n C =\n - 24;\n\n", "changelog": "REF_BUG: FORM's e_ contraction yields +24 with FORM's internal convention. To match the stated metric convention (eps_0123=-1) the program must apply an explicit sign flip: - e_(...) * e_(...) = -24."}
{"instruction": "Write a FORM program to compute the cross-section for Compton scattering (gamma e -> gamma e) in the massless limit, at tree level. The squared amplitude, summed over final polarizations and averaged over initial ones, is given by:\n|M|^2 = (2*e^4) * ( - (u/s) - (s/u) + 4*(s^2+u^2)/(t^2) )\nwhere s = (p1+k1)^2, t = (p1-k2)^2, u = (p1-p2)^2, with p1 (initial electron), p2 (final electron), k1 (initial photon), k2 (final photon), and s+t+u=0. Use FORM to compute this expression directly as a polynomial in s, t, u, then substitute u = -s - t and simplify to a rational function. The final result should be printed. Declare s, t, u as symbols and e as a symbol for the charge. Use a Local expression for |M|^2, apply the substitution, and print.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols s,t,u,e;\nLocal M2 = 2*e^4 * ( -u/s - s/u + 4*(s^2+u^2)/t^2 );\nid u = -s - t;\nid 1/u = 1/(-s-t);\nPrint;\n.end", "category": "physics", "task_id": "f3b055d390", "form_stdout": "\nTime = 0.00 sec Generated terms = 7\n M2 Terms in output = 5\n Bytes used = 296\n\n M2 =\n 2*s^-1*t*e^4 + 10*e^4 + 16*s*t^-1*e^4 + 16*s^2*t^-2*e^4 - 2/( - t - s)*s\n *e^4;\n\n", "changelog": "REF_BUG: id u = -s - t does not touch the factor u^-1 (verified), leaving a leftover u in the output. Added id 1/u = 1/(-s-t) so the substitution is complete."}
{"instruction": "Compute the Dirac trace of the gamma-matrix string \u03b3^\u03bc \u03b3^\u03bd \u03b3^\u03c1 \u03b3^\u03c3 \u03b3^\u03c4 \u03b3^\u03bb in 4 dimensions, contracted with the momenta p_\u03bc q_\u03bd r_\u03c1 s_\u03c3 t_\u03c4 u_\u03bb, where p, q, r, s, t, u are distinct external momenta. Use the 't Hooft-Veltman scheme (Trace4) and express the result in terms of Mandelstam-like invariants (p\u00b7q, p\u00b7r, etc.). Then, take the limit where all momenta are lightlike (p\u00b2=q\u00b2=r\u00b2=s\u00b2=t\u00b2=u\u00b2=0) and output the simplified expression.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Vectors p,q,r,s,t,u;\nIndices mu,nu,rho,sigma,tau,lambda;\nLocal F = g_(1,mu,nu,rho,sigma,tau,lambda) * p(mu) * q(nu) * r(rho) * s(sigma) * t(tau) * u(lambda);\nTrace4,1;\nContract;\nrepeat;\n id p.p = 0;\n id q.q = 0;\n id r.r = 0;\n id s.s = 0;\n id t.t = 0;\n id u.u = 0;\nendrepeat;\nPrint;\n.end", "category": "physics", "task_id": "832631b516", "form_stdout": "\nTime = 0.00 sec Generated terms = 15\n F Terms in output = 15\n Bytes used = 672\n\n F =\n 4*p.q*r.s*t.u - 4*p.q*r.t*s.u + 4*p.q*r.u*s.t - 4*p.r*q.s*t.u + 4*p.r*\n q.t*s.u - 4*p.r*q.u*s.t + 4*p.s*q.r*t.u - 4*p.s*q.t*r.u + 4*p.s*q.u*r.t\n - 4*p.t*q.r*s.u + 4*p.t*q.s*r.u - 4*p.t*q.u*r.s + 4*p.u*q.r*s.t - 4*p.u\n *q.s*r.t + 4*p.u*q.t*r.s;\n\n"}
{"instruction": "Compute three Levi-Civita contractions with FORM's built-in e_ tensor under FORM's convention (e_(mu,nu,rho,sigma)*e_(mu,nu,rho,sigma) = 24):\n1. E1 = e_(mu,nu,rho,sigma)*e_(mu,nu,rho,sigma) \u2014 expect 24.\n2. E2 = e_(mu,nu,rho,sigma)*e_(mu,nu,rho,lambda)*a(lambda) \u2014 expect 6*a(sigma).\n3. E3 = e_(mu,nu,rho,sigma)*e_(mu,nu,lambda,kappa)*a(rho)*b(sigma) \u2014 expect 2*(a(lambda)*b(kappa) - a(kappa)*b(lambda)) (an antisymmetric rank-2 object).\nDeclare two vectors a, b and the needed indices, compute all three with Contract, and print.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Vectors a,b;\nIndices mu,nu,rho,sigma,lambda,kappa;\nLocal E1 = e_(mu,nu,rho,sigma) * e_(mu,nu,rho,sigma);\nLocal E2 = e_(mu,nu,rho,sigma) * e_(mu,nu,rho,lambda) * a(lambda);\nLocal E3 = e_(mu,nu,rho,sigma) * e_(mu,nu,lambda,kappa) * a(rho) * b(sigma);\nContract;\nPrint;\n.end", "category": "physics", "task_id": "143c370683", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n E1 Terms in output = 1\n Bytes used = 20\n\nTime = 0.00 sec Generated terms = 1\n E2 Terms in output = 1\n Bytes used = 36\n\nTime = 0.00 sec Generated terms = 2\n E3 Terms in output = 2\n Bytes used = 76\n\n E1 =\n 24;\n\n E2 =\n 6*a(sigma);\n\n E3 =\n 2*a(lambda)*b(kappa) - 2*a(kappa)*b(lambda);\n\n", "changelog": "SPEC_BUG: instruction demanded the Minkowski-signature sign (which FORM's Euclidean-convention e_ does not produce) and claimed E3 is expressible via scalar products a.b (it is a rank-2 antisymmetric object). Restated with FORM's actual convention and expected forms."}
{"instruction": "Compute the trace of the product of four gamma matrices Tr[gamma^mu gamma^nu gamma^rho gamma^sigma] in 4 dimensions using Trace4, then contract the result with metric tensors in three ways: T1 with d_(mu,nu)*d_(rho,sigma), T2 with d_(mu,rho)*d_(nu,sigma), and T3 with d_(mu,sigma)*d_(nu,rho). Since Tr[...] = 4*(g^mu nu g^rho sigma - g^mu rho g^nu sigma + g^mu sigma g^nu rho), the results are T1 = 64, T2 = -32, T3 = 64 (note: 4*16 minus the mixed contractions). Print all three.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Indices mu,nu,rho,sigma;\nLocal T1 = g_(1,mu,nu,rho,sigma) * d_(mu,nu) * d_(rho,sigma);\nLocal T2 = g_(1,mu,nu,rho,sigma) * d_(mu,rho) * d_(nu,sigma);\nLocal T3 = g_(1,mu,nu,rho,sigma) * d_(mu,sigma) * d_(nu,rho);\nTrace4,1;\nContract;\nPrint;\n.end", "category": "physics", "task_id": "a28404be12", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n T1 Terms in output = 1\n Bytes used = 20\n\nTime = 0.00 sec Generated terms = 1\n T2 Terms in output = 1\n Bytes used = 20\n\nTime = 0.00 sec Generated terms = 1\n T3 Terms in output = 1\n Bytes used = 20\n\n T1 =\n 64;\n\n T2 =\n - 32;\n\n T3 =\n 64;\n\n", "changelog": "SPEC_BUG: instruction's expected values 256/256/-256 were wrong (it neglected the mixed terms of the 4-gamma trace). Correct values 64/-32/64 verified both analytically and by FORM."}
{"instruction": "Compute the Dirac trace Tr[gamma^5 gamma^mu gamma^nu gamma^rho gamma^sigma] in 4 dimensions using FORM's Trace4. In FORM the gamma string is written g_(1,5_,mu,nu,rho,sigma), where the argument 5_ is gamma5, and Trace4 with FORM's convention yields 4*e_(mu,nu,rho,sigma) (real, no factor i \u2014 FORM's phase convention absorbs it). Declare indices mu, nu, rho, sigma, set Dimension 4, apply Trace4,1 and Contract, and print the result.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Indices mu, nu, rho, sigma;\nDimension 4;\nLocal F = g_(1,5_,mu,nu,rho,sigma);\nTrace4,1;\nContract;\nPrint F;\n.end", "category": "physics", "task_id": "87ae31143e", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n F Terms in output = 1\n Bytes used = 48\n\n F =\n 4*e_(mu,nu,rho,sigma);\n\n", "changelog": "REF_BUG: reference never applied Trace4 and used '5' instead of the correct gamma5 argument '5_', so it printed the raw g_ string. SPEC: instruction demanded -4 i eps, but FORM's Trace4 gives the real-valued 4*e_(mu,nu,rho,sigma) (phase absorbed); instruction restated to FORM's convention."}
{"instruction": "Compute the contraction \u03b5^{\u03bc\u03bd\u03c1\u03c3} \u03b5_{\u03bc\u03bd\u03c1\u03c3} in 4-dimensional Minkowski space. Here \u03b5 is the totally antisymmetric Levi-Civita tensor. Declare the necessary indices, use the epsilon tensor function e_ in FORM, and contract all four pairs of indices. The result should be a single integer. Print the final value.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "* Compute epsilon^{mu nu rho sigma} epsilon_{mu nu rho sigma}\n* in 4 dimensions\n\nIndices mu, nu, rho, sigma;\nDimension 4;\n\nLocal F = e_(mu, nu, rho, sigma) * e_(mu, nu, rho, sigma);\nContract;\nPrint F;\n.end", "category": "physics", "task_id": "2d465389ac", "form_stdout": "\nTime = 0.00 sec Generated terms = 1\n F Terms in output = 1\n Bytes used = 20\n\n F =\n 24;\n\n"}
{"instruction": "Write a FORM program that models the SU(3) trace identity Tr(T^a T^b T^c) = (1/4)*(d^abc + i f^abc) symbolically. FORM has no built-in structure constants, so model the symmetric and antisymmetric tensors explicitly: declare d and f as rank-3 CTensors, declare the symbol i and indices a, b, c, define F = (1/4)*(d(a,b,c) + i*f(a,b,c)), and print it.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "* Compute Tr(T^a T^b T^c) in SU(3) using the identity\n* Tr(T^a T^b T^c) = (1/4)(d^{abc} + i f^{abc})\n\nCTensor d, f;\nSymbol i;\nIndices a, b, c;\n\nLocal F = (1/4) * (d(a,b,c) + i * f(a,b,c));\nPrint F;\n.end", "category": "physics", "task_id": "e170393422", "form_stdout": "\nTime = 0.00 sec Generated terms = 2\n F Terms in output = 2\n Bytes used = 100\n\n F =\n 1/4*d(a,b,c) + 1/4*f(a,b,c)*i;\n\n", "changelog": "SPEC_BUG: 'compute the color factor ... using the FORM functions for the structure constants' is impossible \u2014 FORM has no built-in SU(3) functions. Restated as the symbolic modeling task the reference actually implements."}
{"instruction": "Define a function f(x) that returns x^2 + 3*x + 5. Then compute the expression E = f(a+b) - f(a) - f(b), where a and b are symbols. Expand E completely and collect terms with respect to the symbol a. Print the final result, showing the coefficient of each power of a.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,x;\nCFunction f;\nLocal E = f(a+b) - f(a) - f(b);\nid f(x?) = x^2 + 3*x + 5;\nBracket a;\nPrint;\n.end", "category": "docs_optional", "task_id": "52d1a111b2", "form_stdout": "\nTime = 0.00 sec Generated terms = 12\n E Terms in output = 2\n Bytes used = 92\n\n E =\n + a * ( 2*b )\n\n - 5;\n\n"}
{"instruction": "Consider the polynomial P(x) = (x-1)^5. Expand this polynomial completely. Then, for each term x^n, replace it with the product n*(n-1)*x^(n-2) (i.e., compute the second derivative). Print the resulting polynomial.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols x, n;\nLocal P = (x-1)^5;\nid x^n? = n*(n-1)*x^(n-2);\nPrint;\n.end\n", "category": "docs_optional", "task_id": "5905426834", "form_stdout": "FORM 5.0 (Apr 8 2025) Run: Sat Sep 19 21:23:03 2026\n Symbols x, n;\n Local P = (x-1)^5;\n id x^n? = n*(n-1)*x^(n-2);\n Print;\n .end\n\nTime = 0.00 sec Generated terms = 10\n P Terms in output = 4\n Bytes used = 100\n\n P =\n - 20 + 60*x - 60*x^2 + 20*x^3;\n\n 0.00 sec out of 0.00 sec\n"}
{"instruction": "Write a FORM program that defines two vectors p and q in 4-dimensional spacetime, and computes the quantity (p\u00b7q)^2 - p^2 * q^2. Use the FORM convention for dot products and declare the vectors appropriately. Print the result.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Vectors p,q;\nLocal F = (p.q)^2 - (p.p)*(q.q);\nPrint;\n.end", "category": "docs_optional", "task_id": "382f1cc058", "form_stdout": "\nTime = 0.00 sec Generated terms = 2\n F Terms in output = 2\n Bytes used = 88\n\n F =\n - p.p*q.q + p.q^2;\n\n"}
{"instruction": "Use FORM to expand the product (a + b)^4 * (c - d)^3. After expansion, collect terms with respect to the variable 'a' using the Bracket function. Finally, print the result. The final output should show the expression grouped by powers of 'a'.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "S a,b,c,d;\nL F = (a+b)^4*(c-d)^3;\nBracket a;\nPrint;\n.end", "category": "docs_optional", "task_id": "c7c13c9dc7", "form_stdout": "\nTime = 0.00 sec Generated terms = 20\n F Terms in output = 20\n Bytes used = 880\n\n F =\n + a * ( - 4*b^3*d^3 + 12*b^3*c*d^2 - 12*b^3*c^2*d + 4*b^3*c^3 )\n\n + a^2 * ( - 6*b^2*d^3 + 18*b^2*c*d^2 - 18*b^2*c^2*d + 6*b^2*c^3 )\n\n + a^3 * ( - 4*b*d^3 + 12*b*c*d^2 - 12*b*c^2*d + 4*b*c^3 )\n\n + a^4 * ( - d^3 + 3*c*d^2 - 3*c^2*d + c^3 )\n\n - b^4*d^3 + 3*b^4*c*d^2 - 3*b^4*c^2*d + b^4*c^3;\n\n"}
{"instruction": "Create a FORM program that defines a polynomial in three variables x, y, z with at least five terms of your choice (e.g., x^2*y + 3*x*z^2 - 2*y^2*z + x*y*z + 5). Then apply the substitutions x -> a + b and y -> c - d, where a, b, c, d are new symbols. Expand the result and group it by powers of the variable a using the Bracket statement (FORM's collect-with-respect-to-variable idiom). Print the bracketed result.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "* Define a polynomial and apply substitutions, then collect in 'a'\nSymbols x, y, z, a, b, c, d;\nL F = x^2*y + 3*x*z^2 - 2*y^2*z + x*y*z + 5;\nid x = a + b;\nid y = c - d;\nB a;\nPrint;\n.end", "category": "docs_optional", "task_id": "24016e2092", "form_stdout": "\nTime = 0.00 sec Generated terms = 16\n F Terms in output = 16\n Bytes used = 616\n\n F =\n + a * ( - 2*b*d + 2*b*c - z*d + z*c + 3*z^2 )\n\n + a^2 * ( - d + c )\n\n + 5 - b^2*d + b^2*c - 2*z*d^2 + 4*z*c*d - 2*z*c^2 - z*b*d + z*b*c + 3*\n z^2*b;\n\n", "changelog": "SPEC_BUG: instruction named the 'Collect' statement; FORM's Collect takes function names as arguments (Collect f1,f2;), not a symbol \u2014 'Collect a;' is a syntax error (verified). Restated as Bracket a, which is the correct FORM idiom the reference already uses."}
{"instruction": "Write a FORM program that computes the sum of all products of three distinct elements chosen from a set {a, b, c, d}, where each product is formed by multiplying the three elements together. Use a #do loop structure to generate all combinations and sum them. The final result should be printed as a single expression.", "docs": "# FORM Syntax Quick Guide\n\nA quick reference for identifying valid FORM code and writing accurate\nnatural language instructions. FORM (Symbolic Manipulation System) is a\ndomain-specific language for high-performance symbolic algebra, primarily\nused in particle physics.\n\n## Program Structure\n\nA FORM program consists of:\n1. **Preprocessor directives** (lines starting with `#`)\n2. **Declarations** (Symbol, Vector, Index, Function, etc.)\n3. **Expression definitions** (Local, Global)\n4. **Execution statements** (id, multiply, print, etc.)\n5. **Module separators** (`.sort`, `.end`, `.global`)\n\nA minimal FORM program:\n\n```form\n#-\n* This is a comment (starts with * or #-)\nSymbols a, b;\nLocal E = (a + b)^2;\nPrint +f;\n.end\n```\n\n## Key Syntax Elements\n\n### Comments\n- `*` \u2014 single-line comment (rest of line ignored)\n- `#-` \u2014 start of a comment block / preprocessor comment\n- `#+` \u2014 end of preprocessor comment block\n\n### Declarations\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Symbol` / `Symbols` | Declare scalar symbols | `Symbols a, b, c;` |\n| `Vector` / `Vectors` | Declare Lorentz vectors | `Vectors p, q, k;` |\n| `Index` / `Indices` | Declare indices | `Indices mu, nu, rho;` |\n| `Function` / `Functions` | Declare functions | `Functions f, g, h;` |\n| `CTensor` | Declare commuting tensor | `CTensor T;` |\n| `NTensor` | Declare non-commuting tensor | `NTensor g_(1);` |\n| `Set` | Declare a set of symbols | `Set indices: mu, nu, rho, sig;` |\n| `Table` | Declare a lookup table | `Table tab(3);` |\n| `Dimension` | Set spacetime dimension | `Dimension 4;` |\n\n### Expression Definitions\n| Keyword | Purpose | Example |\n|---------|---------|---------|\n| `Local` | Define a local expression (cleared after module) | `Local E = a + b;` |\n| `Global` | Define a global expression (persists) | `Global G = a * b;` |\n\n### Execution Statements\n| Statement | Purpose | Example |\n|-----------|---------|---------|\n| `id` | Substitute / pattern match | `id a = b;` |\n| `multiply` | Multiply expression by factor | `multiply 2;` |\n| `print` / `Print` | Print expression | `Print +f;` |\n| `Format` | Set output format | `Format 80;` |\n| `sort` | Force sorting | `sort;` |\n| `sum` | Sum over a dimension | `sum mu;` |\n| `trace4` / `Trace4` | Take 4D trace | `Trace4, 1;` |\n| `contract` | Contract indices with metric | `contract 0;` |\n| `antibracket` | Extract coefficient | `antibracket x;` |\n| `collect` | Collect terms | `collect f;` |\n\n### Module Separators\n| Separator | Purpose |\n|-----------|---------|\n| `.sort` | End module, sort and garbage collect, continue |\n| `.end` | End program |\n| `.global` | End module, make expressions global |\n| `.clear` | End module, clear all expressions |\n\n### Preprocessor Directives\n| Directive | Purpose | Example |\n|-----------|---------|---------|\n| `#-` | Comment block start | `#- This is a comment` |\n| `#+` | Comment block end | |\n| `#do` | Loop | `#do i = 1, 4` |\n| `#enddo` | End loop | |\n| `#if` | Conditional | `#if ( `i' > 2 )` |\n| `#else` | Else branch | |\n| `#endif` | End conditional | |\n| `#procedure` | Define procedure | `#procedure myproc()` |\n| `#endprocedure` | End procedure | |\n| `#call` | Call procedure | `#call myproc()` |\n| `#include` | Include file | `#include foo.h` |\n| `#define` | Define preprocessor variable | `#define N \"4\"` |\n| `#message` | Print message | `#message \"Hello\"` |\n\n### Gamma Matrix Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `g_(1, mu)` | Gamma matrix \u03b3_\u03bc with spinor line 1 |\n| `g_(1, mu, nu)` | Product g_\u03bc g_\u03bd |\n| `g_(1, 5)` | \u03b3\u2085 |\n| `Trace4, 1` | Take 4D trace over spinor line 1 |\n| `TraceN, 1` | Take N-dimensional trace |\n| `gi_(1)` | Identity matrix for spinor line 1 |\n\n### Color Algebra\n| Construct | Meaning |\n|-----------|---------|\n| `f_(mu, nu, rho)` | SU(N) structure constant f^{\u03bc\u03bd\u03c1} |\n| `d_(mu, nu, rho)` | SU(N) symmetric d^{\u03bc\u03bd\u03c1} |\n| `T_(a, mu, nu)` | Generator T^a_{\u03bc\u03bd} |\n| `d_(mu, nu)` | Kronecker delta \u03b4_{\u03bc\u03bd} (color) |\n\n### Special Variables\n| Variable | Meaning |\n|----------|---------|\n| `i_` | Imaginary unit |\n| `pi_` | \u03c0 |\n| `nl_` | Number of terms in expression |\n\n## Identifying FORM Code\n\nA code block is likely FORM if it contains ANY of:\n- `Symbols`, `Vectors`, `Indices`, `Functions` declarations\n- `Local` or `Global` expression definitions\n- `id` statements with `=` and `;`\n- `.sort`, `.end`, `.global` module separators\n- `g_(` gamma matrix notation\n- `#do`, `#procedure`, `#call` preprocessor directives\n- `Trace4`, `TraceN` trace operations\n- `print` or `Print` followed by `+f` or `-f`\n\nA code block is NOT FORM if it contains:\n- `#include <stdio.h>` (C code)\n- `program foo` or `implicit none` (Fortran)\n- `$ form program.frm` (shell command)\n- `def function()` (Python)\n- Lines starting with `$` or `>` (shell prompts)\n\n## Writing Instructions\n\nWhen writing natural language instructions for FORM programs:\n\n1. **Describe the physics/math goal**, not the syntax\n - \"Compute the trace of gamma matrices\" not \"Use Trace4 on g_\"\n - \"Expand a polynomial\" not \"Apply the ^ operator and Print +f\"\n\n2. **Mention key mathematical objects by their physics name**\n - \"gamma matrices\" (not \"g_ tensors\")\n - \"Lorentz index contraction\" (not \"sum over mu with g_(mu,mu)\")\n - \"SU(3) color factor\" (not \"f_ and d_ tensors\")\n\n3. **Include constraints when relevant**\n - \"in 4 dimensions\"\n - \"using the Chisholm identity\"\n - \"for a scalar field theory\"\n - \"with N = 3 colors\"", "code": "Symbols a,b,c,d,dummy;\nOff Statistics;\nLocal F = dummy;\n#do i = 1, 4\n #do j = 1, 4\n #do k = 1, 4\n #if ( `i' < `j' ) && ( `j' < `k' )\n #if ( `i' == 1 ) && ( `j' == 2 ) && ( `k' == 3 )\n id dummy = dummy + a*b*c;\n #endif\n #if ( `i' == 1 ) && ( `j' == 2 ) && ( `k' == 4 )\n id dummy = dummy + a*b*d;\n #endif\n #if ( `i' == 1 ) && ( `j' == 3 ) && ( `k' == 4 )\n id dummy = dummy + a*c*d;\n #endif\n #if ( `i' == 2 ) && ( `j' == 3 ) && ( `k' == 4 )\n id dummy = dummy + b*c*d;\n #endif\n #endif\n #enddo\n #enddo\n#enddo\nid dummy = 0;\nPrint F;\n.end", "category": "docs_optional", "task_id": "11035b9cbf", "form_stdout": "\n F =\n b*c*d + a*c*d + a*b*d + a*b*c;\n\n", "changelog": "REF_BUG: same as task 13 \u2014 #if needs backtick-quoted loop vars, and 'Local F = F + ...' redefines instead of accumulating. Fixed with backtick-quoted conditions and dummy-symbol accumulation."}