diff --git a/LICENSES/Go-LICENSE b/LICENSES/Go-LICENSE new file mode 100644 index 0000000..2a7cf70 --- /dev/null +++ b/LICENSES/Go-LICENSE @@ -0,0 +1,27 @@ +Copyright 2009 The Go Authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google LLC nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Path/Basic.lean b/Path/Basic.lean index b549e72..b606c95 100644 --- a/Path/Basic.lean +++ b/Path/Basic.lean @@ -1,6 +1,8 @@ /- Lexical path cleaning, as Go's `path.Clean` and `path.Join` do it - (go1.24.7, src/path/path.go). The loop below follows Go's line by + (go1.24.7, src/path/path.go). Derived from `Clean` in src/path/path.go + (go1.24.7); copyright 2009 The Go Authors, under the BSD-3-Clause + license in LICENSES/Go-LICENSE. The loop below follows Go's line by line. Go writes into a buffer and keeps its length `w`; here the buffer is a list, kept reversed so that writing and removing at the end take one step, and `w` is its length. Go reads the input by diff --git a/README.md b/README.md index 292bdcc..0fb584c 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,14 @@ python3 tests/plant_bugs.py - `Spec/Defs.lean`: the rules the statements use, written from Go's documentation. - `Proofs.lean` and `Proofs/`: the proofs. - `Main.lean`: the command-line tool the tests drive. -- `lakefile.toml`: the build. It names the package and its version, its libraries and executable, and the default targets, and sets nothing else. +- `lakefile.toml`: the build. It names the package, its version and license, its libraries and executable, and the default targets, and sets nothing else. - `comparator.json`: which theorems `lake comparator` checks, and which axioms it allows. - `bar.toml`: the record for the bar check: status, authors, approvals, and where things are. - `SPEC.md`: the specification in plain words. - `tests/`: the differential tests, the oracles, and the planted bugs. +- `LICENSE`: the Apache License 2.0, for this library's own code and documents. +- `LICENSES/Go-LICENSE`: Go's BSD-3-Clause license, for the material copied from Go (below). + +## License + +The library's own code and documents are under the Apache License 2.0 (`LICENSE`). Some material is Go's, copyright 2009 The Go Authors, and keeps Go's BSD-3-Clause license (`LICENSES/Go-LICENSE`): the loop in `Path/Basic.lean`, a line-by-line port of `path.Clean`; the test tables `cleantests` and `jointests` from src/path/path_test.go (go1.24.7), copied into `Spec.lean` and `tests/run_tests.py`; and the quotations of Go's documentation in `SPEC.md`, `Spec/Defs.lean`, `Spec.lean` and this page. diff --git a/SPEC.md b/SPEC.md index b36a78f..48d9f22 100644 --- a/SPEC.md +++ b/SPEC.md @@ -1,6 +1,6 @@ # Specification: path -Go's documentation of `path.Clean` (https://pkg.go.dev/path#Clean) says it gives "the shortest path name equivalent to path by purely lexical processing". It reads only the string: it never looks at a file system. This library cleans paths by the rules of that documentation, and joins them as `path.Join` does, in Lean, on strings. That the result is the shortest such path is Go's description; it is not a statement here. +Go's documentation of `path.Clean` (https://pkg.go.dev/path#Clean) says it gives "the shortest path name equivalent to path by purely lexical processing". It reads only the string: it never looks at a file system. This library cleans paths by the rules of that documentation, and joins them as `path.Join` does, in Lean, on strings. That the result is the shortest such path is Go's description; it is not a statement here. Quotations of Go's documentation here are copyright 2009 The Go Authors, under the BSD-3-Clause license in `LICENSES/Go-LICENSE`. A reviewer who did not write this specification approves it. The approval also covers `Spec.lean`, `Spec/Defs.lean`, and the other files that `bar.toml` lists. diff --git a/Spec.lean b/Spec.lean index 35dcdd1..b9f1ae6 100644 --- a/Spec.lean +++ b/Spec.lean @@ -49,9 +49,10 @@ theorem clean_shape (p : String) (es : List Element) theorem clean_idem (p : String) : Path.clean (Path.clean p) = Path.clean p := by sorry -/-- `join`, as Go's documentation says: "Join joins any number of path - elements into a single path, separating them with slashes. Empty - elements are ignored. The result is Cleaned. However, if the +/-- `join`, as Go's documentation says (copyright 2009 The Go Authors, + BSD-3-Clause, see LICENSES/Go-LICENSE): "Join joins any number of + path elements into a single path, separating them with slashes. + Empty elements are ignored. The result is Cleaned. However, if the argument list is empty or all its elements are empty, Join returns an empty string." -/ theorem join_eq (es : List String) : @@ -77,7 +78,8 @@ theorem join_root_inside (b u : String) (hb : b ≠ "") : sorry /-- Go's tests of `Clean`, `cleantests` in src/path/path_test.go - (go1.24.7): each path cleans to its result, and the result cleans + (go1.24.7; copyright 2009 The Go Authors, BSD-3-Clause, see + LICENSES/Go-LICENSE): each path cleans to its result, and the result cleans to itself. Among them, `//abc` cleans to `/abc`: two slashes at the start are one slash, though POSIX lets a system give them a meaning of their own. -/ @@ -107,7 +109,8 @@ theorem go_clean_tests : sorry /-- Go's tests of `Join`, `jointests` in src/path/path_test.go - (go1.24.7), and one more: an empty first element is left out, so + (go1.24.7; copyright 2009 The Go Authors, BSD-3-Clause, see + LICENSES/Go-LICENSE), and one more: an empty first element is left out, so joining it to a rooted path gives a rooted path. -/ theorem go_join_tests : ∀ t ∈ [ diff --git a/Spec/Defs.lean b/Spec/Defs.lean index 91d9bd4..c64a8e4 100644 --- a/Spec/Defs.lean +++ b/Spec/Defs.lean @@ -1,6 +1,8 @@ /- The rules of Go's `path.Clean`, written from its documentation - (https://pkg.go.dev/path#Clean, go1.24.7): + (https://pkg.go.dev/path#Clean, go1.24.7). The quoted text is Go's, + copyright 2009 The Go Authors, under the BSD-3-Clause license in + LICENSES/Go-LICENSE: Clean returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively diff --git a/tests/run_tests.py b/tests/run_tests.py index ecd169c..194503d 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -184,7 +184,8 @@ def model_join(es): return model_clean("/".join(kept)) -# Go's tests: src/path/path_test.go, go1.24.7. +# Go's tests: src/path/path_test.go, go1.24.7. Copyright 2009 The Go Authors, +# under the BSD-3-Clause license in LICENSES/Go-LICENSE. GO_CLEAN = [ ("", "."), ("abc", "abc"), ("abc/def", "abc/def"), ("a/b/c", "a/b/c"), (".", "."), ("..", ".."), ("../..", "../.."), ("../../abc", "../../abc"), ("/abc", "/abc"), ("/", "/"),