Skip to content

Commit

Permalink
Add notes for 8B lecture (SICP)
Browse files Browse the repository at this point in the history
The implementation on the Logic Programming II of the query
language, rule-based using pattern matching makes assumptions about
earlier codes from old lectures. I just keep a general copy-paste
notes from the videos make my own reasoning.

Is curious case. The NOT from a query rule-based system is
different from the NOT LOGICAL. The closed system doesn't build
all the knowledge possible. The NOT from query is a filter, making
a equivalent procedure for the NOT operation on Set Theory, the
complements of a set.

Hmmm... consistency on a closed world. Maybe is this was the initial
insights with Godel on the Incompletude Theorem?

... Who cares.
  • Loading branch information
ryukinix committed Jan 28, 2017
1 parent b6a96f2 commit 2ce324f
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The actual content are answers and code covering the book [Land of Lisp](http://
- [x] Lecture 7A
- [x] Lecture 7B
- [x] Lecture 8A
- [ ] Lecture 8B
- [x] Lecture 8B
- [ ] Lecture 9A
- [ ] Lecture 9B
- [ ] Lecture 10A
Expand Down
105 changes: 105 additions & 0 deletions mit-6.001/8B-logic-programming-II.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
;; Common Lisp Script
;; Manoel Vilela

;; sample patterns

#|
(a ?x c)
(job ?x (computer ?y))
(job ?x (computer . ?y))
(a ?x ?x)
(?x ?y ?y ?x)
(a . ?x)
|#

;; rule-based system for logic programming using
;; patter matching

(load "4A-pattern-matching.lisp")
(match pat data dictionary) ;; needs implements match
;; in earlier lectures, the primitives for pattern matching
;; is implemented

;; query black box

;; ↓ pattern
;; +-------+
;; | |
;; => initial-dict | QUERY | => dictionary
;; | |
;; +-------+
;; ↑ database stream


;; means of combinations: NOT, AND, OR

;; means of abstraction: rules

(rule (boss ?z ?d)
(and (job ?x (?d . ?y))
(supervisor (?x ?z))))


;; == TO APPLY A RULE

;; Evaluate the rule body relative to an environment
;; formed by unifying the rule conclusion with the
;; given query.


;; == TO APPLY A PROCEDURE

;; Evaluate the procedure body relative to an enviroment
;; formed by binding the procedure paramaters to the
;; to the arguments.


;; All humans are mortals
;; All greeks are humans.
;; Socrates is greek,
;;------ syllogism logic ----
;; :: Socrates is mortal.


(Greek Socrates)
(Greek Plato)
(Greek Zeus)
(god Zeus)

(rule (mortal ?x) (human ?x))
(rule (fallible ?x) (human ?x))

(rule (human ?x)
(and (Greek ?x) (not (god ?x))))

(rule (address ?x Olympus)
(and (greek ?x) (god ?x)))

(rule (perfect ?x)
(and (not (mortal ?x))
(not (fallible ?x))))

(and (address ?x ?y)
(perfect ?x)) ;; => Mount Olympus (Zeus)

(and (perfect ?x)
(address ?x ?y)) ;; Nothing


;; But who is right? We can makes assumption of our
;; data here about that: Zeus is not mortal, Zeus
;; is not mortal, just because he is not human?
;; This is not sufficient information.

;; NOT here is NOT from the logic!
;; The NOT here is a filter of a closed world,
;; the complements of a assumption.
;; Logic makes assumptions of only two states.
;; This is a big problem.

0 comments on commit 2ce324f

Please sign in to comment.