From b40dba72b79daeaa9f6e462c55de942706445b2f Mon Sep 17 00:00:00 2001 From: Christoph Fuerst Date: Thu, 20 Apr 2017 17:31:05 +0200 Subject: [PATCH] Update after second Review Wolfgang --- discrete_log.txt | 2 ++ sieveEratosthenes.txt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/discrete_log.txt b/discrete_log.txt index 13ad706..3193ae5 100644 --- a/discrete_log.txt +++ b/discrete_log.txt @@ -43,6 +43,7 @@ proc IntegerRoot(a:nat): nat while y ≤ a do invariant x^2 ≤ a ∧ y = x^2+z ∧ z = 2*x+1; + decreases a-x^2; { x=x+1; z=z+2; @@ -98,3 +99,4 @@ proc DiscreteLog(p:prime,g:nat,a:nat): res + diff --git a/sieveEratosthenes.txt b/sieveEratosthenes.txt index 6b27a8a..a26805b 100644 --- a/sieveEratosthenes.txt +++ b/sieveEratosthenes.txt @@ -14,6 +14,7 @@ proc IntegerRoot(a:nat): nat while y ≤ a do invariant x^2 ≤ a ∧ y = x^2+z ∧ z = 2*x+1; + decreases a-x^2; { x=x+1; z=z+2; @@ -48,11 +49,13 @@ proc SieveOfErathostenes(m:nat): Array[MAX,Bool] proc SetMin(s:Set[nat]): nat requires s ≠ ∅[nat]; + requires ∀e ∈ s. e ≤ MAX; ensures result ∈ s ∧ ∀e ∈ s. result ≤ e; { var ret:nat := MAX; for x in s do + invariant ∀e in forSet. ret ≤ e; { if x < ret then { @@ -67,6 +70,8 @@ fun SetMin2(s:Set[nat]): nat ensures result ∈ s ∧ ∀e ∈ s. result ≤ e; = choose m in s with ∀e in s. m <= e; +theorem PrimeDivisor() ⇔ ∀e:nat. (e > 1 ∧ ¬isPrime(e)) ⇒ ∃p:nat. p