Library Stdlib.Strings.PString
From Stdlib Require Import Uint63.
From Stdlib Require Export PrimString.
From Stdlib Require Export PrimStringAxioms.
From Stdlib.micromega Require Import Lia.
From Stdlib.micromega Require Import ZifyUint63.
From Stdlib.micromega Require Import Zify.
From Stdlib Require Import Ring63.
From Stdlib Require Import ZArith.
#[
local]
Open Scope Z_scope.
#[
local]
Open Scope list_scope.
#[
local]
Arguments to_Z _/ :
simpl nomatch.
#[
local]
Instance Op_max_length :
ZifyClasses.CstOp max_length :=
{
TCst := 16777211%
Z ;
TCstInj :=
eq_refl }.
Add Zify CstOp Op_max_length.
#[
local]
Ltac case_if :=
lazymatch goal with
| |-
context C [
if ?
b then _ else _] =>
destruct b eqn:?
|
H :
context C [
if ?
b then _ else _] |-
_ =>
destruct b eqn:?
end.
Derived properties of to_list and of_list.
Alternative specifications with explicit bounds.
Properties of string length
Properties of string comparison
Lemma char63_compare_refl (
c1 c2 :
char63) :
char63_compare c1 c2 = Eq <-> c1 = c2.
Lemma char63_compare_antisym (
c1 c2 :
char63) :
char63_compare c2 c1 = CompOpp (
char63_compare c1 c2).
Lemma char63_compare_trans (
c1 c2 c3 :
char63) (
c :
comparison) :
char63_compare c1 c2 = c -> char63_compare c2 c3 = c -> char63_compare c1 c3 = c.
Lemma compare_refl (
s :
string) :
compare s s = Eq.
Lemma compare_antisym (
s1 s2 :
string) :
compare s2 s1 = CompOpp (
compare s1 s2).
Lemma compare_trans (
c :
comparison) (
s1 s2 s3 :
string) :
compare s1 s2 = c -> compare s2 s3 = c -> compare s1 s3 = c.
Lemma compare_eq_correct (
s1 s2 :
string) :
compare s1 s2 = Eq -> s1 = s2.
Lemma string_eq_ext (
s1 s2 :
string) :
(length s1 = length s2 /\
forall i,
to_Z i < to_Z (
length s1)
-> get s1 i = get s2 i) ->
s1 = s2.
Lemma to_list_firstn_skipn_middle (
s :
string) (
i :
int) :
to_Z i < to_Z (
length s)
->
to_list s = List.firstn (
to_nat i) (
to_list s)
++
get s i :: List.skipn (
to_nat (
i + 1)) (
to_list s).
Lemma compare_spec (
s1 s2 :
string) (
c :
comparison) :
compare s1 s2 = c <->
exists i,
to_Z i <= to_Z (
length s1)
/\
to_Z i <= to_Z (
length s2)
/\
(forall j,
to_Z j < to_Z i -> get s1 j = get s2 j) /\
match (i =? length s1, i =? length s2)%
uint63 with
|
(true , true ) =>
c = Eq
|
(true , false) =>
c = Lt
|
(false, true ) =>
c = Gt
|
(false, false) =>
match Uint63.compare (
get s1 i) (
get s2 i)
with
|
Eq =>
False
|
ci =>
c = ci
end
end.
Lemma compare_eq (
s1 s2 :
string) :
compare s1 s2 = Eq <-> s1 = s2.
Lemma compare_lt_spec (
s1 s2 :
string) :
compare s1 s2 = Lt <->
exists i,
to_Z i <= to_Z (
length s1)
/\
to_Z i <= to_Z (
length s2)
/\
(forall j,
to_Z j < to_Z i -> get s1 j = get s2 j) /\
((i = length s1 /\ to_Z i < to_Z (
length s2)
) \/
(to_Z i < to_Z (
length s1)
/\
to_Z i < to_Z (
length s2)
/\
char63_compare (
get s1 i) (
get s2 i)
= Lt)).
Properties of to_list and of_list