Skip to content

Commit 5c4b3d0

Browse files
committed
strings: inline proof of compare_ok on > 8.20
1 parent 753638b commit 5c4b3d0

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
opam_file: 'rocq-elpi.opam'
2929
custom_image: ${{ matrix.image }}
3030
after_script: |
31-
ls -l
32-
id
3331
sudo chmod -R a+w .
3432
make all-examples
3533
make all-tests
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
#[only="8.20"] From Coq Require Export PrimStringAxioms PString.
2-
#[skip="8.20"] From Corelib Require Export PrimStringAxioms PString.
3-
Definition compare_ok := compare_eq.
2+
#[only="8.20"] Definition compare_ok := compare_eq.
3+
4+
#[skip="8.20"] From Corelib Require Import ssreflect ssrbool Uint63Axioms PrimStringAxioms.
5+
#[skip="8.20"] Lemma compare_refl (s : string) : compare s s = Eq.
6+
#[skip="8.20"] Proof.
7+
#[skip="8.20"] rewrite PrimStringAxioms.compare_spec.
8+
#[skip="8.20"] elim: (to_list s) => //= x xs ->.
9+
#[skip="8.20"] rewrite Uint63Axioms.compare_def_spec /compare_def eqb_refl.
10+
#[skip="8.20"] suff: ltb x x = false by move->.
11+
#[skip="8.20"] have [+ _] := ltb_spec x x.
12+
#[skip="8.20"] by case: ltb => // /(_ isT); case: (to_Z x) => //=; elim.
13+
#[skip="8.20"] Qed.
14+
#[skip="8.20"] Lemma to_list_inj (s1 s2 : string) :
15+
#[skip="8.20"] to_list s1 = to_list s2 -> s1 = s2.
16+
#[skip="8.20"] Proof.
17+
#[skip="8.20"] intros H. rewrite -(of_to_list s1) -(of_to_list s2) H.
18+
#[skip="8.20"] reflexivity.
19+
#[skip="8.20"] Qed.
20+
#[skip="8.20"] Lemma compare_eq_correct (s1 s2 : string) :
21+
#[skip="8.20"] compare s1 s2 = Eq -> s1 = s2.
22+
#[skip="8.20"] Proof.
23+
#[skip="8.20"] move=> E; rewrite -[s1]of_to_list -[s2]of_to_list; congr (of_list _).
24+
#[skip="8.20"] move: E; rewrite compare_spec.
25+
#[skip="8.20"] elim: (to_list s1) (to_list s2) => [[]//|x xs IH [|y ys] //=].
26+
#[skip="8.20"] rewrite Uint63Axioms.compare_def_spec /compare_def.
27+
#[skip="8.20"] move: (eqb_correct x y); case: eqb => [/(_ isT)->|_].
28+
#[skip="8.20"] suff: ltb y y = false by move=> -> /IH ->.
29+
#[skip="8.20"] have [+ _] := ltb_spec y y.
30+
#[skip="8.20"] by case: ltb => // /(_ isT); case: (to_Z y) => //=; elim.
31+
#[skip="8.20"] by case: ltb.
32+
#[skip="8.20"] Qed.
33+
#[skip="8.20"] Lemma compare_ok (s1 s2 : string) : compare s1 s2 = Eq <-> s1 = s2.
34+
#[skip="8.20"] Proof. split; [apply compare_eq_correct|intros []; apply compare_refl]. Qed.

0 commit comments

Comments
 (0)