I want to prove that there exist a natural number which is less than 10. I write the code in this way..
thm2 : (∃ λ m → (m < 10))
thm2 = zero , s≤s z≤n
I am not able to understand how this is working. Please explain..
I want to prove that there exist a natural number which is less than 10. I write the code in this way..
thm2 : (∃ λ m → (m < 10))
thm2 = zero , s≤s z≤n
I am not able to understand how this is working. Please explain..
Let's dissect
thm2.The type of the expression
∃is defined in Data.Product as an alias forΣwhere the first argument is left implicit. This means that∃is taking an elementBof typeA → Setand returning the type of pairs containing anaof typeAand abof typeB a.Now,
λ m → m < 10is taking anminℕand returning the type of proofs thatm < 10.So
∃ λ m → m < 10is the type of pairs of anℕand a proof that it is less than10.The expression itself
For the whole thing to typecheck, we need:
zeroto be aℕwhich it is.s≤s z≤nto be a proof that0 < 10._<_is defined inData.Nat.Baseas an alias forλ m n → suc m ≤ n. So proving that0 < 10is the same as proving that1 ≤ 10.Now,
_≤_is an inductive type with two constructors:z≤nsaying that0is less than or equal to all natural numberss≤ssaying that if one number is less than or equal to another, then theirsucs also are less than or equal.The proof
s≤s z≤nis indeed a valid proof that1 ≤ 10:z≤nproves that0 ≤ 9ands≤sconcludes that therefore1 ≤ 10.