Wednesday, November 09, 2005

Nếu tôi còn sống thì tôi đã chết!

Một lần nữa, quay trở lại với Lô-gíc hình thức và các mâu thuẫn "tự phủ định"!

Bạn thử nghĩ xem mệnh đề sau đây đúng hay sai:

"Nếu tôi còn sống thì tôi đã chết"

(biết rằng "tôi còn sống" = ¬"tôi đã chết")

Chắc hẳn là nó phải Sai, đúng không nào?!
Nhưng bạn thử nghĩ lại một lần nữa xem, có thay đổi quyết định không? ;-)
.
.
.
Bây giờ chúng ta thử dùng lô-gíc hình thức để xem xét nhé.

Đặt
P = "Nếu tôi còn sống thì tôi đã chết"
Q = "Tôi còn sống"

"tôi còn sống" = ¬"tôi đã chết"
Nên
P = Q → ¬Q
Dùng công thức
A→B = ¬A ∨ B
Ta có
P = Q → ¬Q
= ¬Q ∨ ¬Q
= ¬Q
Kết luận
P = ¬Q
= "tôi đã chết"

Vậy mệnh đề này không (hằng)đúng mà cũng không (hằng)sai, nó tương đương với mệnh đề con đơn giản hơn là "tôi đã chết".
Nếu bạn muốn "chơi khăm", có thể làm cho mệnh đề khó hơn bằng cách kéo dài nó ra thành:

"Mệnh đề 'Nếu tôi còn sống thì tôi đã chết' mà sai, thì tôi chết mất!"
(biết rằng "tôi còn sống" = ¬"tôi đã chết" = ¬"tôi chết mất")

Dùng lô-gíc hình thức phân tích thì ta thấy mệnh đề này có dạng:

R = ¬(Q→¬Q) → ¬Q
= Q → ¬Q
= ¬Q

Và theo lý thuyết, bạn có thể kéo dài ra mãi!

Liên tưởng tới Vật lý Lượng tử, ta có thể thấy nó có liên quan đến còn mèo "dở sống dở chết" của Schrödinger(Schrödinger's cat).


Hoặc nghĩ về Lý thuyết Tính trong Tin học, thì ta nhận ra ngay lớp bài toán "không giải được"(bài toán "dừng") nổi tiếng(Halting problem). Tính "không giải được" được chứng minh nhờ luận đề Turing-Church(Turing-Church thesis).

Còn bây giờ thì mình bỗng nhớ lại một bài toán lô-gíc hấp dẫn mà mình đã được học từ hơn chục năm trước (hình như là hồi lớp 5), bài "Treo cổ - Chặt đầu":

Ngày xửa ngày xưa, ở một vương quốc nọ, có một ông vua độc ác cai trị nhân dân một cách tàn nhẫn và bất công khiến cho nhiều người trong nước đó cứ lũ lượt kéo nhau bỏ sang nước khác hết... Thế là ông vua ấy mới ban hành một điều luật thật quái đản vô nhân đạo rằng: "Ai muốn ra ngoài biên giới thì phải nói một câu. Nếu câu ấy Đúng thì sẽ bị Chặt đầu. Còn nếu câu ấy Sai thì sẽ bị Treo cổ." Từ đó, chẳng còn ái dám bén mảng ra ngoài biên giới nữa.
Ông ta tưởng như thế là đã thành công rồi! Nhưng nào ngờ, một ngày kia, có một nhà thông thái vẫn cứ ung dung bước chân ra vùng biên giới.... Lính gác gặp nhà thông thái thì chặn lại bảo: "Ông già ngạo mạn kia, hãy nói một câu xem nào".
--Tới đây, hỡi các nhà thông thái của chúng ta hãy thử nghĩ xem nên nói câu gì nào? :-?-- .............Nhà thông thái không chùn bước, vừa đi vừa nói: "Ta sẽ bị treo cổ!"... Thế là lính gác cùng các quan binh đều phải để cho ông đi. Đem câu đó tâu lên vua, cả triều đình cũng phải... bó tay! :-))

Monday, October 17, 2005

XUL - XML User Interface Language

XUL Project at Mozilla
Wow, thanks to Trung, I've just known about this new lang!
The amazing/confusing point is, that it somehow coincides with my idea of a "discriptive language" for GUI designing: a language for discribing all of the GUI components ("forground") in a style like XML, and has links to the behaviors "background" built in other "normal" programming languages.

Friday, October 14, 2005

Java Look-and-feels

Most of the Java Look-and-feels can be found at javootoo.com. Belowing is some notable ones.

Sunday, August 07, 2005

InfoNode - a cOoL Swing GUI

http://www.infonode.net/ is an open-source project which provides very cool GUI:
  • (advanced) Tabbed panel
  • (super) Docking window
  • and also with a cool Look-and-feel

Just try, you will like it!

Saturday, August 06, 2005

No "unsigned" int. in Java, NOP!

Nop! wob!

After a long long time working with Java, now I have "discovered" that there really NO UNSIGNED integer type there! E'ry int., byte(8b), short(16b), int(32b) and long(64b) is signED one ! :-?

The more surprising thing is that, there is no pre-built method for casting signed one to unsigned one, either !

Friday, August 05, 2005

Big-endian Vs. Little-endian

The mnemonics are that:

  • big-endian = "big-end-first" : 0x0201 --> 02,01
  • little-endian = "litle-end-first": 0x0201 --> 01,02

Mostly because of the nature of World's languages and of the world-wide used Arabic-numeral system, the Internet Protocol defines a standard "big-endian" network byte order.

To summarize, here are the default endian-formats of some common computer architectures:

It is interesting that... the very terms big-endian and little-endian were taken from the Big-Endians and Little-Endians of Jonathan Swift's novel Gulliver's Travels, two groups of people in conflict over which end of an egg to crack in the voyage to Lilliput and Blefuscu.

Thursday, June 30, 2005

Java applets can communicate with each other easily !

There are 2 ways to do inter-applet communication:

  • the basic way is to use the methods getApplet(), getApplets() in java.applet.AppletContext. An AppletContext can be fetched using method java.appet.Applet.getAppletContext(). This way is only for applets on the same page.


  • the "trick" way is to use a (shared) public static reference to store the reference to this Applet object instance, then other applet can simply access this applet through this reference. This way is only for applets with the same codebase (codebase attribute in APPLET tag).


ref: An alternative way for applet-to-applet communication

Sunday, May 15, 2005

Java GUIs

Glazed Lists - A toolkit for list transformations: Sort & Filter, Display a list in a JTable, JList or JComboBox, ect.

Laziness, the virtue !

Color Schemes and UIDefaults: "We all know that laziness is a virtue (at least for a programmer). "

Thursday, May 12, 2005

"PRN" file name on Windows

Windows NT 4.0, 95, 98 (?) networked PRN flaw

I suppose that, in an effort to maintain reverse compatibility with
old MS-DOS command line gurus, you cannot create a file or directory
named PRN.xxx where the xxx is replacable with any extension.
Old style MS-DOS command line-ing would allow you to do the following
to print your autoexec file:
C:\>copy autoexec.bat prn
what this actually does is redirect the contents of autoexec.bat to
the port LPT1.
...

Wednesday, January 12, 2005

What is a "Lang Spec" ?

...a complete specification of the syntax and semantics of the language. We intend that the behavior of every language construct is specified here, so that all implementations will accept the same programs. Except for timing dependencies or other non-determinisms and given sufficient time and sufficient memory space, a program written in the Java programming language should compute the same result on all machines and in all implementations.


The Java Language Specification

Thursday, January 06, 2005

Drawbacks to XML

XML : Java Glossary: "The primary function of XML is to consume RAM and datacommunication bandwidth. Presumably it was promoted to its current frenzy by companies who sell either RAM or bandwidth. Others promoting it have patents they hope to spring on the public once it is entrenched..."