proving termination using dependent types the case of xor
play

Proving termination using dependent types: the case of xor-terms - PowerPoint PPT Presentation

Proving termination using dependent types: the case of xor-terms J.-F. Monin J. Courant VERIMAG Grenoble, France GDR LAC, Chambery, 2007 Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems


  1. First attempt: rewrite, rewrite, rewrite . . . Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms Functional programming approach: ◮ Not very difficult – use general recursion ◮ Just boring

  2. First attempt: rewrite, rewrite, rewrite . . . Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms Functional programming approach: ◮ Not very difficult – use general recursion ◮ Just boring

  3. First attempt: rewrite, rewrite, rewrite . . . Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms Functional programming approach: ◮ Not very difficult – use general recursion ◮ Just boring In a type theoretic framework, termination proof mandatory and non-trivial: ◮ combination of polynomial and lexicographic ordering

  4. First attempt: rewrite, rewrite, rewrite . . . Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms Functional programming approach: ◮ Not very difficult – use general recursion ◮ Just boring In a type theoretic framework, termination proof mandatory and non-trivial: ◮ combination of polynomial and lexicographic ordering ◮ other approaches (lpo, rpo, . . . ): overkill?

  5. First attempt: rewrite, rewrite, rewrite . . . Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms Functional programming approach: ◮ Not very difficult – use general recursion ◮ Just boring In a type theoretic framework, termination proof mandatory and non-trivial: ◮ combination of polynomial and lexicographic ordering ◮ other approaches (lpo, rpo, . . . ): overkill? ◮ AC matching: a non trivial matter

  6. (Dependent) type theoretic approach

  7. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t

  8. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t

  9. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t

  10. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t Step 2 ◮ Normalize by structural induction on the newly typed version of t

  11. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t Step 2 ◮ Normalize by structural induction on the newly typed version of t

  12. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t Step 2 ◮ Normalize by structural induction on the newly typed version of t Step 1 makes step 2 easy.

  13. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t Step 2 ◮ Normalize by structural induction on the newly typed version of t Step 1 makes step 2 easy. Better formulation: t : T transformed into t ′ : T ′ T ′ enriched version of T , trivial forgetful morphism T ′ → T .

  14. (Dependent) type theoretic approach Step 1 ◮ Consider a more structured version of t = provide an accurate and informative typing to t Step 2 ◮ Normalize by structural induction on the newly typed version of t Step 1 makes step 2 easy. Better formulation: t : T transformed into t ′ : T ′ T ′ enriched version of T , trivial forgetful morphism T ′ → T . Interesting part = T → T ′

  15. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  16. Lasagnas reveal the truth

  17. Lasagnas reveal the truth

  18. Lasagnas reveal the truth ◮ layering a term

  19. Lasagnas reveal the truth ◮ layering a term ◮ layers do not communicate: each layer possesses its own normalization function

  20. Lasagnas reveal the truth ◮ layering a term ◮ layers do not communicate: each layer possesses its own normalization function ◮ in our case: need 2 layers, pasta and sauce

  21. Lasagnas reveal the truth ◮ layering a term ◮ layers do not communicate: each layer possesses its own normalization function ◮ in our case: need 2 layers, pasta and sauce ◮ normalizing pasta = identity

  22. Lasagnas reveal the truth ◮ layering a term ◮ layers do not communicate: each layer possesses its own normalization function ◮ in our case: need 2 layers, pasta and sauce ◮ normalizing pasta = identity ◮ normalizing sauce = rearranging + removing duplicates

  23. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  24. T as a lasagna

  25. T as a lasagna Inductive T : Set := | Zero : T | PC : public const → T | SC : secret const → T | E : T → T → T | Xor : T → T → T | Hash : T → T → T .

  26. T as a lasagna Inductive T : Set := | Zero : T | PC : public const → T | SC : secret const → T | E : T → T → T | Xor : T → T → T | Hash : T → T → T . E H ⊕ P S 0 ⊕ ⊕ ⊕ S 0 E S P 0

  27. T as a lasagna Inductive T : Set := | Zero : T | PC : public const → T | SC : secret const → T | E : T → T → T | Xor : T → T → T | Hash : T → T → T . E H ⊕ P S 0 ⊕ ⊕ ⊕ S 0 E S P 0

  28. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  29. Decomposing T Inductive T x : Set := | X Zero : T x | X Xor : T x → T x → T x Inductive T n : Set := | NX PC : public const → T n | NX SC : secret const → T n | NX E : T n → T n → T n | NX Hash : T n → T n → T n

  30. Decomposing T Variable A : Set . Inductive T x : Set := | X Zero : T x | X Xor : T x → T x → T x | X ns : A → T x Inductive T n : Set := | NX PC : public const → T n | NX SC : secret const → T n | NX E : T n → T n → T n | NX Hash : T n → T n → T n | NX sum : A → T n

  31. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  32. Stratifying and normalizing a term

  33. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc.

  34. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then

  35. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then ◮ T n ( A ) is sortable as well;

  36. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then ◮ T n ( A ) is sortable as well; ◮ the multiset of A -leaves of a T x ( A ) -term can be sorted (and removed when possible) into a list;

  37. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then ◮ T n ( A ) is sortable as well; ◮ the multiset of A -leaves of a T x ( A ) -term can be sorted (and removed when possible) into a list; ◮ list ( A ) is sortable.

  38. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. The typing of t ′ is T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. � �� � k layers Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then ◮ T n ( A ) is sortable as well; ◮ the multiset of A -leaves of a T x ( A ) -term can be sorted (and removed when possible) into a list; ◮ list ( A ) is sortable.

  39. Stratifying and normalizing a term Step 1 Translate a term t into t ′ according to the mapping 0 �→ X Zero , Xor �→ X Xor , PC �→ NX PC , etc. The typing of t ′ is T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. � �� � k layers Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then ◮ T n ( A ) is sortable as well; ◮ the multiset of A -leaves of a T x ( A ) -term can be sorted (and removed when possible) into a list; ◮ list ( A ) is sortable.

  40. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  41. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers

  42. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ?

  43. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general.

  44. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. E H ⊕ P S 0 ⊕ ⊕ ⊕ S 0 E S P 0

  45. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max

  46. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n}

  47. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term

  48. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term ◮ heavy encoding of m − n or n − m

  49. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term ◮ heavy encoding of m − n or n − m ◮ need to lift L x n and L x m to L x ( max n m )

  50. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term ◮ heavy encoding of m − n or n − m ◮ need to lift L x n and L x m to L x ( max n m ) ◮ Lightweight approach: max n m def = m + ( n − m ) =

  51. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term ◮ heavy encoding of m − n or n − m ◮ need to lift L x n and L x m to L x ( max n m ) ◮ Lightweight approach: max n m def = m + ( n − m ) = ◮ lift x : L x k → L x ( k + d ) , lift n : L n k → L n ( k + d )

  52. Lifting lasagna L x k def = T x ( T n ( T x ( . . . ( ∅ )))) for k large enough. = � �� � k layers ◮ What is k ? ◮ The number of layers on the left subterm and on the right subterm are different in general. Take the max ◮ Standard solution: {le n m} + {le m n} ◮ interactive definition, large proof term ◮ heavy encoding of m − n or n − m ◮ need to lift L x n and L x m to L x ( max n m ) ◮ Lightweight approach: max n m def = m + ( n − m ) = ◮ lift x : L x k → L x ( k + d ) , lift n : L n k → L n ( k + d ) ◮ No need to proof that max is the max.

  53. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  54. Internalizing alternation

  55. Internalizing alternation Well designed types help us to design programs

  56. Internalizing alternation Well designed types help us to design programs Many functions are defined by mutual induction, e.g. lift x and lift n

  57. Internalizing alternation Well designed types help us to design programs Many functions are defined by mutual induction, e.g. lift x and lift n Control them using alternating natural numbers

  58. Internalizing alternation Well designed types help us to design programs Many functions are defined by mutual induction, e.g. lift x and lift n Control them using alternating natural numbers Inductive alt even : Set := | 0 e : alt even | S o → e : alt odd → alt even with alt odd : Set := | S e → o : alt even → alt odd

  59. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  60. Forbid fake inclusions

  61. Forbid fake inclusions Inductive T x : Set := | X Zero : T x | X ns : A → T x | X Xor : T x → T x → T x Inductive T n : Set := | NX PC : public const → T n | NX SC : secret const → T n | NX sum : A → T n | NX E : T n → T n → T n | NX Hash : T n → T n → T n

  62. Forbid fake inclusions Inductive T x : Set := | X Zero : T x | X ns : A → T x | X Xor : T x → T x → T x Inductive T n : Set := | NX PC : public const → T n | NX SC : secret const → T n | NX sum : A → T n | NX E : T n → T n → T n | NX Hash : T n → T n → T n X ns ( NX sum ( X ns ( NX sum (. . . ))))

  63. Forbid fake inclusions Inductive T x : bool → Set := | X Zero : ∀ b , T x b | X ns : ∀ b , Is true b → A → T x b | X Xor : ∀ b , T x true → T x true → T x b Inductive T n : bool → Set := | NX PC : ∀ b , public const → T n b | NX SC : ∀ b , secret const → T n b | NX sum : ∀ b , Is true b → A → T n b | NX E : ∀ b , T n true → T n true → T n b | NX Hash : ∀ b , T n true → T n true → T n b X ns ( NX sum ( X ns ( NX sum (. . . ))))

  64. Outline Motivation The case of cryptographic systems State of the art Back to cryptographic systems Solving strategies Solution (intuitive) Basic idea Analyse of T Decomposing T Stratifying and normalizing a term Issues Lifting Alternation Forbid fake inclusions Fixpoints Conversion rule Conclusion

  65. Mutual induction ◮ Prefer fixpoints: built-in computation, no inversion

Recommend


More recommend