computing with infinite data via proofs
play

Computing with infinite data via proofs Helmut Schwichtenberg, - PowerPoint PPT Presentation

Computing with infinite data via proofs Helmut Schwichtenberg, Hideki Tsuiki and Franziskus Wiesnet (with help by Quirin Scholl) June 28, 2017 1 / 15 Signed Digit Representation of Reals 2 / 15 Signed Digit Representation of Reals A real


  1. Computing with infinite data via proofs Helmut Schwichtenberg, Hideki Tsuiki and Franziskus Wiesnet (with help by Quirin Scholl) June 28, 2017 1 / 15

  2. Signed Digit Representation of Reals 2 / 15

  3. Signed Digit Representation of Reals A real number x ∈ [ − 1 , 1] can be wirtten as stream of signed digits ∞ d i � x = 2 i = d 1 d 2 d 3 . . . i =1 where d i ∈ Sd := { 1 , 0 , 1 } . We write co I x or x ∈ co I for “ x has a SD representation”. 2 / 15

  4. Signed Digit Representation of Reals A real number x ∈ [ − 1 , 1] can be wirtten as stream of signed digits ∞ d i � x = 2 i = d 1 d 2 d 3 . . . i =1 where d i ∈ Sd := { 1 , 0 , 1 } . We write co I x or x ∈ co I for “ x has a SD representation”. Our goals are algorithms for the arithmetic functions especially the arithmetic mean and the division. 2 / 15

  5. Formalisation of the Signed Digit Representation 3 / 15

  6. Formalisation of the Signed Digit Representation Reflection: If a real number x has an SD representation, there is a signed digit d and a real number x ′ which also has a SD representation such that x = d + x ′ 2 . 3 / 15

  7. Formalisation of the Signed Digit Representation Reflection: If a real number x has an SD representation, there is a signed digit d and a real number x ′ which also has a SD representation such that x = d + x ′ 2 . So we have the following elimination axiom of co I : Sd d ∧ co I x ′ ∧ | x | ≤ 1 ∧ x = x ′ + d � � ∀ nc x . co I x → ∃ d , x ′ 2 3 / 15

  8. Formalisation of the Signed Digit Representation Reflection: If a real number x has an SD representation, there is a signed digit d and a real number x ′ which also has a SD representation such that x = d + x ′ 2 . So we have the following elimination axiom of co I : Sd d ∧ co I x ′ ∧ | x | ≤ 1 ∧ x = x ′ + d � � ∀ nc x . co I x → ∃ d , x ′ 2 The SD representation of a real is an infinit list of signed digeds. The datatyp of a stream is therefore data Sd = SdL | SdM | SdR data Str = Sd :~: Str 3 / 15

  9. Formalisation of the Signed Digit Representation Reflection: If a real number x has an SD representation, there is a signed digit d and a real number x ′ which also has a SD representation such that x = d + x ′ 2 . So we have the following elimination axiom of co I : Sd d ∧ co I x ′ ∧ | x | ≤ 1 ∧ x = x ′ + d � � ∀ nc x . co I x → ∃ d , x ′ 2 The SD representation of a real is an infinit list of signed digeds. The datatyp of a stream is therefore data Sd = SdL | SdM | SdR data Str = Sd :~: Str Using the elimination axiom co I corresponds to the application of the destructor strDestr :: Str -> (Sd, Str) strDestr (d :~: str) = (d, str) 3 / 15

  10. If we want to prove that a real number x has a SD representation, we have to give an algorithm which provides the digeds of x . 4 / 15

  11. If we want to prove that a real number x has a SD representation, we have to give an algorithm which provides the digeds of x . The introduction axiom of co I is ∀ nc x . Xx → � � Sd d ∧ ( co I x ′ ∨ Xx ′ ) ∧ | x | ≤ 1 ∧ x = d + x ′ �� ∀ nc Xx → ∃ r x d , x ′ 2 → co I x . 4 / 15

  12. If we want to prove that a real number x has a SD representation, we have to give an algorithm which provides the digeds of x . The introduction axiom of co I is ∀ nc x . Xx → � � Sd d ∧ ( co I x ′ ∨ Xx ′ ) ∧ | x | ≤ 1 ∧ x = d + x ′ �� ∀ nc Xx → ∃ r x d , x ′ 2 → co I x . strCoRec :: t -> (t -> (Sd, Either Str t)) -> Str strCoRec t f = let (d, strt) = f t in d :~: case strt of Left str -> str Right t0 -> strCoRec t0 f 4 / 15

  13. Lemma Every real between − 1 and 1 has a SD representation. Proof. 5 / 15

  14. Lemma Every real between − 1 and 1 has a SD representation. Proof. We use the introduction axiom of co I with the predicate Xx := ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) and have to prove: ∀ nc x . ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) → � Sd d ∧ ( co I x ′ ∨ Xx ′ ) ∧ | x | ≤ 1 ∧ x = d + x ′ � ∃ r d , x ′ 2 5 / 15

  15. Lemma Every real between − 1 and 1 has a SD representation. Proof. We use the introduction axiom of co I with the predicate Xx := ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) and have to prove: ∀ nc x . ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) → � Sd d ∧ ( co I x ′ ∨ Xx ′ ) ∧ | x | ≤ 1 ∧ x = d + x ′ � ∃ r d , x ′ 2 Let therefore x, y and x = y ∧ − 1 ≤ y ≤ 1 be given. Define � as , M � := y then we distinguish the following three cases: 5 / 15

  16. Lemma Every real between − 1 and 1 has a SD representation. Proof. We use the introduction axiom of co I with the predicate Xx := ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) and have to prove: ∀ nc x . ∃ y ( y = x ∧ − 1 ≤ y ≤ 1) → � Sd d ∧ ( co I x ′ ∨ Xx ′ ) ∧ | x | ≤ 1 ∧ x = d + x ′ � ∃ r d , x ′ 2 Let therefore x, y and x = y ∧ − 1 ≤ y ≤ 1 be given. Define � as , M � := y then we distinguish the following three cases: If as (2) ≤ − 1 4 it follows y ≤ 0 and therefore we define d := − 1 and x ′ := 2 x + 1 . If as (2) ≥ 1 4 it follows y ≥ 0 and therefore we define d := 1 and x ′ := 2 x − 1 . 2 and define d := 0 and x ′ := 2 x. Otherwise we get − 1 2 ≤ y ≤ 1 5 / 15

  17. RealToStream :: Rea -> Str RealToStream x0 = strCoRec x0 f where f x1@(RealConstr rs m) | rs (m 2) <= -1/4 = (SdL, Right (2*x1+1)) | rs (m 2) <= 1/4 = (SdM, Right (2*x1 )) | otherwise = (SdR, Right (2*x1-1)) 6 / 15

  18. Theorem If co I x and co I y, we also have co I x + y 2 . 7 / 15

  19. Theorem If co I x and co I y, we also have co I x + y 2 . Proof. Observation: From co I x and co I y we get d , e ∈ Sd and x ′ , y ′ ∈ co I such that x = d + x ′ and y = e + y ′ 2 . It follows 2 + e + y ′ = x ′ + y ′ + j d + x ′ x + y 2 2 = 2 2 4 for some j ∈ {− 2 , − 1 , 0 , 1 , 2 } . 7 / 15

  20. So it is sufficient to show that P := { x + y + j | x , y ∈ co I ∧ j ∈ {− 2 , − 1 , 0 , 1 , 2 }} ⊆ co I 4 8 / 15

  21. So it is sufficient to show that P := { x + y + j | x , y ∈ co I ∧ j ∈ {− 2 , − 1 , 0 , 1 , 2 }} ⊆ co I 4 ∈ P and d , e ∈ Sd , x ′ , y ′ ∈ co I with x = d + x ′ and y = e + y ′ Let x + y + j 2 . 4 2 8 / 15

  22. So it is sufficient to show that P := { x + y + j | x , y ∈ co I ∧ j ∈ {− 2 , − 1 , 0 , 1 , 2 }} ⊆ co I 4 ∈ P and d , e ∈ Sd , x ′ , y ′ ∈ co I with x = d + x ′ and y = e + y ′ Let x + y + j 2 . 4 2 We define K : {− 6 , . . . , 6 } → Sd and J : {− 6 , . . . , 6 } → {− 2 , − 1 , 0 , 1 , 2 } such that 4 K ( a ) + J ( a ) = a for all a ∈ {− 6 , . . . , 6 } . 8 / 15

  23. So it is sufficient to show that P := { x + y + j | x , y ∈ co I ∧ j ∈ {− 2 , − 1 , 0 , 1 , 2 }} ⊆ co I 4 ∈ P and d , e ∈ Sd , x ′ , y ′ ∈ co I with x = d + x ′ and y = e + y ′ Let x + y + j 2 . 4 2 We define K : {− 6 , . . . , 6 } → Sd and J : {− 6 , . . . , 6 } → {− 2 , − 1 , 0 , 1 , 2 } such that 4 K ( a ) + J ( a ) = a for all a ∈ {− 6 , . . . , 6 } . Then we have: + e + y ′ = d + e + 2 j + x ′ + y ′ d + x ′ + j x + y + j 2 2 = = 4 4 8 4 K ( d + e + 2 j ) + J ( d + e + 2 j ) + x ′ + y ′ 8 = K ( d + e + 2 j ) + J ( d + e +2 j )+ x ′ + y ′ 4 2 8 / 15

  24. k n | n > 2 = 1 | n < -2 = -1 | otherwise = 0 j 6 = 2 j 5 = 1 j 4 = 0 j 3 = -1 j 2 = 2 j 1 = 1 j 0 = 0 j (-1) = -1 j (-2) = -2 j (-3) = 1 j (-4) = 0 j (-5) = -1 j (-6) = -2 step :: (Int, Str, Str) -> (Sd, Either Str (Int, Str, Str)) step (t, d :~: u, e :~: v) = (toEnum (k num), Right (j num, u, v)) where num = fromEnum d + fromEnum e + 2*t cCoIAverage :: Str -> Str -> Str cCoIAverage (d :~: u) (e :~: v) = strCoRec (fromEnum d + fromEnum e, u, v) step 9 / 15

  25. Lemma x . co I x → | x | ≤ 1 ∀ nc 2 → co I (2 x ) 10 / 15

  26. Lemma x . co I x → | x | ≤ 1 ∀ nc 2 → co I (2 x ) Proof. Because of co I x we have x ′ ∈ co I and d ∈ Sd such that x = d + x ′ 2 . case differentiation by d: 10 / 15

  27. Lemma x . co I x → | x | ≤ 1 ∀ nc 2 → co I (2 x ) Proof. Because of co I x we have x ′ ∈ co I and d ∈ Sd such that x = d + x ′ 2 . case differentiation by d: If d = 0 we are done, because then 2 x = x ′ ∈ co I . 10 / 15

  28. Lemma x . co I x → | x | ≤ 1 ∀ nc 2 → co I (2 x ) Proof. Because of co I x we have x ′ ∈ co I and d ∈ Sd such that x = d + x ′ 2 . case differentiation by d: If d = 0 we are done, because then 2 x = x ′ ∈ co I . The cases d = 1 and d = − 1 are almost similar so we just consider d = − 1 . Here we have 2 x = − 1 + x ′ and x ′ ≥ 0 . 10 / 15

  29. Therefore we show (CoIPosToCoIMinusOne): ∀ nc y . co I y → y ≥ 0 → co I ( y − 1) 11 / 15

  30. Therefore we show (CoIPosToCoIMinusOne): ∀ nc y . co I y → y ≥ 0 → co I ( y − 1) Again we get y ′ ∈ co I and e ∈ Sd such that y = e + y ′ and we do case 2 differentiation by e : If e = 1 we get y − 1 = 1+ y ′ − 1 = − 1+ y ′ ∈ co I 2 2 11 / 15

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend