SLIDE 1 Proving termination using dependent types: the case of xor-terms
J.-F. Monin
VERIMAG Grenoble, France
GDR LAC, Chambery, 2007
SLIDE 2
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
SLIDE 3
Formal models of cryptographic systems
SLIDE 4
Formal models of cryptographic systems
◮ Protocols ◮ Security APIs
SLIDE 5
Formal models of cryptographic systems
◮ Protocols ◮ Security APIs
Xor is ubiquitous
SLIDE 6
Formal models of cryptographic systems
◮ Protocols ◮ Security APIs
Xor is ubiquitous Examples from a security API called CCA (Common Cryptographic Architecture): x, y, {z}x⊕KP⊕KM → {z ⊕ y}x⊕KP⊕KM x, y, {z}x⊕KP⊕KM → {z ⊕ y}x⊕KM
SLIDE 7
Formal models of cryptographic systems
◮ Protocols ◮ Security APIs
Xor is ubiquitous Examples from a security API called CCA (Common Cryptographic Architecture): x, y, {z}x⊕KP⊕KM → {z ⊕ y}x⊕KP⊕KM x, y, {z}x⊕KP⊕KM → {z ⊕ y}x⊕KM Reasoning involves: Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
SLIDE 8
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
SLIDE 9
General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
SLIDE 10
General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
◮ A congruence ≃ : T → T → Prop
SLIDE 11 General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
◮ A congruence ≃ : T → T → Prop
◮ For each constructor Ck
∀a, . . . x1, y1, b, . . . x2, y2, . . . c, x1 ≃ y1 → x2 ≃ y2 → Ck a . . . x1 b . . . y1 c ≃ Ck a . . . x2 b . . . y2 c
SLIDE 12 General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
◮ A congruence ≃ : T → T → Prop
◮ For each constructor Ck
∀a, . . . x1, y1, b, . . . x2, y2, . . . c, x1 ≃ y1 → x2 ≃ y2 → Ck a . . . x1 b . . . y1 c ≃ Ck a . . . x2 b . . . y2 c
◮ specific laws, e.g. ∀xy, C2 x C1 y ≃ C2 y x
SLIDE 13 General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
◮ A congruence ≃ : T → T → Prop
◮ For each constructor Ck
∀a, . . . x1, y1, b, . . . x2, y2, . . . c, x1 ≃ y1 → x2 ≃ y2 → Ck a . . . x1 b . . . y1 c ≃ Ck a . . . x2 b . . . y2 c
◮ specific laws, e.g. ∀xy, C2 x C1 y ≃ C2 y x
SLIDE 14 General setting: quotiented first order-terms
We are given
◮ A type of terms T with constructors Ck:
Inductive T : Set := | C1 : T . . . | Ck : . . . → T . . . → T . . . → T . . .
◮ A congruence ≃ : T → T → Prop
◮ For each constructor Ck
∀a, . . . x1, y1, b, . . . x2, y2, . . . c, x1 ≃ y1 → x2 ≃ y2 → Ck a . . . x1 b . . . y1 c ≃ Ck a . . . x2 b . . . y2 c
◮ specific laws, e.g. ∀xy, C2 x C1 y ≃ C2 y x
We want to reason on T up to ≃
SLIDE 15
Already well-known examples
◮ finite bags represented by finite lists
SLIDE 16
Already well-known examples
◮ finite bags represented by finite lists ◮ algebra of formal arithmetic expressions
SLIDE 17
Already well-known examples
◮ finite bags represented by finite lists ◮ algebra of formal arithmetic expressions ◮ (mobile) process calculi, chemical abstract machines
SLIDE 18
Already well-known examples
◮ finite bags represented by finite lists ◮ algebra of formal arithmetic expressions
+ is associative, commutative, 0 is neutral × is associative, commutative, 1 is neutral × distributes over +
◮ (mobile) process calculi, chemical abstract machines
parallel composition and choice operators are AC
SLIDE 19
Quotients in type theory
◮ High level approach : setoids
SLIDE 20
Quotients in type theory
◮ High level approach : setoids ◮ Explicit approach :
SLIDE 21 Quotients in type theory
◮ High level approach : setoids ◮ Explicit approach :
◮ Define a normalization function N on T
SLIDE 22 Quotients in type theory
◮ High level approach : setoids ◮ Explicit approach :
◮ Define a normalization function N on T ◮ Compare terms using syntactic equality on their norms :
x ≃ y iff N x = N y
SLIDE 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
SLIDE 24
Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
SLIDE 25
Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
SLIDE 26 Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
◮ y occurs in x ⊕ y ⊕ z
SLIDE 27 Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
◮ y occurs in x ⊕ y ⊕ z ◮ but y does not occur in x ⊕ y ⊕ z ⊕ y
SLIDE 28 Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
◮ y occurs in x ⊕ y ⊕ z ◮ but y does not occur in x ⊕ y ⊕ z ⊕ y
SLIDE 29 Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
◮ y occurs in x ⊕ y ⊕ z ◮ but y does not occur in x ⊕ y ⊕ z ⊕ y
x y if x ≃ y x t if t ≃ x ⊕ y0 . . . ⊕ yn and x yi for all i, 0 ≤ i ≤ n
SLIDE 30 Cryptographic systems need more
Reasoning on such systems involves
◮ comparing terms up to AC + involutivity of ⊕:
Commutativity: x ⊕ y ≃ y ⊕ x Associativity: (x ⊕ y) ⊕ z ≃ x ⊕ (y ⊕ z) Neutral element: x ⊕ 0 ≃ x Involutivity: x ⊕ x ≃ 0
◮ a relation for occurrence:
if x, y and z are different terms,
◮ y occurs in x ⊕ y ⊕ z ◮ but y does not occur in x ⊕ y ⊕ z ⊕ y
x y if x ≃ y x t if t ≃ x ⊕ y0 . . . ⊕ yn and x yi for all i, 0 ≤ i ≤ n
→ normalization is needed!
SLIDE 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
SLIDE 32
First attempt: rewrite, rewrite, rewrite. . .
SLIDE 33
First attempt: rewrite, rewrite, rewrite. . .
Replace equations with rewrite rules
SLIDE 34
First attempt: rewrite, rewrite, rewrite. . .
Replace equations with rewrite rules Commutativity: find an suitable well ordering on terms
SLIDE 35
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
SLIDE 36
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
SLIDE 37
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
SLIDE 38
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
SLIDE 39
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?
SLIDE 40
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
SLIDE 41
(Dependent) type theoretic approach
SLIDE 42
(Dependent) type theoretic approach
Step 1
◮ Consider a more structured version of t
SLIDE 43
(Dependent) type theoretic approach
Step 1
◮ Consider a more structured version of t
SLIDE 44
(Dependent) type theoretic approach
Step 1
◮ Consider a more structured version of t
= provide an accurate and informative typing to t
SLIDE 45 (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
SLIDE 46 (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
SLIDE 47 (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
Step 1 makes step 2 easy.
SLIDE 48 (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
Step 1 makes step 2 easy. Better formulation: t : T transformed into t′ : T ′ T ′ enriched version of T , trivial forgetful morphism T ′ → T .
SLIDE 49 (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
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 ′
SLIDE 50
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
SLIDE 51
Lasagnas reveal the truth
SLIDE 52
Lasagnas reveal the truth
SLIDE 53
Lasagnas reveal the truth
◮ layering a term
SLIDE 54
Lasagnas reveal the truth
◮ layering a term ◮ layers do not communicate:
each layer possesses its own normalization function
SLIDE 55
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
SLIDE 56
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
SLIDE 57
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
SLIDE 58
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
SLIDE 59
T as a lasagna
SLIDE 60
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 .
SLIDE 61
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 ⊕ E P S ⊕ S
SLIDE 62
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 ⊕ E P S ⊕ S
SLIDE 63
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
SLIDE 64
Decomposing T
Inductive Tx:Set := | X Zero : Tx | X Xor : Tx → Tx → Tx Inductive Tn: Set := | NX PC : public const → Tn | NX SC : secret const → Tn | NX E : Tn → Tn → Tn | NX Hash : Tn → Tn → Tn
SLIDE 65
Decomposing T
Variable A : Set. Inductive Tx:Set := | X Zero : Tx | X Xor : Tx → Tx → Tx | X ns : A → Tx Inductive Tn: Set := | NX PC : public const → Tn | NX SC : secret const → Tn | NX E : Tn → Tn → Tn | NX Hash : Tn → Tn → Tn | NX sum : A → Tn
SLIDE 66
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
SLIDE 67
Stratifying and normalizing a term
SLIDE 68
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.
SLIDE 69
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
SLIDE 70
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
◮ Tn(A) is sortable as well;
SLIDE 71
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
◮ Tn(A) is sortable as well; ◮ the multiset of A-leaves of a Tx(A)-term can be sorted (and
removed when possible) into a list;
SLIDE 72
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
◮ Tn(A) is sortable as well; ◮ the multiset of A-leaves of a Tx(A)-term can be sorted (and
removed when possible) into a list;
◮ list(A) is sortable.
SLIDE 73 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 Tx(Tn(Tx(. . . (∅))))
for k large enough. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then
◮ Tn(A) is sortable as well; ◮ the multiset of A-leaves of a Tx(A)-term can be sorted (and
removed when possible) into a list;
◮ list(A) is sortable.
SLIDE 74 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 Tx(Tn(Tx(. . . (∅))))
for k large enough. Step 2 A type is sortable if it is equipped with a decidable equality and a decidable total ordering. If A is sortable, then
◮ Tn(A) is sortable as well; ◮ the multiset of A-leaves of a Tx(A)-term can be sorted (and
removed when possible) into a list;
◮ list(A) is sortable.
SLIDE 75
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
SLIDE 76 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
SLIDE 77 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ What is k?
SLIDE 78 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ What is k? ◮ The number of layers on the left subterm and on the right
subterm are different in general.
SLIDE 79 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ What is k? ◮ The number of layers on the left subterm and on the right
subterm are different in general.
E H P ⊕ ⊕ S ⊕ E P S ⊕ S
SLIDE 80 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ What is k? ◮ The number of layers on the left subterm and on the right
subterm are different in general. Take the max
SLIDE 81 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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}
SLIDE 82 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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
SLIDE 83 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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
SLIDE 84 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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 Lx n and Lx m to Lx (max n m)
SLIDE 85 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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 Lx n and Lx m to Lx (max n m)
◮ Lightweight approach: max n m def
= = m + (n − m)
SLIDE 86 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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 Lx n and Lx m to Lx (max n m)
◮ Lightweight approach: max n m def
= = m + (n − m)
◮ liftx : Lx k → Lx (k + d), liftn : Ln k → Ln (k + d)
SLIDE 87 Lifting lasagna
Lx k
def
= = Tx(Tn(Tx(. . . (∅))))
for k large enough.
◮ 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 Lx n and Lx m to Lx (max n m)
◮ Lightweight approach: max n m def
= = m + (n − m)
◮ liftx : Lx k → Lx (k + d), liftn : Ln k → Ln (k + d) ◮ No need to proof that max is the max.
SLIDE 88
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
SLIDE 89
Internalizing alternation
SLIDE 90
Internalizing alternation
Well designed types help us to design programs
SLIDE 91
Internalizing alternation
Well designed types help us to design programs Many functions are defined by mutual induction, e.g. liftx and liftn
SLIDE 92
Internalizing alternation
Well designed types help us to design programs Many functions are defined by mutual induction, e.g. liftx and liftn Control them using alternating natural numbers
SLIDE 93
Internalizing alternation
Well designed types help us to design programs Many functions are defined by mutual induction, e.g. liftx and liftn Control them using alternating natural numbers Inductive alteven: Set := | 0e: alteven | So→e: altodd → alteven with altodd: Set := | Se→o: alteven → altodd
SLIDE 94
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
SLIDE 95
Forbid fake inclusions
SLIDE 96
Forbid fake inclusions
Inductive Tx: Set := | X Zero : Tx | X ns : A → Tx | X Xor : Tx → Tx → Tx Inductive Tn: Set := | NX PC : public const → Tn | NX SC : secret const → Tn | NX sum : A → Tn | NX E : Tn → Tn → Tn | NX Hash : Tn → Tn → Tn
SLIDE 97
Forbid fake inclusions
Inductive Tx: Set := | X Zero : Tx | X ns : A → Tx | X Xor : Tx → Tx → Tx Inductive Tn: Set := | NX PC : public const → Tn | NX SC : secret const → Tn | NX sum : A → Tn | NX E : Tn → Tn → Tn | NX Hash : Tn → Tn → Tn X ns (NX sum ( X ns (NX sum (. . . ))))
SLIDE 98
Forbid fake inclusions
Inductive Tx: bool → Set := | X Zero : ∀ b, Tx b | X ns : ∀ b, Is true b → A → Tx b | X Xor : ∀ b, Tx true → Tx true → Tx b Inductive Tn: bool → Set := | NX PC : ∀ b, public const → Tn b | NX SC : ∀ b, secret const → Tn b | NX sum : ∀ b, Is true b → A → Tn b | NX E : ∀ b, Tn true → Tn true → Tn b | NX Hash : ∀ b, Tn true → Tn true → Tn b X ns (NX sum ( X ns (NX sum (. . . ))))
SLIDE 99
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
SLIDE 100
Mutual induction
◮ Prefer fixpoints: built-in computation, no inversion
SLIDE 101
Mutual induction
◮ Prefer fixpoints: built-in computation, no inversion ◮ Use map combinators
SLIDE 102
Mutual induction
◮ Prefer fixpoints: built-in computation, no inversion ◮ Use map combinators
SLIDE 103
Mutual induction
◮ Prefer fixpoints: built-in computation, no inversion ◮ Use map combinators
Many 10 lines definitions, almost no theorem
SLIDE 104
Mutual induction
◮ Prefer fixpoints: built-in computation, no inversion ◮ Use map combinators
Many 10 lines definitions, almost no theorem Fixpoint lift lasagna x e1 e2 {struct e1} : Lx e1 → Lx (e1 + e2) := match e1 return Lx e1 → Lx (e1 + e2) with | 0e ⇒ fun emp ⇒ match emp with end | So→e o1 ⇒ mapx (lift lasagna n o1 e2) false end with lift lasagna n o1 e2 {struct o1} : Ln o1 → Ln (o1 + e2) := match o1 return Ln o1 → Ln (o1 + e2) with | Se→o e1 ⇒ mapn (lift lasagna x e1 e2) false end.
SLIDE 105
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
SLIDE 106
Conversion rule
SLIDE 107
Conversion rule
Used everywhere
SLIDE 108
Conversion rule
Used everywhere Definition bin xor (bin : ∀ A b, Tx A true → Tx A true → Tx A b) o1 o2 b (l1 : lasagna cand x o1 true) (l2 : lasagna cand x o2 true) : lasagna cand x (max oo o1 o2) b := bin (Ln (max oo o1 o2)) b (lift lasagna cand x true o1 (o2 - o1) l1) (coerce max comm (lift lasagna cand x true o2 (o1 - o2) l2)).
SLIDE 109
Conclusion
Type theory is flexible
SLIDE 110
Conclusion
Type theory is flexible
◮ Polymorphism
SLIDE 111
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types
SLIDE 112
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types
SLIDE 113
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types ◮ Conversion rule
SLIDE 114
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types ◮ Conversion rule ◮ JMEQ not used
SLIDE 115
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types ◮ Conversion rule ◮ JMEQ not used
SLIDE 116
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types ◮ Conversion rule ◮ JMEQ not used (until now)
SLIDE 117
Conclusion
Type theory is flexible
◮ Polymorphism ◮ Mutually inductive types ◮ Dependent types ◮ Conversion rule ◮ JMEQ not used (until now)