├── .github
└── workflows
│ └── docker-action.yml
├── .gitignore
├── LICENSE
├── Makefile
├── Makefile.coq.local
├── README.md
├── TODO.txt
├── _CoqProject
├── coq-atbr.opam
├── dune-project
├── meta.yml
├── resources
├── config.js
├── coqdoc.css
├── coqdocjs.css
├── coqdocjs.js
├── footer.html
├── header.html
├── index.html
└── index.md
├── src
├── dune
├── reification.mlg
├── reification_plugin.mlpack
└── reify.ml
└── theories
├── ATBR.v
├── ATBR_Matrices.v
├── BoolView.v
├── ChurchRosser.v
├── ChurchRosser_Points_vs_Algebraic.v
├── Classes.v
├── Common.v
├── Converse.v
├── DKA_CheckLabels.v
├── DKA_Construction.v
├── DKA_DFA_Equiv.v
├── DKA_DFA_Language.v
├── DKA_Definitions.v
├── DKA_Determinisation.v
├── DKA_Epsilon.v
├── DKA_Merge.v
├── DKA_StateSetSets.v
├── DecideKleeneAlgebra.v
├── DisjointSets.v
├── Examples.v
├── Force.v
├── Functors.v
├── Graph.v
├── KleeneAlgebra.v
├── Model_Languages.v
├── Model_MinPlus.v
├── Model_RegExp.v
├── Model_Relations.v
├── Model_StdRelations.v
├── Monoid.v
├── MxFunctors.v
├── MxGraph.v
├── MxKleeneAlgebra.v
├── MxSemiLattice.v
├── MxSemiRing.v
├── MyFMapProperties.v
├── MyFSetProperties.v
├── MyFSets.v
├── Numbers.v
├── Reification.v
├── SemiLattice.v
├── SemiRing.v
├── StrictKleeneAlgebra.v
├── StrictStarForm.v
├── Utils_WF.v
└── dune
/.github/workflows/docker-action.yml:
--------------------------------------------------------------------------------
1 | name: Docker CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | paths-ignore:
8 | - 'resources/**'
9 | pull_request:
10 | branches:
11 | - '**'
12 | paths-ignore:
13 | - 'resources/**'
14 |
15 | jobs:
16 | build:
17 | # the OS must be GNU/Linux to be able to use the docker-coq-action
18 | runs-on: ubuntu-latest
19 | strategy:
20 | matrix:
21 | image:
22 | - 'coqorg/coq:dev'
23 | fail-fast: false
24 | steps:
25 | - uses: actions/checkout@v3
26 | - uses: coq-community/docker-coq-action@v1
27 | with:
28 | opam_file: 'coq-atbr.opam'
29 | custom_image: ${{ matrix.image }}
30 |
31 |
32 | # See also:
33 | # https://github.com/coq-community/docker-coq-action#readme
34 | # https://github.com/erikmd/docker-coq-github-action-demo
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # build output
2 | _build
3 | docs
4 | *.aux
5 | *.vo
6 | *.glob
7 | *.d
8 | *.vos
9 | *.vok
10 | .lia.cache
11 |
12 | # make-related output
13 | Makefile.coq
14 | Makefile.coq.conf
15 |
16 | # reification plugin
17 | *.cmi
18 | *.cmx
19 | *.cmxs
20 | *.o
21 | *.a
22 | *.cmxa
23 | *.cmt
24 | src/reification.ml
25 | src/.merlin
26 | src/META.coq-atbr
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The ATBR library is free software: you can redistribute it and/or
2 | modify it under the terms of the GNU Lesser General Public License as
3 | published by the Free Software Foundation, either version 3 of the
4 | License, or (at your option) any later version.
5 |
6 | This library is distributed in the hope that it will be useful, but
7 | WITHOUT ANY WARRANTY; without even the implied warranty of
8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 | Lesser General Public License for more details.
10 |
11 | GNU LESSER GENERAL PUBLIC LICENSE
12 | Version 3, 29 June 2007
13 |
14 | Copyright (C) 2007 Free Software Foundation, Inc.
15 | Everyone is permitted to copy and distribute verbatim copies
16 | of this license document, but changing it is not allowed.
17 |
18 |
19 | This version of the GNU Lesser General Public License incorporates
20 | the terms and conditions of version 3 of the GNU General Public
21 | License, supplemented by the additional permissions listed below.
22 |
23 | 0. Additional Definitions.
24 |
25 | As used herein, "this License" refers to version 3 of the GNU Lesser
26 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
27 | General Public License.
28 |
29 | "The Library" refers to a covered work governed by this License,
30 | other than an Application or a Combined Work as defined below.
31 |
32 | An "Application" is any work that makes use of an interface provided
33 | by the Library, but which is not otherwise based on the Library.
34 | Defining a subclass of a class defined by the Library is deemed a mode
35 | of using an interface provided by the Library.
36 |
37 | A "Combined Work" is a work produced by combining or linking an
38 | Application with the Library. The particular version of the Library
39 | with which the Combined Work was made is also called the "Linked
40 | Version".
41 |
42 | The "Minimal Corresponding Source" for a Combined Work means the
43 | Corresponding Source for the Combined Work, excluding any source code
44 | for portions of the Combined Work that, considered in isolation, are
45 | based on the Application, and not on the Linked Version.
46 |
47 | The "Corresponding Application Code" for a Combined Work means the
48 | object code and/or source code for the Application, including any data
49 | and utility programs needed for reproducing the Combined Work from the
50 | Application, but excluding the System Libraries of the Combined Work.
51 |
52 | 1. Exception to Section 3 of the GNU GPL.
53 |
54 | You may convey a covered work under sections 3 and 4 of this License
55 | without being bound by section 3 of the GNU GPL.
56 |
57 | 2. Conveying Modified Versions.
58 |
59 | If you modify a copy of the Library, and, in your modifications, a
60 | facility refers to a function or data to be supplied by an Application
61 | that uses the facility (other than as an argument passed when the
62 | facility is invoked), then you may convey a copy of the modified
63 | version:
64 |
65 | a) under this License, provided that you make a good faith effort to
66 | ensure that, in the event an Application does not supply the
67 | function or data, the facility still operates, and performs
68 | whatever part of its purpose remains meaningful, or
69 |
70 | b) under the GNU GPL, with none of the additional permissions of
71 | this License applicable to that copy.
72 |
73 | 3. Object Code Incorporating Material from Library Header Files.
74 |
75 | The object code form of an Application may incorporate material from
76 | a header file that is part of the Library. You may convey such object
77 | code under terms of your choice, provided that, if the incorporated
78 | material is not limited to numerical parameters, data structure
79 | layouts and accessors, or small macros, inline functions and templates
80 | (ten or fewer lines in length), you do both of the following:
81 |
82 | a) Give prominent notice with each copy of the object code that the
83 | Library is used in it and that the Library and its use are
84 | covered by this License.
85 |
86 | b) Accompany the object code with a copy of the GNU GPL and this license
87 | document.
88 |
89 | 4. Combined Works.
90 |
91 | You may convey a Combined Work under terms of your choice that,
92 | taken together, effectively do not restrict modification of the
93 | portions of the Library contained in the Combined Work and reverse
94 | engineering for debugging such modifications, if you also do each of
95 | the following:
96 |
97 | a) Give prominent notice with each copy of the Combined Work that
98 | the Library is used in it and that the Library and its use are
99 | covered by this License.
100 |
101 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
102 | document.
103 |
104 | c) For a Combined Work that displays copyright notices during
105 | execution, include the copyright notice for the Library among
106 | these notices, as well as a reference directing the user to the
107 | copies of the GNU GPL and this license document.
108 |
109 | d) Do one of the following:
110 |
111 | 0) Convey the Minimal Corresponding Source under the terms of this
112 | License, and the Corresponding Application Code in a form
113 | suitable for, and under terms that permit, the user to
114 | recombine or relink the Application with a modified version of
115 | the Linked Version to produce a modified Combined Work, in the
116 | manner specified by section 6 of the GNU GPL for conveying
117 | Corresponding Source.
118 |
119 | 1) Use a suitable shared library mechanism for linking with the
120 | Library. A suitable mechanism is one that (a) uses at run time
121 | a copy of the Library already present on the user's computer
122 | system, and (b) will operate properly with a modified version
123 | of the Library that is interface-compatible with the Linked
124 | Version.
125 |
126 | e) Provide Installation Information, but only if you would otherwise
127 | be required to provide such information under section 6 of the
128 | GNU GPL, and only to the extent that such information is
129 | necessary to install and execute a modified version of the
130 | Combined Work produced by recombining or relinking the
131 | Application with a modified version of the Linked Version. (If
132 | you use option 4d0, the Installation Information must accompany
133 | the Minimal Corresponding Source and Corresponding Application
134 | Code. If you use option 4d1, you must provide the Installation
135 | Information in the manner specified by section 6 of the GNU GPL
136 | for conveying Corresponding Source.)
137 |
138 | 5. Combined Libraries.
139 |
140 | You may place library facilities that are a work based on the
141 | Library side by side in a single library together with other library
142 | facilities that are not Applications and are not covered by this
143 | License, and convey such a combined library under terms of your
144 | choice, if you do both of the following:
145 |
146 | a) Accompany the combined library with a copy of the same work based
147 | on the Library, uncombined with any other library facilities,
148 | conveyed under the terms of this License.
149 |
150 | b) Give prominent notice with the combined library that part of it
151 | is a work based on the Library, and explaining where to find the
152 | accompanying uncombined form of the same work.
153 |
154 | 6. Revised Versions of the GNU Lesser General Public License.
155 |
156 | The Free Software Foundation may publish revised and/or new versions
157 | of the GNU Lesser General Public License from time to time. Such new
158 | versions will be similar in spirit to the present version, but may
159 | differ in detail to address new problems or concerns.
160 |
161 | Each version is given a distinguishing version number. If the
162 | Library as you received it specifies that a certain numbered version
163 | of the GNU Lesser General Public License "or any later version"
164 | applies to it, you have the option of following the terms and
165 | conditions either of that published version or of any later version
166 | published by the Free Software Foundation. If the Library as you
167 | received it does not specify a version number of the GNU Lesser
168 | General Public License, you may choose any version of the GNU Lesser
169 | General Public License ever published by the Free Software Foundation.
170 |
171 | If the Library as you received it specifies that a proxy can decide
172 | whether future versions of the GNU Lesser General Public License shall
173 | apply, that proxy's public statement of acceptance of any version is
174 | permanent authorization for you to choose that version for the
175 | Library.
176 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: Makefile.coq
2 | @+$(MAKE) -f Makefile.coq all
3 |
4 | clean: Makefile.coq
5 | @+$(MAKE) -f Makefile.coq cleanall
6 | @rm -f Makefile.coq Makefile.coq.conf
7 |
8 | Makefile.coq: _CoqProject
9 | $(COQBIN)coq_makefile -f _CoqProject -o Makefile.coq
10 |
11 | force _CoqProject Makefile: ;
12 |
13 | %: Makefile.coq force
14 | @+$(MAKE) -f Makefile.coq $@
15 |
16 | .PHONY: all clean force
17 |
--------------------------------------------------------------------------------
/Makefile.coq.local:
--------------------------------------------------------------------------------
1 | GLOBFILES = $(VFILES:.v=.glob)
2 | CSSFILES = resources/coqdoc.css resources/coqdocjs.css
3 | JSFILES = resources/config.js resources/coqdocjs.js
4 | HTMLFILES = resources/header.html resources/footer.html
5 | COQDOCDIR = docs/coqdoc
6 |
7 | COQDOCHTMLFLAGS = --toc --toc-depth 2 --index indexpage --html \
8 | --interpolate --no-lib-name --parse-comments \
9 | --with-header resources/header.html --with-footer resources/footer.html
10 |
11 | coqdoc: $(GLOBFILES) $(VFILES) $(CSSFILES) $(JSFILES) $(HTMLFILES)
12 | $(SHOW)'COQDOC -d $(COQDOCDIR)'
13 | $(HIDE)mkdir -p $(COQDOCDIR)
14 | $(HIDE)$(COQDOC) $(COQDOCHTMLFLAGS) $(COQDOCLIBS) -d $(COQDOCDIR) $(VFILES)
15 | $(SHOW)'COPY resources'
16 | $(HIDE)cp $(CSSFILES) $(JSFILES) $(COQDOCDIR)
17 | .PHONY: coqdoc
18 |
19 | resources/index.html: resources/index.md
20 | pandoc -s -o $@ $<
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
5 | # ATBR
6 |
7 | [![Docker CI][docker-action-shield]][docker-action-link]
8 | [![Contributing][contributing-shield]][contributing-link]
9 | [![Code of Conduct][conduct-shield]][conduct-link]
10 | [![Zulip][zulip-shield]][zulip-link]
11 | [![coqdoc][coqdoc-shield]][coqdoc-link]
12 | [![DOI][doi-shield]][doi-link]
13 |
14 | [docker-action-shield]: https://github.com/coq-community/atbr/workflows/Docker%20CI/badge.svg?branch=master
15 | [docker-action-link]: https://github.com/coq-community/atbr/actions?query=workflow:"Docker%20CI"
16 |
17 | [contributing-shield]: https://img.shields.io/badge/contributions-welcome-%23f7931e.svg
18 | [contributing-link]: https://github.com/coq-community/manifesto/blob/master/CONTRIBUTING.md
19 |
20 | [conduct-shield]: https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-%23f15a24.svg
21 | [conduct-link]: https://github.com/coq-community/manifesto/blob/master/CODE_OF_CONDUCT.md
22 |
23 | [zulip-shield]: https://img.shields.io/badge/chat-on%20zulip-%23c1272d.svg
24 | [zulip-link]: https://coq.zulipchat.com/#narrow/stream/237663-coq-community-devs.20.26.20users
25 |
26 | [coqdoc-shield]: https://img.shields.io/badge/docs-coqdoc-blue.svg
27 | [coqdoc-link]: https://coq-community.org/atbr
28 |
29 | [doi-shield]: https://zenodo.org/badge/DOI/10.2168/LMCS-8(1:16)2012.svg
30 | [doi-link]: https://doi.org/10.2168/LMCS-8(1:16)2012
31 |
32 | This library provides algebraic tools for working with binary relations.
33 | The main tactic provided is a reflexive tactic for solving (in)equations
34 | in an arbitrary Kleene algebra. The decision procedure goes through
35 | standard finite automata constructions.
36 |
37 | Note that the initial authors consider this library to be superseded
38 | by the Relation Algebra library, which is based on derivatives
39 | rather than automata: https://github.com/damien-pous/relation-algebra
40 |
41 | ## Meta
42 |
43 | - Author(s):
44 | - Thomas Braibant (initial)
45 | - Damien Pous (initial)
46 | - Coq-community maintainer(s):
47 | - Tej Chajed ([**@tchajed**](https://github.com/tchajed))
48 | - License: [GNU Lesser General Public License v3.0 or later](LICENSE)
49 | - Compatible Coq versions: master (use the corresponding branch or release for other Coq versions)
50 | - Compatible OCaml versions: 4.09.0 or later
51 | - Additional dependencies: none
52 | - Coq namespace: `ATBR`
53 | - Related publication(s):
54 | - [Deciding Kleene Algebras in Coq](https://arxiv.org/abs/1105.4537) doi:[10.2168/LMCS-8(1:16)2012](https://doi.org/10.2168/LMCS-8(1:16)2012)
55 |
56 | ## Building and installation instructions
57 |
58 | The easiest way to install the latest released version of ATBR
59 | is via [OPAM](https://opam.ocaml.org/doc/Install.html):
60 |
61 | ```shell
62 | opam repo add coq-released https://coq.inria.fr/opam/released
63 | opam install coq-atbr
64 | ```
65 |
66 | To instead build and install manually, do:
67 |
68 | ``` shell
69 | git clone https://github.com/coq-community/atbr.git
70 | cd atbr
71 | make # or make -j
72 | make install
73 | ```
74 |
75 |
76 | ## Documentation
77 |
78 | The development and underlying theory of the library is described in the paper
79 | [Deciding Kleene Algebras in Coq][paper], Logical Methods in Computer Science,
80 | Volume 8, Issue 1, 2012.
81 |
82 | Below are succinct descriptions of each file and tactic. See also the
83 | [coqdoc presentation][coqdoc] of the Coq source files from the latest release.
84 |
85 | ### Library files
86 |
87 | | Filename | Description
88 | | -------- | -----------
89 | | ATBR | Export all relevant modules, except those related to matrices
90 | | ATBR_Matrices | Export all relevant modules, including those related to matrices
91 |
92 |
93 | #### Algebraic hierarchy
94 |
95 | | Filename | Description
96 | | -------- | -----------
97 | | Classes | Definitions of algebraic classes of the development
98 | | Graph | Lemmas and hints about the base class (carrier with equality)
99 | | Monoid | Monoids, free monoids, finite iterations over a monoid, various tactics
100 | | SemiLattice | Semilattices, tactics: normalise, reflexivity, rewrite
101 | | SemiRing | Idempotent semirings, tactics: normalise, reflexivity, rewrite
102 | | KleeneAlgebra | Kleene algebras, basic properties
103 | | Converse | Structures with converse (semirings and Kleene Algebras)
104 | | Functors | Functors between the various algebraic structures
105 | | StrictKleeneAlgebra | Class of Strict Kleene algebras (without 0), and extension of the decision procedure
106 |
107 | #### Models
108 |
109 | | Filename | Description
110 | | -------- | -----------
111 | | Model_Relations | Kleene Algebra of (heterogeneous) binary relations
112 | | Model_StdRelations | Kleene Algebra of standard (homogeneous) binary relations
113 | | Model_Languages | Kleene Algebra of languages
114 | | Model_RegExp | Kleene Algebra of regular expressions (syntactic free model), typed reification
115 | | Model_MinMax | (min,+) Kleene Algebra (matrices on this algebra give weighted graphs)
116 |
117 | #### Matrices
118 |
119 | | Filename | Description
120 | | -------- | -----------
121 | | MxGraph | Matrices without operations; blocks definitions
122 | | MxSemiLattice | Semilattices of matrices
123 | | MxSemiRing | Semiring of matrices
124 | | MxKleeneAlgebra | Kleene algebra of matrices (definition of the star operation)
125 | | MxFunctors | Extension of functors to matrices
126 |
127 |
128 | #### Decision procedure for KA
129 |
130 | | Filename | Description
131 | | -------- | -----------
132 | | DKA_Definitions | Base definitions for the decision procedure for KA (automata types, notations, ...)
133 | | DKA_StateSetSets | Properties about sets of sets
134 | | DKA_CheckLabels | Algorithm to check whether two regex have the same set of labels
135 | | DKA_Construction | Construction algorithm, and proof of correctness
136 | | DKA_Epsilon | Removal of epsilon transitions, proof of correctness
137 | | DKA_Determinisation | Determinisation algorithm, proof of correctness
138 | | DKA_Merge | Union of DFAs, proof of correctness
139 | | DKA_DFA_Language | Language recognised by a DFA, equivalence with the evaluation of the DFA
140 | | DKA_DFA_Equiv | Equivalence check for DFAs, proof of correctness
141 | | DecideKleeneAlgebra | Kozen's initiality proof, kleene_reflexivity tactic
142 |
143 | #### Other tools
144 |
145 | | Filename | Description
146 | | -------- | -----------
147 | | StrictStarForm | Conversion of regular expressions into strict star form, kleene_ssf tactic
148 | | Equivalence | Tactic for solving equivalences by transitivity
149 |
150 | #### Examples
151 |
152 | | Filename | Description
153 | | -------- | -----------
154 | | Examples | Small tutorial file, that goes through our set of tactics
155 | | ChurchRosser | Simple usages of kleene_reflexivity to prove commutation properties
156 | | ChurchRosser_Points | Comparison between a standard CR proof and algebraic ones
157 |
158 | #### Misc.
159 |
160 | | Filename | Description
161 | | -------- | -----------
162 | | Common | Shared simple tactics and definitions
163 | | BoolView | View mechanism for Boolean computations
164 | | Numbers | NUM interface, to abstract over the representation of numbers, sets, and maps
165 | | Utils_WF | Utilities about well-founded relations; partial fixpoint operators (powerfix)
166 | | DisjointSets | Efficient implementation of a disjoint sets data structure
167 | | Force | Functional memoisation (in case one needs efficient matrix computations)
168 | | Reification | Reified syntax for the various algebraic structures
169 |
170 | #### Finite sets and maps
171 |
172 | | Filename | Description
173 | | -------- | -----------
174 | | MyFSets | Efficient ordered datatypes constructions (for FSets functors)
175 | | MyFSetProperties | Handler for FSet properties
176 | | MyFMapProperties | Handler for FMap properties
177 |
178 | #### OCaml modules
179 |
180 | | Filename | Description
181 | | -------- | -----------
182 | | `reification.ml` | reification for the reflexive tactics
183 |
184 | ### Tactics
185 |
186 | #### Reflexive tactics
187 |
188 | | Tactic | Description
189 | | ------ | -----------
190 | | `semiring_reflexivity` | solve an (in)equation on the idempotent semiring (*,+,1,0)
191 | | `semiring_normalize` | simplify an (in)equation on the idempotent semiring (*,+,1,0)
192 | | `semiring_clean` | simplify 0 and 1
193 | | `semiring_cleanassoc` | simplify 0 and 1, normalize the parentheses
194 | | `kleene_reflexivity` | solve an (in)equation in Kleene Algebras
195 | | `ckleene_reflexivity` | solve an (in)equation in Kleene Algebras with converse
196 | | `skleene_reflexivity` | solve an (in)equation in Strict Kleene Algebras (without 0)
197 | | `kleene_clean_zero` | remove zeros in a KA expression
198 | | `kleene_ssf` | put KA expressions into strict star form
199 |
200 | #### Rewriting tactics
201 |
202 | | Tactic | Description
203 | | ------ | -----------
204 | | `ac_rewrite H` | rewrite a closed equality modulo (AC) of (+)
205 | | `monoid_rewrite H` | rewrite a closed equality modulo (A) of (*)
206 |
207 | #### Other tactics
208 |
209 | | Tactic | Description
210 | | ------ | -----------
211 | | `converse_down` | push converses down to terms leaves
212 | | `switch` | add converses to the goal and push them down to terms leaves
213 |
214 | ## Acknowledgements
215 |
216 | The initial authors would like to thank Guilhem Moulin and Sebastien Briais,
217 | who participated to a preliminary version of this project. They are also grateful
218 | to Assia Mahboubi, Matthieu Sozeau, Bruno Barras, and Hugo Herbelin for highly
219 | stimulating discussions, as well as numerous hints for solving various problems.
220 |
221 | [paper]: https://arxiv.org/abs/1105.4537
222 | [coqdoc]: https://coq-community.github.io/atbr/docs/latest/coqdoc/toc.html
223 |
224 |
--------------------------------------------------------------------------------
/TODO.txt:
--------------------------------------------------------------------------------
1 | Here is a list of things we intend to do at some point;
2 | suggestions are welcome.
3 |
4 | - Non idempotent semirings:
5 | we considered only idempotent (non-commutative) semirings in this
6 | development. This is because we wanted to work with binary relations.
7 | It should be easy, however, to isolate the idempotence hypothesis,
8 | so as to provide tools for non necessarily idempotents semirings.
9 | This would fill the gap with existing Coq tactics (ring), that handle
10 | the commutative case.
11 |
12 | - Matrix library:
13 | we need to clean up this part of the code, and to add some
14 | documentation, in order to release it as a library for working
15 | with matrices in a non-commutative setting. Some lemmas and
16 | functions will be renamed.
17 |
18 | - Compilation time / Loading time:
19 | our library is really slow to compile (about 6 minutes), and slow
20 | to load (about 8 seconds), for at least two reasons:
21 | 1/ our intensive use of FSets modules and functors, that are really
22 | slow to instantiate and load in the current version of Coq;
23 | 2/ our intensive use of typeclasses.
24 | Depending on the evolutions of Coq, we might be able to improve this
25 | situation.
26 |
--------------------------------------------------------------------------------
/_CoqProject:
--------------------------------------------------------------------------------
1 | -generate-meta-for-package coq-atbr
2 | -Q theories ATBR
3 | -I src
4 |
5 | -arg -w -arg -variable-collision
6 | -arg -w -arg -projection-no-head-constant
7 | -arg -w -arg -undo-batch-mode
8 | -arg -w -arg -undeclared-scope
9 | -arg -w -arg -ambiguous-paths
10 |
11 | src/reify.ml
12 | src/reification.mlg
13 | src/reification_plugin.mlpack
14 |
15 | theories/Common.v
16 | theories/BoolView.v
17 | theories/MyFSets.v
18 | theories/MyFSetProperties.v
19 | theories/MyFMapProperties.v
20 | theories/Numbers.v
21 | theories/Utils_WF.v
22 | theories/Force.v
23 | theories/DisjointSets.v
24 | theories/Classes.v
25 | theories/Reification.v
26 | theories/Functors.v
27 | theories/Graph.v
28 | theories/SemiLattice.v
29 | theories/Monoid.v
30 | theories/SemiRing.v
31 | theories/KleeneAlgebra.v
32 | theories/Converse.v
33 | theories/Model_Relations.v
34 | theories/Model_StdRelations.v
35 | theories/Model_Languages.v
36 | theories/Model_RegExp.v
37 | theories/Model_MinPlus.v
38 | theories/StrictStarForm.v
39 | theories/MxGraph.v
40 | theories/MxSemiLattice.v
41 | theories/MxSemiRing.v
42 | theories/MxKleeneAlgebra.v
43 | theories/MxFunctors.v
44 | theories/DKA_Definitions.v
45 | theories/DKA_StateSetSets.v
46 | theories/DKA_CheckLabels.v
47 | theories/DKA_Construction.v
48 | theories/DKA_Epsilon.v
49 | theories/DKA_Determinisation.v
50 | theories/DKA_Merge.v
51 | theories/DKA_DFA_Language.v
52 | theories/DKA_DFA_Equiv.v
53 | theories/DecideKleeneAlgebra.v
54 | theories/StrictKleeneAlgebra.v
55 | theories/ATBR.v
56 | theories/ATBR_Matrices.v
57 | theories/Examples.v
58 | theories/ChurchRosser.v
59 | theories/ChurchRosser_Points_vs_Algebraic.v
60 |
--------------------------------------------------------------------------------
/coq-atbr.opam:
--------------------------------------------------------------------------------
1 | # This file was generated from `meta.yml`, please do not edit manually.
2 | # Follow the instructions on https://github.com/coq-community/templates to regenerate.
3 |
4 | opam-version: "2.0"
5 | maintainer: "palmskog@gmail.com"
6 | version: "dev"
7 |
8 | homepage: "https://github.com/coq-community/atbr"
9 | dev-repo: "git+https://github.com/coq-community/atbr.git"
10 | bug-reports: "https://github.com/coq-community/atbr/issues"
11 | doc: "https://coq-community.github.io/atbr/"
12 | license: "LGPL-3.0-or-later"
13 |
14 | synopsis: "Coq library and tactic for deciding Kleene algebras"
15 | description: """
16 | This library provides algebraic tools for working with binary relations.
17 | The main tactic provided is a reflexive tactic for solving (in)equations
18 | in an arbitrary Kleene algebra. The decision procedure goes through
19 | standard finite automata constructions.
20 |
21 | Note that the initial authors consider this library to be superseded
22 | by the Relation Algebra library, which is based on derivatives
23 | rather than automata: https://github.com/damien-pous/relation-algebra"""
24 |
25 | build: [make "-j%{jobs}%"]
26 | install: [make "install"]
27 | depends: [
28 | "ocaml" {>= "4.09.0"}
29 | "coq" {= "dev"}
30 | ]
31 |
32 | tags: [
33 | "category:Miscellaneous/Coq Extensions"
34 | "category:Computer Science/Decision Procedures and Certified Algorithms/Decision procedures"
35 | "keyword:Kleene algebra"
36 | "keyword:finite automata"
37 | "keyword:semiring"
38 | "keyword:matrices"
39 | "keyword:decision procedure"
40 | "keyword:reflexive tactic"
41 | "logpath:ATBR"
42 | ]
43 | authors: [
44 | "Thomas Braibant"
45 | "Damien Pous"
46 | ]
47 |
--------------------------------------------------------------------------------
/dune-project:
--------------------------------------------------------------------------------
1 | (lang dune 2.8)
2 | (using coq 0.3)
3 | (name atbr)
4 |
--------------------------------------------------------------------------------
/meta.yml:
--------------------------------------------------------------------------------
1 | ---
2 | fullname: ATBR
3 | shortname: atbr
4 | organization: coq-community
5 | community: true
6 | action: true
7 | coqdoc: true
8 | doi: 10.2168/LMCS-8(1:16)2012
9 | plugin: true
10 |
11 | synopsis: Coq library and tactic for deciding Kleene algebras
12 |
13 | description: |-
14 | This library provides algebraic tools for working with binary relations.
15 | The main tactic provided is a reflexive tactic for solving (in)equations
16 | in an arbitrary Kleene algebra. The decision procedure goes through
17 | standard finite automata constructions.
18 |
19 | Note that the initial authors consider this library to be superseded
20 | by the Relation Algebra library, which is based on derivatives
21 | rather than automata: https://github.com/damien-pous/relation-algebra
22 |
23 | publications:
24 | - pub_url: https://arxiv.org/abs/1105.4537
25 | pub_title: Deciding Kleene Algebras in Coq
26 | pub_doi: 10.2168/LMCS-8(1:16)2012
27 |
28 | authors:
29 | - name: Thomas Braibant
30 | initial: true
31 | - name: Damien Pous
32 | initial: true
33 |
34 | maintainers:
35 | - name: Tej Chajed
36 | nickname: tchajed
37 |
38 | opam-file-maintainer: palmskog@gmail.com
39 |
40 | opam-file-version: dev
41 |
42 | license:
43 | fullname: GNU Lesser General Public License v3.0 or later
44 | identifier: LGPL-3.0-or-later
45 |
46 | supported_coq_versions:
47 | text: master (use the corresponding branch or release for other Coq versions)
48 | opam: '{= "dev"}'
49 |
50 | supported_ocaml_versions:
51 | text: 4.09.0 or later
52 | opam: '{>= "4.09.0"}'
53 |
54 | tested_coq_opam_versions:
55 | - version: 'dev'
56 |
57 | namespace: ATBR
58 |
59 | keywords:
60 | - name: Kleene algebra
61 | - name: finite automata
62 | - name: semiring
63 | - name: matrices
64 | - name: decision procedure
65 | - name: reflexive tactic
66 |
67 | categories:
68 | - name: Miscellaneous/Coq Extensions
69 | - name: Computer Science/Decision Procedures and Certified Algorithms/Decision procedures
70 |
71 | documentation: |
72 | ## Documentation
73 |
74 | The development and underlying theory of the library is described in the paper
75 | [Deciding Kleene Algebras in Coq][paper], Logical Methods in Computer Science,
76 | Volume 8, Issue 1, 2012.
77 |
78 | Below are succinct descriptions of each file and tactic. See also the
79 | [coqdoc presentation][coqdoc] of the Coq source files from the latest release.
80 |
81 | ### Library files
82 |
83 | | Filename | Description
84 | | -------- | -----------
85 | | ATBR | Export all relevant modules, except those related to matrices
86 | | ATBR_Matrices | Export all relevant modules, including those related to matrices
87 |
88 |
89 | #### Algebraic hierarchy
90 |
91 | | Filename | Description
92 | | -------- | -----------
93 | | Classes | Definitions of algebraic classes of the development
94 | | Graph | Lemmas and hints about the base class (carrier with equality)
95 | | Monoid | Monoids, free monoids, finite iterations over a monoid, various tactics
96 | | SemiLattice | Semilattices, tactics: normalise, reflexivity, rewrite
97 | | SemiRing | Idempotent semirings, tactics: normalise, reflexivity, rewrite
98 | | KleeneAlgebra | Kleene algebras, basic properties
99 | | Converse | Structures with converse (semirings and Kleene Algebras)
100 | | Functors | Functors between the various algebraic structures
101 | | StrictKleeneAlgebra | Class of Strict Kleene algebras (without 0), and extension of the decision procedure
102 |
103 | #### Models
104 |
105 | | Filename | Description
106 | | -------- | -----------
107 | | Model_Relations | Kleene Algebra of (heterogeneous) binary relations
108 | | Model_StdRelations | Kleene Algebra of standard (homogeneous) binary relations
109 | | Model_Languages | Kleene Algebra of languages
110 | | Model_RegExp | Kleene Algebra of regular expressions (syntactic free model), typed reification
111 | | Model_MinMax | (min,+) Kleene Algebra (matrices on this algebra give weighted graphs)
112 |
113 | #### Matrices
114 |
115 | | Filename | Description
116 | | -------- | -----------
117 | | MxGraph | Matrices without operations; blocks definitions
118 | | MxSemiLattice | Semilattices of matrices
119 | | MxSemiRing | Semiring of matrices
120 | | MxKleeneAlgebra | Kleene algebra of matrices (definition of the star operation)
121 | | MxFunctors | Extension of functors to matrices
122 |
123 |
124 | #### Decision procedure for KA
125 |
126 | | Filename | Description
127 | | -------- | -----------
128 | | DKA_Definitions | Base definitions for the decision procedure for KA (automata types, notations, ...)
129 | | DKA_StateSetSets | Properties about sets of sets
130 | | DKA_CheckLabels | Algorithm to check whether two regex have the same set of labels
131 | | DKA_Construction | Construction algorithm, and proof of correctness
132 | | DKA_Epsilon | Removal of epsilon transitions, proof of correctness
133 | | DKA_Determinisation | Determinisation algorithm, proof of correctness
134 | | DKA_Merge | Union of DFAs, proof of correctness
135 | | DKA_DFA_Language | Language recognised by a DFA, equivalence with the evaluation of the DFA
136 | | DKA_DFA_Equiv | Equivalence check for DFAs, proof of correctness
137 | | DecideKleeneAlgebra | Kozen's initiality proof, kleene_reflexivity tactic
138 |
139 | #### Other tools
140 |
141 | | Filename | Description
142 | | -------- | -----------
143 | | StrictStarForm | Conversion of regular expressions into strict star form, kleene_ssf tactic
144 | | Equivalence | Tactic for solving equivalences by transitivity
145 |
146 | #### Examples
147 |
148 | | Filename | Description
149 | | -------- | -----------
150 | | Examples | Small tutorial file, that goes through our set of tactics
151 | | ChurchRosser | Simple usages of kleene_reflexivity to prove commutation properties
152 | | ChurchRosser_Points | Comparison between a standard CR proof and algebraic ones
153 |
154 | #### Misc.
155 |
156 | | Filename | Description
157 | | -------- | -----------
158 | | Common | Shared simple tactics and definitions
159 | | BoolView | View mechanism for Boolean computations
160 | | Numbers | NUM interface, to abstract over the representation of numbers, sets, and maps
161 | | Utils_WF | Utilities about well-founded relations; partial fixpoint operators (powerfix)
162 | | DisjointSets | Efficient implementation of a disjoint sets data structure
163 | | Force | Functional memoisation (in case one needs efficient matrix computations)
164 | | Reification | Reified syntax for the various algebraic structures
165 |
166 | #### Finite sets and maps
167 |
168 | | Filename | Description
169 | | -------- | -----------
170 | | MyFSets | Efficient ordered datatypes constructions (for FSets functors)
171 | | MyFSetProperties | Handler for FSet properties
172 | | MyFMapProperties | Handler for FMap properties
173 |
174 | #### OCaml modules
175 |
176 | | Filename | Description
177 | | -------- | -----------
178 | | `reification.ml` | reification for the reflexive tactics
179 |
180 | ### Tactics
181 |
182 | #### Reflexive tactics
183 |
184 | | Tactic | Description
185 | | ------ | -----------
186 | | `semiring_reflexivity` | solve an (in)equation on the idempotent semiring (*,+,1,0)
187 | | `semiring_normalize` | simplify an (in)equation on the idempotent semiring (*,+,1,0)
188 | | `semiring_clean` | simplify 0 and 1
189 | | `semiring_cleanassoc` | simplify 0 and 1, normalize the parentheses
190 | | `kleene_reflexivity` | solve an (in)equation in Kleene Algebras
191 | | `ckleene_reflexivity` | solve an (in)equation in Kleene Algebras with converse
192 | | `skleene_reflexivity` | solve an (in)equation in Strict Kleene Algebras (without 0)
193 | | `kleene_clean_zero` | remove zeros in a KA expression
194 | | `kleene_ssf` | put KA expressions into strict star form
195 |
196 | #### Rewriting tactics
197 |
198 | | Tactic | Description
199 | | ------ | -----------
200 | | `ac_rewrite H` | rewrite a closed equality modulo (AC) of (+)
201 | | `monoid_rewrite H` | rewrite a closed equality modulo (A) of (*)
202 |
203 | #### Other tactics
204 |
205 | | Tactic | Description
206 | | ------ | -----------
207 | | `converse_down` | push converses down to terms leaves
208 | | `switch` | add converses to the goal and push them down to terms leaves
209 |
210 | ## Acknowledgements
211 |
212 | The initial authors would like to thank Guilhem Moulin and Sebastien Briais,
213 | who participated to a preliminary version of this project. They are also grateful
214 | to Assia Mahboubi, Matthieu Sozeau, Bruno Barras, and Hugo Herbelin for highly
215 | stimulating discussions, as well as numerous hints for solving various problems.
216 |
217 | [paper]: https://arxiv.org/abs/1105.4537
218 | [coqdoc]: https://coq-community.github.io/atbr/docs/latest/coqdoc/toc.html
219 | ---
220 |
--------------------------------------------------------------------------------
/resources/config.js:
--------------------------------------------------------------------------------
1 | var coqdocjs = coqdocjs || {};
2 |
3 | coqdocjs.repl = {
4 | "forall": "∀",
5 | "exists": "∃",
6 | "~": "¬",
7 | "/\\": "∧",
8 | "\\/": "∨",
9 | "->": "→",
10 | "<-": "←",
11 | "<->": "↔",
12 | "=>": "⇒",
13 | "<>": "≠",
14 | "<=": "≤",
15 | ">=": "≥",
16 | "el": "∈",
17 | "nel": "∉",
18 | "<<=": "⊆",
19 | "|-": "⊢",
20 | ">>": "»",
21 | "<<": "⊆",
22 | "++": "⧺",
23 | "===": "≡",
24 | "=/=": "≢",
25 | "=~=": "≅",
26 | "==>": "⟹",
27 | "<==": "⟸",
28 | "False": "⊥",
29 | "True": "⊤",
30 | ":=": "≔",
31 | "-|": "⊣",
32 | "*": "×",
33 | "::": "∷",
34 | "lhd": "⊲",
35 | "rhd": "⊳",
36 | "nat": "ℕ",
37 | "alpha": "α",
38 | "beta": "β",
39 | "gamma": "γ",
40 | "delta": "δ",
41 | "epsilon": "ε",
42 | "eta": "η",
43 | "iota": "ι",
44 | "kappa": "κ",
45 | "lambda": "λ",
46 | "mu": "μ",
47 | "nu": "ν",
48 | "omega": "ω",
49 | "phi": "ϕ",
50 | "pi": "π",
51 | "psi": "ψ",
52 | "rho": "ρ",
53 | "sigma": "σ",
54 | "tau": "τ",
55 | "theta": "θ",
56 | "xi": "ξ",
57 | "zeta": "ζ",
58 | "Delta": "Δ",
59 | "Gamma": "Γ",
60 | "Pi": "Π",
61 | "Sigma": "Σ",
62 | "Omega": "Ω",
63 | "Xi": "Ξ"
64 | };
65 |
66 | coqdocjs.subscr = {
67 | "0" : "₀",
68 | "1" : "₁",
69 | "2" : "₂",
70 | "3" : "₃",
71 | "4" : "₄",
72 | "5" : "₅",
73 | "6" : "₆",
74 | "7" : "₇",
75 | "8" : "₈",
76 | "9" : "₉",
77 | };
78 |
79 | coqdocjs.replInText = ["==>","<=>", "=>", "->", "<-", ":="];
80 |
--------------------------------------------------------------------------------
/resources/coqdoc.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);
2 |
3 | body{
4 | font-family: 'Open Sans', sans-serif;
5 | font-size: 14px;
6 | color: #2D2D2D
7 | }
8 |
9 | a {
10 | text-decoration: none;
11 | border-radius: 3px;
12 | padding-left: 3px;
13 | padding-right: 3px;
14 | margin-left: -3px;
15 | margin-right: -3px;
16 | color: inherit;
17 | font-weight: bold;
18 | }
19 |
20 | #main .code a, #main .inlinecode a, #toc a {
21 | font-weight: inherit;
22 | }
23 |
24 | a[href]:hover, [clickable]:hover{
25 | background-color: rgba(0,0,0,0.1);
26 | cursor: pointer;
27 | }
28 |
29 | h, h1, h2, h3, h4, h5 {
30 | line-height: 1;
31 | color: black;
32 | text-rendering: optimizeLegibility;
33 | font-weight: normal;
34 | letter-spacing: 0.1em;
35 | text-align: left;
36 | }
37 |
38 | div + br {
39 | display: none;
40 | }
41 |
42 | div:empty{ display: none;}
43 |
44 | #main h1 {
45 | font-size: 2em;
46 | }
47 |
48 | #main h2 {
49 | font-size: 1.667rem;
50 | }
51 |
52 | #main h3 {
53 | font-size: 1.333em;
54 | }
55 |
56 | #main h4, #main h5, #main h6 {
57 | font-size: 1em;
58 | }
59 |
60 | #toc h2 {
61 | padding-bottom: 0;
62 | }
63 |
64 | #main .doc {
65 | margin: 0;
66 | text-align: justify;
67 | }
68 |
69 | .inlinecode, .code, #main pre {
70 | font-family: monospace;
71 | }
72 |
73 | .code > br:first-child {
74 | display: none;
75 | }
76 |
77 | .doc + .code{
78 | margin-top:0.5em;
79 | }
80 |
81 | .block{
82 | display: block;
83 | margin-top: 5px;
84 | margin-bottom: 5px;
85 | padding: 10px;
86 | text-align: center;
87 | }
88 |
89 | .block img{
90 | margin: 15px;
91 | }
92 |
93 | table.infrule {
94 | border: 0px;
95 | margin-left: 50px;
96 | margin-top: 10px;
97 | margin-bottom: 10px;
98 | }
99 |
100 | td.infrule {
101 | font-family: "Droid Sans Mono", "DejaVu Sans Mono", monospace;
102 | text-align: center;
103 | padding: 0;
104 | line-height: 1;
105 | }
106 |
107 | tr.infrulemiddle hr {
108 | margin: 1px 0 1px 0;
109 | }
110 |
111 | .infrulenamecol {
112 | color: rgb(60%,60%,60%);
113 | padding-left: 1em;
114 | padding-bottom: 0.1em
115 | }
116 |
117 | .id[type="constructor"], .id[type="projection"], .id[type="method"],
118 | .id[title="constructor"], .id[title="projection"], .id[title="method"] {
119 | color: #A30E16;
120 | }
121 |
122 | .id[type="var"], .id[type="variable"],
123 | .id[title="var"], .id[title="variable"] {
124 | color: inherit;
125 | }
126 |
127 | .id[type="definition"], .id[type="record"], .id[type="class"], .id[type="instance"], .id[type="inductive"], .id[type="library"],
128 | .id[title="definition"], .id[title="record"], .id[title="class"], .id[title="instance"], .id[title="inductive"], .id[title="library"] {
129 | color: #A6650F;
130 | }
131 |
132 | .id[type="lemma"],
133 | .id[title="lemma"]{
134 | color: #188B0C;
135 | }
136 |
137 | .id[type="keyword"], .id[type="notation"], .id[type="abbreviation"],
138 | .id[title="keyword"], .id[title="notation"], .id[title="abbreviation"]{
139 | color : #2874AE;
140 | }
141 |
142 | .comment {
143 | color: #808080;
144 | }
145 |
146 | /* TOC */
147 |
148 | #toc h2{
149 | letter-spacing: 0;
150 | font-size: 1.333em;
151 | }
152 |
153 | /* Index */
154 |
155 | #index {
156 | margin: 0;
157 | padding: 0;
158 | width: 100%;
159 | }
160 |
161 | #index #frontispiece {
162 | margin: 1em auto;
163 | padding: 1em;
164 | width: 60%;
165 | }
166 |
167 | .booktitle { font-size : 140% }
168 | .authors { font-size : 90%;
169 | line-height: 115%; }
170 | .moreauthors { font-size : 60% }
171 |
172 | #index #entrance {
173 | text-align: center;
174 | }
175 |
176 | #index #entrance .spacer {
177 | margin: 0 30px 0 30px;
178 | }
179 |
180 | ul.doclist {
181 | margin-top: 0em;
182 | margin-bottom: 0em;
183 | }
184 |
185 | #toc > * {
186 | clear: both;
187 | }
188 |
189 | #toc > a {
190 | display: block;
191 | float: left;
192 | margin-top: 1em;
193 | }
194 |
195 | #toc a h2{
196 | display: inline;
197 | }
198 |
--------------------------------------------------------------------------------
/resources/coqdocjs.css:
--------------------------------------------------------------------------------
1 | /* replace unicode */
2 |
3 | .id[repl] .hidden {
4 | font-size: 0;
5 | }
6 |
7 | .id[repl]:before{
8 | content: attr(repl);
9 | }
10 |
11 | /* folding proofs */
12 |
13 | @keyframes show-proof {
14 | 0% {
15 | max-height: 1.2em;
16 | opacity: 1;
17 | }
18 | 99% {
19 | max-height: 1000em;
20 | }
21 | 100%{
22 | }
23 | }
24 |
25 | @keyframes hide-proof {
26 | from {
27 | visibility: visible;
28 | max-height: 10em;
29 | opacity: 1;
30 | }
31 | to {
32 | max-height: 1.2em;
33 | }
34 | }
35 |
36 | .proof {
37 | cursor: pointer;
38 | }
39 | .proof * {
40 | cursor: pointer;
41 | }
42 |
43 | .proof {
44 | overflow: hidden;
45 | position: relative;
46 | transition: opacity 1s;
47 | display: inline-block;
48 | }
49 |
50 | .proof[show="false"] {
51 | max-height: 1.2em;
52 | visibility: visible;
53 | opacity: 0.3;
54 | }
55 |
56 | .proof[show="false"][animate] {
57 | animation-name: hide-proof;
58 | animation-duration: 0.25s;
59 | }
60 |
61 | .proof[show="true"] {
62 | animation-name: show-proof;
63 | animation-duration: 10s;
64 | }
65 |
66 | .proof[show="true"]:before {
67 | content: "\25BC"; /* arrow down */
68 | }
69 | .proof[show="false"]:before {
70 | content: "\25B6"; /* arrow right */
71 | }
72 |
73 | .proof[show="false"]:hover {
74 | visibility: visible;
75 | opacity: 0.5;
76 | }
77 |
78 | #toggle-proofs[proof-status="no-proofs"] {
79 | display: none;
80 | }
81 |
82 | #toggle-proofs[proof-status="some-hidden"]:before {
83 | content: "Show Proofs";
84 | }
85 |
86 | #toggle-proofs[proof-status="all-shown"]:before {
87 | content: "Hide Proofs";
88 | }
89 |
90 |
91 | /* page layout */
92 |
93 | html, body {
94 | height: 100%;
95 | margin:0;
96 | padding:0;
97 | }
98 |
99 | @media only screen { /* no div with internal scrolling to allow printing of whole content */
100 | body {
101 | display: flex;
102 | flex-direction: column
103 | }
104 |
105 | #content {
106 | flex: 1;
107 | overflow: auto;
108 | display: flex;
109 | flex-direction: column;
110 | }
111 | }
112 |
113 | #content:focus {
114 | outline: none; /* prevent glow in OS X */
115 | }
116 |
117 | #main {
118 | display: block;
119 | padding: 16px;
120 | padding-top: 1em;
121 | padding-bottom: 2em;
122 | margin-left: auto;
123 | margin-right: auto;
124 | max-width: 60em;
125 | flex: 1 0 auto;
126 | }
127 |
128 | .libtitle {
129 | display: none;
130 | }
131 |
132 | /* header */
133 | #header {
134 | width:100%;
135 | padding: 0;
136 | margin: 0;
137 | display: flex;
138 | align-items: center;
139 | background-color: rgb(21,57,105);
140 | color: white;
141 | font-weight: bold;
142 | overflow: hidden;
143 | }
144 |
145 |
146 | .button {
147 | cursor: pointer;
148 | }
149 |
150 | #header * {
151 | text-decoration: none;
152 | vertical-align: middle;
153 | margin-left: 15px;
154 | margin-right: 15px;
155 | }
156 |
157 | #header > .right, #header > .left {
158 | display: flex;
159 | flex: 1;
160 | align-items: center;
161 | }
162 | #header > .left {
163 | text-align: left;
164 | }
165 | #header > .right {
166 | flex-direction: row-reverse;
167 | }
168 |
169 | #header a, #header .button {
170 | color: white;
171 | box-sizing: border-box;
172 | }
173 |
174 | #header a {
175 | border-radius: 0;
176 | padding: 0.2em;
177 | }
178 |
179 | #header .button {
180 | background-color: rgb(63, 103, 156);
181 | border-radius: 1em;
182 | padding-left: 0.5em;
183 | padding-right: 0.5em;
184 | margin: 0.2em;
185 | }
186 |
187 | #header a:hover, #header .button:hover {
188 | background-color: rgb(181, 213, 255);
189 | color: black;
190 | }
191 |
192 | #header h1 { padding: 0;
193 | margin: 0;}
194 |
195 | /* footer */
196 | #footer {
197 | text-align: center;
198 | opacity: 0.5;
199 | font-size: 75%;
200 | }
201 |
202 | /* hyperlinks */
203 |
204 | @keyframes highlight {
205 | 50%{
206 | background-color: black;
207 | }
208 | }
209 |
210 | :target * {
211 | animation-name: highlight;
212 | animation-duration: 1s;
213 | }
214 |
215 | a[name]:empty {
216 | float: right;
217 | }
218 |
219 | /* Proviola */
220 |
221 | div.code {
222 | width: auto;
223 | float: none;
224 | }
225 |
226 | div.goal {
227 | position: fixed;
228 | left: 75%;
229 | width: 25%;
230 | top: 3em;
231 | }
232 |
233 | div.doc {
234 | clear: both;
235 | }
236 |
237 | span.command:hover {
238 | background-color: inherit;
239 | }
240 |
--------------------------------------------------------------------------------
/resources/coqdocjs.js:
--------------------------------------------------------------------------------
1 | var coqdocjs = coqdocjs || {};
2 | (function(){
3 |
4 | function replace(s){
5 | var m;
6 | if (m = s.match(/^(.+)'/)) {
7 | return replace(m[1])+"'";
8 | } else if (m = s.match(/^([A-Za-z]+)_?(\d+)$/)) {
9 | return replace(m[1])+m[2].replace(/\d/g, function(d){
10 | if (coqdocjs.subscr.hasOwnProperty(d)) {
11 | return coqdocjs.subscr[d];
12 | } else {
13 | return d;
14 | }
15 | });
16 | } else if (coqdocjs.repl.hasOwnProperty(s)){
17 | return coqdocjs.repl[s]
18 | } else {
19 | return s;
20 | }
21 | }
22 |
23 | function toArray(nl){
24 | return Array.prototype.slice.call(nl);
25 | }
26 |
27 | function replInTextNodes() {
28 | // Get all the nodes up front.
29 | var nodes = Array.from(document.querySelectorAll(".code, .inlinecode"))
30 | .flatMap(elem => Array.from(elem.childNodes)
31 | .filter(e => e.nodeType == Node.TEXT_NODE)
32 | );
33 |
34 | // Create a replacement template node to clone from.
35 | var replacementTemplate = document.createElement("span");
36 | replacementTemplate.setAttribute("class", "id");
37 | replacementTemplate.setAttribute("type", "keyword");
38 |
39 | // Do the replacements.
40 | coqdocjs.replInText.forEach(function(toReplace){
41 | var replacement = replacementTemplate.cloneNode(true);
42 | replacement.appendChild(document.createTextNode(toReplace));
43 |
44 | nodes.forEach(node => {
45 | var fragments = node.textContent.split(toReplace);
46 | node.textContent = fragments[fragments.length-1];
47 | for (var k = 0; k < fragments.length - 1; ++k) {
48 | fragments[k] && node.parentNode.insertBefore(document.createTextNode(fragments[k]),node);
49 | node.parentNode.insertBefore(replacement.cloneNode(true), node);
50 | }
51 | });
52 | });
53 | }
54 |
55 | function replNodes() {
56 | toArray(document.getElementsByClassName("id")).forEach(function(node){
57 | if (["var", "variable", "keyword", "notation", "definition", "inductive"].indexOf(node.getAttribute("type"))>=0){
58 | var text = node.textContent;
59 | var replText = replace(text);
60 | if(text != replText) {
61 | node.setAttribute("repl", replText);
62 | node.setAttribute("title", text);
63 | var hidden = document.createElement("span");
64 | hidden.setAttribute("class", "hidden");
65 | while (node.firstChild) {
66 | hidden.appendChild(node.firstChild);
67 | }
68 | node.appendChild(hidden);
69 | }
70 | }
71 | });
72 | }
73 |
74 | function isVernacStart(l, t){
75 | t = t.trim();
76 | for(var s of l){
77 | if (t == s || t.startsWith(s+" ") || t.startsWith(s+".")){
78 | return true;
79 | }
80 | }
81 | return false;
82 | }
83 |
84 | function isProofStart(n){
85 | return isVernacStart(["Proof"], n.textContent) ||
86 | (isVernacStart(["Next"], n.textContent) && isVernacStart(["Obligation"], n.nextSibling.nextSibling.textContent));
87 | }
88 |
89 | function isProofEnd(s){
90 | return isVernacStart(["Qed", "Admitted", "Defined", "Abort"], s);
91 | }
92 |
93 | function proofStatus(){
94 | var proofs = toArray(document.getElementsByClassName("proof"));
95 | if(proofs.length) {
96 | for(var proof of proofs) {
97 | if (proof.getAttribute("show") === "false") {
98 | return "some-hidden";
99 | }
100 | }
101 | return "all-shown";
102 | }
103 | else {
104 | return "no-proofs";
105 | }
106 | }
107 |
108 | function updateView(){
109 | document.getElementById("toggle-proofs").setAttribute("proof-status", proofStatus());
110 | }
111 |
112 | function foldProofs() {
113 | var hasCommands = true;
114 | var nodes = document.getElementsByClassName("command");
115 | if(nodes.length == 0) {
116 | hasCommands = false;
117 | console.log("no command tags found")
118 | nodes = document.getElementsByClassName("id");
119 | }
120 | toArray(nodes).forEach(function(node){
121 | if(isProofStart(node)) {
122 | var proof = document.createElement("span");
123 | proof.setAttribute("class", "proof");
124 |
125 | node.parentNode.insertBefore(proof, node);
126 | if(proof.previousSibling.nodeType === Node.TEXT_NODE)
127 | proof.appendChild(proof.previousSibling);
128 | while(node && !isProofEnd(node.textContent)) {
129 | proof.appendChild(node);
130 | node = proof.nextSibling;
131 | }
132 | if (proof.nextSibling) proof.appendChild(proof.nextSibling); // the Qed
133 | if (!hasCommands && proof.nextSibling) proof.appendChild(proof.nextSibling); // the dot after the Qed
134 |
135 | proof.addEventListener("click", function(proof){return function(e){
136 | if (e.target.parentNode.tagName.toLowerCase() === "a")
137 | return;
138 | proof.setAttribute("show", proof.getAttribute("show") === "true" ? "false" : "true");
139 | proof.setAttribute("animate", "");
140 | updateView();
141 | };}(proof));
142 | proof.setAttribute("show", "false");
143 | }
144 | });
145 | }
146 |
147 | function toggleProofs(){
148 | var someProofsHidden = proofStatus() === "some-hidden";
149 | toArray(document.getElementsByClassName("proof")).forEach(function(proof){
150 | proof.setAttribute("show", someProofsHidden);
151 | proof.setAttribute("animate", "");
152 | });
153 | updateView();
154 | }
155 |
156 | function repairDom(){
157 | // pull whitespace out of command
158 | toArray(document.getElementsByClassName("command")).forEach(function(node){
159 | while(node.firstChild && node.firstChild.textContent.trim() == ""){
160 | console.log("try move");
161 | node.parentNode.insertBefore(node.firstChild, node);
162 | }
163 | });
164 | toArray(document.getElementsByClassName("id")).forEach(function(node){
165 | node.setAttribute("type", node.getAttribute("title"));
166 | });
167 | toArray(document.getElementsByClassName("idref")).forEach(function(ref){
168 | toArray(ref.childNodes).forEach(function(child){
169 | if (["var", "variable"].indexOf(child.getAttribute("type")) > -1)
170 | ref.removeAttribute("href");
171 | });
172 | });
173 |
174 | }
175 |
176 | function fixTitle(){
177 | var url = "/" + window.location.pathname;
178 | var basename = url.substring(url.lastIndexOf('/')+1, url.lastIndexOf('.'));
179 | if (basename === "toc") {document.title = "Table of Contents";}
180 | else if (basename === "indexpage") {document.title = "Index";}
181 | else {document.title = basename;}
182 | }
183 |
184 | function postprocess(){
185 | repairDom();
186 | replInTextNodes()
187 | replNodes();
188 | foldProofs();
189 | document.getElementById("toggle-proofs").addEventListener("click", toggleProofs);
190 | updateView();
191 | }
192 |
193 | fixTitle();
194 | document.addEventListener('DOMContentLoaded', postprocess);
195 |
196 | coqdocjs.toggleProofs = toggleProofs;
197 | })();
198 |
--------------------------------------------------------------------------------
/resources/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |