Professional Documents
Culture Documents
Curs 2
Curs 2
Curs 2
O : Nat
| S: Nat -> Nat.
Check O.
Fixpoint plus (k m : Nat) : Nat :=
match k with
| O => m (*aici ajunge simpl*)
| S n => S (plus n m)
end.
(*Proof by simplification*)
Lemma plus_O_n_is_n:
forall n,plus O n =n.
Proof.
(*Tactits *)
(*Proof by rewriting*)
Lemma plus_eq:
forall m n,
m=n -> plus O m = plus O n.
Proof.
(*intro m.
intro n. (*daca plec de la ce fals, orice concluzie as avea e adevarata*)
intro H. (*introfuc o noua ipoteza*)*)
(*saauuu pot sa scriu simplu: intros.*)
intros m n H. (*ASA E cel mai safe totusi*)
rewrite H. (* inlocuieste partea stanga cu dreapta. dupa ce am 2 cantitati la fel,
fac reflexivitatea*)
reflexivity.
Qed.
(*daca as vr sa fac inlocuirea invers as putea face inlocuirea invers rewrite <-
H.*)
intro k.
destruct k as [|k']. (*intre paramteze se pot constructorii.pot da info
aditionale- situatia cand e 0 sau succ k`*)
(*Show 2. arat al doilea caz pe care l analizeaza*)
-simpl. unfold not. intro H.
inversion H.
(*Locate "<>". notatia <> este o deifnitie ce poate fi gasita cu comanda locate*)
(*unfold not da definitia negatiei. doar avand ipoteele inconsistente se poate
arata false => inversion H*)
- simpl. unfold not. intro H. inversion H. (*ca sa scap de plus aplic
simplificarea*)
Qed.
intro k.
destruct k as [|k']; simpl; unfold not; intro H;
inversion H.
Qed.
Lemma plus_n_O_is_n:
forall n, plus n O =n.
Proof.
induction n.
- simpl. trivial.
- simpl. rewrite IHn. trivial.
Qed.
Theorem plus_comm:
forall m n, plus m n = plus n m.
Proof.
Qed.
Inductive Nat :=
| O : Nat
| S : Nat -> Nat.
Fixpoint le_Nat(m n: Nat) : bool :=
match m with
| O => true
| S m' => match n with
| O =>false
| S n' => le_Nat m' n'
end
end.
Compute le_Nat O O.
Compute le_Nat (S O) O.
Compute le_Nat O (S O).
Lemma le_Trans :
forall m n p,
le_Nat m n = true ->
le_Nat n p = true ->
le_Nat m p = true.
Proof.
(* intros. *)
induction m.
-simpl. reflexivity.
-intros.
simpl in H.
destruct n.
--inversion H.
--simpl in H0.
destruct p.
--- inversion H0.
--- simpl.
apply IHm with (n := n);
assumption.