Exercise session 5 — Advanced elimination / induction — Solutions

Authors:

Yannick Forster

Théo Winterhalter

Files:
Set Default Goal Selector "!".

Set Default Goal Selector "!".

From Stdlib Require Import Arith Lia List.
Import ListNotations.

Exercise: Booleans in Prop

Define a copy of Booleans called boolp that lives in Prop. Show that you can go from bool to boolp. Can you do the converse? Why? What would a surjective function from boolp to bool mean for proof irrelevance? (We want to see a proof.)

Inductive boolp : Prop := ptrue' | pfalse'.

Definition to_boolp (b : bool) : boolp :=
  if b then ptrue' else pfalse'.

Answer. We can't go the other way because boolp doesn't satisfy the subsingleton criterion: it has two constructors.

If we assume such a function, then we can negate proof irrelevance.


forall f : boolp -> bool, (forall b : bool, b = f (to_boolp b)) -> ~ (forall (P : Prop) (u v : P), u = v)

forall f : boolp -> bool, (forall b : bool, b = f (to_boolp b)) -> ~ (forall (P : Prop) (u v : P), u = v)
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: forall (P : Prop) (u v : P), u = v

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'
e1: true = f (to_boolp true)

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'
e1: true = f (to_boolp true)
e2: false = f (to_boolp false)

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'
e1: true = f ptrue'
e2: false = f pfalse'

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'
e1: true = f pfalse'
e2: false = f pfalse'

False
f: boolp -> bool
hf: forall b : bool, b = f (to_boolp b)
PI: ptrue' = pfalse'
e1: true = false
e2: false = f pfalse'

False
discriminate. Qed.

Exercise: Surjectivity

Prove that for all p : boolp, there exists some b : bool such that its mapping to boolp is equal to p.


forall p : boolp, exists b : bool, to_boolp b = p

forall p : boolp, exists b : bool, to_boolp b = p

exists b : bool, to_boolp b = ptrue'

exists b : bool, to_boolp b = pfalse'

exists b : bool, to_boolp b = ptrue'

to_boolp true = ptrue'
reflexivity.

exists b : bool, to_boolp b = pfalse'
unshelve eexists ; econstructor. Qed.

Exercise: Existential quantifier and Σ types

exists (x : A), P x and { x : A | P x } are two very similar types but the former lives in Prop while the latter is in Type. Show how one implies the other. Why is the other implication not provable?

A: Type
P: A -> Prop

{x : A | P x} -> exists x : A, P x
A: Type
P: A -> Prop

{x : A | P x} -> exists x : A, P x
A: Type
P: A -> Prop
x: A
h: P x

exists x0 : A, P x0
A: Type
P: A -> Prop
x: A
h: P x

P x
assumption. Qed.

Answer. The other implication once again would eliminate a proof (whose type is in Prop) to produce a value, and that is not allowed.

Exercise: Disjunction and sum

P \/ Q and A + B are also similar types. The first you know as disjunction of propositions, the other one is relevant data that contains either a value of type A, or a value of type B.

Prove that P + Q -> P \/ Q, ideally with a proof term.

Why is the other implication not provable?

Notation "{ A } + { B }" := (sumbool A B) (* A in scope _type_scope, B in scope _type_scope *) : type_scope (default interpretation) (from Corelib.Init.Specif) Notation "A + { B }" := (sumor A B) (* A in scope _type_scope, B in scope _type_scope *) : type_scope (default interpretation) (from Corelib.Init.Specif) Notation "x + y" := (Init.Nat.add x y) (* x in scope _nat_scope, y in scope _nat_scope *) : nat_scope (default interpretation) (from Corelib.Init.Peano) Notation "x + y" := (sum x y) (* x in scope _type_scope, y in scope _type_scope *) : type_scope (from Corelib.Init.Datatypes)
Inductive sum (A B : Type) : Type := inl : A -> A + B | inr : B -> A + B. Arguments sum (A B)%_type_scope Arguments inl {A B}%_type_scope _, [_] _ _ Arguments inr {A B}%_type_scope _, _ [_] _
Definition to_disj {P Q : Prop} (x : P + Q) : P \/ Q := match x with | inl p => or_introl p | inr q => or_intror q end.

Answer. Same answer as usual, one cannot examine a proof to produce so-called relevant data (in Type).

Exercise: Existential quantifier on Booleans

We can't show that (exists x, P x) -> { x : A | P x } in general, but we can when A is bool and when P x is of the form f x = true. Show it.


forall f : bool -> bool, (exists b : bool, f b = true) -> {b : bool | f b = true}

forall f : bool -> bool, (exists b : bool, f b = true) -> {b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true

{b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = true

{b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = false
{b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = true

{b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = true

f true = true
assumption.
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = false

{b : bool | f b = true}
f: bool -> bool
h: exists b : bool, f b = true
etrue: f true = false

f false = true
f: bool -> bool
b: bool
e: f b = true
etrue: f true = false

f false = true
f: bool -> bool
e: f true = true
etrue: f true = false

f false = true
f: bool -> bool
e: f false = true
etrue: f true = false
f false = true
f: bool -> bool
e: f true = true
etrue: f true = false

f false = true
f: bool -> bool
e: f true = true
etrue: true = false

f false = true
discriminate.
f: bool -> bool
e: f false = true
etrue: f true = false

f false = true
assumption. Qed.

Exercise: True is a singleton

Show that, for any P : True -> Type, it is enough to prove P I to prove any P p. Try to do it with a proof term and explain why it is allowed.

Definition true_rect (P : True -> Type) (h : P I) (t : True) : P t :=
  match t with I => h end.

Answer. This elimination is allowed because True satisfies the subsingleton criterion:

  • It has exactly one constructor I (so in particular at most one).

  • I has no arguments, so in particular all its non-parameter arguments are proofs.

Exercise: Ex falso

Write a term that goes from False to any A : Type. Explain why this term is allowed.

Definition exfalso'' {A : Type} (bot : False) : A :=
  match bot with end.

Answer. This elimination is allowed because False satisfies the subsingleton criterion:

  • It has no constructors (so in particular at most one).

  • So, vacuously, all non-parameter arguments of constructors are proofs.

Exercise: Conjunction

We have seen above that disjunction did not satisfy the subsingleton criterion. What about conjunction? State the equivalence between P * Q and P /\ Q. Either give a proof script that fails because conjunction does not satisfy the subsingleton criterion, or give a proof script that works because it does. Explain why it satisfies it or not.

P, Q: Prop

(P /\ Q -> P * Q) * (P * Q -> P /\ Q)
P, Q: Prop

(P /\ Q -> P * Q) * (P * Q -> P /\ Q)
P, Q: Prop

P /\ Q -> P * Q
P, Q: Prop
P * Q -> P /\ Q
P, Q: Prop

P /\ Q -> P * Q
P, Q: Prop
p: P
q: Q

P * Q
P, Q: Prop
p: P
q: Q

P
P, Q: Prop
p: P
q: Q
Q
all: assumption.
P, Q: Prop

P * Q -> P /\ Q
P, Q: Prop
p: P
q: Q

P /\ Q
P, Q: Prop
p: P
q: Q

P
P, Q: Prop
p: P
q: Q
Q
all: assumption. Qed.

Answer. Conjunction does satisfy the subsingleton criterion:

  • It has exactly one constructor conj (so in particular at most one).

  • conj has two arguments p : P and q : Q that are proofs, so in particular all its non-parameter arguments are proofs.

Exercise: Singleton version of le

Propose a version of le that satisfies the singleton criterion (in particular, make sure it is defined in Prop). You can use the goal below with le (<=) and with your le'. It should only work with le'. Is it satisfying? If not you can try and think if you can't define one (perhaps not with the Inductive keyword) that works a bit better. Be warned: you probably won't be satisfied either.


forall n m : nat, n <= m -> nat

forall n m : nat, n <= m -> nat
n, m: nat
h: n <= m

nat
The command has indeed failed with message: Incorrect elimination in the inductive type "le": the return type has sort "Set" while it should be SProp or Prop. Elimination of an inductive object of sort Prop is not allowed on a predicate in sort "Set" because proofs can be eliminated only to build proofs.
n, m: nat
h: n <= m

nat
Abort.
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]
le' is nested using or. No scheme for or is registered as All. It can be generated using command "Scheme All" e.g. "Scheme All for or.". [register-all,automation,default]

forall n m : nat, le' n m -> nat

forall n m : nat, le' n m -> nat
n, m: nat
h: le' n m

nat
n, m: nat
H: n = m \/ le' n (Init.Nat.pred m)

nat

We can't actually do much, it's a bit like Box in the end.

Abort.

Alternatively we can define le with a fixed point to actually extract info.

Fixpoint le_alt (n m : nat) : Prop :=
  match n, m with
  | 0, _ => True
  | S n, 0 => False
  | S n, S m => le_alt n m
  end.

But then, we're not really destructing the proof, but rather the natural numbers. In particular, we can't perform induction on the proof itself.

Fixpoint le_dec n m : { le_alt n m } + { ~ le_alt n m } :=
  match n, m with
  | 0, _ => left I
  | S n, 0 => right (fun x => x)
  | S n, S m => le_dec n m
  end.

Exercise: Binary trees

Define an inductive type bintree' for binary trees. Write down both type and term for bintree_rect' (the induction principle with Type-valued motive) manually.

Inductive bintree' A :=
| bt_leaf' (a : A)
| bt_node' (a : A) (l r : bintree' A).

Arguments bt_leaf' {A}.
Arguments bt_node' {A}.

Fixpoint bintree_rect' {A} (P : bintree' A -> Type)
  (hl : forall a, P (bt_leaf' a))
  (hn : forall a l, P l -> forall r, P r -> P (bt_node' a l r))
  (t : bintree' A) : P t :=
  match t with
  | bt_leaf' a => hl a
  | bt_node' a l r =>
    hn _ _ (bintree_rect' P hl hn l) _ (bintree_rect' P hl hn r)
  end.

Exercise: Map on binary trees

Define a map function for it, and show mapping with the identity results in the identity on binary trees.

Fixpoint bt_map' {A B} (f : A -> B) (t : bintree' A) : bintree' B :=
  match t with
  | bt_leaf' a => bt_leaf' (f a)
  | bt_node' a l r => bt_node' (f a) (bt_map' f l) (bt_map' f r)
  end.


forall (A : Type) (t : bintree' A), bt_map' (fun x : A => x) t = t

forall (A : Type) (t : bintree' A), bt_map' (fun x : A => x) t = t
A: Type
t: bintree' A

bt_map' (fun x : A => x) t = t
A: Type
a: A

bt_map' (fun x : A => x) (bt_leaf' a) = bt_leaf' a
A: Type
a: A
l, r: bintree' A
ihl: bt_map' (fun x : A => x) l = l
ihr: bt_map' (fun x : A => x) r = r
bt_map' (fun x : A => x) (bt_node' a l r) = bt_node' a l r
A: Type
a: A

bt_map' (fun x : A => x) (bt_leaf' a) = bt_leaf' a
reflexivity.
A: Type
a: A
l, r: bintree' A
ihl: bt_map' (fun x : A => x) l = l
ihr: bt_map' (fun x : A => x) r = r

bt_map' (fun x : A => x) (bt_node' a l r) = bt_node' a l r
A: Type
a: A
l, r: bintree' A
ihl: bt_map' (fun x : A => x) l = l
ihr: bt_map' (fun x : A => x) r = r

bt_node' a (bt_map' (fun x : A => x) l) (bt_map' (fun x : A => x) r) = bt_node' a l r
A: Type
a: A
l, r: bintree' A
ihl: bt_map' (fun x : A => x) l = l
ihr: bt_map' (fun x : A => x) r = r

bt_node' a l r = bt_node' a l r
reflexivity. Qed.

Exercise: Induction principle for indexed type

Define an inductive type dtree A : nat -> Type for binary trees indexed by their depth. State and prove (with a term) its Type-valued induction principle.

Inductive dtree A | : nat -> Type :=
| dleaf (a : A) : dtree 0
| dnode {n m} (a : A) (l : dtree n) (r : dtree m) : dtree (max n m).

Arguments dleaf {A}.
Arguments dnode {A n m}.
Fixpoint dtree_rect' {A} (P : forall n, dtree A n -> Type)
  (hl : forall a, P 0 (dleaf a))
  (hn : forall n m a l, P n l -> forall r, P m r -> P _ (dnode a l r))
  n (t : dtree A n) : P n t :=
  match t with
  | dleaf a => hl a
  | @dnode _ n m a l r =>
    hn _ _ _ _ (dtree_rect' P hl hn n l) _ (dtree_rect' P hl hn m r)
  end.

(* From the lecture: *)

Scheme All for list.

Inductive tree A :=
| node (a : A) (children : list (tree A)).

Arguments node {A}.

Fixpoint tree_map {A B} (f : A -> B) (t : tree A) : tree B :=
  match t with
  | node a l => node (f a) (map (tree_map f) l)
  end.

Exercise: Using list_all

Prove the following lemma.

A: Type
t: tree A

tree_map (fun x : A => x) t = t
A: Type
t: tree A

tree_map (fun x : A => x) t = t
A: Type
a: A
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l

tree_map (fun x : A => x) (node a l) = node a l
A: Type
a: A
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l

node a (map (tree_map (fun x : A => x)) l) = node a l
A: Type
a: A
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l

map (tree_map (fun x : A => x)) l = l
A: Type
a: A

map (tree_map (fun x : A => x)) [] = []
A: Type
a: A
a0: tree A
p: tree_map (fun x : A => x) a0 = a0
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l
IHih: map (tree_map (fun x : A => x)) l = l
map (tree_map (fun x : A => x)) (a0 :: l) = a0 :: l
A: Type
a: A

map (tree_map (fun x : A => x)) [] = []
reflexivity.
A: Type
a: A
a0: tree A
p: tree_map (fun x : A => x) a0 = a0
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l
IHih: map (tree_map (fun x : A => x)) l = l

map (tree_map (fun x : A => x)) (a0 :: l) = a0 :: l
A: Type
a: A
a0: tree A
p: tree_map (fun x : A => x) a0 = a0
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l
IHih: map (tree_map (fun x : A => x)) l = l

tree_map (fun x : A => x) a0 :: map (tree_map (fun x : A => x)) l = a0 :: l
A: Type
a: A
a0: tree A
p: tree_map (fun x : A => x) a0 = a0
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l
IHih: map (tree_map (fun x : A => x)) l = l

tree_map (fun x : A => x) a0 = a0
A: Type
a: A
a0: tree A
p: tree_map (fun x : A => x) a0 = a0
l: list (tree A)
ih: list_all (tree A) (fun t : tree A => tree_map (fun x : A => x) t = t) l
IHih: map (tree_map (fun x : A => x)) l = l
map (tree_map (fun x : A => x)) l = l
all: assumption. Qed.

Exercise: Nested induction principle by hand

You already had an exercise about defining a nice induction principle for tree using Forall (which is the special case of list_all for Prop-valued predicates). To switch things up we'll be using a different method, using In.

State and prove the induction principle for tree called tree_ind_in. You will likely have to use the fix tactic, and probably the revert tactic to generalise the goal (revert x is basically the opposite of intro x).


forall (A : Type) (P : tree A -> Prop), (forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)) -> forall t : tree A, P t

forall (A : Type) (P : tree A -> Prop), (forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)) -> forall t : tree A, P t
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)

forall t : tree A, P t
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t

forall t : tree A, P t
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
l: list (tree A)

P (node a l)
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
l: list (tree A)

forall x : tree A, In x l -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A

forall (l : list (tree A)) (x : tree A), In x l -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x

forall (l : list (tree A)) (x : tree A), In x l -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
l: list (tree A)

forall x : tree A, In x l -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x

forall x : tree A, In x [] -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)
forall x0 : tree A, In x0 (x :: l) -> P x0
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x

forall x : tree A, In x [] -> P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
y: tree A
Hy: In y []

P y
destruct Hy.
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)

forall x0 : tree A, In x0 (x :: l) -> P x0
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)
y: tree A
Hy: In y (x :: l)

P y
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)

P x
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)
y: tree A
Hy: In y l
P y
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)

P x
apply ind.
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)
y: tree A
Hy: In y l

P y
A: Type
P: tree A -> Prop
h: forall (a : A) (l : list (tree A)), (forall x : tree A, In x l -> P x) -> P (node a l)
ind: forall t : tree A, P t
a: A
aux: forall (l : list (tree A)) (x : tree A), In x l -> P x
x: tree A
l: list (tree A)
y: tree A
Hy: In y l

In y l
assumption. Qed.

You can add using tree_ind_in to an induction command to instruct Rocq to use your custom induction principle instead. Use it to prove the following.

A: Type
t: tree A

tree_map (fun x : A => x) t = t
A: Type
t: tree A

tree_map (fun x : A => x) t = t
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

tree_map (fun x : A => x) (node a l) = node a l
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

node a (map (tree_map (fun x : A => x)) l) = node a l
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

map (tree_map (fun x : A => x)) l = l
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

map ?g l = l
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x
forall a0 : tree A, In a0 l -> tree_map (fun x : A => x) a0 = ?g a0
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

map ?g l = l
apply map_id.
A: Type
a: A
l: list (tree A)
ih: forall x : tree A, In x l -> tree_map (fun x0 : A => x0) x = x

forall a0 : tree A, In a0 l -> tree_map (fun x : A => x) a0 = (fun x : tree A => x) a0
firstorder. Qed.

Exercise: Strong induction on natural numbers

We have seen strong induction on nat already, but show it again and use it to prove the following lemma that corresponds to induction on natural numbers with access to the two previous cases.


forall P : nat -> Prop, (forall n : nat, (forall m : nat, m < n -> P m) -> P n) -> forall n : nat, P n

forall P : nat -> Prop, (forall n : nat, (forall m : nat, m < n -> P m) -> P n) -> forall n : nat, P n
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat

P n
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat

forall m : nat, m < n -> P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n

forall m : nat, m < 0 -> P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
forall m : nat, m < S n -> P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n

forall m : nat, m < 0 -> P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
m: nat
hm: m < 0

P m
inversion hm.
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m

forall m : nat, m < S n -> P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n

P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
H0: m = n

P n
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
m0: nat
H0: S m <= n
H: m0 = n
P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
H0: m = n

P n
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
H0: m = n

forall m0 : nat, m0 < n -> P m0
assumption.
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
m0: nat
H0: S m <= n
H: m0 = n

P m
P: nat -> Prop
h: forall n : nat, (forall m : nat, m < n -> P m) -> P n
n: nat
ih: forall m : nat, m < n -> P m
m: nat
hm: m < S n
m0: nat
H0: S m <= n
H: m0 = n

m < n
lia. Qed.

forall P : nat -> Prop, P 0 -> P 1 -> (forall n : nat, P n -> P (S n) -> P (S (S n))) -> forall n : nat, P n

forall P : nat -> Prop, P 0 -> P 1 -> (forall n : nat, P n -> P (S n) -> P (S (S n))) -> forall n : nat, P n
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat

P n
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < n -> P m

P n
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
ih: forall m : nat, m < 0 -> P m

P 0
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
ih: forall m : nat, m < 1 -> P m
P 1
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m
P (S (S n))
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m

P (S (S n))
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m

P n
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m
P (S n)
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m

n < S (S n)
P: nat -> Prop
h0: P 0
h1: P 1
hSS: forall n : nat, P n -> P (S n) -> P (S (S n))
n: nat
ih: forall m : nat, m < S (S n) -> P m
S n < S (S n)
all: lia. Qed.

Exercise: Fibonacci

Use the induction tactic with nat_ind_2 to prove that the Fibonacci sequence is always above its index (n <= fib n).

Fixpoint fib n :=
  match n with
  | 0 => 1
  | 1 => 1
  | S (S n as m) => fib n + fib m
  end.


forall n : nat, n <= fib n

forall n : nat, n <= fib n
n: nat

n <= fib n

0 <= fib 0

1 <= fib 1
n: nat
hn: n <= fib n
hSn: S n <= fib (S n)
S (S n) <= fib (S (S n))

0 <= fib 0

0 <= 1
auto.

1 <= fib 1

1 <= 1
auto.
n: nat
hn: n <= fib n
hSn: S n <= fib (S n)

S (S n) <= fib (S (S n))
n: nat
hn: n <= fib n
hSn: S n <= fib (S n)

S (S n) <= fib n + fib (S n)
hn: 0 <= fib 0
hSn: 1 <= fib 1

2 <= fib 0 + fib 1
n: nat
hn: S n <= fib (S n)
hSn: S (S n) <= fib (S (S n))
S (S (S n)) <= fib (S n) + fib (S (S n))
hn: 0 <= fib 0
hSn: 1 <= fib 1

2 <= fib 0 + fib 1
hn: 0 <= fib 0
hSn: 1 <= fib 1

2 <= 2
auto.
n: nat
hn: S n <= fib (S n)
hSn: S (S n) <= fib (S (S n))

S (S (S n)) <= fib (S n) + fib (S (S n))
lia. Qed.

Exercise: No infinite decreasing sequence

You might be surprised that our definition of well-foundedness isn't talking about the absence of infinite decreasing sequences. While that is the usual definition, in our setting such a definition doesn't let us construct terms in general, so it is better to have a positive outlook on well-foundedness.

We can still connect the two though! Prove the following lemmas.

Section Sequences.

  Context (A : Type) (R : A -> A -> Prop).

  Definition noseq_from x :=
    ~ (exists (u : nat -> A), u 0 = x /\ forall n, R (u (S n)) (u n)).

  
A: Type
R: A -> A -> Prop
x: A

Acc R x -> noseq_from x
A: Type
R: A -> A -> Prop
x: A

Acc R x -> noseq_from x
A: Type
R: A -> A -> Prop
x: A
h: Acc R x

noseq_from x
A: Type
R: A -> A -> Prop
x: A
h: forall y : A, R y x -> Acc R y
ih: forall y : A, R y x -> noseq_from y

noseq_from x
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)

False
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)

R ?y (u 0)
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)
exists u0 : nat -> A, u0 0 = ?y /\ (forall n : nat, R (u0 (S n)) (u0 n))
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)

R ?y (u 0)
apply hu.
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)

exists u0 : nat -> A, u0 0 = u 1 /\ (forall n : nat, R (u0 (S n)) (u0 n))
A: Type
R: A -> A -> Prop
u: nat -> A
ih: forall y : A, R y (u 0) -> noseq_from y
h: forall y : A, R y (u 0) -> Acc R y
hu: forall n : nat, R (u (S n)) (u n)

u 1 = u 1 /\ (forall n : nat, R (u (S (S n))) (u (S n)))
firstorder. Qed.
End Sequences.

From Stdlib Require Import Lia.

Exercise: Search using Acc

We are going to show that for any decidable predicate P with exists n, P n we can compute a natural number n for which P holds, i.e. deduce { n | P n }.

Prove the admitted lemmas below.

Section ConstructiveIndefiniteGroundDescription_Acc.

  Context (P : nat -> Prop).

  Hypothesis P_decidable : forall n : nat, {P n} + {~ P n}.

  Let R (x y : nat) : Prop := x = S y /\ ~ P y.

  Local Abbreviation acc x := (Acc R x).

  
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x : nat, P x -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x : nat, P x -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
H: P x

acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
H: P x

forall y : nat, R y x -> acc y
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
H: P x
y: nat
not_Px: ~ P x

acc y
absurd (P x); assumption. Qed.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x n : nat, P (n + x) -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x n : nat, P (n + x) -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x : nat, P x -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
forall x : nat, P (S (n + x)) -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

forall x : nat, P x -> acc x
apply P_implies_acc.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x

forall x : nat, P (S (n + x)) -> acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))

acc x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))

forall y : nat, R y x -> acc y
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))
y: nat
fxy: y = S x

acc y
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))
y: nat
fxy: y = S x

P (n + y)
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))
y: nat
fxy: y = S x

P (n + S x)
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
n: nat
IH: forall x : nat, P (n + x) -> acc x
x: nat
H: P (S (n + x))
y: nat
fxy: y = S x

P (S (n + x))
assumption. Qed.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

(exists n : nat, P n) -> acc 0
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

(exists n : nat, P n) -> acc 0
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
H: exists n : nat, P n

forall x : nat, P x -> acc 0
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
H: exists n : nat, P n
x: nat
Px: P x

acc 0
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
H: exists n : nat, P n
x: nat
Px: P x

P (x + 0)
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
H: exists n : nat, P n
x: nat
Px: P x

P x
assumption. Qed.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

acc 0 -> {n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

acc 0 -> {n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
Acc_0: acc 0

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
Acc_0: acc 0

(fun _ : nat => {n : nat | P n}) 0
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
Acc_0: acc 0

forall x : nat, (forall y : nat, R y x -> {n : nat | P n}) -> {n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
Px: P x

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
Px: P x

{n : nat | P n}
exists x; simpl; assumption.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat

R y x
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat
Ryx: R y x
{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat

R y x
unfold R; split; auto.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat
Ryx: R y x

{n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
x: nat
IH: forall y : nat, R y x -> {n : nat | P n}
not_Px: ~ P x
y:= S x: nat
Ryx: R y x
n: nat
Hn: P n

{n0 : nat | P n0}
exists n; assumption. Qed.
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

(exists n : nat, P n) -> {n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop

(exists n : nat, P n) -> {n : nat | P n}
P: nat -> Prop
P_decidable: forall n : nat, {P n} + {~ P n}
R:= fun x y : nat => x = S y /\ ~ P y: nat -> nat -> Prop
H: exists n : nat, P n

acc 0
apply P_eventually_implies_acc_ex; assumption. Qed. End ConstructiveIndefiniteGroundDescription_Acc.

Exercise: Defining functions by well-founded recursion

We have seen well-founded induction, but sometimes we also want to define functions by well-founded recursion. The standard library comes with a helpful function for doing that called Fix_F. It performs induction on accessibility like we have been doing.

Fix_F : forall [A : Type] [R : A -> A -> Prop] (P : A -> Type), (forall x : A, (forall y : A, R y x -> P y) -> P x) -> forall [x : A], Acc R x -> P x Fix_F is not universe polymorphic Arguments Fix_F [A]%_type_scope [R]%_function_scope (P F)%_function_scope [x] a Fix_F is transparent Expands to: Constant Corelib.Init.Wf.Fix_F Declared in library Corelib.Init.Wf, line 83, characters 11-16

Implement a merge function on lists such that if l and r are individually sorted, then merge l r should be sorted too. This function is the main ingredient for the merge sort algorithm.

We give you the version one would write in OCaml and you have to adapt it into a function accepted by Rocq. We're using lists of natural numbers to make it simpler but it could be generalised of course.

Next, prove a specification for merge that ensures it preserves sortedness and that the result is a permutation of the original lists. You can use a weak version of permutation that doesn't account for multiplicity.

We give you some lemmas about sorted and wpermut that you may or may not use. This is so you don't waste too much time on those. We expect you to begin by admitting them, but you should be able to prove them.

From Stdlib Require Import RelationClasses.

The command has indeed failed with message: Cannot guess decreasing argument of fix.
Inductive sorted : list nat -> Prop := | sorted_nil : sorted [] | sorted_cons : forall x l, sorted l -> Forall (le x) l -> sorted (x :: l). Definition wpermut (l r : list nat) : Prop := forall x, In x l <-> In x r.

forall (A : Type) (R : A -> A -> Prop) (P : forall a : A, Acc R a -> Type), (forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)) -> forall (x : A) (a : Acc R x), P x a

forall (A : Type) (R : A -> A -> Prop) (P : forall a : A, Acc R a -> Type), (forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)) -> forall (x : A) (a : Acc R x), P x a
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)

forall (x : A) (a : Acc R x), P x a
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)
ind: forall (x : A) (a : Acc R x), P x a

forall (x : A) (a : Acc R x), P x a
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)
ind: forall (x : A) (a : Acc R x), P x a
x: A
a: Acc R x

P x a
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)
ind: forall (x : A) (a : Acc R x), P x a
x: A
ha: forall y : A, R y x -> Acc R y

P x (Acc_intro x ha)
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)
ind: forall (x : A) (a : Acc R x), P x a
x: A
ha: forall y : A, R y x -> Acc R y

forall (y : A) (hy : R y x), P y (ha y hy)
A: Type
R: A -> A -> Prop
P: forall a : A, Acc R a -> Type
h: forall (x : A) (h : forall y : A, R y x -> Acc R y), (forall (y : A) (hy : R y x), P y (h y hy)) -> P x (Acc_intro x h)
ind: forall (x : A) (a : Acc R x), P x a
x: A
ha: forall y : A, R y x -> Acc R y
y: A
hy: R y x

P y (ha y hy)
apply ind. Defined.

Reflexive wpermut

Reflexive wpermut
l: list nat
x: nat

In x l <-> In x l
reflexivity. Qed.

Symmetric wpermut

Symmetric wpermut
l, r: list nat
h: wpermut l r
x: nat

In x r <-> In x l
l, r: list nat
h: wpermut l r
x: nat

In x l <-> In x r
apply h. Qed.

Transitive wpermut

Transitive wpermut
a, b, c: list nat
h1: wpermut a b
h2: wpermut b c
x: nat

In x a <-> In x c
a, b, c: list nat
h1: wpermut a b
h2: wpermut b c
x: nat

In x a <-> In x b
a, b, c: list nat
h1: wpermut a b
h2: wpermut b c
x: nat
In x b <-> In x c
a, b, c: list nat
h1: wpermut a b
h2: wpermut b c
x: nat

In x a <-> In x b
apply h1.
a, b, c: list nat
h1: wpermut a b
h2: wpermut b c
x: nat

In x b <-> In x c
apply h2. Qed. Add Parametric Relation : (list nat) wpermut as wpermut_rel.

forall (P : nat -> Prop) (l r : list nat), wpermut l r -> Forall P r -> Forall P l

forall (P : nat -> Prop) (l r : list nat), wpermut l r -> Forall P r -> Forall P l
P: nat -> Prop
l, r: list nat
hp: wpermut l r
h: Forall P r

Forall P l
P: nat -> Prop
l, r: list nat
hp: wpermut l r
h: Forall P r

forall x : nat, In x l -> P x
P: nat -> Prop
l, r: list nat
hp: wpermut l r
h: forall x : nat, In x r -> P x

forall x : nat, In x l -> P x
P: nat -> Prop
l, r: list nat
hp: wpermut l r
h: forall x : nat, In x r -> P x
x: nat
hx: In x l

P x
P: nat -> Prop
l, r: list nat
hp: forall x : nat, In x l <-> In x r
h: forall x : nat, In x r -> P x
x: nat
hx: In x l

P x
P: nat -> Prop
l, r: list nat
hp: forall x : nat, In x l <-> In x r
h: forall x : nat, In x r -> P x
x: nat
hx: In x r

P x
auto. Qed.

forall (x : nat) (l r : list nat), wpermut l r -> wpermut (x :: l) (x :: r)

forall (x : nat) (l r : list nat), wpermut l r -> wpermut (x :: l) (x :: r)
x: nat
l, r: list nat
h: wpermut l r

wpermut (x :: l) (x :: r)
x: nat
l, r: list nat
h: forall x : nat, In x l <-> In x r

forall x0 : nat, In x0 (x :: l) <-> In x0 (x :: r)
x: nat
l, r: list nat
h: forall x : nat, In x l <-> In x r

forall x0 : nat, x = x0 \/ In x0 l <-> x = x0 \/ In x0 r
x: nat
l, r: list nat
h: forall x : nat, In x l <-> In x r
y: nat

x = y \/ In y l <-> x = y \/ In y r
x: nat
l, r: list nat
h: forall x : nat, In x l <-> In x r
y: nat

x = y \/ In y r <-> x = y \/ In y r
reflexivity. Qed.

forall l r : list nat, wpermut (l ++ r) (r ++ l)

forall l r : list nat, wpermut (l ++ r) (r ++ l)
l, r: list nat
x: nat

In x (l ++ r) <-> In x (r ++ l)
l, r: list nat
x: nat

In x l \/ In x r <-> In x r \/ In x l
l, r: list nat
x: nat

In x r \/ In x l <-> In x r \/ In x l
reflexivity. Qed.

forall (x : nat) (l : list nat), sorted (x :: l) -> sorted l /\ Forall (le x) l

forall (x : nat) (l : list nat), sorted (x :: l) -> sorted l /\ Forall (le x) l
x: nat
l: list nat
h: sorted (x :: l)

sorted l /\ Forall (le x) l
x: nat
l: list nat
h: sorted (x :: l)
x0: nat
l0: list nat
H1: sorted l
H2: Forall (le x) l
H: x0 = x
H0: l0 = l

sorted l /\ Forall (le x) l
auto. Qed. Section Merge. Let T := (list nat * list nat)%type. Let m (x : T) := length (fst x) + length (snd x). Let R (x y : T) := S (m x) = m y.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall x : T, Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall x : T, Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T

Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: n = m x

Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x

Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x
Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x

Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x

forall y : T, R y x -> Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x
y: T
hr: R y x

Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x
y: T
hr: S (m y) = m x

Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
e: 0 = m x
y: T
hr: S (m y) = 0

Acc R y
inversion hr.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x

Acc R x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x

forall y : T, R y x -> Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x
y: T
hr: R y x

Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x
y: T
hr: S (m y) = m x

Acc R y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: T
n: nat
e: S n = m x
ih: forall x : T, n = m x -> Acc R x
y: T
hr: S (m y) = m x

n = m y
lia. Qed.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall (x y : nat) (l r : list nat), R (x :: l, r) (x :: l, y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall (x y : nat) (l r : list nat), R (x :: l, r) (x :: l, y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x, y: nat
l, r: list nat

R (x :: l, r) (x :: l, y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x, y: nat
l, r: list nat

S (m (x :: l, r)) = m (x :: l, y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x, y: nat
l, r: list nat

S (S (length l + length r)) = S (length l + S (length r))
lia. Qed. Definition merge (x : T) : list nat := Fix_F _ (fun x rec => match x with | ([], l) | (l, []) => fun rec => l | (x :: l, y :: r) => fun (rec : forall z, R z (x :: l, y :: r) -> list nat) => if x <? y then x :: rec (l, y :: r) eq_refl else y :: rec (x :: l, r) (R_step2 _ _ _ _) end rec ) (merge_acc x).
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall l r : list nat, sorted l -> sorted r -> sorted (merge (l, r)) /\ wpermut (merge (l, r)) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop

forall l r : list nat, sorted l -> sorted r -> sorted (merge (l, r)) /\ wpermut (merge (l, r)) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r

sorted (merge (l, r)) /\ wpermut (merge (l, r)) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r

sorted (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) (merge_acc (l, r))) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) (merge_acc (l, r))) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
a:= merge_acc (l, r): Acc R (l, r)

sorted (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
a: Acc R (l, r)

sorted (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
t: list nat * list nat
e: t = (l, r)
a: Acc R t

sorted (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) (fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l0, l1) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l0 as l2 return (forall z : T, R z (l2, l1) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l1) -> list nat => l1 | x0 :: l2 => match l1 as l3 return (forall z : T, R z (x0 :: l2, l3) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l2, []) -> list nat => l0 | y :: r0 => fun rec0 : forall z : T, R z (x0 :: l2, y :: r0) -> list nat => if x0 <? y then x0 :: rec0 (l2, y :: r0) eq_refl else y :: rec0 (x0 :: l2, r0) (R_step2 x0 y l2 r0) end end) rec) a) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
t: list nat * list nat
e: t = (l, r)
a: Acc R t
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat

sorted (Fix_F (fun _ : list nat * list nat => list nat) F a) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F a) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
t: T
e: t = (l, r)
h: forall y : T, R y t -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y t) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

sorted (Fix_F (fun _ : list nat * list nat => list nat) F (Acc_intro t h)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (Acc_intro t h)) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
t: T
e: t = (l, r)
h: forall y : T, R y t -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y t) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

