Pedagogical formal and functionnal systems - Vincent Demange

Basics : the pedagogical constraint. Poincaré criterion. «A definition by ... Pedagogical simply typed λ-calculus [Colson and Michel (2007)]. Morphology α | A → B.
470KB taille 11 téléchargements 263 vues
Pedagogical formal and functionnal systems Vincent Demange CPR, Cédric, Cnam

27/06/2013

1/38

Introduction to formal pedagogy Published works

L. Colson and D. Michel. Pedagogical natural deduction systems : the propositional case. JUCS, 13(10) :1396–1410, 2007. L. Colson and D. Michel. Pedagogical Second-Order Propositional Calculi. JLC, 18(4) :669–695, 2008. L. Colson and D. Michel. Pedagogical second-order λ-calculus. TCS, 410 :4190–4203, 2009. L. Colson and V. Demange. Investigations on a Pedagogical Calculus of Constructions. JUCS, to appear, 2013.

2/38

Introduction to formal pedagogy Basics : the pedagogical constraint

Poincaré criterion «A definition by postulate has value only if there exists an example.» [Henri Poincaré – Last Thoughts (1913)]

Good postulate Let x be a natural number such that x 2 − 1 = 0 holds. . x := 1 suits

Bad postulate Let y be a natural number verifying y 2 + 1 = 0. . no such y Called “pedagogical” because of usual teaching practice 3/38

Outline of the investigation

1. Summary of the previous works 2. First attempts toward a pedagogical CC 3. A formal definition and some examples 4. Toward a Pedagogical Calculus of Constructions

4/38

Summary of the previous works The formal pedagogical constraint

Informal Poincaré criterion «A definition by postulate has value only if there exists an example.» [Henri Poincaré – Last Thoughts (1913)]

Formal Poincaré criterion (example) If > is a type and o a term of type > : I

Γ := {f : (α → α) → α, g : > → β}

I

σ := [α 7→ >, β 7→ >, f 7→ λh>→> .o, g 7→ λx > .x] example :

. defines α, β, f , g

` λh>→> .o : (> → >) → > ` λx > .x

:>→>

5/38

Summary of the previous works The formal pedagogical constraint

Informal Poincaré criterion «A definition by postulate has value only if there exists an example.» [Henri Poincaré – Last Thoughts (1913)]

Formal Poincaré criterion Used environments must be exemplifiable : Γ `t : A where : `σ · Γ `σ(x) : σ(A) `σ · ∅

(ex1 )

`σ · (Γ, x : A)

i.e. `σ · (x1 : A1 , . . . , xn : An ) := ∀i



`σ · Γ

(ex2 )

`σ(xi ) : σ(Ai )

5/38

Summary of the previous works Simply typed λ-calculus

Morphology α | A → B Syntax x | λx A .u | u v x :F ∈Γ (var)

Γ `x : F Γ, x : A `u : B Γ `λx A .u : A → B

Γ `u : A → B (abs)

Γ `v : A

Γ `u v : B

(app)

6/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Morphology α | A → B Syntax x | λx A .u | u v x :F ∈Γ

`σ · Γ (var)

Γ `x : F Γ, x : A `u : B Γ `λx A .u : A → B

Γ `u : A → B (abs)

Γ `v : A

Γ `u v : B

(app)

Results I

satisfies the Poincaré criterion

6/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Morphology α | A → B Syntax x | λx A .u | u v No starting rule x :F ∈Γ

`σ · Γ (var)

Γ `x : F Γ, x : A `u : B Γ `λx A .u : A → B

Γ `u : A → B (abs)

Γ `v : A

Γ `u v : B

(app)

Results I

satisfies the Poincaré criterion

6/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Morphology α | A → B | > Syntax x | λx A .u | u v | o `σ · Γ

x :F ∈Γ

Γ `o : >

(ax)

Γ, x : A `u : B Γ `λx A .u : A → B

`σ · Γ (var)

Γ `x : F Γ `u : A → B

(abs)

Γ `v : A

Γ `u v : B

(app)

Results I

satisfies the Poincaré criterion

I

all formulas exemplified by >

I

initial and pedagogical systems (syntactically) equivalents 6/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Example of derivation

`σ · (f : A → B, g : B → C , x : A) .. .

(var)

(app? )

f : A → B, g : B → C , x : A `g (f x) : C `λf A→B .λg B→C .λx A .g (f x) : (A → B) → (B → C ) → (A → C )

(abs? )

7/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Example of derivation

(ex2 )

`σ · (f : A → B, g : B → C , x : A) σ := [A, B, C 7→ > ; f , g 7→ λy > .y ; x 7→ o] 7/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Example of derivation

(var)

y : > `y : > `λy > .y : > → >

(abs) (ex2 )

`σ · (f : A → B, g : B → C )

(ax)

`o : > (ex2 )

`σ · (f : A → B, g : B → C , x : A) σ := [A, B, C 7→ > ; f , g 7→ λy > .y ; x 7→ o] 7/38

Summary of the previous works Pedagogical simply typed λ-calculus [Colson and Michel (2007)]

Example of derivation (ax)

`o : > `σ 0 (y : >)

(ex2 ) (var)

y : > `y : > `λy > .y : > → >

(abs) (ex2 )

`σ · (f : A → B, g : B → C )

(ax)

`o : > (ex2 )

`σ · (f : A → B, g : B → C , x : A) σ := [A, B, C 7→ > ; f , g 7→ λy > .y ; x 7→ o] σ 0 := [y 7→ o] 7/38

Summary of the previous works System F [Girard (1972), Reynolds (1974)]

Morphology α | A → B | ∀α.A Syntax x | λx A .u | u v | Λα.u x :F ∈Γ (var)

Γ `f x : F Γ, x : A `f u : B Γ `f λx A .u : A → B Γ `f u : B

Γ `f u : A → B (abs)

Γ `f u v : B

(app)

Γ `f u : ∀α.B

α 6∈ V(Γ)

Γ `f Λα.u : ∀α.B

Γ `f v : A

(Abs)

Γ `f u V : B[α ← V ]

(App)

8/38

Summary of the previous works Weakly pedagogical System F [Colson and Michel (2008)]

Morphology α | A → B | ∀α.A | > Syntax x | λx A .u | u v | Λα.u | o `fw σ · Γ

x :F ∈Γ

Γ `fw o : >

(ax)

Γ, x : A `fw u : B Γ `fw λx A .u : A → B Γ `fw u : B

(abs)

(var)

Γ `fw x : F Γ `fw u : A → B

Γ `fw v : A

Γ `fw u v : B

(app)

Γ `fw u : ∀α.B

α 6∈ V(Γ)

Γ `fw Λα.u : ∀α.B

`fw σ · Γ

(Abs)

Γ `fw u V : B[α ← V ]

(App)

Results I satisfies the Poincaré criterion

8/38

Summary of the previous works Weakly pedagogical System F [Colson and Michel (2008)]

Morphology α | A → B | ∀α.A | > Syntax x | λx A .u | u v | Λα.u | o `fw σ · Γ

x :F ∈Γ

Γ `fw o : >

(ax)

Γ, x : A `fw u : B Γ `fw λx A .u : A → B Γ `fw u : B

(var)

Γ `fw x : F Γ `fw u : A → B

(abs)

Γ `fw v : A

Γ `fw u v : B

(app)

Γ `fw u : ∀α.B

α 6∈ V(Γ)

Γ `fw Λα.u : ∀α.B

`fw σ · Γ

(Abs)

Γ `fw u V : B[α ← V ]

(App)

Results I satisfies the Poincaré criterion I no subject reduction property : fw α

. ⊥ := ∀α.α fw

` (Λα.λx .x) ⊥ : ⊥ → ⊥ but 6` λx ⊥ .x : ⊥ → ⊥ 8/38

Summary of the previous works Pedagogical System F [Colson and Michel (2009)]

Pre-Morphology α | A → B | ∀α.A | > Syntax x | λx A .u | u v | Λα.u | o `fp σ · Γ

x :F ∈Γ

Γ `fp o : >

(ax)

Γ, x : A `fp u : B Γ `fp λx A .u : A → B Γ `fp u : B

(abs)

Γ `fp v : A

Γ `fp u v : B Γ `fp u : ∀α.B

(Abs)

(var)

Γ `fp x : F Γ `fp u : A → B

α 6∈ V(Γ)

Γ `fp Λα.u : ∀α.B

`fp σ · Γ

(app)

`fp σ · V

Γ `fp u V : B[α ← V ]

(App)

8/38

Summary of the previous works Pedagogical System F [Colson and Michel (2009)]

Main results I

every well-formed sub-type can be exemplified : I

I

I

I

Poincaré criterion always satisfied : Γ `fp u : A ⇒ `fp σ · Γ usefulness of functions : Γ `fp f : A → B with A closed ⇒ A is inhabited negationless second-order propositional calculus

