SlideShare a Scribd company logo
Prolog
Section 4
Recursion
• A common method of simplification is to
divide a problem into subproblems of the
same type.
• Recursion is when a function calls itself.
• It is when a function (operation) exists on the
left and the right hand side of an equation.
• It should have a stop condition.
Factorial
Iterative

Recursive

X! = 1*2*3*…*X
= X*(X-1)*(X-2)*…*2*1

X!=

Factorial (X-1)

1
if X=0
X*(X-1)! otherwise
Factorial
Iterative prolog, there are no return values -> new
Recursive
•In
the result
int factorial(int X) variable forint factorial(int X)
{

}

factorial(X,Y) -> we’ll put the result in Y Basic step
{
int Y=1;
if(X==0)
•The if statements in C++ are converted into
for(int i=0;i<X;i++)
return 1;
rules in prolog
{
else
Y*=X-i;
return X*factorial(X-1);
}
}
General
return Y;
rule
Factorial
•We
Iterative can’t put an operation as a parameter to a
Recursive
rule. factorial(int X)
int factorial(int X)
int
factorial(X-1)  Z=X-1, factorial(Z)
{
{
int Y=1;
if(X==0)
•Bounded variables can’t be assigned a value
for(int i=0;i<X;i++)
return 1;
X=5
{
else
Y*=X-i;
return X*factorial(X-1);
If X is free
If X is bounded
}
} then this statement is
then this statement is
return Y;
assign statement
comparison statement,
}
and returns true or false
Factorial
(non-tailer recursion)
predicates
fact(integer,integer)
clauses
fact(X,Y):-X=0,Y=1.
fact(X,Y):- Z=X-1,
fact(Z,NZ),Y=NZ*X.

Recursive

int factorial(int X)
{
if(X==0)
return 1;
else
return
X*factorial(X-1);
}
Factorial
(non-tailer recursion)
Recursive
predicates
int factorial(int X)
fact(integer,integer)
Stack overflow {
clauses
(infinite loop)
if(X==0)
fact(0,1).
return 1;

else
return
X*factorial(X-1);

fact(X,Y):- Z=X-1,
fact(Z,NZ),Y=NZ*X.
}
Factorial
(non-tailer recursion)
predicates
fact(integer,integer)
clauses
fact(0,1):-!.
fact(X,Y):- Z=X-1,
fact(Z,NZ),Y=NZ*X.

Recursive

int factorial(int X)
{
if(X==0)
return 1;
else
return
X*factorial(X-1);
}
Tracing
fact(4,Y).

0

Y=24

Match with the second rule:

6
6
fact (4, 24 ):- Z=4-1=3, fact (3,NZ),Y=NZ*4.
Y
Match with the second rule:

fact (3,6):- Z=3-1=2, fact (2,NZ),Y=NZ*3.
Y
2
2
Match with the second rule:

fact (2,2):- Z=2-1=1, fact (1,NZ),Y=NZ*2.
Y
1
1
Match with the second rule:

fact (1,1):- Z=1-1=0, fact (0,NZ),Y=NZ*1.
Y
1
1
Match with the first rule:

fact (0,1).

Then Y=1
Tracing
fact(4,Y).

Y=24

Match with the second rule:

6
6
fact TheYproblem with non-tailer recursion is
(4, 24 ):- Z=4-1=3, fact (3,NZ),Y=NZ*4.

Match with the second rule: variable waiting for
that there is always a

fact (3,6):- Z=3-1=2, fact (2,NZ),Y=NZ*3. call
Y
2
2
the return value from the recursive
Match withto complete the computations
the second rule:
fact (2,2):- Z=2-1=1, fact (1,NZ),Y=NZ*2.
Y
1
1
Match with the second rule:
(lots of memory taken… not good!)
fact (1,1):- Z=1-1=0, fact (0,NZ),Y=NZ*1.
Y
1
1
Match with the first rule:

fact (0,1).

Then Y=1
Tailer recursion
• Put the recursive call at the tail.
• To convert from non-tailer to tailer recursion
we need:
– Auxiliary (helper) function
– Accumulator

