How to solve R of Problems - discrete-mathematics

what's the meaning of this?
R o R o R o R = R o R o R
As I understand it means R of R of R of R is same as R of R of R
But It seems there something more in discrete mathematics

Let us consider a relation R={(1,2),(2,3),(3,1)} defined on set S={1,2,3}.
R o R is calculated as follows
R o R(1) = R(2) = 3
R o R(2) = R(3) = 1
R o R(3) = R(1) = 2
R o R = {(1,3),(2,1),(3,2)}
similarly R o R o R = {(1,1),(2,2),(3,3)}
R o R o R o R = {(1,2),(2,3),(3,1)}
for this example R o R o R o R = R
In case your question R o R o R o R = R o R o R, The relation R={(1,1),(2,2),(3,3)} satisfies the equation.

You are correct; the meaning of:
R o R o R o R = R o R o R
Is this:
R of R of R of R is equal to R of R of R
We can infer some more about the nature of R based on this equality by composing with R's inverse:
R o R o R o R = R o R o R
(R^-1 o R^-1 o R^-1) o (R o R o R o R) = (R^-1 o R^-1 o R^-1) o (R o R o R)
(R^-1 o R^-1) o (R^-1 o R) o (R o R o R) = (R^-1 o R^-1) o (R^-1 o R) o (R o R)
(R^-1 o R^-1) o I o (R o R o R) = (R^-1 o R^-1) o I o (R o R)
(R^-1 o R^-1) o (R o R o R) = (R^-1 o R^-1) o (R o R)
You can repeat this process and find that:
R = I
is the only admissible solution.

Related

How to prove a*b*c=a*(b*c) in Coq?

Im trying to prove the above question. I have been given a definition of an induction:
Definition nat_ind
(p : nat -> Prop)
(basis : p 0)
(step : forall n, p n -> p (S n)) :
forall n, p n := fix f n :=
match n return p n with
| 0 => basis
| S n => step n (f n)
end.
This is my attempt, but don't know how to finish
Goal forall a b c, a * b * c = a * (b * c).
Proof.
apply nat_ind.
- intros a b c. revert a.
apply (nat_ind (fun a => a * b * c = a * (b * c))); simpl.
+ reflexivity.
+ intros. f_equal. intros.
After your very first nat_ind invocation, if you look at your goal, you see that Coq did not do the right thing at all!
______________________________________(1/3)
forall a b c : nat, a * b * c = a * (b * c)
______________________________________(2/3)
nat ->
(forall a b c : nat, a * b * c = a * (b * c)) ->
forall a b c : nat, a * b * c = a * (b * c)
______________________________________(3/3)
nat
What happened here is that it made a guess for your motive p, and decided to unify it with fun (_ : nat) => <YOUR_WHOLE_GOAL>, a function which given any nat would give your goal... Yes, this is silly!
One way to nudge it into doing the induction on a is by explicitly forcing it to do so, with:
apply nat_ind with (n := a)
(where the n matches the name used in your definition of nat_ind)
After this, you get the much more reasonable goals:
______________________________________(1/2)
forall b c : nat, 0 * b * c = 0 * (b * c)
______________________________________(2/2)
forall n : nat,
(forall b c : nat, n * b * c = n * (b * c)) ->
forall b c : nat, S n * b * c = S n * (b * c)
where indeed a has been replaced by 0 and S n respectively.
[EDIT: I guess this does not quite answer your question as you had gotten your way to the same point with the second induction call...]
To solve your goal, it will help a lot to have a property about distributivity of multiplication over addition:
forall n m p, (n + m) * p = n * p + m * p
All of these, as well as what you're trying to prove, already exists in Coq. Is this homework? Are you just training?

Automatically specialize forall when the parameters are in scope