expressive power compared to System F : I

at logical side : ∃t Γ `f t : F



∃t 0

Γγ `fp t 0 : F γ

where F γ is F with occurrences of variables α replaced by α ∨ γ (γ fresh) I

at computational side : Γ `f t : A ⇒ Γδ `fp ¯t : Aδ where Aδ is a double-negation version of A (⊥ replaced by δ) and ¯t is a CPS version of t (δ fresh)

9/38

Summary of the previous works Pedagogical System F [Colson and Michel (2009)]

Main results logic

computation

formula proof simplification direct proof proof checking exemplifiability

datatype program computation result type checking utility

9/38

First attempts toward a pedagogical CC Calculus of Constructions [Coquand and Huet (1985)]

Motivations The Calculus of Constructions : I

uniform presentation of previous systems

I

interdependence between morphology and syntax . reduction of constraints number first step towards pedagogical pure type systems (PTS) . especially Type : Type [Martin-Löf (1971)]

I

10/38

First attempts toward a pedagogical CC Calculus of Constructions [Coquand and Huet (1985)]

∅ wf c

(c-env1 )

(c-env2 )

Γ, x : A wf c Γ, x : A, Γ0 wf c

Γ wf c Γ `c Prop : Type

(c-ax)

Γ `c λx A .u : ∀x A .B

Γ, x : A, Γ0 `c x : A Γ `c u : ∀x A .B

Γ, x : A `c u : B : κ (c-abs)

Γ, x : A `c B : κ Γ `c ∀x A .B : κ

Γ `c A : κ x 6∈ dom(Γ)

Γ `c v : A

Γ `c u v : B[x ← v ] Γ `c u : A

(c-prod)

(c-var)

A ' A0 Γ `c u : A0

(c-app)

Γ `c A0 : κ (c-conv)

κ denotes Prop or Type

11/38

First attempts toward a pedagogical CC Naive transposition

Formal Poincaré criterion Γ ≡ x1 : A1 , . . . , xn : An can be exemplified by terms t1 , . . . , tn if `t1 : A1 `t2 : A2 [x1 ← t1 ] .. . `tn : An [x1 , . . . , xn−1 ← t1 , . . . , tn−1 ] Abbreviation : `σ · Γ with σ := [x1 7→ t1 , . . . , xn 7→ tn ]

First idea Substitutes the well-formedness of an environment by its . Γ wf replaced by `σ · Γ exemplifiability

12/38

First attempts toward a pedagogical CC Naive transposition

`n σ · Γ Γ `n o : > : Prop : Type

`n σ · (Γ, x : A, Γ0 ) (n-ax)

Γ, x : A, Γ0 `n x : A

(n-var)

But I

“exemplifiable” does not imply “well-formed” : I I I

I

x1 : Type x1 : Prop, x2 : (λH >→x1 .>) (λy > .y ) etc.

no subject reduction

. σ := [x1 7→ Prop] . σ := [x1 7→ >; x2 7→ o] . ⊥ → ⊥ inhabited

13/38

First attempts toward a pedagogical CC Calculus of Constructions [Coquand and Huet (1985)]

∅ wf c

(c-env1 )

(c-env2 )

Γ, x : A wf c Γ, x : A, Γ0 wf c

Γ wf c Γ `c Prop : Type

(c-ax)

Γ `c λx A .u : ∀x A .B

Γ, x : A, Γ0 `c x : A Γ `c u : ∀x A .B

Γ, x : A `c u : B : κ (c-abs)

Γ, x : A `c B : κ Γ `c ∀x A .B : κ

Γ `c A : κ x 6∈ dom(Γ)

Γ `c v : A

Γ `c u v : B[x ← v ] Γ `c u : A

(c-prod)

(c-var)

A ' A0 Γ `c u : A0

(c-app)

Γ `c A0 : κ (c-conv)

κ denotes Prop or Type

14/38

First attempts toward a pedagogical CC Calculus of Constructions [Coquand and Huet (1985)]

∅ wf c

(c-env1 )

(c-env2 )

Γ, x : A wf c Γ, x : A, Γ0 wf c

Γ wf c Γ `c Prop : Type

(c-ax)

Γ `c λx A .u : ∀x A .B

Γ, x : A, Γ0 `c x : A Γ `c u : ∀x A .B

Γ, x : A `c u : B : κ (c-abs)

Γ, x : A `c B : κ Γ `c ∀x A .B : κ

Γ `c A : κ x 6∈ dom(Γ)

(c-prod) responsible of vacuity

Γ `c v : A

Γ `c u v : B[x ← v ] Γ `c u : A

(c-prod)

(c-var)

A ' A0 Γ `c u : A0

(c-app)

Γ `c A0 : κ (c-conv)

κ denotes Prop or Type

14/38

First attempts toward a pedagogical CC Poincarean Calculus of Constructions – CCr

Strategy change I

keep Γ wf judgements

I

avoid empty types as soon as possible

Radical idea Constrain (only) the type formation rule : Γ, x : A `c

B:κ

Γ `c ∀x A .B : κ

(c-prod)

15/38

First attempts toward a pedagogical CC Poincarean Calculus of Constructions – CCr

Strategy change I

keep Γ wf judgements

I

avoid empty types as soon as possible

Radical idea Constrain (only) the type formation rule : Γ, x : A `r u :B : κ Γ `r ∀x A .B : κ

(r-prod)

15/38

First attempts toward a pedagogical CC Poincarean Calculus of Constructions – CCr

Theorems I

respectful of the Poincaré criterion . relies on strong normalization of CC

I

subject reduction property holds . Coq proof adapted from [Barras (1996)]

I

usefulness of functions . `r f : ∀x A .B ⇒ ∃u `r u : A terms of Gödel system T can be interpreted in CCr . usual way : recursion from iteration (and trick for cartesian products)

I

But I

I

does not contain natively simply typed λ-calculus . @u A B C : Prop `r u : (A → B) → (B → C ) → (A → C ) does not prove symmetry of Leibniz equality . @u A : Prop, x y z : A `r u : x =A y → y =A z → x =A z 16/38

First attempts toward a pedagogical CC Poincarean Calculus of Constructions – CCr

Observation CCr seems too much constrained Goal increase expressive power Idea exemplifiable types should be usable . similar to pedagogical system F

Definition : converse of the Poincaré criterion CC? , sub-system of CC, meets the converse of the Poincaré criterion if : `? σ · Γ



Γ wf ?

17/38

First attempts toward a pedagogical CC Poincarean Calculus of Constructions – CCr

Observation CCr seems too much constrained Goal increase expressive power Idea exemplifiable types should be usable . similar to pedagogical system F

Definition : converse of the Poincaré criterion CC? , sub-system of CC, meets the converse of the Poincaré criterion if : `? σ · Γ and Γ wf c



Γ wf ?

Beware Exemplifiable types need not be well-formed 17/38

A formal definition and some examples Pedagogical sub-system of the Calculus of Constructions

Definition : CC? pedagogical sub-system of CC I

I

I

CC? sub-system of CC . Γ `? u : A ⇒ Γ `c u : A Subject reduction property holds for CC? . Γ `? u : A and u u 0 ⇒ Γ `? u 0 : A CC? meets Poincaré criterion and its converse . Γ wf ? ⇔ `? σ · Γ and Γ wf c

18/38

A formal definition and some examples Calculus of Constructions [Coquand and Huet (1985)]

∅ wf c

(c-env1 )

Γ, x : A, Γ0 wf c

Γ `c Prop : Type

(c-ax)

Γ, x : A, Γ0 `c x : A Γ `c u : ∀x A .B

Γ, x : A `c u : B : κ (c-abs)

(c-prod)

(c-var)

Γ `c v : A

Γ `c u v : B[x ← v ] Γ `c u : A

Γ, x : A `c B : κ Γ `c ∀x A .B : κ

(c-env2 )

Γ, x : A wf c

Γ wf c

Γ `c λx A .u : ∀x A .B

Γ `c A : κ x 6∈ dom(Γ)

A ' A0 Γ `c u : A0

(c-app)

Γ `c A0 : κ (c-conv)

κ denotes Prop or Type

19/38

A formal definition and some examples Second order λ-calculus – λ2

∅ wf 2

( env1 )

( env2 )

Γ, x : A wf 2 Γ, x : A, Γ0 wf 2

Γ wf 2 Γ `2 Prop : Type

( ax)

Γ, x : A, Γ0 `2 x : A Γ `2 u : ∀x A .B

Γ, x : A `2 u : B : Prop Γ `2 λx A .u : ∀x A .B

Γ `2 A : κ x 6∈ dom(Γ)

( abs)

( var)

Γ `2 v : A

Γ `2 u v : B[x ← v ]

( app)

Γ, x : A `2 B : Prop Γ `2 ∀x A .B : Prop

( prod)

19/38

A formal definition and some examples With explicit total exemplifications – λ2e

Goal Obtain a pedagogical version of λ2 . in the sense of the previous definition

First idea Keep examples explicit : Γ `σ u : A and Γ wf σ where I

Γ ≡ x1 : A1 , . . . , xn : An

I

σ ≡ [x1 7→ t1 , . . . , xn 7→ tn ] or in short σ ≡ [t1 , . . . , tn ]

20/38

A formal definition and some examples Second order λ-calculus – λ2

2

2 ∅ wf ∅

( env1 )

2

2

Γ, x : A, Γ0 wf σ ( ax)

2

2

( var)

Γ, x : A, Γ0 `σ x : A

Prop : Type

2

2

Γ `σ u : ∀x A .B

Γ, x : A `σ:: a u : B : Prop 2

( env2 )

2

Γ, x : A wf σ:: a

Γ wf σ Γ `σ

x 6∈ dom(Γ)

Γ `σ A : κ

( abs)

Γ `σ λx A .u : ∀x A .B

2

2

Γ `σ v : A ( app)

Γ `σ u v : B[x ← v ] 2

Γ, x : A `σ:: a B : Prop 2

( prod)

Γ `σ ∀x A .B : Prop

21/38

A formal definition and some examples With explicit total exemplifications – λ2e

2

(e-env1 ) 2 ∅ wf ∅e

Γ `σe A : κ

2

2

Γ, x : A, Γ0 wf σe (e-ax)

2

2

(e-var)

Γ, x : A, Γ0 `σe x : A

Prop : Type

2

2

Γ `σe u : ∀x A .B

e Γ, x : A `σ:: a u : B : Prop 2

(e-env2 )

2

e Γ, x : A wf σ:: a

Γ wf σe Γ `σe

x 6∈ dom(Γ)

(e-abs)

Γ `σe λx A .u : ∀x A .B

2

2

Γ `σe v : A (e-app)

Γ `σe u v : B[x ← v ] 2

e Γ, x : A `σ:: a B : Prop 2

(e-prod)

Γ `σe ∀x A .B : Prop

21/38

A formal definition and some examples With explicit total exemplifications – λ2e

2

2

(e-env1 ) 2 ∅ wf ∅e

Γ `σe A : κ

x 6∈ dom(Γ) (e-env2 )

2

e Γ, x : A wf σ:: a 2

2

Γ, x : A, Γ0 wf σe

Γ wf σe (e-ax)

2

2

(e-var)

Γ, x : A, Γ0 `σe x : A

Γ `σe o : > : Prop : Type

2

2

Γ `σe u : ∀x A .B

e Γ, x : A `σ:: a u : B : Prop 2

`∅e a : σ(A)

(e-abs)

Γ `σe λx A .u : ∀x A .B

2

Γ `σe v : A

2

(e-app)

Γ `σe u v : B[x ← v ] 2

e Γ, x : A `σ:: a B : Prop 2

2

`∅e t : σ(∀x A .B) (e-prod)

Γ `σe ∀x A .B : Prop

21/38

A formal definition and some examples With explicit total exemplifications – λ2e

Theorems I

λ2e (almost) a pedagogical sub-system of CC

I

examples contained as sub-derivations . Γ `2σe A : κ ⇒ ∃a `2∅e a : σ(A) sub-derivation exchange of exemplifications : . Γ `2σe w : C and Γ wf 2ρe ⇒ Γ `2ρe w : C

I

But λ2e not exactly sub-system of CC because : I

exemplifications are explicit

I

addition of two symbols o and >

22/38

A formal definition and some examples With explicit total exemplifications – λ2e

Theorems I

λ2e (almost) a pedagogical sub-system of CC

I

examples contained as sub-derivations . Γ `2σe A : κ ⇒ ∃a `2∅e a : σ(A) sub-derivation exchange of exemplifications : . Γ `2σe w : C and Γ wf 2ρe ⇒ Γ `2ρe w : C

I

But λ2e not exactly sub-system of CC because : I

exemplifications are explicit

I

addition of two symbols o and >

Second idea Relax constraints on exemplifications by making them implicit 22/38

A formal definition and some examples With explicit total exemplifications – λ2e 2

2

(e-env1 ) 2 ∅ wf ∅e

x 6∈ dom(Γ) (e-env2 )

2

e Γ, x : A wf σ:: a

2

2

