closes#1175
The types `string_imp` and `string.iterator_imp` were supposed to be
marked private, but we cannot do it because we need to provide
`string_imp.mk`, `string_imp.cases_on`, `string.iterator_imp.mk` and
`string.iterator_imp.cases_on` in the VM since we use a different
internal representation. Note that marking them as private does not
work since users can still access `string_imp.cases_on` using
meta-programming.
So, we need better support for private declarations.
Missing feature, char literals do not support non ASCII values.
That is, in the current implementation, we cannot write 'α'.
This will be implemented in the future.
The VM native implementation does not behave correctly for huge
strings (i.e., strings with more than 4G characters).
The problem is that the current implementation relies on
```
size_t force_to_size_t(vm_obj const & o, size_t def)
```
We may also have overflow problems in the string.iterator implementation
code. This is not a big deal right now, since I doubt we will try
to process string with more than 2^32 characters.
@Kha the `core_lib` and tests seem to be working correctly, but
we need more tests.
Remarks:
- Some tests do not produce error messages anymore because they can be
processed using the new equation compiler preprocessor.
- Some error messages got worse because of the preprocessing step.
We use metavariables in the preprocessing step. This information
may "leak" to users. Another problem is that some variable names
are lost. Example: in the following definition
def to_nat : ∀ {n}, fi n → nat
| (succ n) f0 := 0
| (succ n) (fs i) := succ (to_nat i)
The preprocessing step uses metavariables for pattern variables.
Thus, we have
def to_nat : ∀ {n}, fi n → nat
| (succ ?n) (@f0 ?x) := 0
| (succ ?n) (@fs ?x ?i) := succ (to_nat i)
when solving the constraint `succ ?n =?= succ ?x`, Lean assigns
?n := ?x
after solving these constraints, the preprocessor converts
metavariables into pattern variables again, and we have
def to_nat : ∀ {n}, fi n → nat
| (succ x) (@f0 x) := 0
| (succ x) (@fs x i) := succ (to_nat i)
So, we get the following equation lemmas:
to_nat.equations._eqn_1 : ∀ (x : ℕ), @to_nat (succ x) (@f0 x) = 0
to_nat.equations._eqn_2 : ∀ (x : ℕ) (i : fi x), @to_nat (succ x) (@fs x i) = succ (@to_nat x i)
instead of
to_nat.equations._eqn_1 : ∀ (n : ℕ), @to_nat (succ n) (@f0 n) = 0
to_nat.equations._eqn_2 : ∀ (n : ℕ) (i : fi n), @to_nat (succ n) (@fs n i) = succ (@to_nat n i)
See issue #1175
BTW, we may have to revise this decision in the future when we decide to
populate the string library with lemmas.
It is inconvenient to prove the lemmas at string/basic.lean since the
tactic framework has not been defined yet.
Anyway, I think it is worth to keep the private for now, and make sure
nobody relies on its implementation.