Skip to content

Commit

Permalink
New notations for PR functions and FOL formulas (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
Casteran committed Oct 27, 2023
1 parent 432f5b4 commit 5ac3861
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
12 changes: 5 additions & 7 deletions theories/ordinals/Ackermann/cPair.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Require Import Arith Coq.Lists.List Lia.
From hydras Require Import extEqualNat primRec.
From hydras Require Export Compat815 ssrnat_extracts.

Import PRNotations.
Import Nat.


Expand Down Expand Up @@ -603,13 +603,11 @@ Proof.
induction H0 as (x0, p0).
induction H1 as (x1, p1).
exists
(primRecFunc n (composeFunc n 0 (PRnil _) zeroFunc)
(composeFunc (S (S n)) 2
(PRcons _ _ x
(PRcons _ _ (projFunc n.+2 n
(primRecFunc n (PRcomp zeroFunc [ ])
(PRcomp x0
[ x ; projFunc n.+2 n
(Nat.lt_lt_succ_r n n.+1
(Nat.lt_succ_diag_r n)))
(PRnil _))) x0)).
(Nat.lt_succ_diag_r n))]))%pr.
apply
extEqualTrans
with
Expand Down
14 changes: 6 additions & 8 deletions theories/ordinals/Ackermann/primRec.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Require Export Bool.
Require Export EqNat.
Require Import Lia.


(** * Definitions *)

(** [PrimRec n] : data type of primitive recursive functions of arity [n]
Expand Down Expand Up @@ -72,7 +73,7 @@ End PRNotations.

(* end snippet PRNotations *)


Import PRNotations.


Scheme PrimRec_PrimRecs_rec := Induction for PrimRec Sort Set
Expand Down Expand Up @@ -351,30 +352,27 @@ Proof. exists succFunc; cbn; reflexivity. Qed.
Proof.
induction n as [|n [x Hx]].
- exists zeroFunc; reflexivity.
- exists (composeFunc _ _ (PRcons _ _ x (PRnil _)) succFunc);
cbn; now rewrite Hx.
- exists (PRcomp succFunc [x]%pr)%pr; cbn; now rewrite Hx.
Qed.

#[export] Instance const1_NIsPR n: isPR 1 (fun _ => n).
Proof.
destruct (const0_NIsPR n) as [x Hx].
exists (composeFunc 1 _ (PRnil _) x); cbn in *; auto.
exists (PRcomp x [])%pr; cbn in *; auto.
Qed.

(** ** Usual projections (in curried form) are primitive recursive *)

(* begin snippet idIsPR:: no-out *)
#[export] Instance idIsPR : isPR 1 (fun x : nat => x).
Proof.
assert (H: 0 < 1) by auto.
exists (projFunc 1 0 H); cbn; auto.
exists pi1_1; cbn; reflexivity.
Qed.
(* end snippet idIsPR *)

#[export] Instance pi1_2IsPR : isPR 2 (fun a b : nat => a).
Proof.
assert (H: 1 < 2) by auto.
exists (projFunc _ _ H); cbn; reflexivity.
exists pi1_2; cbn; reflexivity.
Qed.

#[export] Instance pi2_2IsPR : isPR 2 (fun a b : nat => b).
Expand Down
12 changes: 6 additions & 6 deletions theories/ordinals/MoreAck/PrimRecExamples.v
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Compute (evalPrimRec _ pi2_3) 1 2 3.
.. coq:: no-out
|*)

Check (PRcons _ _ pi2_3 (PRnil _)).
Check [pi2_3]%pr.

Definition plus := (PRrec pi1_1
(PRcomp succFunc [pi2_3]))%pr.
Expand Down Expand Up @@ -203,7 +203,7 @@ End MoreExamples.
make the construction more concrete *)

Definition PRcompose1 (g f : PrimRec 1) : PrimRec 1 :=
composeFunc 1 _ (PRcons _ _ f (PRnil _) ) g.
PRcomp g [f]%pr.

Goal forall f g x, evalPrimRec 1 (PRcompose1 g f) x =
evalPrimRec 1 g (evalPrimRec 1 f x).
Expand Down Expand Up @@ -321,8 +321,7 @@ Fact compose_01 :
forall (x:PrimRec 0) (t : PrimRec 1),
let c := evalPrimRec 0 x in
let f := evalPrimRec 1 t in
evalPrimRec 0
(composeFunc 0 1 (PRcons 0 0 x (PRnil 0)) t)
evalPrimRec 0 (PRcomp t [x])%pr
= f c.
Proof. reflexivity. Qed.
(*||*)
Expand All @@ -341,7 +340,7 @@ Proof.
induction n.
- apply zeroIsPR.
- destruct IHn as [x Hx].
exists (composeFunc 0 1 (PRcons 0 0 x (PRnil 0)) succFunc).
exists (PRcomp succFunc [x])%pr.
cbn in *; intros; now rewrite Hx.
Qed.

Expand Down Expand Up @@ -455,7 +454,8 @@ Qed.

(* Move to MoreAck *)

Section Exs. (* Todo: exercise *)Let f: naryFunc 2 := fun x y => x + pred (cPairPi1 y).
Section Exs. (* Todo: exercise *)
Let f: naryFunc 2 := fun x y => x + pred (cPairPi1 y).

(* To prove !!! *)

Expand Down

0 comments on commit 5ac3861

Please sign in to comment.