Γ, x : A, Γ0 wf σe

Γ wf σe (e-ax)

2

2

(e-var)

Γ, x : A, Γ0 `σe x : A

Γ `σe o : > : Prop : Type

2

2

Γ `σe u : ∀x A .B

e Γ, x : A `σ:: a u : B : Prop 2

`∅e a : σ(A)

Γ `σe A : κ

(e-abs)

Γ `σe λx A .u : ∀x A .B

2

Γ `σe v : A

2

(e-app)

Γ `σe u v : B[x ← v ] 2

e Γ, x : A `σ:: a B : Prop 2

2

`∅e t : σ(∀x A .B) (e-prod)

Γ `σe ∀x A .B : Prop

23/38

A formal definition and some examples With implicit total exemplifications – λ2t 2

2 ∅ wf ∅t

Γ `σt A : κ

(t-env1 )

x 6∈ dom(Γ) (t-env2 )

2

t Γ, x : A wf σ:: a

2

2

Γ, x : A, Γ0 wf σt

Γ wf σt (t-ax)

2

2

2

2

Γ `σt u : ∀x A .B

t Γ, x : A `σ:: a u : B : Prop (t-abs)

2

(t-var)

Γ, x : A, Γ0 `σt x : A

Γ `σt o : > : Prop : Type

2

Γ `σt v : A

2

Γ `σt λx A .u : ∀x A .B

(t-app)

Γ `σt u v : B[x ← v ] 2

t Γ, x : A `σ:: a B : Prop

σ motΓ ∀x A .B (t-prod)

2

Γ `σt ∀x A .B : Prop where σ motΓ C abbreviates : 2

(a) σ exemplifies Γ, i.e. `t σ · Γ 2

(b) and there is term t such that `t t : σ(C ) 23/38

A formal definition and some examples With implicit total exemplifications – λ2t

Theorems I

λ2t equivalent to λ2e : Γ `2t t : A

I

λ2t (almost) a pedagogical sub-system of CC



∃σ

Γ `2σe t : A

But λ2t not exactly sub-system of CC because : I

addition of two symbols o and >

24/38

A formal definition and some examples With implicit total exemplifications – λ2t

Theorems I

λ2t equivalent to λ2e : Γ `2t t : A

I

λ2t (almost) a pedagogical sub-system of CC



∃σ

Γ `2σe t : A

But λ2t not exactly sub-system of CC because : I

addition of two symbols o and >

Last idea Have partial exemplifications to restore the CCr ’s behaviour : Γ `r Id : True : Prop . with Id := λAProp .λx A .x and True := ∀AProp .A → A 24/38

A formal definition and some examples With implicit total exemplifications – λ2t 2

Γ `t A : κ ∅ wf Γ wf

x 6∈ dom(Γ)

(t-env1 )

2t

Γ, x : A wf

2t

Γ, x : A, Γ0 wf (t-ax)

2

2t (t-var)

2

Γ, x : A, Γ0 `t x : A

Γ `t o : > : Prop : Type

2

Γ `t u : ∀x A .B

2

Γ, x : A `t u : B : Prop (t-abs)

2

(t-env2 )

2t

Γ `t λx A .u : ∀x A .B 2

Γ, x : A `t B : Prop

2

Γ `t v : A (t-app)

2

Γ `t u v : B[x ← v ] σ motΓ ∀x A .B (t-prod)

2

Γ `t ∀x A .B : Prop where σ motΓ C abbreviates : 2

(a) σ exemplifies Γ, i.e. `t σ · Γ 2

(b) and there is term t such that `t t : σ(C ) 25/38

A formal definition and some examples With implicit partial exemplifications – λ2p 2

Γ `p A : κ ∅ wf Γ wf

2p

Γ, x : A wf

2p

Γ, x : A, Γ0 wf (p-ax)

2

Γ `p

x 6∈ dom(Γ)

(p-env1 )

2p (p-var)

2

Γ, x : A, Γ0 `p x : A

Prop : Type

2

Γ `p u : ∀x A .B

2

Γ, x : A `p u : B : Prop (p-abs)

2

(p-env2 )

2p

2

(p-app)

2

Γ `p u v : B[x ← v ]

Γ `p λx A .u : ∀x A .B Γ, x : A `p B : Prop

2

Γ `p v : A

g Γ ∀x A .B σ mot (p-prod)

2