• Instead of waiting for the returned value I’ll
accumulate the result, so each time I have a
recursive call I’ll be sending part of the result
until the computations are completed.
Factorial
(tailer recursion)
In C++ as if I’ll say:
Acc=1;
for(int i=X;i>0;i--)
{
Acc=Acc*i;
}
Factorial
(tailer recursion)
predicates
fact(integer,integer)
fact_aux(integer,integer,integer)
clauses
fact(X,F):-fact_aux(X,F,1).
fact_aux(0,F,Acc):- F=Acc,!.
fact_aux(X,F,Acc):NAcc=Acc*X, NX=X-1,
fact_aux(NX,F,NAcc).
Factorial
(tailer recursion)
predicates
fact(integer,integer)
fact_aux(integer,integer,integer)
clauses
fact(X,F):-fact_aux(X,F,1).
fact_aux(0,F,F):-!.
fact_aux(X,F,Acc):NAcc=Acc*X, NX=X-1,
fact_aux(NX,F,NAcc).
Factorial
(tailer recursion)

*
X

F

Acc

3

?

1

2
1

?
?

3
6

0

?

6

= NAcc
3
6
6

NX
2
1
0
Power
Iterative

Recursive

23 = 2*2*2
XN=X*X*…*X (N times)

XN =

X (N-1)

1
if N=0
X*XN-1 otherwise
Power
(non-tailer recursion)
predicates
power(integer,integer,integer)
clauses
power(X,0,1):-!.
power(X,N,P):-Z=N-1,
power(X,Z,NP),P=NP*X.
goal
power(2,4,X).
Tracing
power(2,4,P). P=16
Match with the second rule:
16
8
8
power(2,4, P ):-Z=4-1=3, power(2,3,NP),P=NP*2.

Match with the second rule:

4
4
power(2,3,P):-Z=3-1=2, power(2,2,NP),P=NP*2.
8
Match with the second rule:

power(2,2,P):- Z=2-1=1, power(2,1,NP),P=NP*2.
4
2
2
Match with the second rule:

power(2,1,P):- Z=1-1=0, power(2,0,NP),P=NP*2.
2
1
1
Match with the first rule:

power(2,0,1).

Then P=1
Power
(tailer recursion)
In C++ as if I’ll say:
Acc=1;//in case of multiplication initialize the accumulator
with 1 but in case of addition initialize it with zero

for(int i=N;i>0;i--)
{
Acc=Acc*???;
}
Power
(tailer recursion)
In C++ as if I’ll say:
Acc=1;//in case of multiplication initialize the accumulator
with 1 but in case of addition initialize it with zero

for(int i=N;i>0;i--)
{
Acc=Acc*X;
}
Power
(tailer recursion)
predicates
power(integer,integer,integer)
power_aux(integer,integer,integer,integer)
clauses
power(X,N,P):- power_aux(X,N,P,1).
power_aux(_,0,P,P):-!.
power_aux(X,N,P,Acc):Nacc=Acc*X, Z=N-1,
power_aux(X,Z,P,Nacc).
Power
(tailer recursion)

*
X

N

P

Acc

2

4

?

1

2
2

3
2

?
?

2
4

2
2

1
0

?
?

8
16

= NAcc
2
4
8
16

Z (new N)
3
2
1
0
Fibonacci
fib(0)=1
fib(1)=1
fib(X)=fib(X-1)+fib(X-2)
Ex:
X
F(X)

0
1

1
1

2
2

3
3

F(X)=F(X1)+F(X2)

4
5

5
8
Fibonacci
(non-tailer recursion)
predicates
fib(integer,integer)
clauses
fib(1,1):-!.
fib(0,1):-!.
fib(X,Y):M=X-1,N=X-2,
fib(M,B),fib(N,A),Y=A+B.
Fibonacci
(tailer recursion)
int fib (int X)
{
int first = 1;
int second = 1;
for(int i = X; i>1; i--)
{
int temp=first;
first = second;
second = temp + second;
}
return second;
}
Fibonacci
(tailer recursion)
predicates
fib(integer, integer)
fib_aux(integer, integer, integer, integer)
clauses
fib(X, Fib):fib_aux(X, Fib,1, 1).
fib_aux(1, Second,_, Second):-!.
fib_aux(X, Fib,First, Second):NewX = X - 1,
NewFirst = Second,
NewSecond = First + Second,
fib_aux(NewX, Fib, NewFirst, NewSecond).
Assignment
Write a program to calculate the summation
from X to Y of i

More Related Content

What's hot

Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
Chyi-Tsong Chen
 
21 3 ztransform
21 3 ztransform21 3 ztransform
21 3 ztransform
Mahyar Alzobaidy
 
Cs1123 8 functions
Cs1123 8 functionsCs1123 8 functions
Cs1123 8 functions
TAlha MAlik
 
MATLAB ODE
MATLAB ODEMATLAB ODE
MATLAB ODE
Kris014
 
Chap08alg
Chap08algChap08alg
Chap08alg
Munkhchimeg
 
Lyapunov stability
Lyapunov stability Lyapunov stability
Lyapunov stability
Srinath Thamban
 
Boolean Matching in Logic Synthesis
Boolean Matching in Logic SynthesisBoolean Matching in Logic Synthesis
Boolean Matching in Logic Synthesis
Iffat Anjum
 
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
The1 Uploader
 
Finite difference &amp; interpolation
Finite difference &amp; interpolationFinite difference &amp; interpolation
Finite difference &amp; interpolation
Daffodil International University
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdf
Amir Saleh
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umrao
ssuserd6b1fd
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Jay Nagar
 
Introduction to Decision Making Theory
Introduction to Decision Making TheoryIntroduction to Decision Making Theory
Introduction to Decision Making Theory
Yosuke YASUDA
 
Eigenvalue eigenvector slides
Eigenvalue eigenvector slidesEigenvalue eigenvector slides
Eigenvalue eigenvector slides
AmanSaeed11
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforce
chidabdu
 
Modern Control - Lec07 - State Space Modeling of LTI Systems
Modern Control - Lec07 - State Space Modeling of LTI SystemsModern Control - Lec07 - State Space Modeling of LTI Systems
Modern Control - Lec07 - State Space Modeling of LTI Systems
Amr E. Mohamed
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
Matlab Assignment Experts
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlighted
AmanSaeed11
 
Rules of derivatives 2.2
Rules of derivatives 2.2Rules of derivatives 2.2
Rules of derivatives 2.2
Lorie Blickhan
 
Optimization Approach to Nash Euilibria with Applications to Interchangeability
Optimization Approach to Nash Euilibria with Applications to InterchangeabilityOptimization Approach to Nash Euilibria with Applications to Interchangeability
Optimization Approach to Nash Euilibria with Applications to Interchangeability
Yosuke YASUDA
 

What's hot (20)

Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
Intelligent Process Control Using Neural Fuzzy Techniques ~陳奇中教授演講投影片
 
21 3 ztransform
21 3 ztransform21 3 ztransform
21 3 ztransform
 
Cs1123 8 functions
Cs1123 8 functionsCs1123 8 functions
Cs1123 8 functions
 
MATLAB ODE
MATLAB ODEMATLAB ODE
MATLAB ODE
 
Chap08alg
Chap08algChap08alg
Chap08alg
 
Lyapunov stability
Lyapunov stability Lyapunov stability
Lyapunov stability
 
Boolean Matching in Logic Synthesis
Boolean Matching in Logic SynthesisBoolean Matching in Logic Synthesis
Boolean Matching in Logic Synthesis
 
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
Pengolahan Data Panel Logit di Stata: Penilaian Goodness of Fit, Uji Model, d...
 
Finite difference &amp; interpolation
Finite difference &amp; interpolationFinite difference &amp; interpolation
Finite difference &amp; interpolation
 
Regression_1.pdf
Regression_1.pdfRegression_1.pdf
Regression_1.pdf
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umrao
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Introduction to Decision Making Theory
Introduction to Decision Making TheoryIntroduction to Decision Making Theory
Introduction to Decision Making Theory
 
Eigenvalue eigenvector slides
Eigenvalue eigenvector slidesEigenvalue eigenvector slides
Eigenvalue eigenvector slides
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforce
 
Modern Control - Lec07 - State Space Modeling of LTI Systems
Modern Control - Lec07 - State Space Modeling of LTI SystemsModern Control - Lec07 - State Space Modeling of LTI Systems
Modern Control - Lec07 - State Space Modeling of LTI Systems
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
 
Numarical values highlighted
Numarical values highlightedNumarical values highlighted
Numarical values highlighted
 
Rules of derivatives 2.2
Rules of derivatives 2.2Rules of derivatives 2.2
Rules of derivatives 2.2
 
Optimization Approach to Nash Euilibria with Applications to Interchangeability
Optimization Approach to Nash Euilibria with Applications to InterchangeabilityOptimization Approach to Nash Euilibria with Applications to Interchangeability
Optimization Approach to Nash Euilibria with Applications to Interchangeability
 

Viewers also liked

Gianotti María de los Ángeles Unidad 1
Gianotti María de los Ángeles Unidad 1Gianotti María de los Ángeles Unidad 1
Gianotti María de los Ángeles Unidad 1
mariangianotti9
 
