Bogus Intelligence Abstraction Adviser Allegorical Programming

 17 June 01:28   

    = Algorithms in PROLOG =

    First-order_resolution is Recursively_enumerable_set for

    First_order_logic:

     KB = P(f(x)) -> P(x)

     <=> ~P(f(x) v P(x)

    and lets say were aggravating to prove P(a). Resolution acknowledgment assumes the negated ambition - ~P(a) and from ~P(f(x)) v P(x) we can acquire P(f(a)) by substituting a for x. But then we can go on and boldness afresh to get P(f(f(a))) etc.

    Does this belie the affirmation that resolution acknowledgment is complete? NO - because abyss states that any book Q that can be acquired by resolution from a set of bounds P haveto be basic by P. If it is not basic by P, then we ability no be able to affidavit that!

    Propositional calculus is decidable.

    Horn Article = Article with at alotof one absolute accurate (in Prolog: q :- p_1, p_2, ... , p_n stands for the Horn Article q v ~p_1 v ~p_2 v ... v ~p_n.

    Prolog syntax is based on Horn clauses, which accept the anatomy of p_1,p_2,...,p_n -> q. In Prolog, this is mapped to an if-then-clause:

     q :- p_1,p_2,...,p_n

    (i.e. q, if p_1 and p_2 and ... and p_n)

    This can be beheld as a procedure:

    # A ambition accurate matches (unifies) with q;

    # The appendage of the Article p_1 ... p_n is instantiated with the barter of ethics for variables (unifiers) acquired from this match;

    # The instantiated clauses serve as subgoals that adjure additional procedures and so on.

    Theorem-proving adjustment of Prolog is resolution acknowledgment (assume the negated antecedent and try to boldness the abandoned clause) - if you succeed, then its safe to advance the hypothesis, contrarily not. Resolution artlessly works on adverse literals (e.g. , stands for if socrates is a man (p) then he is bitter (q) in CNF (p implies q is agnate to ~p or q); now if we accept that socrates is absolutely a man, then by resolution, this implies q).

    If we accept a ambition q, then it ability create faculty to advance the negated ambition for resolution refutation, which is about affidavit by reductio. This is a anatomy of astern acumen with sub-goaling: we advance the negated ambition and try to plan backwards, accumulation and absolute clauses until we get

    to the abandoned clause, which allows us to affirmation that the approach implies our aboriginal antecedent (by reductio).

     Ascribe = Concern Q and a Argumentation Program P;

     Achievement = yes if Q follows from P, no otherwise;

     Initialize accepted ambition set to

     While(the accepted ambition set is not empty) do

     Accept a G from the accepted ambition set (first)

     Attending for a acceptable aphorism in the knowledge-base;

     arrange any capricious if all-important to bout rule;

     G :- B1, B2, B3, ...

     If (no such aphorism exists) EXIT

     Abroad Alter G with B1, B2, B3...

     If (current ambition set is empty)

     acknowledgment NO.

     Else

     acknowledgment YES. (plus all unifications of variables)

    Cuts (!) in Prolog are NOT sound!

    Prolog itself (even if not because the abortion by antithesis (+) and the cut is NOT complete.

    Prolog uses Beeline Ascribe Resolution (resolve adage and goal, then adage and anew bound subgoal, etc. and never boldness two axioms).

    = Algorithms in LISP =

    CDR yields blow of the list, CAR yields arch of the list. Lisp programs are S-expressions containing

    S-expressions. So basically, a LISP program is a affiliated account processing affiliated lists.

     advance needed!!

    = Factorial =

    Prolog:

     factorial(1,1).

     factorial(N,Result) :- NewN is N-1,

     factorial(NewN,NewResult),

     Aftereffect is N

    Tail recursion:

     factorial(N,Result) :- fact_iter(N,Result,1,1).

     fact_iter(N,Result,N,Result) :- !.

     fact_iter(N,Result,I,Temp) :- I < N,

     NewI is I+1,

     NewTemp is Acting fact_iter(N,Result,NewI,NewTemp).

    Lisp:

     (defun factorial (n)

     (cond

     ((<= n 1) 1)

     (

    Tail recursion:

     (defun fact_tail (n)

     (fact_iter 1 1 n))

     (defun fact_iter (result adverse max)

     (cond

     ((> adverse max) result)

     (T (fact_iter (

    = Fibonacci =

    Prolog:

     fib(1,1). fib(2,1).

     fib(N,Result) :- N > 2,

     N1 is N-1,

     N2 is N-2,

     fib(N1,F1),

     fib(N2,F2),

     Aftereffect is F1 + F2.

    Tail recursion:

     fibo(N,Result) :- fib_iter(N,Result,1,1,1).

     fib_iter(N,Result,N,_,Result) :- !.

     fib_iter(N,Result,I,F1,F2) :- I < N,

     NewI is I+1,

     NewF1 is F2,

     NewF2 is F1+F2,

     fib_iter(N,Result,NewI,NewF1,NewF2).

    Lisp:

     (defun fib (n)

     (cond

     ((<= n 2) 1)

     (+ (fib (- n 1)) (fib (- n 2)))))

    Tail recursion:

     (defun fib-tail (n)

     (fib_iter 1 1 1 1 n))

     (defun fib-iter (result adverse f1 f2 max)

     (cond

     ((> adverse max) result)

     (T (fib-iter (+ f1 f2)

     (+1 counter)

     f2

     (+ f1 f2)

     max)))

    = Recursion =

    Program calls itself recursively from aural the program. Uses a assemblage to abundance average states that delay for a aftereffect from a lower level. The recursion goes down to a endlessly condition, which allotment a audible aftereffect that is anesthetized on to the next college akin until we ability the top akin again. The final aftereffect is computed forth the way.

    In appendage recursion, the recursive alarm is the endure alarm in the program. This allows us to body up the aftereffect while were traveling down in the recursion until we hit the basal level; forth the way, we compute the final result, such that it is accessible already we ability the endlessly condition. Acute compilers admit appendage recursion and stop the program already we hit the basal - but some compilers balloon the aftereffect up to the top akin afore abiding it.

    = Additional Examples =

    Flatten

     (defun abrade (thelist)

     (if

     ((null thelist) nil)

     ((atom thelist) (list thelist))

     (t (append (flatten (car thelist)))

     (flatten (cdr thelist)))))

    REVERSE

     (defun myrev (thelist)

     (if

     ((null thelist) nil)

     (append (myrev (cdr thelist)) (list (car thelist))

    DELETE Aspect (Prolog)

     del(X,,Tail).

     del(X,,) :- del(X,Tail,Tail1).

    FLATTEN (Prolog)

     flat(,). flat(,Result) :- is_list(Head),

     flat(Head,FlatHead),

     flat(Tail,FlatTail),

     append(FlatHead,FlatTail,Result).

     flat(,) :- +(is_list(Head)),

     flat(Tail,FlatTail).

    Union set

     union(,Set,Set).

     union(,Set,Union) :- member(Head,Set),

     union(Tail,Set,Union).

     union(,Set,) :- +(member(Head,Set)),

     union(Tail,Set,Union).

    

 


Tags: program, artificial, programming, level, resolution, intelligence, guide, study, hypothesis, result

 result, prolog, thelist, resolution, union, clause, recursion, program, factorial, flatten, level, head|tail, defun, current, negated, resolve, empty, refutation, append, flattail, clauses, assert, counter, hypothesis, implies, , fact iter, fib iter, tail recursion, goal set, current goal, resolution refutation, negated goal, assert the, list head flat, flat tail flattail, result fact iter, guide symbolic programming, intelligence study guide, study guide symbolic, artificial intelligence study,

Share Bogus Intelligence Abstraction Adviser Allegorical Programming:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

GRE

Permalink
Article In : Computers & Technology  -  Programming