Proof Objects

Table of Contents


Homepage | Previous: IndProp.v | Code | Next: IndPrinciples.v

1. Summary

Curry-Howard correspondence. Proofs are programs, types are propositions. You can prove something using tactics, or by constructing a proof object, which are programs. Or you can construct a program by using tactics. Functions are syntactic sugar for universal quantification. All other logical connectives are defined inductively. True has one constructor and False has none.

1.1. TODO Terms

Curry-Howard correspondence, proof objects, propositional extensionality, proof irrelevance

2. Notes

Coq has mechanisms for programming and for proving properties of programs - inductive data types and inductive propositions respectively.

These mechanisms are thought of as separete, but under the “Curry-Howard Correspondence”, they are the same. This is hinted in how the Inductive keyword can be used to declare both data types and propositions.

Provability in Coq is represented by concrete evidence. Constructing a proof of a basic propositions is the same as constructing a tree of evidence.

(Other sources might call “proof” as “derivation” and “evidence” as “proof” instead.)

The proposition “A -> B” is proven with an evidence transformer, one that takes evidence for A and creates evidence for B. (Sounds similar to what a function is!)

This is called the Curry-Howard Correspondence: Proofs are programs that manipulate evidence. Propositions are types.

2.1. Proof Scripts

When Coq is following a proof script (sequence of tactics), it is gradually constructing a proof object.

You can also simply construct the required evidence by hand (by supplying a proof term).

Here is a proof that 4 is even using tactics:

Theorem ev_4'' : ev 4.
Proof.
  Show Proof.
  apply ev_SS.
  Show Proof.
  apply ev_SS.
  Show Proof.
  apply ev_0.
  Show Proof.
Qed.

Here is a proof that 4 is even by supplying evidence (a proof object).

Definition ev_4''' : ev 4 :=
  ev_SS 2 (ev_SS 0 ev_0).

2.2. Quantifiers, Implications, Functions

Consider the following:

Theorem ev_plus4 : forall n, ev n → ev (4 + n).
Proof.
  intros n H. simpl.
  apply ev_SS.
  apply ev_SS.
  apply H.
Qed.

The corresponding proof object would be an expression whose type is the proposition forall n, ev n → ev (4 + n) itself:

Definition ev_plus4' :  n, ev n → ev (4 + n) :=
  fun (n : nat) ⇒ fun (H : ev n) ⇒
    ev_SS (S (S n)) (ev_SS n H).

We realise that implication -> and quantification forall are the same thing - both introduce something that can be used in the body of the proof object.

-> is a degenerate use of forall where there is no need to give a name to the thing being introduced.

In general, P -> Q is just syntactic sugar for forall (_:P), Q-.

This notion is particularly important when constructing proof objects for propositions with quantifiers.

2.3. Programming with Tactics

We can build proofs by supplying a proof object (i.e. a program). It turns out, we can also build program using tactics.

Definition add1 : nat → nat.
intro n.
Show Proof.
apply S.
Show Proof.
apply n. Defined.
Print add1.
(* ==>
    add1 = fun n : nat => S n
         : nat -> nat
*)
Compute add1 2.
(* ==> 3 : nat *)

2.4. Logical Connectives

Logical connectives can be inductively defined.

  • Conjunction. To prove P /\ Q, prove both P and Q.

    Inductive and (P Q : Prop) : Prop :=
      | conj : P → Q → and P Q.
    
  • Disjunction.

To prove P \/ Q, either prove P or prove Q.

Inductive or (P Q : Prop) : Prop :=
  | or_introl : P → or P Q
  | or_intror : Q → or P Q.
  • Existential Quantification

    To prove exists x. P x, provide a witness x and a proof of P x.

    Inductive ex {A : Type} (P : A → Prop) : Prop :=
      | ex_intro :  x : A, P x → ex P.
    
  • True and False

    True has one constructor I and False has no constructor.

    Inductive True : Prop :=
      | I : True.
    
    Inductive False : Prop := .
    

2.5. Equality

Equality is defined as:

  Inductive eq {X:Type} : X → X → Prop :=
  | eq_refl :  x, eq x x.

There is another notion of equivalence similar to functional extensionality:

Definition propositional_extensionality : Prop :=
   (P Q : Prop), (P ↔ Q) → P = Q.

Quoting,

Propositional extensionality asserts that if two propositions are equivalent – i.e., each implies the other – then they are in fact equal. The proof objects for the propositions might be syntactically different terms. But propositional extensionality overlooks that, just as functional extensionality overlooks the syntactic differences between functions.

3. Exercises

3.1. eight_is_even

2 stars, standard

3.2. conj_fact

2 stars, standard

3.3. or_commut'

2 stars, standard

3.4. ex_ev_Sn

2 stars, standard

3.5. ex_match

2 stars, standard

3.6. p_implies_true

1 star, standard

3.7. ex_falso_quodlibet'

1 star, standard

3.8. eq_cons

2 stars, standard

3.9. equality__leibniz_equality

2 stars, standard

3.10. equality__leibniz_equality_term

2 stars, standard

3.11. leibniz_equality__equality

3 stars, standard, optional

3.12. and_assoc

2 stars, standard

3.13. or_distributes_over_and

3 stars, standard

3.14. negations

3 stars, standard

3.15. currying

2 stars, standard

3.16. pe_implies_or_eq

1 star, advanced

3.17. pe_implies_true_eq

1 star, advanced

3.18. TODO pe_implies_pi

3 stars, advanced

Stuck at showing that pf1 and pf2 is equal to I.

4. Scores

33/36

5. TODO Questions

6. Metacognition

Constructing proof terms is very fun :)

7. TODO Further Knowledge

Author: selffins

Created: 2025-04-12 Sat 22:33