As a review question I have to prove that the decryption process of counter mode is correct. How do you prove it? No other information is given.
Encryption: Cj = E(K, Counter + j -1) ⊕ Pj
Decryption: Pj = E(K, Counter + j -1) ⊕ Cj
Pj = E(K, Counter + j -1) ⊕ Cj
Replace Cj = E(K, Counter + j -1) ⊕ Pj
Cj = E(K, Counter + j -1) ⊕ E(K, Counter + j -1) ⊕ Pj
Since x⊕x=0 (the encrypted counter is xored with itself) and 0⊕x=x
Pj = 0 ⊕ Pj
Pj = Pj
QED
Related
In the subgoal of the proof, the premise uses variable modified by a universal quantifier, and the conclusion instantiates the universal quantifier to a concrete value. What strategies can be used for such proofs?
[enter image description here][1][enter image description here][2]
The following two examples:
the first example,in the conclusion variable i is replaced by 1;
Second example,In the conclusion the variable i is replaced by i +1 and j is replaced by 2.
⋀m s a i j r k t.
((i = j ∧ m ! i ! j = 0 ∨
i < j ∧ m ! i ! j = Min (⋃k∈{i..<j}. {m ! i ! k + m ! (k + 1) ! j + a ! (i - 1) * a ! i
a ! j})) ∧
1 ≤ r ∧ r < length m ∧ 1 ≤ i ∧ i < length m - r + 1 ∧ j = i + r - 1) ∧
r ≤ length m - 1 ⟹
1 = j ∧ m ! 1 ! j = 0 ∨
1 < j ∧ m ! 1 ! j = Min (⋃k∈{1..<j}. {m ! 1 ! k + m ! (k + 1) ! j + a ! (1 - 1) * a ! 1 *
a ! j})
⋀L A B i j.
((A ! (i - 1) = B ! (j - 1) ∧ L ! (i - 1) ! (j - 1) = L ! (i - 2) ! (j - 2) + 1 ∨
A ! (i - 1) ≠ B ! (j - 1) ∧ L ! (i - 1) ! (j - 1) = max (L ! (i - 1) ! (j - 2)) (L ! (i
! (j - 1)))
∧2 ≤ i
∧i < length L
∧2 ≤ j ∧ j ≤ length (L ! (i - 1)) ∧ (∀k<length L. length (L ! k) = length (L ! (k - 1))
∧ 2 ≤ length (L ! k)))
∧ ¬ j ≤ length (L ! i) - 1 ⟹
A ! (i + 1 - 1) = B ! (2 - 1) ∧ L ! (i + 1 - 1) ! (2 - 1) = L ! (i + 1 - 2) ! (2 - 2) + 1
∨
A ! (i + 1 - 1) ≠ B ! (2 - 1) ∧
L ! (i + 1 - 1) ! (2 - 1) = max (L ! (i + 1 - 1) ! (2 - 2)) (L ! (i + 1 - 2) ! (2 - 1))
(x XOR a) + (x XOR b) + (x XOR c)
Can we simplify this further?
Here '+' is addition not a logical disjunction.
x, a, b, c are numbers.
Example :
x = 10 , a = 5 , b = 4 , c = 6
(10 XOR 5) + (10 XOR 4) + (10 XOR 6) = 41.
On this documentation, it is mentioned how replace could be used to complete the proof, but it ends up using rewrite, which seems to be a syntax sugar that writes replace for you. I'm interested in understanding how to use it explicitly.
If I understand correctly, it could be used to rewrite S k = S (plus k 0) as S (plus k 0) = S (plus k 0), given a proof that k = plus k 0, which would then be provable by reflexivity. But if we instance it as replace {P = \x => S x = S (plus k 0)} {x = k} {y = plus k 0} rec, we'll now need a proof of S k = S (plus k 0), which is what we wanted to prove to begin with. In short, I'm not sure what exactly P should be.
Ah, it is fairly obvious in retrospect. If we let:
P = \x => S x = S (plus k 0)
Then, we can prove it for x = (plus k 0) (by reflexivity). Now, if we let y = k, then, by using replace, we gain a proof of S k = S (plus k 0), which is what we need. Or, in other words:
plusCommZ : (m : Nat) -> m = plus m 0
plusCommZ Z = Refl
plusCommZ (S k) = replace
{P = \x => S x = S (plus k 0)}
{x = plus k 0}
{y = k}
(sym (plusCommZ k))
Refl
Completes the proof. We could do it the other way around with P = \x => S x = S k.
I have a function f(n) defined as follows:
f(n) = (n-1)(n+1)lg(n+5)/(n+3)
Here, lg is log2. I'd like to determine the big-O, big-Ω, and big-Θ values for this function. How would I go about approaching this?
Thanks!
Let's start off by simplifying your expression:
f(n) = (n-1)(n+1)lg(n+5)/(n+3)
= ((n2 - 1) lg (n + 5)) / (n + 3)
For now, let's pretend that the additive constants are there. If we delete those constants, we get this function g(n):
g(n) = n2 lg n / n = n lg n
Since we don't expect those constants to make all that much of a difference in the long term, it's reasonable to venture a guess that this function is Θ(n log n). We can prove this by taking the limit of f(n) / n log n as n tends toward infinity. If we get back a nonzero finite value, then we known that f(n) = Θ(n log n).
So let's try it!
limn → ∞ f(n) / n log n
= limn → ∞ (((n2 - 1) lg (n + 5)) / (n + 3)) / n lg n
= limn → ∞ ((n2 - 1) lg (n + 5)) / n lg n (n + 3)
= (limn → ∞ (n2 - 1) / n(n+3)) (limn → ∞ (lg (n + 5) / lg n)
= (limn → ∞ (n2 - 1) / (n2 + n)) (limn → ∞ (lg (n + 5) / lg n)
Both of these limits are degenerate forms of type ∞ / ∞, so we can use l'Hopital's rule and replace each with its derivative:
limn → ∞ (n2 - 1) / (n2 + n)
= limn → ∞ (2n / 2n + 1)
= 1
and
limn → ∞ lg (n + 5) / lg n
= limn → ∞ (1 / (n+5)) / (1 / n)
= limn → ∞ (n / (n+5))
= 1
Therefore, we get
(limn → ∞ (n2 - 1) / (n2 + n)) (limn → ∞ (lg (n + 5) / lg n)
= 1
Consequently, the ratio of f(n) / n lg n tends toward 1 as n goes to infinity, and so we have that f(n) = Θ(n log n), as required. Because of this, we also get that f(n) = O(n log n) and f(n) = Ω(n log n). We also have that f(n) ~ n log n, which is a much stronger claim.
Hope this helps!
I am trying to find the modulo of an expression. All I know is that
(a+b) mod N = ((a mod N) + (b mod N)) mod N
How do I use it to simplify the following modulo operation?
(a - 2*b + 1) mod N
There must be some way to simplify it by considering it as
(a - b - b + 1) mod N ?
EDIT:
I have stumbled upon the following property too:
ab mod N = ((a mod N) (b mod N)) mod N
Will this be helpful somehow?
If: (a+b) mod N = ((a mod N) + (b mod N)) mod N
then:
(a - 2*b + 1) mod N = ((a mod N) - (b mod N) - (b mod N) + (1 mod N)) mod N
It is simpler with large values of a and b and a small value for N.
For example: a=85773, b = 77733340, N=5:
which would you rather solve
(85773 - 77733340 - 77733340 + 1) mod 5
or
((85773 mod 5) - (77733340 mod 5) - (77733340 mod 5) + (1 mod 5)) mod 5
for the second one i get (3 - 0 - 0 + 1) % 5 = 4
There is no way to simplify (b*-2 + a + 1) % n unfortunately.