@@ -235,7 +235,7 @@ theorem fib_triple : ⦃⌜True⌝⦄ fib_impl n ⦃⇓ r => ⌜r = fib_spec n
235235 if h : n = 0 then simp [h] else
236236 simp only [h, reduceIte]
237237 mspec -- Spec.pure
238- mspec Spec.forIn_range (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.prefix.length ∧ b = fib_spec (xs.prefix.length + 1 )⌝) ?step
238+ mspec Spec.forIn_range (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.pos ∧ b = fib_spec (xs.pos + 1 )⌝) ?step
239239 case step => intros; mintro _; simp_all
240240 simp_all [Nat.sub_one_add_one]
241241
@@ -246,7 +246,7 @@ theorem fib_triple_cases : ⦃⌜True⌝⦄ fib_impl n ⦃⇓ r => ⌜r = fib_sp
246246 mintro -
247247 simp only [fib_impl, h, reduceIte]
248248 mspec
249- mspec Spec.forIn_range (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.prefix.length ∧ b = fib_spec (xs.prefix.length + 1 )⌝) ?step
249+ mspec Spec.forIn_range (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.pos ∧ b = fib_spec (xs.pos + 1 )⌝) ?step
250250 case step => intros; mintro _; mspec; mspec; simp_all
251251 simp_all [Nat.sub_one_add_one]
252252
@@ -279,7 +279,7 @@ theorem fib_impl_vcs
279279
280280theorem fib_triple_vcs : ⦃⌜True⌝⦄ fib_impl n ⦃⇓ r => ⌜r = fib_spec n⌝⦄ := by
281281 apply fib_impl_vcs
282- case I => intro n hn; exact (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.prefix.length ∧ b = fib_spec (xs.prefix.length + 1 )⌝)
282+ case I => intro n hn; exact (⇓ ⟨xs, a, b⟩ => ⌜a = fib_spec xs.pos ∧ b = fib_spec (xs.pos + 1 )⌝)
283283 case ret => mpure_intro; rfl
284284 case loop_pre => intros; mpure_intro; trivial
285285 case loop_post => simp_all [Nat.sub_one_add_one]
@@ -365,14 +365,14 @@ theorem fib_triple : ⦃⌜True⌝⦄ fib_impl n ⦃⇓ r => ⌜r = fib_spec n
365365 unfold fib_impl
366366 mvcgen
367367 case inv1 => exact ⇓ (xs, ⟨a, b⟩) =>
368- ⌜a = fib_spec xs.prefix.length ∧ b = fib_spec (xs.prefix.length + 1 )⌝
368+ ⌜a = fib_spec xs.pos ∧ b = fib_spec (xs.pos + 1 )⌝
369369 all_goals simp_all +zetaDelta [Nat.sub_one_add_one]
370370
371371theorem fib_triple_step : ⦃⌜True⌝⦄ fib_impl n ⦃⇓ r => ⌜r = fib_spec n⌝⦄ := by
372372 unfold fib_impl
373373 mvcgen (stepLimit := some 14 ) -- 13 still has a wp⟦·⟧
374374 case inv1 => exact ⇓ ⟨xs, a, b⟩ =>
375- ⌜a = fib_spec xs.prefix.length ∧ b = fib_spec (xs.prefix.length + 1 )⌝
375+ ⌜a = fib_spec xs.pos ∧ b = fib_spec (xs.pos + 1 )⌝
376376 all_goals simp_all +zetaDelta [Nat.sub_one_add_one]
377377
378378attribute [local spec] fib_triple in
@@ -674,7 +674,7 @@ def max_and_sum (xs : Array Nat) : Id (Nat × Nat) := do
674674theorem max_and_sum_spec (xs : Array Nat) :
675675 ⦃⌜∀ i, (h : i < xs.size) → xs[i] ≥ 0 ⌝⦄ max_and_sum xs ⦃⇓ (m, s) => ⌜s ≤ m * xs.size⌝⦄ := by
676676 mvcgen [max_and_sum]
677- case inv1 => exact (⇓ ⟨xs, m, s⟩ => ⌜s ≤ m * xs.prefix.length ⌝)
677+ case inv1 => exact (⇓ ⟨xs, m, s⟩ => ⌜s ≤ m * xs.pos ⌝)
678678 all_goals simp_all
679679 · rw [Nat.left_distrib]
680680 simp +zetaDelta only [Nat.mul_one, Nat.add_le_add_iff_right]
@@ -821,14 +821,14 @@ theorem naive_expo_correct (x n : Nat) : naive_expo x n = x^n := by
821821 generalize h : naive_expo x n = r
822822 apply Id.of_wp_run_eq h
823823 mvcgen
824- case inv1 => exact ⇓⟨xs, r⟩ => ⌜r = x^xs.prefix.length ⌝
824+ case inv1 => exact ⇓⟨xs, r⟩ => ⌜r = x^xs.pos ⌝
825825 all_goals simp_all [Nat.pow_add_one]
826826
827827theorem fast_expo_correct (x n : Nat) : fast_expo x n = x^n := by
828828 generalize h : fast_expo x n = r
829829 apply Id.of_wp_run_eq h
830830 mvcgen
831- case inv1 => exact ⇓⟨xs, e, x', y⟩ => ⌜x' ^ e * y = x ^ n ∧ e ≤ n - xs.prefix.length ⌝
831+ case inv1 => exact ⇓⟨xs, e, x', y⟩ => ⌜x' ^ e * y = x ^ n ∧ e ≤ n - xs.pos ⌝
832832 all_goals simp_all
833833 case vc1 b _ _ _ _ _ _ ih =>
834834 obtain ⟨e, y, x'⟩ := b
0 commit comments