verifythis_2015_relatex_prefix: simplified source code

parent a62ff0e8
......@@ -94,17 +94,13 @@ module RelaxedPrefix
ofs1 + len <= length a1 /\ ofs2 + len <= length a2 /\
forall i: int. 0 <= i < len -> a1[ofs1 + i] = a2[ofs2 + i]
(** The target property. Note that this definition imposes the
index of the character which is ignored (index [i] in the existential
quantifier). It simplifies our proof, but a looser definition would
be possible (see the comment at the end of this file). *)
(** The target property. *)
predicate is_relaxed_prefix (pat a: array char) =
let n = length pat in
eq_array pat 0 a 0 n
\/ exists i: int. 0 <= i < n /\
eq_array pat 0 a 0 i /\
(* (i = length a \/ pat[i] <> a[i]) /\*)
eq_array pat (i+1) a i (n - i - 1)
(** This exception is used to exit the loop as soon as the target
......@@ -136,10 +132,10 @@ module RelaxedPrefix
(!ignored < m -> pat[!ignored] <> a[!ignored]) }
if i - !shift >= m || pat[i] <> a[i - !shift] then begin
if !shift = 1 then begin
assert { forall j. eq_array pat 0 a 0 j /\
assert { forall j. eq_array pat 0 a 0 j ->
eq_array pat (j+1) a j (n-j-1) ->
(!ignored > j -> pat[j+1+(i-j-1)] = a[j+(i-j-1)] && false)
&& false };
!ignored > j -> pat[j+1+(i-j-1)] = a[j+(i-j-1)]
};
raise NoPrefix
end;
ignored := i;
......@@ -151,19 +147,4 @@ module RelaxedPrefix
False
end
(** a simpler definition of [is_relaxed_prefix] would be the following: *)
predicate simple_is_relaxed_prefix (pat a: array char) =
let n = length pat in
eq_array pat 0 a 0 n
\/ exists i: int. 0 <= i < n /\
eq_array pat 0 a 0 i /\
eq_array pat (i+1) a i (n - i - 1)
(* TODO: prove the equivalence
lemma equivalence:
forall pat a: array char.
is_relaxed_prefix pat a <-> simple_is_relaxed_prefix pat a
*)
end
......@@ -4,101 +4,89 @@
<why3session shape_version="4">
<prover id="1" name="Alt-Ergo" version="0.99.1" timelimit="6" memlimit="1000"/>
<prover id="2" name="Z3" version="4.3.1" timelimit="6" memlimit="1000"/>
<file name="../verifythis_2015_relaxed_prefix.mlw">
<theory name="RelaxedPrefix" sum="39e24d0606ef6c014ef1ff9b3a7d8f29">
<goal name="WP_parameter is_relaxed_prefix" expl="VC for is_relaxed_prefix">
<transf name="split_goal_wp">
<goal name="WP_parameter is_relaxed_prefix.1" expl="1. postcondition">
<file name="../verifythis_2015_relaxed_prefix.mlw" expanded="true">
<theory name="RelaxedPrefix" sum="8b7f0d83946a7a83195b54026027b10b" expanded="true">
<goal name="WP_parameter is_relaxed_prefix" expl="VC for is_relaxed_prefix" expanded="true">
<transf name="split_goal_wp" expanded="true">
<goal name="WP_parameter is_relaxed_prefix.1" expl="1. postcondition" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="7"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.2" expl="2. loop invariant init">
<goal name="WP_parameter is_relaxed_prefix.2" expl="2. loop invariant init" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="3"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.3" expl="3. loop invariant init">
<goal name="WP_parameter is_relaxed_prefix.3" expl="3. loop invariant init" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="3"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.4" expl="4. loop invariant init">
<goal name="WP_parameter is_relaxed_prefix.4" expl="4. loop invariant init" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="3"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.5" expl="5. loop invariant init">
<goal name="WP_parameter is_relaxed_prefix.5" expl="5. loop invariant init" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="6"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.6" expl="6. assertion">
<transf name="split_goal_wp">
<goal name="WP_parameter is_relaxed_prefix.6.1" expl="1. assertion">
<goal name="WP_parameter is_relaxed_prefix.6" expl="6. assertion" expanded="true">
<transf name="split_goal_wp" expanded="true">
<goal name="WP_parameter is_relaxed_prefix.6.1" expl="1. assertion" expanded="true">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="20"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.6.2" expl="2. assertion">
<proof prover="1" timelimit="5"><result status="valid" time="0.03" steps="20"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.6.3" expl="3. assertion">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="19"/></proof>
</goal>
</transf>
</goal>
<goal name="WP_parameter is_relaxed_prefix.7" expl="7. postcondition">
<goal name="WP_parameter is_relaxed_prefix.7" expl="7. postcondition" expanded="true">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="44"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.8" expl="8. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.8" expl="8. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="12"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.9" expl="9. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.9" expl="9. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="12"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.10" expl="10. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.10" expl="10. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="12"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.11" expl="11. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.11" expl="11. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.03" steps="26"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.12" expl="12. index in array bounds">
<goal name="WP_parameter is_relaxed_prefix.12" expl="12. index in array bounds" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="11"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.13" expl="13. index in array bounds">
<goal name="WP_parameter is_relaxed_prefix.13" expl="13. index in array bounds" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="11"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.14" expl="14. assertion">
<transf name="split_goal_wp">
<goal name="WP_parameter is_relaxed_prefix.14.1" expl="1. assertion">
<goal name="WP_parameter is_relaxed_prefix.14" expl="14. assertion" expanded="true">
<transf name="split_goal_wp" expanded="true">
<goal name="WP_parameter is_relaxed_prefix.14.1" expl="1. assertion" expanded="true">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="49"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.14.2" expl="2. assertion">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="18"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.14.3" expl="3. assertion">
<proof prover="1" timelimit="5"><result status="valid" time="0.03" steps="49"/></proof>
</goal>
</transf>
</goal>
<goal name="WP_parameter is_relaxed_prefix.15" expl="15. postcondition">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="73"/></proof>
<goal name="WP_parameter is_relaxed_prefix.15" expl="15. postcondition" expanded="true">
<proof prover="1" timelimit="5"><result status="valid" time="0.02" steps="108"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.16" expl="16. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.16" expl="16. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="15"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.17" expl="17. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.17" expl="17. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="15"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.18" expl="18. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.18" expl="18. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="15"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.19" expl="19. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.19" expl="19. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.10" steps="50"/></proof>
<proof prover="2"><result status="valid" time="0.01"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.20" expl="20. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.20" expl="20. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.02" steps="12"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.21" expl="21. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.21" expl="21. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="15"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.22" expl="22. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.22" expl="22. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.01" steps="12"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.23" expl="23. loop invariant preservation">
<goal name="WP_parameter is_relaxed_prefix.23" expl="23. loop invariant preservation" expanded="true">
<proof prover="1"><result status="valid" time="0.08" steps="115"/></proof>
</goal>
<goal name="WP_parameter is_relaxed_prefix.24" expl="24. postcondition">
<goal name="WP_parameter is_relaxed_prefix.24" expl="24. postcondition" expanded="true">
<proof prover="1"><result status="valid" time="0.00" steps="35"/></proof>
</goal>
</transf>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment