Section PROPOSITONAL_LOGIC.
Definition propLetter : Set := nat.
Inductive formula : Set :=
| AtomF (i : propLetter) : formula
| ContradictionF : formula
| NegationF (p1 : formula) : formula
| ConjunctionF (p1 : formula) (p2 : formula) : formula
| DisjunctionF (p1 : formula) (p2 : formula) : formula
| ImplicationF (p1 : formula) (p2 : formula) : formula
| BiconditionalF (p1 : formula) (p2 : formula) : formula.
#[global]
Instance propLetter_hasEqDec : hasEqDec propLetter :=
Nat.eq_dec.
#[global]
Instance formula_hasEqDec
: hasEqDec formula.
Definition is_structure (Gamma : ensemble formula) : Prop :=
forall p : formula, p \in Gamma <-> evalFormula (E.preimage AtomF Gamma) p.
Proof with repeat ((now left) || right).
eapply NegationE, ContradictionI.
- eapply DisjunctionI2, NegationI, ContradictionI.
+ eapply DisjunctionI1, ByAssumption...
+ eapply ByAssumption...
- eapply ByAssumption...
Qed.
Proof with eauto.
revert Gamma' SUBSET. induction INFERS; ii.
- eapply ByAssumption with (C := C)...
- eapply ContradictionI with (A := A)...
- eapply ContradictionE with (A := A)...
- eapply NegationI with (A := A)...
- eapply NegationE with (A := A)...
- eapply ConjunctionI with (A := A) (B := B)...
- eapply ConjunctionE1 with (A := A) (B := B)...
- eapply ConjunctionE2 with (A := A) (B := B)...
- eapply DisjunctionI1 with (A := A) (B := B)...
- eapply DisjunctionI2 with (A := A) (B := B)...
- eapply DisjunctionE with (A := A) (B := B) (C := C)...
- eapply ImplicationI with (A := A) (B := B)...
- eapply ImplicationE with (A := A) (B := B)...
- eapply BiconditionalI with (A := A) (B := B)...
- eapply BiconditionalE1 with (A := A) (B := B)...
- eapply BiconditionalE2 with (A := A) (B := B)...
Qed.
Fixpoint depth (p : formula) {struct p} : nat :=
match p with
| AtomF i => 0
| ContradictionF => 1
| NegationF p1 => S (depth p1)
| ConjunctionF p1 p2 => S (max (depth p1) (depth p2))
| DisjunctionF p1 p2 => S (max (depth p1) (depth p2))
| ImplicationF p1 p2 => S (max (depth p1) (depth p2))
| BiconditionalF p1 p2 => S (max (depth p1) (depth p2))
end.
#[local] Notation plus6 i := (S (S (S (S (S (S i)))))).
Fixpoint enumFormula' (rk : nat) (seed0 : nat) {struct rk} : formula :=
match rk with
| O => AtomF seed0
| S rk' =>
let seed1 := fst (cp seed0) in
let piece := snd (cp seed0) in
let seed2 := fst (cp seed1) in
let seed3 := snd (cp seed1) in
match piece with
| 0 => ContradictionF
| 1 => NegationF (enumFormula' rk' seed1)
| 2 => ConjunctionF (enumFormula' rk' seed2) (enumFormula' rk' seed3)
| 3 => DisjunctionF (enumFormula' rk' seed2) (enumFormula' rk' seed3)
| 4 => ImplicationF (enumFormula' rk' seed2) (enumFormula' rk' seed3)
| 5 => BiconditionalF (enumFormula' rk' seed2) (enumFormula' rk' seed3)
| plus6 i => AtomF i
end
end.
#[local]
Tactic Notation "tac_aux1" :=
match goal with
| [ H : cp ?seed = ?rhs |- _ ] => rewrite H; simpl
end.
#[local]
Tactic Notation "tac_aux2" :=
match goal with
| [ H : enumFormula' ?rk ?seed = ?p |- _ ] => rewrite <- H
end.
#[local]
Tactic Notation "tac" :=
unfold enumFormula'; repeat tac_aux1; repeat tac_aux2; eauto.

Lemma ideaOf_enumFormula' (p : formula) (rk : nat)
(RANK_LE : depth p <= rk)
: { seed0 : nat | enumFormula' rk seed0 = p }.