West Suburban Teachers Union 75th anniversary presentation
West Suburban Teachers Union 75th anniversary presentationWest Suburban Teachers Union 75th anniversary presentation
West Suburban Teachers Union 75th anniversary presentation
a bendelow
 
Què és la infor.
Què és la infor.Què és la infor.
Què és la infor.evamm24
 
The stages of film making
The stages of film makingThe stages of film making
The stages of film making
benzibob1234
 
Tp de ingles
Tp de inglesTp de ingles
Tp de ingles
Sofia_T
 
Bintang menurut perspektif al quran
Bintang menurut perspektif al   quranBintang menurut perspektif al   quran
Bintang menurut perspektif al quran
farisiman0821
 
VisióN Comparativa De Una Unidad De InformacióN En
VisióN Comparativa De Una Unidad De InformacióN EnVisióN Comparativa De Una Unidad De InformacióN En
VisióN Comparativa De Una Unidad De InformacióN En
juliemarie_7
 
104 O Haver Handout
104 O Haver Handout104 O Haver Handout
104 O Haver Handout
MedicineAndDermatology
 
practicas pedagogicas
practicas pedagogicaspracticas pedagogicas
practicas pedagogicas
jeff120
 

Viewers also liked (9)

Gianotti María de los Ángeles Unidad 1
Gianotti María de los Ángeles Unidad 1Gianotti María de los Ángeles Unidad 1
Gianotti María de los Ángeles Unidad 1
 
West Suburban Teachers Union 75th anniversary presentation
West Suburban Teachers Union 75th anniversary presentationWest Suburban Teachers Union 75th anniversary presentation
West Suburban Teachers Union 75th anniversary presentation
 
Què és la infor.
Què és la infor.Què és la infor.
Què és la infor.
 
The stages of film making
The stages of film makingThe stages of film making
The stages of film making
 
Tp de ingles
Tp de inglesTp de ingles
Tp de ingles
 
Bintang menurut perspektif al quran
Bintang menurut perspektif al   quranBintang menurut perspektif al   quran
Bintang menurut perspektif al quran
 
VisióN Comparativa De Una Unidad De InformacióN En
VisióN Comparativa De Una Unidad De InformacióN EnVisióN Comparativa De Una Unidad De InformacióN En
VisióN Comparativa De Una Unidad De InformacióN En
 
104 O Haver Handout
104 O Haver Handout104 O Haver Handout
104 O Haver Handout
 
practicas pedagogicas
practicas pedagogicaspracticas pedagogicas
practicas pedagogicas
 

Similar to Sec4

Recursion
RecursionRecursion
Recursion
James Wong
 
Recursion.pdf
Recursion.pdfRecursion.pdf
Recursion.pdf
Flavia Tembo Kambale
 
Recursion
RecursionRecursion
Recursion
Syed Zaid Irshad
 
Piecewise Functions
Piecewise FunctionsPiecewise Functions
Piecewise Functions
swartzje
 
Recursion
RecursionRecursion
Recursion
SAGARDAVE29
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introduction
SSE_AndyLi
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Amit Kumar Rathi
 
Generating functions (albert r. meyer)
Generating functions (albert r. meyer)Generating functions (albert r. meyer)
Generating functions (albert r. meyer)
Ilir Destani
 
DynamicProgramming.pdf
DynamicProgramming.pdfDynamicProgramming.pdf
DynamicProgramming.pdf
ssuser3a8f33
 
Recursion examples
Recursion examplesRecursion examples
Recursion examples
HafsaZahran
 
6-Python-Recursion.pdf
6-Python-Recursion.pdf6-Python-Recursion.pdf
6-Python-Recursion.pdf
AshishPalandurkar2
 
Introduction to Artificial Neural Networks
Introduction to Artificial Neural NetworksIntroduction to Artificial Neural Networks
Introduction to Artificial Neural Networks
Stratio
 
Answers To Exercises Microeconomic Analysis Third Edition
Answers To Exercises Microeconomic Analysis Third EditionAnswers To Exercises Microeconomic Analysis Third Edition
Answers To Exercises Microeconomic Analysis Third Edition
Stephen Faucher
 
Artificial neural networks - A gentle introduction to ANNS.pptx
Artificial neural networks - A gentle introduction to ANNS.pptxArtificial neural networks - A gentle introduction to ANNS.pptx
Artificial neural networks - A gentle introduction to ANNS.pptx
AttaNox1
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
Neural Networks.pptx
Neural Networks.pptxNeural Networks.pptx
Neural Networks.pptx
SovonChakraborty8
 
