code for unevaluated Boolean and conditional express ions
Subject: code for unevaluated Boolean and conditional express ions
From: Rogers, Raymond
Date: Fri, 5 May 2006 13:12:07 -0400
> -----Original Message-----
> From: BIOMATES at telefonica.net [mailto:BIOMATES at telefonica.net]
>
> Either cat fur or dog fur was found at the scene of the crime. If dog
> fur was found at the scene of the crime, officer Thompson had an
> allergy
> attack. If cat fur was found at the scene of the crime, then Macavity
> is
> responsibile for the crime. But officer Thompson didn't have an
> allergy
> attack, and so therefore Macavity must be responsible for the crime.
>
>
> Now, let's define some variables:
> p: cat fur was found at the scene of the crime,
> q: dog fur was found at the scene of the crime,
> r: officer Thompson had an allergy attack,
> s: Macavity is responsible for the crime
>
>
> Premise #1: p or q
> Premise #2: q => r
> Premise #3: p => s
> Premise #4: not r
>
> Question: is Macavity responsible for the crime?
>
> /********** begin Maxima session ********/
>
> (%i1) load("~/Desktop/boolsimp.lisp")$
> (%i2) /* I define the conditional operator */
> "=>"(r,s):= not r or s $ infix("=>") $
> (%i4) /* Checks for the validity of */
> /* ante => conse by means of */
> /* the truth table. */
> implies(ante, conse, listvar):=
> block([expr,npos,maxn,combis:[],bits,quot,div],
> npos: length(listvar),
> maxn: 2^npos - 1,
> expr: not ante or conse,
> for i:0 thru maxn do(
> bits:[],
> quot:i,
> for j:1 thru npos do(
> div: divide(quot, 2),
> quot: div[1],
> bits: cons(listvar[j]=div[2],bits) ),
> combis: cons( subst([1=true,0=false],bits), combis)),
> apply("and", makelist(subst(k,expr),k,combis)) )$
> (%i5) /* Let's know who's the criminal */
> implies((p or q) and (q => r) and (p => s) and not r,s,
> [p,q,r,s]);
> (%o5) true
>
> /********** end Maxima session ********/
>
> Lawyers will find your 'boolsimp' package very useful !
>
Can we make it part of the BAR exam?
Could we make our politicians take it? Sort of a politician poll test.
(from the USA)
RRogers