{"id":13803906,"url":"https://github.com/math-comp/algebra-tactics","last_synced_at":"2025-07-10T03:32:25.335Z","repository":{"id":41508803,"uuid":"364861583","full_name":"math-comp/algebra-tactics","owner":"math-comp","description":"Ring, field, lra, nra, and psatz tactics for Mathematical Components","archived":false,"fork":false,"pushed_at":"2025-05-09T07:27:08.000Z","size":299,"stargazers_count":33,"open_issues_count":15,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-09T08:32:56.264Z","etag":null,"topics":["coq","elpi","mathcomp","proof-automation","ssreflect"],"latest_commit_sha":null,"homepage":"","language":"Coq","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/math-comp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-06T09:49:29.000Z","updated_at":"2025-05-09T07:24:58.000Z","dependencies_parsed_at":"2023-10-17T00:09:12.360Z","dependency_job_id":"ec93fb89-e084-4036-b59b-45b1d7a96ad2","html_url":"https://github.com/math-comp/algebra-tactics","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/math-comp/algebra-tactics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-comp%2Falgebra-tactics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-comp%2Falgebra-tactics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-comp%2Falgebra-tactics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-comp%2Falgebra-tactics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/math-comp","download_url":"https://codeload.github.com/math-comp/algebra-tactics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-comp%2Falgebra-tactics/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264521666,"owners_count":23622185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coq","elpi","mathcomp","proof-automation","ssreflect"],"created_at":"2024-08-04T01:00:38.987Z","updated_at":"2025-07-10T03:32:20.323Z","avatar_url":"https://github.com/math-comp.png","language":"Coq","funding_links":[],"categories":["Projects","Coq"],"sub_categories":["Libraries"],"readme":"\u003c!---\nThis file was generated from `meta.yml`, please do not edit manually.\nFollow the instructions on https://github.com/coq-community/templates to regenerate.\n---\u003e\n# Algebra Tactics\n\n[![Docker CI][docker-action-shield]][docker-action-link]\n\n[docker-action-shield]: https://github.com/math-comp/algebra-tactics/actions/workflows/docker-action.yml/badge.svg?branch=master\n[docker-action-link]: https://github.com/math-comp/algebra-tactics/actions/workflows/docker-action.yml\n\n\n\n\nThis library provides `ring`, `field`, `lra`, `nra`, and `psatz` tactics for\nthe Mathematical Components library. These tactics use the algebraic\nstructures defined in the MathComp library and their canonical instances for\nthe instance resolution, and do not require any special instance declaration,\nlike the `Add Ring` and `Add Field` commands. Therefore, each of these tactics\nworks with any instance of the respective structure, including concrete\ninstances declared through Hierarchy Builder, abstract instances, and mixed\nconcrete and abstract instances, e.g., `int * R` where `R` is an abstract\ncommutative ring. Another key feature of Algebra Tactics is that they\nautomatically push down ring morphisms and additive functions to leaves of\nring/field expressions before applying the proof procedures.\n\n## Meta\n\n- Author(s):\n  - Kazuhiko Sakaguchi (initial)\n  - Pierre Roux\n- License: [CeCILL-B Free Software License Agreement](CeCILL-B)\n- Compatible Coq versions: 8.16 or later\n- Additional dependencies:\n  - [MathComp](https://math-comp.github.io) ssreflect 2.0 or later\n  - [MathComp](https://math-comp.github.io) algebra\n  - [Mczify](https://github.com/math-comp/mczify) 1.5.0 or later\n  - [Coq-Elpi](https://github.com/LPCIC/coq-elpi) 1.15.0 or later (known not to work with 1.17.0)\n- Coq namespace: `mathcomp.algebra_tactics`\n- Related publication(s):\n  - [Reflexive tactics for algebra, revisited](https://drops.dagstuhl.de/opus/volltexte/2022/16738/) doi:[10.4230/LIPIcs.ITP.2022.29](https://doi.org/10.4230/LIPIcs.ITP.2022.29)\n\n## Building and installation instructions\n\nThe easiest way to install the latest released version of Algebra Tactics\nis via [OPAM](https://opam.ocaml.org/doc/Install.html):\n\n```shell\nopam repo add coq-released https://coq.inria.fr/opam/released\nopam install coq-mathcomp-algebra-tactics\n```\n\nTo instead build and install manually, do:\n\n``` shell\ngit clone https://github.com/math-comp/algebra-tactics.git\ncd algebra-tactics\nmake   # or make -j \u003cnumber-of-cores-on-your-machine\u003e \nmake install\n```\n\n\n\n## Documentation\n\n**Caveat: the `lra`, `nra`, and `psatz` tactics are considered experimental\nfeatures and subject to change.**\n\nThis Coq library provides an adaptation of the\n[`ring`, `field`](https://coq.inria.fr/refman/addendum/ring),\n[`lra`, `nra`, and `psatz`](https://coq.inria.fr/refman/addendum/micromega)\ntactics to the MathComp library.\nSee the Coq reference manual for the basic functionalities of these tactics.\nThe descriptions of these tactics below mainly focus on the differences\nbetween ones provided by Coq and ones provided by this library, including the\nadditional features introduced by this library.\n\n### The `ring` tactic\n\nThe `ring` tactic solves a goal of the form `p = q :\u003e R` representing a\npolynomial equation. The type `R` must have a canonical `comRingType`\n(commutative ring) or at least `comSemiRingType` (commutative semiring)\ninstance.\nThe `ring` tactic solves the equation by normalizing each side as a\npolynomial, whose coefficients are either integers `Z` (if `R` is a\n`comRingType`) or natural numbers `N`.\n\nThe `ring` tactic can decide the given polynomial equation modulo given\nmonomial equations. The syntax to use this feature is `ring: t_1 .. t_n` where\neach `t_i` is a proof of equality `m_i = p_i`, `m_i` is a monomial, and `p_i`\nis a polynomial.\nAlthough the `ring` tactic supports ring homomorphisms (explained below), all\nthe monomials and polynomials `m_1, .., m_n, p_1, .., p_n, p, q` must have the\nsame type `R` for the moment.\n\nEach tactic provided by this library has a preprocessor and supports\napplications of (semi)ring homomorphisms and additive functions (N-module or\nZ-module homomorphisms).\nFor example, suppose `f : S -\u003e T` and `g : R -\u003e S` are ring homomorphisms. The\npreprocessor turns a ring sub-expression of the form `f (x + g (y * z))` into\n`f x + f (g y) * f (g z)`.\nA composition of homomorphisms from the initial objects `nat`, `N`, `int`, and\n`Z` is automatically normalized to the canonical one. For example, if `R` in\nthe above example is `int`, the result of the preprocessing should be\n`f x + y%:~R * z%:~R` where `f \\o g : int -\u003e T` is replaced with `intr`\n(`_%:~R`).\nThanks to the preprocessor, the `ring` tactic supports the following\nconstructs apart from homomorphism applications:\n- `GRing.zero` (`0%R`),\n- `GRing.add` (`+%R`),\n- `addn`,\n- `N.add`,\n- `Z.add`,\n- `GRing.natmul`,\n- `GRing.opp` (`-%R`),\n- `Z.opp`,\n- `Z.sub`,\n- `intmul`,\n- `GRing.one` (`1%R`),\n- `GRing.mul` (`*%R`),\n- `muln`,\n- `N.mul`,\n- `Z.mul`,\n- `GRing.exp`,[^constant_exponent]\n- `exprz`,[^constant_exponent]\n- `expn`,[^constant_exponent]\n- `N.pow`,[^constant_exponent]\n- `Z.pow`,[^constant_exponent]\n- `S`,\n- `Posz`,\n- `Negz`, and\n- constants of type `nat`, `N`, or `Z`.\n\n[^constant_exponent]: The exponent must be a constant value. In addition, it\nmust be non-negative for `exprz`.\n\n### The `field` tactic\n\nThe `field` tactic solves a goal of the form `p = q :\u003e F` representing a\nrational equation. The type `F` must have a canonical `fieldType` (field)\ninstance.\nThe `field` tactic solves the equation by normalizing each side to a pair of\ntwo polynomials representing a fraction, whose coefficients are integers `Z`.\nAs is the case for the `ring` tactic, the `field` tactic can decide the given\nrational equation modulo given monomial equations. The syntax to use this\nfeature is the same as the `ring` tactic: `field: t_1 .. t_n`.\n\nThe `field` tactic generates proof obligations that all the denominators in\nthe equation are not zero.\nA proof obligation of the form `p * q != 0 :\u003e F` is always automatically\nreduced to `p != 0 /\\ q != 0`.\nIf the field `F` is a `numFieldType` (partially ordered field), a proof\nobligation of the form `c%:~R != 0 :\u003e F` where `c` is a non-zero integer\nconstant is automatically resolved.\n\nThe `field` tactic has a preprocessor similar to the `ring` tactic.\nIn addition to the constructs supported by the `ring` tactic, the `field`\ntactic supports `GRing.inv` and `exprz` with a negative exponent.\n\n### The `lra`, `nra`, and `psatz` tactics\n\nThe `lra` tactic is a decision procedure for linear real arithmetic. The `nra`\nand `psatz` tactics are incomplete proof procedures for non-linear real\narithmetic.\nThe carrier type must have a canonical `realDomainType` (totally ordered\nintegral domain) or `realFieldType` (totally ordered field) instance.\nThe multiplicative inverse is supported only if the carrier type is a\n`realFieldType`.\n\nIf the carrier type is not a `realFieldType` but a `realDomainType`, these\nthree tactics use the same preprocessor as the `ring` tactic.\nIf the carrier type is a `realFieldType`, these tactics support `GRing.inv`\nand `exprz` with a negative exponent.\nIn contrast to the `field` tactic, these tactics push down the multiplicative\ninverse through multiplication and exponentiation, e.g., turning `(x * y)^-1`\ninto `x^-1 * y^-1`.\n\n## Files\n\n- `theories/`\n  - `common.v`: provides the reflexive preprocessors (syntax, interpretation\n    function, and normalization functions),\n  - `common.elpi`: provides the reification procedure for (semi)ring and\n    module expressions, except for the case that the carrier type is a\n    `realFieldType` in the `lra`, `nra`, and `psatz` tactics,\n  - `ring.v`: provides the Coq code specific to the `ring` and `field`\n    tactics, including the reflection lemmas,\n  - `ring.elpi`: provides the Elpi code specific to the `ring` and `field`\n    tactics,\n  - `ring_tac.elpi`: provides the entry point for the `ring` tactic,\n  - `field_tac.elpi`: provides the entry point for the `field` tactic,\n  - `lra.v`: provides the Coq code specific to the `lra`, `nra`, and `psatz`\n    tactics, including the reflection lemmas,\n  - `lra.elpi`: provides the Elpi code specific to the `lra`, `nra`, and\n    `psatz` tactics, including the reification procedure and the entry point.\n\n## Credits\n\n- The adaptation of the `lra`, `nra`, and `psatz` tactics is contributed by\n  Pierre Roux.\n- The way we adapt the internal lemmas of Coq's `ring` and `field` tactics to\n  algebraic structures of the Mathematical Components library is inspired by\n  the [elliptic-curves-ssr](https://github.com/strub/elliptic-curves-ssr)\n  library by Evmorfia-Iro Bartzia and Pierre-Yves Strub.\n- The example [`from_sander.v`](examples/from_sander.v) contributed by Assia\n  Mahboubi was given to her by [Sander Dahmen](http://www.few.vu.nl/~sdn249/).\n  It is related to a computational proof that elliptic curves are endowed with\n  a group law.\n  As [suggested](https://hal.inria.fr/inria-00129237v4/document) by Laurent\n  Théry a while ago, this problem is a good benchmark for proof systems.\n  Laurent Théry and Guillaume Hanrot [formally\n  verified](https://doi.org/10.1007/978-3-540-74591-4_24) this property in Coq\n  in 2007.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath-comp%2Falgebra-tactics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmath-comp%2Falgebra-tactics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath-comp%2Falgebra-tactics/lists"}