Varian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution bookVarian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution book
José Antonio PAYANO YALE
 
14 recursion
14 recursion14 recursion
14 recursion
Himadri Sen Gupta
 
Comparison market implied volatilities with implied volatilities computed by ...
Comparison market implied volatilities with implied volatilities computed by ...Comparison market implied volatilities with implied volatilities computed by ...
Comparison market implied volatilities with implied volatilities computed by ...
Yuan Jing
 

Similar to Sec4 (20)

Recursion
RecursionRecursion
Recursion
 
Recursion.pdf
Recursion.pdfRecursion.pdf
Recursion.pdf
 
Recursion
RecursionRecursion
Recursion
 
Piecewise Functions
Piecewise FunctionsPiecewise Functions
Piecewise Functions
 
Recursion
RecursionRecursion
Recursion
 
1 chapter1 introduction
1 chapter1 introduction1 chapter1 introduction
1 chapter1 introduction
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Generating functions (albert r. meyer)
Generating functions (albert r. meyer)Generating functions (albert r. meyer)
Generating functions (albert r. meyer)
 
DynamicProgramming.pdf
DynamicProgramming.pdfDynamicProgramming.pdf
DynamicProgramming.pdf
 
Recursion examples
Recursion examplesRecursion examples
Recursion examples
 
6-Python-Recursion.pdf
6-Python-Recursion.pdf6-Python-Recursion.pdf
6-Python-Recursion.pdf
 
Introduction to Artificial Neural Networks
Introduction to Artificial Neural NetworksIntroduction to Artificial Neural Networks
Introduction to Artificial Neural Networks
 
Answers To Exercises Microeconomic Analysis Third Edition
Answers To Exercises Microeconomic Analysis Third EditionAnswers To Exercises Microeconomic Analysis Third Edition
Answers To Exercises Microeconomic Analysis Third Edition
 
Artificial neural networks - A gentle introduction to ANNS.pptx
Artificial neural networks - A gentle introduction to ANNS.pptxArtificial neural networks - A gentle introduction to ANNS.pptx
Artificial neural networks - A gentle introduction to ANNS.pptx
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
Neural Networks.pptx
Neural Networks.pptxNeural Networks.pptx
Neural Networks.pptx
 
Varian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution bookVarian, microeconomic analysis, solution book
Varian, microeconomic analysis, solution book
 
14 recursion
14 recursion14 recursion
14 recursion
 
Comparison market implied volatilities with implied volatilities computed by ...
Comparison market implied volatilities with implied volatilities computed by ...Comparison market implied volatilities with implied volatilities computed by ...
Comparison market implied volatilities with implied volatilities computed by ...
 

Recently uploaded

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 

Recently uploaded (20)

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 

Sec4

Editor's Notes

  1. goalfact(4,X).
  2. If the goal is what question, ex factorial(4,Y), when it reaches X=1 it will match with the first rule AND also the second trying to subtract 1 from X so it will be zero then -1 then -2… so on!
  3. Tracing the goal factorial(4,Y)The problem with non-tailer recursion is that it is always waiting for the return value to complete the computations
  4. Tracing the goal factorial(4,Y)The problem with non-tailer recursion is that it is always waiting for the return value to complete the computations
  5. To convert non-tailer to tailer, I’ll need a helper function in which I’ll define a new variable to accumulate the results in.
  6. Why do I need the auxiliary function? because the user should not know anything about the accumulator, he ONLY knows the number and want its factorial.goalfact(4,X).
  7. Why do I need the auxiliary function? because the user should not know anything about the accumulator, he ONLY knows the number and want its factorial.goalfact(4,X).
  8. Goal factorial(3,F).
  9. Tracing the goal Power(2,4,P)The problem with non-tailer recursion is that it is always waiting for the return value to complete the computations
  10. Tracepow(2,4)i=4 Acc= 1 *2i=3 Acc = 2*2i=2 Acc= 2*2*2i=1 Acc= 2*2*2*2
  11. goalpower(2,4,P).
  12. Goal power(2,4,F).
  13. Why put rule for both fib(0) and fib(1)? Because if the user asks for fib(0) it must have a rule to match with.goalfib(6,X).
  14. Fib(4)i=4 first = 1 sec=1+1=2i=3 first=2sec=2+1=3i=2 first=3 sec=3+2=5
  15. goalfib(4,X).