I'm trying to do a proof by contradiction, but don't quite understand how to write it down formally or how to come to an answer in this case. I'm doing a conditional statement.
The problem I'm trying to solve is "Given the premises, h ^ ~r and (h^n) --> r, show that you can conclude ~n using proof by contradiction.
I've taken the negation of both h ^ ~r and (h^n) --> r, but I'm unsure how to use these two to prove ~n
so far I've written:
(i.)~((h^n) --> r)
(ii.)~(h ^ ~r)
therefore, ~n
The hardest part I'm having is that this isn't an actual statement that I can imagine a negation of, and a step by step answer of how to do one of these proofs would be really useful, thanks!
Suppose
~(((h ^ ~r) ^ ((h^n) --> r)) --> ~n)
Then,
~(~((h ^ ~r) ^ ((h^n) --> r)) v ~n)
=> ~(~(h ^ ~r) v ~((h^n) --> r)) v ~n)
=> ~((~h v r) v ~(~(h^n) v r)) v ~n)
=> ~((~h v r) v ((h^n) ^ ~r)) v ~n)
=> ~((~h v r) v (h ^ n ^ ~r)) v ~n)
=> ~((((~h v r v h) ^ (~h v r v n) ^ ((~h v r) v ~r)) v ~n)
=> ~(((true) ^ (~h v r v n) ^ (true)) v ~n)
=> ~((~h v r v n) v ~n)
=> ~(~h v r v n v ~n)
=> ~((~h v r) v (n v ~n))
=> ~((~h v r) v (true))
=> ~(true)
=> false //contradiction
Therefore,
((h ^ ~r) ^ ((h^n) --> r)) --> ~n
Let's define:
p1 := h ^ ~r, p2 := (h ^ n) -> r and q := ~n
we want to prove that p1 ^ p2 -> q.
Assume by contradiction that q=false. Then n=true. There are two cases r=true and r=false.
Case r=true
Then p1 cannot be true because ~r=false. Contradiction.
Case r=false
From p2 we deduce that (h ^ n) must be false. And given that we have assumed n=true, it must be h=false, in contradiction with p1.
Direct proof
From p1 we get h=true and r=false. Now from p2 we deduce (h ^ n) = false. And since h=true, it must be n=false, or ~n=true.
I think the OP is probably asking about, or mis-interpretting, the structure of a proof by contradiction rather than requesting a detailed proof for the specific example.
The structure goes like this ...
We've been told to assume a set of things A1, A2, ... An
Let's also assume the negation of what we eventually hope to prove, i.e. ~C
Do some logic that ends with any contradiction, by which we mean any statement of the form X & ~X
Now we ponder what that means. Since a contradiction can never be true, there must be something wrong with at least one of our n+1 assumptions. Could be that several or all of the assumptions are false. But if any n of the assumptions are true then the remaining one cannot be true. We cannot tell at this stage which one is the problem.
In this case we have been told ahead of time to accept A1, A2, ... An, and on that basis we can select the assumption of ~C as the one to be rejected.
As a final step we conclude that if A1, A2, ... An are true then C must be true.
Related
I have a knowledge base as CNF and i'd like to use prolog to make a resolution, but
i can't wrap my head around how to formulate the problem in prolog.
I have
KB = { P v Q, Q => (R ^ S), (P v R) => U }
that i put in CNF as:
KB = { P v Q, not(Q) v R, not(Q) v S, not(P) v U, not(R) v U }
and i'd like to prove that KB entails U ( KB |= U ).
I can prove in manually by refutation but i'd like to know how this can be done using prolog ?
Thx
The answer is: it is impossible.
not(Q) v R, not(Q) v S, not(P) v U, not(R) v U
can be expressed by r:-q., s:-q., u:-p. and u:-r..
Questioning ? u. amounts to asking for a proof by refutation.
However,
P v Q
cannot be expressed as a fact/rule in a prolog program. Prolog is restricted to Horn clauses, i.e. disjunctions of literals that contain at most one positive literal.
In the section on insertion into Braun trees of the Verified Programming in Agda book (page 118), the author does some explanation of what the code is supposed to be doing, but leaving what it does aside, a singificant ommision in the book so far is not explaining the strange syntax in function pattern matching for theorem proving.
I understand that the with pattern can be further destructured by using | and I can understand that when using rewrite, | can also be used to separate the different rewrites, but this makes it confusing.
As far as I can tell, rewrite is definitely not a function. And then comes the following:
bt-insert a (bt-node{n}{m} a' l r p)
rewrite +comm n m with p | if a <A a' then (a , a') else (a' , a)
bt-insert a (bt-node{n}{m} a' l r _) | inj₁ p | (a1 , a2)
rewrite p = (bt-node a1 (bt-insert a2 r) l (inj₂ refl))
bt-insert a (bt-node{n}{m} a' l r _) | inj₂ p | (a1 , a2) =
(bt-node a1 (bt-insert a2 r) l (inj₁ (sym p)))
I am really confused as to how rewrite +comm n m with p | if a <A a' then (a , a') else (a' , a) should be parsed mentally. And how does one read | inj₁ p | (a1 , a2) rewrite p? Also, while testing the previous examples I've discovered that for some reason the order of the rewrites does not matter. Why is that?
If you ignore the proofs for a sec, this function can be simplified as
bt-insert : ∀ {n: ℕ} → A → braun-tree n → braun-tree (suc n)
bt-insert a (bt-node {n} {m} a' l r _) = bt-node a1 (bt-insert a2 r) l _
where
(a1, a2) = if a <A a' then (a , a') else (a' , a)
So (a1, a2) is just (min a a', max a a') i.e. (a, a') sorted.
All the other code is there to maintain the proofs of the invariants:
We rewrite +comm n m so that we can return a braun-tree (2 + (m + n)) even though the return type requires a braun-tree (2 + (n + m)).
p is used to prove that the resulting tree is still balanced: p proves that n ≡ m ∨ n ≡ suc m, so it's either inj₁ (p : n ≡ m) or inj₂ (p : n ≡ suc m). We use the proof of either property to compute the proof of suc m ≡ n ∨ suc m ≡ suc n (remember we flipped n and m via the proof of commutativity).
After pondering it for a bit, I realized that if...
p | if a <A a' then (a , a') else (a' , a)
inj₁ p | (a1 , a2)
I put the expressions like that then it makes sense visually. In bt_insert's second case the rewrite comes before the if statement and in the third case it comes after the destructuring of the if pattern.
Well, that leaves figuring out what the rest of the function is doing.
I think for the logic question for a long time. It seems easy but very hard. I don't know how to prove it using equivalence.
(A->(B->C))->((A->(C->D))->(A->(B->D)))
Use the definition of A->B (that is, ~A v B) and DeMorgan's Law to come up with an equivalent expression in disjunctive normal form (all ands and ors). From there, repeatedly apply the fact that A v ~A is true to simplify the expression to True. (The latter may require the use of distribution: A v (B ^ C) = (A v B) ^ (A v C), as well as A ^ (B v C) = (A ^ B) v (A ^ C), although the former will be of more use here.)
I'm working with an exercise where I need to show that KB |= ~D.
And I know that the Knowledge Base is:
- (B v ¬C) => ¬A
- (¬A v D) => B
- A ∧ C
After converting to CNF:
A ∧ C ∧ (¬A v ¬B) ∧ (¬A v C) ∧ (A v B) ∧ (B v ¬D)
So now I have converted to CNF but from there, I don't know how to go any further. Would appreciate any help. Thanks!
The general resolution rule is that, for any two clauses
(that is, disjunctions of literals)
P_1 v ... v P_n
and
Q_1 v ... v Q_m
in your CNF such that there is i and j with P_i and Q_j being the negation of each other,
you can add a new clause
P_1 v ... v P_{i-1} v P_{i+1} ... v P_n v Q_1 v ... v Q_{j-1} v Q_{j+1} ... v Q_m
This is just a rigorous way to say that you can form a new clause by joining two of them, minus a literal with opposite "signs" in each.
For example
(A v ¬B)∧(B v ¬C)
is equivalent to
(A v ¬B)∧(B v ¬C)∧(A v ¬C),
by joining the two clauses while removing the opposites B and ¬B, obtaining A v ¬C.
Another example is
A∧(¬A v ¬C)
which is equivalent to
A∧(¬A v ¬C) ∧ ¬C.
since A counts as a clause with a single literal (A itself). So the two clauses are joined, while A and ¬A are removed, yielding a new clause ¬C.
Applying this to your problem, we can resolve A and ¬A v ¬B, obtaining ¬B.
We then resolve this new clause ¬B with B v ¬D, obtaining ¬D.
Because the CNF is a conjunction, the fact that it holds means that every clause in it holds. That is to say, the CNF implies all of its clauses. Since ¬D is one of its clauses, ¬D is implied by the CNF. Since the CNF is equivalent to the original KB, the KB implies ¬D.
I need help proving the following:
(a ∨ b) ∨ c = a ∨ (b ∨ c)
I don't want the answer... just a hint that will help me understand the process of proving this.
Thank you.
Why not just prove it by doing all possible values of a, b and c = True, False? -- there are only 2^3 = 8 different cases.
Here's a start, for a=T, b=F, c=T
(a v b) v c = a ∨ (b ∨ c)
(T v F) v T = T v (F v T)
T v T = T v T
T = T
(However, this isn't really a programming question...)
What is your axiom set?
Not knowing the set, you could build a truth table