Γ `p ∀x A .B : Prop

where

g Γ C abbreviates : σ mot

(a) σ partially exemplifies Γ, i.e. dom(σ) ⊆ dom(Γ) 2

(b) and there is a term t such that σ(Γ) `p t : σ(C ) 25/38

A formal definition and some examples With implicit partial exemplifications – λ2p

Theorems I

λ2p equivalent to λ2t : Γ `2p t : A ⇔ Γ `2t t : A . exemplifications can be completed

I

λ2p is a pedagogical sub-system of CC . definition exemplified !

General theorems I

λ2e , λ2t and λ2p are equivalents

I

embeddings to and from pedagogical system F

I

embedding from pedagogical λ2

26/38

A formal definition and some examples With implicit partial exemplifications – λ2p

Type checking ? Undecidable for λ2e , λ2t , λ2p and system Fp : ∃t

where ∃?t

Γ `f t : A ⇔ ∃t 0 Γγ `fp t 0 : Aγ ⇔ ∃t 00 `fp t 00 : ∀~ α.Γγ → Aγ 2t ⇔ ` ∀~ αProp .Γγ → Aγ : Prop Γ `f t : A undecidable [Urzyczyn (1997)]

Idea Annotate types with terms to ensure exemplification : Γσ `Aa : κ

x 6∈ dom(Γ)

Γσ , x : Aa `Bb : Prop (env2 )

Γσ , x : Aa wf

`t : σ(∀x Aa .Bb )

Γσ `(∀x Aa .Bb )t : Prop

(prod)

where Γσ ≡ x1 : A1a1 , . . . , xn : An an and σ ≡ [x1 7→ a1 ; . . . ; xn 7→ an ]. 26/38

Toward a Pedagogical Calculus of Constructions Higher order

Goal Obtain a Pedagogical λω

New objects I

I

predicates/propositional functions . λAProp .λB Prop→Prop .B A postulated into environments . f : Prop → (Prop → Prop) → Prop

⇒ notion of predicate exemplification needed

Idea Exemplifiable predicate ⇔ useful propositional function

27/38

Toward a Pedagogical Calculus of Constructions Higher order

Exemplifiable predicate (formally) P : O1 → . . . → On → Prop exemplifiable if : I

can be completely applied

. there are ui : Oi

I

reducible to an exemplifiable type

. P ~u

Abbreviated :



R and `σ · R

σ motO1 →...→On →Prop (P)

Examplifiable predicates P := λAProp .A → A Q := λAProp .λB Prop→Prop .B A

.P > ∗ > → > . Q > (λC Prop .>)



>

Non exemplifiable predicate V := λAProp .∀B Prop .A → B

. hopefully no arguments

28/38

Toward a Pedagogical Calculus of Constructions Pedagogical higher-order λ-calculus – λω e

Beware interaction of exemplifiable predicates I

Q := λR Prop→Prop .∀F Prop .R F and Id := λAProp .A . but Q Id ∗ ⊥

Necessary constraint Γ `σ u : A → B : Type

Γ `σ v : A σ motB (u v )

Γ `σ u v : B

(ωe-app )

29/38

Toward a Pedagogical Calculus of Constructions Pedagogical higher-order λ-calculus – λω e

Beware interaction of exemplifiable predicates I

I

Q := λR Prop→Prop .∀F Prop .R F and Id := λAProp .A . but Q Id ∗ ⊥ Prop S := λAProp→Prop .λH ∀B .A B .H . but S Id ∗ λH ⊥ .H

Necessary constraint Γ `σ u : ∀x A .B : Prop

Γ `σ v : A σ motProp (B[x ← v ])

Γ `σ u v : B[x ← v ]

(ωe-app? )

29/38

Toward a Pedagogical Calculus of Constructions Pedagogical higher-order λ-calculus – λω e

Beware interaction of exemplifiable predicates I

I

Q := λR Prop→Prop .∀F Prop .R F and Id := λAProp .A . but Q Id ∗ ⊥ Prop S := λAProp→Prop .λH ∀B .A B .H . but S Id ∗ λH ⊥ .H

Necessary constraint Γ `σ u : ∀x A .B : Prop

Γ `σ v : A σ motProp (B[x ← v ])

Γ `σ u v : B[x ← v ]

(ωe-app? )

Strong : only normal form examples ? 29/38

Toward a Pedagogical Calculus of Constructions Pedagogical higher-order λ-calculus – λω e

Theorems I

λωe satisfies Poincaré criterion

I

λωe satisfies the converse Poincaré criterion

I

subject reduction still conjectured . usual substitution lemma invalid : A : ? → ? `λz ? .> λH ∀B `∅ λC ? .C : ? → ? 6`∅ λH ∀B

