* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download 4-up
Falcon (programming language) wikipedia , lookup
Logic programming wikipedia , lookup
Monad (functional programming) wikipedia , lookup
Hindley–Milner type system wikipedia , lookup
Functional programming wikipedia , lookup
C Sharp syntax wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Covariance and contravariance (computer science) wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
schema simply typed lambda-calculus logical verification lecture 2 2015 04 02 simply typed λ-calculus Curry-Howard-de Bruijn isomorphism Curry-Howard-De Bruijn isomorphism some remarks further reading from logic to type theory schema simply typed lambda-calculus logic type theory proofs λ-terms on paper × today some remarks in Coq × today further reading Curry-Howard-De Bruijn isomorphism programming styles functional programming imperative programming C object-oriented programming C++ Java functions are first class objects functions can be anonymous logic programming prolog functions may return functional values functional programming lisp ML Haskell currying simply typed λ-calculus: types f :A×B →C • atomic type (type variable) may admit partial evaluation: f (a, ·) : B → C a b c ... • function type (A → B) curried version: f :A→B→C simply typed λ-calculus: terms parentheses conventions • variable x function types associate to the right • lambda abstraction (λx : A. M) the function that maps the variable x of type A to M • function application application associates to the left (f a) b for f : A → (B → C ) is written as f a b for f : A → B → C (F M) the application of the function F to the argument M lambda-terms: examples lambda-terms: more examples term: type: λx : A. x A→A term: type: λx : R. x R→R λx : A. λy : B. x : A → B → A term: type: λx : (A → B) → C → D. λy : C . λz : B. x (λw : A. z) y ((A → B) → C → D) → C → B → D λx : A. λy : A. y : A → A → A λx : A. x : A → A λx : A. λy : A. x : A → A → A judgement typing rules variable rule: Γ`x :A x1 : A1 , . . . , xn : An ` M : A in an environment x1 : A1 , . . . , xn : An the term M has type A if x : A ∈ Γ abstraction rule: Γ, x : A ` M : B Γ ` (λx : A. M) : A → B application rule: Γ`F :A→B Γ`M:A Γ ` (F M) : B lambda-terms: examples reconsidered x :A`x :A ` λx : A. x : A → A schema simply typed lambda-calculus Curry-Howard-De Bruijn isomorphism x : A, y : B ` x : A x : A ` λy : B. x : B → A ` λx : A. λy : B. x : A → B → A consider also λx : (A → B) → C → D. λy : C . λz : B. x (λw : A. z) y some remarks further reading Curry-Howard-De Bruijn isomorphism Curry- Howard- De Bruijn- isomorphism: logic ∼ typed λ-calculus formulas as types propositional variable a ∼ type variable a implication A → B ∼ function space A → B today more in particular: minimal propositional logic ∼ simply typed λ-calculus proofs as terms: introduction proofs as terms: elimination implication introduction and abstraction implication elimination and application [Ax ] .. . B I [x] → A→B Γ, x : A ` M : B Γ ` (λx : A. M) : A → B A→B B A E→ Γ`F :A→B Γ`M:A Γ ` (F M) : B Curry-Howard-De Bruijn isomorphism provability is inhabitation minimal prop1 ∼ λ→ formula propositional variable connective → ∼ ∼ ∼ type type variable type constructor → inhabitation do we have a closed term P of type A? proof assumption implication introduction implication elimination ∼ ∼ ∼ ∼ term term variable abstraction application provability do we have a proof P of the formula A? provability proof checking ∼ ∼ inhabitation type checking proof checking is type checking type checking: is the typing derivation Γ ` P : A correct? corresponds to proof checking is the proof P of the formula A using assumptions Γ correct? and is decidable for λ→ and ML corresponds to decidable for λ→ and ML (but for instance not for first-order predicate logic) Brouwer-Heyting-Kolmogorov interpretation proof of A → B ∼ proof of A ∧ B proof of A ∨ B proof of ⊥ ∼ ∼ function that maps proofs of A to proofs of B pair of a proof of A and a proof of B either a proof of A or a proof of B does not exist example: proof objects • λx : A. x : A → A the function type A → A represents a proposition the term λx : A. x represents a proof of that proposition example: proof and proof object [Ax ] I [y ] → B→A I [x] → A→B→A • λx : A. λy : B. x : A → B → A • λx : A. λy : A. x : A → A → A : A→B→A ∼ λx : A. λy : B. x : A→B→A • λx : A. λy : A. y : A → A → A schema alpha equivalence simply typed lambda-calculus Curry-Howard-De Bruijn isomorphism we identify expressions that are equal some remarks up to a renaming of bound variables further reading alpha equivalence: examples same terms: λx : A. x and λy : A. y same proofs: [Ax ] I [x] → A→A and [Ay ] I [y ] → A→A Coq term syntax x alpha equivalence: non-examples different terms: λx : A. λy : A. x and λx : A. λy : A. y different proofs: [Ax ] I [y ] → A→A I [x] → A→A→A and [Ay ] I [y ] → A→A I [x] → A→A→A Coq commands Check prints a term with its type fun x:A => M Print prints the term for a symbol with its type M N Definition binds a term to an identifier Coq example fun x:A => x : A -> A further reading • intuitionism • ten questions about intuitionism arrow is implication for Coq as proof checker arrow is function type for Coq as programming language • interactive theorem proving