inductive predicates unit vs true inductive unit : set := tt : unit inductive true : prop := i :...

6
Inductive Predicates Unit vs True Inductive unit : Set := tt : unit Inductive True : Prop := I : True Curry Howard Isomorphism But Coq distinguish Proof and Program Efficiency? Proof Prevalence?

Upload: magdalene-white

Post on 17-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

Inductive Predicates Unit vs True

Inductive unit : Set := tt : unit Inductive True : Prop := I : True Curry Howard Isomorphism But Coq distinguish Proof and Program

Efficiency? Proof Prevalence?

Page 2: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

Propositional Logic not = fun A : Prop => A -> False

     : Prop -> Prop Inductive and (A : Prop) (B : Prop) : Prop :=

conj : A -> B -> A /\ B Inductive or (A : Prop) (B : Prop) : Prop :=

    or_introl : A -> A \/ B | or_intror : B -> A \/ B

Page 3: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

Bool Vs Prop bool is datatype of two members, true, false Prop is primitive type in Coq, and True, False

are two members in Prop Coq use Constructive Logic, while P\/~P is not

allowed Issues

bool is decidable Constructive logic allow us to extract program

from proof We can write program by proof a theorem, though

maybe less efficient

Page 4: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

First-Order Logic forall and exists

forall is built-in exists:

Inductive ex (A : Type) (P : A -> Prop) : Prop :=    ex_intro : forall x : A, P x -> ex P

Page 5: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

Tactics Tauto

Solve intuition logic, only unfold not Intuition

Use tauto, and apply tactics Intuition=intuition auto.

Firstorder Extend tauto to firstorder logic

Trivial Restricted auto

auto Eauto

Auto using eapply, generate ‘_’

Page 6: Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish

Basic dependant type Inductive isZero : nat -> Prop :=

| IsZero : isZero 0. Inductive even : nat -> Prop :=

| EvenO : even O| EvenSS : forall n, even n -> even (S (S n)).

Example of product: forall a:A,B (s,s’,s’’) 约束 分类(s,s’,s’) s,s’ {Set,Prop} 普通的类型(Type,Prop,Prop)

(s,Type,Type) Type denpends on a value

(Type,Type,Type) High order type