?

.(λC ? .C ) B

?

.A B

.H : (∀B ? .A B) → (∀B ? .A B) : ?

.H : (∀B ? .(λC ? .C ) B) → (∀B ? .(λC ? .C ) B)

where ? := Prop

30/38

Toward a Pedagogical Calculus of Constructions Summary of necessary constraints

Γ `A : s1

Γ, x : A `B : s2

Γ `∀x A .B : s2

(prod)

(s1 , s2 ) λ2 λω (Prop, Prop) 3 3 (Type, Prop) 7 7 (Prop, Type) (Type, Type) 3 I

3 instance of the rule does not produce empty type

I

7 instance of the rule can produce empty types

31/38

Toward a Pedagogical Calculus of Constructions Summary of necessary constraints

Γ `A : s1

Γ, x : A `B : s2

Γ `∀x A .B : s2

(prod)

(s1 , s2 ) λ2 λω λC (Prop, Prop) 3 3 7 7 (Type, Prop) 7 7 (Prop, Type) 3 (Type, Type) 3 3 I

3 instance of the rule does not produce empty type

I

7 instance of the rule can produce empty types

31/38

Toward a Pedagogical Calculus of Constructions Summary of necessary constraints

Γ `v : A : s1

Γ `u : ∀x A .B : s2

Γ `u v : B[x ← v ]

(app)

(s1 , s2 ) λ2 λω (Prop, Prop) 3 3 (Type, Prop) 3 7 (Prop, Type) (Type, Type) 7 I

3 instance of the rule does not produce empty type

I

7 instance of the rule can produce empty types

32/38

Toward a Pedagogical Calculus of Constructions Summary of necessary constraints

Γ `v : A : s1

Γ `u : ∀x A .B : s2

Γ `u v : B[x ← v ]

(app)

(s1 , s2 ) λ2 λω λC (Prop, Prop) 3 3 7 (Type, Prop) 3 7 7 7 (Prop, Type) 7 (Type, Type) 7 I

3 instance of the rule does not produce empty type

I

7 instance of the rule can produce empty types

32/38

Toward a Pedagogical Calculus of Constructions Pedagogical Calculus of Constructions ?

∅ wf cσe Γ `cσe A : κ

`c∅e a : A0 Γ, x :

(env1 )

σ(A)



A0

x 6∈ dom(Γ) (env2 )

e A wf cσ::(x 7→ a)

Γ wf cσe Γ `cσe o : > : Prop : Type Γ, x : A, Γ0 wf cσe Γ, x : A, Γ0 `cσe x : A

(ax)

(var)

e Γ, x : A `cσ::(x 7→ a) u : B : κ

Γ `cσe λx A .u : ∀x A .B

(abs)

33/38

Toward a Pedagogical Calculus of Constructions Pedagogical Calculus of Constructions ?

Γ `cσe u : ∀x A .B : Prop

Γ `cσe v : A σ motProp (B[x ← v ])

Γ `cσe u v : B[x ← v ] Γ `cσe u : ∀x A .B : Type

Γ `cσe v : A σ motB[x←v ] (u v )

Γ `cσe u v : B[x ← v ] e Γ, x : A `cσ::(x 7→ a) B : Prop

e Γ, x : A `cσ::(x 7→ a) B : Type

Γ `cσe ∀x A .B : Type Γ `cσe u : A0

(app )

σ motProp (∀x A .B) (prod? )

Γ `cσe ∀x A .B : Prop

Γ `cσe u : A A ' A0

(app? )

(prod )

Γ `cσe A0 : κ

(conv)

33/38

Conclusion and further work Contributions I

formal definition of pedagogical sub-system of CC

I

examples of pedagogical sub-system of CC (λ2e , λ2t , λ2p , λωe )

I

formalisms with explicit examples

I

study of type checking pedagogical calculi

I

motivated conjectures : pedagogical higher-order and Calculus of Constructions

Further work I

show the conjectures

I

study machine implementation

I

extend to stronger systems

I

formal verification of Griss’ negationless mathematics

I

study inconsistency and pedagogy 34/38

Certification of Spike proofs Ideas on an example

Spike specification function symbols 0 : nat S : nat → nat + : nat nat → nat

Spike proof `case_variable `rewrite `delete `injection `subsumption

axioms 0+y = y S(x) + y = S(x + y )

symbol precedence 0