sorted (F t (fun (y : list nat * list nat) (h0 : R y t) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) /\ wpermut (F t (fun (y : list nat * list nat) (h0 : R y t) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
l, r: list nat
hl: sorted l
hr: sorted r
h: forall y : T, R y (l, r) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y (l, r)) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

sorted (F (l, r) (fun (y : list nat * list nat) (h0 : R y (l, r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) /\ wpermut (F (l, r) (fun (y : list nat * list nat) (h0 : R y (l, r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) (l ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
hl, hr: sorted []
h: forall y : T, R y ([], []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y ([], [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

sorted (F ([], []) (fun (y : list nat * list nat) (h0 : R y ([], [])) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) /\ wpermut (F ([], []) (fun (y : list nat * list nat) (h0 : R y ([], [])) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) ([] ++ [])
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
y: nat
r: list nat
hl: sorted []
hr: sorted (y :: r)
h: forall y0 : T, R y0 ([], y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 ([], y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (F ([], y :: r) (fun (y0 : list nat * list nat) (h0 : R y0 ([], y :: r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y0 h0))) /\ wpermut (F ([], y :: r) (fun (y0 : list nat * list nat) (h0 : R y0 ([], y :: r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y0 h0))) ([] ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
hl: sorted (x :: l)
hr: sorted []
h: forall y : T, R y (x :: l, []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y (x :: l, [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)
sorted (F (x :: l, []) (fun (y : list nat * list nat) (h0 : R y (x :: l, [])) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) /\ wpermut (F (x :: l, []) (fun (y : list nat * list nat) (h0 : R y (x :: l, [])) => Fix_F (fun _ : list nat * list nat => list nat) F (h y h0))) ((x :: l) ++ [])
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (F (x :: l, y :: r) (fun (y0 : list nat * list nat) (h0 : R y0 (x :: l, y :: r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y0 h0))) /\ wpermut (F (x :: l, y :: r) (fun (y0 : list nat * list nat) (h0 : R y0 (x :: l, y :: r)) => Fix_F (fun _ : list nat * list nat => list nat) F (h y0 h0))) ((x :: l) ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
hl, hr: sorted []
h: forall y : T, R y ([], []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y ([], [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

sorted [] /\ wpermut [] []
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
y: nat
r: list nat
hl: sorted []
hr: sorted (y :: r)
h: forall y0 : T, R y0 ([], y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 ([], y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (y :: r) /\ wpermut (y :: r) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
hl: sorted (x :: l)
hr: sorted []
h: forall y : T, R y (x :: l, []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y (x :: l, [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)
sorted (x :: l) /\ wpermut (x :: l) (x :: l ++ [])
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
hl, hr: sorted []
h: forall y : T, R y ([], []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y ([], [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

wpermut [] []
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
y: nat
r: list nat
hl: sorted []
hr: sorted (y :: r)
h: forall y0 : T, R y0 ([], y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 ([], y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
wpermut (y :: r) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
hl: sorted (x :: l)
hr: sorted []
h: forall y : T, R y (x :: l, []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y (x :: l, [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)
wpermut (x :: l) (x :: l ++ [])
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
hl, hr: sorted []
h: forall y : T, R y ([], []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y ([], [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)

wpermut [] []
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
y: nat
r: list nat
hl: sorted []
hr: sorted (y :: r)
h: forall y0 : T, R y0 ([], y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 ([], y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
wpermut (y :: r) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
hl: sorted (x :: l)
hr: sorted []
h: forall y : T, R y (x :: l, []) -> Acc R y
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y : T) (hy : R y (x :: l, [])) (l r : list nat), sorted l -> sorted r -> y = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y hy)) (l ++ r)
wpermut (x :: l) (x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
sorted (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)

sorted (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (if x <? y then x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl) else y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
e: (x <? y) = false
sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall hy : R (l, y :: r) (x :: l, y :: r), sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) hy)) (l ++ y :: r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) /\ wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true
wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

sorted (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true
Forall (le x) (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

Forall (le x) (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) ?r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true
Forall (le x) ?r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

Forall (le x) (l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

Forall (le x) (l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

Forall (le x) l /\ Forall (le x) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

Forall (le x) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y

Forall (le x) (y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y

x <= y
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y
Forall (le x) r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y

Forall (le x) r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y

forall a : nat, ?P a -> x <= a
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y
Forall ?P r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: S x <= y

forall a : nat, y <= a -> x <= a
lia.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

wpermut (x :: Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
e: (x <? y) = true

wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (l, y :: r) eq_refl)) (l ++ y :: r)
assumption.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall (y0 : T) (hy : R y0 (x :: l, y :: r)) (l r : list nat), sorted l -> sorted r -> y0 = (l, r) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h y0 hy)) (l ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: forall l0 r0 : list nat, sorted l0 -> sorted r0 -> (x :: l, r) = (l0, r0) -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (l0 ++ r0)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted (y :: r)
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: sorted (x :: l) -> sorted r -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: sorted (x :: l) -> sorted r -> sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ih: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) /\ wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false
wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false
Forall (le y) (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

Forall (le y) (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ?r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false
Forall (le y) ?r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

Forall (le y) ((x :: l) ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

Forall (le y) ((x :: l) ++ r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

Forall (le y) (x :: l) /\ Forall (le y) r
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

Forall (le y) (x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x

Forall (le y) (x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x

y <= x
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x
Forall (le y) l
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x

Forall (le y) l
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x

forall a : nat, ?P a -> y <= a
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x
Forall ?P l
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted l
hxl: Forall (le x) l
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: y <= x

forall a : nat, x <= a -> y <= a
lia.
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (x :: l ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ y :: r)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((y :: r) ++ x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (y :: Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (y :: r ++ x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) (r ++ x :: l)
T:= (list nat * list nat)%type: Set
m:= fun x : T => length (fst x) + length (snd x): T -> nat
R:= fun x y : T => S (m x) = m y: T -> T -> Prop
x: nat
l: list nat
y: nat
r: list nat
hl: sorted (x :: l)
hr: sorted r
hyr: Forall (le y) r
h: forall y0 : T, R y0 (x :: l, y :: r) -> Acc R y0
F:= fun (x : list nat * list nat) (rec : forall y : list nat * list nat, R y x -> list nat) => (let (l, l0) as x0 return (forall z : T, R z x0 -> list nat) -> list nat := x in match l as l1 return (forall z : T, R z (l1, l0) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z ([], l0) -> list nat => l0 | x0 :: l1 => match l0 as l2 return (forall z : T, R z (x0 :: l1, l2) -> list nat) -> list nat with | [] => fun _ : forall z : T, R z (x0 :: l1, []) -> list nat => l | y :: r => fun rec0 : forall z : T, R z (x0 :: l1, y :: r) -> list nat => if x0 <? y then x0 :: rec0 (l1, y :: r) eq_refl else y :: rec0 (x0 :: l1, r) (R_step2 x0 y l1 r) end end) rec: forall x : list nat * list nat, (forall y : list nat * list nat, R y x -> list nat) -> list nat
ihs: sorted (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r)))
ihp: wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
e: (x <? y) = false

wpermut (Fix_F (fun _ : list nat * list nat => list nat) F (h (x :: l, r) (R_step2 x y l r))) ((x :: l) ++ r)
assumption. Qed. End Merge.

Exercise: Hilbert's epsilon (advanced)

We're going to show the Bishop-Diaconescu-Myhill-Goodman theorem. It shows that the axiom of choice implies excluded middle with sufficient extensionality.

There are several versions of the axiom of choice. One is Hilbert's epsilon operator which takes a property on a type, and returns an element of that type that verifies the property if such an element exists. To avoid inconsistencies, we have to restrict this operator to inhabited types.

Section Hilbert.

inhabited A is just a proposition from which you cannot extract the witness.

  Context (epsilon : forall A, inhabited A -> (A -> Prop) -> A).

If there is an element verifying the property, then the one epsilon gave us also verifies it.

  Context (epsilon_spec :
    forall A i P,
      (exists x, P x) ->
      P (epsilon A i P)).

We also need some extensionality to tell us that the choice does not depend on how the property was formulated.

  Context (epsilon_ext :
    forall A i P Q,
      (forall x, P x <-> Q x) ->
      epsilon A i P = epsilon A i Q
  ).

Prove the excluded middle.

  
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q

forall P : Prop, P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q

forall P : Prop, P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

B b
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b
P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

B b
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

exists x : bool, B x
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

B false
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool

false = false
reflexivity.
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

C c
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b
hc: C c
P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

C c
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

exists x : bool, C x
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

C true
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b

true = true
reflexivity.
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hb: B b
hc: C c

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
hc: C c

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
hP: P
hc: C c
P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
hc: C c

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
hP: P
P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true

P \/ ~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true

~ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P

False
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P

b = c
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
e: b = c
False
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P

b = c
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P

forall x : bool, B x <-> C x
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
x: bool

B x <-> C x
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
x: bool

x = false \/ P <-> x = true \/ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
x: bool

x = false \/ P -> x = true \/ P
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
x: bool
x = true \/ P -> x = false \/ P
all: auto.
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
e: b = c

False
epsilon: forall A : Type, inhabited A -> (A -> Prop) -> A
epsilon_spec: forall (A : Type) (i : inhabited A) (P : A -> Prop), (exists x : A, P x) -> P (epsilon A i P)
epsilon_ext: forall (A : Type) (i : inhabited A) (P Q : A -> Prop), (forall x : A, P x <-> Q x) -> epsilon A i P = epsilon A i Q
P: Prop
i:= inhabits true: inhabited bool
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
b:= epsilon bool i B: bool
c:= epsilon bool i C: bool
eb: b = false
ec: c = true
hP: P
e: false = true

False
discriminate. Qed. End Hilbert.

Exercise: From relation to function (advanced)

Another version of the axiom of choice says that from an entire relation, one can extract a function. It's a form of inversion of quantifiers.

Definition fun_choice :=
  forall A B (R : A -> B -> Prop),
    (forall x, exists y, R x y) ->
    exists (f : A -> B),
      forall x, R x (f x).

Show that fun_choice implies LEM as well. You may use proposition and function extensionality.

The proof should share some ideas with the one above and could involve some function of type { p : bool -> Prop | p = B \/ p = C } -> bool with carefully chosen B and C.

Definition FunExt :=
  forall A B (f g : A -> B),
    (forall x, f x = g x) ->
    f = g.

Definition PropExt :=
  forall (P Q : Prop), P <-> Q -> P = Q.


fun_choice -> FunExt -> PropExt -> forall P : Prop, P \/ ~ P

fun_choice -> FunExt -> PropExt -> forall P : Prop, P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
eps: (forall x : {p : bool -> Prop | p = B \/ p = C}, exists y : bool, (fun (p : {p : bool -> Prop | p = B \/ p = C}) (b : bool) => proj1_sig p b) x y) -> exists f : {p : bool -> Prop | p = B \/ p = C} -> bool, forall x : {p : bool -> Prop | p = B \/ p = C}, (fun (p : {p : bool -> Prop | p = B \/ p = C}) (b : bool) => proj1_sig p b) x (f x)

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

forall x : {p : bool -> Prop | p = B \/ p = C}, exists y : bool, proj1_sig x y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

forall x : {p : bool -> Prop | p = B \/ p = C}, exists y : bool, proj1_sig x y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
p: bool -> Prop
eB: p = B

exists y : bool, proj1_sig (exist (fun p0 : bool -> Prop => p0 = B \/ p0 = C) p (or_introl eB)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
p: bool -> Prop
eC: p = C
exists y : bool, proj1_sig (exist (fun p0 : bool -> Prop => p0 = B \/ p0 = C) p (or_intror eC)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
p: bool -> Prop
eB: p = B

exists y : bool, proj1_sig (exist (fun p0 : bool -> Prop => p0 = B \/ p0 = C) p (or_introl eB)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

exists y : bool, proj1_sig (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl eq_refl)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

exists y : bool, B y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

B false
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

false = false
reflexivity.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
p: bool -> Prop
eC: p = C

exists y : bool, proj1_sig (exist (fun p0 : bool -> Prop => p0 = B \/ p0 = C) p (or_intror eC)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

exists y : bool, proj1_sig (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror eq_refl)) y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

exists y : bool, C y
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

C true
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop

true = true
reflexivity.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
hfB: proj1_sig (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) (f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
hfB: B (f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
hfB: B (f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))))
hfC: proj1_sig (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) (f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
hfB: B (f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))))
hfC: C (f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
hfC: C (f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
hP: P
hfC: C (f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))))
P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
hfC: C (f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))))

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
hP: P
P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true

P \/ ~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true

~ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P

False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P

B = C
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
e: B = C
False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P

B = C
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P

forall x : bool, B x = C x
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
x: bool

B x = C x
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
x: bool

B x <-> C x
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
x: bool

x = false \/ P <-> x = true \/ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
x: bool

x = false \/ P -> x = true \/ P
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
x: bool
x = true \/ P -> x = false \/ P
all: auto.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B:= fun x : bool => x = false \/ P: bool -> Prop
C:= fun x : bool => x = true \/ P: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
e: B = C

False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
B, C: bool -> Prop
f: {p : bool -> Prop | p = B \/ p = C} -> bool
hf: forall x : {p : bool -> Prop | p = B \/ p = C}, proj1_sig x (f x)
eB: f (exist (fun p : bool -> Prop => p = B \/ p = C) B (or_introl (funext bool Prop B B (fun x : bool => eq_refl)))) = false
eC: f (exist (fun p : bool -> Prop => p = B \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
hP: P
e: B = C

False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P

False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P

forall (P0 : Prop) (p q : P0), p = q
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q
False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P

forall (P0 : Prop) (p q : P0), p = q
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q

u = v
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q

Q = True
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q
H: Q = True
u = v
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q

Q = True
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q

Q <-> True
split ; auto.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
Q: Prop
u, v: Q
H: Q = True

u = v
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
v, u: True

u = v
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P

I = I
reflexivity.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

true = false
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q
H: true = false
False
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

true = false
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl))))
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

C = C \/ C = C
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q
C = C \/ C = C
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q
f (exist (fun p : bool -> Prop => p = C \/ p = C) C ?Goal1) = f (exist (fun p : bool -> Prop => p = C \/ p = C) C ?Goal2)
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q

C = C \/ C = C
auto.
ac: fun_choice
funext: FunExt
propext: PropExt
P: Prop
C: bool -> Prop
f: {p : bool -> Prop | p = C \/ p = C} -> bool
eC: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_intror (funext bool Prop C C (fun x : bool => eq_refl)))) = true
eB: f (exist (fun p : bool -> Prop => p = C \/ p = C) C (or_introl (funext bool Prop C C (fun x : bool => eq_refl)))) = false
hf: forall x : {p : bool -> Prop | p = C \/ p = C}, proj1_sig x (f x)
hP: P
pi: forall (P : Prop) (p q : P), p = q
H: true = false

False
discriminate. Qed.

Exercise: Choice and proof irrelevance (advanced)

PI (forall P : Prop, forall h1 h2 : P, h1 = h2) suffices to prove that choice implies ELEM := forall A : Type, forall a b : A, a = b \/ ~ (a = b).

Prove this, and then deduce that PropExt suffices for Diaconescu's theorem, i.e. that FunExt is not actually needed.


fun_choice -> (forall (P : Prop) (h1 h2 : P), h1 = h2) -> forall (A : Type) (a b : A), a = b \/ a <> b

fun_choice -> (forall (P : Prop) (h1 h2 : P), h1 = h2) -> forall (A : Type) (a b : A), a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop

forall h : {x : A | S x}, exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
H: forall h : {x : A | S x}, exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b
a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop

forall h : {x : A | S x}, exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b
intros [x [-> | ->]]; cbn; eauto.
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
H: forall h : {x : A | S x}, exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = true /\ proj1_sig (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = a \/ f (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = false /\ proj1_sig (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = true /\ proj1_sig (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = a \/ f (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = false /\ proj1_sig (exist (fun x : A => S x) a (or_introl eq_refl : S a)) = b
hfb: f (exist (fun x : A => S x) b (or_intror eq_refl : S b)) = true /\ proj1_sig (exist (fun x : A => S x) b (or_intror eq_refl : S b)) = a \/ f (exist (fun x : A => S x) b (or_intror eq_refl : S b)) = false /\ proj1_sig (exist (fun x : A => S x) b (or_intror eq_refl : S b)) = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true /\ a = a \/ f (exist (fun x : A => S x) a (or_introl eq_refl)) = false /\ a = b
hfb: f (exist (fun x : A => S x) b (or_intror eq_refl)) = true /\ b = a \/ f (exist (fun x : A => S x) b (or_intror eq_refl)) = false /\ b = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
hfb: f (exist (fun x : A => S x) b (or_intror eq_refl)) = true /\ b = a \/ f (exist (fun x : A => S x) b (or_intror eq_refl)) = false /\ b = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
eP: f (exist (fun x : A => S x) a (or_introl eq_refl)) = false /\ a = b
hfb: f (exist (fun x : A => S x) b (or_intror eq_refl)) = true /\ b = a \/ f (exist (fun x : A => S x) b (or_intror eq_refl)) = false /\ b = b
a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
hfb: f (exist (fun x : A => S x) b (or_intror eq_refl)) = true /\ b = a \/ f (exist (fun x : A => S x) b (or_intror eq_refl)) = false /\ b = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
eb: f (exist (fun x : A => S x) b (or_intror eq_refl)) = true /\ b = a

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
h2: b = b
a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
h2: b = b

a = b \/ a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
a, b: A
S:= fun x : A => x = a \/ x = b: A -> Prop
f: {x : A | S x} -> bool
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist (fun x : A => S x) a (or_introl eq_refl)) = true
ea2: a = a
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
h2: b = b

a <> b
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

False
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

true = false
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

true = f (exist (fun x : A => S x) b (or_intror eq_refl))
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

f (exist (fun x : A => S x) b (or_introl eq_refl)) = f (exist (fun x : A => S x) b (or_intror eq_refl))
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl) -> f (exist (fun x : A => S x) b (or_introl eq_refl)) = f (exist (fun x : A => S x) b (or_intror eq_refl))
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b
exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl) -> f (exist (fun x : A => S x) b (or_introl eq_refl)) = f (exist (fun x : A => S x) b (or_intror eq_refl))
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

f (exist (fun x : A => S x) b (or_intror eq_refl)) = f (exist (fun x : A => S x) b (or_intror eq_refl))
reflexivity.
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

A = A -> (fun x : A => S x) = (fun x : A => S x) -> b = b -> or_introl eq_refl = or_intror eq_refl -> exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b
or_introl eq_refl = or_intror eq_refl
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

A = A -> (fun x : A => S x) = (fun x : A => S x) -> b = b -> or_introl eq_refl = or_intror eq_refl -> exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b
H: A = A
H0: (fun x : A => S x) = (fun x : A => S x)
H1: b = b
H2: or_introl eq_refl = or_intror eq_refl

exist (fun x : A => S x) b (or_introl eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b
H: A = A
H0: (fun x : A => S x) = (fun x : A => S x)
H1: b = b
H2: or_introl eq_refl = or_intror eq_refl

exist (fun x : A => S x) b (or_intror eq_refl) = exist (fun x : A => S x) b (or_intror eq_refl)
reflexivity.
ac: fun_choice
pi: forall (P : Prop) (h1 h2 : P), h1 = h2
A: Type
b: A
S:= fun x : A => x = b \/ x = b: A -> Prop
f: {x : A | S x} -> bool
h1: f (exist (fun x : A => S x) b (or_intror eq_refl)) = false
ea2: b = b
ea1: f (exist (fun x : A => S x) b (or_introl eq_refl)) = true
hf: forall x : {x : A | S x}, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

or_introl eq_refl = or_intror eq_refl
apply pi. Qed.

fun_choice -> PropExt -> forall P : Prop, P \/ ~ P

fun_choice -> PropExt -> forall P : Prop, P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop

P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop

forall (Q : Prop) (h1 h2 : Q), h1 = h2
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop

forall (Q : Prop) (h1 h2 : Q), h1 = h2
c: fun_choice
pext: PropExt
P, Q: Prop
h1, h2: Q

h1 = h2
c: fun_choice
pext: PropExt
P, Q: Prop
h1, h2: Q

Q = True
c: fun_choice
pext: PropExt
P: Prop
h2, h1: True
h1 = h2
c: fun_choice
pext: PropExt
P, Q: Prop
h1, h2: Q

Q = True
c: fun_choice
pext: PropExt
P, Q: Prop
h1, h2: Q

Q <-> True
tauto.
c: fun_choice
pext: PropExt
P: Prop
h2, h1: True

h1 = h2
destruct h1, h2; reflexivity.
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2

P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P = True

P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True
P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P = True

P \/ ~ P
c: fun_choice
pext: PropExt
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2

True \/ ~ True
tauto.
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True

P \/ ~ P
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True

~ P
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True
hP: P

False
c: fun_choice
pext: PropExt
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
hP: True
H: True <> True

False
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True
hP: P
P = True
c: fun_choice
pext: PropExt
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
hP: True
H: True <> True

False
congruence.
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True
hP: P

P = True
c: fun_choice
pext: PropExt
P: Prop
pi: forall (Q : Prop) (h1 h2 : Q), h1 = h2
H: P <> True
hP: P

P <-> True
tauto. Qed.

Exercise: Choice in SProp (advanced)

Read the documentation of SProp and see whether you can prove that choice for SProp implies ELEM for SProp (without any additional assumption).

To make our life easier, we define how to squash a proposition into a strict proposition.

Definition squash (P : Prop) : SProp :=
  forall S : SProp, (P -> S) -> S.

P: Prop

P -> squash P
P: Prop

P -> squash P
firstorder. Qed.

The statement.

Definition fun_choice_SProp :=
  forall A B (R : A -> B -> Prop),
    (forall x, squash (exists y, R x y)) ->
    squash (exists (f : A -> B),
    forall x, R x (f x)).

Auxiliary definition for the proof.

Inductive sig {A : Type} (P : A -> SProp) : Type :=  exist : forall x : A, P x -> sig P.


forall (A : Type) (P : A -> SProp), sig P -> A

forall (A : Type) (P : A -> SProp), sig P -> A
A: Type
p: A -> SProp
x: A
p0: p x

A
exact x. Defined.

fun_choice_SProp -> forall (A : Type) (a b : A), squash (a = b \/ a <> b)

fun_choice_SProp -> forall (A : Type) (a b : A), squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp

forall h : sig S, squash (exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
H: forall h : sig S, squash (exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b)
squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp

forall h : sig S, squash (exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
x: A
s: S x

squash (exists e : bool, e = true /\ proj1_sig (exist S x s) = a \/ e = false /\ proj1_sig (exist S x s) = b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
x: A
s: S x

x = a \/ x = b -> squash (exists e : bool, e = true /\ proj1_sig (exist S x s) = a \/ e = false /\ proj1_sig (exist S x s) = b)
intros [-> | ->]; cbn; clear s; eauto using sq.
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
H: forall h : sig S, squash (exists e : bool, e = true /\ proj1_sig h = a \/ e = false /\ proj1_sig h = b)

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
H: squash (exists f : sig S -> bool, forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b)

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
H: squash (exists f : sig S -> bool, forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b)

(exists f : sig S -> bool, forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b) -> squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp

(exists f : sig S -> bool, forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b) -> squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true /\ proj1_sig (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = a \/ f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = false /\ proj1_sig (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true /\ proj1_sig (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = a \/ f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = false /\ proj1_sig (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = b
hfb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ proj1_sig (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = a \/ f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false /\ proj1_sig (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
hfa: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true /\ a = a \/ f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = false /\ a = b
hfb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ b = a \/ f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false /\ b = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
hfb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ b = a \/ f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false /\ b = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
eP: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = false /\ a = b
hfb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ b = a \/ f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false /\ b = b
squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
hfb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ b = a \/ f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false /\ b = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
eb: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = true /\ b = a

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
h1: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false
h2: b = b
squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
h1: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false
h2: b = b

squash (a = b \/ a <> b)
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
h1: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false
h2: b = b

a = b \/ a <> b
ac: fun_choice_SProp
A: Type
a, b: A
S:= fun x : A => squash (x = a \/ x = b): A -> SProp
f: sig S -> bool
hf: forall x : sig S, f x = true /\ proj1_sig x = a \/ f x = false /\ proj1_sig x = b
ea1: f (exist S a (sq (a = a \/ a = b) (or_introl eq_refl))) = true
ea2: a = a
h1: f (exist S b (sq (b = a \/ b = b) (or_intror eq_refl))) = false
h2: b = b

a <> b
ac: fun_choice_SProp
A: Type
b: A
S:= fun x : A => squash (x = b \/ x = b): A -> SProp
f: sig S -> bool
h1: f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl))) = false
ea2: b = b
ea1: f (exist S b (sq (b = b \/ b = b) (or_introl eq_refl))) = true
hf: forall x : sig S, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

False
ac: fun_choice_SProp
A: Type
b: A
S:= fun x : A => squash (x = b \/ x = b): A -> SProp
f: sig S -> bool
h1: f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl))) = false
ea2: b = b
ea1: f (exist S b (sq (b = b \/ b = b) (or_introl eq_refl))) = true
hf: forall x : sig S, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

true = false
ac: fun_choice_SProp
A: Type
b: A
S:= fun x : A => squash (x = b \/ x = b): A -> SProp
f: sig S -> bool
h1: f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl))) = false
ea2: b = b
ea1: f (exist S b (sq (b = b \/ b = b) (or_introl eq_refl))) = true
hf: forall x : sig S, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

true = f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl)))
ac: fun_choice_SProp
A: Type
b: A
S:= fun x : A => squash (x = b \/ x = b): A -> SProp
f: sig S -> bool
h1: f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl))) = false
ea2: b = b
ea1: f (exist S b (sq (b = b \/ b = b) (or_introl eq_refl))) = true
hf: forall x : sig S, f x = true /\ proj1_sig x = b \/ f x = false /\ proj1_sig x = b
h2: b = b

f (exist S b (sq (b = b \/ b = b) (or_introl eq_refl))) = f (exist S b (sq (b = b \/ b = b) (or_intror eq_refl)))
reflexivity. Qed.