Consider the following simple problem:
Goal forall (R : relation nat) (a b c d e f g h : nat),
(forall m n : nat, R m n -> False) -> (R a b) -> False.
Proof.
intros ? a b c d e f g h H1 H2.
saturate H1. (* <-- TODO implement this *)
assumption.
Qed.
My current implementation of saturate instantiates H1 with every possible combination of nat hypotheses, leading to quadratic blowup in time and memory usage. Instead I would like it to inspect forall and see that it requires a R m n, so the only combination of parameters that makes sense in context is a and then b.
Is there a known solution to this? My intuition is to use evars, but if I could avoid them without sacrificing significant performance I would like to.
This might be too simplistic, the idea is to try apply H1 on every hypothesis:
Ltac saturate H :=
match goal with
(* For any hypothesis I... *)
| [ I : _ |- _ ] =>
(* 1. Clone it (to not lose information). *)
let J := fresh I in pose proof I as J;
(* 2. apply H. *)
apply H in J;
(* 3. Abort if we already knew the resulting fact. *)
let T := type of J in
match goal with
| [ I1 : T, I2 : T |- _ ] => fail 2
end + idtac;
(* 4. Keep going *)
try (saturate H)
end.
Example:
Require Setoid. (* To get [relation] in scope so the example compiles *)
(* Made the example a little less trivial to better test the backtracking logic. *)
Goal forall (R S : relation nat) (a b c d e f g h : nat),
(forall m n : nat, R m n -> S m n) -> (R a b) -> R c d -> S a b.
Proof.
intros R S a b c d e f g h H1 H2 H3.
(* --- BEFORE ---
H2: R a b
H3: R c d
*)
saturate H1.
(* --- AFTER ---
H2: R a b
H3: R c d
H0: S c d
H4: S a b
*)
assumption.
Qed.

Converging sequence to least upper bound

Given a non-empty subset of the real numbers E : R -> Prop, the completeness axiom gives a least upper bound l of E.
Is there a constructive function
lub_approx_seq (E : R -> Prop) (l : R)
: is_lub E l -> forall n:nat, { x:R | E x /\ l-1/n < x }
In classical mathematics we would argue that for all n:nat, l-1/n is not an upper bound, so there exists an x such that E x /\ l-1/n < x.
But in constructive mathematics, ~forall (not an upper bound) is weaker than exists.
If it is not possible for a general subset E, are there conditions on E that make it possible ?
EDIT
I'm particularly interested in the case where E is a downward-infinite interval. Then the converging sequence is simply fun n:nat => l-1/n and what remains to be proved is :
Lemma lub_approx (E : R -> Prop) (l : R)
: is_lub E l
-> (forall x y : R, x < y -> E y -> E x) (* interval *)
-> forall x : R, x < l -> E x

Prove that one hypothesis is negation of another in Coq

For example I have these two hypotheses (one is negation of other)
H : forall e : R, e > 0 -> exists p : X, B e x p -> ~ F p
H0 : exists e : R, e > 0 -> forall p : X, B e x p -> F p
And goal
False
How to prove it?
You can't, because H0 is not the negation of H. The correct statement would be
Definition R := nat.
Parameter X: Type.
Parameter T: Type.
Parameter x: T.
Parameter B : R -> T -> X -> Prop.
Parameter F : X -> Prop.
Lemma foobar: forall (H: forall e : R, e > 0 -> exists p : X, B e x p -> ~ F p)
(H0: exists e: R, e > 0 /\ forall p: X, B e x p /\ F p), False.
Proof.
intros H H0.
destruct H0 as [e [he hforall]].
destruct (H e he) as [p hp].
destruct (hforall p) as [hB hF].
exact (hp hB hF).
Qed.

SQLCMD outputting text with spaces between letters

I have a powershell script that takes some inputs and uses them in a SQLCMD call, putting the output into a log file.
SQLCMD -Q $RestoreDB -S $SQLServer -d $DBName >> $SQLLogFile
The log file is a .txt file, but when I run this the output of the script (in this case, some information related to the restore process) is very odd:
C h a n g e d d a t a b a s e c o n t e x t t o ' m a s t e r ' .
N o n q u a l i f i e d t r a n s a c t i o n s a r e b e i n g r o l l e d b a c k . E s t i m a t e d r o l l b a c k c o m p l e t i o n : 1 0 0 % .
1 0 p e r c e n t p r o c e s s e d .
2 0 p e r c e n t p r o c e s s e d .
3 0 p e r c e n t p r o c e s s e d .
I think this is because Powershell uses unicode, so these are 2-byte characters (hence the space). Is there any way to change the way Powershell outputs, or should I pipe the output from SQLCMD using out-file -append and just change it there?