Lets Talk about Recursion…
by Katie Kish on Sep.20, 2006, under Mmmath
since it’s the only thing that makes sense to me in regards to my logic homework tonight.
To set the stage we need to do a little be on functions though…
F: A –> B range (f) is the set of values from B to which f
takes numbers of A.
S: Natural # –> Natural # ran(S):{1,2,3,…}
If ran(f)=B we say f maps A and B. if for every element
ran(f), there is only an xЄA such that f(x)=y, then f is one to one.
If f(x)=f(y) then x=y
there are no x,y such that F(x) =h(y). (their ranges have no elements in
common.)
Є¬ : |S –> |S
Є≡: |S x |S –> |S where ≡ is a binary connective.
disjoint ranges. (Freely generated)
(α ^ β)
= (γ ^ δ) implies α = γ and β =
δ one to one.
Disjoint
ranges (α ^ β) /= (γ v δ)
|S of wffs is freely generated by the formula building fns.
#s freely generated by S (successor)
n+1 =
m+1 n = m
Natural
#s freely generated by S, +–> addition is not one to one.They
also don’t have disjoint ranges. Everything is a successor.
S(2)
= 3 = 1+2
alrighty.. now, with those definitions I can dive into a little recursion
f(0)
= 0 | f = (0)
f(1)
= 2 | f (n+1) = 2+f (n)
f(2)
= 4 | f(3) ? 3 = 2+1
f(n)
= 2n | f(3) = f(2+1) = 2 + f(2) = 2+4= 6
f(2) = f(1+1) = 2+f (1) = 2+2 = 4
f(1) = f(0+1) = 2+f(0) = 2+0 = 2
f(0) = 0
Where
recursion doesn’t work:
NI is
not freely generated by s, x
Example:
h(0)
= 0
h
(n+1) = h (n) + 2
h
(nxm) = h (n) x h(m)
0+1 successor of 0
1 =
(0+1) x (0+1) multiply successor of 0
h
(1) = h (0+1) = h (0) +2 = 0+2 =2
h (1)
= h ((0+1) x (0+1)) = h (0+1) x h (0+1) = 2×2 = 4
because successor and x’s don’t freely generate. There are 2 different way to
calculate value of 1 #.
The
rules have conflicting instructions. The ranges of the functions were not
disjoint.
H is
defined a S.S
H
defined on negation/binary connection, you won’t get conflicting instructions.
You always know what rule to apply.
Start with v on sentence symbols, extend it using recursion
to |v on all wffs.
How do we know |v exists? – is it a function?
What we know: The formula building functions freely generate
the set of wffs. (Freely generated – a) generates all effs b) on to one c)
disjoint ranges.)
truth table (shown below for this particular case).
f^
f^ (T,F) = F
f^ (T,T) = T
|
A
|
B
|
f^
|
|
T
|
T
|
T
|
|
T
|
F
|
F
|
|
F
|
T
|
F
|
|
F
|
F
|
F
|
Theorem: Given that the formal building operations freely
generate the set |S of wffs, given a function v:S à {F,T}, which is a
truth assignment on sentence symbols then there is a unique |v: |S à
{F,T}
i) for AЄ|S, |v(A) = v(A)
ii) for α, βЄ|S, |v ((α≡β)) = f≡ (|v(α)), (|v(β)) and
|v((¬α)) = f¬(|v(α))
Example:
|v ((A^(¬B)) à (C v A) = ? … f à (|v(A^(¬B))), (|v(C v
A))
β = (C v A)
|v(A) = v(A) = T
|v(¬B) = f¬(|v(B)) f¬ (B) = T (negation of B)
= f^ (T, T) = T
β = T
f (T, T) = T.
(this may, or may not make sense, we’re doing it *tomorrow* in class…however, I’m fairly certain I’ve got it under control.)
Prove – Then there is a unique |v: |S à
{F,T}.
(Calculated in the same way as |v, using the same rules)
|v (β) = T when ever all acceptable functions defined on β are T given β.
To do this we need to show all acceptable functions agree.
- Definition of |v
- Gives us a function. All acceptable functions agree
- If h and g are acceptable functions defined and β, then h(β)= g(β) (Recall
acceptable functions agree on sentence symbols) This therefore proven by
induction
- If h and g are acceptable functions defined and β, then h(β)= g(β) (Recall
- Gives us a function. All acceptable functions agree
- Does this |v satisfy the conditions?
- Is it defined on all of |S?
- Show that there is always a way to extend an acceptable function to an
acceptable function. If h is defined on α and β then h, such that h1((α≡
β)) = f≡(h(α)), h(β) is acceptable
- Show that there is always a way to extend an acceptable function to an
- Does it satisfy (i) and (ii)?
- Follows from definition of |v as union of acceptable functions
- Is it defined on all of |S?
- Show |v is unique
- Follows from the fact that acceptable functions agree
September 21st, 2006 on 10:26 am
You just think you’re so smart don’t you… I may not understand your odd greek symbols, but I do understand logical recursion - especially with regards to boolean logic.
Recursion is kind of a holy grail in programming because of it’s elegant solving ability. Here’s one I wrote in ASP earlier this week that displays a directory tree:
< %
Response.Write Replace (displayTree ("c:\windows", 0), vbTab," ")
Function displayTree ( strFolder, intTreeLevel )
Dim obj_fs, objFolder, objSubFolders, objTempFolder
Set obj_fs = CreateObject("Scripting.FileSystemObject")
Set objFolder = obj_fs.GetFolder ( strFolder )
displayTree = displayTree & String ( intTreeLevel,vbTab) & "."
displayTree = displayTree & vbTab & objFolder.Name &"<br>"
If objSubFolders.Count > 0 Then
For Each objTempFolder in objSubFolders
str_argument = strFolder & “\” & objTempFolder.Name
displayTree = displayTree &
displayTree ( str_argument, intTreeLevel+1 )
Next
End If
End Function
%>
September 21st, 2006 on 11:40 am
hahaha, no i dont think I’m “so smart” its just a way for me to understand the classes I’m having.
Iheard that the only good thing mathematical logic is good for is programming… so far, that is the case.
September 21st, 2006 on 2:37 pm
I’m jealous that you’re learning and I’m stuck writing beautiful recursive functions… for perverts that need to pay to get laid.
I wish I was in logic classes.
September 22nd, 2006 on 8:58 am
Well, feel free to come on over and take the classes for me. Its the hardest stuff I’ve ever done in my entire life…I dont work well with problem sets and notations, I do well wtih analysis and essays.