cs508-3-bc080200115

download cs508-3-bc080200115

of 3

Transcript of cs508-3-bc080200115

  • 7/31/2019 cs508-3-bc080200115

    1/3

    Modern Programming Languages (CS508)

    Assignment No. 3

    Muhammad Sheraz

    Bc080200115

    Application:AlstraSoft Expert System Application:Scenario:Suppose you are developing an expert Environmental system at Alstrasoft Pvt. Ltd that strives tobe the premier provider of web-based software solutions for businesses worldwide. As a web

    development and software company, Alstrasoft specialize mainly in web design and software

    programming.

    Evaluation:Now In the same Environmental systems that predict the weather, analyze water supplies, and so

    on. There is a need to develop an expert system in Prolog named Weather Modeling System, forNational Center for Atmospheric Research .This expert system will provide relatively detailed,short term forecast of meteorological conditions. It is used particularly to model pollutant

    dispersion (for instance, acid rain deposition).

    Answer the following questions based on the scenario provided.

    a)Why is PROLOG the language of choice for developers to develop expert system likeWeather Modeling System?

    Answer:

    Basically, if your program can be stated easily as declarative formal logic statements, Prolog (oranother language in that family) will give the fastest development time. If you use a good Prologcompiler, it will also give the best performance and reliability, because the engine will have had a

    lot of design and development effort.

    Trying to implement this kind of thing in another language tends to be a mess. The cleanest andmost general solution probably involves implementing your own unification engine. Of course in

    the real world, key parts of your program may benefit from Prolog, but a lot of other stuff is better

    handled using another language. Prolog works well for problems where a knowledge base forms animportant part of the solution, especially when the knowledge structure is suited to be encoded as

    logical rules. It's also a nice language to explore solutions to logical puzzles.

    The stuff which are inherent in Prolog:

    Pattern matching. Anything that involves a depth first search.

    Unification.

    b) Write Prolog equivalent for the following statements?1. Weather is cloudy and rainy.

    2. Dust storm is expected today.

    3. Mike carries umbrella for John.

  • 7/31/2019 cs508-3-bc080200115

    2/3

    4. Is there a forecast for rain today?

    5. Is the earth round.

    Answer:1. Weather_is_cloudy_rainy.

    2. Dust_storm_is_expected_today.

    3. Umbrella(Mike,John)4. ?-Forecast_for_rain_today

    5. ?- Earth(X)

    X=round

    c) Consider a program that has following four facts and one rule. What will be the response offollowing queries in PROLOG also justifies your answer against each query?

    Facts:

    cloudy(South Carolina).cloudy(Oslo).

    cold(Oslo).

    snowy(Toronto)The rule is:

    foggy(X) :- cloudy(X), cold(X).

    Queries:

    ?- foggy(Oslo).

    ?- foggy(South Carolina).

    ?- foggy(Toronto).

    ?- foggy(C).C = X

    ?- foggy(Sweden).

    Answer:?- foggy(Oslo).

    Yes.

    As in rule foggy is equal to cloudy and cold so it is true.

    ?- foggy(South Carolina).

    Yes.

    As in rule foggy is equal to cloudy and cold so it is true.

    ?- foggy(Toronto).

    No.

    It is not true because Toronto is not cloudy and cold.

    ?- foggy (C).

    C = X

    Yes.

    As in rule foggy is equal to cloudy and cold so it is true.

    ?- foggy(Sweden).

  • 7/31/2019 cs508-3-bc080200115

    3/3

    No.

    Sweden is not in facts.