Nghiên cứu lý thuyết lập trình logic ngôn ngữ dựa trên biểu diễn mờ và diễn dịch xác suất của các nhãn ngôn ngữ

73 10 0
Nghiên cứu lý thuyết lập trình logic ngôn ngữ dựa trên biểu diễn mờ và diễn dịch xác suất của các nhãn ngôn ngữ

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Đại Học Quốc Gia Tp Hồ Chí Minh TRƯỜNG ĐẠI HỌC BÁCH KHOA NGUYỄN VĂN NỐI NGHIÊN CỨU LÝ THUYẾT LẬP TRÌNH LOGIC NGÔN NGỮ DỰA TRÊN BIỂU DIỄN MỜ VÀ DIỄN DỊCH XÁC SUẤT CỦA CÁC NHÃN NGÔN NGỮ ( ANNOTATED LINGUISTIC LOGIC PROGRAMMING ) Chuyên ngành : CÔNG NGHỆ THÔNG TIN Mã số ngành : 01.02.10 LUẬN VĂN THẠC SĨ TP HỒ CHÍ MINH, tháng 12 năm 2003 CÔNG TRÌNH ĐƯC HOÀN THÀNH TẠI TRƯỜNG ĐẠI HỌC BÁCH KHOA ĐẠI HỌC QUỐC GIA TP HỒ CHÍ MINH Cán hướng dẫn khoa học : Tiến só CAO HOÀNG TRỤ Cán chấm nhận xét : Tiến só DƯƠNG TUẤN ANH Cán chấm nhận xét : Phó Giáo sư Tiến só TRẦN VĂN HẠO Luận văn thạc só bảo vệ HỘI ĐỒNG CHẤM BẢO VỆ LUẬN VĂN THẠC SĨ TRƯỜNG ĐẠI HỌC BÁCH KHOA, ngày 08 tháng 01 năm 2004 Đại Học Quốc Gia Tp Hồ Chí Minh TRƯỜNG ĐẠI HỌC BÁCH KHOA CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM Độc Lập – Tự Do – Hạnh Phúc Tp HCM, ngày 09 tháng 01 năm 2004 NHIỆM VỤ LUẬN VĂN THẠC SĨ Họ tên học viên : NGUYỄN VĂN NỐI Ngày, tháng, năm sinh : Ngày 10 tháng 11 năm 1976 Chuyên ngành : Công Nghệ Thông Tin I- TÊN ĐỀ TÀI : Phái : Nam Nơi sinh : Tiền Giang MSHV : 6003.11.003 Nghiên cứu lý thuyết lập trình logic ngôn ngữ dựa biểu diễn mờ diễn dịch xác suất nhãn ngôn ngữ II- NHIỆM VỤ VÀ NỘI DUNG : Phân tích xác định vấn đề : tìm hiểu diễn dịch xác suất nhãn ngôn ngữ lập trình logic xác suất, đưa đặc tả ngôn ngữ lập trình logic ngôn ngữ Phương pháp luận : định nghóa cú pháp, ngữ nghóa thủ tục chứng minh chương trình Hiện thực : minh hoạ chương trình III- NGÀY GIAO NHIỆM VỤ : Ngày 01 tháng 07 năm 2003 IV- NGÀY HOÀN THÀNH NHIỆM VỤ : Ngày 08 tháng 01 năm 2004 V- HỌ VÀ TÊN CÁN BỘ HƯỚNG DẪN : CÁN BỘ HƯỚNG DẪN Ts Cao Hoàng Trụ Tiến só Cao Hoàng Trụ CHỦ NHIỆM NGÀNH BỘ MÔN QUẢN LÝ NGÀNH Ts Dương Tuấn Anh Nội dung đề cương luận văn thạc só Hội Đồng Chuyên Ngành thông qua Ngày PHÒNG ĐÀO TẠO SĐH tháng năm KHOA QUẢN LÝ NGÀNH “ Kính gởi lời cảm ơn chân thành đến Tiến só Cao Hoàng Trụ, Quý Thầy Cô, bạn bè gia đình tận tình hướng dẫn, giảng dạy, giúp đỡ động viên để luận văn hoàn thành !“ 12/2003 - Nguyễn Văn Nối Abstract Several approaches have been proposed for modeling and computing with linguistic information in natural language, among which Lawry’s label semantics provides a clear interpretation of linguistic expressions and thus a transparent model for real-world applications Meanwhile annotated logic programs have been developed as an extension of classical logic programs offering a powerful computational framework for handling uncertain and imprecise data within logic programs This paper proposes annotated linguistic logic programs (ALLPs) that embeds Lawry’s label semantics into the annotated logic program syntax, providing a formalism for development of automated reasoning systems involving soft data as vague and imprecise concepts occurring frequently in natural language The basic notions of ALLPs are introduced, and their syntax and declarative semantics are defined And the ALLP proof procedure is developed and proved to be sound and complete with respect to the declarative semantics of ALLPs MUÏC LUÏC Danh mục hình vẽ .4 Chương GIỚI THIỆU 1.1 Động .5 1.2 Phạm vi nghiên cứu 1.3 Định nghóa .7 1.4 Ký hiệu quy ước .8 Chương KHUNG THỨC BIỂU DIỄN NGÔN NGỮ 2.1 Phép gán khối 2.2 Ngữ nghóa nhãn ngôn ngữ 2.3 Biểu thức nhãn ngôn ngữ .11 2.4 Giải mờ độ tương hợp hai biểu thức nhãn ngôn ngữ .14 Chương NGỮ NGHĨA KHAI BÁO 16 3.1 Tính chất dàn tập biểu thức nhãn ngôn ngữ 16 3.2 Cú pháp ALLP 18 3.3 Lý thuyết mô hình ALLP 21 3.4 Ngữ nghóa điểm bất động ALLP 25 Chương NGỮ NGHĨA THỦ TUÏC 34 4.1 Mệnh đề thu giảm ràng buộc 34 4.2 Thủ tục chứng minh chương trình 36 Chương HIỆN THỰC 44 5.1 XSB chương trình logic thích tổng quát .44 5.2 Hiện thực chương trình logic thích ngôn ngữ 45 5.3 Các khối chức chương trình nguồn XSB 46 5.4 Chương trình minh họa 48 Chương KẾT LUAÄN 50 6.1 Kết 50 6.2 Hướng nghiên cứu tương lai 50 TÀI LIỆU THAM KHẢO .56 PHỤ LỤC - Chương trình nguoàn 57 Danh mục hình vẽ Hình 3-1 Dàn ngôn ngữ cho tập nhãn LA= {L1, L2} .18 Hình 3-2 Độ thích hợp cho SAL vaø YRS .21 Hình 3-3 Bước lặp lên Rp 33 Hình 5-1 Các khối chức chương trình nguồn 47 Hình 5-2 Sơ đồ gọi ALLP meta-interpreter 48 Hình 6-1 Độ thích hợp cho LAscore 55 Chương GIỚI THIỆU 1.1 Động Con người sử dụng ngôn ngữ tự nhiên phương tiện quan trọng yếu giao tiếp Việc não người xử lý thông tin thể ngôn ngữ tự nhiên thách thức khoa học nói chung, đặc biệt lónh vực trí tuệ nhân tạo Hơn nữa, ngôn ngữ tự nhiên, khái niệm không xác, không rõ ràng không chắn xuất thường xuyên Để máy tính xử lý tính toán khái niệm cấp ngôn ngữ, cần thiết phải có khung thức để biểu diễn cần phải có dạng thức logic cho trình suy diễn dựa khung thức Một phương pháp tổng quát cho việc tính toán với từ (computing with words) Zadeh ([9], [10]) đề xuất lấy ý tưởng tính toán dựa thuật ngữ biểu thức ngôn ngữ tự nhiên tính toán lý thuyết tập mờ logic mờ, đặc biệt dựa ý tưởng biến ngôn ngữ Biến ngôn ngữ tứ L tên biến ngôn ngữ, T(L) tập hữu hạn nhãn (giá trị biến ngôn ngữ), Ω tập vũ trụ (tập khảo sát) M luật ngữ nghóa Luật ngữ nghóa M định nghóa ánh xạ kết hợp tập mờ Ω với từ w T(L), nghóa tập mờ M(w) xem giải mã ngữ nghóa w∈ T(L) cho x ∈Ω giá trị thành viên (membership value) χM(w)(x) định lượng độ thích hợp từ w cho giá trị x Luật ngữ nghóa M xác định mô hình bầu cử nhóm Việc sử dụng tập mờ rõ ràng trung tâm việc tính toán với từ Tập mờ cung cấp mô hình không xác không rõ ràng cho hầu hết thuật ngữ ngôn ngữ tự nhiên Tuy nhiên, vấn đề áp dụng phương pháp hàm thành viên diễn dịch rõ vấn đề ngữ nghóa không giải logic mờ định nghóa tiên đề hàm t-norm t-conorm tính chất toán tử Kết khó xem xét cách để tính toán hàm thành viên biểu thức ngôn ngữ Gần đây, Lawry ([1]) giới thiệu khung thức cho mô hình ngôn ngữ, nhãn ngôn ngữ giả sử chọn từ tập hữu hạn nhãn định nghóa trước tập nhãn thích hợp cho giá trị định nghóa tập ngẫu nhiên từ tập số đông cá nhân bầu chọn vào tập tập nhãn Sau độ thích hợp giá trị nhãn dẫn xuất từ phân bố xác suất, phép gán khối tập tập nhãn Khung thức cung cấp cách tính toán chặt chẽ cho biểu thức ngôn ngữ thành lập từ toán tử kết nối logic nhãn ngôn ngữ Tuy nhiên, khung thức thiếu dạng thức cho việc phát triển chương trình logic ngôn ngữ để xây dựng hệ thống suy diễn tự động cho tính toán mềm Để phục vụ cho suy diễn tự động, Lloyd ([6]) xây dựng sở lý thuyết cho ngôn ngữ lập trình logic dựa logic vị từ cấp Hai khía cạnh quan trọng lập trình logic ngữ nghóa khai báo ngữ nghóa thủ tục Ngữ nghóa khai báo lập trình logic bao gồm kiến thức logic vị từ cấp một, lý thuyết điểm bất động Các khái niệm ngữ nghóa khai báo khái niệm mệnh đề, chương trình logic, mô hình, điểm bất động, giải thuật hợp nhất… Ngữ nghóa thủ tục lập trình logic liên quan đến thủ tục chứng minh phân giải SLD đầy đủ Tuy nhiên, ngữ nghóa chương trình logic cho lý thuyết mâu thuẫn (inconsistent theories) mô hình Trong lúc đó, chương trình logic thích ([7]) cung cấp dạng thức tính toán cho việc suy diễn định lượng tưởng chương trình logic thích thích atom giá trị chân lý đa trị Một chương trình logic thích tập hợp mệnh đề tương tự mệnh đề Horn có dạng: A:µ ← B1:µ1 & B2:µ2 & …& Bn:µn A:µ Bi:µi’s atom thích Các thành phần thích µ, µi thuộc dàn giá trị chân lý Mỗi phần tử dàn xem hệ số tin cậy (confidence factor), độ tin tưởng (degree of belief ), giá trị tương tự giá trị logic đa trị Mỗi dàn tồn quan hệ thứ tự riêng phần, toán tử chặn nhỏ nhất, toán tử chặn lớn nhất, phần tử lớn phần tử nhỏ Diễn dịch tựa Herbrand ánh xạ từ Herbrand base, tập ground atom, vào dàn thích Trong ([8]), khung thức mở rộng atom term xem đối tượng thích tập mờ miền khác Tuy nhiên, chương trình logic thích xây dựng khái niệm dàn tổng quát thành phần thích chưa phải giá trị đại diện thật cho nhãn ngôn ngữ tự nhiên mà não người tư suy diễn nhãn ngôn ngữ Với đề tài ”Nghiên cứu lý thuyết lập trình logic ngôn ngữ dựa biểu diễn mờ diễn dịch xác suất nhãn ngôn ngữ”, luận văn đề xuất chương trình logic thích ngôn ngữ (ALLP) nhúng ngữ nghóa nhãn ngôn ngữ Lawry vào cú pháp chương trình logic thích phục vụ cho việc suy diễn tự động với liệu mờ không xác thể biểu thức nhãn ngôn ngữ 1.2 Phạm vi nghiên cứu Mục tiêu nghiên cứu luận văn tập trung vào vấn đề sau: Tìm hiểu khung thức biểu diễn ngôn ngữ, diễn dịch độ thích hợp biểu thức nhãn ngôn ngữ, tính chất dàn tập biểu thức nhãn ngôn ngữ Đưa đặc tả cú pháp ngữ nghóa khai báo chương trình logic thích ngôn ngữ bao gồm thành phần thích, đối tượng thích, mệnh đề chương trình, diễn dịch, quan hệ thỏa mãn, mô hình ngữ nghóa điểm bất động chương trình logic thích ngôn ngữ, cầu nối liên kết ngữ nghóa khai báo ngữ nghóa thủ tục chương trình Nghiên cứu ngữ nghóa thủ tục chương trình logic thích ngôn ngữ bao gồm ý tưởng mệnh đề thu giảm ràng buộc, sở cho thủ tục chứng minh chương trình logic thích ngôn ngữ, thủ tục chứng minh kiểu phân giải SLD đầy đủ Hiện thực chương trình logic thích ngôn ngữ bao gồm định nghóa văn phạm, biên dịch thực thi chương trình logic thích ngôn ngữ Sau chương này, chương nêu tổng quan khung thức biểu diễn nhãn ngữ Lawry Chương giới thiệu ngữ nghóa khai báo chương trình logic thích ngôn ngữ Chương nghiên cứu ngữ nghóa thủ tục chương trình logic thích ngôn ngữ Chương thực chương trình logic thích ngôn ngữ sử dụng ngôn ngữ XSB Và cuối cùng, chương đưa kết luận số gợi ý nghiên cứu tương lai 1.3 Định nghóa Quan hệ thứ tự riêng phần Quan hệ R tập S thứ tự riêng phần : (a) R phản thân : xRx ∀x∈S (b) R phản đối xứng : xRy yRx ⇒ x = y ∀x,y∈S (c) R truyền : xRy yRz ⇒ xRz ∀x,y,z∈S Chặn chặn Cho S tập với thứ tự riêng phần ≤ (a) a ∈ S chặn (upper bound) X ⊆ S x ≤ a ∀x ∈ X (b) b ∈ S chặn (lower bound) X ⊆ S b ≤ x ∀x ∈ X 56 TÀI LIỆU THAM KHẢO [1] J Lawry, “Label Semantics: A Formal Framework for Modeling with Words”, Proceedings of the Sixth European Conference for Symbolic and Quantitative Approaches to Reasoning with Uncertainty, Lecture Notes in Artificial Intelligent, Vol 2143, 374-385, 2001 [2] J Lawry, “A New Calculus for Linguistic Prototypes in Data Analysis”, Proceedings of Soft Methods in Probability and Statistics, SMPS2002, Springer, 116-125, 2002 [3] J Lawry, “Query Evaluation from Linguistic Prototypes”, Proceedings of the 10'th IEEE International Conference on Fuzzy Systems, Melbourne, Australia, 2001 [4] J Lawry, “Alternative Interpretation of Linguistic Variables and Computing with Words”, Proceedings of Information Processing and Management of Uncertainty, IPMU2000, Madrid, Spain, 3, 1743-1750, 2000 [5] J.F Baldwin, J.Lawry, T.P Martin, “A Mass Assignment Theory of The Probability of Fuzzy Events”, Fuzzy Sets and System, 83, 353-367, 1996 [6] J.W Lloyd, “Foundations of Logic Programming”, Springer-Verlag, 1987 [7] M Kifer, V.S Subrahmanian, “Theory of Generalized Annotated Logic Programming and Its Applications”, Journal of Logic Programming, 12, 335-367, 1992 [8] Tru H Cao, “Annotated Fuzzy Logic Programs”, International Journal for Fuzzy Sets and Systems, Elsevier Science, 113 (2), 277-298, 2000 [9] L.A Zadeh, “The Concept of Linguistic Variable and Its Application to Approximate Reasoning”, Information Science, Parts I II III 8(1975) 199251; 8(1975) 301-357; 9(1975) 43-80, 1975 [10] L.A Zadeh, “Fuzzy Logic = Computing with Words”, IEEE Transactions on Fuzzy Systems, 4, 103-111, 1996 [11] Terrance Swift, David S Warren, Michael Kifer, “The XSB System Programmer’s Manual”, Ver 2.5, Vol 2, June 2003 [12] Judea Pearl, “Probabilistic Reasoning in Intelligent Systems : Network of Plausible Inference”, Morgan Kaufmann Publishers Inc, 1997 [13] Nguyen Van Noi, Tru Hoang Cao, “Annotated Linguistic Logic Programs for Soft Computing”, Recherche Informatique Vietnam & Francophonie, RIVF’04, Hà Nội, 2004 (Sắp xuất bản) 57 PHỤ LỤC - Chương trình nguồn File: allp.p /* ANNOTATED LINGUISTIC LOGIC PROGRAMMING - ALLP ** File: allp.p ** Date: 19/10/2003 ** Author: NGUYEN VAN NOI ** Contact: nvnoi@vtihcm.com.vn ** Copyright (C) 2003 ** Purpose: ALLP interface for user query*/ :- op(1200,xfx, Approriate Set lamda(_,false,[]):-! lamda(Lattice,true,AppSet):- la2p(Lattice,AppSet),! lamda(Lattice, LabelExp, AppSet):normalize(LabelExp, LabelExpNorm), lda(Lattice,LabelExpNorm, AppSet) %% - Normalize the label set laex(Lattice,LabelSet):la(Lattice,LabelList),!, list_to_ord_set(LabelList,LabelSet) 62 laex(Lattice,_):-nl, write('"'), write(Lattice), write('" is not a lattice '), write('!'),nl, abort('Error in lattice definition !'),nl la2p(Lattice,PowerLabelSet):laex(Lattice,LabelSet), findall(X,sublist(X,LabelSet),F), list_to_ord_set(F,PowerLabelSet) %% - All subsets of a set -sublist(List, List) sublist(Sub, [Head|Tail]) :- sublist_(Tail, Head, Sub) sublist_(Sub, _, Sub) sublist_([Head|Tail], _, Sub) :- sublist_(Tail, Head,Sub) sublist_([Head|Tail], X, [X|Sub]) :- sublist_(Tail, Head, Sub) %% - lda used for lamda lda(_,false,[]):-! lda(Lattice,true,AppSet):-!, la2p(Lattice,AppSet) lda(Lattice,(X /\ Y),AppSet) :- !, lda(Lattice,X,A), lda(Lattice,Y,B), ord_intersection(A,B,C), list_to_ord_set(C,AppSet) lda(Lattice,(X \/ Y),AppSet) :- !, lda(Lattice,X,A), lda(Lattice,Y,B), ord_union(A,B,Union),list_to_ord_set(Union,AppSet) lda(Lattice,~Label,AppSet):laex(Lattice,LabelSet), memberchk(Label,LabelSet),!, la2p(Lattice,PowerLabelSet), appendsetnot(PowerLabelSet,Label,AppSetTemp), list_to_ord_set(AppSetTemp,AppSet) appendsetnot([X|F],Label,L):-memberchk(Label,X),!,appendsetnot(F,Label,L) appendsetnot([X|F],Label,[X|L]):-!,appendsetnot(F,Label,L) appendsetnot([],_,[]) lda(Lattice,~Label,_):- !,error(Lattice,Label) lda(Lattice,Label,AppSet):laex(Lattice,LabelSet), 63 memberchk(Label,LabelSet),!, la2p(Lattice,PowerLabelSet), appendset(PowerLabelSet,Label,AppSetTemp), list_to_ord_set(AppSetTemp,AppSet) appendset([X|F],Label,[X|L]):-memberchk(Label,X),!,appendset(F,Label,L) appendset([_|F],Label,L):-!,appendset(F,Label,L) appendset([],_,[]) lda(Lattice,Label,_):- !,error(Lattice,Label) error(Lattice,Label):- nl,write('"'), write(Label),write('" is not in lattice "'),write(Lattice),write('" !'),nl, abort('Error in lattice definition !'),nl /* - End of file lda.p */ File: cnf.p /* ANNOTATED LINGUISTIC LOGIC PROGRAMMING - ALLP ** File: cnf.p ** Date: 15/10/2003 ** Author: NGUYEN VAN NOI ** Contact: nvnoi@vtihcm.com.vn ** Copyright (C) 2003 ** Purpose: Convert linguitics expression with logical conectives to CNF ** and /\ , or \/ , not ~, implies => */ :- auto_table :- export normalize/2, flatten_and/2,combine_and/2, flatten_or/2,combine_or/2 :- import reverse/2 from basics :- import list_to_ord_set/2 from ordsets %% - Normalize(+Wff,-NormalClauses) -normalize(Wff,NormalClauses) :convert(Wff,S), cnF(S,NormalClauses) %% - Move negation inward -convert(~(~X), Y) :- !, convert(X, Y) convert(~(X /\ Y), A) :- !, convert((~X \/ ~Y), A) convert(~(X \/ Y), A) :- !, convert((~X /\ ~Y), A) 64 convert(~(X => Y), A) :- !, convert((X /\ ~Y), A) %% - Connectives -convert((X => Y), Q) :- !, convert((~X \/ Y), Q) convert((X /\ Y), (A /\ B)) :- !, convert(X, A), convert(Y, B) convert((X \/ Y), (A \/ B)) :- !, convert(X, A), convert(Y, B) %% - Logically atomic -convert(X,X) %% - Distribute -distriBute((X /\ Y) \/ Z, (X \/ Z) /\ (Y \/ Z),true) :- ! distriBute(X \/ (Y /\ Z), (X \/ Y) /\ (X \/ Z),true) :- ! distriBute(X,X,fail) %% - Conjunctive normal form -cnF((X /\ Y),(A /\ B)) :- !, cnF(X,A), cnF(Y,B) cnF((X \/ Y),G) :- !, cnF(X,A), cnF(Y,B), distriBute((A \/ B),F,Flag), (Flag -> cnF(F,G) %% More work may be needed ; G = F ) cnF(X,X) %% - make a sequence out of a conjunction flatten_and(X,F):normalize(X,L), flatten_andex(L,F) flatten_andex(X /\ Y, F) :- !, 65 flatten_andex(X,A), flatten_andex(Y,B), sequence_append(A,B,F) flatten_andex(X,[X]) %% - append two sequences sequence_append([X|R],S,[X|T]) :- !, sequence_append(R,S,T) sequence_append([],S,S) %% - combine a sequence in a conjunction -combine_and(X,L):reverse(X,X1), combine_andex(X1,L1), normalize(L1,L) combine_andex([X],X):-! combine_andex([X|L], A /\ X):- combine_andex(L,A) %% - make a sequence out of a disjunction flatten_or(X,F):normalize(X,L), flatten_orex(L,F1), list_to_ord_set(F1,F) flatten_orex(X \/ Y, F) :- !, flatten_orex(X,A), flatten_orex(Y,B), sequence_append(A,B,F) flatten_orex(X,[X]) %% - combine a sequence in a conjunction -combine_or(X,L):reverse(X,X1), combine_orex(X1,L1), normalize(L1,L) combine_orex([X],X):-! combine_orex([X|L], A \/ X):- combine_orex(L,A) /* - End of file cnf.p */ File: rdu.p /* ANNOTATED LINGUISTIC LOGIC PROGRAMMING - ALLP ** File: rdu.p ** Date: 19/10/2003 66 ** Author: NGUYEN VAN NOI ** Contact: nvnoi@vtihcm.com.vn ** Copyright (C) 2003 ** Purpose: simplify the linguistics expression with cnf*/ :- auto_table :- export reduce/3 :- import flatten_and/2,combine_and/2, flatten_or/2,combine_or/2 from cnf :- import lamda/3,la2p/2 from lda :- import list_to_ord_set/2 from ordsets reduce(Lattice,Lin,false):lamda(Lattice,Lin,[]),! reduce(Lattice,Lin,true):la2p(Lattice,LabelPower),lamda(Lattice,Lin,LabelPower),! reduce(Lattice,Lin,Lout):flatten_and(Lin,Land), treatlist(Lattice,Land,Land1), list_to_ord_set(Land1,Land2), combine_and(Land2,Lout) treatlist(Lattice,[X|L],L1):la2p(Lattice,LabelPower),lamda(Lattice,X,LabelPower),!,treatlist(Lattice,L,L1) treatlist(Lattice,[X|L],[X1|L1]):!, flatten_or(X,Xt), combine_or(Xt,X1), treatlist(Lattice,L,L1) treatlist(_,[],[]) /* - End of file rdu.p */ File: dfu.p /* ANNOTATED LINGUISTIC LOGIC PROGRAMMING - ALLP ** File: dfu.p ** Date: 17/10/2003 ** Author: NGUYEN VAN NOI ** Contact: nvnoi@vtihcm.com.vn ** Copyright (C) 2003 ** Purpose: Compute Approriateness degree and defuzzification */ :- auto_table :- import lamda/3 from lda :- import list_to_ord_set/2 from ordsets :- import memberchk/2,member/2 from basics 67 :- import ma/4 from usermod :- export apdeg/3, dispro/3, defu/3 maex(Lattice, LabelSubsetStd, Element, Value):ma(Lattice, LabelSubset,Element,Value), list_to_ord_set(LabelSubset,LabelSubsetStd) mambr(Lattice,LabelPowerSet,Element,Value):maex(Lattice, LabelSubsetStd, Element,Value), memberchk(LabelSubsetStd,LabelPowerSet) apdeg(Lattice,LinguisticsExpression, ListAppDeg):lamda(Lattice,LinguisticsExpression,AppSet), findall(Element,mambr(Lattice,AppSet,Element,_),L), list_to_ord_set(L,L1), findall([Element,Sum],(member(Element,L1),sumap(Lattice,AppSet,Element, Sum)),ListAppDeg) sumap(Lattice,AppSet,Element,Sum):findall(Value,mambr(Lattice,AppSet,Element,Value),ValueList), sumlist(ValueList,Sum) sumlist([],0) sumlist([X|L],S):sumlist(L,S1),S is S1+X dispro(Lattice,LinguisticsExpression, ListAppPro):apdeg(Lattice,LinguisticsExpression, ListAppDeg), sumlist2(ListAppDeg,Sum), proclist(ListAppDeg,Sum,ListAppPro) sumlist2([],0) sumlist2([[_,Value]|L],S):sumlist2(L,S1), S is S1+ Value proclist([],_,[]) proclist([[Element,Value]|L],Sum,[[Element,Proba]|L1]):Proba is Value / Sum , proclist(L,Sum, L1) defu(_,Var,na):var(Var),! defu(Lattice,LinguisticsExpression, RealValue):apdeg(Lattice,LinguisticsExpression, ListAppDeg), sumlist3(ListAppDeg,SumApp,SumPro), RealValue is SumPro /SumApp 68 sumlist3([],0,0) sumlist3([[Element,Value]|L],SumApp,SumPro):sumlist3(L,SumApp1,SumPro1), SumApp is Value + SumApp1, SumPro is Element * Value + SumPro1 /* - End of file dfu.p */ File: testa.p /* ANNOTATED LINGUISTIC LOGIC PROGRAMMING - ALLP ** File: testa.p ** Date: 15/10/2003 ** Author: NGUYEN VAN NOI ** Contact: nvnoi@vtihcm.com.vn ** Copyright (C) 2003 ** Purpose: An example for ALLP meta-interpreter */ %%la/2 - Lattice declarations : la(latticename, labelset) la(salary,[low, moderate, good, very_good]) la(year,[junior, experienced, senior]) %% ma/4 -Mass assignment declaration :ma(latticename, labelsubset, element, value ) ma(salary,[low],0,1) ma(salary,[low],1,1) ma(salary,[low,moderate],2,0.5) ma(salary,[],2,0.5) ma(salary,[moderate],3,1) ma(salary,[moderate],4,1) ma(salary,[moderate,good],5,0.5) ma(salary,[],5,0.5) ma(salary,[good],6,1) ma(salary,[good],7,1) ma(salary,[good,very_good],8,0.5) ma(salary,[],8,0.5) ma(salary,[very_good],9,1) ma(salary,[very_good],10,1) ma(year,[junior],0,1) ma(year,[junior],2.5,0.5) ma(year,[junior,experienced],2.5,0.5) ma(year,[junior,experienced],5,1) 69 ma(year,[junior,experienced],7.5,0.5) ma(year,[experienced],7.5,0.5) ma(year,[experienced],10,1) ma(year,[experienced,senior],12.5,0.5) ma(year,[experienced],12.5,0.5) ma(year,[experienced,senior],15,1) ma(year,[senior],17.5,0.5) ma(year,[experienced,senior],17.5,0.5) ma(year,[senior],20,1) ma(year,[senior],22.5,1) ma(year,[senior],25,1) ma(year,[senior],27.5,1) ma(year,[senior],30,1) ma(year,[senior],32.5,1) ma(year,[senior],35,1) ma(year,[senior],37.5,1) ma(year,[senior],40,1) %% cr/3 - Comformity relations : cr(term,arity,latticename) cr(sal,1,salary) cr(yrs,1,year) %% Clauses /*Senior project managers have good or very good salaries.*/ sal(X):[good \/ very_good]

Ngày đăng: 18/02/2021, 08:01

Tài liệu cùng người dùng

Tài liệu liên quan