Theory MachineEquations
section ‹Arithmetization of Register Machines›
subsection ‹A first definition of the arithmetizing equations›
theory MachineEquations
imports MultipleStepRegister MultipleStepState MachineMasking
begin
definition mask_equations :: "nat ⇒ (register ⇒ nat) ⇒ (register ⇒ nat)
⇒ nat ⇒ nat ⇒ nat ⇒ nat ⇒ bool"
where "(mask_equations n r z c d e f) = ((∀l<n. (r l) ≼ d)
∧ (∀l<n. (z l) ≼ e)
∧ (∀l<n. 2^c * (z l) = (r l + d) && f))"
definition reg_equations :: "program ⇒ (register ⇒ nat) ⇒ (register ⇒ nat) ⇒ (state ⇒ nat)
⇒ nat ⇒ nat ⇒ nat ⇒ nat ⇒ bool" where
"(reg_equations p r z s b a n q) = (
(∀l>0. l < n ⟶ r l = b*r l + b*∑R+ p l (λk. s k) - b*∑R- p l (λk. s k && z l))
∧ ( r 0 = a + b*r 0 + b*∑R+ p 0 (λk. s k) - b*∑R- p 0 (λk. s k && z 0))
∧ (∀l<n. r l < b ^ q)) "
definition state_equations :: "program ⇒ (state ⇒ nat) ⇒ (register ⇒ nat) ⇒
nat ⇒ nat ⇒ nat ⇒ nat ⇒ bool" where
"state_equations p s z b e q m = (
(∀d>0. d≤m ⟶ s d = b*∑S+ p d (λk. s k) + b*∑S- p d (λk. s k && z (modifies (p!k)))
+ b*∑S0 p d (λk. s k && (e - z (modifies (p!k)))))
∧ ( s 0 = 1 + b*∑S+ p 0 (λk. s k) + b*∑S- p 0 (λk. s k && z (modifies (p!k)))
+ b*∑S0 p 0 (λk. s k && (e - z (modifies (p!k)))))
∧ (s m = b^q)
∧ (∀k≤m. s k ≼ e) ∧ (∀k<m. s k < b ^ q)
∧ (∀M≤m. (∑k≤M. s k) ≼ e) )"
definition state_unique_equations :: "program ⇒ (state⇒nat) ⇒ nat ⇒ nat ⇒bool" where
"state_unique_equations p s m e = ((∑k=0..m. s k) ≼ e ∧ (∀k≤m. s k ≼ e))"
definition rm_constants :: "nat ⇒ nat ⇒ nat ⇒ nat ⇒ nat ⇒ nat ⇒ nat ⇒ bool" where
"rm_constants q c b d e f a = (
(b = B c)
∧ (d = D q c b)
∧ (e = E q b)
∧ (f = F q c b)
∧ c > 0
∧ (a < 2^c) ∧ (q>0))"
definition rm_equations_old :: "program ⇒ nat ⇒ nat ⇒ nat ⇒ bool" where
"rm_equations_old p q a n = (
∃ b c d e f :: nat.
∃ r z :: register ⇒ nat.
∃ s :: state ⇒ nat.
mask_equations n r z c d e f
∧ reg_equations p r z s b a n q
∧ state_equations p s z b e q (length p - 1)
∧ rm_constants q c b d e f a)"
end