Type Theory Proof by reflection Marene Dimmendaal, Pleun Koldewijn
Overview - What is ‘proof by reflection’? - The two main classes: - Direct computation proofs - Algebraic computation proofs - Example Direct proof - Example Algebraic proof - Summary
What is proof by reflection? Statements involving computations - Automated proof development system -
General presentation Coq file - Complex combinations of reasoning steps replaced by few - computation steps Two classes of problems: - Direct computation proofs Algebraic computation proofs
Direct computation proofs predicate function Proof of “C t ”: Proof of ‘C t ’:
Algebraic computational proofs Functions and The reflection process relies on the following theorem:
Example direct computation proof Coq proof: A reasonably sized natural number is prime Proved by computing remainders In this case, C x is the mathematical statement for ‘x is prime’, i.e. there is no integer n (not equal to 1 or x) which divides x.
Setting up reflection Existence of a divisor: Only smaller number need to be checked:
Function for division To check presence of divisors:
Primality To check primality:
Function check_range Isn’t it simpler with two arguments?
Duration of the functions
Duration of the functions
Deduced result This is our f_correct!
Primality proof TTTT This proof takes a few minutes while the naïve procedure could not cope with a number this size.
Example Algebraic computational proofs For set A and a binary operation *, we have that Easily use Associativity law: ( x * y ) * z = x * ( y * z ) for all x y z in A For With
Example Algebraic computational proofs x x y u y t z z t u
Example Algebraic computational proofs x x y u y t z z t u
Data Type and functions Data Type A : Function f :
Data Type and functions Data Type A : Function i :
The required proofs
Example Algebraic computational proofs x x y u y t z z t u
Using the proof
Ltac: transforming equation to binary tree
Ltac: automated proof steps
Ltac: automated proof steps
Example Algebraic computational proofs x x y u y t z z t u
Generic version For set A and a binary operation *, we have that Associativity law: ( x * y ) * z = x * ( y * z ) for all x y z in A represented as f x ( f ( f y z ) ( f t u ) )
Generic version f x ( f ( f y z ) ( f t x ) ) x x y z y t z x t x
Generic version - theorems Original : Generic :
Generic version f x ( f ( f y z ) ( f t x ) ) x x y z y t z x t x f x ( f ( f y z ) ( f t x ) ) cons x ( cons y ( cons z ( cons t ( cons x ) ) ) )
Generic version f x ( f ( f y z ) ( f t x ) ) 0 0 1 2 1 3 2 0 3 0 f x ( f ( f y z ) ( f t x ) ) cons x ( cons y ( cons z ( cons t ( cons x ) ) ) )
Generic version f x ( f ( f y z ) ( f t x ) ) 0 0 1 2 1 3 2 0 3 0 f x ( f ( f y z ) ( f t x ) ) cons x ( cons y ( cons z ( cons t ( cons x ) ) ) )
Generic version - theorems
Generic version
Generic version - with commutativity f x ( f ( f y z ) ( f t x ) ) 0 0 1 2 1 3 2 0 3 0
Generic version - with commutativity f x ( f ( f y z ) ( f t x ) ) 0 0 0 1 0 2 1 1 3 2 0 3 0 2 3
Recommend
More recommend