{"id":16312091,"url":"https://github.com/zimmi48/transfer","last_synced_at":"2025-10-25T16:31:13.914Z","repository":{"id":31240887,"uuid":"34802317","full_name":"Zimmi48/transfer","owner":"Zimmi48","description":"Automatic transfer of theorems along isomorphisms in Coq","archived":false,"fork":false,"pushed_at":"2021-07-27T18:06:24.000Z","size":427,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-16T10:26:48.563Z","etag":null,"topics":["coq","coq-tactic","library"],"latest_commit_sha":null,"homepage":null,"language":"Coq","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zimmi48.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-29T15:35:03.000Z","updated_at":"2021-07-27T18:06:27.000Z","dependencies_parsed_at":"2022-09-04T13:11:37.435Z","dependency_job_id":null,"html_url":"https://github.com/Zimmi48/transfer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zimmi48%2Ftransfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zimmi48%2Ftransfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zimmi48%2Ftransfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zimmi48%2Ftransfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zimmi48","download_url":"https://codeload.github.com/Zimmi48/transfer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238174221,"owners_count":19428646,"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","coq-tactic","library"],"created_at":"2024-10-10T21:46:45.001Z","updated_at":"2025-10-25T16:31:13.603Z","avatar_url":"https://github.com/Zimmi48.png","language":"Coq","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transfer library for Coq\n\n⚠️ **This library is not maintained.** ⚠️\nThe most similar tool available for Coq is probably the [CoqEAL library](https://github.com/CoqEAL/CoqEAL) refinements module.\n\nThe most up-to-date documentation for this library is [the presentation\nI made at the Deducteam seminar\n(April, 2017)](http://www.theozimmermann.net/transfer/deducteam-seminar/)\n(whose sources you can find in the *slides-deducteam* branch of this\nrepository). The README below hasn't been updated for a longer period.\n\nThis library helps you working seamlessly with several representations\nfor the same objects, switching from one to another when doing proofs\nand easily transferring theorems across representations.\n\nA typical workflow would be the following:\n- You define two new types and a few functions on them.\n- You relate the two types and their functions by adequate transfer\ndeclarations.\n- You prove your theorems only once (on the most suited representation)\nand if you need to use them on the other representation, instead of\ndoing ``exact my_thm``, you do ``exactm my_thm`` and the library\ntakes care of the transfer.\n- Similarly, you can use ``applym my_thm`` instead of ``apply my_thm``\nbut it is not guaranteed to work with any type of theorem.\n- Finally, if you have defined your transfer rules properly, you may\nalso be able to change your current proof goal from one representation\nto the other by doing ``transfer`` (this may not work well if you\nhave more than two related representations). This way of using the\ntransfer library was inspired by Isabelle's ``transfer'`` tactic.\n\n## Transfer declarations\n\nFirst, you need to define a relation between the two types you\nare considering:\n``R : A -\u003e B -\u003e Prop``.\nIf you are given a function from one type to the other, say ``f : A -\u003e B``,\nyou may define ``R x y := f x = y``.\n\nThen you need to declare properties of this relation, such as injectivity\n(right-uniqueness), functionality (left-uniqueness), surjectivity\n(right-totality) and (left-)totality.\n\nThe corresponding declarations should look like this:\n\n```coq\nInstance injectivity_of_R : Related (R ##\u003e R ##\u003e flip impl) (@eq A) (@eq B).\n\nInstance functionality_of_R : Related (R ##\u003e R ##\u003e impl) (@eq A) (@eq B).\n\nInstance surjectivity_of_R : Related ((R ##\u003e impl) ##\u003e impl) (@all A) (@all B).\n\nInstance totality_of_R : Related ((R ##\u003e flip impl) ##\u003e flip impl) (@all A) (@all B).\n```\n\n[Respectful.v](Respectful.v) contains theorems relating these kinds of declarations\nto more familiar statements.\n\nIf some of these properties are not true for relation ``R``, it may be possible to\nprove variants, for instance replacing equality with another equivalence\nor universal quantification with some bounded quantification.\n\nIf all these properties are true, then they can be expressed in a simpler way in only\ntwo properties:\n\n```coq\nInstance bitotal_R : Related ((R ##\u003e iff) ##\u003e iff) (@all A) (@all B).\n\nInstance biunique_R : Related (R ##\u003e R ##\u003e iff) (@eq A) (@eq B).\n```\n\n### Compatibility with functions and relations\n\nHere are some examples of such declarations:\n\n```coq\nInstance compat_with_binary_op : Related (R ##\u003e R ##\u003e R) bin_op_A bin_op_B.\n\nInstance compat_with_internal_function : Related (R ##\u003e R) fun_A fun_B.\n\nInstance compat_with_external_function : Related (R ##\u003e eq) fun_from_A fun_from_B.\n\nInstance compat_with_binary_relation_one_way : Related (R ##\u003e R ##\u003e impl) bin_rel_A bin_rel_B.\n\nInstance compat_with_binary_relation_other_way : Related (R ##\u003e R ##\u003e flip impl) bin_rel_A bin_rel_B.\n```\n\nNB: for now, all these declarations will be good only for transferring\ntheorems from ``A`` to ``B``. If you need to go both ways, you should\nadd the corresponding reversed declarations, even when they are equivalent.\nFor instance:\n\n```coq\nInstance compat_with_binary_op' : Related (flip R ##\u003e flip R ##\u003e flip R) bin_op_B bin_op_A.\n```\n\n## Usage of the library\n\n### Transfer of theorems\n\nYou can see examples of transferred theorems in [NArithTests.v](NArithTests.v).\nWhen two theorems have the same form but for related objects (in particular, quantification is\non two different types), you can prove only one of them and use\n``exactm my_proved_thm`` to get a proof of the other.\nThis will unify the current goal with ``my_proved_thm`` modulo some known relations\n(previously declared as instances of ``Related``).\n\n## Change of representation\n\n``modulo`` is a very general theorem:\n\n```coq\nmodulo : ?t -\u003e ?u\nwhere\n?t : [ |- Prop]\n?u : [ |- Prop]\n?class : [ |- Related impl ?t ?u]\n```\n\nBy calling it through `exactm thm` which is just sugar for `exact (modulo thm)`\nyou are providing it with the values\nof ``?t`` and ``?u`` and it just has to infer a proof of ``Related impl ?t ?u``\nfrom the known ``Related`` instances.\nAnother use however is to call `transfer` (just sugar for `apply modulo`)\ninside a proof development, thus\nproviding ``?u`` but not ``?t``. In some cases, it will be able to also infer\nthe value of ``?t`` and leave you with a transformed goal, thus effectively\noperating a change of representation.\nSince it is a more complicated task, it might also fail, or leave you a transformed\ngoal which does not correspond to what you wanted (in particular when your type\nis related to several other types).\n\nHere is an example of how it can be used to go beyond `exactm thm)`:\n\n```coq\nRequire Import NArithTransfer.\n\nGoal forall x1 y1 z1 : N, x1 = y1 -\u003e N.add x1 z1 = N.add y1 z1.\nProof.\n  transfer. (* Now the goal is: forall x x0 x1 : nat, x = x0 -\u003e x + x1 = x0 + x1 *)\n  intros.\n  Check f_equal2_plus. (* f_equal2_plus : forall x1 y1 x2 y2 : nat, x1 = y1 -\u003e x2 = y2 -\u003e x1 + x2 = y1 + y2 *)\n  apply f_equal2_plus; trivial.\nQed.\n```\n\nThere is an implementation problem which makes it difficult handling theorems\nwhere there is no implication under the quantifiers. To work around this\nlimitation, it may be useful to insert dummy hypotheses as in the following example:\n```coq\nRequire Import NArithTransfer.\n\n(** ** Basic specifications : pred add sub mul *)\n\nGoal forall n, N.pred (N.succ n) = n.\nProof.\n  enough (forall n, True -\u003e N.pred (N.succ n) = n) by firstorder. (* Adding dummy hypothesis *)\n  trasnfer. (* Now the goal is: forall n : nat, True -\u003e Nat.pred (S n) = n *)\n  intros n _.\n  apply PeanoNat.Nat.pred_succ.\nQed.\n```\n\n# Bibliography\n\n* Zimmermann T. and Herbelin H.\n*Automatic and Transparent Transfer of Theorems along Isomorphisms in the Coq Proof Assistant.*\nPresented at CICM 2015 (work-in-progress track).\nRead it\non [HAL](https://hal.archives-ouvertes.fr/hal-01152588)\nor on [arXiv](http://arxiv.org/abs/1505.05028).\n\nNB: you can find the *plugin* described in this paper in the *plugin* branch of this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimmi48%2Ftransfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzimmi48%2Ftransfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzimmi48%2Ftransfer/lists"}